include "main_header.php";
include "includes/utils.php";
function display_browse_bar ()
{
global $l_result;
global $l_base_url;
global $l_posts_per_page;
global $l_result_count;
global $l_recent_start;
$l_start_page = 1;
$l_total_pages = floor ( $l_result_count / $l_posts_per_page ) + 1;
$l_current_page = floor ( $l_recent_start / $l_posts_per_page ) + 1;
if ( $l_result_count > 0 )
{
?>
| Build Thread, Page :
//
// Work out the starting page we should display.
//
$l_start_page = $l_current_page - 5;
if ( $l_start_page < 1 )
{
$l_start_page = 1;
}
if ( $l_start_page > 1 )
{
printf ( " << " );
}
$l_pages = $l_total_pages;
if ( $l_pages > ( $l_start_page + 10 ) )
{
$l_pages = $l_start_page + 10;
}
for ( $l_temp = $l_start_page; $l_temp <= $l_pages; $l_temp += 1 )
{
$l_offset = ( $l_temp - 1 ) * $l_posts_per_page;
$l_marker1 = ' ';
$l_marker2 = ' ';
if ( $l_offset == $l_recent_start )
{
$l_marker1 = '[';
$l_marker2 = ']';
}
printf ( " %s %d %s ", $l_offset, $l_marker1, $l_temp, $l_marker2 );
}
if ( $l_temp < ( $l_result_count / $l_posts_per_page ) )
{
printf ( " >> ", $l_result_count - $l_posts_per_page );
}
?>
(=$l_result_count?> posts, =$l_posts_per_page?> posts per page, =$l_total_pages?> pages in total)
|
if ( $l_recent_start > 0 )
{
$l_temp = $l_recent_start - $l_posts_per_page;
if ( $l_temp < 0 ) $l_temp = 0;
printf ( "[ < Prev ] ", $l_temp );
}
$l_pages = floor ( $l_result_count / $l_posts_per_page );
$l_temp = $l_recent_start + $l_posts_per_page;
if ( $l_temp <= ( $l_pages * $l_posts_per_page ) )
{
printf ( "[ Next > ] ", $l_temp );
}
?>
|
}
}
/*------------------------------------------------------------------------------------------------------*/
$l_base_url = "image_thread.html?l=1";
$p_aircraft_id = $_GET["p_aircraft_id"];
$p_user_id = $_GET["p_user_id"];
$offset = $_GET["offset"];
$l_recent_start = 0;
if (isset ($offset))
{
$l_recent_start = $offset;
}
if ( $p_aircraft_id > 0 )
{
$l_base_url = $l_base_url . "&p_aircraft_id=$p_aircraft_id";
}
if ( $p_user_id > 0 )
{
$l_base_url = $l_base_url . "&p_user_id=$p_user_id";
}
$l_connection = new mysqli($c_db_hostname, $c_db_username, $c_db_password, $c_db_database);
$l_sql = "select \"i\" type, i.id image_id, u.id user_id, u.username, i.comment, " .
" DATE_FORMAT(i.date_added, '%d %b %y %H:%i' ) as date_added, i.date_added date_order, a.name, m.name manufacturer_name ".
"from user_aircraft_images i, user_aircraft ua, aircraft a, " .
" user u, image_category ic, manufacturer m " .
"where ua.id = i.user_aircraft_id " .
"and a.id = ua.aircraft_id " .
"and u.id = ua.user_id " .
"and m.id = a.manufacturer_id " .
"and ic.id = i.image_category_id " .
"and i.status = 1 " .
"and u.id = $p_user_id " .
"and a.id = $p_aircraft_id " .
"union " .
"select \"c\" type, ic.user_aircraft_image_id image_id, ic.user_id, u.username, ic.comment, " .
" DATE_FORMAT(ic.date_added, '%d %b %y %H:%i' ) as date_added, ic.date_added date_order, a.name, m.name manufacturer_name " .
"from user_aircraft ua, aircraft a, user_aircraft_images uai, image_comment ic, manufacturer m, user u " .
"where a.id = $p_aircraft_id ".
"and ua.user_id = $p_user_id " .
"and ua.aircraft_id = a.id ".
"and ua.status = 1 " .
"and a.status = 1 " .
"and ic.status = 1 " .
"and uai.user_aircraft_id = ua.id " .
"and ic.user_aircraft_image_id = uai.id " .
"and m.id = a.manufacturer_id " .
"and u.id = ic.user_id " .
"order by date_order desc";
$l_result = $l_connection -> query ( $l_sql ) or
die ( "Unble to read thread." );
$l_result_count = $l_result -> num_rows;
$l_result -> data_seek ($l_recent_start);
$l_posts_per_page = 20;
$l_image_dir = "/user_aircraft_images";
?>
include "main_footer.php";
?>