Skip to content

Commit

Permalink
Fix bugs found by EPV. Add license file.
Browse files Browse the repository at this point in the history
  • Loading branch information
rxu committed Aug 8, 2014
1 parent 7f377a8 commit f1c53ab
Show file tree
Hide file tree
Showing 23 changed files with 558 additions and 301 deletions.
1 change: 0 additions & 1 deletion acp/acp_thanks_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ function uninstall()
}
}

?>
12 changes: 6 additions & 6 deletions acp/acp_thanks_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,11 @@ function main($id, $mode)
'thanks_notice_on' => array('lang' => 'THANKS_NOTICE_ON', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'thanks_info_page' => array('lang' => 'THANKS_INFO_PAGE', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'thanks_postlist_view' => array('lang' => 'THANKS_POSTLIST_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'thanks_number_post' => array('lang' => 'THANKS_NUMBER_POST', 'validate' => 'int:1:250', 'type' => 'text:4:6', 'explain' => true),
'thanks_time_view' => array('lang' => 'THANKS_TIME_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'thanks_counters_view' => array('lang' => 'THANKS_COUNTERS_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'thanks_number_post' => array('lang' => 'THANKS_NUMBER_POST', 'validate' => 'int:1:250', 'type' => 'text:4:6', 'explain' => true),
'thanks_time_view' => array('lang' => 'THANKS_TIME_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'thanks_counters_view' => array('lang' => 'THANKS_COUNTERS_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'thanks_profilelist_view' => array('lang' => 'THANKS_PROFILELIST_VIEW', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true),
'thanks_number' => array('lang' => 'THANKS_NUMBER', 'validate' => 'int:1', 'type' => 'text:4:4', 'explain' => false),
'thanks_number' => array('lang' => 'THANKS_NUMBER', 'validate' => 'int:1', 'type' => 'text:4:4', 'explain' => false),
'thanks_top_number' => array('lang' => 'THANKS_TOP_NUMBER', 'validate' => 'int:0', 'type' => 'text:4:6', 'explain' => true),
)
);
Expand Down Expand Up @@ -81,7 +81,7 @@ function main($id, $mode)
{
continue;
}

$this->new_config[$config_name] = $config_value = $cfg_array[$config_name];

if ($submit)
Expand All @@ -99,7 +99,7 @@ function main($id, $mode)
}

$this->tpl_name = 'acp_thanks';
$this->page_title = $display_vars['title'];
$this->page_title = $display_vars['title'];

$template->assign_vars(array(
'L_TITLE' => $user->lang[$display_vars['title']],
Expand Down
1 change: 0 additions & 1 deletion acp/acp_thanks_refresh_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ function uninstall()
}
}

?>
95 changes: 47 additions & 48 deletions acp/acp_thanks_refresh_module.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
/**
* @package acp
*/
class acp_thanks_refresh_module
class acp_thanks_refresh_module
{
var $u_action;

Expand All @@ -22,8 +22,8 @@ function main($id, $mode)

$this->tpl_name = 'acp_thanks_refresh';
$this->page_title = 'ACP_THANKS_REFRESH';
$posts_delete_us = $all_posts = array();

$posts_delete_us = $all_posts = array();
$end_thanks = $del_thanks = $all_thanks = $all_posts_number = $all_users_thanks = $all_posts_thanks = $end_posts_thanks = $end_users_thanks = $thanks_update = '';
$del_uthanks = $del_nofirst_thanks = $del_selfthanks = 0;

Expand All @@ -36,7 +36,7 @@ function main($id, $mode)
$cache->destroy('_all_users_thanks');
$cache->destroy('_all_thanks');
$cache->destroy('_all_posts');
$cache->destroy('_all_posts_number');
$cache->destroy('_all_posts_number');

if (!defined('THANKS_TABLE'))
{
Expand All @@ -62,18 +62,18 @@ function main($id, $mode)
$all_thanks = $db->sql_fetchfield('total_match_count');
$db->sql_freeresult($result);

unset($all_posts);
$all_posts = array();
unset($all_posts);
$all_posts = array();

$sql = 'SELECT t.*
FROM ' . THANKS_TABLE .' t
LEFT JOIN ' . POSTS_TABLE .' p ON t.post_id = p.post_id
WHERE p.post_id IS NULL';
$result = $db->sql_query($sql);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$all_posts[] = $row['post_id'];
}
}
$db->sql_freeresult($result);
$all_posts_number = $config['num_posts'];

Expand All @@ -82,13 +82,13 @@ function main($id, $mode)
$cache->put('_all_thanks', $all_thanks);
$cache->put('_all_posts', $all_posts);
$cache->put('_all_posts_number', $all_posts_number);

$template->assign_vars(array(
'S_REFRESH' => false,
'L_WARNING' => sprintf($user->lang['WARNING']),
));
}
//update
//update
if ($refresh)
{
// check mode
Expand All @@ -99,14 +99,14 @@ function main($id, $mode)
$all_posts = $cache->get('_all_posts');
$all_posts_number = $cache->get('_all_posts_number');
$all_posts_thanks = $cache->get('_all_posts_thanks');
// update delete posts

// update delete posts
if(!empty($all_posts))
{
$sql = 'DELETE FROM ' . THANKS_TABLE ."
WHERE " . $db->sql_in_set('post_id', $all_posts, false);
$result = $db->sql_query($sql);
$del_thanks = $db->sql_affectedrows($result);
$del_thanks = $db->sql_affectedrows($result);
$db->sql_freeresult($result);
}
$end_thanks = $all_thanks - $del_thanks;
Expand All @@ -116,35 +116,35 @@ function main($id, $mode)
LEFT JOIN ' . POSTS_TABLE . ' p ON (t.post_id = p.post_id)
WHERE p.poster_id = '. ANONYMOUS;
$result = $db->sql_query($sql);

while ($row = $db->sql_fetchrow($result))
{
$posts_delete_us[] = $row['post_id'];
}
$db->sql_freeresult($result);
}
$db->sql_freeresult($result);

if(!empty($posts_delete_us))
{
$del_uthanks = count($posts_delete_us);
$sql = 'DELETE FROM ' . THANKS_TABLE ."
WHERE " . $db->sql_in_set('post_id', $posts_delete_us);
$result = $db->sql_query($sql);
$db->sql_freeresult($result);
$result = $db->sql_query($sql);
$db->sql_freeresult($result);
}
//update move posts /topics /forums and change posters
$sql = 'SELECT p.post_id
FROM ' . POSTS_TABLE . ' p
LEFT JOIN ' . THANKS_TABLE . ' t ON (p.post_id = t.post_id)
WHERE p.topic_id <> t.topic_id OR p.forum_id <> t.forum_id OR p.poster_id <> t.poster_id';
$result = $db->sql_query($sql);
$result = $db->sql_query($sql);
$thanks_update = 0;
if ($result)
{
while ($row = $db->sql_fetchrow($result))
{
$sql = 'SELECT forum_id, topic_id, poster_id, post_id
FROM ' . POSTS_TABLE . '
WHERE post_id = '.$row ['post_id'];
WHERE post_id = '.$row['post_id'];
$results = $db->sql_query($sql);
$rows = $db->sql_fetchrow($results);

Expand All @@ -154,15 +154,15 @@ function main($id, $mode)
'topic_id' => $rows['topic_id'],
'poster_id' => $rows['poster_id'],
);

$sql = 'UPDATE ' . THANKS_TABLE . '
SET ' . $db->sql_build_array('UPDATE', $sql_ary) .'
WHERE post_id = '. $sql_ary['post_id'];
$db->sql_query($sql);
$thanks_update++;
}
}
$db->sql_freeresult($result);
}
}
$db->sql_freeresult($result);

