include "main_header.php";
include "includes/utils.php";
function get_base_url_size ( $a_size )
{
global $p_user_id;
global $p_aircraft_id;
global $p_image_category;
$l_base_url = "image_browser.html?p_image_size=$a_size";
if ( $p_image_category > 0 )
{
$l_base_url = $l_base_url . "&p_image_category=$p_image_category";
}
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";
}
return $l_base_url;
}
function get_base_url_category ( $a_category )
{
global $p_user_id;
global $p_aircraft_id;
global $p_image_size;
$l_base_url = "image_browser.html?p_image_category=$a_category";
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";
}
if ( $p_image_size > 0 )
{
$l_base_url = $l_base_url . "&p_image_size=$p_image_size";
}
return $l_base_url;
}
function display_browse_bar ()
{
global $l_result;
global $l_base_url;
global $l_images_per_page;
global $l_result_count;
global $l_recent_start;
$l_start_page = 1;
$l_total_pages = floor ( $l_result_count / $l_images_per_page ) + 1;
$l_current_page = floor ( $l_recent_start / $l_images_per_page ) + 1;
if ( $l_result_count > 0 )
{
?>
| Page (=$l_total_pages?> in total) :
//
// 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_images_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_images_per_page ) )
{
printf ( " >> ", $l_result_count - $l_images_per_page );
}
?>
|
if ( $l_recent_start > 0 )
{
$l_temp = $l_recent_start - $l_images_per_page;
if ( $l_temp < 0 ) $l_temp = 0;
printf ( "[ < Prev ] ", $l_temp );
}
$l_pages = floor ( $l_result_count / $l_images_per_page );
$l_temp = $l_recent_start + $l_images_per_page;
if ( $l_temp <= ( $l_pages * $l_images_per_page ) )
{
printf ( "[ Next > ] ", $l_temp );
}
?>
|
}
}
function display_browse_column ( $a_column_size, $a_image_size )
{
global $l_result;
global $l_base_url;
global $l_images_per_page;
global $offset;
$l_image_dir = "user_aircraft_thumb100";
if ( $a_image_size == 1 )
{
$l_image_dir = "user_aircraft_thumb600";
}
?>
| Hangar |
Aircraft |
Category |
Date |
Preview |
$l_counter = 0;
$l_column_count = 0;
while ( ( $l_column_count < $a_column_size ) && ( $l_row = $l_result -> fetch_array(MYSQLI_ASSOC) ) )
{
$l_aircraft_id = $l_row [ 'aircraft_id' ];
$l_aircraft_model = $l_row [ 'name' ];
$l_manufacturer_name = $l_row [ 'manufacturer_name' ];
$l_user_id = $l_row [ 'user_id' ];
$l_username = $l_row [ 'user_name' ];
$l_date_added = $l_row [ 'date_added' ];
$l_image_id = $l_row [ 'id' ];
$l_image_category = $l_row [ 'image_category' ];
$l_image_comment = $l_row [ 'comment' ];
$l_image_view_count = $l_row [ 'view_count' ];
$l_image_comment = clickable_link ( $l_image_comment );
if ( $l_counter == 0 ) { $l_bgcolor = "dialog1"; $l_counter = 1; }
else { $l_bgcolor = "dialog2"; $l_counter = 0; }
echo ( "| $l_username | " );
//echo ( "
| $l_username | " );
echo ( "$l_manufacturer_name $l_aircraft_model | $l_image_category | " );
echo ( "$l_date_added | " );
echo ( "" );
echo ( " |
" );
echo ( "| Views : $l_image_view_count |
" );
echo ( "| $l_image_comment |
\n" );
$l_column_count = $l_column_count + 1;
}
?>
}
?>
Browse Images
$p_image_size = $_GET["p_image_size"];
$p_aircraft_id = $_GET["p_aircraft_id"];
$p_user_id = $_GET["p_user_id"];
$offset = $_GET["offset"];
$l_connection = new mysqli($c_db_hostname, $c_db_username, $c_db_password, $c_db_database) or
die ( "Unable to connect to database." );
if ( $p_image_size == 1 )
{
$l_images_per_page = 4;
}
else
{
$l_images_per_page = 12;
}
$l_base_url = "image_browser.html?l=1";
$l_recent_start = 0;
if (isset ($_GET["offset"]))
{
$l_recent_start = $_GET["offset"];
}
$p_search_params = "";
if ( $p_image_category > 0 )
{
$p_search_params = "and i.image_category_id = $p_image_category ";
$l_base_url = $l_base_url . "&p_image_category=$p_image_category";
}
if ( $p_aircraft_id > 0 )
{
$p_search_params = $p_search_params . " and a.id = $p_aircraft_id ";
$l_base_url = $l_base_url . "&p_aircraft_id=$p_aircraft_id";
}
if ( $p_user_id > 0 )
{
$p_search_params = $p_search_params . " and u.id = $p_user_id ";
$l_base_url = $l_base_url . "&p_user_id=$p_user_id";
}
if ( $p_image_size > 0 )
{
$l_base_url = $l_base_url . "&p_image_size=$p_image_size";
}
$l_sql = "select i.id, a.id aircraft_id, a.name name, u.id user_id, u.username user_name, " .
" DATE_FORMAT(i.date_added, '$c_app_format_datetime' ) date_added, " .
" ic.name image_category, i.comment, m.name manufacturer_name, i.view_count ".
"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 " .
"$p_search_params" .
"and i.status = 1 " .
"order by i.date_added desc ";
$l_result = $l_connection -> query ( $l_sql ) or
die ( "Unble to read latest additions." );
$l_result_count = $l_result -> num_rows;
if (( $l_result_count > 0 ) && ( $l_recent_start < $l_result_count))
{
$l_result -> data_seek ( $l_recent_start );
}
?>
|
=$c_app_name?> Image Browser
( Small / Large )
|
Show :
All |
Parked |
Flying |
Build |
Aerial |
Reference
|
display_browse_bar ();
?>
| display_browse_column ( floor ( $l_images_per_page / 2 ), $p_image_size ); ?> |
display_browse_column ( floor ( $l_images_per_page / 2 ), $p_image_size ); ?> |
display_browse_bar ();
?>
include "main_footer.php";
?>