$Date: 2006-02-02 17:23:13 +0000 (Thu, 02 Feb 2006) $ | > $Revision: 133 $ | > $Author: bfarber $ +--------------------------------------------------------------------------- | | > Admin Forum functions | > Module written by Matt Mecham | > Date started: 1st march 2002 | | > Module Version Number: 1.0.0 | > DBA Checked: Tue 25th May 2004 +-------------------------------------------------------------------------- */ if ( ! defined( 'IN_ACP' ) ) { print "
';
$posts_deleted = 0;
$topics_deleted = 0;
$skipit = intval( $this->ipsclass->input['skipit'] );
//--------------------------------------------
// NOT INIT YET?
//--------------------------------------------
if ( ! $init )
{
$url = $this->ipsclass->base_url.'&'.$this->ipsclass->form_code_js."&code=deleteposts_process&dpergo={$this->ipsclass->input['dpergo']}"
."&st=0"
."&init=1"
."&dposts={$delete_posts}"
."&dtopics={$delete_topics}"
."&mid={$member_id}";
$this->ipsclass->admin->output_multiple_redirect_init( $url );
}
//--------------------------------------------
// Not loaded the func?
//--------------------------------------------
if ( ! is_object( $this->func_mod ) )
{
require_once( ROOT_PATH.'sources/lib/func_mod.php' );
$this->func_mod = new func_mod();
$this->func_mod->ipsclass =& $this->ipsclass;
}
//-----------------------------------------
// Get member
//-----------------------------------------
$member = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'members', 'where' => 'id='.$member_id ) );
//-----------------------------------------
// Non root admin attempting to edit root admin?
//-----------------------------------------
if ( $this->ipsclass->member['mgroup'] != $this->ipsclass->vars['admin_group'] )
{
if ( $member['mgroup'] == $this->ipsclass->vars['admin_group'] )
{
$this->ipsclass->admin->error("Вы не можете редактировать главных администраторов");
}
}
//-----------------------------------------
// Avoid limit...
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => '*',
'from' => 'posts',
'where' => "author_id={$member_id}",
'order' => 'pid ASC',
'limit' => array( $skipit, $end + $skipit ) ) );
$outer = $this->ipsclass->DB->simple_exec();
//-----------------------------------------
// Process...
//-----------------------------------------
while( $r = $this->ipsclass->DB->fetch_row( $outer ) )
{
//-----------------------------------------
// Get topic...
//-----------------------------------------
$topic = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*',
'from' => 'topics',
'where' => 'tid='.$r['topic_id'] ) );
//-----------------------------------------
// No longer a topic?
//-----------------------------------------
if ( ! $topic['tid'] )
{
continue;
}
//-----------------------------------------
// Get number of MID posters
//-----------------------------------------
$topic_i_posted = $this->ipsclass->DB->build_and_exec_query( array( 'select' => 'COUNT(*) as count',
'from' => 'posts',
'where' => 'author_id='.$member_id.' AND topic_id='.$r['topic_id'] ) );
//-----------------------------------------
// Aready deleted this topic?
//-----------------------------------------
if ( ! $topic_i_posted['count'])
{
continue;
}
//-----------------------------------------
// First check: Our topic and no other replies?
//-----------------------------------------
if ( $topic['starter_id'] == $member_id AND $topic_i_posted['count'] == ( $topic['posts'] + 1 ) )
{
//-----------------------------------------
// Ok, deleting topics or posts?
//-----------------------------------------
if ( $delete_posts OR $delete_topics )
{
$this->ipsclass->DB->build_and_exec_query( array( 'delete' => 'posts',
'where' => 'author_id='.$member_id.' AND topic_id='.$r['topic_id'] ) );
$this->ipsclass->DB->build_and_exec_query( array( 'delete' => 'topics',
'where' => 'tid='.$r['topic_id'] ) );
$forums_affected[ $topic['forum_id'] ] = $topic['forum_id'];
$topics_deleted++;
$posts_deleted += $topic_i_posted['count'];
}
}
//-----------------------------------------
// Is this a topic we started?
//-----------------------------------------
else if ( $topic['starter_id'] == $member_id AND $delete_topics )
{
$this->ipsclass->DB->build_and_exec_query( array( 'delete' => 'posts',
'where' => 'topic_id='.$r['topic_id'] ) );
$this->ipsclass->DB->build_and_exec_query( array( 'delete' => 'topics',
'where' => 'tid='.$r['topic_id'] ) );
$forums_affected[ $topic['forum_id'] ] = $topic['forum_id'];
$topics_deleted++;
$posts_deleted += $topic['posts'] + 1;
}
//-----------------------------------------
// Just delete the post, then
//-----------------------------------------
else if ( $delete_posts AND ! $r['new_topic'] )
{
$this->ipsclass->DB->build_and_exec_query( array( 'delete' => 'posts',
'where' => 'pid='.$r['pid'] ) );
$forums_affected[ $topic['forum_id'] ] = $topic['forum_id'];
$topics_affected[ $topic['tid'] ] = $topic['tid'];
$posts_deleted++;
}
else
{
//-----------------------------------------
// Ignore this post...
//-----------------------------------------
$skipit++;
}
$done++;
}
//-----------------------------------------
// Rebuild topics and forums
//-----------------------------------------
if ( count( $topics_affected ) )
{
foreach( $topics_affected as $i => $tid )
{
$this->func_mod->rebuild_topic( $tid, 0 );
}
}
if ( count( $forums_affected ) )
{
foreach( $forums_affected as $i => $fid )
{
$this->func_mod->forum_recount( $fid );
}
}
//-----------------------------------------
// Finish - or more?...
//-----------------------------------------
if ( ! $done )
{
//-----------------------------------------
// Recount stats..
//-----------------------------------------
$this->func_mod->stats_recount();
//-----------------------------------------
// Reset member's posts
//-----------------------------------------
$forums = array();
foreach( $this->ipsclass->cache['forum_cache'] as $id => $data )
{
if ( ! $data['inc_postcount'] )
{
$forums[] = $data['id'];
}
}
if ( ! count( $forums ) )
{
$count = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'count(*) as count', 'from' => 'posts', 'where' => 'queued != 1 AND author_id='.$member_id ) );
}
else
{
$this->ipsclass->DB->query( "SELECT count(p.pid) as count
FROM ".SQL_PREFIX."posts p, ".SQL_PREFIX."topics t
WHERE p.queued != 1 AND p.author_id={$member_id}
AND t.tid=p.topic_id AND t.forum_id NOT IN (".implode(",",$forums).")" );
$count = $this->ipsclass->DB->fetch_row();
}
$new_post_count = intval( $count['count'] );
$this->ipsclass->DB->do_update( 'members', array( 'posts' => $new_post_count ), 'id='.$member_id );
$this->ipsclass->admin->output_multiple_redirect_done( $this->ipsclass->acp_lang['mem_posts_process_done'] );
}
else
{
//-----------------------------------------
// More..
//-----------------------------------------
$url = $this->ipsclass->base_url.'&'.$this->ipsclass->form_code_js."&code=deleteposts_process&dpergo={$this->ipsclass->input['dpergo']}"
."&st={$end}"
."&init=1"
."&skipit={$skipit}"
."&dposts={$delete_posts}"
."&dtopics={$delete_topics}"
."&mid={$member_id}";
$text = sprintf( $this->ipsclass->acp_lang['mem_posts_process_more'], $end, $posts_deleted, $topics_deleted );
$this->ipsclass->admin->output_multiple_redirect_hit( $url, $img.' '.$text );
}
}
/*-------------------------------------------------------------------------*/
// Member Delete posts, start
/*-------------------------------------------------------------------------*/
function member_delete_posts_start()
{
//-----------------------------------------
// Page set up
//-----------------------------------------
$this->ipsclass->admin->page_title = $this->ipsclass->acp_lang['mem_delete_title'];
$this->ipsclass->admin->page_detail = $this->ipsclass->acp_lang['mem_delete_title_desc'];
//-----------------------------------------
// INIT
//-----------------------------------------
$member_id = intval($this->ipsclass->input['mid']);
//-----------------------------------------
// Get member
//-----------------------------------------
$member = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'members', 'where' => 'id='.$member_id ) );
//-----------------------------------------
// Non root admin attempting to edit root admin?
//-----------------------------------------
if ( $this->ipsclass->member['mgroup'] != $this->ipsclass->vars['admin_group'] )
{
if ( $member['mgroup'] == $this->ipsclass->vars['admin_group'] )
{
$this->ipsclass->admin->error("Вы не можете редактировать главных администраторов");
}
}
//-----------------------------------------
// Get number of topics member has started
//-----------------------------------------
$topics = $this->ipsclass->DB->build_and_exec_query( array( 'select' => 'count(*) as count',
'from' => 'topics',
'where' => 'starter_id='.$member_id ) );
$posts = $this->ipsclass->DB->build_and_exec_query( array( 'select' => 'count(*) as count',
'from' => 'posts',
'where' => 'author_id='.$member_id ) );
//-----------------------------------------
// Got any posts?
//-----------------------------------------
if ( ! $posts['count'] )
{
$this->ipsclass->main_msg = "Нет сообщений для удаления!";
$this->search_results();
}
//-----------------------------------------
// Get number of topics member has started
//-----------------------------------------
$this->ipsclass->acp_lang['mem_delete_delete_posts'] = sprintf( $this->ipsclass->acp_lang['mem_delete_delete_posts'] , intval($posts['count']) );
$this->ipsclass->acp_lang['mem_delete_delete_topics'] = sprintf( $this->ipsclass->acp_lang['mem_delete_delete_topics'], intval($topics['count']) );
$this->ipsclass->html .= $this->html->member_delete_posts_start( $member, intval($topics['count']), intval($posts['count']) );
$this->ipsclass->admin->output();
}
/*-------------------------------------------------------------------------*/
// PASS: COMPLETE
/*-------------------------------------------------------------------------*/
function member_password_complete()
{
if ( ! $this->ipsclass->input['password'] )
{
$this->ipsclass->main_msg = "Вы должны ввести пароль!";
$this->member_password_start();
}
//-----------------------------------------
// Get member
//-----------------------------------------
$member = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'members', 'where' => 'id='.$this->ipsclass->input['id'] ) );
//-----------------------------------------
// Non root admin attempting to edit root admin?
//-----------------------------------------
if ( $this->ipsclass->member['mgroup'] != $this->ipsclass->vars['admin_group'] )
{
if ( $member['mgroup'] == $this->ipsclass->vars['admin_group'] )
{
$this->ipsclass->admin->error("Вы не можете редактировать главных администраторов");
}
}
$salt = $this->ipsclass->converge->generate_password_salt(5);
$salt = str_replace( '\\', "\\\\", $salt );
$key = $this->ipsclass->converge->generate_auto_log_in_key();
$md5_once = md5( trim($this->ipsclass->input['password']) );
$converge = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'members_converge', 'where' => 'converge_id='.$this->ipsclass->input['id'] ) );
$save_array = array();
if ( $this->ipsclass->input['newsalt'] )
{
$save_array['converge_pass_salt'] = $salt;
$save_array['converge_pass_hash'] = md5( md5($salt) . $md5_once );
}
else
{
$save_array['converge_pass_hash'] = md5( md5( $converge['converge_pass_salt'] ) . $md5_once );
}
$this->ipsclass->DB->do_update( 'members_converge', $save_array, 'converge_id='.$this->ipsclass->input['id'] );
if ( $this->ipsclass->input['newkey'] )
{
$this->ipsclass->DB->do_update( 'members', array( 'member_login_key' => $key ), 'id='.$this->ipsclass->input['id'] );
}
//-----------------------------------------
// Redirect
//-----------------------------------------
$page_query = "";
foreach( array('name','email','ip_address','aim_name','icq_number','yahoo','signature','posts','suspended', 'registered_first', 'registered_last','last_post_first', 'last_post_last', 'last_activity_first', 'last_activity_last','mgroup','namewhere','gotcount', 'fromdel') as $bit )
{
$page_query .= '&'.$bit.'='.trim($this->ipsclass->input[ $bit ]);
}
$this->ipsclass->admin->save_log("Изменен пароль пользователя (ID: {$this->ipsclass->input['id']} )");
$this->ipsclass->admin->done_screen("Пароль изменен", "Поиск пользователей", "{$this->ipsclass->form_code}".$page_query, "redirect" );
}
//-----------------------------------------
//
// PASS: START
//
//-----------------------------------------
function member_password_start()
{
//-----------------------------------------
// Redirect
//-----------------------------------------
$page_array = array( 1 => array( 'code' , 'dochangepassword' ),
2 => array( 'act' , 'mem' ),
3 => array( 'id' , $this->ipsclass->input['id'] ),
4 => array( 'section', $this->ipsclass->section_code ),
);
foreach( array('name','email','ip_address','aim_name','icq_number','yahoo','signature','posts','suspended', 'registered_first', 'registered_last','last_post_first', 'last_post_last', 'last_activity_first', 'last_activity_last','mgroup','namewhere','gotcount', 'fromdel') as $bit )
{
$page_array[] = array( $bit, trim($this->ipsclass->input[ $bit ]) );
}
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( $page_array );
//-----------------------------------------
// Get member
//-----------------------------------------
$member = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'members', 'where' => 'id='.$this->ipsclass->input['id'] ) );
//-----------------------------------------
// Non root admin attempting to edit root admin?
//-----------------------------------------
if ( $this->ipsclass->member['mgroup'] != $this->ipsclass->vars['admin_group'] )
{
if ( $member['mgroup'] == $this->ipsclass->vars['admin_group'] )
{
$this->ipsclass->admin->error("Вы не можете редактировать главных администраторов");
}
}
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Изменение пароля пользователя: {$member['members_display_name']}" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Введите новый пароль" ,
$this->ipsclass->adskin->form_input('password' ),
) );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Создать новый кеш пароля?| \n"; } $people .= " |