+ Changed generating last post and post count in forum and topic.php

+ Deleted not used template file: post_add_body.tpl
+ Replaced MCP images

git-svn-id: https://svn.pioder.pl/uf-svn/uF@21 72ec579a-5ced-4fa4-82f3-afba5d98df2f
This commit is contained in:
pioder
2009-05-03 21:00:21 +00:00
parent b1f37b6ea5
commit c2ba3eb804
70 changed files with 371 additions and 395 deletions

View File

@@ -35,7 +35,7 @@ function GenerateDefaultDisplay()
//cache forums --don't modify!!!
$cache_id=1;
$sql = "SELECT * FROM ".FORUMS_TABLE." ORDER BY `c_id`, `sort`";
$query = DataBase::sql_query($sql,'CRITICAL','Could not obtain forum information.');
$query = DataBase::sql_query($sql,CRITICAL,'Could not obtain forum information.');
while($result = DataBase::fetch($query))
{
$forum[$cache_id]['f_id'] = $result['f_id'];
@@ -58,7 +58,7 @@ function GenerateDefaultDisplay()
include('./template/forums_beam_body.tpl');
//add forums and categories
$sql = "SELECT * FROM `".CATS_TABLE."` ORDER BY `sort`";
$query = DataBase::sql_query($sql,'CRITICAL','Could not obtain categories information.');
$query = DataBase::sql_query($sql,CRITICAL,'Could not obtain categories information.');
while($result = DataBase::fetch($query))
{
$skin = array(
@@ -115,15 +115,15 @@ switch($_GET['mode'])
{
$cat_name = strip_tags($_POST['cat_name']);
$sql = "SELECT `sort` FROM `".CATS_TABLE."` ORDER BY `sort` DESC LIMIT 1";
$last = DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain last category sort id'));
$last = DataBase::fetch(DataBase::sql_query($sql,GENERAL,'Could not obtain last category sort id'));
$sort = $last ['sort'];
$sort = $sort+1;
$sql = "SELECT `c_id` FROM `".CATS_TABLE."` ORDER BY `c_id` DESC LIMIT 1";
$last = DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain last category id'));
$last = DataBase::fetch(DataBase::sql_query($sql,GENERAL,'Could not obtain last category id'));
$last = $last['c_id'];
$last = $last +1;
$sql = "INSERT INTO `".CATS_TABLE."` VALUES ('$last','$cat_name','$sort')";
DataBase::sql_query($sql,'GENERAL','Could not add category');
DataBase::sql_query($sql,GENERAL,'Could not add category');
$msg='./template/blank.tpl';
admin_message_forum($lng['cat_saved'],'admin_forums.php');
}
@@ -169,15 +169,15 @@ switch($_GET['mode'])
$forum_lock = (isset($_POST['forum_locked'])) ? 1 : 0;
$allow_moderate = (isset($_POST['allow_moderate'])) ? 1 : 0;
$sql = "SELECT `sort`, `c_id` FROM `".FORUMS_TABLE."` WHERE `c_id`='$forum_cat' ORDER BY `sort` DESC LIMIT 1";
$last = DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain last forum sort id'));
$last = DataBase::fetch(DataBase::sql_query($sql,GENERAL,'Could not obtain last forum sort id'));
$sort = $last ['sort'];
$sort = $sort+1;
$sql = "SELECT `f_id` FROM `".FORUMS_TABLE."` ORDER BY `f_id` DESC LIMIT 1";
$last = DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain last forum id'));
$last = DataBase::fetch(DataBase::sql_query($sql,GENERAL,'Could not obtain last forum id'));
$last = $last['f_id'];
$last = $last +1;
$sql = "INSERT INTO `".FORUMS_TABLE."` VALUES ('$last','$forum_lock','$allow_moderate', '$forum_name', '$forum_desc','$forum_cat','$sort')";
DataBase::sql_query($sql,'GENERAL','Could not add forum');
$sql = "INSERT INTO `".FORUMS_TABLE."` VALUES ('$last','$forum_lock','$allow_moderate', '$forum_name', '$forum_desc', '0', '','$forum_cat','$sort')";
DataBase::sql_query($sql,GENERAL,'Could not add forum');
$msg='./../skins/'.$default_skin.'/blank.tpl';
admin_message_forum($lng['forum_saved'],'admin_forums.php');
}
@@ -243,19 +243,19 @@ switch($_GET['mode'])
{
$i1 = $_GET['c'];
$sql = "SELECT `sort`, `c_id` FROM ".CATS_TABLE." WHERE `c_id`='$i1'";
$s1 = DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain category information.'));
$s1 = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not obtain category information.'));
$s1 = $s1['sort'];
$s2 = $s1 -1;
if ($s1>1)
{
$sql = "SELECT `sort`, `c_id` FROM ".CATS_TABLE." WHERE `sort`='$s2'";
$s2 = DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain category information.'));
$s2 = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not obtain category information.'));
$i2 = $s2['c_id'];
$s2 = $s2['sort'];
$sql = "UPDATE ".CATS_TABLE." SET `sort`='$s2' WHERE `c_id`='$i1'";
DataBase::sql_query($sql,'GENERAL','Could not update category position');
DataBase::sql_query($sql,GENERAL,'Could not update category position');
$sql = "UPDATE ".CATS_TABLE." SET `sort`='$s1' WHERE `c_id`='$i2'";
DataBase::sql_query($sql,'GENERAL','Could not update category position');
DataBase::sql_query($sql,GENERAL,'Could not update category position');
}
}
break;
@@ -266,20 +266,20 @@ switch($_GET['mode'])
{
$i1 = $_GET['f'];
$sql = "SELECT `sort`, `c_id`, `f_id` FROM ".FORUMS_TABLE." WHERE `f_id`='$i1'";
$s1 = DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain forum information.'));
$s1 = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not obtain forum information.'));
$cid = $s1['c_id'];
$s1 = $s1['sort'];
$s2 = $s1 -1;
if ($s1>1)
{
$sql = "SELECT `sort`, `c_id`, `f_id` FROM ".FORUMS_TABLE." WHERE `sort`='$s2' AND `c_id`='$cid'";
$s2 = DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not forum forum information.'));
$s2 = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not forum forum information.'));
$i2 = $s2['f_id'];
$s2 = $s2['sort'];
$sql = "UPDATE ".FORUMS_TABLE." SET `sort`='$s2' WHERE `f_id`='$i1'";
DataBase::sql_query($sql,'GENERAL','Could not update forum position');
DataBase::sql_query($sql,GENERAL,'Could not update forum position');
$sql = "UPDATE ".FORUMS_TABLE." SET `sort`='$s1' WHERE `f_id`='$i2'";
DataBase::sql_query($sql,'GENERAL','Could not update forum position');
DataBase::sql_query($sql,GENERAL,'Could not update forum position');
}
}
break;
@@ -306,21 +306,21 @@ switch($_GET['mode'])
$i1 = $_GET['c'];
$i2 = $i1 +1;
$sql = "SELECT `sort`, `c_id` FROM ".CATS_TABLE." WHERE `c_id`='$i1'";
$s1 = DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain category information.'));
$s1 = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not obtain category information.'));
$s1 = $s1['sort'];
$s2 = $s1 +1;
$sql = "SELECT `c_id` FROM ".CATS_TABLE;
$count = DataBase::num_rows(DataBase::sql_query($sql,'CRITICAL','Could not obtain category information.'));
$count = DataBase::num_rows(DataBase::sql_query($sql,CRITICAL,'Could not obtain category information.'));
if ($s1<$count)
{
$sql = "SELECT `sort`, `c_id` FROM ".CATS_TABLE." WHERE `sort`='$s2'";
$s2 = DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain category information.'));
$s2 = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not obtain category information.'));
$i2 = $s2['c_id'];
$s2 = $s2['sort'];
$sql = "UPDATE ".CATS_TABLE." SET `sort`='$s2' WHERE `c_id`='$i1'";
DataBase::sql_query($sql,'GENERAL','Could not update category position');
DataBase::sql_query($sql,GENERAL,'Could not update category position');
$sql = "UPDATE ".CATS_TABLE." SET `sort`='$s1' WHERE `c_id`='$i2'";
DataBase::sql_query($sql,'GENERAL','Could not update category position');
DataBase::sql_query($sql,GENERAL,'Could not update category position');
}
}
break;
@@ -332,22 +332,22 @@ switch($_GET['mode'])
$i1 = $_GET['f'];
$i2 = $i1 +1;
$sql = "SELECT `sort`, `c_id`, `f_id` FROM ".FORUMS_TABLE." WHERE `f_id`='$i1'";
$s1 = DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain forum information.'));
$s1 = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not obtain forum information.'));
$cid = $s1['c_id'];
$s1 = $s1['sort'];
$s2 = $s1 +1;
$sql = "SELECT `f_id` FROM ".FORUMS_TABLE." WHERE `c_id`='$cid'";
$count = DataBase::num_rows(DataBase::sql_query($sql,'CRITICAL','Could not obtain forum information.'));
$count = DataBase::num_rows(DataBase::sql_query($sql,CRITICAL,'Could not obtain forum information.'));
if ($s1<$count)
{
$sql = "SELECT `sort`, `f_id` FROM ".FORUMS_TABLE." WHERE `sort`='$s2'";
$s2 = DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain forum information.'));
$s2 = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not obtain forum information.'));
$i2 = $s2['f_id'];
$s2 = $s2['sort'];
$sql = "UPDATE ".FORUMS_TABLE." SET `sort`='$s2' WHERE `f_id`='$i1'";
DataBase::sql_query($sql,'GENERAL','Could not update forum position');
DataBase::sql_query($sql,GENERAL,'Could not update forum position');
$sql = "UPDATE ".FORUMS_TABLE." SET `sort`='$s1' WHERE `f_id`='$i2'";
DataBase::sql_query($sql,'GENERAL','Could not update forum position');
DataBase::sql_query($sql,GENERAL,'Could not update forum position');
}
}
break;
@@ -368,32 +368,32 @@ switch($_GET['mode'])
{
$cid = intval($_GET['c']);
$sql = "SELECT * FROM `".CATS_TABLE."` WHERE `c_id`='$cid'";
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain category information');
$query = DataBase::sql_query($sql,GENERAL,'Could not obtain category information');
$result = DataBase::fetch($query);
$sort = $result['sort'];
$sql = "SELECT * FROM `".CATS_TABLE."` WHERE `sort`>'$sort'";
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain categories information');
$query = DataBase::sql_query($sql,GENERAL,'Could not obtain categories information');
while($item = DataBase::fetch($query))
{
$new_sort = $item['sort']-1;
$cid2 = $item['c_id'];
$sql2 = "UPDATE `".CATS_TABLE."` SET `sort`='$new_sort' WHERE `c_id`='$cid2'";
DataBase::sql_query($sql,'GENERAL','Could not update category');
DataBase::sql_query($sql,GENERAL,'Could not update category');
}
$sql = "SELECT `f_id` FROM `".FORUMS_TABLE."` WHERE `c_id`='$cid'";
$query = DataBase::sql_query($sql, 'GENERAL','Could not obtain forum information.');
$query = DataBase::sql_query($sql, GENERAL,'Could not obtain forum information.');
while($item = DataBase::fetch($query))
{
$fid = $item['f_id'];
$sql="DELETE FROM `".POSTS_TABLE."` WHERE `f_id`='$fid'";
DataBase::sql_query($sql, 'GENERAL','Could not delete post.');
DataBase::sql_query($sql, GENERAL,'Could not delete post.');
$sql = "DELETE FROM `".TOPICS_TABLE."` WHERE `f_id`='$fid'";
DataBase::sql_query($sql, 'GENERAL','Could not delete topic');
DataBase::sql_query($sql, GENERAL,'Could not delete topic');
}
$sql = "DELETE FROM `".FORUMS_TABLE."` WHERE `c_id`='$cid'";
DataBase::sql_query($sql, 'GENERAL','Could not delete topic');
DataBase::sql_query($sql, GENERAL,'Could not delete topic');
$sql = "DELETE FROM `".CATS_TABLE."` WHERE `c_id`='$cid'";
DataBase::sql_query($sql,'GENERAL','Could not delete category.');
DataBase::sql_query($sql,GENERAL,'Could not delete category.');
}
}
case 'forum':
@@ -402,24 +402,24 @@ switch($_GET['mode'])
{
$fid = intval($_GET['f']);
$sql = "SELECT * FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'";
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain forum information');
$query = DataBase::sql_query($sql,GENERAL,'Could not obtain forum information');
$result = DataBase::fetch($query);
$sort = $result['sort'];
$sql = "SELECT * FROM `".FORUMS_TABLE."` WHERE `sort`>'$sort'";
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain forums information');
$query = DataBase::sql_query($sql,GENERAL,'Could not obtain forums information');
while($item = DataBase::fetch($query))
{
$new_sort = $item['sort']-1;
$fid1 = $item['f_id'];
$sql2 = "UPDATE `".FORUMS_TABLE."` SET `sort`='$new_sort' WHERE `f_id`='$fid1'";
DataBase::sql_query($sql,'GENERAL','Could not update forum');
DataBase::sql_query($sql,GENERAL,'Could not update forum');
}
$sql="DELETE FROM `".POSTS_TABLE."` WHERE `f_id`='$fid'";
DataBase::sql_query($sql, 'GENERAL','Could not delete post.');
DataBase::sql_query($sql, GENERAL,'Could not delete post.');
$sql = "DELETE FROM `".TOPICS_TABLE."` WHERE `f_id`='$fid'";
DataBase::sql_query($sql, 'GENERAL','Could not delete topic');
DataBase::sql_query($sql, GENERAL,'Could not delete topic');
$sql = "DELETE FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'";
DataBase::sql_query($sql, 'GENERAL','Could not delete forum');
DataBase::sql_query($sql, GENERAL,'Could not delete forum');
}
}
}
@@ -439,11 +439,11 @@ switch($_GET['mode'])
{
$cat_name = strip_tags($_POST['cat_name']);
$sql = "SELECT `sort`, `c_id` FROM `".FORUMS_TABLE."` WHERE `c_id`='$cat_name' ORDER BY `sort` DESC LIMIT 1";
$last = DataBase::fetch(DataBase::sql_query($sql,'GENERAL','Could not obtain last forum sort id'));
$last = DataBase::fetch(DataBase::sql_query($sql,GENERAL,'Could not obtain last forum sort id'));
$sort = $last ['sort'];
$sort = $sort+1;
$sql = "UPDATE `".CATS_TABLE."` SET `name`='$cat_name', `sort`='$sort' WHERE `c_id`='$cid'";
DataBase::sql_query($sql,'GENERAL','Could not update category');
DataBase::sql_query($sql,GENERAL,'Could not update category');
$msg='./../skins/'.$default_skin.'/blank.tpl';
admin_message_forum($lng['cat_saved'],'admin_forums.php');
}
@@ -455,7 +455,7 @@ switch($_GET['mode'])
}
else
{
$tmp = DataBase::fetch(DataBase::sql_query("SELECT `name` FROM `".CATS_TABLE."` WHERE `c_id`='$cid'",'GENERAL','Could not obtain category information'));
$tmp = DataBase::fetch(DataBase::sql_query("SELECT `name` FROM `".CATS_TABLE."` WHERE `c_id`='$cid'",GENERAL,'Could not obtain category information'));
$tmp = $tmp['name'];
$_POST['cat_name'] = $tmp;
if($tmp['name']=='')
@@ -495,14 +495,14 @@ switch($_GET['mode'])
$forum_desc = strip_tags($_POST['forum_desc']);
$forum_cat = $_POST['forum_cat'];
$sql = "SELECT * FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'";
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain forum information');
$query = DataBase::sql_query($sql,GENERAL,'Could not obtain forum information');
$result = DataBase::fetch($query);
$actual_cid = $result['c_id'];
$sort = $result['sort'];
if ($actual_cid != $forum_cat)
{
$sql = "SELECT * FROM `".FORUMS_TABLE."` WHERE `c_id`='$forum_cat' ORDER BY `sort` DESC LIMIT 1";
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain forums information');
$query = DataBase::sql_query($sql,GENERAL,'Could not obtain forums information');
$result = DataBase::fetch($query);
$sort = $result['sort']+1;
}
@@ -517,7 +517,7 @@ switch($_GET['mode'])
`c_id`='$forum_cat',
`sort`='$sort'
WHERE `f_id`='$fid'";
DataBase::sql_query($sql,'GENERAL','Could not update forum');
DataBase::sql_query($sql,GENERAL,'Could not update forum');
$msg='./../skins/'.$default_skin.'/blank.tpl';
admin_message_forum($lng['forum_saved'],'admin_forums.php');
}
@@ -535,7 +535,7 @@ switch($_GET['mode'])
}
else
{
$tmp = DataBase::fetch(DataBase::sql_query("SELECT `name`, `desc` FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'",'GENERAL','Could not obtain forum information'));
$tmp = DataBase::fetch(DataBase::sql_query("SELECT `name`, `desc` FROM `".FORUMS_TABLE."` WHERE `f_id`='$fid'",GENERAL,'Could not obtain forum information'));
$_POST['forum_name'] = $tmp['name'];
$msg='./../skins/'.$default_skin.'/blank.tpl';
$_POST['forum_desc'] = $tmp['desc'];