Location: PHPKode > projects > PBBoard > PBBoard_v2.1.4/Upload/modules/admin/fixup.module.php
<?php

(!defined('IN_PowerBB')) ? die() : '';

define('IN_ADMIN',true);

include('common.php');

define('CLASS_NAME','PowerBBFixMOD');

class PowerBBFixMOD
{
	function run()
	{
		global $PowerBB;

		if ($PowerBB->_CONF['member_permission'])
		{
			$PowerBB->template->display('header');

			if ($PowerBB->_CONF['rows']['group_info']['admincp_fixup'] == '0')
			{
			  $PowerBB->functions->error($PowerBB->_CONF['template']['lang']['error_permission']);
			}

			if ($PowerBB->_GET['repair'])
			{
				if ($PowerBB->_GET['main'])
				{
					$this->_RepairMain();
				}
			}
			elseif ($PowerBB->_GET['update_meter'])
			{
				if ($PowerBB->_GET['main'])
				{
					$this->_MeterMain();
				}
				elseif ($PowerBB->_GET['start'])
				{
					$this->_MeterStart();
				}
				elseif ($PowerBB->_GET['all_cache'])
				{
					$this->_AllCacheStart();
				}
				elseif ($PowerBB->_GET['groups'])
				{
					$this->_MeterGroupsStart();
				}

			}
			elseif ($PowerBB->_GET['repair_mem_posts'])
			{
				$this->_RepairMemberPostsStart();
			}
			elseif ($PowerBB->_GET['update_posts'])
			{
				$this->_UpdatePostsStart();
			}
			elseif ($PowerBB->_GET['update_username_members'])
			{
				$this->_UpdatUsernameMembersStart();
			}
			elseif ($PowerBB->_GET['update_static'])
			{
				$this->_UpdatStaticStart();
			}
			if ($PowerBB->_GET['info'])
			{
				$this->_php_infoStart();
			}

			$PowerBB->template->display('footer');
		}
	}



	function _MeterMain()
	{
		global $PowerBB;



		// Show Jump List to:)
		$result = $PowerBB->DB->sql_query("SELECT id,title,parent FROM " . $PowerBB->table['section'] . " ORDER BY id ASC");

		$Master = array();
		while ($row = @mysql_fetch_array($result)) {
			extract($row);
		    $Master = $PowerBB->section->GetSectionsList(array ('id'=>$id,'title'=>"".$title."",'parent'=>$parent));
		    $PowerBB->_CONF['template']['foreach']['SecList'] = $PowerBB->section->GetSectionsList($Master);
		}

		$MainAndSub = new PowerBBCommon;
          	$PowerBB->template->assign('DoJumpList',$MainAndSub->DoJumpList($Master,$url,1));
		unset($Master);
	   ////////

		$GroupArr 						= 	array();
		$GroupArr['order'] 				= 	array();
		$GroupArr['order']['field'] 	= 	'id';
		$GroupArr['order']['type'] 		= 	'ASC';

		$PowerBB->_CONF['template']['while']['groups'] = $PowerBB->group->GetGroupList($GroupArr);

		//////////
		//////////

        $SecArr 						= 	array();
		$SecArr['get_from']				=	'db';

		$SecArr['proc'] 				= 	array();
		$SecArr['proc']['*'] 			= 	array('method'=>'clean','param'=>'html');

		$SecArr['order']				=	array();
		$SecArr['order']['field']		=	'sort';
		$SecArr['order']['type']		=	'ASC';

		$SecArr['where']				=	array();
		$SecArr['where'][0]['name']		= 	'parent';
		$SecArr['where'][0]['oper']		= 	'=';
		$SecArr['where'][0]['value']	= 	'0';

		// Get main sections
		$cats = $PowerBB->section->GetSectionsList($SecArr);

		// We will use forums_list to store list of forums which will view in main page
		$PowerBB->_CONF['template']['foreach']['forums_list'] = array();

		// Loop to read the information of main sections
		foreach ($cats as $cat)
		{
			// Get the groups information to know view this section or not
			$groups = unserialize(base64_decode($cat['sectiongroup_cache']));


					$PowerBB->_CONF['template']['foreach']['forums_list'][$cat['id'] . '_m'] = $cat;


			if (!empty($cat['forums_cache']))
			{
				$forums = unserialize(base64_decode($cat['forums_cache']));

				foreach ($forums as $forum)
				{


							$forum['is_sub'] 	= 	0;
							$forum['sub']		=	'';

							if (!empty($forum['forums_cache']))
							{
								$subs = unserialize(base64_decode($forum['forums_cache']));

								if (is_array($subs))
								{
									foreach ($subs as $sub)
									{

												if (!$forum['is_sub'])
												{
													$forum['is_sub'] = 1;
												}

												$forum['sub'] .= ('<option value="' .$sub['id'] . '">---'  . $sub['title'] . '</option>');

									}
								}
							}


							$PowerBB->_CONF['template']['foreach']['forums_list'][$forum['id'] . '_f'] = $forum;
					} // end if is_array
				} // end foreach ($forums)
			} // end !empty($forums_cache)
		$PowerBB->template->display('meter_edit');
	}

