1 ) { $authwhere = ""; $tmp = ""; $stcnt = 0; $state1 = 0; $state2 = 0; $state999 = 0; $stval = 0; if( $alphatags["state1"] == "state1" ) { $state1 = 1; $stcnt += 1; $stval = 1; } if( $alphatags["state2"] == "state2" ) { $state2 = 1; $stcnt += 1; $stval = 2; } if( $alphatags["state999"] == "state999" ) { $state999 = 1; $stcnt += 1; $stval = 999; } if( $stcnt == 0 ) { $authwhere .= "ff_state = 2 "; } else if( $stcnt == 1 ) { $authwhere .= "ff_state = $stval "; } else { $authwhere .= "ff_state in( "; $pfx = ""; if( $state1 ) { $authwhere .= $pfx . "1"; $pfx = ", "; } if( $state2 ) { $authwhere .= $pfx . "2"; $pfx = ", "; } if( $state999 ) { $authwhere .= $pfx . "999"; $pfx = ", "; } $authwhere .= ") "; } $val = 0; if( $alphatags["visible"] == "visible" ) { $val += 1; } if( $alphatags["invisible"] == "invisible" ) { $val += 2; } if( $val == 2 ) { $authwhere .= "and ff_public = 0"; } else if( $val != 3 ) { $authwhere .= "and ff_public = 1"; } } // echo "WHERE=$authwhere\n"; if( $picid == 0 ) { var_int( "R", "off", $offset, -1, 999999 ); if( var_int( "R", "fromoff", $fromoffset, 0, 999999 ) ) { $qry = "select " . pgts2str( "f.ff_disp_date", "ff_disp_date" ) . " " . "from fotolib_foto f where ff_id = \$1"; $qryval = array( 1 => $fromoffset ); $date = sql_quick_fetch( $conn, $qry, $qryval ); if( $date ) { $qry = "select " . "count(*) as cnt " . "from " . "fotolib_foto f " . "where " . $authwhere . $tagwhere . "and ff_disp_date < " . str2pgts( "\$1" ); $qryval = array( 1 => $date ); $newoff = sql_quick_fetch( $conn, $qry, $qryval ); if( $newoff ) { $offset = $newoff; } } } else if( $offset < 0 ) { $offset = 0; $qry = "select " . "count(*) as cnt " . "from " . "fotolib_foto f " . "where " . // "ff_public = 1 " . $authwhere . $tagwhere; $newoff = sql_quick_fetch( $conn, $qry ); if( $newoff ) { $offset = $newoff - 1; } } $sqloff = $offset - $lrcnt; $limit = 2 * $lrcnt + 2; if( $sqloff < 0 ) { $sqloff = 0; $limit = $offset + 2 + $lrcnt; } } $sql = "select " . "f.ff_id, " . pgts2str( "f.ff_disp_date", "ff_disp_date" ) . ", " . "ff_exif_latitude, ff_exif_longitude, " . "f.ff_comment " . "from " . "fotolib_foto f " . "where " . // "f.ff_state = " . FFS_ACTIVE . " and " . // "f.ff_public = 1 " . $authwhere . $tagwhere . "order by " . "f.ff_disp_date " . "limit $limit offset $sqloff"; // +++ hmm authwhere contains ff_public? // logstr( $sql ); $ress = pg_query( $conn, $sql ); // logstr( "pg_query returned" ); if( !$ress ) { return; } $row = pg_fetch_array( $ress, NULL, PGSQL_ASSOC ); // logstr( "pg_fetch_array returned" ); if( !$row ) { return; } if( $offset > 1 ) { $n = $offset - 1; $urlRight = "$baseUrl/$url&off=$n"; } if( $picid == 0 ) { echo "\n"; if( $sqloff > 0 ) { $n = $sqloff - $lrcnt - 1; if( $n < 0 ) $n = 0; $urlDown = "$baseUrl/$url&off=$n"; echo ""; } $currow = null; $lastrow = null; while( $row && $limit > 1 ) { $limit--; $row["sqloff"] = $sqloff; $lastrow = $row; $lnkb = ""; $lnke = ""; $bgc = ""; if( $sqloff == $offset ) { $currow = $row; $lnkb = " "; $lnke = " "; $bgc = " bgcolor=\"blue\""; } $id = $row["ff_id"]; if( 0 ) { echo "$lnkb$lnke\n"; } else { echo "$lnkb$lnke\n"; } $row = pg_fetch_array( $ress, NULL, PGSQL_ASSOC ); $sqloff++; } if( $row ) { $n = $sqloff + $lrcnt; $urlUp = "$baseUrl/$url&off=$n"; echo ""; } echo "
"; echo "prev"; echo "
"; echo "first"; echo "
"; echo "next"; echo "
"; echo "last"; echo "
\n"; if( $currow != null ) { $row = $currow; } else { $row = $lastrow; } } if( $sqloff > $offset ) { $n = $offset + 1; $urlLeft = "$baseUrl/$url&off=$n"; } $id = $row["ff_id"]; $date = $row["ff_disp_date"]; $exiflat = $row["ff_exif_latitude"]; $exiflong = $row["ff_exif_longitude"]; $comment = $row["ff_comment"]; $size = "sm"; // $size = "ti"; $linksize = "sm"; if( 0 ) { echo "\n"; } else { // echo "\n"; // echo ""; echo ""; // echo "\n"; } echo "