$end_thanks = $end_thanks - $del_uthanks;
$del_thanks = $del_thanks + $del_uthanks;
Expand All @@ -171,63 +171,63 @@ function main($id, $mode)
{
$sql = 'SELECT topic_first_post_id
FROM ' . TOPICS_TABLE;
$result = $db->sql_query($sql);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$all_first_posts[] = $row['topic_first_post_id'];
}
$db->sql_freeresult($result);
}
$db->sql_freeresult($result);

if(!empty($all_first_posts))
{
$sql = 'DELETE FROM ' . THANKS_TABLE ."
WHERE " . $db->sql_in_set('post_id', $all_first_posts, TRUE);
WHERE " . $db->sql_in_set('post_id', $all_first_posts, true);
$result = $db->sql_query($sql);
$del_nofirst_thanks = $db->sql_affectedrows($result);
$del_nofirst_thanks = $db->sql_affectedrows($result);
$db->sql_freeresult($result);
$end_thanks = $end_thanks - $del_nofirst_thanks;
$del_thanks = $del_thanks + $del_nofirst_thanks;
}
}
}
}
// delete thanks global announce
if (isset($config['thanks_global_post']) ? !$config['thanks_global_post'] : false)
{
$sql = 'SELECT topic_id
FROM ' . TOPICS_TABLE .'
WHERE topic_type = '. POST_GLOBAL;
$result = $db->sql_query($sql);
$result = $db->sql_query($sql);
while ($row = $db->sql_fetchrow($result))
{
$all_global_posts[] = $row['topic_id'];
}
$db->sql_freeresult($result);
}
$db->sql_freeresult($result);

