<?php
if( !defined( 'DATALIFEENGINE' ) OR !defined( 'LOGGED_IN' ) ) {die("Hacking attempt!");}
if($member_id['user_group'] != 1){ msg("error", $lang['addnews_denied'], $lang['db_denied']); }



echoheader("", "");

$row = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_post" );
echo <<<HTML
<form action="" method="post">
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
    <tr>
        <td width="4"><img src="system/skins/images/tl_lo.gif" width="4" height="4" border="0"></td>
        <td background="system/skins/images/tl_oo.gif"><img src="system/skins/images/tl_oo.gif" width="1" height="4" border="0"></td>
        <td width="6"><img src="system/skins/images/tl_ro.gif" width="6" height="4" border="0"></td>
    </tr>
    <tr>
        <td background="system/skins/images/tl_lb.gif"><img src="system/skins/images/tl_lb.gif" width="4" height="1" border="0"></td>
        <td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
    <tr>
        <td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">{$lang['opt_srebuild']}</div></td>
    </tr>
</table>
<div class="unterline"></div>

<table width="100%">
    <tr>
        <td style="padding:2px;height:0px;"><div id="progressbar"></div>{$lang['stat_allnews']}&nbsp;{$row['count']},&nbsp;{$lang['rebuild_count']}&nbsp;<font color="red"><span id="newscount">0</span></font>&nbsp;<span id="progress"></span></td>
    </tr>

	<tr><td background="system/skins/images/mline.gif" height=1 colspan=2></td></tr>
    <tr>
        <td style="padding:2px;" colspan="2">&nbsp;</td>
    </tr>
    <tr>
        <td style="padding:2px;"><input type="submit" id="button" class="btn btn-primary" value="{$lang['rebuild_start']}" style="width:190px;"><input type="hidden" id="rebuild_ok" name="rebuild_ok" value="0"></td>
    </tr>
</table>
</td>
        <td background="system/skins/images/tl_rb.gif"><img src="system/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
    </tr>
    <tr>
        <td><img src="system/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
        <td background="system/skins/images/tl_ub.gif"><img src="system/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
        <td><img src="system/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
    </tr>
</table>
</div></form>
<script language="javascript" type="text/javascript">

  var total = {$row['count']};

	$(function() {

		$( "#progressbar" ).progressbar({
			value: 0
		});

		$('#button').click(function() {

			$("#progress").ajaxError(function(event, request, settings){
			   $(this).html('{$lang['nl_error']}');
				$('#button').attr("disabled", false);
			 });

			$('#progress').html('{$lang['rebuild_status']}');
			$('#button').attr("disabled", "disabled");
			$('#button').val("{$lang['rebuild_forw']}");
			senden( $('#rebuild_ok').val() );
			return false;
		});

	});

function senden( startfrom ){

	$.post("system/ajax/rebuild.php?user_hash={$dle_login_hash}", { startfrom: startfrom },
		function(data){

			if (data) {

				if (data.status == "ok") {

					$('#newscount').html(data.rebuildcount);
					$('#rebuild_ok').val(data.rebuildcount);

					var proc = Math.round( (100 * data.rebuildcount) / total );

					if ( proc > 100 ) proc = 100;

					$('#progressbar').progressbar( "option", "value", proc );

			         if (data.rebuildcount >= total) 
			         {
			              $('#progress').html('{$lang['rebuild_status_ok']}');
			         }
			         else 
			         { 
			              setTimeout("senden(" + data.rebuildcount + ")", 5000 );
			         }


				}

			}
		}, "json");

	return false;
}
</script>
HTML;


$row = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_static" );
echo <<<HTML
<form action="" method="post">
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
    <tr>
        <td width="4"><img src="system/skins/images/tl_lo.gif" width="4" height="4" border="0"></td>
        <td background="system/skins/images/tl_oo.gif"><img src="system/skins/images/tl_oo.gif" width="1" height="4" border="0"></td>
        <td width="6"><img src="system/skins/images/tl_ro.gif" width="6" height="4" border="0"></td>
    </tr>
    <tr>
        <td background="system/skins/images/tl_lb.gif"><img src="system/skins/images/tl_lb.gif" width="4" height="1" border="0"></td>
        <td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
    <tr>
        <td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">{$lang['opt_statrebuild']}</div></td>
    </tr>
</table>
<div class="unterline"></div>
<table width="100%">
    <tr>
        <td style="padding:2px;height:0px;"><div id="progressbar2"></div>{$lang['stat_allstaic']}&nbsp;{$row['count']},&nbsp;{$lang['rebuild_count']}&nbsp;<font color="red"><span id="statcount">0</span></font>&nbsp;<span id="statprogress"></span></td>
    </tr>

	<tr><td background="system/skins/images/mline.gif" height=1 colspan=2></td></tr>
    <tr>
        <td style="padding:2px;" colspan="2">&nbsp;</td>
    </tr>
    <tr>
        <td style="padding:2px;"><input type="submit" id="button2" class="btn btn-primary" value="{$lang['rebuild_start']}" style="width:190px;"><input type="hidden" id="rebuild_ok2" name="rebuild_ok2" value="0"></td>
    </tr>
