database query error.

\n"; return; } $row = pg_fetch_array( $ress, NULL, PGSQL_ASSOC ); if( !$row ) { echo "

no incoming images found.

\n"; return; } $img = "index.phtml?cmd=img_in&id=$id&sz=TH"; echo "\n"; // echo "\n"; $i = $sqloffset; while( $row && $limit > 1 ) { $limit--; if( $i == $offset ) { $currow = $row; } $id = $row["ff_id"]; $img = "index.phtml?cmd=img_in&id=$id&sz=TH"; $url = "index.phtml?cmd=incoming&off=$i"; //echo " "; //echo ""; if( $i == $offset ) { echo ""; } else { echo ""; } $row = pg_fetch_array( $ress, NULL, PGSQL_ASSOC ); $i++; } if( $row ) { $i += $lrcnt; echo ""; } echo "
"; echo "
"; if( $sqloffset > 0 ) { $i = $sqloffset - $lrcnt; if( $i < 0 ) { $i = 0; } echo ""; } $currow = null; //echo "
"; echo "prev"; echo "
"; echo "first"; echo "
" . "" . "  "; echo "next"; echo "
"; echo "last"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; if( $currow != null ) { $row = $currow; } foto_show_editform( $conn, $row ); } function foto_edit( $conn ) { if( !var_int( "R", "id", $id, 1, 999999 ) ) { echo "

invalid id.

\n"; return; } $sql = "select " . "ff_id, ff_state, ff_public, ff_camera, ff_orig_name, " . "ff_filename, ff_hash, " . "ff_timv_width, ff_timv_height, ff_timv_mtime, " . "ff_timv_angle, ff_timv_flip, " . pgts2str( "ff_exif_date" ) . ", ff_date_offset, " . pgts2str( "ff_real_date" ) . ", " . pgts2str( "ff_disp_date" ) . ", ff_comment " . "from " . "fotolib_foto " . "where " . "ff_id = $id"; $ress = pg_query( $conn, $sql ); if( !$ress ) { echo "

database query error.

\n"; return; } $row = pg_fetch_array( $ress, NULL, PGSQL_ASSOC ); if( !$row ) { echo "

no incoming images found.

\n"; return; } $url = "index.phtml?cmd=img_any&id=$id&sz=ti"; echo "

\n"; foto_show_editform( $conn, $row, $id ); } function foto_show_editform( $conn, $row, $ff_id=0 ) { global $FTK_NAMES; global $FTK_ORDER; $id = $row["ff_id"]; $state = $row["ff_state"]; $public = $row["ff_public"]; $camera = $row["ff_camera"]; $orig_name = $row["ff_orig_name"]; $filename = $row["ff_filename"]; $hash = $row["ff_hash"]; $timv_width = $row["ff_timv_width"]; $timv_height = $row["ff_timv_height"]; $timv_mtime = $row["ff_timv_mtime"]; $timv_angle = $row["ff_timv_angle"]; $timv_flip = $row["ff_timv_flip"]; $exif_latitude = $row["ff_exif_latitude"]; $exif_longitude = $row["ff_exif_longitude"]; $exif_date = $row["ff_exif_date"]; $date_offset = $row["ff_date_offset"]; $real_date = $row["ff_real_date"]; $disp_date = $row["ff_disp_date"]; $comment = htmlentities( $row["ff_comment"] ); $sel = array( 0 => "", 1 => "", 2 => "", 3 => "", 4 => "", 5 => "", 6 => "", 7 => "" ); $txtangle = "Rotation"; $txtflip = "Flip"; if( $timv_angle >= 0 and $timv_angle <= 3 ) { $sel[$timv_angle] = "checked=\"checked\" "; } else { $sel[0] = "checked=\"checked\" "; $txtangle = "" . $txtangle . ""; } if( $timv_flip >= 0 and $timv_flip <= 3 ) { $sel[$timv_flip+4] = "checked=\"checked\" "; } else { $sel[4] = "checked=\"checked\" "; $txtflip = "" . $txtflip . ""; } echo "
\n"; echo "\n"; echo "\n"; echo "

"; echo "$txtangle: "; echo "none  \n"; echo "left  \n"; echo "180  \n"; echo "right  \n"; echo "   $txtflip: "; echo "none  \n"; echo "X  \n"; echo "Y  \n"; echo "both  \n"; echo ""; echo "