if(!empty($all_global_posts))
{
$sql = 'DELETE FROM ' . THANKS_TABLE ."
WHERE " . $db->sql_in_set('topic_id', $all_global_posts, false);
$result = $db->sql_query($sql);
$del_global_thanks = $db->sql_affectedrows($result);
$del_global_thanks = $db->sql_affectedrows($result);
$db->sql_freeresult($result);
$end_thanks = $end_thanks - $del_global_thanks;
$del_thanks = $del_thanks + $del_global_thanks;
}
}
}
// delete selfthanks
$sql = 'DELETE FROM ' . THANKS_TABLE .'
WHERE poster_id = user_id';
$result = $db->sql_query($sql);
$result = $db->sql_query($sql);
$del_selfthanks = $db->sql_affectedrows($result);
$db->sql_freeresult($result);
$db->sql_freeresult($result);
$del_thanks = $del_thanks + $del_selfthanks;
$end_thanks = $end_thanks - $del_selfthanks;

$sql = 'SELECT DISTINCT post_id
FROM ' . THANKS_TABLE;
$result = $db->sql_query($sql);
$end_posts_thanks = $db->sql_affectedrows($result);
$db->sql_freeresult($result);

$sql = 'SELECT DISTINCT user_id
FROM ' . THANKS_TABLE;
$result = $db->sql_query($sql);
Expand All @@ -236,7 +236,7 @@ function main($id, $mode)

$template->assign_vars(array(
'S_REFRESH' => true,
));
));
}
else
{
Expand All @@ -251,18 +251,17 @@ function main($id, $mode)
}
$template->assign_vars(array(
'POSTS' => $all_posts_number,

'POSTSTHANKS' => $all_posts_thanks,
'USERSTHANKS' => $all_users_thanks,
'ALLTHANKS' => $all_thanks,

'DELTHANKS' => $del_thanks,
'UPDATETHANKS' => $thanks_update,

'POSTSEND' => $end_posts_thanks,
'USERSEND' => $end_users_thanks,
'THANKSEND' => $end_thanks,
));
}
}
?>
2 changes: 0 additions & 2 deletions acp/acp_thanks_reput_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,3 @@ function uninstall()
{
}
}

?>
Loading

0 comments on commit f1c53ab

Please sign in to comment.