	function _MeterStart()
	{
		global $PowerBB;

		$SubjectArr = array();
		$SubjectArr['where'] = array('section',$PowerBB->_POST['section']);

		$subject = $PowerBB->subject->GetSubjectInfo($SubjectArr);

		$SecArr 			= 	array();
		$SecArr['where'] 	= 	array('id',$PowerBB->_POST['section']);

		$SectionInfo = $PowerBB->section->GetSectionInfo($SecArr);

		if ($SectionInfo['parent'] == 0)
		{

        $PowerBB->functions->msg($PowerBB->_CONF['template']['lang']['updated']  .  $SectionInfo['title']  .  $PowerBB->_CONF['template']['lang']['Successfully']);
		$PowerBB->functions->redirect('admin.php?page=fixup&amp;update_meter=1&amp;main=1');


		}
		else
		{


	     	// The number of section's subjects number
	        $section = $PowerBB->_POST['section'];
			$reply_num = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query("SELECT  *   FROM " . $PowerBB->table['reply'] . " WHERE section = '$section' "));

     		$UpdateArr 					= 	array();
     		$UpdateArr['field']			=	array();

     		$UpdateArr['field']['reply_num'] 	= 	$reply_num;
     		$UpdateArr['where']					= 	array('id',$section);

     		$UpdateReplyNumber = $PowerBB->section->UpdateSection($UpdateArr);
          	$PowerBB->cache->UpdateReplyNumber(array('reply_num'	=>	$reply_num));

           // The number of section's subjects number

			$section = $PowerBB->_POST['section'];
			$subject_nm = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query("SELECT  *   FROM " . $PowerBB->table['subject'] . " WHERE section = '$section' "));

			$UpdateArr 					= 	array();
			$UpdateArr['field']			=	array();

			$UpdateArr['field']['subject_num'] 	= 	$subject_nm;
			$UpdateArr['where']					= 	array('id',$section);

			$UpdateSubjectNumber = $PowerBB->section->UpdateSection($UpdateArr);
            $PowerBB->cache->UpdateSubjectNumber(array('subject_num'	=>	$subject_nm));

					$SecArr 					= 	array();
					$SecArr['get_from']			=	'db';
					$SecArr['proc'] 			= 	array();
					$SecArr['proc']['*'] 		= 	array('method'=>'clean','param'=>'html');
					$SecArr['order']			=	array();
					$SecArr['order']['field']	=	'sort';
					$SecArr['order']['type']	=	'ASC';

					$SecArr['where']				=	array();
					$SecArr['where'][0]				=	array();
					$SecArr['where'][0]['name']		=	'parent';
					$SecArr['where'][0]['oper']		=	'<>';
					$SecArr['where'][0]['value']	=	'0';

					$SecList = $PowerBB->section->GetSectionsList($SecArr);

					$x = 0;
					$y = sizeof($SecList);
					$s = array();

