Travel Photography: 2001-
ini_set ( "display_errors", "1" );
error_reporting ( E_ALL ^ E_NOTICE );
function escape_space ( $input ) {
return str_replace ( " ","%20", $input);
}
function escape_slash ( $input ) {
return str_replace ( "'", "%5C'", $input);
}
$connection_string = "dbname=joe user=joe host=localhost password='spork22'";
$header=$_GET['header'];
$title="locations";
$width_limit=$_GET['width']; // number of images across
$limit=$_GET['limit'];
if ( $width_limit == "" ) $width_limit = 2;
$connection = pg_pconnect($connection_string);
$locations_sql="SELECT * FROM locations where priority = 1 ORDER BY name DESC";
if ( $limit != "" ) $locations_sql .= " limit $limit";
$locations_result = pg_exec( $locations_sql );
?>
$align="left";
$width_count=0;
$num_of_results = pg_numrows($locations_result) - 1;
for ($lt = $num_of_results ; $lt >= 0; $lt--) {
$location = rtrim (pg_result ( $locations_result, $lt, 0 ) );
$location_description = pg_result ( $locations_result, $lt, 1 );
$good_pics = pg_exec ( "SELECT * FROM images WHERE location='".addslashes($location)."' AND use_for_main='t'" );
$row_max = pg_numrows ( $good_pics );
$row = rand ( 0, $row_max - 1 );
if ( $row_max == 0 ) continue;
$id = pg_result($good_pics, $row, 0);
$caption = pg_result($good_pics, $row, 1);
$description = pg_result($good_pics, $row, 2);
$country = rtrim(pg_result($good_pics, $row, 3));
$spec_loc = rtrim(pg_result($good_pics, $row, 4));
$date = pg_result($good_pics, $row, 5);
$photographer = pg_result($good_pics, $row, 6);
$use_for_main = pg_result($good_pics, $row, 7);
$quality = pg_result($good_pics, $row, 8);
$fileext = pg_result($good_pics, $row, 9);
$file_loc=escape_slash ( escape_space ( "https://xenotropic.net/images/{$country}/{$spec_loc}{$id}_med.{$fileext}" ) );
$med_width = pg_result($good_pics, $row, 12);
$med_height = pg_result($good_pics, $row, 13);
if ( $width_count == $width_limit ) {
echo " \n";
$width_count = 1;
} else { $width_count ++; }
if ( $med_width < 300 ) {
echo "\n";
// $width_count = $width_limit;
} else {
echo " | \n";
}
echo "\n \n";
echo " $location: $location_description ";
}
?>
|