</table>
</td>
        <td background="system/skins/images/tl_rb.gif"><img src="system/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
    </tr>
    <tr>
        <td><img src="system/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
        <td background="system/skins/images/tl_ub.gif"><img src="system/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
        <td><img src="system/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
    </tr>
</table>
</div></form>
<script language="javascript" type="text/javascript">

  var total2 = {$row['count']};

	$(function() {

		$( "#progressbar2" ).progressbar({
			value: 0
		});

		$('#button2').click(function() {

			$("#statprogress").ajaxError(function(event, request, settings){
			   $(this).html('{$lang['nl_error']}');
				$('#button2').attr("disabled", false);
			 });


			$('#statprogress').html('{$lang['rebuild_status']}');
			$('#button2').attr("disabled", "disabled");
			$('#button2').val("{$lang['rebuild_forw']}");
			senden_stat( $('#rebuild_ok2').val() );
			return false;
		});

	});

function senden_stat( startfrom ){

	$.post("system/ajax/rebuild.php?user_hash={$dle_login_hash}", { startfrom: startfrom, area: 'static' },
		function(data){

			if (data) {

				if (data.status == "ok") {

					$('#statcount').html(data.rebuildcount);
					$('#rebuild_ok2').val(data.rebuildcount);

					var proc = Math.round( (100 * data.rebuildcount) / total2 );

					if ( proc > 100 ) proc = 100;

					$('#progressbar2').progressbar( "option", "value", proc );

			         if (data.rebuildcount >= total2) 
			         {
			              $('#statprogress').html('{$lang['rebuild_status_ok']}');
			         }
			         else 
			         { 
			              setTimeout("senden_stat(" + data.rebuildcount + ")", 5000 );
			         }


				}

			}
		}, "json");

	return false;
}
</script>
HTML;

$row2 = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_comments" );
echo <<<HTML
<form action="" method="post">
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
    <tr>
        <td width="4"><img src="system/skins/images/tl_lo.gif" width="4" height="4" border="0"></td>
        <td background="system/skins/images/tl_oo.gif"><img src="system/skins/images/tl_oo.gif" width="1" height="4" border="0"></td>
        <td width="6"><img src="system/skins/images/tl_ro.gif" width="6" height="4" border="0"></td>
    </tr>
    <tr>
        <td background="system/skins/images/tl_lb.gif"><img src="system/skins/images/tl_lb.gif" width="4" height="1" border="0"></td>
        <td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
    <tr>
        <td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">������������ ������������</div></td>
    </tr>
</table>
<div class="unterline"></div>
<table width="100%">
    <tr>
        <td style="padding:2px;height:0px;"><div id="progressbar3"></div>����� ������������ ������������&nbsp;{$row2['count']},&nbsp;{$lang['rebuild_count']}&nbsp;<font color="red"><span id="stat_c">0</span></font>&nbsp;<span id="1stat_p"></span></td>
    </tr>

	<tr><td background="system/skins/images/mline.gif" height=1 colspan=2></td></tr>
    <tr>
        <td style="padding:2px;" colspan="2">&nbsp;</td>
    </tr>
    <tr>
        <td style="padding:2px;"><input type="submit" id="button3" class="btn btn-primary" value="{$lang['rebuild_start']}" style="width:190px;"><input type="hidden" id="rebuild_ok3" name="rebuild_ok3" value="0"></td>
    </tr>
</table>
</td>
        <td background="system/skins/images/tl_rb.gif"><img src="system/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
    </tr>
    <tr>
        <td><img src="system/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
        <td background="system/skins/images/tl_ub.gif"><img src="system/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
        <td><img src="system/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
    </tr>
</table>
</div></form>
<script language="javascript" type="text/javascript">

 var total3 = {$row2['count']};

	$(function() {

		$( "#progressbar3" ).progressbar({
			value: 0
		});

		$('#button3').click(function() {

			$("#1stat_p").ajaxError(function(event, request, settings){
			   $(this).html('{$lang['nl_error']}');
				$('#button3').attr("disabled", false);
			 });


			$('#1stat_p').html('{$lang['rebuild_status']}');
			$('#button3').attr("disabled", "disabled");
			$('#button3').val("{$lang['rebuild_forw']}");
			senden_comm( $('#rebuild_ok3').val() );
			return false;
		});

	});

