require_once('./include/ProcessDB2.inc.php');
// 最多每行32個byte
$number_of_bytes_per_line = 32;
// 最多11行
$max_number_of_lines = 10000;
$current_number_of_lines = 0;
$current_time = time();
$period_count = 0;
$period_result = GetActivity(20, 0, $current_time, 1, 0);
//$period_result = GetActivity( 20, 2, $current_time, 1, 0 );
$normal_count = 0;
$normal_result = GetActivity(100, 0, $current_time, 1, 0);
while (($row = mysqli_fetch_array($normal_result))) {
if (trim($row['title']) != '') {
$current_number_of_lines += intval((mb_strlen($row["title"], '8bit') + $number_of_bytes_per_line - 1) / $number_of_bytes_per_line);
if ($current_number_of_lines >= $max_number_of_lines)
break;
$sort_array[1000 + $normal_count] = $row['ID']; // $row['date'];
$item_count++;
}
$normal_count++;
}
// sorting
arsort($sort_array);
// output
foreach ($sort_array as $key => $val) {
// normal
if (intval($key / 1000) == 1) {
mysqli_data_seek($normal_result, $key % 1000);
$row = mysqli_fetch_array($normal_result);
}
// with period
else {
mysqli_data_seek($period_result, $key % 1000);
$row = mysqli_fetch_array($period_result);
}
$printEven = ($even) ? 'even' : 'odd';
print('| ');
if (($current_time - $row['date']) < 604800)
print('' . date('%d/%m/%Y', $row['date']) . '');
else
print(date('%d/%m/%Y', $row['date']));
print(' | ');
if ($row['link'] == '')
print("" . $row['title'] . " ");
else {
if ($row['newwin'] == 1)
print("" . $row['title'] . " ");
else
print("" . $row['title'] . " ");
}
/*
switch( $row['ChangeColor'] )
{
case 3:
print( ' ' );
break;
case 2:
print( ' ' );
break;
case 1:
print( ' ' );
break;
}*/
print(' |
');
$item_count++;
$even = !$even;
}
/*$item_count = 0;
while( ($row = mysql_fetch_array($data_array)) && $item_count < 5 )
{
if( $row['title'] != '' )
{
print( '| ' );
if( ($current_time - $row['date']) < 604800 )
print('' . strftime('%d/%m/%Y', $row['date']) . '' );
else if ($row['ChangeColor'] == 1)
print('' . strftime('%d/%m/%Y', $row['date']) . '' );
else
print( strftime('%d/%m/%Y', $row['date']) );
print( ' | ' );
if( $row['link'] == '' )
print( "" . $row['title'] . " " );
else
{
if($row['newwin'] == 1)
print("" . $row['title'] . " ");
else
print("" . $row['title'] . " ");
}
print( ' |
' );
$item_count++;
}
}*/
mysqli_free_result($period_result);
mysqli_free_result($normal_result);
?>