+ 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:
@@ -19,7 +19,7 @@ function SetCounter()
|
||||
{
|
||||
setcookie('forum_visited','1');
|
||||
$visit_count = $forum_config['forum_counter'] +1;
|
||||
DataBase::sql_query("UPDATE `".CONFIG_TABLE."` SET `value`='$visit_count' WHERE `name`='forum_counter'",'GENERAL','Could not update forum counter');
|
||||
DataBase::sql_query("UPDATE `".CONFIG_TABLE."` SET `value`='$visit_count' WHERE `name`='forum_counter'",GENERAL,'Could not update forum counter');
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -201,7 +201,7 @@ function AddSkins()
|
||||
global $forum_config;
|
||||
global $default_skin;
|
||||
$all='';
|
||||
$query = DataBase::sql_query("SELECT `name`, `s_id` FROM `".SKINS_TABLE."`",'GENERAL','Could not obtain skins information');
|
||||
$query = DataBase::sql_query("SELECT `name`, `s_id` FROM `".SKINS_TABLE."`",GENERAL,'Could not obtain skins information');
|
||||
while($t = DataBase::fetch($query))
|
||||
{
|
||||
|
||||
@@ -277,7 +277,7 @@ function IfModGroup($guid)
|
||||
function TotalPosts()
|
||||
{
|
||||
$sql = "SELECT count(*) as `p_id` FROM ".POSTS_TABLE."";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain total posts information');
|
||||
$query = DataBase::sql_query($sql,GENERAL,'Could not obtain total posts information');
|
||||
$result = DataBase::fetch($query);
|
||||
$result = $result['p_id'];
|
||||
|
||||
@@ -338,13 +338,15 @@ function ViewSkinName()
|
||||
$result = $forum_config['defaultskin'];
|
||||
}
|
||||
$sql = "SELECT * FROM `".SKINS_TABLE."` WHERE `s_id`='$result'";
|
||||
$result = DataBase::fetch(DataBase::sql_query($sql,'CRITICAL','Could not obtain skin information.'));
|
||||
$result = DataBase::fetch(DataBase::sql_query($sql,CRITICAL,'Could not obtain skin information.'));
|
||||
|
||||
return $result['name'];
|
||||
}
|
||||
|
||||
function GenerateLastPost($id, $type)
|
||||
{
|
||||
$last_post = '';
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
/** field lastpost in forum format
|
||||
@@ -352,8 +354,8 @@ function GenerateLastPost($id, $type)
|
||||
*/
|
||||
case 1: //for forum
|
||||
{
|
||||
$sql = "SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".POSTS_TABLE.".u_id = ".USERS_TABLE.".u_id WHERE `f_id`='$id' ORDER BY `ptime` LIMIT 1";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain last post in forum', true);
|
||||
$sql = "SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".POSTS_TABLE.".u_id = ".USERS_TABLE.".u_id WHERE `f_id`='$id' ORDER BY `ptime` DESC LIMIT 1";
|
||||
$query = DataBase::sql_query($sql,GENERAL,'Could not obtain last post in forum', true);
|
||||
$post_count = DataBase::num_rows($query);
|
||||
$result = DataBase::fetch($query);
|
||||
|
||||
@@ -372,7 +374,7 @@ function GenerateLastPost($id, $type)
|
||||
$sql = "UPDATE ".FORUMS_TABLE." SET
|
||||
`lastpost`='$last_post'
|
||||
WHERE `f_id`='$id'";
|
||||
DataBase::sql_query($sql,'GENERAL','Could not update lastpost in forum');
|
||||
DataBase::sql_query($sql,GENERAL,'Could not update lastpost in forum');
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -381,8 +383,8 @@ function GenerateLastPost($id, $type)
|
||||
*/
|
||||
case 2: //for topic
|
||||
{
|
||||
$sql = "SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id = ".POSTS_TABLE.".u_id WHERE `t_id`='$id' ORDER BY `ptime` LIMIT 1";
|
||||
$query = DataBase::sql_query($sql,'GENERAL', 'Could not obtain amout of posts in topic');
|
||||
$sql = "SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id = ".POSTS_TABLE.".u_id WHERE `t_id`='$id' ORDER BY `ptime` DESC LIMIT 1";
|
||||
$query = DataBase::sql_query($sql,GENERAL, 'Could not obtain amout of posts in topic');
|
||||
$result = DataBase::fetch($query);
|
||||
|
||||
$last_post .= $result['tp_id'];
|
||||
@@ -396,60 +398,93 @@ function GenerateLastPost($id, $type)
|
||||
$last_post .= $result['nick'];
|
||||
|
||||
$sql = "UPDATE ".TOPICS_TABLE." SET
|
||||
`lastpost_time`='".$result['ptime']."',
|
||||
`lastpost`='$last_post'
|
||||
WHERE `t_id`='$id'";
|
||||
DataBase::sql_query($sql,'GENERAL','Could not update lastpost in topic');
|
||||
DataBase::sql_query($sql,GENERAL,'Could not update lastpost in topic');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function GeneratePosts($id, $type)
|
||||
{
|
||||
{
|
||||
switch ($type)
|
||||
{
|
||||
case 1: //for forum
|
||||
{
|
||||
$sql = "SELECT COUNT (`p_id`) AS 'count', `f_id` FROM ".POSTS_TABLE." WHERE `f_id`='$id'";
|
||||
$query = DataBase::sql_query($sql,'GENERAL','Could not obtain posts in forum', true);
|
||||
$sql = "SELECT COUNT(p_id) AS cnt, `f_id` FROM ".POSTS_TABLE." WHERE `f_id`='$id'";
|
||||
$query = DataBase::sql_query($sql,GENERAL,'Could not obtain posts in forum', true);
|
||||
$post_count = DataBase::num_rows($query);
|
||||
$result = DataBase::fetch($query);
|
||||
|
||||
$posts = $result['count'];
|
||||
$posts = $result['cnt'];
|
||||
|
||||
$sql = "UPDATE ".FORUMS_TABLE." SET
|
||||
`posts`='$last_post'
|
||||
`posts`='$posts'
|
||||
WHERE `f_id`='$id'";
|
||||
DataBase::sql_query($sql,'GENERAL','Could not update lastpost in forum');
|
||||
DataBase::sql_query($sql,GENERAL,'Could not update lastpost in forum');
|
||||
break;
|
||||
}
|
||||
|
||||
/** field lastpost in topic format
|
||||
tp_id:u_id:ptime:rank:nick
|
||||
*/
|
||||
case 2: //for topic
|
||||
{
|
||||
$sql = "SELECT ".POSTS_TABLE.".*, ".USERS_TABLE.".* FROM ".POSTS_TABLE." LEFT JOIN ".USERS_TABLE." ON ".USERS_TABLE.".u_id = ".POSTS_TABLE.".u_id WHERE `t_id`='$id' ORDER BY `ptime` LIMIT 1";
|
||||
$query = DataBase::sql_query($sql,'GENERAL', 'Could not obtain amout of posts in topic');
|
||||
$sql = "SELECT COUNT(p_id) AS cnt, t_id FROM ".POSTS_TABLE." WHERE `t_id`='$id'";
|
||||
$query = DataBase::sql_query($sql,GENERAL, 'Could not obtain posts count in topic');
|
||||
$result = DataBase::fetch($query);
|
||||
|
||||
$last_post .= $result['tp_id'];
|
||||
$last_post .= ':';
|
||||
$last_post .= $result['u_id'];
|
||||
$last_post .= ':';
|
||||
$last_post .= $result['ptime'];
|
||||
$last_post .= ':';
|
||||
$last_post .= $result['rank'];
|
||||
$last_post .= ':';
|
||||
$last_post .= $result['nick'];
|
||||
$posts = $result['cnt'];
|
||||
|
||||
$sql = "UPDATE ".TOPICS_TABLE." SET
|
||||
`lastpost`='$last_post'
|
||||
`posts`='$posts'
|
||||
WHERE `t_id`='$id'";
|
||||
DataBase::sql_query($sql,'GENERAL','Could not update lastpost in topic');
|
||||
DataBase::sql_query($sql,GENERAL,'Could not update post count in topic');
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function UpdateConfigPosts()
|
||||
{
|
||||
$sql = "SELECT count(`p_id`) AS `count` FROM ".POSTS_TABLE;
|
||||
$query = DataBase::sql_query($sql, GENERAL, 'Could not obtain posts count.');
|
||||
$result = DataBase::fetch($query);
|
||||
$cnt = $result['count'];
|
||||
|
||||
unset ($sql, $query, $result);
|
||||
|
||||
$sql = "UPDATE ".CONFIG_TABLE." SET
|
||||
`value`='$cnt'
|
||||
WHERE `name`='posts'";
|
||||
DataBase::sql_query($sql, GENERAL, 'Could not update posts count in config table');
|
||||
}
|
||||
function TriggerStats($id, $type)
|
||||
{
|
||||
GeneratePosts($id, $type);
|
||||
GenerateLastPost($id, $type);
|
||||
UpdateConfigPosts();
|
||||
}
|
||||
|
||||
function array_push_associative(&$arr)
|
||||
{
|
||||
$ret = '';
|
||||
$args = func_get_args();
|
||||
foreach ($args as $arg)
|
||||
{
|
||||
if (is_array($arg))
|
||||
{
|
||||
foreach ($arg as $key => $value)
|
||||
{
|
||||
$arr[$key] = $value;
|
||||
$ret++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$arr[$arg] = "";
|
||||
}
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user