					while ($x < $y)
					{
						$name = 'order-' . $SecList[$x]['id'];

						if ($SecList[$x]['order'] != $PowerBB->_POST[$name])
						{
							$UpdateArr 						= 	array();

							$UpdateArr['field']		 		= 	array();
							$UpdateArr['field']['sort'] 	= 	$PowerBB->_POST[$name];

							$UpdateArr['where'] 			=	array('id',$SecList[$x]['id']);

							$update = $PowerBB->section->UpdateSection($UpdateArr);

							if ($update)
							{
								$cache = $PowerBB->section->UpdateSectionsCache(array('parent'=>$SecList[$x]['id']));
								//////////

								$CacheArr 			= 	array();
								$CacheArr['where'] 	= 	array('section_id',$SecList[$x]['parent']);
								$cache = $PowerBB->moderator->CreateModeratorsCache($CacheArr);

								$SecArr 				= 	array();
								$SecArr['field']		=	array();
								$SecArr['field']['moderators'] 	= 	$cache;
								$SecArr['where'] 			=	array('id',$SecList[$x]['parent']);
								$update = $PowerBB->section->UpdateSection($SecArr);
	                           $UpdateSectionCache6 = $PowerBB->functions->UpdateSectionCache($SecList[$x]['id']);
							}

							$s[$SecList[$x]['id']] = ($update) ? 'true' : 'false';
						}

						$x += 1;
					}




