$Date: 2006-01-31 22:47:20 +0000 (Tue, 31 Jan 2006) $
| > $Revision: 131 $
| > $Author: bfarber $
+---------------------------------------------------------------------------
|
| > Admin Rebuild Counter Functions
| > Module written by Matt Mecham
| > Date started: 9th March 2004
|
| > Module Version Number: 1.0.0
| > DBA Checked: Tue 25th May 2004
+--------------------------------------------------------------------------
*/
if ( ! defined( 'IN_ACP' ) )
{
print "
Неверный вход
У Вас нет доступа к директиве этого файла. Если Вы проводили обновления, убедитесь, что не забыли обновить 'admin.php'.";
exit();
}
class ad_rebuild {
var $base_url;
/**
* Section title name
*
* @var string
*/
var $perm_main = "tools";
/**
* Section title name
*
* @var string
*/
var $perm_child = "rebuild";
function auto_run()
{
//-----------------------------------------
// Kill globals - globals bad, Homer good.
//-----------------------------------------
$tmp_in = array_merge( $_GET, $_POST, $_COOKIE );
foreach ( $tmp_in as $k => $v )
{
unset($$k);
}
switch($this->ipsclass->input['code'])
{
case 'docount':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':recount' );
$this->docount();
break;
case 'doresyncforums':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':recount' );
$this->resync_forums();
break;
case 'doresynctopics':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':recount' );
$this->resync_topics();
break;
case 'doposts':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':rebuild' );
$this->rebuild_posts();
break;
case 'dopostnames':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':rebuild' );
$this->rebuild_post_names();
break;
case 'dopostcounts':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':rebuild' );
$this->rebuild_post_counts();
break;
case 'dothumbnails':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':rebuild' );
$this->rebuild_thumbnails();
break;
case 'doattachdata':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':rebuild' );
$this->rebuild_attachdata();
break;
case 'cleanattachments':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':rebuild' );
$this->clean_attachments();
break;
case 'cleanavatars':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':rebuild' );
$this->clean_avatars();
break;
case 'cleanphotos':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':rebuild' );
$this->clean_photos();
break;
//-----------------------------------------
// Tools
//-----------------------------------------
case '210polls':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':rebuild' );
$this->tools_210_polls();
break;
case '210calevents':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':rebuild' );
$this->tools_210_calevents();
break;
case '210tool_settings':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':rebuild' );
$this->tools_210_dupe_settings();
break;
case 'tool_settings':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':rebuild' );
$this->tools_dupe_settings();
break;
case 'tool_converge':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':rebuild' );
$this->tools_converge();
break;
case 'tool_bansettings':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':rebuild' );
$this->tool_bansettings();
break;
case 'tools':
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' );
$this->tools_splash();
break;
default:
$this->ipsclass->admin->cp_permission_check( $this->perm_main.'|'.$this->perm_child.':' );
$this->rebuild_start();
break;
}
}
/*-------------------------------------------------------------------------*/
// 210: TOOLS DUPLICATE SETTINGS
/*-------------------------------------------------------------------------*/
function tools_210_dupe_settings()
{
//-----------------------------------------
// Remove dupe categories
//-----------------------------------------
$title_id_to_keep = array();
$title_id_to_delete = array();
$title_deleted_count = 0;
$msg = '';
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'conf_settings_titles', 'order' => 'conf_title_id DESC' ) );
$this->ipsclass->DB->simple_exec();
while ( $r = $this->ipsclass->DB->fetch_row() )
{
if ( $title_id_to_keep[ $r['conf_title_title'] ] )
{
$title_id_to_delete[ $r['conf_title_id'] ] = $r['conf_title_id'];
$msg .= "Удаление: {$r['conf_title_title']} ID:{$r['conf_title_id']}
";
}
else
{
$title_id_to_keep[ $r['conf_title_title'] ] = $r['conf_title_id'];
$msg .= "Хранение: {$r['conf_title_title']} ID:{$r['conf_title_id']}
";
}
}
if ( count( $title_id_to_delete ) )
{
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'conf_settings_titles', 'where' => 'conf_title_id IN ('.implode( ',', $title_id_to_delete ).')' ) );
}
$title_deleted_count = intval( count($title_id_to_delete) );
//-----------------------------------------
// Time to move on dude
//-----------------------------------------
$this->ipsclass->main_msg = "Удалено: $title_deleted_count двойных системных настроек
$msg";
$this->tools_splash();
}
/*-------------------------------------------------------------------------*/
// CALENDAR EVENTS
/*-------------------------------------------------------------------------*/
function tools_210_calevents()
{
$start = intval($_GET['st']);
$lend = 50;
$end = $start + $lend;
$max = intval($_GET['max']);
//-----------------------------------------
// Do we need to run this tool?
//-----------------------------------------
if ( ! $max )
{
$original = $this->ipsclass->DB->build_and_exec_query( array( 'select' => 'COUNT(*) as max', 'from' => 'calendar_events' ) );
$new = $this->ipsclass->DB->build_and_exec_query( array( 'select' => 'COUNT(*) as max', 'from' => 'cal_events' ) );
if ( $new['max'] >= $original['max'] OR ! $original['max'] )
{
$this->ipsclass->main_msg = "Календарные события уже конвертированы";
$this->tools_splash();
}
}
$max = intval( $original['max'] );
//-----------------------------------------
// In steps...
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => '*',
'from' => 'calendar_events',
'limit' => array( $start, $lend ) ) );
$o = $this->ipsclass->DB->simple_exec();
//-----------------------------------------
// Do it...
//-----------------------------------------
if ( $this->ipsclass->DB->get_num_rows($o) )
{
//-----------------------------------------
// Got some to convert!
//-----------------------------------------
while ( $r = $this->ipsclass->DB->fetch_row($o) )
{
$recur_remap = array( 'w' => 1,
'm' => 2,
'y' => 3 );
$begin_date = $this->ipsclass->date_getgmdate( $r['unix_stamp'] );
$end_date = $this->ipsclass->date_getgmdate( $r['end_unix_stamp'] );
if ( ! $begin_date OR ! $end_date )
{
continue;
}
$day = $begin_date['mday'];
$month = $begin_date['mon'];
$year = $begin_date['year'];
$end_day = $end_date['mday'];
$end_month = $end_date['mon'];
$end_year = $end_date['year'];
$_final_unix_from = gmmktime(0, 0, 0, $month, $day, $year );
//-----------------------------------------
// Recur or ranged...
//-----------------------------------------
if ( $r['event_repeat'] OR $r['event_ranged'] )
{
$_final_unix_to = gmmktime(23, 59, 59, $end_month, $end_day, $end_year);
}
else
{
$_final_unix_to = 0;
}
$new_event = array( 'event_calendar_id' => 1,
'event_member_id' => $r['userid'],
'event_content' => $r['event_text'],
'event_title' => $r['title'],
'event_smilies' => $r['show_emoticons'],
'event_perms' => $r['read_perms'],
'event_private' => $r['priv_event'],
'event_approved' => 1,
'event_unixstamp' => $r['unix_stamp'],
'event_recurring' => ( $r['event_repeat'] && $recur_remap[ $r['repeat_unit'] ] ) ? $recur_remap[ $r['repeat_unit'] ] : 0,
'event_tz' => 0,
'event_unix_from' => $_final_unix_from,
'event_unix_to' => $_final_unix_to );
//-----------------------------------------
// INSERT
//-----------------------------------------
$this->ipsclass->DB->do_insert( 'cal_events', $new_event );
}
$this->ipsclass->main_msg = "Календарные события: $start до $end завершены....";
$url = "{$this->ipsclass->form_code}&code=".$this->ipsclass->input['code'].'&max='.$max.'&st='.$end;
}
else
{
$this->ipsclass->main_msg = "Календарные события уже конвертированы";
$url = "{$this->ipsclass->form_code}&code=tools";
}
//-----------------------------------------
// Bye....
//-----------------------------------------
$this->ipsclass->admin->redirect( $url, $this->ipsclass->main_msg, 0, $time );
}
/*-------------------------------------------------------------------------*/
// POLLS
/*-------------------------------------------------------------------------*/
function tools_210_polls()
{
$start = intval($_GET['st']);
$lend = 50;
$end = $start + $lend;
$max = intval($_GET['max']);
$done = 0;
$converted = intval( $_GET['conv'] );
//-----------------------------------------
// First off.. grab number of polls to convert
//-----------------------------------------
if ( ! $max )
{
$total = $this->ipsclass->DB->build_and_exec_query( array( 'select' => 'COUNT(*) as max',
'from' => 'topics',
'where' => "poll_state IN ('open', 'close', 'closed')" ) );
$max = $total['max'];
}
if ( $max < 1 )
{
$done = 1;
}
//-----------------------------------------
// In steps...
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => '*',
'from' => 'topics',
'where' => "poll_state IN ('open', 'close', 'closed' )",
'limit' => array( 0, $lend ) ) );
$o = $this->ipsclass->DB->simple_exec();
//-----------------------------------------
// Do it...
//-----------------------------------------
if ( $this->ipsclass->DB->get_num_rows($o) )
{
//-----------------------------------------
// Got some to convert!
//-----------------------------------------
while ( $r = $this->ipsclass->DB->fetch_row($o) )
{
$converted++;
$new_poll = array( 1 => array() );
$poll_data = $this->ipsclass->DB->build_and_exec_query( array( 'select' => '*',
'from' => 'polls',
'where' => "tid=".$r['tid']
) );
if ( ! $poll_data['pid'] )
{
continue;
}
if ( ! $poll_data['poll_question'] )
{
$poll_data['poll_question'] = $r['title'];
}
//-----------------------------------------
// Kick start new poll
//-----------------------------------------
$new_poll[1]['question'] = $poll_data['poll_question'];
//-----------------------------------------
// Get OLD polls
//-----------------------------------------
$poll_answers = unserialize( stripslashes( $poll_data['choices'] ) );
reset($poll_answers);
foreach ( $poll_answers as $entry )
{
$id = $entry[0];
$choice = $entry[1];
$votes = $entry[2];
$total_votes += $votes;
if ( strlen($choice) < 1 )
{
continue;
}
$new_poll[ 1 ]['choice'][ $id ] = $choice;
$new_poll[ 1 ]['votes'][ $id ] = $votes;
}
//-----------------------------------------
// Got something?
//-----------------------------------------
if ( count( $new_poll[1]['choice'] ) )
{
$this->ipsclass->DB->do_update( 'polls' , array( 'choices' => serialize( $new_poll ) ), 'tid='.$r['tid'] );
$this->ipsclass->DB->do_update( 'topics', array( 'poll_state' => 1 ), 'tid='.$r['tid'] );
}
//-----------------------------------------
// All done?
//-----------------------------------------
if ( $converted >= $max )
{
$done = 1;
continue;
}
}
}
else
{
$done = 1;
}
if ( ! $done )
{
$this->ipsclass->main_msg = "Опросы: $start до $end из $max завершено....";
$url = "{$this->ipsclass->form_code}&code=".$this->ipsclass->input['code'].'&max='.$max.'&st='.$end.'&conv='.$converted;
}
else
{
$this->ipsclass->main_msg = "Опросы конвертированы";
$url = "{$this->ipsclass->form_code}&code=tools";
}
//-----------------------------------------
// Bye....
//-----------------------------------------
$this->ipsclass->admin->redirect( $url, $this->ipsclass->main_msg, 0, 1 );
}
/*-------------------------------------------------------------------------*/
// TOOLS BAN SETTINGS
/*-------------------------------------------------------------------------*/
function tool_bansettings()
{
//-----------------------------------------
// Init
//-----------------------------------------
$bomb = array();
$ban = array();
$ip_count = 0;
$email_count = 0;
$name_count = 0;
//-----------------------------------------
// Get current entries
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'banfilters', 'order' => 'ban_date desc' ) );
$this->ipsclass->DB->simple_exec();
while ( $r = $this->ipsclass->DB->fetch_row() )
{
$ban[ $r['ban_type'] ][ $r['ban_content'] ] = $r;
}
//-----------------------------------------
// Get $INFO (again) ip email name
//-----------------------------------------
require( ROOT_PATH."conf_global.php" );
//-----------------------------------------
// IP
//-----------------------------------------
if ( $INFO['ban_ip'] )
{
$bomb = explode( '|', $INFO['ban_ip'] );
if ( is_array( $bomb ) and count( $bomb ) )
{
foreach( $bomb as $bang )
{
if ( ! is_array($ban['ip'][ $bang ]) )
{
$this->ipsclass->DB->do_insert( 'banfilters', array( 'ban_type' => 'ip', 'ban_content' => $bang, 'ban_date' => time() ) );
$ip_count++;
}
}
}
}
//-----------------------------------------
// EMAIL
//-----------------------------------------
if ( $INFO['ban_email'] )
{
$bomb = explode( '|', $INFO['ban_email'] );
if ( is_array( $bomb ) and count( $bomb ) )
{
foreach( $bomb as $bang )
{
if ( ! is_array($ban['email'][ $bang ]) )
{
$this->ipsclass->DB->do_insert( 'banfilters', array( 'ban_type' => 'email', 'ban_content' => $bang, 'ban_date' => time() ) );
$email_count++;
}
}
}
}
//-----------------------------------------
// EMAIL
//-----------------------------------------
if ( $INFO['ban_names'] )
{
$bomb = explode( '|', $INFO['ban_names'] );
if ( is_array( $bomb ) and count( $bomb ) )
{
foreach( $bomb as $bang )
{
if ( ! is_array($ban['name'][ $bang ]) )
{
$this->ipsclass->DB->do_insert( 'banfilters', array( 'ban_type' => 'name', 'ban_content' => $bang, 'ban_date' => time() ) );
$name_count++;
}
}
}
}
$this->ipsclass->main_msg = "Импортировано: $ip_count IP-адресов, $email_count адресов email, $name_count запрещенных имен.";
require_once( ROOT_PATH."sources/action_admin/banandbadword.php");
$thing = new ad_banandbadword();
$thing->ipsclass =& $this->ipsclass;
$thing->ban_rebuildcache();
$this->tools_splash();
}
/*-------------------------------------------------------------------------*/
// TOOLS (UN)CONVERGE
/*-------------------------------------------------------------------------*/
function tools_converge()
{
//-----------------------------------------
// Get all validating members...
//-----------------------------------------
$to_unconverge = array();
$unconverge_count = 0;
$this->ipsclass->DB->simple_construct( array( 'select' => 'id, email, mgroup', 'from' => 'members', 'where' => 'mgroup=1' ) );
$this->ipsclass->DB->simple_exec();
while( $m = $this->ipsclass->DB->fetch_row() )
{
if ( preg_match( "#^{$m['id']}\-#", $m['email'] ) )
{
$to_unconverge[] = $m['id'];
}
}
$unconverge_count = intval( count($to_unconverge) );
if ( $unconverge_count )
{
foreach( $to_unconverge as $mid )
{
$this->ipsclass->DB->do_update( 'members' , array( 'mgroup' => $this->ipsclass->vars['member_group'] ), 'id='.$mid );
$this->ipsclass->DB->do_update( 'member_extra', array( 'bio' => 'dupemail' ), 'id='.$mid );
}
}
//-----------------------------------------
// Time to move on dude
//-----------------------------------------
$this->ipsclass->main_msg = "Всего найдено и восстановлено $unconverge_count пользователей.";
$this->tools_splash();
}
/*-------------------------------------------------------------------------*/
// TOOLS DUPLICATE SETTINGS
/*-------------------------------------------------------------------------*/
function tools_dupe_settings()
{
//-----------------------------------------
// Remove dupe categories
//-----------------------------------------
$title_id_to_keep = array();
$title_id_to_delete = array();
$title_deleted_count = 0;
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'conf_settings_titles', 'order' => 'conf_title_id' ) );
$this->ipsclass->DB->simple_exec();
while ( $r = $this->ipsclass->DB->fetch_row() )
{
if ( $title_id_to_keep[ $r['conf_title_title'] ] )
{
$title_id_to_delete[ $r['conf_title_id'] ] = $r['conf_title_id'];
}
else
{
$title_id_to_keep[ $r['conf_title_title'] ] = $r['conf_title_id'];
}
}
if ( count( $title_id_to_delete ) )
{
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'conf_settings_titles', 'where' => 'conf_title_id IN ('.implode( ',', $title_id_to_delete ).')' ) );
}
$title_deleted_count = intval( count($title_id_to_delete) );
//-----------------------------------------
// Remove dupe settings
//-----------------------------------------
$setting_id_to_keep = array();
$setting_id_to_delete = array();
$setting_id_deleted_count = 0;
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'conf_settings', 'order' => 'conf_id' ) );
$this->ipsclass->DB->simple_exec();
while ( $r = $this->ipsclass->DB->fetch_row() )
{
if ( $setting_id_to_keep[ $r['conf_title'].','.$r['conf_key'] ] )
{
$setting_id_to_delete[ $r['conf_id'] ] = $r['conf_id'];
}
else
{
$setting_id_to_keep[ $r['conf_title'].','.$r['conf_key'] ] = $r['conf_id'];
}
}
if ( count( $setting_id_to_delete ) )
{
$this->ipsclass->DB->simple_exec_query( array( 'delete' => 'conf_settings', 'where' => 'conf_id IN ('.implode( ',', $setting_id_to_delete ).')' ) );
}
$setting_deleted_count = intval( count($setting_id_to_delete) );
//-----------------------------------------
// Time to move on dude
//-----------------------------------------
$this->ipsclass->main_msg = "Удалено: $title_deleted_count двойных названий, $setting_deleted_count двойных системных настроек.";
$this->tools_splash();
}
/*-------------------------------------------------------------------------*/
// TOOLS SPLASH
/*-------------------------------------------------------------------------*/
function tools_splash()
{
$this->ipsclass->admin->page_detail = "В этой секции представлены такие инструменты, как «Удаление двойных системных настроек», «Восстановление соединившихся пользователей», «Восстановление прежних бан-фильтров».";
$this->ipsclass->admin->page_title = "Инструменты форума";
//-----------------------------------------
// 210: DUPE SETTINGS
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , '210tool_settings' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( "{none}" , "100%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Удаление двойных системных настроек из IPB 2.1.x" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "После модернизации форума или импортирования от других версий форума, вы можете обнаружить, что в результате этих обновлений или импортирования некоторые системные настройки продублировались.
Этот инструмент находит и удаляет двойные записи, у которых ID больше, чем оригинальные."
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Запустить инструмент...');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// 210: CALEVENTS
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , '210calevents' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( "{none}" , "100%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Конвертирование календарных событий из формата 2.0.x в 2.1.x " );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Этот инструмент переконвертирует календарные события формата IPB 2.0.x в новый формат. Используйте этот инструмент после ознакомлением о его использовании или когда некоторые календарные события не прошли конвертирование."
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Запустить инструмент...');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// 210: POLLS
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , '210polls' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( "{none}" , "100%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Конвертирование опросов из формата 2.0.x в 2.1.x " );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Этот инструмент переконвертирует опросы формата IPB 2.0.x в новый формат. Используйте этот инструмент после ознакомлением о его использовании или когда некоторые опросы не прошли конвертирование."
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Запустить инструмент...');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// DUPE SETTINGS
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'tool_settings' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( "{none}" , "100%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Удаление повторяющихся системных настроек из IPB 2.0.x" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "После обновления с предыдущей версии или импортирования с других систем форумов, вы можете найти что должны запустить обновление дважды.
Эта функция найдет повторения, которые имеют высший ID чем оригинальные."
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Запустить инструмент...');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// STATISTICS (also vali mem)
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'tool_converge' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( "{none}" , "100%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Восстановление 'соединившихся' пользователей" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "После модернизации форума или импортирования от других версий форума, вы можете обнаружить, что в результате этих обновлений или импортирования у некоторых пользователей появились повторяющиеся адреса email или их учетные записи перемещены в группу ожидающих подтверждения регистрации (смены адресов email).
Этот инструмент находит и перемещает таких пользователей в основную группу, а также запрашивает пользователей о смене адреса email."
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Запустить');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// Import old bandana settings
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'tool_bansettings' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( "{none}" , "100%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Восстановление прежние бан-фильтры" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "После модернизации форума, вы можете обнаружить, что ваши старые бан-фильтры больше не работают.
В момент запуска этот инструмент делает попытки восстановления ваших старых бан-фильтров. Старые записи не будут заменены новыми, то есть вы не потеряете ваши новые бан-фильтры."
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Запустить инструмент...');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// Print
//-----------------------------------------
$this->ipsclass->admin->output();
}
/*-------------------------------------------------------------------------*/
// Clean out photos
/*-------------------------------------------------------------------------*/
function clean_photos()
{
require_once( KERNEL_PATH.'class_upload.php' );
$upload = new class_upload();
//-----------------------------------------
// Set up
//-----------------------------------------
$done = 0;
$start = intval( $this->ipsclass->input['st'] );
$end = intval( $this->ipsclass->input['pergo'] ) ? intval( $this->ipsclass->input['pergo'] ) : 100;
$display = $end + $start;
$output = array();
//-----------------------------------------
// Pop open the directory and
// peek inside...
//-----------------------------------------
$i = 0;
$dh = opendir( ROOT_PATH.'uploads' );
while ( $file = readdir( $dh ) )
{
if ( strstr( $file, 'photo-' ) )
{
$fullfile = ROOT_PATH.'uploads/'.$file;
$i++;
//-----------------------------------------
// Already started?
//-----------------------------------------
if ( $start > $i )
{
continue;
}
//-----------------------------------------
// Done for this iteration?
//-----------------------------------------
if ( $i > $end )
{
break;
}
//-----------------------------------------
// Try and get attach row
//-----------------------------------------
$found = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'id', 'from' => 'member_extra', 'where' => "photo_location='$file'" ) );
if ( ! $found['id'] )
{
@unlink( $fullfile );
$output[] = "Удалена фотография без связей: $file";
}
else
{
$output[] = "Фотография в порядке: $file";
}
}
}
closedir( $dh );
//-----------------------------------------
// Finish - or more?...
//-----------------------------------------
if ( $i < $display)
{
//-----------------------------------------
// Done..
//-----------------------------------------
$text = "Перестройка завершена
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}";
$time = 2;
}
else
{
//-----------------------------------------
// More..
//-----------------------------------------
$text = "Файлов проверено {$display}, продолжение...
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}&code=".$this->ipsclass->input['code'].'&pergo='.$this->ipsclass->input['pergo'].'&st='.$end;
$time = 0;
}
//-----------------------------------------
// Bye....
//-----------------------------------------
$this->ipsclass->admin->redirect( $url, $text, 0, $time );
}
/*-------------------------------------------------------------------------*/
// Clean out avatars
/*-------------------------------------------------------------------------*/
function clean_avatars()
{
require_once( KERNEL_PATH.'class_upload.php' );
$upload = new class_upload();
//-----------------------------------------
// Set up
//-----------------------------------------
$done = 0;
$start = intval( $this->ipsclass->input['st'] );
$end = intval( $this->ipsclass->input['pergo'] ) ? intval( $this->ipsclass->input['pergo'] ) : 100;
$dis = $end + $start;
$output = array();
//-----------------------------------------
// Pop open the directory and
// peek inside...
//-----------------------------------------
$i = 0;
$dh = opendir( ROOT_PATH.'uploads' );
while ( $file = readdir( $dh ) )
{
if ( strstr( $file, 'av-' ) )
{
$fullfile = ROOT_PATH.'uploads/'.$file;
$i++;
//-----------------------------------------
// Already started?
//-----------------------------------------
if ( $start > $i )
{
continue;
}
//-----------------------------------------
// Done for this iteration?
//-----------------------------------------
if ( $i > $end )
{
break;
}
//-----------------------------------------
// Try and get attach row
//-----------------------------------------
$found = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'id', 'from' => 'member_extra', 'where' => "avatar_location='$file' or avatar_location='upload:$file'" ) );
if ( ! $found['id'] )
{
@unlink( $fullfile );
$output[] = "Удалена аватара без связей: $file";
}
else
{
$output[] = "Аватара в порядке: $file";
}
}
}
closedir( $dh );
//-----------------------------------------
// Finish - or more?...
//-----------------------------------------
if ( $i < $dis)
{
//-----------------------------------------
// Done..
//-----------------------------------------
$text = "Перестройка завершена
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}";
$time = 2;
}
else
{
//-----------------------------------------
// More..
//-----------------------------------------
$text = "Файлов проверено: $dis, продолжение...
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}&code=".$this->ipsclass->input['code'].'&pergo='.$this->ipsclass->input['pergo'].'&st='.$end;
$time = 0;
}
//-----------------------------------------
// Bye....
//-----------------------------------------
$this->ipsclass->admin->redirect( $url, $text, 0, $time );
}
/*-------------------------------------------------------------------------*/
// Clean out attachments
/*-------------------------------------------------------------------------*/
function clean_attachments()
{
require_once( KERNEL_PATH.'class_upload.php' );
$upload = new class_upload();
//-----------------------------------------
// Set up
//-----------------------------------------
$done = 0;
$start = intval( $this->ipsclass->input['st'] );
$end = intval( $this->ipsclass->input['pergo'] ) ? intval( $this->ipsclass->input['pergo'] ) : 100;
$dis = $end + $start;
$output = array();
//-----------------------------------------
// Pop open the directory and
// peek inside...
//-----------------------------------------
$i = 0;
$dh = opendir( ROOT_PATH.'uploads' );
while ( $file = readdir( $dh ) )
{
if ( strstr( $file, 'post-' ) )
{
$fullfile = ROOT_PATH.'uploads/'.$file;
$i++;
//-----------------------------------------
// Already started?
//-----------------------------------------
if ( $start > $i )
{
continue;
}
//-----------------------------------------
// Done for this iteration?
//-----------------------------------------
if ( $i > $end )
{
break;
}
//-----------------------------------------
// Try and get attach row
//-----------------------------------------
$found = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'attach_id', 'from' => 'attachments', 'where' => "attach_location='$file' OR attach_thumb_location='$file'" ) );
if ( ! $found['attach_id'] )
{
@unlink( $fullfile );
$output[] = "Удален файл без связей: $file";
}
else
{
$output[] = "Прикрепленный файл в порядке: $file";
}
}
}
closedir( $dh );
//-----------------------------------------
// Finish - or more?...
//-----------------------------------------
if ( $i < $dis)
{
//-----------------------------------------
// Done..
//-----------------------------------------
$text = "Перестройка завершена
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}";
$time = 2;
}
else
{
//-----------------------------------------
// More..
//-----------------------------------------
$text = "Файлов проверено: $dis, продолжение...
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}&code=".$this->ipsclass->input['code'].'&pergo='.$this->ipsclass->input['pergo'].'&st='.$dis;
$time = 0;
}
//-----------------------------------------
// Bye....
//-----------------------------------------
$this->ipsclass->admin->redirect( $url, $text, 0, $time );
}
/*-------------------------------------------------------------------------*/
// REBUILD ATTACH DATA
/*-------------------------------------------------------------------------*/
function rebuild_attachdata()
{
require_once( KERNEL_PATH.'class_upload.php' );
$upload = new class_upload();
//-----------------------------------------
// Set up
//-----------------------------------------
$done = 0;
$start = intval( $this->ipsclass->input['st'] );
$end = intval( $this->ipsclass->input['pergo'] ) ? intval( $this->ipsclass->input['pergo'] ) : 100;
$dis = $end + $start;
$output = array();
//-----------------------------------------
// Got any more?
//-----------------------------------------
$tmp = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'attach_id', 'from' => 'attachments', 'limit' => array($dis,1) ) );
$max = intval( $tmp['attach_id'] );
//-----------------------------------------
// Avoid limit...
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'attachments', 'order' => 'attach_id ASC', 'limit' => array($start,$end) ) );
$outer = $this->ipsclass->DB->simple_exec();
//-----------------------------------------
// Process...
//-----------------------------------------
while( $r = $this->ipsclass->DB->fetch_row( $outer ) )
{
//-----------------------------------------
// Get ext
//-----------------------------------------
$update = array();
$update['attach_ext'] = $upload->_get_file_extension( $r['attach_file'] );
if ( $r['attach_location'] )
{
if ( file_exists( $this->ipsclass->vars['upload_dir'].'/'.$r['attach_location'] ) )
{
$update['attach_filesize'] = @filesize( $this->ipsclass->vars['upload_dir'].'/'.$r['attach_location'] );
}
}
if ( count( $update ) )
{
$this->ipsclass->DB->do_update( 'attachments', $update, 'attach_id='.$r['attach_id'] );
}
$done++;
}
//-----------------------------------------
// Finish - or more?...
//-----------------------------------------
if ( ! $done and ! $max )
{
//-----------------------------------------
// Done..
//-----------------------------------------
$text = "Перестройка завершена
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}";
$time = 2;
}
else
{
//-----------------------------------------
// More..
//-----------------------------------------
$text = "Файлов проверено: $dis, продолжение...
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}&code=".$this->ipsclass->input['code'].'&pergo='.$this->ipsclass->input['pergo'].'&st='.$dis;
$time = 0;
}
//-----------------------------------------
// Bye....
//-----------------------------------------
$this->ipsclass->admin->redirect( $url, $text, 0, $time );
}
/*-------------------------------------------------------------------------*/
// REBUILD THUMBNAILS
/*-------------------------------------------------------------------------*/
function rebuild_thumbnails()
{
require_once( KERNEL_PATH.'class_image.php' );
//-----------------------------------------
// Set up
//-----------------------------------------
$done = 0;
$start = intval( $this->ipsclass->input['st'] );
$end = intval( $this->ipsclass->input['pergo'] ) ? intval( $this->ipsclass->input['pergo'] ) : 100;
$dis = $end + $start;
$output = array();
//-----------------------------------------
// Got any more?
//-----------------------------------------
$tmp = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'attach_id', 'from' => 'attachments', 'limit' => array($dis,1) ) );
$max = intval( $tmp['attach_id'] );
//-----------------------------------------
// Avoid limit...
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'attachments', 'order' => 'attach_id ASC', 'limit' => array($start,$end) ) );
$outer = $this->ipsclass->DB->simple_exec();
//-----------------------------------------
// Process...
//-----------------------------------------
while( $r = $this->ipsclass->DB->fetch_row( $outer ) )
{
if ( $r['attach_is_image'] )
{
if ( $r['attach_thumb_location'] and ( $r['attach_thumb_location'] != $r['attach_location'] ) )
{
if ( file_exists( $this->ipsclass->vars['upload_dir'].'/'.$r['attach_thumb_location'] ) )
{
if ( ! @unlink( $this->ipsclass->vars['upload_dir'].'/'.$r['attach_thumb_location'] ) )
{
$output[] = "Невозможно удалить: ".$r['attach_thumb_location'];
continue;
}
}
}
$attach_data = array();
$thumb_data = array();
$image = new class_image();
$image->in_type = 'file';
$image->out_type = 'file';
$image->in_file_dir = $this->ipsclass->vars['upload_dir'];
$image->in_file_name = $r['attach_location'];
$image->desired_width = $this->ipsclass->vars['siu_width'];
$image->desired_height = $this->ipsclass->vars['siu_height'];
$image->gd_version = $this->ipsclass->vars['gd_version'];
$thumb_data = $image->generate_thumbnail();
$attach_data['attach_thumb_width'] = $thumb_data['thumb_width'];
$attach_data['attach_thumb_height'] = $thumb_data['thumb_height'];
$attach_data['attach_thumb_location'] = $thumb_data['thumb_location'];
if ( count( $attach_data ) )
{
$this->ipsclass->DB->do_update( 'attachments', $attach_data, 'attach_id='.$r['attach_id'] );
$output[] = "Размер изменен: ".$r['attach_location'];
}
unset($image);
}
$done++;
}
//-----------------------------------------
// Finish - or more?...
//-----------------------------------------
if ( ! $done and ! $max )
{
//-----------------------------------------
// Done..
//-----------------------------------------
$text = "Перестройка завершена
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}";
$time = 2;
}
else
{
//-----------------------------------------
// More..
//-----------------------------------------
$text = "Файлов проверено: $dis, продолжение...
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}&code=".$this->ipsclass->input['code'].'&pergo='.$this->ipsclass->input['pergo'].'&st='.$dis;
$time = 0;
}
//-----------------------------------------
// Bye....
//-----------------------------------------
$this->ipsclass->admin->redirect( $url, $text, 0, $time );
}
/*-------------------------------------------------------------------------*/
// REBUILD POST COUNTS
/*-------------------------------------------------------------------------*/
function rebuild_post_counts()
{
//-----------------------------------------
// Forums not to count?
//-----------------------------------------
$forums = array();
foreach( $this->ipsclass->cache['forum_cache'] as $id => $data )
{
if ( ! $data['inc_postcount'] )
{
$forums[] = $data['id'];
}
}
//-----------------------------------------
// Set up
//-----------------------------------------
$done = 0;
$start = intval( $this->ipsclass->input['st'] );
$end = intval( $this->ipsclass->input['pergo'] ) ? intval( $this->ipsclass->input['pergo'] ) : 100;
$dis = $end + $start;
$output = array();
//-----------------------------------------
// Got any more?
//-----------------------------------------
$tmp = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'id', 'from' => 'members', 'limit' => array($dis,1) ) );
$max = intval( $tmp['id'] );
//-----------------------------------------
// Avoid limit...
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'id, name', 'from' => 'members', 'order' => 'id ASC', 'limit' => array($start,$end) ) );
$outer = $this->ipsclass->DB->simple_exec();
//-----------------------------------------
// Process...
//-----------------------------------------
while( $r = $this->ipsclass->DB->fetch_row( $outer ) )
{
if ( ! count( $forums ) )
{
$count = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'count(*) as count', 'from' => 'posts', 'where' => 'queued != 1 AND author_id='.$r['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={$r['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='.$r['id'] );
$done++;
}
//-----------------------------------------
// Finish - or more?...
//-----------------------------------------
if ( ! $done and ! $max )
{
//-----------------------------------------
// Done..
//-----------------------------------------
$text = "Перестройка завершена
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}";
$time = 2;
}
else
{
//-----------------------------------------
// More..
//-----------------------------------------
$text = "Файлов проверено: $dis, продолжение...
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}&code=".$this->ipsclass->input['code'].'&pergo='.$this->ipsclass->input['pergo'].'&st='.$dis;
$time = 0;
}
//-----------------------------------------
// Bye....
//-----------------------------------------
$this->ipsclass->admin->redirect( $url, $text, 0, $time );
}
/*-------------------------------------------------------------------------*/
// REBUILD POSTS
/*-------------------------------------------------------------------------*/
function rebuild_post_names()
{
//-----------------------------------------
// Set up
//-----------------------------------------
$done = 0;
$start = intval( $this->ipsclass->input['st'] );
$end = intval( $this->ipsclass->input['pergo'] ) ? intval( $this->ipsclass->input['pergo'] ) : 100;
$dis = $end + $start;
$output = array();
//-----------------------------------------
// Got any more?
//-----------------------------------------
$tmp = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'id', 'from' => 'members', 'limit' => array($dis,1) ) );
$max = intval( $tmp['id'] );
//-----------------------------------------
// Avoid limit...
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'id, members_display_name', 'from' => 'members', 'order' => 'id ASC', 'limit' => array($start,$end) ) );
$outer = $this->ipsclass->DB->simple_exec();
//-----------------------------------------
// Process...
//-----------------------------------------
while( $r = $this->ipsclass->DB->fetch_row( $outer ) )
{
$this->ipsclass->DB->do_update( 'contacts' , array( 'contact_name' => $r['members_display_name'] ), "contact_id=" .$r['id'] );
$this->ipsclass->DB->do_update( 'topics' , array( 'starter_name' => $r['members_display_name'] ), "starter_id=" .$r['id'] );
$done++;
}
//-----------------------------------------
// Finish - or more?...
//-----------------------------------------
if ( ! $done and ! $max )
{
//-----------------------------------------
// Done..
//-----------------------------------------
$text = "Перестройка завершена
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}";
$time = 2;
}
else
{
//-----------------------------------------
// More..
//-----------------------------------------
$text = "Файлов проверено: $dis, продолжение...
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}&code=".$this->ipsclass->input['code'].'&pergo='.$this->ipsclass->input['pergo'].'&st='.$dis;
$time = 0;
}
//-----------------------------------------
// Bye....
//-----------------------------------------
$this->ipsclass->admin->redirect( $url, $text, 0, $time );
}
/*-------------------------------------------------------------------------*/
// REBUILD POSTS
/*-------------------------------------------------------------------------*/
function rebuild_posts()
{
require_once( ROOT_PATH."sources/handlers/han_parse_bbcode.php" );
$parser = new parse_bbcode();
$parser->ipsclass =& $this->ipsclass;
$parser->allow_update_caches = 1;
//-----------------------------------------
// Set up
//-----------------------------------------
$done = 0;
$start = intval( $this->ipsclass->input['st'] );
$end = intval( $this->ipsclass->input['pergo'] ) ? intval( $this->ipsclass->input['pergo'] ) : 100;
$dis = $end + $start;
$output = array();
//-----------------------------------------
// Got any more?
//-----------------------------------------
$tmp = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'pid', 'from' => 'posts', 'limit' => array($dis,1) ) );
$max = intval( $tmp['pid'] );
//-----------------------------------------
// Avoid limit...
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => 'p.*, t.forum_id', 'from' => 'posts p, ibf_topics t', 'where' => "p.topic_id=t.tid", 'order' => 'pid ASC', 'limit' => array($start,$end) ) );
$outer = $this->ipsclass->DB->simple_exec();
//-----------------------------------------
// Process...
//-----------------------------------------
while( $r = $this->ipsclass->DB->fetch_row( $outer ) )
{
$parser->quote_open = 0;
$parser->quote_closed = 0;
$parser->quote_error = 0;
$parser->error = '';
$parser->image_count = 0;
$parser->parse_smilies = $r['use_emo'];
$parser->parse_html = 0;
$parser->parse_bbcode = $this->ipsclass->cache['forum_cache'][ $r['forum_id'] ]['use_ibc'];
$rawpost = $parser->pre_edit_parse( $r['post'] );
$newpost = $parser->pre_db_parse( $rawpost );
//-----------------------------------------
// Remove old \' escaping
//-----------------------------------------
$newpost = str_replace( "\\'", "'", $newpost );
//-----------------------------------------
// Convert old dohtml?
//-----------------------------------------
$htmlstate = 0;
if ( strstr( strtolower($newpost), '[dohtml]' ) )
{
//-----------------------------------------
// Can we use HTML?
//-----------------------------------------
if ( $this->ipsclass->cache['forum_cache'][ $r['forum_id'] ]['use_html'] )
{
$htmlstate = 2;
}
$newpost = preg_replace( "#\[dohtml\]#i" , "", $newpost );
$newpost = preg_replace( "#\[/dohtml\]#i", "", $newpost );
}
else
{
$htmlstate = intval( $r['post_htmlstate'] );
}
if ( $newpost )
{
$this->ipsclass->DB->do_update( 'posts', array( 'post' => $newpost, 'post_htmlstate' => $htmlstate ), 'pid='.$r['pid'] );
}
$done++;
}
//-----------------------------------------
// Finish - or more?...
//-----------------------------------------
if ( ! $done and ! $max )
{
//-----------------------------------------
// Done..
//-----------------------------------------
$text = "Перестройка завершена
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}";
$time = 2;
}
else
{
//-----------------------------------------
// More..
//-----------------------------------------
$text = "Файлов проверено: $dis, продолжение...
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}&code=".$this->ipsclass->input['code'].'&pergo='.$this->ipsclass->input['pergo'].'&st='.$dis;
$time = 0;
}
//-----------------------------------------
// Bye....
//-----------------------------------------
$this->ipsclass->admin->redirect( $url, $text, 0, $time );
}
/*-------------------------------------------------------------------------*/
// RESYNCHRONIZE TOPICS
/*-------------------------------------------------------------------------*/
function resync_topics()
{
require_once( ROOT_PATH.'sources/lib/func_mod.php' );
$modfunc = new func_mod();
$modfunc->ipsclass =& $this->ipsclass;
//-----------------------------------------
// Set up
//-----------------------------------------
$done = 0;
$start = intval( $this->ipsclass->input['st'] );
$end = intval( $this->ipsclass->input['pergo'] ) ? intval( $this->ipsclass->input['pergo'] ) : 100;
$dis = $end + $start;
$output = array();
//-----------------------------------------
// Got any more?
//-----------------------------------------
$tmp = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'count(*) as count', 'from' => 'topics', 'limit' => array($dis,1) ) );
$max = intval( $tmp['count'] );
//-----------------------------------------
// Avoid limit...
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'topics', 'order' => 'tid ASC', 'limit' => array($start,$end) ) );
$outer = $this->ipsclass->DB->simple_exec();
//-----------------------------------------
// Process...
//-----------------------------------------
while( $r = $this->ipsclass->DB->fetch_row( $outer ) )
{
$modfunc->rebuild_topic($r['tid'], 0);
if ( $this->ipsclass->input['pergo'] <= 200 )
{
$output[] = "Проверяемая тема ".$r['title'];
}
$done++;
}
//-----------------------------------------
// Finish - or more?...
//-----------------------------------------
if ( ! $done and ! $max )
{
//-----------------------------------------
// Done..
//-----------------------------------------
$text = "Перестройка завершена
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}";
$time = 2;
}
else
{
//-----------------------------------------
// More..
//-----------------------------------------
$text = "Тем проверено: $dis, продолжение...
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}&code=".$this->ipsclass->input['code'].'&pergo='.$this->ipsclass->input['pergo'].'&st='.$dis;
$time = 0;
}
//-----------------------------------------
// Bye....
//-----------------------------------------
$this->ipsclass->admin->redirect( $url, $text, 0, $time );
}
/*-------------------------------------------------------------------------*/
// RESYNCHRONIZE FORUMS
/*-------------------------------------------------------------------------*/
function resync_forums()
{
require_once( ROOT_PATH.'sources/lib/func_mod.php' );
$modfunc = new func_mod();
$modfunc->ipsclass =& $this->ipsclass;
//-----------------------------------------
// Set up
//-----------------------------------------
$done = 0;
$start = intval( $this->ipsclass->input['st'] );
$end = intval( $this->ipsclass->input['pergo'] ) ? intval( $this->ipsclass->input['pergo'] ) : 100;
$dis = $end + $start;
$output = array();
//-----------------------------------------
// Got any more?
//-----------------------------------------
$tmp = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'count(*) as count', 'from' => 'forums', 'limit' => array($dis,1) ) );
$max = intval( $tmp['count'] );
//-----------------------------------------
// Avoid limit...
//-----------------------------------------
$this->ipsclass->DB->simple_construct( array( 'select' => '*', 'from' => 'forums', 'order' => 'id ASC', 'limit' => array($start,$end) ) );
$outer = $this->ipsclass->DB->simple_exec();
//-----------------------------------------
// Process...
//-----------------------------------------
while( $r = $this->ipsclass->DB->fetch_row( $outer ) )
{
$modfunc->forum_recount( $r['id'] );
$output[] = "Проверяемый форум ".$r['name'];
$done++;
}
//-----------------------------------------
// Finish - or more?...
//-----------------------------------------
if ( ! $done and ! $max )
{
//-----------------------------------------
// Done..
//-----------------------------------------
$text = "Перестройка завершена
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}";
$time = 2;
}
else
{
//-----------------------------------------
// More..
//-----------------------------------------
$text = "Форумов проверено: $dis, продолжение...
".implode( "
", $output );
$url = "{$this->ipsclass->form_code}&code=".$this->ipsclass->input['code'].'&pergo='.$this->ipsclass->input['pergo'].'&st='.$dis;
$time = 0;
}
//-----------------------------------------
// Bye....
//-----------------------------------------
$this->ipsclass->admin->redirect( $url, $text, 0, $time );
}
/*-------------------------------------------------------------------------*/
// DO COUNT - Count the stats
/*-------------------------------------------------------------------------*/
function docount()
{
if ( (! $this->ipsclass->input['posts']) and (! $this->ipsclass->input['online']) and (! $this->ipsclass->input['members'] ) and (! $this->ipsclass->input['lastreg'] ) )
{
$this->ipsclass->admin->error("Нечего пересчитывать, вы должны выбрать хоть что-то!");
}
$stats = $this->ipsclass->DB->simple_exec_query( array( 'select' => '*', 'from' => 'cache_store', 'where' => "cs_key='stats'" ) );
$stats = unserialize($this->ipsclass->txt_stripslashes($stats['cs_value']));
if ($this->ipsclass->input['posts'])
{
$topics = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'COUNT(*) as tcount',
'from' => 'topics',
'where' => 'approved=1' ) );
$posts = $this->ipsclass->DB->simple_exec_query( array( 'select' => 'SUM(posts) as replies',
'from' => 'topics',
'where' => 'approved=1' ) );
$stats['total_topics'] = $topics['tcount'];
$stats['total_replies'] = $posts['replies'];
}
if ($this->ipsclass->input['members'])
{
$this->ipsclass->DB->simple_construct( array( 'select' => 'count(id) as members', 'from' => 'members', 'where' => "mgroup <> '".$this->ipsclass->vars['auth_group']."'" ) );
$this->ipsclass->DB->simple_exec();
$r = $this->ipsclass->DB->fetch_row();
$stats['mem_count'] = intval($r['members']);
}
if ($this->ipsclass->input['lastreg'])
{
$this->ipsclass->DB->simple_construct( array( 'select' => 'id, name, members_display_name',
'from' => 'members',
'where' => "mgroup <> '".$this->ipsclass->vars['auth_group']."'",
'order' => "id DESC",
'limit' => array(0,1) ) );
$this->ipsclass->DB->simple_exec();
$r = $this->ipsclass->DB->fetch_row();
$stats['last_mem_name'] = $r['members_display_name'] ? $r['members_display_name'] : $r['name'];
$stats['last_mem_id'] = $r['id'];
}
if ($this->ipsclass->input['online'])
{
$stats['most_date'] = time();
$stats['most_count'] = 1;
}
if ( count($stats) > 0 )
{
$this->ipsclass->cache['stats'] =& $stats;
$this->ipsclass->update_cache( array( 'name' => 'stats', 'array' => 1, 'deletefirst' => 1 ) );
}
else
{
$this->ipsclass->admin->error("Нечего пересчитывать!");
}
$this->ipsclass->main_msg = 'Статистика пересчитана';
$this->ipsclass->admin->done_screen("Статистика пересчитана", "Пересчет и перестройка", "{$this->ipsclass->form_code}", 'redirect' );
}
/*-------------------------------------------------------------------------*/
// MAIN PAGE
/*-------------------------------------------------------------------------*/
function rebuild_start()
{
$this->ipsclass->admin->page_detail = "Эта секция позволяет вам синхронизировать данные вашего форума.";
$this->ipsclass->admin->page_title = "Пересчет и перестройка";
//-----------------------------------------
// STATISTICS
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'docount' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( "Статистика" , "70%" );
$this->ipsclass->adskin->td_header[] = array( "Опция" , "30%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Пересчет статистики" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Пересчитать все темы и сообщения?",
$this->ipsclass->adskin->form_dropdown( 'posts', array( 0 => array( 1, 'Да' ), 1 => array( 0, 'Нет' ) ) )
) );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Пересчитать пользователей?",
$this->ipsclass->adskin->form_dropdown( 'members', array( 0 => array( 1, 'Да' ), 1 => array( 0, 'Нет' ) ) )
) );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Найти последнего зарегистрированного пользователя?",
$this->ipsclass->adskin->form_dropdown( 'lastreg', array( 0 => array( 1, 'Да' ), 1 => array( 0, 'Нет' ) ) )
) );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Сбросить 'Рекорд посещаемости форума'?",
$this->ipsclass->adskin->form_dropdown( 'online', array( 0 => array( 0, 'Нет' ), 1 => array( 1, 'Да' ) ) )
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Обновить статистику');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// Resynchronise Forums
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'doresyncforums' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Ресинхронизация форумов" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Ресинхронизация форумовДанная опция позволяет пересчитать темы, сообщения и найти последнего автора.
Действует для всех ваших форумов.
",
"по ". $this->ipsclass->adskin->form_simple_input( 'pergo', '50', 5 ). " за раз"
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Ресинхронизировать форумы');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// Resynchronise Forums
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'doresynctopics' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Ресинхронизация тем" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Ресинхронизация темЭта опция позволяет пересчитывать ответы, количество прикрепленных файлов, авторов тем и авторов ответов.
",
"по ". $this->ipsclass->adskin->form_simple_input( 'pergo', '500', 5 ). " за раз"
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Ресинхронизировать темы');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// Resynchronise Posts
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'doposts' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Перестройка содержимого сообщений" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Перестройка содержимого сообщенийЭта опция позволяет перестроить содержимое всех сообщений, включая BB-тэги и смайлики.
Полезно в тех случаях, когда вы изменили множество смайликов или изменили к ним путь.
",
"по ". $this->ipsclass->adskin->form_simple_input( 'pergo', '500', 5 ). " за раз"
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Перестроить содержимое сообщений');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// Resynchronise User Names
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'dopostnames' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Перестройка имен пользователей" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Перестройка имен пользователейЭта опция позволяет сбросить сохраненные имена пользователей в темах, сообщениях, логах и т.п.
Полезно в тех случаях, когда вы часто конвертируете или меняете в ручную имена пользователей.
",
"по ". $this->ipsclass->adskin->form_simple_input( 'pergo', '500', 5 ). " за раз"
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Перестроить имена пользователей');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// Resynchronise User Post Counts
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'dopostcounts' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Пересчет сообщений пользователей" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Пересчет сообщений пользователейЭта опция позволяет пересчитать все сообщения пользователей по ТЕКУЩИМ сообщениям базы данных форума.
Обычно после пересчета счетчики сообщений пользователей УМЕНЬШАЮТСЯ, так как при пересчете не учитываются удаленные сообщения.
Это действие следует выполнить в том случае, если вы хотите узнать настоящее количество сообщений ваших пользователей.
Внимание: ЭТО ДЕЙСТВИЕ НЕЛЬЗЯ ОТМЕНИТЬ!",
"по ". $this->ipsclass->adskin->form_simple_input( 'pergo', '500', 5 ). " за раз"
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Пересчет сообщений пользователей');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// Rebuild thumbnails
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'dothumbnails' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Перестройка уменьшенных изображений" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Перестройка уменьшенных изображенийЭта опция позволяет перестроить уменьшенные изображения прикрепленных файлов.
Полезно в тех случаях, когда вы изменили размеры уменьшенных изображений и хотите обновить все прикрепленные изображения.
Внимание: эта опция требует достаточно много ресурсов.",
"по ". $this->ipsclass->adskin->form_simple_input( 'pergo', '20', 5 ). " за раз"
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Перестроить уменьшенные изображения');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// Rebuild attachment data
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'doattachdata' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Перестройка информации о прикрепленных файлах" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Перестройка информации о прикрепленных файлахЭта опция позволяет перестроить всю информацию о прикрепленных файлах, такую как: размер файла, местоположение и разрешение файла.
Внимание: эта опция требует достаточно много ресурсов.",
"по ".
$this->ipsclass->adskin->form_simple_input( 'pergo', '50', 5 ). " за раз"
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Перестроить информацию о прикрепленных файлах');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// Clean up attachments
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'cleanattachments' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Удаление прикрепленных файлов без связей" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Удаление прикрепленных файлов без связейЭта опция позволяет проверить и удалить все файлы 'post-', которые уже не являются прикрепленными.
Внимание: эта опция требует достаточно много ресурсов.",
"по ".
$this->ipsclass->adskin->form_simple_input( 'pergo', '50', 5 ). " за раз"
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Удалить прикрепленные файлы без связей');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// Clean up uploaded avatars
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'cleanavatars' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Удаление аватар без связей" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Удаление аватар без связейЭта опция позволяет проверить и удалить все файлы 'av-', которые уже не используются пользователями.
Внимание: эта опция требует достаточно много ресурсов.",
"по ".
$this->ipsclass->adskin->form_simple_input( 'pergo', '50', 5 ). " за раз"
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Удалить аватары без связей');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-----------------------------------------
// Clean up uploaded photos
//-----------------------------------------
$this->ipsclass->html .= $this->ipsclass->adskin->start_form( array( 1 => array( 'code' , 'cleanphotos' ),
2 => array( 'act' , 'rebuild' ),
4 => array( 'section', $this->ipsclass->section_code ),
) );
$this->ipsclass->adskin->td_header[] = array( " " , "60%" );
$this->ipsclass->adskin->td_header[] = array( " " , "40%" );
$this->ipsclass->html .= $this->ipsclass->adskin->start_table( "Удаление фотографий без связей" );
$this->ipsclass->html .= $this->ipsclass->adskin->add_td_row( array( "Удаление фотографий без связейЭта опция позволяет проверить и удалить все файлы 'photo-', которые уже не используются пользователями.
Внимание: эта опция требует достаточно много ресурсов.",
"по ".
$this->ipsclass->adskin->form_simple_input( 'pergo', '50', 5 ). " за раз"
) );
$this->ipsclass->html .= $this->ipsclass->adskin->end_form('Удалить фотографии без связей');
$this->ipsclass->html .= $this->ipsclass->adskin->end_table();
//-------------------------------//
$this->ipsclass->admin->output();
}
}
?>