Date: $date

\n"; if( $exiflat != "" && $exiflong != "" ) { $mapurl = maps_url( $exif_latitude, $exif_longitude ); echo "

Coordinates: $exiflat / $exiflong

\n"; } if( $comment ) { echo "

Comment: " . markup2html( $comment, true ) . "

\n"; } $sql = "select " . "t.ft_id, " . "t.ft_kind, " . "t.ft_name, " . "t.ft_descr " . "from " . "fotolib_tag t, " . "fotolib_foto_tag f " . "where " . "t.ft_id = f.ft_id and " . "f.ff_id = $id " . "order by " . "t.ft_name, " . "t.ft_descr"; $ress = pg_query( $conn, $sql ); if( !$ress ) { echo "

no cursor

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

no row

\n"; return; } echo "

Tags:\n"; $pfx = ""; while( $row ) { $tid = $row["ft_id"]; $kind = $row["ft_kind"]; $name = $row["ft_name"]; $descr = htmlentities( $row["ft_descr"] ); $url = "index.phtml?cmd=show&tag=$tid&fromoff=$id"; echo "$pfx$name"; $row = pg_fetch_array( $ress, NULL, PGSQL_ASSOC ); $pfx = ",\n"; } echo "

\n"; if( $authlevel > 0 ) { echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; } $urlRight = str_replace( "&", "&", $urlRight ); $urlLeft = str_replace( "&", "&", $urlLeft ); $urlDown = str_replace( "&", "&", $urlDown ); $urlUp = str_replace( "&", "&", $urlUp ); echo "\n"; } function search( $conn, $authenticated, $authlevel ) { global $FTK_NAMES; global $FTK_ORDER; ?> \n"; echo "\n"; echo "\n"; echo "\n"; echo "
\n"; echo "\n"; if( $authlevel > 1 ) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; } tags_read_all( $conn, $tags ); foreach( $FTK_ORDER as $kind ) { if( isset( $tags[$kind] ) ) { echo "\n"; foreach( $tags[$kind] as $tag ) { list( $ftid, $name, $descr, $bsel ) = $tag; $name = htmlentities($name); if( $descr != "" ) { $descr = ": " . htmlentities($descr); } $url = "index.phtml?cmd=show&tag=$ftid"; echo "\n"; } } } echo ""; echo "
State
 " . "State Incoming
 " . "State Active
 " . "State Special
Visibility
 " . "Visible
 " . "Invisible
" . htmlentities($FTK_NAMES[$kind]) . "
 " . "" . htmlentities($name) . "$descr (" . "first)
"; echo "\n"; echo "
\n"; echo "
\n"; } ?>