\n"; echo "
\n"; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $checked = ""; if( $public != 0 ) { $checked = " checked=\"1\""; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $mapurl = maps_url( $exif_latitude, $exif_longitude ); echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $dateid = tags_read_all( $conn, $tags, $real_date, $ff_id ); echo "\n"; $radio_kinds = array( FTK_CITY => "ct", FTK_DATE => "dt" ); $seltags = array(); if( !isset( $_SESSION["seltags"] ) ) { $_SESSION["seltags"] = array(); } if( $ff_id == 0 ) { $seltags = $_SESSION["seltags"]; $seltags["dt"] = $dateid; } foreach( $FTK_ORDER as $kind ) { if( isset( $tags[$kind] ) ) { echo "\n"; foreach( $tags[$kind] as $tag ) { list( $ftid, $name, $descr, $bsel ) = $tag; // $descr .= " bsel=" . $bsel; $t = "checkbox"; $n = "t$ftid"; $sel = ""; if( $descr != "" ) { $descr = ": " . htmlentities($descr); } if( isset( $radio_kinds[$kind] ) ) { $t = "radio"; $n = $radio_kinds[$kind]; if( isset( $seltags[$n] ) && $seltags[$n] == $ftid ) { $bsel = true; } // $descr .= " (" . $n . "=" . $ftid . ":" . $seltags[$n] . ") " . $sel; } else if( isset( $seltags[$ftid] ) ) { $bsel = true; } if( $bsel ) { $sel = "checked=\"checked\" "; } if( isset( $radio_kinds[$kind] ) ) { echo "\n"; } else { $nw = $n . "Wrap"; $wsel = ""; if( $sel != "" ) { $wsel = " wrapChecked"; } echo "\n"; } } } } echo "\n"; echo "
ID: $id
state: $state
public:
camera: $camera
orig_name: $orig_name
filename: $filename
hash: $hash
timv_width: $timv_width
timv_height: $timv_height
timv_mtime: $timv_mtime
timv_angle: $timv_angle
timv_flip: $timv_flip
exif_coords: $exif_latitude / $exif_longitude
exif_date: $exif_date
date_offset: $date_offset
real_date: $real_date
disp_date: $disp_date
comment: \n"; echo "\n"; echo "\n"; echo "\n"; echo "
 

[url=URL]...[/url]
[pl=PICNR]...[/pl]
[bc=COLOR]...[/bc]

tags:" . "clear all" . "
" . htmlentities($FTK_NAMES[$kind]) . "" . " clear" . "
 " . "" . htmlentities($name) . "$descr
 " . "" . "" . "$descr
 
\n"; echo "
\n"; ?> invalid 'id'

\n"; return; } $public = 0; var_int( "P", "public", $public, 1, 1 ); // date_offset if( !var_string( "P", "comment", $comment, 0, 2000 ) ) { page_header( $authenticated, $authlevel ); echo "

invalid 'public'

\n"; return; } if( !var_int( "P", "dt", $datetag, 1, 999999 ) ) { page_header( $authenticated, $authlevel ); echo "

invalid 'datetag'

\n"; return; } if( !var_int( "P", "ct", $citytag, 1, 999999 ) ) { page_header( $authenticated, $authlevel ); echo "

invalid 'citytag'

\n"; return; } $tags = array(); $tags["dt"] = $datetag; $tags["ct"] = $citytag; foreach( $_POST as $k => $v ) { /* if( preg_match( "/^t[0-9]+\$/", $k ) && preg_match( "/^[1-9][0-9]*\$/", $v ) ) */ if( preg_match( "/^t[0-9]+\$/", $k ) && $k == ("t" . $v) ) { $tags[$v] = $v; } } pg_query( $conn, "begin" ); $sql = "update " . "fotolib_foto " . "set " . "ff_state = \$2, " . "ff_public = \$3, " . "ff_comment = \$4 " . "where " . "ff_id = \$1"; $values = array( 1 => $id, 2 => FFS_ACTIVE, 3 => $public, 4 => $comment ); pg_query_params( $conn, $sql, $values ); $sql = "delete from fotolib_foto_tag where ff_id = \$1"; $values = array( 1 => $id ); pg_query_params( $conn, $sql, $values ); $sql = "insert into fotolib_foto_tag ( " . "ff_id, ft_id, fft_timestamp " . ") values ( " . "\$1, \$2, current_timestamp " . ")"; $values = array( 1 => $id, 2 => 0 ); foreach( $tags as $t => $tag ) { $values[2] = $tag; pg_query_params( $conn, $sql, $values ); } pg_query( $conn, "commit" ); $_SESSION["seltags"] = $tags; if( var_string( "S", "HTTP_REFERER", $url ) ) { // header( "303 See Other HTTP/1.1", true, 303 ); header( "Location: $url" ); } } function foto_rot( $conn, $authenticated, $authlevel ) { global $G_CFG_DIR_LIB; // echo "

foto_rot

\n"; if( !var_int( "P", "id", $id, 1, 999999 ) ) { page_header( $authenticated, $authlevel ); echo "

invalid 'id'

\n"; return; } if( !var_int( "P", "angle", $angle, 0, 3 ) ) { page_header( $authenticated, $authlevel ); echo "

invalid 'angle'

\n"; return; } if( !var_int( "P", "flip", $flip, 0, 3 ) ) { page_header( $authenticated, $authlevel ); echo "

invalid 'flip'

\n"; return; } $sql = "select " . "ff_id, ff_timv_angle, ff_timv_flip, ff_filename " . "from " . "fotolib_foto " . "where " . "ff_id = \$1"; $values = array( 1 => $id ); $row = sql_quick_fetch( $conn, $sql, $values, null ); if( $row === null ) { // echo "

id not found on the DB

\n"; return; } if( $row[1] != $angle || $row[2] != $flip ) { pg_query( $conn, "begin" ); $sql = "update " . "fotolib_foto " . "set " . "ff_timv_angle = \$2, " . "ff_timv_flip = \$3 " . "where " . "ff_id = \$1"; $values = array( 1 => $id, 2 => $angle, 3 => $flip ); pg_query_params( $conn, $sql, $values ); $filename = $G_CFG_DIR_LIB . "/" . $row[3]; // echo "

file - $filename -

\n"; if( gfx_scale( $filename, $filename, $angle*90 ) ) { pg_query( $conn, "commit" ); // echo "

commit

\n"; } else { pg_query( $conn, "rollback" ); // echo "

rollback

\n"; } } $_SESSION["seltags"] = $tags; if( var_string( "S", "HTTP_REFERER", $url ) ) { header( "Location: $url" ); } } ?>