		$GetLastqueryReplyForm = $PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['reply'] . " WHERE section = '$section' ORDER by write_time DESC");
		$GetLastReplyForm = $PowerBB->DB->sql_fetch_array($GetLastqueryReplyForm);

			// Update Last subject's information in Section Form
     		$UpdateLastFormSecArr = array();
     		$UpdateLastFormSecArr['field']			=	array();

			$UpdateLastFormSecArr['field']['last_writer'] 		= 	$GetLastReplyForm['writer'];
     		$UpdateLastFormSecArr['field']['last_subject'] 		= 	$PowerBB->functions->CleanVariable($GetLastReplyForm['title'],'html');
     		$UpdateLastFormSecArr['field']['last_subjectid'] 	= 	$GetLastReplyForm['subject_id'];
     		$UpdateLastFormSecArr['field']['last_date'] 	= 	$GetLastReplyForm['write_time'];
     		$UpdateLastFormSecArr['field']['last_time'] 	= 	$GetLastReplyForm['write_time'];
     		$UpdateLastFormSecArr['field']['icon'] 		    = 	$LastSubjectInfo['icon'];
		    $UpdateLastFormSecArr['field']['last_reply'] 	= 	0;
		    $UpdateLastFormSecArr['field']['last_berpage_nm']  = 	0;

     		$UpdateLastFormSecArr['where'] 		        = 	array('id',$section);

     		// Update Last Form Sec subject's information
     		$UpdateLastFormSec = $PowerBB->section->UpdateSection($UpdateLastFormSecArr);

                // Get Section Info
				$SecArr 			= 	array();
				$SecArr['where'] 	= 	array('id',$section);

				$this->SectionInfo = $PowerBB->section->GetSectionInfo($SecArr);

				$CacheArr 			= 	array();
				$CacheArr['where'] 	= 	array('section_id',$PowerBB->_POST['section']);
				$cache = $PowerBB->moderator->CreateModeratorsCache($CacheArr);

				$SecArr 				= 	array();
				$SecArr['field']		=	array();
				$SecArr['field']['moderators'] 	= 	$cache;
				$SecArr['where'] 			=	array('id',$PowerBB->_POST['section']);
				$update = $PowerBB->section->UpdateSection($SecArr);

     		// Update section's cache
     		$UpdateArr 				= 	array();
     		$UpdateArr['parent'] 	= 	$this->SectionInfo['parent'];

     		$update_cache = $PowerBB->section->UpdateSectionsCache($UpdateArr);

     		unset($UpdateArr);

				$PowerBB->functions->msg($PowerBB->_CONF['template']['lang']['updated']  .  $SectionInfo['title']  .  $PowerBB->_CONF['template']['lang']['Successfully']);
				$PowerBB->functions->redirect('admin.php?page=fixup&amp;update_meter=1&amp;main=1');



        }


	}

	function _AllCacheStart()
	{
		global $PowerBB;

					$SecArr 					= 	array();
					$SecArr['get_from']			=	'db';
					$SecArr['proc'] 			= 	array();
					$SecArr['proc']['*'] 		= 	array('method'=>'clean','param'=>'html');
					$SecArr['order']			=	array();
					$SecArr['order']['field']	=	'sort';
					$SecArr['order']['type']	=	'ASC';

					$SecArr['where']				=	array();
					$SecArr['where'][0]				=	array();
					$SecArr['where'][0]['name']		=	'parent';
					$SecArr['where'][0]['oper']		=	'<>';
					$SecArr['where'][0]['value']	=	'0';

					$SecList = $PowerBB->section->GetSectionsList($SecArr);

					$x = 0;
					$y = sizeof($SecList);
					$s = array();

					while ($x < $y)
					{
						$name = 'order-' . $SecList[$x]['id'];

						if ($SecList[$x]['order'] != $PowerBB->_POST[$name])
						{
							$UpdateArr 						= 	array();

							$UpdateArr['field']		 		= 	array();
							$UpdateArr['field']['sort'] 	= 	$PowerBB->_POST[$name];

							$UpdateArr['where'] 			=	array('id',$SecList[$x]['id']);

							$update = $PowerBB->section->UpdateSection($UpdateArr);

							if ($update)
							{
								$cache = $PowerBB->section->UpdateSectionsCache(array('parent'=>$SecList[$x]['parent']));
								$cache = $PowerBB->section->UpdateSectionsCache(array('parent'=>$SecList[$x]['id']));


	                           $UpdateSectionCache6 = $PowerBB->functions->UpdateSectionCache($SecList[$x]['id']);


							}

							$s[$SecList[$x]['id']] = ($update) ? 'true' : 'false';
						}

						$x += 1;

						    $section = $SecList[$x]['id'];
						    $subject_nm = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query("SELECT  *   FROM " . $PowerBB->table['subject'] . " WHERE section = '$section' "));

				            // The number of section's subjects number
				     		$UpdateArr 					= 	array();
				     		$UpdateArr['field']			=	array();

				     		$UpdateArr['field']['subject_num'] 	= 	$subject_nm;
				     		$UpdateArr['where']					= 	array('id',$section);

				     		$UpdateSubjectNumber = $PowerBB->section->UpdateSection($UpdateArr);
				            $PowerBB->cache->UpdateSubjectNumber(array('subject_num'	=>	$subject_nm));

				                 		// The number of section's subjects number
				            $section = $SecList[$x]['id'];
						    $reply_num = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query("SELECT  *   FROM " . $PowerBB->table['reply'] . " WHERE section = '$section' "));

				     		$UpdateArr 					= 	array();
				     		$UpdateArr['field']			=	array();

				     		$UpdateArr['field']['reply_num'] 	= 	$reply_num;
				     		$UpdateArr['where']					= 	array('id',$section);

				     		$UpdateReplyNumber = $PowerBB->section->UpdateSection($UpdateArr);
				     		$PowerBB->cache->UpdateReplyNumber(array('reply_num'	=>	$reply_num));

			                // Get Section Info
							$SecArr 			= 	array();
							$SecArr['where'] 	= 	array('id',$section);

							$this->SectionInfo = $PowerBB->section->GetSectionInfo($SecArr);

			     		// Update section's cache
			     		$UpdateArr 				= 	array();
			     		$UpdateArr['parent'] 	= 	$this->SectionInfo['parent'];

			     		$update_cache = $PowerBB->section->UpdateSectionsCache($UpdateArr);

			     		unset($UpdateArr);

								//////////

								$CacheArr 			= 	array();
								$CacheArr['where'] 	= 	array('section_id',$SecList[$x]['id']);
								$cache = $PowerBB->moderator->CreateModeratorsCache($CacheArr);

								$SecArr 				= 	array();
								$SecArr['field']		=	array();
								$SecArr['field']['moderators'] 	= 	$cache;
								$SecArr['where'] 			=	array('id',$SecList[$x]['id']);
								$update = $PowerBB->section->UpdateSection($SecArr);


						$PowerBB->functions->msg($PowerBB->_CONF['template']['lang']['updated']  .  $SecList[$x]['title']  .  $PowerBB->_CONF['template']['lang']['Successfully']);
						$PowerBB->functions->redirect('admin.php?page=fixup&amp;update_meter=1&amp;main=1');
					}



	}

	function _MeterGroupsStart()
	  {
		global $PowerBB;

        $truncate_sectiongroup = $PowerBB->DB->sql_query("TRUNCATE " . $PowerBB->table['section_group'] );

        $query = $PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['section'] . " ");

        while ($r = $PowerBB->DB->sql_fetch_array($query))
	    {

	    $forumid 	    = 	$r['id'];
        $parentid 	    = 	$r['parent'];

       		$info_query_groups = $PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['group'] . " ");

			while ($groups = $PowerBB->DB->sql_fetch_array($info_query_groups))
			{
				if ($parentid == '0')
				{
					$main_section = '1';
				}
				else
				{
					$main_section = '0';
				}

				if ($groups['id'] == 7)
				{
					$write = '0';
				}
				elseif ($groups['id'] == 6)
				{
					$write = '0';
				}
				elseif ($groups['id'] == 5)
				{
					$write = '0';
				}
				else
				{
					$write = '1';
				}

				$SecArr 				= 	array();
				$SecArr['field']		=	array();

				$SecArr['field']['section_id'] 			= 	$forumid;
				$SecArr['field']['group_id'] 			= 	$groups['id'];
				$SecArr['field']['view_section'] 		= 	$groups['view_section'];
		        $SecArr['field']['view_subject'] 		= 	$groups['view_subject'];
				$SecArr['field']['download_attach'] 	= 	$groups['download_attach'];
				$SecArr['field']['write_subject'] 		= 	$groups['write_subject'];
				$SecArr['field']['write_reply'] 		= 	$groups['write_reply'];
				$SecArr['field']['upload_attach'] 		= 	$groups['upload_attach'];
				$SecArr['field']['edit_own_subject'] 	= 	$groups['edit_own_subject'];
				$SecArr['field']['edit_own_reply'] 		= 	$groups['edit_own_reply'];
				$SecArr['field']['del_own_subject'] 	= 	$groups['del_own_subject'];
				$SecArr['field']['del_own_reply'] 		= 	$groups['del_own_reply'];
				$SecArr['field']['write_poll'] 			= 	$groups['write_poll'];
				$SecArr['field']['vote_poll'] 			= 	$groups['vote_poll'];
				$SecArr['field']['no_posts'] 			= 	$groups['no_posts'];
				$SecArr['field']['main_section'] 		= 	$main_section;
				$SecArr['field']['group_name'] 			= 	$groups['title'];

				$insert = $PowerBB->group->InsertSectionGroup($SecArr);
			if ($insert)
			{

			$CacheArr 			= 	array();
			$CacheArr['id'] 	= 	$forumid;

			$cache = $PowerBB->group->UpdateSectionGroupCache($CacheArr);
			$cache = $PowerBB->section->UpdateSectionsCache(array('parent'=>$forumid));

           }
		 }
		}

				$PowerBB->functions->msg($PowerBB->_CONF['template']['lang']['updated_successfully_Please_wait']);
				$PowerBB->functions->redirect('admin.php?page=fixup&amp;update_meter=1&amp;main=1');
       }

   function _php_infoStart()
	{
    global $PowerBB;
      @phpinfo();

	}

   function _RepairMemberPostsStart()
	{
    global $PowerBB;

		if (!empty($PowerBB->_POST['perpage']))
		{
    	$perpage = $PowerBB->_POST['perpage'];
		}
		if (empty($PowerBB->_POST['perpage']))
		{
    	$perpage = '200';
		}
		$page = (int) (!isset($PowerBB->_GET['pag']) ? 1 : $PowerBB->_GET['pag']);
		$page = ($page == 0 ? 1 : $page);

		$startpoint = ($page * $perpage) - $perpage;
		$member_nm = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['member'] . " WHERE id"));
              $br = '<br>';
		echo('<br><br><table border="1" width="80%" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" style="border-collapse: collapse" align="center"><tr><td><font face="Tahoma" size="2">');

		$getmember_query = $PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['member'] . " ORDER BY id DESC LIMIT ".$startpoint.",".$perpage." ");
	    while ($MemInfo = $PowerBB->DB->sql_fetch_array($getmember_query))
        {
        	$MemUsername = $MemInfo['username'];
		    $member_nm_reply = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['reply'] . " WHERE writer = '$MemUsername'"));
		    $member_nm_subject = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['subject'] . " WHERE writer = '$MemUsername'"));

		  // change the cache of username style

			$GrpArr 			= 	array();
			$GrpArr['where'] 	= 	array('id',$MemInfo['usergroup']);

			$GroupInfo = $PowerBB->group->GetGroupInfo($GrpArr);

			$style = $GroupInfo['username_style'];
			$style = str_replace('[username]',$MemInfo['username'],$style);

		$UpdateArr 				= 	array();
		$UpdateArr['field'] 	= 	array();
		$UpdateArr['field']['posts'] 				= 	$member_nm_reply+$member_nm_subject;
		$UpdateArr['field']['username_style_cache']	=	$style;
		$UpdateArr['where']					    	 =	array('id',$MemInfo['id']);

		$update = $PowerBB->member->UpdateMember($UpdateArr);
		// UPDATE username_style today
		$update_username_style_today = $PowerBB->DB->sql_query("UPDATE " . $PowerBB->table['today'] . " SET username_style='" . $style . "' WHERE user_id='" . $MemInfo['id'] . "'");
		// UPDATE username_style online
		$update_username_style_online = $PowerBB->DB->sql_query("UPDATE " . $PowerBB->table['online'] . " SET username_style='" . $style . "' WHERE user_id='" . $MemInfo['id'] . "'");

		echo($MemInfo['username'] .' ..'. $br);

	   }
      		echo('</font></td></tr></table>');

		$current_page = $page;
       $pagesnum = round(ceil($member_nm / $perpage));

		if ($update)
		{
			if($pagesnum != $current_page or $pagesnum > $current_page)
			{
			$n_page = $current_page+1;
			$seconds= '5';
			$n_page = intval($n_page);
			echo('<br><table border="1" width="80%" cellspacing="0" cellpadding="0" bgcolor="#E5EBF0" style="border-collapse: collapse" align="center"><tr><td><font face="Tahoma" size="2">');
			$transition_click = $PowerBB->_CONF['template']['lang']['If_your_browser_does_not_support_automatic_transition_click_here'];
			echo($PowerBB->_CONF['template']['lang']['Waiting_Time'].$seconds.$PowerBB->_CONF['template']['lang']['seconds']);
			echo('</font></td></tr></table>');

			$PowerBB->functions->redirect('admin.php?page=fixup&amp;repair_mem_posts=1&amp;pag='.$n_page,$seconds);
			}
			else
			{

			$PowerBB->functions->redirect('admin.php?page=fixup&amp;update_meter=1&amp;main=1');

			}

		}
		else
		{
		echo('<br><table border="1" width="80%" cellspacing="0" cellpadding="0" bgcolor="#E5EBF0" style="border-collapse: collapse" align="center"><tr><td><font face="Tahoma" size="2">');
		echo($PowerBB->_CONF['template']['lang']['forum_does_not_contain_any_posts']);
		echo('</font></td></tr></table>');
		}

	}


	function _UpdatStaticStart()
	{
		global $PowerBB;


	         $reply_number = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query('SELECT ID FROM '.$PowerBB->table['reply'].' WHERE delete_topic <> 1 '));
	         $subject_number = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query('SELECT ID FROM '.$PowerBB->table['subject'].' WHERE delete_topic <> 1 '));
	         $member_number = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query('SELECT ID FROM '.$PowerBB->table['member'].' '));

	        $update = array();
			$update[0] = $PowerBB->info->UpdateInfo(array('value'=>$member_number,'var_name'=>'member_number'));
			$update[1] = $PowerBB->info->UpdateInfo(array('value'=>$reply_number,'var_name'=>'reply_number'));
			$update[2] = $PowerBB->info->UpdateInfo(array('value'=>$subject_number,'var_name'=>'subject_number'));

			if ($update[0] and $update[1] and $update[2])
			{
				$PowerBB->functions->msg($PowerBB->_CONF['template']['lang']['updated_successfully_Please_wait']);
				$PowerBB->functions->redirect('admin.php?page=fixup&amp;update_meter=1&amp;main=1');
			}


    }

	function _UpdatePostsStart()
	{
		global $PowerBB;

    	$perpage = '50';

		$page = (int) (!isset($PowerBB->_GET['pag']) ? 1 : $PowerBB->_GET['pag']);
		$page = ($page == 0 ? 1 : $page);

		$startpoint = ($page * $perpage) - $perpage;
        $br = '<br>';
		echo('<br><br><table border="1" width="80%" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" style="border-collapse: collapse" align="center"><tr><td><font face="Tahoma" size="2">');
       	 $reply_num = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query("SELECT  *   FROM " . $PowerBB->table['reply'] . " "));

		$ReplyArr = $PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['reply'] . " ORDER BY id DESC LIMIT ".$startpoint.",".$perpage." ");

		while ($RepList = $PowerBB->DB->sql_fetch_array($ReplyArr))
		{

				$SubjectArr = array();
				$SubjectArr['where'] = array('id',$RepList['subject_id']);

                      $SubjectInfo = $PowerBB->subject->GetSubjectInfo($SubjectArr);

				$UpdateRepArr 						= 	array();

				$UpdateRepArr['field']		 		= 	array();
				$UpdateRepArr['field']['section'] 	= 	$SubjectInfo['section'];

				$UpdateRepArr['where'] 			=	array('id',$RepList['id']);

				$update = $PowerBB->reply->UpdateReply($UpdateRepArr);

				if ($update)
				{
					$cache = $PowerBB->section->UpdateSectionsCache(array('parent'=>$SubjectInfo['section']));
					//////////
                     $reply_nm = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['reply'] . " WHERE section = ".$SubjectInfo['section'].""));

					$SubArr 				= 	array();
					$SubArr['field']		=	array();
					$SubArr['field']['reply_num'] 	= 	$reply_nm;
					$SubArr['where'] 			=	array('id',$RepList['section']);
					$update = $PowerBB->section->UpdateSection($SubArr);

                 $UpdateSectionCache6 = $PowerBB->functions->UpdateSectionCache($SubjectInfo['section']);
				}

				$s[$RepList['id']] = ($update) ? 'true' : 'false';

			echo($RepList['id'] .' ..'. $br);

		}

            echo('</font></td></tr></table>');

		$current_page = $page;
       $pagesnum = round(ceil($reply_num / $perpage));
		if ($update)
		{
			if($pagesnum != $current_page or $pagesnum > $current_page)
			{
			$n_page = $current_page+1;
			$seconds= '5';
			$n_page = intval($n_page);
			echo('<br><table border="1" width="80%" cellspacing="0" cellpadding="0" bgcolor="#E5EBF0" style="border-collapse: collapse" align="center"><tr><td><font face="Tahoma" size="2">');
			$transition_click = $PowerBB->_CONF['template']['lang']['If_your_browser_does_not_support_automatic_transition_click_here'];
			echo($PowerBB->_CONF['template']['lang']['Waiting_Time'].$seconds.$PowerBB->_CONF['template']['lang']['seconds']);
			echo('</font></td></tr></table>');

			$PowerBB->functions->redirect('admin.php?page=fixup&amp;update_posts=1&amp;pag='.$n_page,$seconds);
			}
			else
			{

			$PowerBB->functions->redirect('admin.php?page=fixup&amp;update_meter=1&amp;main=1');

			}

		}
		else
		{
		echo('<br><table border="1" width="80%" cellspacing="0" cellpadding="0" bgcolor="#E5EBF0" style="border-collapse: collapse" align="center"><tr><td><font face="Tahoma" size="2">');
		echo($PowerBB->_CONF['template']['lang']['forum_does_not_contain_any_posts']);
		echo('</font></td></tr></table>');
		}
    }



	function _UpdatUsernameMembersStart()
	{
		global $PowerBB;

		if (!empty($PowerBB->_POST['perpage']))
		{
    	$perpage = $PowerBB->_POST['perpage'];
		}
		if (empty($PowerBB->_POST['perpage']))
		{
    	$perpage = '200';
		}
		$page = (int) (!isset($PowerBB->_GET['pag']) ? 1 : $PowerBB->_GET['pag']);
		$page = ($page == 0 ? 1 : $page);

		$startpoint = ($page * $perpage) - $perpage;
		$member_nm = $PowerBB->DB->sql_num_rows($PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['member'] . " WHERE id"));
              $br = '<br>';
		echo('<br><br><table border="1" width="80%" cellspacing="0" cellpadding="0" bgcolor="#FFFFFF" style="border-collapse: collapse" align="center"><tr><td><font face="Tahoma" size="2">');

		$getmember_query = $PowerBB->DB->sql_query("SELECT * FROM " . $PowerBB->table['member'] . " ORDER BY id DESC LIMIT ".$startpoint.",".$perpage." ");
	    while ($MemInfo = $PowerBB->DB->sql_fetch_array($getmember_query))
        {
        	$MemUsername = $MemInfo['username'];
		  // change the cache of username style
			$GrpArr 			= 	array();
			$GrpArr['where'] 	= 	array('id',$MemInfo['usergroup']);

			$GroupInfo = $PowerBB->group->GetGroupInfo($GrpArr);

			$style = $GroupInfo['username_style'];
			$style = str_replace('[username]',$MemInfo['username'],$style);

		$UpdateArr 				= 	array();
		$UpdateArr['field'] 	= 	array();
		$UpdateArr['field']['username_style_cache']	=	$style;
		$UpdateArr['where']					    	 =	array('id',$MemInfo['id']);

		$update = $PowerBB->member->UpdateMember($UpdateArr);

		echo($MemInfo['username'] .' ..'. $br);

	   }
      		echo('</font></td></tr></table>');

		$current_page = $page;
       $pagesnum = round(ceil($member_nm / $perpage));

		if ($update)
		{
			if($pagesnum != $current_page or $pagesnum > $current_page)
			{
			$n_page = $current_page+1;
			$seconds= '5';
			$n_page = intval($n_page);
			echo('<br><table border="1" width="80%" cellspacing="0" cellpadding="0" bgcolor="#E5EBF0" style="border-collapse: collapse" align="center"><tr><td><font face="Tahoma" size="2">');
			$transition_click = $PowerBB->_CONF['template']['lang']['If_your_browser_does_not_support_automatic_transition_click_here'];
			echo($PowerBB->_CONF['template']['lang']['Waiting_Time'].$seconds.$PowerBB->_CONF['template']['lang']['seconds']);
			echo('</font></td></tr></table>');

			$PowerBB->functions->redirect('admin.php?page=fixup&amp;update_username_members=1&amp;pag='.$n_page,$seconds);
			}
			else
			{

			$PowerBB->functions->redirect('admin.php?page=fixup&amp;update_meter=1&amp;main=1');

			}

		}
		else
		{
		echo('<br><table border="1" width="80%" cellspacing="0" cellpadding="0" bgcolor="#E5EBF0" style="border-collapse: collapse" align="center"><tr><td><font face="Tahoma" size="2">');
		echo($PowerBB->_CONF['template']['lang']['forum_does_not_contain_any_members']);
		echo('</font></td></tr></table>');
		}

    }

	function _RepairMain()
	{
		global $PowerBB;

		$repair = $PowerBB->fixup->RepairTables();

		foreach ($repair as $table => $success)
		{
			if ($success)
			{
				$PowerBB->functions->msg($PowerBB->_CONF['template']['lang']['Has_been_fixed_table'] . $table);
			}
			else
			{
				$PowerBB->functions->msg($PowerBB->_CONF['template']['lang']['Failure_in_the_repair_of_table'] . $table);
			}
		}
	}

}



?>
Return current item: PBBoard