Initial sub-categories code from Jason Verber
git-svn-id: http://svn.automattic.com/wordpress/trunk@798 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
996ba79f93
commit
8b9f213e57
|
@ -9,11 +9,16 @@ function gethelp_link($this_file, $helptag) {
|
||||||
return $s;
|
return $s;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($use_cache)) $use_cache=1;
|
if (!isset($use_cache)) $use_cache=1;
|
||||||
if (!isset($blogID)) $blog_ID=1;
|
if (!isset($blogID)) $blog_ID=1;
|
||||||
if (!isset($debug)) $debug=0;
|
if (!isset($debug)) $debug=0;
|
||||||
timer_start();
|
timer_start();
|
||||||
|
|
||||||
|
$dogs = $wpdb->get_results("SELECT * FROM $tablecategories WHERE 1=1");
|
||||||
|
foreach ($dogs as $catt) {
|
||||||
|
$cache_categories[$catt->cat_ID] = $catt;
|
||||||
|
}
|
||||||
|
|
||||||
get_currentuserinfo();
|
get_currentuserinfo();
|
||||||
|
|
||||||
$posts_per_page = get_settings('posts_per_page');
|
$posts_per_page = get_settings('posts_per_page');
|
||||||
|
@ -27,22 +32,22 @@ $admin_area_charset = (!isset($admin_area_charset)) ? 'iso-8859-15' : $admin_are
|
||||||
|
|
||||||
// let's deactivate quicktags on IE Mac and Lynx, because they don't work there.
|
// let's deactivate quicktags on IE Mac and Lynx, because they don't work there.
|
||||||
if (($is_macIE) || ($is_lynx))
|
if (($is_macIE) || ($is_lynx))
|
||||||
$use_quicktags = 0;
|
$use_quicktags = 0;
|
||||||
|
|
||||||
$wpvarstoreset = array('profile','standalone','redirect','redirect_url','a','popuptitle','popupurl','text', 'trackback', 'pingback');
|
$wpvarstoreset = array('profile','standalone','redirect','redirect_url','a','popuptitle','popupurl','text', 'trackback', 'pingback');
|
||||||
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($HTTP_POST_VARS["$wpvar"])) {
|
if (empty($HTTP_POST_VARS["$wpvar"])) {
|
||||||
if (empty($HTTP_GET_VARS["$wpvar"])) {
|
if (empty($HTTP_GET_VARS["$wpvar"])) {
|
||||||
$$wpvar = '';
|
$$wpvar = '';
|
||||||
} else {
|
} else {
|
||||||
$$wpvar = $HTTP_GET_VARS["$wpvar"];
|
$$wpvar = $HTTP_GET_VARS["$wpvar"];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$$wpvar = $HTTP_POST_VARS["$wpvar"];
|
$$wpvar = $HTTP_POST_VARS["$wpvar"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($standalone == 0) {
|
if ($standalone == 0) {
|
||||||
|
@ -72,65 +77,65 @@ setTimeout("redirect();", 600);
|
||||||
<script language="javascript" type="text/javascript">
|
<script language="javascript" type="text/javascript">
|
||||||
//<![CDATA[
|
//<![CDATA[
|
||||||
|
|
||||||
function profile(userID) {
|
function profile(userID) {
|
||||||
window.open ("profile.php?action=viewprofile&user="+userID, "Profile", "width=500, height=450, location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=60, left=60, screenY=60, top=60");
|
window.open ("profile.php?action=viewprofile&user="+userID, "Profile", "width=500, height=450, location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=60, left=60, screenY=60, top=60");
|
||||||
}
|
}
|
||||||
|
|
||||||
function launchupload() {
|
function launchupload() {
|
||||||
window.open ("upload.php", "wpupload", "width=380,height=360,location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0");
|
window.open ("upload.php", "wpupload", "width=380,height=360,location=0,menubar=0,resizable=1,scrollbars=yes,status=1,toolbar=0");
|
||||||
}
|
}
|
||||||
|
|
||||||
function helpWindow(url) {
|
function helpWindow(url) {
|
||||||
window.open(url, "Help", "width=640, height=450, location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=60, left=60, screenY=60, top=60");
|
window.open(url, "Help", "width=640, height=450, location=0, menubar=0, resizable=0, scrollbars=1, status=1, titlebar=0, toolbar=0, screenX=60, left=60, screenY=60, top=60");
|
||||||
}
|
}
|
||||||
function GetElementsWithClassName(elementName, className) {
|
function GetElementsWithClassName(elementName, className) {
|
||||||
var allElements = document.getElementsByTagName(elementName);
|
var allElements = document.getElementsByTagName(elementName);
|
||||||
var elemColl = new Array();
|
var elemColl = new Array();
|
||||||
for (i = 0; i < allElements.length; i++) {
|
for (i = 0; i < allElements.length; i++) {
|
||||||
if (allElements[i].className == className) {
|
if (allElements[i].className == className) {
|
||||||
elemColl[elemColl.length] = allElements[i];
|
elemColl[elemColl.length] = allElements[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return elemColl;
|
return elemColl;
|
||||||
}
|
}
|
||||||
|
|
||||||
function blurry() {
|
function blurry() {
|
||||||
if (!document.getElementById) return;
|
if (!document.getElementById) return;
|
||||||
|
|
||||||
var aInputs = document.getElementsByTagName('input');
|
var aInputs = document.getElementsByTagName('input');
|
||||||
|
|
||||||
for (var i = 0; i < aInputs.length; i++) {
|
for (var i = 0; i < aInputs.length; i++) {
|
||||||
|
|
||||||
aInputs[i].onclick = function() {
|
aInputs[i].onclick = function() {
|
||||||
var inputColl = GetElementsWithClassName('input','valinp');
|
var inputColl = GetElementsWithClassName('input','valinp');
|
||||||
var rel = document.getElementById('rel');
|
var rel = document.getElementById('rel');
|
||||||
var inputs = '';
|
var inputs = '';
|
||||||
for (i = 0; i < inputColl.length; i++) {
|
for (i = 0; i < inputColl.length; i++) {
|
||||||
if (inputColl[i].checked) {
|
if (inputColl[i].checked) {
|
||||||
if (inputColl[i].value != '') inputs += inputColl[i].value + ' ';
|
if (inputColl[i].value != '') inputs += inputColl[i].value + ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inputs = inputs.substr(0,inputs.length - 1);
|
inputs = inputs.substr(0,inputs.length - 1);
|
||||||
rel.value = inputs;
|
rel.value = inputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
aInputs[i].onkeyup = function() {
|
aInputs[i].onkeyup = function() {
|
||||||
var inputColl = GetElementsWithClassName('input','valinp');
|
var inputColl = GetElementsWithClassName('input','valinp');
|
||||||
var rel = document.getElementById('rel');
|
var rel = document.getElementById('rel');
|
||||||
var inputs = '';
|
var inputs = '';
|
||||||
for (i = 0; i < inputColl.length; i++) {
|
for (i = 0; i < inputColl.length; i++) {
|
||||||
if (inputColl[i].checked) {
|
if (inputColl[i].checked) {
|
||||||
inputs += inputColl[i].value + ' ';
|
inputs += inputColl[i].value + ' ';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
inputs = inputs.substr(0,inputs.length - 1);
|
inputs = inputs.substr(0,inputs.length - 1);
|
||||||
rel.value = inputs;
|
rel.value = inputs;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
window.onload = blurry;
|
window.onload = blurry;
|
||||||
//]]>
|
//]]>
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
|
@ -138,10 +143,10 @@ setTimeout("redirect();", 600);
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
if ($profile==0) {
|
if ($profile==0) {
|
||||||
include('menu.php');
|
include('menu.php');
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
|
@ -3,180 +3,188 @@ $title = 'Categories';
|
||||||
/* <Categories> */
|
/* <Categories> */
|
||||||
|
|
||||||
function add_magic_quotes($array) {
|
function add_magic_quotes($array) {
|
||||||
foreach ($array as $k => $v) {
|
foreach ($array as $k => $v) {
|
||||||
if (is_array($v)) {
|
if (is_array($v)) {
|
||||||
$array[$k] = add_magic_quotes($v);
|
$array[$k] = add_magic_quotes($v);
|
||||||
} else {
|
} else {
|
||||||
$array[$k] = addslashes($v);
|
$array[$k] = addslashes($v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return $array;
|
return $array;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!get_magic_quotes_gpc()) {
|
if (!get_magic_quotes_gpc()) {
|
||||||
$HTTP_GET_VARS = add_magic_quotes($HTTP_GET_VARS);
|
$HTTP_GET_VARS = add_magic_quotes($HTTP_GET_VARS);
|
||||||
$HTTP_POST_VARS = add_magic_quotes($HTTP_POST_VARS);
|
$HTTP_POST_VARS = add_magic_quotes($HTTP_POST_VARS);
|
||||||
$HTTP_COOKIE_VARS = add_magic_quotes($HTTP_COOKIE_VARS);
|
$HTTP_COOKIE_VARS = add_magic_quotes($HTTP_COOKIE_VARS);
|
||||||
}
|
}
|
||||||
|
|
||||||
$wpvarstoreset = array('action','standalone','cat');
|
$wpvarstoreset = array('action','standalone','cat');
|
||||||
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($HTTP_POST_VARS["$wpvar"])) {
|
if (empty($HTTP_POST_VARS["$wpvar"])) {
|
||||||
if (empty($HTTP_GET_VARS["$wpvar"])) {
|
if (empty($HTTP_GET_VARS["$wpvar"])) {
|
||||||
$$wpvar = '';
|
$$wpvar = '';
|
||||||
} else {
|
} else {
|
||||||
$$wpvar = $HTTP_GET_VARS["$wpvar"];
|
$$wpvar = $HTTP_GET_VARS["$wpvar"];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$$wpvar = $HTTP_POST_VARS["$wpvar"];
|
$$wpvar = $HTTP_POST_VARS["$wpvar"];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
switch($action) {
|
switch($action) {
|
||||||
|
|
||||||
case 'addcat':
|
case 'addcat':
|
||||||
|
|
||||||
$standalone = 1;
|
$standalone = 1;
|
||||||
require_once('admin-header.php');
|
require_once('admin-header.php');
|
||||||
|
|
||||||
if ($user_level < 3)
|
if ($user_level < 3)
|
||||||
die ('Cheatin’ uh?');
|
die ('Cheatin’ uh?');
|
||||||
|
|
||||||
$cat_name= addslashes(stripslashes(stripslashes($HTTP_POST_VARS['cat_name'])));
|
$cat_name= addslashes(stripslashes(stripslashes($HTTP_POST_VARS['cat_name'])));
|
||||||
$category_nicename = sanitize_title($cat_name);
|
$category_nicename = sanitize_title($cat_name);
|
||||||
$category_description = addslashes(stripslashes(stripslashes($HTTP_POST_VARS['category_description'])));
|
$category_description = addslashes(stripslashes(stripslashes($HTTP_POST_VARS['category_description'])));
|
||||||
|
|
||||||
$wpdb->query("INSERT INTO $tablecategories (cat_ID, cat_name, category_nicename, category_description) VALUES ('0', '$cat_name', '$category_nicename', '$category_description')");
|
$wpdb->query("INSERT INTO $tablecategories (cat_ID, cat_name, category_nicename, category_description, category_parent) VALUES ('0', '$cat_name', '$category_nicename', '$category_description', $cat)");
|
||||||
|
|
||||||
header('Location: categories.php');
|
header('Location: categories.php');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'Delete':
|
case 'Delete':
|
||||||
|
|
||||||
$standalone = 1;
|
$standalone = 1;
|
||||||
require_once('admin-header.php');
|
require_once('admin-header.php');
|
||||||
|
|
||||||
$cat_ID = intval($HTTP_GET_VARS["cat_ID"]);
|
$cat_ID = intval($HTTP_GET_VARS["cat_ID"]);
|
||||||
$cat_name = get_catname($cat_ID);
|
$cat_name = get_catname($cat_ID);
|
||||||
$cat_name = addslashes($cat_name);
|
$cat_name = addslashes($cat_name);
|
||||||
|
|
||||||
if (1 == $cat_ID)
|
if (1 == $cat_ID)
|
||||||
die("Can't delete the <strong>$cat_name</strong> category: this is the default one");
|
die("Can't delete the <strong>$cat_name</strong> category: this is the default one");
|
||||||
|
|
||||||
if ($user_level < 3)
|
if ($user_level < 3)
|
||||||
die ('Cheatin’ uh?');
|
die ('Cheatin’ uh?');
|
||||||
|
|
||||||
$wpdb->query("DELETE FROM $tablecategories WHERE cat_ID = $cat_ID");
|
$wpdb->query("DELETE FROM $tablecategories WHERE cat_ID = $cat_ID");
|
||||||
$wpdb->query("UPDATE $tablepost2cat SET category_id='1' WHERE category_id='$cat_ID'");
|
$wpdb->query("UPDATE $tablepost2cat SET category_id='1' WHERE category_id='$cat_ID'");
|
||||||
|
|
||||||
header('Location: categories.php');
|
header('Location: categories.php');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'edit':
|
case 'edit':
|
||||||
|
|
||||||
require_once ('admin-header.php');
|
require_once ('admin-header.php');
|
||||||
$category = $wpdb->get_row("SELECT * FROM $tablecategories WHERE cat_ID = " . $HTTP_GET_VARS['cat_ID']);
|
$category = $wpdb->get_row("SELECT * FROM $tablecategories WHERE cat_ID = " . $HTTP_GET_VARS['cat_ID']);
|
||||||
$cat_name = stripslashes($category->cat_name);
|
$cat_name = stripslashes($category->cat_name);
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h2>Edit Category</h2>
|
<h2>Edit Category</h2>
|
||||||
<form name="editcat" action="categories.php" method="post">
|
<form name="editcat" action="categories.php" method="post">
|
||||||
<input type="hidden" name="action" value="editedcat" />
|
<input type="hidden" name="action" value="editedcat" />
|
||||||
<input type="hidden" name="cat_ID" value="<?php echo $HTTP_GET_VARS['cat_ID'] ?>" />
|
<input type="hidden" name="cat_ID" value="<?php echo $HTTP_GET_VARS['cat_ID'] ?>" />
|
||||||
<p>Category name:<br />
|
<p>Category name:<br />
|
||||||
<input type="text" name="cat_name" value="<?php echo $cat_name; ?>" /></p>
|
<input type="text" name="cat_name" value="<?php echo $cat_name; ?>" /></p>
|
||||||
<p>Description:<br />
|
<p>Category parent:<br />
|
||||||
<textarea name="category_description" rows="5" cols="50" style="width: 97%;"><?php echo htmlentities($category->category_description); ?></textarea></p>
|
<?php dropdown_cats(FALSE, '', 'name', 'asc', FALSE, FALSE, FALSE, TRUE, $category->category_parent, $HTTP_GET_VARS['cat_ID']); ?></p>
|
||||||
<p><input type="submit" name="submit" value="Edit it!" class="search" /></p>
|
<p>Description:<br />
|
||||||
</form>
|
<textarea name="category_description" rows="5" cols="50" style="width: 97%;"><?php echo htmlentities($category->category_description); ?></textarea></p>
|
||||||
|
<p><input type="submit" name="submit" value="Edit it!" class="search" /></p>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'editedcat':
|
case 'editedcat':
|
||||||
|
|
||||||
$standalone = 1;
|
$standalone = 1;
|
||||||
require_once('admin-header.php');
|
require_once('admin-header.php');
|
||||||
|
|
||||||
if ($user_level < 3)
|
if ($user_level < 3)
|
||||||
die ('Cheatin’ uh?');
|
die ('Cheatin’ uh?');
|
||||||
|
|
||||||
$cat_name = addslashes(stripslashes(stripslashes($HTTP_POST_VARS['cat_name'])));
|
$cat_name = addslashes(stripslashes(stripslashes($HTTP_POST_VARS['cat_name'])));
|
||||||
$cat_ID = addslashes($HTTP_POST_VARS['cat_ID']);
|
$cat_ID = addslashes($HTTP_POST_VARS['cat_ID']);
|
||||||
$category_nicename = sanitize_title($cat_name);
|
$category_nicename = sanitize_title($cat_name);
|
||||||
$category_description = $HTTP_POST_VARS['category_description'];
|
$category_description = $HTTP_POST_VARS['category_description'];
|
||||||
|
|
||||||
$wpdb->query("UPDATE $tablecategories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description' WHERE cat_ID = $cat_ID");
|
$wpdb->query("UPDATE $tablecategories SET cat_name = '$cat_name', category_nicename = '$category_nicename', category_description = '$category_description', category_parent = $cat WHERE cat_ID = $cat_ID");
|
||||||
|
|
||||||
header('Location: categories.php');
|
header('Location: categories.php');
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
||||||
$standalone = 0;
|
$standalone = 0;
|
||||||
require_once ('admin-header.php');
|
require_once ('admin-header.php');
|
||||||
if ($user_level < 3) {
|
if ($user_level < 3) {
|
||||||
die("You have no right to edit the categories for this blog.<br />Ask for a promotion to your <a href='mailto:$admin_email'>blog admin</a>. :)");
|
die("You have no right to edit the categories for this blog.<br />Ask for a promotion to your <a href='mailto:$admin_email'>blog admin</a>. :)");
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h2>Current Categories</h2>
|
<h2>Current Categories</h2>
|
||||||
<table width="100%" cellpadding="3" cellspacing="3">
|
<table width="100%" cellpadding="3" cellspacing="3">
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">Name</th>
|
<th scope="col">Name</th>
|
||||||
<th scope="col">Description</th>
|
<th scope="col">Parent</th>
|
||||||
<th scope="col"># Posts</th>
|
<th scope="col">Description</th>
|
||||||
<th colspan="2">Action</th>
|
<th scope="col"># Posts</th>
|
||||||
</tr>
|
<th colspan="2">Action</th>
|
||||||
<?php
|
</tr>
|
||||||
$categories = $wpdb->get_results("SELECT * FROM $tablecategories ORDER BY cat_name");
|
<?php
|
||||||
foreach ($categories as $category) {
|
$categories = $wpdb->get_results("SELECT * FROM $tablecategories ORDER BY cat_name");
|
||||||
$count = $wpdb->get_var("SELECT COUNT(post_id) FROM $tablepost2cat WHERE category_id = $category->cat_ID");
|
foreach ($categories as $category) {
|
||||||
$bgcolor = ('#eee' == $bgcolor) ? 'none' : '#eee';
|
$parent = "None";
|
||||||
echo "<tr style='background-color: $bgcolor'><td>$category->cat_name</td>
|
if ($category->category_parent) $parent = $wpdb->get_var("SELECT cat_name FROM $tablecategories WHERE cat_ID = $category->category_parent");
|
||||||
<td>$category->category_description</td>
|
$count = $wpdb->get_var("SELECT COUNT(post_id) FROM $tablepost2cat WHERE category_id = $category->cat_ID");
|
||||||
<td>$count</td>
|
$bgcolor = ('#eee' == $bgcolor) ? 'none' : '#eee';
|
||||||
<td><a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>Edit</a></td><td><a href='categories.php?action=Delete&cat_ID=$category->cat_ID' onclick=\"return confirm('You are about to delete the category \'". addslashes($category->cat_name) ."\' and all its posts will go to the default category.\\n \'OK\' to delete, \'Cancel\' to stop.')\" class='delete'>Delete</a></td>
|
echo "<tr style='background-color: $bgcolor'><td>$category->cat_name</td>
|
||||||
</tr>";
|
<td>$parent</td>
|
||||||
}
|
<td>$category->category_description</td>
|
||||||
?>
|
<td>$count</td>
|
||||||
</table>
|
<td><a href='categories.php?action=edit&cat_ID=$category->cat_ID' class='edit'>Edit</a></td><td><a href='categories.php?action=Delete&cat_ID=$category->cat_ID' onclick=\"return confirm('You are about to delete the category \'". addslashes($category->cat_name) ."\' and all its posts will go to the default category.\\n \'OK\' to delete, \'Cancel\' to stop.')\" class='delete'>Delete</a></td>
|
||||||
|
</tr>";
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
</table>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<h2>Add New Category</h2>
|
<h2>Add New Category</h2>
|
||||||
<form name="addcat" action="categories.php" method="post">
|
<form name="addcat" action="categories.php" method="post">
|
||||||
|
|
||||||
<p>Name:<br />
|
<p>Name:<br />
|
||||||
<input type="text" name="cat_name" value="" /></p>
|
<input type="text" name="cat_name" value="" /></p>
|
||||||
<p>Description: (optional) <br />
|
<p>Category parent:<br />
|
||||||
<textarea name="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p>
|
<?php dropdown_cats(FALSE, '', 'name', 'asc', FALSE, FALSE, FALSE, TRUE); ?></p>
|
||||||
<p><input type="hidden" name="action" value="addcat" /><input type="submit" name="submit" value="Add" class="search" /></p>
|
<p>Description: (optional) <br />
|
||||||
</form>
|
<textarea name="category_description" rows="5" cols="50" style="width: 97%;"></textarea></p>
|
||||||
|
<p><input type="hidden" name="action" value="addcat" /><input type="submit" name="submit" value="Add" class="search" /></p>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div class="wrap">
|
<div class="wrap">
|
||||||
<p><strong>Note:</strong><br />
|
<p><strong>Note:</strong><br />
|
||||||
Deleting a category does not delete posts from that category, it will just
|
Deleting a category does not delete posts from that category, it will just
|
||||||
set them back to the default category <strong><?php echo get_catname(1) ?></strong>.
|
set them back to the default category <strong><?php echo get_catname(1) ?></strong>.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* </Categories> */
|
/* </Categories> */
|
||||||
include('admin-footer.php');
|
include('admin-footer.php');
|
||||||
?>
|
?>
|
|
@ -6,35 +6,35 @@ $use_cache = 1; // No reason not to
|
||||||
$curpath = dirname(__FILE__).'/';
|
$curpath = dirname(__FILE__).'/';
|
||||||
|
|
||||||
if (!file_exists($curpath . '/wp-config.php'))
|
if (!file_exists($curpath . '/wp-config.php'))
|
||||||
die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://wordpress.org/docs/faq/#wp-config'>We got it</a>. You can <a href='wp-admin/install-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.");
|
die("There doesn't seem to be a <code>wp-config.php</code> file. I need this before we can get started. Need more help? <a href='http://wordpress.org/docs/faq/#wp-config'>We got it</a>. You can <a href='wp-admin/install-config.php'>create a <code>wp-config.php</code> file through a web interface</a>, but this doesn't work for all server setups. The safest way is to manually create the file.");
|
||||||
|
|
||||||
require($curpath.'/wp-config.php');
|
require($curpath.'/wp-config.php');
|
||||||
|
|
||||||
$wpvarstoreset = array('m','p','posts','w','c', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'name', 'category_name');
|
$wpvarstoreset = array('m','p','posts','w','c', 'cat','withcomments','s','search','exact', 'sentence','poststart','postend','preview','debug', 'calendar','page','paged','more','tb', 'pb','author','order','orderby', 'year', 'monthnum', 'day', 'name', 'category_name');
|
||||||
|
|
||||||
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($HTTP_POST_VARS[$wpvar])) {
|
if (empty($HTTP_POST_VARS[$wpvar])) {
|
||||||
if (empty($HTTP_GET_VARS[$wpvar])) {
|
if (empty($HTTP_GET_VARS[$wpvar])) {
|
||||||
$$wpvar = '';
|
$$wpvar = '';
|
||||||
} else {
|
} else {
|
||||||
$$wpvar = $HTTP_GET_VARS[$wpvar];
|
$$wpvar = $HTTP_GET_VARS[$wpvar];
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$$wpvar = $HTTP_POST_VARS[$wpvar];
|
$$wpvar = $HTTP_POST_VARS[$wpvar];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Sending HTTP headers */
|
/* Sending HTTP headers */
|
||||||
// It is presumptious to think that WP is the only thing that might change on the page.
|
// It is presumptious to think that WP is the only thing that might change on the page.
|
||||||
@header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
|
@header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
|
||||||
@header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
|
@header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // always modified
|
||||||
@header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
|
@header("Cache-Control: no-store, no-cache, must-revalidate"); // HTTP/1.1
|
||||||
@header("Cache-Control: post-check=0, pre-check=0", false);
|
@header("Cache-Control: post-check=0, pre-check=0", false);
|
||||||
@header("Pragma: no-cache"); // HTTP/1.0
|
@header("Pragma: no-cache"); // HTTP/1.0
|
||||||
@header ("X-Pingback: $siteurl/xmlrpc.php");
|
@header ("X-Pingback: $siteurl/xmlrpc.php");
|
||||||
|
|
||||||
/* Getting settings from db */
|
/* Getting settings from db */
|
||||||
|
@ -62,103 +62,110 @@ if ($pagenow != 'post.php') { timer_start(); }
|
||||||
|
|
||||||
if (isset($showposts) && $showposts) {
|
if (isset($showposts) && $showposts) {
|
||||||
$showposts = (int)$showposts;
|
$showposts = (int)$showposts;
|
||||||
$posts_per_page = $showposts;
|
$posts_per_page = $showposts;
|
||||||
}
|
}
|
||||||
// if a month is specified in the querystring, load that month
|
// if a month is specified in the querystring, load that month
|
||||||
if ($m != '') {
|
if ($m != '') {
|
||||||
$m = ''.intval($m);
|
$m = ''.intval($m);
|
||||||
$where .= ' AND YEAR(post_date)='.substr($m,0,4);
|
$where .= ' AND YEAR(post_date)='.substr($m,0,4);
|
||||||
if (strlen($m)>5)
|
if (strlen($m)>5)
|
||||||
$where .= ' AND MONTH(post_date)='.substr($m,4,2);
|
$where .= ' AND MONTH(post_date)='.substr($m,4,2);
|
||||||
if (strlen($m)>7)
|
if (strlen($m)>7)
|
||||||
$where .= ' AND DAYOFMONTH(post_date)='.substr($m,6,2);
|
$where .= ' AND DAYOFMONTH(post_date)='.substr($m,6,2);
|
||||||
if (strlen($m)>9)
|
if (strlen($m)>9)
|
||||||
$where .= ' AND HOUR(post_date)='.substr($m,8,2);
|
$where .= ' AND HOUR(post_date)='.substr($m,8,2);
|
||||||
if (strlen($m)>11)
|
if (strlen($m)>11)
|
||||||
$where .= ' AND MINUTE(post_date)='.substr($m,10,2);
|
$where .= ' AND MINUTE(post_date)='.substr($m,10,2);
|
||||||
if (strlen($m)>13)
|
if (strlen($m)>13)
|
||||||
$where .= ' AND SECOND(post_date)='.substr($m,12,2);
|
$where .= ' AND SECOND(post_date)='.substr($m,12,2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($year != '') {
|
if ($year != '') {
|
||||||
$year = '' . intval($year);
|
$year = '' . intval($year);
|
||||||
$where .= ' AND YEAR(post_date)=' . $year;
|
$where .= ' AND YEAR(post_date)=' . $year;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($monthnum != '') {
|
if ($monthnum != '') {
|
||||||
$monthnum = '' . intval($monthnum);
|
$monthnum = '' . intval($monthnum);
|
||||||
$where .= ' AND MONTH(post_date)=' . $monthnum;
|
$where .= ' AND MONTH(post_date)=' . $monthnum;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($day != '') {
|
if ($day != '') {
|
||||||
$day = '' . intval($day);
|
$day = '' . intval($day);
|
||||||
$where .= ' AND DAYOFMONTH(post_date)=' . $day;
|
$where .= ' AND DAYOFMONTH(post_date)=' . $day;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($name != '') {
|
if ($name != '') {
|
||||||
$name = preg_replace('/[^a-z0-9-]/', '', $name);
|
$name = preg_replace('/[^a-z0-9-]/', '', $name);
|
||||||
$where .= " AND post_name = '$name'";
|
$where .= " AND post_name = '$name'";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($w != '') {
|
if ($w != '') {
|
||||||
$w = ''.intval($w);
|
$w = ''.intval($w);
|
||||||
$where .= ' AND WEEK(post_date, 1)=' . $w;
|
$where .= ' AND WEEK(post_date, 1)=' . $w;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if a post number is specified, load that post
|
// if a post number is specified, load that post
|
||||||
if (($p != '') && ($p != 'all')) {
|
if (($p != '') && ($p != 'all')) {
|
||||||
$p = intval($p);
|
$p = intval($p);
|
||||||
$where = ' AND ID = '.$p;
|
$where = ' AND ID = '.$p;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if a search pattern is specified, load the posts that match
|
// if a search pattern is specified, load the posts that match
|
||||||
if (!empty($s)) {
|
if (!empty($s)) {
|
||||||
$s = addslashes_gpc($s);
|
$s = addslashes_gpc($s);
|
||||||
$search = ' AND (';
|
$search = ' AND (';
|
||||||
// puts spaces instead of commas
|
// puts spaces instead of commas
|
||||||
$s = preg_replace('/, +/', '', $s);
|
$s = preg_replace('/, +/', '', $s);
|
||||||
$s = str_replace(',', ' ', $s);
|
$s = str_replace(',', ' ', $s);
|
||||||
$s = str_replace('"', ' ', $s);
|
$s = str_replace('"', ' ', $s);
|
||||||
$s = trim($s);
|
$s = trim($s);
|
||||||
if ($exact) {
|
if ($exact) {
|
||||||
$n = '';
|
$n = '';
|
||||||
} else {
|
} else {
|
||||||
$n = '%';
|
$n = '%';
|
||||||
}
|
}
|
||||||
if (!$sentence) {
|
if (!$sentence) {
|
||||||
$s_array = explode(' ',$s);
|
$s_array = explode(' ',$s);
|
||||||
$search .= '((post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$n.$s_array[0].$n.'\'))';
|
$search .= '((post_title LIKE \''.$n.$s_array[0].$n.'\') OR (post_content LIKE \''.$n.$s_array[0].$n.'\'))';
|
||||||
for ( $i = 1; $i < count($s_array); $i = $i + 1) {
|
for ( $i = 1; $i < count($s_array); $i = $i + 1) {
|
||||||
$search .= ' AND ((post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))';
|
$search .= ' AND ((post_title LIKE \''.$n.$s_array[$i].$n.'\') OR (post_content LIKE \''.$n.$s_array[$i].$n.'\'))';
|
||||||
}
|
}
|
||||||
$search .= ' OR (post_title LIKE \''.$n.$s.$n.'\') OR (post_content LIKE \''.$n.$s.$n.'\')';
|
$search .= ' OR (post_title LIKE \''.$n.$s.$n.'\') OR (post_content LIKE \''.$n.$s.$n.'\')';
|
||||||
$search .= ')';
|
$search .= ')';
|
||||||
} else {
|
} else {
|
||||||
$search = ' AND ((post_title LIKE \''.$n.$s.$n.'\') OR (post_content LIKE \''.$n.$s.$n.'\'))';
|
$search = ' AND ((post_title LIKE \''.$n.$s.$n.'\') OR (post_content LIKE \''.$n.$s.$n.'\'))';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// category stuff
|
// category stuff
|
||||||
|
$dogs = $wpdb->get_results("SELECT * FROM $tablecategories WHERE 1=1");
|
||||||
|
foreach ($dogs as $catt) {
|
||||||
|
$cache_categories[$catt->cat_ID] = $catt;
|
||||||
|
}
|
||||||
|
|
||||||
if ((empty($cat)) || ($cat == 'all') || ($cat == '0')) {
|
if ((empty($cat)) || ($cat == 'all') || ($cat == '0')) {
|
||||||
$whichcat='';
|
$whichcat='';
|
||||||
} else {
|
} else {
|
||||||
$cat = ''.urldecode($cat).'';
|
$cat = ''.urldecode($cat).'';
|
||||||
$cat = addslashes_gpc($cat);
|
$cat = addslashes_gpc($cat);
|
||||||
if (stristr($cat,'-')) {
|
if (stristr($cat,'-')) {
|
||||||
$eq = '!=';
|
$eq = '!=';
|
||||||
$andor = 'AND';
|
$andor = 'AND';
|
||||||
$cat = explode('-',$cat);
|
$cat = explode('-',$cat);
|
||||||
$cat = intval($cat[1]);
|
$cat = intval($cat[1]);
|
||||||
} else {
|
} else {
|
||||||
$eq = '=';
|
$eq = '=';
|
||||||
$andor = 'OR';
|
$andor = 'OR';
|
||||||
}
|
}
|
||||||
$join = " LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) ";
|
$join = " LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) ";
|
||||||
$cat_array = explode(' ',$cat);
|
$cat_array = explode(' ',$cat);
|
||||||
$whichcat .= ' AND (category_id '.$eq.' '.intval($cat_array[0]);
|
$whichcat .= ' AND (category_id '.$eq.' '.intval($cat_array[0]);
|
||||||
|
$whichcat .= get_category_children($cat_array[0], ' '.$andor.' category_id '.$eq.' ');
|
||||||
for ($i = 1; $i < (count($cat_array)); $i = $i + 1) {
|
for ($i = 1; $i < (count($cat_array)); $i = $i + 1) {
|
||||||
$whichcat .= ' '.$andor.' category_id '.$eq.' '.intval($cat_array[$i]);
|
$whichcat .= ' '.$andor.' category_id '.$eq.' '.intval($cat_array[$i]);
|
||||||
|
$whichcat .= get_category_children($cat_array[$i], ' '.$andor.' category_id '.$eq.' ');
|
||||||
}
|
}
|
||||||
$whichcat .= ')';
|
$whichcat .= ')';
|
||||||
}
|
}
|
||||||
|
@ -166,136 +173,146 @@ if ((empty($cat)) || ($cat == 'all') || ($cat == '0')) {
|
||||||
// Category stuff for nice URIs
|
// Category stuff for nice URIs
|
||||||
|
|
||||||
if ('' != $category_name) {
|
if ('' != $category_name) {
|
||||||
$category_name = preg_replace('|[^a-z0-9-]|', '', $category_name);
|
if (stristr($category_name,'/')) {
|
||||||
$tables = ", $tablepost2cat, $tablecategories";
|
$category_name = explode('/',$category_name);
|
||||||
$join = " LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) LEFT JOIN $tablecategories ON ($tablepost2cat.category_id = $tablecategories.cat_ID) ";
|
if ($category_name[count($category_name)-1]) {
|
||||||
$whichcat = " AND (category_nicename = '$category_name') ";
|
$category_name = $category_name[count($category_name)-1];#no trailing slash
|
||||||
$cat = $wpdb->get_var("SELECT cat_ID FROM $tablecategories WHERE category_nicename = '$category_name'");
|
} else {
|
||||||
|
$category_name = $category_name[count($category_name)-2];#there was a trailling slash
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$category_name = preg_replace('|[^a-z0-9-]|', '', $category_name);
|
||||||
|
$tables = ", $tablepost2cat, $tablecategories";
|
||||||
|
$join = " LEFT JOIN $tablepost2cat ON ($tableposts.ID = $tablepost2cat.post_id) LEFT JOIN $tablecategories ON ($tablepost2cat.category_id = $tablecategories.cat_ID) ";
|
||||||
|
$whichcat = " AND (category_nicename = '$category_name'";
|
||||||
|
$cat = $wpdb->get_var("SELECT cat_ID FROM $tablecategories WHERE category_nicename = '$category_name'");
|
||||||
|
$whichcat .= get_category_children($cat, " OR category_id = ");
|
||||||
|
$whichcat .= ")";
|
||||||
}
|
}
|
||||||
|
|
||||||
// author stuff
|
// author stuff
|
||||||
if ((empty($author)) || ($author == 'all') || ($author == '0')) {
|
if ((empty($author)) || ($author == 'all') || ($author == '0')) {
|
||||||
$whichauthor='';
|
$whichauthor='';
|
||||||
} else {
|
} else {
|
||||||
$author = ''.urldecode($author).'';
|
$author = ''.urldecode($author).'';
|
||||||
$author = addslashes_gpc($author);
|
$author = addslashes_gpc($author);
|
||||||
if (stristr($author, '-')) {
|
if (stristr($author, '-')) {
|
||||||
$eq = '!=';
|
$eq = '!=';
|
||||||
$andor = 'AND';
|
$andor = 'AND';
|
||||||
$author = explode('-', $author);
|
$author = explode('-', $author);
|
||||||
$author = ''.intval($author[1]);
|
$author = ''.intval($author[1]);
|
||||||
} else {
|
} else {
|
||||||
$eq = '=';
|
$eq = '=';
|
||||||
$andor = 'OR';
|
$andor = 'OR';
|
||||||
}
|
}
|
||||||
$author_array = explode(' ', $author);
|
$author_array = explode(' ', $author);
|
||||||
$whichauthor .= ' AND (post_author '.$eq.' '.intval($author_array[0]);
|
$whichauthor .= ' AND (post_author '.$eq.' '.intval($author_array[0]);
|
||||||
for ($i = 1; $i < (count($author_array)); $i = $i + 1) {
|
for ($i = 1; $i < (count($author_array)); $i = $i + 1) {
|
||||||
$whichauthor .= ' '.$andor.' post_author '.$eq.' '.intval($author_array[$i]);
|
$whichauthor .= ' '.$andor.' post_author '.$eq.' '.intval($author_array[$i]);
|
||||||
}
|
}
|
||||||
$whichauthor .= ')';
|
$whichauthor .= ')';
|
||||||
}
|
}
|
||||||
|
|
||||||
$where .= $search.$whichcat.$whichauthor;
|
$where .= $search.$whichcat.$whichauthor;
|
||||||
|
|
||||||
if ((empty($order)) || ((strtoupper($order) != 'ASC') && (strtoupper($order) != 'DESC'))) {
|
if ((empty($order)) || ((strtoupper($order) != 'ASC') && (strtoupper($order) != 'DESC'))) {
|
||||||
$order='DESC';
|
$order='DESC';
|
||||||
}
|
}
|
||||||
|
|
||||||
// order by stuff
|
// order by stuff
|
||||||
if (empty($orderby)) {
|
if (empty($orderby)) {
|
||||||
$orderby='date '.$order;
|
$orderby='date '.$order;
|
||||||
} else {
|
} else {
|
||||||
// used to filter values
|
// used to filter values
|
||||||
$allowed_keys = array('author','date','category','title');
|
$allowed_keys = array('author','date','category','title');
|
||||||
$orderby = urldecode($orderby);
|
$orderby = urldecode($orderby);
|
||||||
$orderby = addslashes_gpc($orderby);
|
$orderby = addslashes_gpc($orderby);
|
||||||
$orderby_array = explode(' ',$orderby);
|
$orderby_array = explode(' ',$orderby);
|
||||||
if (!in_array($orderby_array[0],$allowed_keys)) {
|
if (!in_array($orderby_array[0],$allowed_keys)) {
|
||||||
$orderby_array[0] = 'date';
|
$orderby_array[0] = 'date';
|
||||||
}
|
}
|
||||||
$orderby = $orderby_array[0].' '.$order;
|
$orderby = $orderby_array[0].' '.$order;
|
||||||
if (count($orderby_array)>1) {
|
if (count($orderby_array)>1) {
|
||||||
for ($i = 1; $i < (count($orderby_array)); $i = $i + 1) {
|
for ($i = 1; $i < (count($orderby_array)); $i = $i + 1) {
|
||||||
// Only allow certain values for safety
|
// Only allow certain values for safety
|
||||||
if (in_array($orderby_array[$i],$allowed_keys)) {
|
if (in_array($orderby_array[$i],$allowed_keys)) {
|
||||||
$orderby .= ',post_'.$orderby_array[$i].' '.$order;
|
$orderby .= ',post_'.$orderby_array[$i].' '.$order;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((!$whichcat) && (!$m) && (!$p) && (!$w) && (!$s) && empty($poststart) && empty($postend)) {
|
if ((!$whichcat) && (!$m) && (!$p) && (!$w) && (!$s) && empty($poststart) && empty($postend)) {
|
||||||
if ($what_to_show == 'posts') {
|
if ($what_to_show == 'posts') {
|
||||||
$limits = ' LIMIT '.$posts_per_page;
|
$limits = ' LIMIT '.$posts_per_page;
|
||||||
} elseif ($what_to_show == 'days' && empty($monthnum) && empty($year) && empty($day)) {
|
} elseif ($what_to_show == 'days' && empty($monthnum) && empty($year) && empty($day)) {
|
||||||
$lastpostdate = get_lastpostdate();
|
$lastpostdate = get_lastpostdate();
|
||||||
$lastpostdate = mysql2date('Y-m-d 00:00:00',$lastpostdate);
|
$lastpostdate = mysql2date('Y-m-d 00:00:00',$lastpostdate);
|
||||||
$lastpostdate = mysql2date('U',$lastpostdate);
|
$lastpostdate = mysql2date('U',$lastpostdate);
|
||||||
$otherdate = date('Y-m-d H:i:s', ($lastpostdate - (($posts_per_page-1) * 86400)));
|
$otherdate = date('Y-m-d H:i:s', ($lastpostdate - (($posts_per_page-1) * 86400)));
|
||||||
$where .= ' AND post_date > \''.$otherdate.'\'';
|
$where .= ' AND post_date > \''.$otherdate.'\'';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !empty($postend) && ($postend > $poststart) && (!$m) && empty($monthnum) && empty($year) && empty($day) &&(!$w) && (!$whichcat) && (!$s) && (!$p)) {
|
if ( !empty($postend) && ($postend > $poststart) && (!$m) && empty($monthnum) && empty($year) && empty($day) &&(!$w) && (!$whichcat) && (!$s) && (!$p)) {
|
||||||
if ($what_to_show == 'posts' || ($what_to_show == 'paged' && (!$paged))) {
|
if ($what_to_show == 'posts' || ($what_to_show == 'paged' && (!$paged))) {
|
||||||
$poststart = intval($poststart);
|
$poststart = intval($poststart);
|
||||||
$postend = intval($postend);
|
$postend = intval($postend);
|
||||||
$limposts = $postend - $poststart;
|
$limposts = $postend - $poststart;
|
||||||
$limits = ' LIMIT '.$poststart.','.$limposts;
|
$limits = ' LIMIT '.$poststart.','.$limposts;
|
||||||
} elseif ($what_to_show == 'days') {
|
} elseif ($what_to_show == 'days') {
|
||||||
$poststart = intval($poststart);
|
$poststart = intval($poststart);
|
||||||
$postend = intval($postend);
|
$postend = intval($postend);
|
||||||
$limposts = $postend - $poststart;
|
$limposts = $postend - $poststart;
|
||||||
$lastpostdate = get_lastpostdate();
|
$lastpostdate = get_lastpostdate();
|
||||||
$lastpostdate = mysql2date('Y-m-d 00:00:00',$lastpostdate);
|
$lastpostdate = mysql2date('Y-m-d 00:00:00',$lastpostdate);
|
||||||
$lastpostdate = mysql2date('U',$lastpostdate);
|
$lastpostdate = mysql2date('U',$lastpostdate);
|
||||||
$startdate = date('Y-m-d H:i:s', ($lastpostdate - (($poststart -1) * 86400)));
|
$startdate = date('Y-m-d H:i:s', ($lastpostdate - (($poststart -1) * 86400)));
|
||||||
$otherdate = date('Y-m-d H:i:s', ($lastpostdate - (($postend -1) * 86400)));
|
$otherdate = date('Y-m-d H:i:s', ($lastpostdate - (($postend -1) * 86400)));
|
||||||
$where .= ' AND post_date > \''.$otherdate.'\' AND post_date < \''.$startdate.'\'';
|
$where .= ' AND post_date > \''.$otherdate.'\' AND post_date < \''.$startdate.'\'';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (($what_to_show == 'paged') && (!$p) && (!$more)) {
|
if (($what_to_show == 'paged') && (!$p) && (!$more)) {
|
||||||
if ($pagenow != 'post.php') {
|
if ($pagenow != 'post.php') {
|
||||||
$pgstrt = '';
|
$pgstrt = '';
|
||||||
if ($paged) {
|
if ($paged) {
|
||||||
$pgstrt = (intval($paged) -1) * $posts_per_page . ', ';
|
$pgstrt = (intval($paged) -1) * $posts_per_page . ', ';
|
||||||
}
|
}
|
||||||
$limits = 'LIMIT '.$pgstrt.$posts_per_page;
|
$limits = 'LIMIT '.$pgstrt.$posts_per_page;
|
||||||
} else {
|
} else {
|
||||||
if (($m) || ($p) || ($w) || ($s) || ($whichcat)) {
|
if (($m) || ($p) || ($w) || ($s) || ($whichcat)) {
|
||||||
$limits = '';
|
$limits = '';
|
||||||
} else {
|
} else {
|
||||||
$pgstrt = '';
|
$pgstrt = '';
|
||||||
if ($paged) {
|
if ($paged) {
|
||||||
$pgstrt = (intval($paged) -1) * $posts_per_page . ', ';
|
$pgstrt = (intval($paged) -1) * $posts_per_page . ', ';
|
||||||
}
|
}
|
||||||
$limits = 'LIMIT '.$pgstrt.$posts_per_page;
|
$limits = 'LIMIT '.$pgstrt.$posts_per_page;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
elseif (($m) || ($p) || ($w) || ($s) || ($whichcat) || ($author) || $monthnum || $year || $day) {
|
elseif (($m) || ($p) || ($w) || ($s) || ($whichcat) || ($author) || $monthnum || $year || $day) {
|
||||||
$limits = '';
|
$limits = '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($p == 'all') {
|
if ($p == 'all') {
|
||||||
$where = '';
|
$where = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
$now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));
|
$now = date('Y-m-d H:i:s',(time() + ($time_difference * 3600)));
|
||||||
|
|
||||||
if ($pagenow != 'post.php' && $pagenow != 'edit.php') {
|
if ($pagenow != 'post.php' && $pagenow != 'edit.php') {
|
||||||
if ((empty($poststart)) || (empty($postend)) || !($postend > $poststart)) {
|
if ((empty($poststart)) || (empty($postend)) || !($postend > $poststart)) {
|
||||||
$where .= ' AND post_date <= \''.$now.'\'';
|
$where .= ' AND post_date <= \''.$now.'\'';
|
||||||
}
|
}
|
||||||
|
|
||||||
$distinct = 'DISTINCT';
|
$distinct = 'DISTINCT';
|
||||||
|
|
||||||
if ($use_gzipcompression) {
|
if ($use_gzipcompression) {
|
||||||
// gzipping the output of the script
|
// gzipping the output of the script
|
||||||
gzip_compression();
|
gzip_compression();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$where .= ' AND (post_status = "publish"';
|
$where .= ' AND (post_status = "publish"';
|
||||||
|
|
||||||
|
@ -309,12 +326,12 @@ $request = " SELECT $distinct * FROM $tableposts $join WHERE 1=1".$where." ORDER
|
||||||
|
|
||||||
|
|
||||||
if ($preview) {
|
if ($preview) {
|
||||||
$request = 'SELECT 1-1'; // dummy mysql query for the preview
|
$request = 'SELECT 1-1'; // dummy mysql query for the preview
|
||||||
// little funky fix for IEwin, rawk on that code
|
// little funky fix for IEwin, rawk on that code
|
||||||
$is_winIE = ((preg_match('/MSIE/',$HTTP_USER_AGENT)) && (preg_match('/Win/',$HTTP_USER_AGENT)));
|
$is_winIE = ((preg_match('/MSIE/',$HTTP_USER_AGENT)) && (preg_match('/Win/',$HTTP_USER_AGENT)));
|
||||||
if (($is_winIE) && (!isset($IEWin_bookmarklet_fix))) {
|
if (($is_winIE) && (!isset($IEWin_bookmarklet_fix))) {
|
||||||
$preview_content = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $preview_content);
|
$preview_content = preg_replace('/\%u([0-9A-F]{4,4})/e', "'&#'.base_convert('\\1',16,10).';'", $preview_content);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// error_log("$request");
|
// error_log("$request");
|
||||||
|
@ -325,39 +342,39 @@ $posts = $wpdb->get_results($request);
|
||||||
if ($posts) {
|
if ($posts) {
|
||||||
// Get the categories for all the posts
|
// Get the categories for all the posts
|
||||||
foreach ($posts as $post) {
|
foreach ($posts as $post) {
|
||||||
$post_id_list[] = $post->ID;
|
$post_id_list[] = $post->ID;
|
||||||
}
|
}
|
||||||
$post_id_list = implode(',', $post_id_list);
|
$post_id_list = implode(',', $post_id_list);
|
||||||
|
|
||||||
$dogs = $wpdb->get_results("SELECT DISTINCT
|
$dogs = $wpdb->get_results("SELECT DISTINCT
|
||||||
ID, category_id, cat_name, category_nicename, category_description
|
ID, category_id, cat_name, category_nicename, category_description, category_parent
|
||||||
FROM $tablecategories, $tablepost2cat, $tableposts
|
FROM $tablecategories, $tablepost2cat, $tableposts
|
||||||
WHERE category_id = cat_ID AND post_id = ID AND post_id IN ($post_id_list)");
|
WHERE category_id = cat_ID AND post_id = ID AND post_id IN ($post_id_list)");
|
||||||
|
|
||||||
foreach ($dogs as $catt) {
|
foreach ($dogs as $catt) {
|
||||||
$category_cache[$catt->ID][] = $catt;
|
$category_cache[$catt->ID][] = $catt;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Do the same for comment numbers
|
// Do the same for comment numbers
|
||||||
$comment_counts = $wpdb->get_results("SELECT ID, COUNT( comment_ID ) AS ccount
|
$comment_counts = $wpdb->get_results("SELECT ID, COUNT( comment_ID ) AS ccount
|
||||||
FROM $tableposts
|
FROM $tableposts
|
||||||
LEFT JOIN $tablecomments ON ( comment_post_ID = ID AND comment_approved = '1')
|
LEFT JOIN $tablecomments ON ( comment_post_ID = ID AND comment_approved = '1')
|
||||||
WHERE post_status = 'publish' AND ID IN ($post_id_list)
|
WHERE post_status = 'publish' AND ID IN ($post_id_list)
|
||||||
GROUP BY ID");
|
GROUP BY ID");
|
||||||
|
|
||||||
foreach ($comment_counts as $comment_count) {
|
foreach ($comment_counts as $comment_count) {
|
||||||
$comment_count_cache["$comment_count->ID"] = $comment_count->ccount;
|
$comment_count_cache["$comment_count->ID"] = $comment_count->ccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (1 == count($posts)) {
|
if (1 == count($posts)) {
|
||||||
if ($p || $name) {
|
if ($p || $name) {
|
||||||
$more = 1;
|
$more = 1;
|
||||||
$c = 1;
|
$c = 1;
|
||||||
$single = 1;
|
$single = 1;
|
||||||
}
|
}
|
||||||
if ($s && empty($paged)) { // If they were doing a search and got one result
|
if ($s && empty($paged)) { // If they were doing a search and got one result
|
||||||
header('Location: ' . get_permalink($posts[0]->ID));
|
header('Location: ' . get_permalink($posts[0]->ID));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
File diff suppressed because it is too large
Load Diff
|
@ -223,6 +223,11 @@ p, li, .feedback {
|
||||||
border-bottom: 1px solid #809080;
|
border-bottom: 1px solid #809080;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#menu ul ul ul.children {
|
||||||
|
padding-left:4px;
|
||||||
|
font-size:142%;
|
||||||
|
}
|
||||||
|
|
||||||
#wp-calendar {
|
#wp-calendar {
|
||||||
border: 1px solid #ddd;
|
border: 1px solid #ddd;
|
||||||
empty-cells: show;
|
empty-cells: show;
|
||||||
|
|
Loading…
Reference in New Issue