function senden_comm( startfrom ){

	$.post("system/ajax/rebuild.php?user_hash={$dle_login_hash}", { startfrom: startfrom, area: 'comments' },
		function(data){

			if (data) {

				if (data.status == "ok") {

					$('#stat_c').html(data.rebuildcount);
					$('#rebuild_ok3').val(data.rebuildcount);

					var proc = Math.round( (100 * data.rebuildcount) / total3 );

					if ( proc > 100 ) proc = 100;

					$('#progressbar3').progressbar( "option", "value", proc );

			         if (data.rebuildcount >= total3)
			         {
			              $('#1stat_p').html('{$lang['rebuild_status_ok']}');
			         }
			         else
			         {
			              setTimeout("senden_comm(" + data.rebuildcount + ")", 5000 );
			         }


				}

			}
		}, "json");

	return false;
}
</script>
HTML;

$row3 = $db->super_query( "SELECT COUNT(*) as count FROM " . PREFIX . "_forum_posts" );
echo <<<HTML
<form action="" method="post">
<div style="padding-top:5px;padding-bottom:2px;">
<table width="100%">
    <tr>
        <td width="4"><img src="system/skins/images/tl_lo.gif" width="4" height="4" border="0"></td>
        <td background="system/skins/images/tl_oo.gif"><img src="system/skins/images/tl_oo.gif" width="1" height="4" border="0"></td>
        <td width="6"><img src="system/skins/images/tl_ro.gif" width="6" height="4" border="0"></td>
    </tr>
    <tr>
        <td background="system/skins/images/tl_lb.gif"><img src="system/skins/images/tl_lb.gif" width="4" height="1" border="0"></td>
        <td style="padding:5px;" bgcolor="#FFFFFF">
<table width="100%">
    <tr>
        <td bgcolor="#EFEFEF" height="29" style="padding-left:10px;"><div class="navigation">������������ ������ ������</div></td>
    </tr>
</table>
<div class="unterline"></div>
<table width="100%">
    <tr>
        <td style="padding:2px;height:0px;"><div id="progressbar4"></div>����� ������������ ������&nbsp;{$row3['count']},&nbsp;{$lang['rebuild_count']}&nbsp;<font color="red"><span id="stat_f">0</span></font>&nbsp;<span id="1stat_f"></span></td>
    </tr>

	<tr><td background="system/skins/images/mline.gif" height=1 colspan=2></td></tr>
    <tr>
        <td style="padding:2px;" colspan="2">&nbsp;</td>
    </tr>
    <tr>
        <td style="padding:2px;"><input type="submit" id="button4" class="btn btn-primary" value="{$lang['rebuild_start']}" style="width:190px;"><input type="hidden" id="rebuild_ok4" name="rebuild_ok4" value="0"></td>
    </tr>
</table>
</td>
        <td background="system/skins/images/tl_rb.gif"><img src="system/skins/images/tl_rb.gif" width="6" height="1" border="0"></td>
    </tr>
    <tr>
        <td><img src="system/skins/images/tl_lu.gif" width="4" height="6" border="0"></td>
        <td background="system/skins/images/tl_ub.gif"><img src="system/skins/images/tl_ub.gif" width="1" height="6" border="0"></td>
        <td><img src="system/skins/images/tl_ru.gif" width="6" height="6" border="0"></td>
    </tr>
</table>
</div></form>
<script language="javascript" type="text/javascript">

 var total4 = {$row3['count']};

	$(function() {

		$( "#progressbar4" ).progressbar({
			value: 0
		});

		$('#button4').click(function() {

			$("#1stat_f").ajaxError(function(event, request, settings){
			   $(this).html('{$lang['nl_error']}');
				$('#button4').attr("disabled", false);
			 });


			$('#1stat_f').html('{$lang['rebuild_status']}');
			//$('#button4').attr("disabled", "disabled");
			$('#button4').val("{$lang['rebuild_forw']}");
			senden_forum( $('#rebuild_ok4').val() );
			return false;
		});

	});

function senden_forum ( startfrom ){

	$.post("system/ajax/rebuild.php?user_hash={$dle_login_hash}", { startfrom: startfrom, area: 'forum' },
		function(data){

			if (data) {

				if (data.status == "ok") {

					$('#stat_f').html(data.rebuildcount);
					$('#rebuild_ok4').val(data.rebuildcount);

					var proc = Math.round( (100 * data.rebuildcount) / total4 );

					if ( proc > 100 ) proc = 100;

					$('#progressbar4').progressbar( "option", "value", proc );

			         if (data.rebuildcount >= total3)
			         {
			              $('#1stat_f').html('{$lang['rebuild_status_ok']}');
			         }
			         else
			         {
			              setTimeout("senden_forum(" + data.rebuildcount + ")", 5000 );
			         }


				}

			}
		}, "json");

	return false;
}
</script>
HTML;

echofooter();
?>