f
f
f
f
f
f
f
f
include "includes/getvars.php"; //Open DB $link = @mysql_connect($db_server, $db_user, $db_pass) or die("Couldn't connect to database server"); mysql_select_db($db_name) or die("Couldn't select database"); //get configuration variables $query = "SELECT * FROM $configtable"; $result = mysql_query($query, $link) or die("Query failed: ".mysql_error()); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { define ($line[c_key],$line[c_value]);} //main variables if ($en['galid']!='') $galid = $en['galid']; if ($en['galreq']!='') $galreq = $en['galreq']; if ($en['galoffs']!='') $galoffs = $en['galoffs']; if ($galreq=='') $galreq = 'view'; if ($galoffs=='') $galoffs = 1; //get all galleries $query = "SELECT * FROM $galstable"; $result = mysql_query($query, $link) or die("Query failed: ".mysql_error()); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { if ($galid=='') $galid = $line[ID]; $gal[$line[ID]] = $line;} $gcount = mysql_num_rows($result); if ($en['galreq']=='picalone') { //VIEW PICTURE ALONE //increase view count for the picture $query = "UPDATE $picstable SET times_viewed=times_viewed+1 WHERE picID='$galid'"; $result = mysql_query($query, $link) or die("Query failed: ".mysql_error()); //get picture info $query = "SELECT * FROM $picstable WHERE picID='$galid'"; $result = mysql_query($query, $link) or die("Query failed: ".mysql_error()); $pic = mysql_fetch_array($result, MYSQL_ASSOC); $gal_n = substr($galid,0,strpos($galid,'_')); //gallery number $pic_n = substr($galid,strpos($galid,'_')+1,strlen($galid)); //picture number //get gallery data $query = "SELECT * FROM $galstable WHERE ID=$gal_n"; $result = mysql_query($query, $link) or die("Query failed: ".mysql_error()); $gal = mysql_fetch_array($result, MYSQL_ASSOC); $href = $gal[pics_www_dir].$pic[file_name]; header("Location: $href"); //redirect to picture } if ($en['submit']!='') { //PROCESS COMMENTS $loc = "Location: index.php?galreq=pic&galid={$en['galid']}"; $en[comment] = strip_tags($en[comment], '
'); if (str_replace(' ','',$en['user']) == '') header($loc); //stop if name is blank //remove http:// from homepage URL $en[www] = str_replace("http://", "", strtolower($en[www])); // fix DOS newlines $en[comment] = str_replace("\r\n", "\n", $en[comment]); // fix Mac newlines $en[comment] = str_replace("\r", "\n", $en[comment]); // replace newlines with
's $en[comment] = str_replace("\n","
",$en[comment]); foreach($en as $key => $value) { if ($key == comment) continue; $en[$key] = strip_tags($value); } //$gal_id = substr($en['galsid'],0,strpos($en['galid'],'_')); $query = "INSERT INTO $commtable VALUES ('{$en['galid']}','{$en['user']}','{$en['email']}','{$en['www']}','{$en['comment']}','$ip','$time','$date')"; $result = mysql_query($query, $link) or die("Query failed: ".mysql_error()); header($loc); //redirect back to picture page } //page head echo "
"; echo "
".constant('site_name')."
"; //drop down list to choose galleries ?> echo "
Beschikbare albums ($gcount):
"; foreach ($gal as $value) { echo "
$value[name]
"; } echo "
"; if ($gcount == 0) {die ("Geen albums beschikbaar");} //page contents if ($galreq=='view') { //VIEW GALLERY $query = "SELECT * FROM $picstable WHERE galleryID=$galid"; $result = mysql_query($query, $link) or die("Query failed: ".mysql_error()); $picc = mysql_num_rows($result); $pc = 0; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { $pc++; $pics[$pc] = $line; } echo "Huidige album:
".$gal[$galid][name]."
Aantal foto's: $picc
"; echo "
"; $perpage = constant('max_thumbnail_rows') * constant('max_thumbs_per_row'); $pages = round($picc / $perpage); $pg = 0; for ($k=1;$k<=$pages+1;$k++) { $n1 = ($k-1)*$perpage+1; $n2 = ($k)*$perpage; if ($n2 > $picc) $n2 = $picc; if ($galoffs == $n1) {$lnk = '
'; $lnk_c = '
';} else {$lnk = "
"; $lnk_c = '
';} if ($n1<=$picc) {$href .= ' '.$lnk.$n1.'-'.$n2.$lnk_c; $pg++;} } $href = "$pg pagina(s) ... $href"; echo $href; $p = $galoffs-1; for ($y=1;$y<=constant('max_thumbnail_rows');$y++) { echo "
"; for ($x=1;$x<=constant('max_thumbs_per_row');$x++) { $p++; $query = "SELECT * FROM $commtable WHERE picID='{$pics[$p][picID]}'"; $res = mysql_query($query, $link) or die("Query failed: ".mysql_error()); $commc = mysql_num_rows($res); echo "
{$pics[$p][file_name]}
{$pics[$p][short_descr]}
"; if ($p >= $picc) break; } echo "
"; if ($p >= $picc) break; } echo "
"; echo $href; echo "
{$gal[$galid][descr]}
"; } if ($galreq=='pic') { //VIEW PICTURE //increase view count for the picture $query = "UPDATE $picstable SET times_viewed=times_viewed+1 WHERE picID='$galid'"; $result = mysql_query($query, $link) or die("Query failed: ".mysql_error()); //get picture info $query = "SELECT * FROM $picstable WHERE picID='$galid'"; $result = mysql_query($query, $link) or die("Query failed: ".mysql_error()); $pic = mysql_fetch_array($result, MYSQL_ASSOC); $gal_n = substr($galid,0,strpos($galid,'_')); //gallery number $pic_n = substr($galid,strpos($galid,'_')+1,strlen($galid)); //picture number $perpage = constant('max_thumbnail_rows') * constant('max_thumbs_per_row'); //check whether next/previous images are available $nn = $pic_n+1; $pn = $pic_n-1; $query = "SELECT * FROM $picstable WHERE galleryID=$gal_n"; $result = mysql_query($query, $link) or die("Query failed: ".mysql_error()); $c = 0; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { $c++; $tmp[$c] = $line; if ($line[picID] == $galid) $nm = $c; //$nm - picture index in gallery } $isnext = ($nm < mysql_num_rows($result)); $nextp = $tmp[$nm+1]; $isprev = ($nm > 1); $prevp = $tmp[$nm-1]; $pn = floor(($nm-1)/$perpage); //get page number in gallery $offs = ($pn*$perpage)+1; //page offset //get gallery data $query = "SELECT * FROM $galstable WHERE ID=$gal_n"; $result = mysql_query($query, $link) or die("Query failed: ".mysql_error()); $gal = mysql_fetch_array($result, MYSQL_ASSOC); $href = '
'. ($isprev ? "
:: " : ''). "
$gal[name]
". ($isnext ? " ::
" : ''). '
'; //display the pic... echo "
$gal[name]
> $pic[short_descr]
"; echo "$href
".($isnext ? "
" : '')."
".($isnext ? "
" : '')."
$href"; if ($pic[long_descr]!='') echo "
Omschrijving: $pic[long_descr]
"; if ($commc > 0) { while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "
".($line[email] == '' ? $line[name] : "
$line[name]
")." ".($line[www]==''?'':"
[www]
")." @ $line[date], $line[time]
"; } } ?> } echo ""; include("/var/www/lughnalynn/bottom.php"); ?>