Update all to eol-style: native, also fixes #1645
git-svn-id: http://svn.automattic.com/wordpress/trunk@3061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
fe1e8af589
commit
b7f5af4551
|
@ -1,24 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
require_once('../wp-config.php');
|
require_once('../wp-config.php');
|
||||||
require_once('admin-functions.php');
|
require_once('admin-functions.php');
|
||||||
require_once('admin-db.php');
|
require_once('admin-db.php');
|
||||||
|
|
||||||
get_currentuserinfo();
|
get_currentuserinfo();
|
||||||
|
|
||||||
if ( !current_user_can('manage_categories') )
|
if ( !current_user_can('manage_categories') )
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
function get_out_now() { exit; }
|
function get_out_now() { exit; }
|
||||||
|
|
||||||
add_action('shutdown', 'get_out_now', -1);
|
add_action('shutdown', 'get_out_now', -1);
|
||||||
|
|
||||||
$cat_name = rawurldecode($_GET['ajaxnewcat']);
|
$cat_name = rawurldecode($_GET['ajaxnewcat']);
|
||||||
|
|
||||||
if ( !$category_nicename = sanitize_title($cat_name) )
|
if ( !$category_nicename = sanitize_title($cat_name) )
|
||||||
die('0');
|
die('0');
|
||||||
if ( $already = category_exists($cat_name) )
|
if ( $already = category_exists($cat_name) )
|
||||||
die((string) $already);
|
die((string) $already);
|
||||||
|
|
||||||
$new_cat_id = wp_create_category($cat_name);
|
$new_cat_id = wp_create_category($cat_name);
|
||||||
die((string) $new_cat_id);
|
die((string) $new_cat_id);
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1,451 +1,451 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
require_once('admin.php');
|
require_once('admin.php');
|
||||||
|
|
||||||
if (!current_user_can('edit_posts'))
|
if (!current_user_can('edit_posts'))
|
||||||
die(__('You do not have permission to edit posts.'));
|
die(__('You do not have permission to edit posts.'));
|
||||||
|
|
||||||
$wpvarstoreset = array('action', 'post', 'all', 'last', 'link', 'sort', 'start', 'imgtitle', 'descr', 'object', 'flickrtag');
|
$wpvarstoreset = array('action', 'post', 'all', 'last', 'link', 'sort', 'start', 'imgtitle', 'descr', 'object', 'flickrtag');
|
||||||
|
|
||||||
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
|
for ($i=0; $i<count($wpvarstoreset); $i += 1) {
|
||||||
$wpvar = $wpvarstoreset[$i];
|
$wpvar = $wpvarstoreset[$i];
|
||||||
if (!isset($$wpvar)) {
|
if (!isset($$wpvar)) {
|
||||||
if (empty($_POST["$wpvar"])) {
|
if (empty($_POST["$wpvar"])) {
|
||||||
if (empty($_GET["$wpvar"])) {
|
if (empty($_GET["$wpvar"])) {
|
||||||
$$wpvar = '';
|
$$wpvar = '';
|
||||||
} else {
|
} else {
|
||||||
$$wpvar = $_GET["$wpvar"];
|
$$wpvar = $_GET["$wpvar"];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$$wpvar = $_POST["$wpvar"];
|
$$wpvar = $_POST["$wpvar"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$post = (int) $post;
|
$post = (int) $post;
|
||||||
$images_width = 1;
|
$images_width = 1;
|
||||||
|
|
||||||
function get_udims($width, $height) {
|
function get_udims($width, $height) {
|
||||||
if ( $height <= 96 && $width <= 128 )
|
if ( $height <= 96 && $width <= 128 )
|
||||||
return array($width, $height);
|
return array($width, $height);
|
||||||
elseif ( $width / $height > 4 / 3 )
|
elseif ( $width / $height > 4 / 3 )
|
||||||
return array(128, (int) ($height / $width * 128));
|
return array(128, (int) ($height / $width * 128));
|
||||||
else
|
else
|
||||||
return array((int) ($width / $height * 96), 96);
|
return array((int) ($width / $height * 96), 96);
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($action) {
|
switch($action) {
|
||||||
case 'delete':
|
case 'delete':
|
||||||
|
|
||||||
wp_delete_object($object);
|
wp_delete_object($object);
|
||||||
|
|
||||||
header("Location: ".basename(__FILE__)."?post=$post&all=$all&action=view&start=$start");
|
header("Location: ".basename(__FILE__)."?post=$post&all=$all&action=view&start=$start");
|
||||||
die;
|
die;
|
||||||
|
|
||||||
case 'save':
|
case 'save':
|
||||||
|
|
||||||
$overrides = array('action'=>'save');
|
$overrides = array('action'=>'save');
|
||||||
|
|
||||||
$file = wp_handle_upload($_FILES['image'], $overrides);
|
$file = wp_handle_upload($_FILES['image'], $overrides);
|
||||||
|
|
||||||
if ( isset($file['error']) )
|
if ( isset($file['error']) )
|
||||||
die($file['error'] . '<a href="' . basename(__FILE__) . '?action=upload&post="' . $post . '">Back to Image Uploading</a>');
|
die($file['error'] . '<a href="' . basename(__FILE__) . '?action=upload&post="' . $post . '">Back to Image Uploading</a>');
|
||||||
|
|
||||||
$url = $file['url'];
|
$url = $file['url'];
|
||||||
$file = $file['file'];
|
$file = $file['file'];
|
||||||
$filename = basename($file);
|
$filename = basename($file);
|
||||||
|
|
||||||
// Construct the object array
|
// Construct the object array
|
||||||
$object = array(
|
$object = array(
|
||||||
'post_title' => $imgtitle ? $imgtitle : $filename,
|
'post_title' => $imgtitle ? $imgtitle : $filename,
|
||||||
'post_content' => $descr,
|
'post_content' => $descr,
|
||||||
'post_status' => 'object',
|
'post_status' => 'object',
|
||||||
'post_parent' => $post,
|
'post_parent' => $post,
|
||||||
'post_type' => $_FILES['image']['type'],
|
'post_type' => $_FILES['image']['type'],
|
||||||
'guid' => $url
|
'guid' => $url
|
||||||
);
|
);
|
||||||
|
|
||||||
// Save the data
|
// Save the data
|
||||||
$id = wp_attach_object($object, $post);
|
$id = wp_attach_object($object, $post);
|
||||||
|
|
||||||
// Generate the object's postmeta.
|
// Generate the object's postmeta.
|
||||||
$imagesize = getimagesize($file);
|
$imagesize = getimagesize($file);
|
||||||
$imagedata['width'] = $imagesize['0'];
|
$imagedata['width'] = $imagesize['0'];
|
||||||
$imagedata['height'] = $imagesize['1'];
|
$imagedata['height'] = $imagesize['1'];
|
||||||
list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']);
|
list($uwidth, $uheight) = get_udims($imagedata['width'], $imagedata['height']);
|
||||||
$imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'";
|
$imagedata['hwstring_small'] = "height='$uheight' width='$uwidth'";
|
||||||
$imagedata['file'] = $file;
|
$imagedata['file'] = $file;
|
||||||
$imagedata['thumb'] = "thumb-$filename";
|
$imagedata['thumb'] = "thumb-$filename";
|
||||||
|
|
||||||
add_post_meta($id, 'imagedata', $imagedata);
|
add_post_meta($id, 'imagedata', $imagedata);
|
||||||
|
|
||||||
if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {
|
if ( $imagedata['width'] * $imagedata['height'] < 3 * 1024 * 1024 ) {
|
||||||
if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
|
if ( $imagedata['width'] > 128 && $imagedata['width'] >= $imagedata['height'] * 4 / 3 )
|
||||||
$error = wp_create_thumbnail($file['file'], 128);
|
$error = wp_create_thumbnail($file['file'], 128);
|
||||||
elseif ( $imagedata['height'] > 96 )
|
elseif ( $imagedata['height'] > 96 )
|
||||||
$error = wp_create_thumbnail($file, 96);
|
$error = wp_create_thumbnail($file, 96);
|
||||||
}
|
}
|
||||||
|
|
||||||
header("Location: ".basename(__FILE__)."?post=$post&all=$all&action=view&last=true");
|
header("Location: ".basename(__FILE__)."?post=$post&all=$all&action=view&last=true");
|
||||||
die;
|
die;
|
||||||
|
|
||||||
case 'upload':
|
case 'upload':
|
||||||
|
|
||||||
$current_1 = ' class="current"';
|
$current_1 = ' class="current"';
|
||||||
$back = $next = false;
|
$back = $next = false;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'view':
|
case 'view':
|
||||||
|
|
||||||
// How many images do we show? How many do we query?
|
// How many images do we show? How many do we query?
|
||||||
$num = 5;
|
$num = 5;
|
||||||
$double = $num * 2;
|
$double = $num * 2;
|
||||||
|
|
||||||
if ( $post && empty($all) ) {
|
if ( $post && empty($all) ) {
|
||||||
$and_post = "AND post_parent = '$post'";
|
$and_post = "AND post_parent = '$post'";
|
||||||
$current_2 = ' class="current"';
|
$current_2 = ' class="current"';
|
||||||
} else {
|
} else {
|
||||||
$current_3 = ' class="current"';
|
$current_3 = ' class="current"';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $last )
|
if ( $last )
|
||||||
$start = $wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_status = 'object' AND left(post_type, 5) = 'image' $and_post") - $num;
|
$start = $wpdb->get_var("SELECT count(ID) FROM $wpdb->posts WHERE post_status = 'object' AND left(post_type, 5) = 'image' $and_post") - $num;
|
||||||
else
|
else
|
||||||
$start = (int) $start;
|
$start = (int) $start;
|
||||||
|
|
||||||
if ( $start < 0 )
|
if ( $start < 0 )
|
||||||
$start = 0;
|
$start = 0;
|
||||||
|
|
||||||
if ( '' == $sort )
|
if ( '' == $sort )
|
||||||
$sort = "ID";
|
$sort = "ID";
|
||||||
|
|
||||||
$images = $wpdb->get_results("SELECT ID, post_date, post_title, guid FROM $wpdb->posts WHERE post_status = 'object' AND left(post_type, 5) = 'image' $and_post ORDER BY $sort LIMIT $start, $double", ARRAY_A);
|
$images = $wpdb->get_results("SELECT ID, post_date, post_title, guid FROM $wpdb->posts WHERE post_status = 'object' AND left(post_type, 5) = 'image' $and_post ORDER BY $sort LIMIT $start, $double", ARRAY_A);
|
||||||
|
|
||||||
if ( count($images) > $num ) {
|
if ( count($images) > $num ) {
|
||||||
$next = $start + count($images) - $num;
|
$next = $start + count($images) - $num;
|
||||||
} else {
|
} else {
|
||||||
$next = false;
|
$next = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $start > 0 ) {
|
if ( $start > 0 ) {
|
||||||
$back = $start - $num;
|
$back = $start - $num;
|
||||||
if ( $back < 1 )
|
if ( $back < 1 )
|
||||||
$back = '0';
|
$back = '0';
|
||||||
} else {
|
} else {
|
||||||
$back = false;
|
$back = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$i = 0;
|
$i = 0;
|
||||||
$uwidth_sum = 0;
|
$uwidth_sum = 0;
|
||||||
$images_html = '';
|
$images_html = '';
|
||||||
$images_style = '';
|
$images_style = '';
|
||||||
$images_script = '';
|
$images_script = '';
|
||||||
if ( count($images) > 0 ) {
|
if ( count($images) > 0 ) {
|
||||||
$images = array_slice( $images, 0, $num );
|
$images = array_slice( $images, 0, $num );
|
||||||
$__delete = __('DELETE');
|
$__delete = __('DELETE');
|
||||||
$__subpost_on = __('SUBPOST <strong>ON</strong>');
|
$__subpost_on = __('SUBPOST <strong>ON</strong>');
|
||||||
$__subpost_off = __('SUBPOST <strong>OFF</strong>');
|
$__subpost_off = __('SUBPOST <strong>OFF</strong>');
|
||||||
$__thumbnail_on = __('THUMBNAIL <strong>ON</strong>');
|
$__thumbnail_on = __('THUMBNAIL <strong>ON</strong>');
|
||||||
$__thumbnail_off = __('THUMBNAIL <strong>OFF</strong>');
|
$__thumbnail_off = __('THUMBNAIL <strong>OFF</strong>');
|
||||||
$__no_thumbnail = __('<del>THUMBNAIL</del>');
|
$__no_thumbnail = __('<del>THUMBNAIL</del>');
|
||||||
$__close = __('CLOSE');
|
$__close = __('CLOSE');
|
||||||
$__confirmdelete = __('Delete this photo from the server?');
|
$__confirmdelete = __('Delete this photo from the server?');
|
||||||
$__nothumb = __('There is no thumbnail associated with this photo.');
|
$__nothumb = __('There is no thumbnail associated with this photo.');
|
||||||
$images_script .= "subposton = '$__subpost_on';\nsubpostoff = '$__subpost_off';\n";
|
$images_script .= "subposton = '$__subpost_on';\nsubpostoff = '$__subpost_off';\n";
|
||||||
$images_script .= "thumbnailon = '$__thumbnail_on';\nthumbnailoff = '$__thumbnail_off';\n";
|
$images_script .= "thumbnailon = '$__thumbnail_on';\nthumbnailoff = '$__thumbnail_off';\n";
|
||||||
foreach ( $images as $key => $image ) {
|
foreach ( $images as $key => $image ) {
|
||||||
$meta = get_post_meta($image['ID'], 'imagedata', true);
|
$meta = get_post_meta($image['ID'], 'imagedata', true);
|
||||||
if (!is_array($meta)) {
|
if (!is_array($meta)) {
|
||||||
wp_delete_object($image['ID']);
|
wp_delete_object($image['ID']);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$image = array_merge($image, $meta);
|
$image = array_merge($image, $meta);
|
||||||
if ( ($image['width'] > 128 || $image['height'] > 96) && !empty($image['thumb']) && file_exists(dirname($image['file']).'/'.$image['thumb']) ) {
|
if ( ($image['width'] > 128 || $image['height'] > 96) && !empty($image['thumb']) && file_exists(dirname($image['file']).'/'.$image['thumb']) ) {
|
||||||
$src = str_replace(basename($image['guid']), '', $image['guid']) . $image['thumb'];
|
$src = str_replace(basename($image['guid']), '', $image['guid']) . $image['thumb'];
|
||||||
$images_script .= "src".$i."a = '$src';\nsrc".$i."b = '".$image['guid']."';\n";
|
$images_script .= "src".$i."a = '$src';\nsrc".$i."b = '".$image['guid']."';\n";
|
||||||
$thumb = 'true';
|
$thumb = 'true';
|
||||||
$thumbtext = $__thumbnail_on;
|
$thumbtext = $__thumbnail_on;
|
||||||
} else {
|
} else {
|
||||||
$src = $image['guid'];
|
$src = $image['guid'];
|
||||||
$thumb = 'false';
|
$thumb = 'false';
|
||||||
$thumbtext = $__no_thumbnail;
|
$thumbtext = $__no_thumbnail;
|
||||||
}
|
}
|
||||||
list($image['uwidth'], $image['uheight']) = get_udims($image['width'], $image['height']);
|
list($image['uwidth'], $image['uheight']) = get_udims($image['width'], $image['height']);
|
||||||
$height_width = 'height="'.$image['uheight'].'" width="'.$image['uwidth'].'"';
|
$height_width = 'height="'.$image['uheight'].'" width="'.$image['uwidth'].'"';
|
||||||
$uwidth_sum += 128;
|
$uwidth_sum += 128;
|
||||||
$xpadding = (128 - $image['uwidth']) / 2;
|
$xpadding = (128 - $image['uwidth']) / 2;
|
||||||
$ypadding = (96 - $image['uheight']) / 2;
|
$ypadding = (96 - $image['uheight']) / 2;
|
||||||
$object = $image['ID'];
|
$object = $image['ID'];
|
||||||
$images_style .= "#target$i img { padding: {$ypadding}px {$xpadding}px; }\n";
|
$images_style .= "#target$i img { padding: {$ypadding}px {$xpadding}px; }\n";
|
||||||
$href = get_subpost_link($object);
|
$href = get_subpost_link($object);
|
||||||
$images_script .= "href".$i."a = '$href';\nhref".$i."b = '{$image['guid']}';\n";
|
$images_script .= "href".$i."a = '$href';\nhref".$i."b = '{$image['guid']}';\n";
|
||||||
$images_html .= "
|
$images_html .= "
|
||||||
<div id='target$i' class='imagewrap left'>
|
<div id='target$i' class='imagewrap left'>
|
||||||
<div id='popup$i' class='popup'>
|
<div id='popup$i' class='popup'>
|
||||||
<a id=\"L$i\" onclick=\"toggleLink($i);return false;\" href=\"javascript:void();\">$__subpost_on</a>
|
<a id=\"L$i\" onclick=\"toggleLink($i);return false;\" href=\"javascript:void();\">$__subpost_on</a>
|
||||||
<a id=\"I$i\" onclick=\"if($thumb)toggleImage($i);else alert('$__nothumb');return false;\" href=\"javascript:void();\">$thumbtext</a>
|
<a id=\"I$i\" onclick=\"if($thumb)toggleImage($i);else alert('$__nothumb');return false;\" href=\"javascript:void();\">$thumbtext</a>
|
||||||
<a onclick=\"return confirm('$__confirmdelete')\" href=\"".basename(__FILE__)."?action=delete&object=$object&all=$all&start=$start&post=$post\">$__delete</a>
|
<a onclick=\"return confirm('$__confirmdelete')\" href=\"".basename(__FILE__)."?action=delete&object=$object&all=$all&start=$start&post=$post\">$__delete</a>
|
||||||
<a onclick=\"popup.style.display='none';return false;\" href=\"javascript:void()\">$__close</a>
|
<a onclick=\"popup.style.display='none';return false;\" href=\"javascript:void()\">$__close</a>
|
||||||
</div>
|
</div>
|
||||||
<a id=\"link$i\" class=\"imagelink\" href=\"$href\" onclick=\"imagePopup($i);return false;\" title=\"{$image['post_title']}\">
|
<a id=\"link$i\" class=\"imagelink\" href=\"$href\" onclick=\"imagePopup($i);return false;\" title=\"{$image['post_title']}\">
|
||||||
<img id='image$i' src='$src' alt='{$image['post_title']}' $height_width />
|
<img id='image$i' src='$src' alt='{$image['post_title']}' $height_width />
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
";
|
";
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$images_width = $uwidth_sum + ( count($images) * 5 ) + 30;
|
$images_width = $uwidth_sum + ( count($images) * 5 ) + 30;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
die('This script was not meant to be called directly.');
|
die('This script was not meant to be called directly.');
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
<!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">
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||||
<head>
|
<head>
|
||||||
<meta http-equiv="imagetoolbar" content="no" />
|
<meta http-equiv="imagetoolbar" content="no" />
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
/* Define any variables we'll need, such as alternate URLs. */
|
/* Define any variables we'll need, such as alternate URLs. */
|
||||||
<?php echo $images_script; ?>
|
<?php echo $images_script; ?>
|
||||||
|
|
||||||
function validateImageName() {
|
function validateImageName() {
|
||||||
/* This is more for convenience than security. Server-side validation is very thorough.*/
|
/* This is more for convenience than security. Server-side validation is very thorough.*/
|
||||||
obj = document.getElementById('upload');
|
obj = document.getElementById('upload');
|
||||||
r = /.jpg$|.gif$|.png$/i;
|
r = /.jpg$|.gif$|.png$/i;
|
||||||
if ( obj.value.match(r) )
|
if ( obj.value.match(r) )
|
||||||
return true;
|
return true;
|
||||||
alert('Please select a JPG, PNG or GIF file.');
|
alert('Please select a JPG, PNG or GIF file.');
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
function cancelUpload() {
|
function cancelUpload() {
|
||||||
o = document.getElementById('uploadForm');
|
o = document.getElementById('uploadForm');
|
||||||
o.method = 'GET';
|
o.method = 'GET';
|
||||||
o.action.value = 'view';
|
o.action.value = 'view';
|
||||||
o.submit();
|
o.submit();
|
||||||
}
|
}
|
||||||
function imagePopup(i) {
|
function imagePopup(i) {
|
||||||
if ( popup )
|
if ( popup )
|
||||||
popup.style.display = 'none';
|
popup.style.display = 'none';
|
||||||
target = document.getElementById('target'+i);
|
target = document.getElementById('target'+i);
|
||||||
popup = document.getElementById('popup'+i);
|
popup = document.getElementById('popup'+i);
|
||||||
//popup.style.top = (target.offsetTop + 3) + 'px';
|
//popup.style.top = (target.offsetTop + 3) + 'px';
|
||||||
popup.style.left = (target.offsetLeft) + 'px';
|
popup.style.left = (target.offsetLeft) + 'px';
|
||||||
popup.style.display = 'block';
|
popup.style.display = 'block';
|
||||||
}
|
}
|
||||||
function init() {
|
function init() {
|
||||||
popup = false;
|
popup = false;
|
||||||
}
|
}
|
||||||
function toggleLink(n) {
|
function toggleLink(n) {
|
||||||
o=document.getElementById('link'+n);
|
o=document.getElementById('link'+n);
|
||||||
oi=document.getElementById('L'+n);
|
oi=document.getElementById('L'+n);
|
||||||
if ( oi.innerHTML == subposton ) {
|
if ( oi.innerHTML == subposton ) {
|
||||||
o.href = eval('href'+n+'b');
|
o.href = eval('href'+n+'b');
|
||||||
oi.innerHTML = subpostoff;
|
oi.innerHTML = subpostoff;
|
||||||
} else {
|
} else {
|
||||||
o.href = eval('href'+n+'a');
|
o.href = eval('href'+n+'a');
|
||||||
oi.innerHTML = subposton;
|
oi.innerHTML = subposton;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function toggleImage(n) {
|
function toggleImage(n) {
|
||||||
o = document.getElementById('image'+n);
|
o = document.getElementById('image'+n);
|
||||||
oi = document.getElementById('I'+n);
|
oi = document.getElementById('I'+n);
|
||||||
if ( oi.innerHTML == thumbnailon ) {
|
if ( oi.innerHTML == thumbnailon ) {
|
||||||
o.src = eval('src'+n+'b');
|
o.src = eval('src'+n+'b');
|
||||||
oi.innerHTML = thumbnailoff;
|
oi.innerHTML = thumbnailoff;
|
||||||
} else {
|
} else {
|
||||||
o.src = eval('src'+n+'a');
|
o.src = eval('src'+n+'a');
|
||||||
oi.innerHTML = thumbnailon;
|
oi.innerHTML = thumbnailon;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
<style type="text/css">
|
<style type="text/css">
|
||||||
body {
|
body {
|
||||||
font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
|
font: 13px "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana;
|
||||||
border: none;
|
border: none;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
height: 150px;
|
height: 150px;
|
||||||
background: rgb(223, 232, 241);
|
background: rgb(223, 232, 241);
|
||||||
}
|
}
|
||||||
form {
|
form {
|
||||||
margin: 6px 2px 0px 6px;
|
margin: 6px 2px 0px 6px;
|
||||||
}
|
}
|
||||||
#wrap {
|
#wrap {
|
||||||
clear: both;
|
clear: both;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
height: 133px;
|
height: 133px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
overflow: auto;
|
overflow: auto;
|
||||||
}
|
}
|
||||||
#images {
|
#images {
|
||||||
clear: both;
|
clear: both;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
padding: 5px 15px;
|
padding: 5px 15px;
|
||||||
height: 96px;
|
height: 96px;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
width: <?php echo $images_width; ?>px;
|
width: <?php echo $images_width; ?>px;
|
||||||
}
|
}
|
||||||
#images img {
|
#images img {
|
||||||
background-color: rgb(209, 226, 239);
|
background-color: rgb(209, 226, 239);
|
||||||
}
|
}
|
||||||
<?php echo $images_style; ?>
|
<?php echo $images_style; ?>
|
||||||
.imagewrap {
|
.imagewrap {
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
height: 96px;
|
height: 96px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
}
|
}
|
||||||
.imagewrap * {
|
.imagewrap * {
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
padding: 0px;
|
padding: 0px;
|
||||||
border: 0px;
|
border: 0px;
|
||||||
}
|
}
|
||||||
.imagewrap a, .imagewrap a img, .imagewrap a:hover img, .imagewrap a:visited img, .imagewrap a:active img {
|
.imagewrap a, .imagewrap a img, .imagewrap a:hover img, .imagewrap a:visited img, .imagewrap a:active img {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
float: left;
|
float: left;
|
||||||
/*display: block;*/
|
/*display: block;*/
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
#menu {
|
#menu {
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
list-style: none;
|
list-style: none;
|
||||||
background: rgb(109, 166, 209);
|
background: rgb(109, 166, 209);
|
||||||
padding: 4px 0px 0px 8px;
|
padding: 4px 0px 0px 8px;
|
||||||
text-align: left;
|
text-align: left;
|
||||||
border-bottom: 3px solid rgb(68, 138, 189);
|
border-bottom: 3px solid rgb(68, 138, 189);
|
||||||
}
|
}
|
||||||
#menu li {
|
#menu li {
|
||||||
display: inline;
|
display: inline;
|
||||||
margin: 0px;
|
margin: 0px;
|
||||||
}
|
}
|
||||||
#menu a, #menu a:visited, #menu a:active {
|
#menu a, #menu a:visited, #menu a:active {
|
||||||
padding: 1px 3px 3px;
|
padding: 1px 3px 3px;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #234;
|
color: #234;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
}
|
}
|
||||||
#menu a:hover {
|
#menu a:hover {
|
||||||
background: rgb(203, 214, 228);
|
background: rgb(203, 214, 228);
|
||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
#menu .current a, #menu .current a:hover, #menu .current a:visited, #menu .current a:active {
|
#menu .current a, #menu .current a:hover, #menu .current a:visited, #menu .current a:active {
|
||||||
background: rgb(223, 232, 241);
|
background: rgb(223, 232, 241);
|
||||||
padding-bottom: 3px;
|
padding-bottom: 3px;
|
||||||
color: #000;
|
color: #000;
|
||||||
border-right: 2px solid rgb(20, 86, 138);
|
border-right: 2px solid rgb(20, 86, 138);
|
||||||
}
|
}
|
||||||
.tip {
|
.tip {
|
||||||
color: rgb(68, 138, 189);
|
color: rgb(68, 138, 189);
|
||||||
padding: 1px 3px;
|
padding: 1px 3px;
|
||||||
}
|
}
|
||||||
.inactive {
|
.inactive {
|
||||||
color: #579;
|
color: #579;
|
||||||
padding: 1px 3px;
|
padding: 1px 3px;
|
||||||
}
|
}
|
||||||
.left {
|
.left {
|
||||||
float: left;
|
float: left;
|
||||||
}
|
}
|
||||||
.right {
|
.right {
|
||||||
float: right;
|
float: right;
|
||||||
}
|
}
|
||||||
.center {
|
.center {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
#menu li.spacer {
|
#menu li.spacer {
|
||||||
margin-left: 40px;
|
margin-left: 40px;
|
||||||
}
|
}
|
||||||
label {
|
label {
|
||||||
float: left;
|
float: left;
|
||||||
width: 18%;
|
width: 18%;
|
||||||
}
|
}
|
||||||
#title, #descr {
|
#title, #descr {
|
||||||
width: 80%;
|
width: 80%;
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
}
|
}
|
||||||
#descr {
|
#descr {
|
||||||
height: 35px;
|
height: 35px;
|
||||||
v-align: top;
|
v-align: top;
|
||||||
}
|
}
|
||||||
#buttons {
|
#buttons {
|
||||||
width: 98%;
|
width: 98%;
|
||||||
margin-top: 2px;
|
margin-top: 2px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
.popup {
|
.popup {
|
||||||
margin: 4px 4px;
|
margin: 4px 4px;
|
||||||
padding: 3px;
|
padding: 3px;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
width: 114px;
|
width: 114px;
|
||||||
height: 82px;
|
height: 82px;
|
||||||
display: none;
|
display: none;
|
||||||
background-color: rgb(223, 232, 241);
|
background-color: rgb(223, 232, 241);
|
||||||
opacity: .90;
|
opacity: .90;
|
||||||
filter:alpha(opacity=90);
|
filter:alpha(opacity=90);
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
.popup a, .popup a:visited, .popup a:active {
|
.popup a, .popup a:visited, .popup a:active {
|
||||||
background-color: transparent;
|
background-color: transparent;
|
||||||
display: block;
|
display: block;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
color: #246;
|
color: #246;
|
||||||
}
|
}
|
||||||
.popup a:hover {
|
.popup a:hover {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
color: #000;
|
color: #000;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body onload="init()">
|
<body onload="init()">
|
||||||
<ul id="menu">
|
<ul id="menu">
|
||||||
<li<?php echo $current_1; ?>><a href="<?php echo basename(__FILE__); ?>?action=upload&post=<?php echo $post; ?>&all=<?php echo $all; ?>"><?php _e('Upload File'); ?></a></li>
|
<li<?php echo $current_1; ?>><a href="<?php echo basename(__FILE__); ?>?action=upload&post=<?php echo $post; ?>&all=<?php echo $all; ?>"><?php _e('Upload File'); ?></a></li>
|
||||||
<li<?php echo $current_2; ?>><a href="<?php echo basename(__FILE__); ?>?action=view&post=<?php echo $post; ?>"><?php _e('Browse Attached'); ?></a></li>
|
<li<?php echo $current_2; ?>><a href="<?php echo basename(__FILE__); ?>?action=view&post=<?php echo $post; ?>"><?php _e('Browse Attached'); ?></a></li>
|
||||||
<li<?php echo $current_3; ?>><a href="<?php echo basename(__FILE__); ?>?action=view&post=<?php echo $post; ?>&all=true"><?php _e('Browse All'); ?></a></li>
|
<li<?php echo $current_3; ?>><a href="<?php echo basename(__FILE__); ?>?action=view&post=<?php echo $post; ?>&all=true"><?php _e('Browse All'); ?></a></li>
|
||||||
<li> </li>
|
<li> </li>
|
||||||
<?php if ( false !== $back ) : ?>
|
<?php if ( false !== $back ) : ?>
|
||||||
<li class="spacer"><a href="<?php echo basename(__FILE__); ?>?action=<?php echo $action; ?>&post=<?php echo $post; ?>&all=<?php echo $all; ?>&start=0" title="<?php _e('First'); ?>">|<</a></li>
|
<li class="spacer"><a href="<?php echo basename(__FILE__); ?>?action=<?php echo $action; ?>&post=<?php echo $post; ?>&all=<?php echo $all; ?>&start=0" title="<?php _e('First'); ?>">|<</a></li>
|
||||||
<li><a href="<?php echo basename(__FILE__); ?>?action=<?php echo $action; ?>&post=<?php echo $post; ?>&all=<?php echo $all; ?>&start=<?php echo $back; ?>" title="<?php _e('Back'); ?>"><<</a></li>
|
<li><a href="<?php echo basename(__FILE__); ?>?action=<?php echo $action; ?>&post=<?php echo $post; ?>&all=<?php echo $all; ?>&start=<?php echo $back; ?>" title="<?php _e('Back'); ?>"><<</a></li>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<li class="inactive spacer">|<</li>
|
<li class="inactive spacer">|<</li>
|
||||||
<li class="inactive"><<</li>
|
<li class="inactive"><<</li>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
<?php if ( false !== $next ) : ?>
|
<?php if ( false !== $next ) : ?>
|
||||||
<li><a href="<?php echo basename(__FILE__); ?>?action=<?php echo $action; ?>&post=<?php echo $post; ?>&all=<?php echo $all; ?>&start=<?php echo $next; ?>" title="<?php _e('Next'); ?>">>></a></li>
|
<li><a href="<?php echo basename(__FILE__); ?>?action=<?php echo $action; ?>&post=<?php echo $post; ?>&all=<?php echo $all; ?>&start=<?php echo $next; ?>" title="<?php _e('Next'); ?>">>></a></li>
|
||||||
<li><a href="<?php echo basename(__FILE__); ?>?action=<?php echo $action; ?>&post=<?php echo $post; ?>&all=<?php echo $all; ?>&last=true" title="<?php _e('Last'); ?>">>|</a></li>
|
<li><a href="<?php echo basename(__FILE__); ?>?action=<?php echo $action; ?>&post=<?php echo $post; ?>&all=<?php echo $all; ?>&last=true" title="<?php _e('Last'); ?>">>|</a></li>
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<li class="inactive">>></li>
|
<li class="inactive">>></li>
|
||||||
<li class="inactive">>|</li>
|
<li class="inactive">>|</li>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</ul>
|
</ul>
|
||||||
<?php if ( $action == 'view' ) : ?>
|
<?php if ( $action == 'view' ) : ?>
|
||||||
<span class="left tip"><?php _e('Drag and drop photos to post'); ?></span>
|
<span class="left tip"><?php _e('Drag and drop photos to post'); ?></span>
|
||||||
<span class="right tip"><?php _e('Click photos for more options'); ?></span>
|
<span class="right tip"><?php _e('Click photos for more options'); ?></span>
|
||||||
<div id="wrap">
|
<div id="wrap">
|
||||||
<div id="images">
|
<div id="images">
|
||||||
<?php echo $images_html; ?>
|
<?php echo $images_html; ?>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<?php elseif ( $action == 'upload' ) : ?>
|
<?php elseif ( $action == 'upload' ) : ?>
|
||||||
<div class="tip"></div>
|
<div class="tip"></div>
|
||||||
<form enctype="multipart/form-data" id="uploadForm" method="POST" action="<?php echo basename(__FILE__); ?>" onsubmit="return validateImageName()">
|
<form enctype="multipart/form-data" id="uploadForm" method="POST" action="<?php echo basename(__FILE__); ?>" onsubmit="return validateImageName()">
|
||||||
<label for="upload"><?php _e('Image:'); ?></label><input type="file" id="upload" name="image" onchange="validateImageName()" />
|
<label for="upload"><?php _e('Image:'); ?></label><input type="file" id="upload" name="image" onchange="validateImageName()" />
|
||||||
<label for="title"><?php _e('Title:'); ?></label><input type="text" id="title" name="imgtitle" />
|
<label for="title"><?php _e('Title:'); ?></label><input type="text" id="title" name="imgtitle" />
|
||||||
<label for="descr"><?php _e('Description:'); ?></label><input type="textarea" name="descr" id="descr" value="" />
|
<label for="descr"><?php _e('Description:'); ?></label><input type="textarea" name="descr" id="descr" value="" />
|
||||||
<input type="hidden" name="action" value="save" />
|
<input type="hidden" name="action" value="save" />
|
||||||
<input type="hidden" name="post" value="<?php echo $post; ?>" />
|
<input type="hidden" name="post" value="<?php echo $post; ?>" />
|
||||||
<input type="hidden" name="all" value="<?php echo $all; ?>" />
|
<input type="hidden" name="all" value="<?php echo $all; ?>" />
|
||||||
<div id="buttons">
|
<div id="buttons">
|
||||||
<input type="submit" value="<?php _e('Upload'); ?>" />
|
<input type="submit" value="<?php _e('Upload'); ?>" />
|
||||||
<input type="button" value="<?php _e('Cancel'); ?>" onclick="cancelUpload()" />
|
<input type="button" value="<?php _e('Cancel'); ?>" onclick="cancelUpload()" />
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,96 +1,96 @@
|
||||||
var listItems;
|
var listItems;
|
||||||
var reg_color = '#FFFFFF';
|
var reg_color = '#FFFFFF';
|
||||||
var alt_color = '#F1F1F1';
|
var alt_color = '#F1F1F1';
|
||||||
|
|
||||||
addLoadEvent(getListItems);
|
addLoadEvent(getListItems);
|
||||||
|
|
||||||
function deleteSomething( what, id, message ) {
|
function deleteSomething( what, id, message ) {
|
||||||
what.replace('-', ' ');
|
what.replace('-', ' ');
|
||||||
if (!message) message = 'Are you sure you want to delete this ' + what + '?';
|
if (!message) message = 'Are you sure you want to delete this ' + what + '?';
|
||||||
if ( confirm(message) ) {
|
if ( confirm(message) ) {
|
||||||
return ajaxDelete( what.replace(' ', '-'), id );
|
return ajaxDelete( what.replace(' ', '-'), id );
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getResponseElement() {
|
function getResponseElement() {
|
||||||
var p = document.getElementById('ajax-response-p');
|
var p = document.getElementById('ajax-response-p');
|
||||||
if (!p) {
|
if (!p) {
|
||||||
p = document.createElement('p');
|
p = document.createElement('p');
|
||||||
p.id = 'ajax-response-p';
|
p.id = 'ajax-response-p';
|
||||||
document.getElementById('ajax-response').appendChild(p);
|
document.getElementById('ajax-response').appendChild(p);
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function ajaxDelete(what, id) {
|
function ajaxDelete(what, id) {
|
||||||
ajaxDel = new sack('list-manipulation.php');
|
ajaxDel = new sack('list-manipulation.php');
|
||||||
if ( ajaxDel.failed ) return true;
|
if ( ajaxDel.failed ) return true;
|
||||||
ajaxDel.myResponseElement = getResponseElement();
|
ajaxDel.myResponseElement = getResponseElement();
|
||||||
ajaxDel.method = 'POST';
|
ajaxDel.method = 'POST';
|
||||||
ajaxDel.onLoading = function() { ajaxDel.myResponseElement.innerHTML = 'Sending Data...'; };
|
ajaxDel.onLoading = function() { ajaxDel.myResponseElement.innerHTML = 'Sending Data...'; };
|
||||||
ajaxDel.onLoaded = function() { ajaxDel.myResponseElement.innerHTML = 'Data Sent...'; };
|
ajaxDel.onLoaded = function() { ajaxDel.myResponseElement.innerHTML = 'Data Sent...'; };
|
||||||
ajaxDel.onInteractive = function() { ajaxDel.myResponseElement.innerHTML = 'Processing Data...'; };
|
ajaxDel.onInteractive = function() { ajaxDel.myResponseElement.innerHTML = 'Processing Data...'; };
|
||||||
ajaxDel.onCompletion = function() { removeThisItem( what + '-' + id ); };
|
ajaxDel.onCompletion = function() { removeThisItem( what + '-' + id ); };
|
||||||
ajaxDel.runAJAX('action=delete-' + what + '&id=' + id);
|
ajaxDel.runAJAX('action=delete-' + what + '&id=' + id);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function removeThisItem(id) {
|
function removeThisItem(id) {
|
||||||
var response = ajaxDel.response;
|
var response = ajaxDel.response;
|
||||||
if ( isNaN(response) ) { alert(response); }
|
if ( isNaN(response) ) { alert(response); }
|
||||||
response = parseInt(response, 10);
|
response = parseInt(response, 10);
|
||||||
if ( -1 == response ) { ajaxDel.myResponseElement.innerHTML = "You don't have permission to do that."; }
|
if ( -1 == response ) { ajaxDel.myResponseElement.innerHTML = "You don't have permission to do that."; }
|
||||||
else if ( 0 == response ) { ajaxDel.myResponseElement.interHTML = "Something odd happened. Try refreshing the page? Either that or what you tried to delete never existed in the first place."; }
|
else if ( 0 == response ) { ajaxDel.myResponseElement.interHTML = "Something odd happened. Try refreshing the page? Either that or what you tried to delete never existed in the first place."; }
|
||||||
else if ( 1 == response ) {
|
else if ( 1 == response ) {
|
||||||
theItem = document.getElementById(id);
|
theItem = document.getElementById(id);
|
||||||
Fat.fade_element(id,null,700,'#FF3333');
|
Fat.fade_element(id,null,700,'#FF3333');
|
||||||
setTimeout('theItem.parentNode.removeChild(theItem)', 705);
|
setTimeout('theItem.parentNode.removeChild(theItem)', 705);
|
||||||
var pos = getListPos(id);
|
var pos = getListPos(id);
|
||||||
listItems.splice(pos,1);
|
listItems.splice(pos,1);
|
||||||
recolorList(pos);
|
recolorList(pos);
|
||||||
ajaxDel.myResponseElement.parentNode.removeChild(ajaxDel.myResponseElement);
|
ajaxDel.myResponseElement.parentNode.removeChild(ajaxDel.myResponseElement);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getListPos(id) {
|
function getListPos(id) {
|
||||||
for (var i = 0; i < listItems.length; i++) {
|
for (var i = 0; i < listItems.length; i++) {
|
||||||
if (id == listItems[i]) {
|
if (id == listItems[i]) {
|
||||||
var pos = i;
|
var pos = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pos;
|
return pos;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getListItems() {
|
function getListItems() {
|
||||||
if (list) return;
|
if (list) return;
|
||||||
listItems = new Array();
|
listItems = new Array();
|
||||||
var extra = false;
|
var extra = false;
|
||||||
var list = document.getElementById('the-list');
|
var list = document.getElementById('the-list');
|
||||||
if (!list) { var list = document.getElementById('the-list-x'); extra = true; }
|
if (!list) { var list = document.getElementById('the-list-x'); extra = true; }
|
||||||
if (list) {
|
if (list) {
|
||||||
var items = list.getElementsByTagName('tr');
|
var items = list.getElementsByTagName('tr');
|
||||||
if (!items[0]) { items = list.getElementsByTagName('li'); }
|
if (!items[0]) { items = list.getElementsByTagName('li'); }
|
||||||
for (var i=0; i<items.length; i++) { listItems.push(items[i].id); }
|
for (var i=0; i<items.length; i++) { listItems.push(items[i].id); }
|
||||||
if (extra) { listItems.splice(0,1); }
|
if (extra) { listItems.splice(0,1); }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function recolorList(pos,dur,from) {
|
function recolorList(pos,dur,from) {
|
||||||
if (!pos) pos = 0;
|
if (!pos) pos = 0;
|
||||||
|
|
||||||
if (!from) {
|
if (!from) {
|
||||||
reg_from = alt_color;
|
reg_from = alt_color;
|
||||||
alt_from = reg_color;
|
alt_from = reg_color;
|
||||||
} else {
|
} else {
|
||||||
reg_from = from;
|
reg_from = from;
|
||||||
alt_from = from;
|
alt_from = from;
|
||||||
}
|
}
|
||||||
for (var i = pos; i < listItems.length; i++) {
|
for (var i = pos; i < listItems.length; i++) {
|
||||||
if (i % 2 == 1) Fat.fade_element(listItems[i],null,dur,reg_from,reg_color);
|
if (i % 2 == 1) Fat.fade_element(listItems[i],null,dur,reg_from,reg_color);
|
||||||
else Fat.fade_element(listItems[i],null,dur,alt_from,alt_color);
|
else Fat.fade_element(listItems[i],null,dur,alt_from,alt_color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,81 +1,81 @@
|
||||||
<?php
|
<?php
|
||||||
require_once('../wp-config.php');
|
require_once('../wp-config.php');
|
||||||
require_once('admin-functions.php');
|
require_once('admin-functions.php');
|
||||||
require_once('admin-db.php');
|
require_once('admin-db.php');
|
||||||
|
|
||||||
get_currentuserinfo();
|
get_currentuserinfo();
|
||||||
if ( !$current_user )
|
if ( !$current_user )
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
function grab_results() {
|
function grab_results() {
|
||||||
global $ajax_results;
|
global $ajax_results;
|
||||||
$ajax_results = func_get_arg(0);
|
$ajax_results = func_get_arg(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_out_now() { exit; }
|
function get_out_now() { exit; }
|
||||||
add_action('shutdown', 'get_out_now', -1);
|
add_action('shutdown', 'get_out_now', -1);
|
||||||
|
|
||||||
// check_admin_referer();
|
// check_admin_referer();
|
||||||
|
|
||||||
switch ( $_POST['action'] ) :
|
switch ( $_POST['action'] ) :
|
||||||
case 'delete-link' :
|
case 'delete-link' :
|
||||||
$id = (int) $_POST['id'];
|
$id = (int) $_POST['id'];
|
||||||
if ( !current_user_can('manage_links') )
|
if ( !current_user_can('manage_links') )
|
||||||
die ('-1');
|
die ('-1');
|
||||||
|
|
||||||
if ( $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$id'") )
|
if ( $wpdb->query("DELETE FROM $wpdb->links WHERE link_id = '$id'") )
|
||||||
die('1');
|
die('1');
|
||||||
else die('0');
|
else die('0');
|
||||||
break;
|
break;
|
||||||
case 'delete-post' :
|
case 'delete-post' :
|
||||||
case 'delete-page' :
|
case 'delete-page' :
|
||||||
$id = (int) $_POST['id'];
|
$id = (int) $_POST['id'];
|
||||||
if ( !current_user_can('edit_post', $post_id) )
|
if ( !current_user_can('edit_post', $post_id) )
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
if ( wp_delete_post($id) )
|
if ( wp_delete_post($id) )
|
||||||
die('1');
|
die('1');
|
||||||
else die('0');
|
else die('0');
|
||||||
break;
|
break;
|
||||||
case 'delete-cat' :
|
case 'delete-cat' :
|
||||||
if ( !current_user_can('manage_categories') )
|
if ( !current_user_can('manage_categories') )
|
||||||
die ('-1');
|
die ('-1');
|
||||||
|
|
||||||
$id = (int) $_POST['id'];
|
$id = (int) $_POST['id'];
|
||||||
$cat_name = get_catname($cat_ID);
|
$cat_name = get_catname($cat_ID);
|
||||||
|
|
||||||
if ( wp_delete_category($id) )
|
if ( wp_delete_category($id) )
|
||||||
die('1');
|
die('1');
|
||||||
else die('0');
|
else die('0');
|
||||||
break;
|
break;
|
||||||
case 'delete-comment' :
|
case 'delete-comment' :
|
||||||
$id = (int) $_POST['id'];
|
$id = (int) $_POST['id'];
|
||||||
|
|
||||||
if ( !$comment = get_comment($id) )
|
if ( !$comment = get_comment($id) )
|
||||||
die('0');
|
die('0');
|
||||||
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
|
if ( !current_user_can('edit_post', $comment->comment_post_ID) )
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
if ( wp_set_comment_status($comment->comment_ID, "delete") ) {
|
if ( wp_set_comment_status($comment->comment_ID, "delete") ) {
|
||||||
do_action('delete_comment', $comment->comment_ID);
|
do_action('delete_comment', $comment->comment_ID);
|
||||||
die('1');
|
die('1');
|
||||||
} else {
|
} else {
|
||||||
die('0');
|
die('0');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 'delete-link-category' :
|
case 'delete-link-category' :
|
||||||
$id = (int) $_POST['id'];
|
$id = (int) $_POST['id'];
|
||||||
if ( 1 == $id )
|
if ( 1 == $id )
|
||||||
die('0');
|
die('0');
|
||||||
if ( !current_user_can('manage_links') )
|
if ( !current_user_can('manage_links') )
|
||||||
die('-1');
|
die('-1');
|
||||||
|
|
||||||
if ( $wpdb->query("DELETE FROM $wpdb->linkcategories WHERE cat_id='$id'") ) {
|
if ( $wpdb->query("DELETE FROM $wpdb->linkcategories WHERE cat_id='$id'") ) {
|
||||||
$wpdb->query("UPDATE $wpdb->links SET link_category=1 WHERE link_category='$id'");
|
$wpdb->query("UPDATE $wpdb->links SET link_category=1 WHERE link_category='$id'");
|
||||||
die('1');
|
die('1');
|
||||||
} else {
|
} else {
|
||||||
die('0');
|
die('0');
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
endswitch;
|
endswitch;
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -6,6 +6,7 @@ $title = __('Users');
|
||||||
$parent_file = 'profile.php';
|
$parent_file = 'profile.php';
|
||||||
|
|
||||||
$action = $_REQUEST['action'];
|
$action = $_REQUEST['action'];
|
||||||
|
$update = '';
|
||||||
|
|
||||||
switch ($action) {
|
switch ($action) {
|
||||||
|
|
||||||
|
@ -19,13 +20,20 @@ case 'promote':
|
||||||
if ( !current_user_can('edit_users') )
|
if ( !current_user_can('edit_users') )
|
||||||
die(__('You can’t edit users.'));
|
die(__('You can’t edit users.'));
|
||||||
|
|
||||||
$userids = $_POST['users'];
|
$userids = $_POST['users'];
|
||||||
foreach($userids as $id) {
|
$update = 'promote';
|
||||||
$user = new WP_User($id);
|
foreach($userids as $id) {
|
||||||
$user->set_role($_POST['new_role']);
|
// The new role of the current user must also have edit_users caps
|
||||||
}
|
if($id == $current_user->id && !$wp_roles->role_objects[$_POST['new_role']]->has_cap('edit_users')) {
|
||||||
|
$update = 'err_admin_role';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
$user = new WP_User($id);
|
||||||
|
$user->set_role($_POST['new_role']);
|
||||||
|
}
|
||||||
|
|
||||||
header('Location: users.php?update=promote');
|
header('Location: users.php?update=' . $update);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -33,7 +41,7 @@ case 'dodelete':
|
||||||
|
|
||||||
check_admin_referer();
|
check_admin_referer();
|
||||||
|
|
||||||
if (empty($_POST['users'])) {
|
if ( empty($_POST['users']) ) {
|
||||||
header('Location: users.php');
|
header('Location: users.php');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,8 +50,13 @@ case 'dodelete':
|
||||||
|
|
||||||
$userids = $_POST['users'];
|
$userids = $_POST['users'];
|
||||||
|
|
||||||
foreach($userids as $id) {
|
$update = 'del';
|
||||||
switch($_POST['delete_option']) {
|
foreach ($userids as $id) {
|
||||||
|
if($id == $current_user->id) {
|
||||||
|
$update = 'err_admin_del';
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
switch($_POST['delete_option']) {
|
||||||
case 'delete':
|
case 'delete':
|
||||||
wp_delete_user($id);
|
wp_delete_user($id);
|
||||||
break;
|
break;
|
||||||
|
@ -53,7 +66,7 @@ case 'dodelete':
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
header('Location: users.php?update=del');
|
header('Location: users.php?update=' . $update);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -74,26 +87,32 @@ case 'delete':
|
||||||
?>
|
?>
|
||||||
<form action="" method="post" name="updateusers" id="updateusers">
|
<form action="" method="post" name="updateusers" id="updateusers">
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h2><?php _e('Delete Users'); ?></h2>
|
<h2><?php _e('Delete Users'); ?></h2>
|
||||||
<p><?php _e('You have specified these users for deletion:'); ?></p>
|
<p><?php _e('You have specified these users for deletion:'); ?></p>
|
||||||
<ul>
|
<ul>
|
||||||
<?php
|
<?php
|
||||||
foreach($userids as $id) {
|
$go_delete = false;
|
||||||
$user = new WP_User($id);
|
foreach ($userids as $id) {
|
||||||
echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />";
|
$user = new WP_User($id);
|
||||||
echo "{$id}: {$user->data->user_login}</li>\n";
|
if ($id == $current_user->id) {
|
||||||
}
|
echo "<li>" . sprintf('ID #%1s: %2s <strong>The current user will not be deleted.</strong>', $id, $user->data->user_login) . "</li>\n";
|
||||||
$all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login");
|
} else {
|
||||||
$user_dropdown = '<select name="reassign_user">';
|
echo "<li><input type=\"hidden\" name=\"users[]\" value=\"{$id}\" />" . sprintf('ID #%1s: %2s', $id, $user->data->user_login) . "</li>\n";
|
||||||
foreach($all_logins as $login) {
|
$go_delete = true;
|
||||||
if(!in_array($login->ID, $userids)) {
|
|
||||||
$user_dropdown .= "<option value=\"{$login->ID}\">{$login->user_login}</option>";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$user_dropdown .= '</select>';
|
$all_logins = $wpdb->get_results("SELECT ID, user_login FROM $wpdb->users ORDER BY user_login");
|
||||||
?>
|
$user_dropdown = '<select name="reassign_user">';
|
||||||
</ul>
|
foreach ($all_logins as $login) {
|
||||||
<p><?php _e('What should be done with posts and links owned by this user?'); ?></p>
|
if ( $login->ID == $current_user->id || !in_array($login->ID, $userids) ) {
|
||||||
|
$user_dropdown .= "<option value=\"{$login->ID}\">{$login->user_login}</option>";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$user_dropdown .= '</select>';
|
||||||
|
?>
|
||||||
|
</ul>
|
||||||
|
<?php if($go_delete) : ?>
|
||||||
|
<p><?php _e('What should be done with posts and links owned by this user?'); ?></p>
|
||||||
<ul style="list-style:none;">
|
<ul style="list-style:none;">
|
||||||
<li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" />
|
<li><label><input type="radio" id="delete_option0" name="delete_option" value="delete" checked="checked" />
|
||||||
<?php _e('Delete all posts and links.'); ?></label></li>
|
<?php _e('Delete all posts and links.'); ?></label></li>
|
||||||
|
@ -102,6 +121,9 @@ case 'delete':
|
||||||
</ul>
|
</ul>
|
||||||
<input type="hidden" name="action" value="dodelete" />
|
<input type="hidden" name="action" value="dodelete" />
|
||||||
<p class="submit"><input type="submit" name="submit" value="<?php _e('Confirm Deletion'); ?>" /></p>
|
<p class="submit"><input type="submit" name="submit" value="<?php _e('Confirm Deletion'); ?>" /></p>
|
||||||
|
<?php else : ?>
|
||||||
|
<p><?php _e('There are no valid users selected for deletion.'); ?></p>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
<?php
|
<?php
|
||||||
|
@ -151,6 +173,18 @@ default:
|
||||||
<div id="message" class="updated fade"><p><?php _e('Changed roles.'); ?></p></div>
|
<div id="message" class="updated fade"><p><?php _e('Changed roles.'); ?></p></div>
|
||||||
<?php
|
<?php
|
||||||
break;
|
break;
|
||||||
|
case 'err_admin_role':
|
||||||
|
?>
|
||||||
|
<div id="message" class="error"><p><?php _e("The current user's role must have user editing capabilities."); ?></p></div>
|
||||||
|
<div id="message" class="updated fade"><p><?php _e('Other user roles have been changed.'); ?></p></div>
|
||||||
|
<?php
|
||||||
|
break;
|
||||||
|
case 'err_admin_del':
|
||||||
|
?>
|
||||||
|
<div id="message" class="error"><p><?php _e("You can't delete the current user."); ?></p></div>
|
||||||
|
<div id="message" class="updated fade"><p><?php _e('Other users have been deleted.'); ?></p></div>
|
||||||
|
<?php
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
endif;
|
endif;
|
||||||
if ( isset($errors) ) : ?>
|
if ( isset($errors) ) : ?>
|
||||||
|
|
Loading…
Reference in New Issue