/*
* Copyright (C) 2000 Christophe Thibault
* Rating system added by sIX / aEGIS
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
if ($lang=="fr")include "config.fr.inc.php";
else include "config.inc.php";
include "move.inc.php"; // blob add-on
//BLOB
$SELF="index.php";
//error_reporting(E_NONE);
if($thumb_generator=="convert") {
// @exec("which convert", $my_convert_path);
$my_convert_tmp = "/public/httpd/tmp/"; // aim is to bypass safe mode restriction
$my_bindir = "/public/httpd/bin/";
$my_convert_path = $my_bindir."convert";
if($my_convert_path=="") die("install convert (see manual) or use 'GD' or 'manual' as thumb generator");
}
function replaceln($str) {
global $root_dir;
$rd=realpath($root_dir);
// echo $rd."\n \n";
$r=realpath($rd.'/'.stripslashes($str));
// echo $r."\n \n";
$ret=substr($r,strlen($rd)+1,strlen($r)-1-strlen($rd));
//if(is_link($root_dir.$str)) $r=dirname($str)."/".readlink($root_dir.$str);
//else $r=$str;
//$ret=realpath($r);
// echo $ret."\n\n"; exit();
return $ret;
}
// le code suivant a �t� boug� ici pour �tre s�r k'il soit bien trait� avant toute autre chose.
/*
echo "display=".$display." ";
echo "displaypic=".$displaypic." ";
echo "preview=".$preview." ";
echo "dir=".$dir." ";
//*/
if($display) $display=reformat(replaceln($display));
if($displaypic) $displaypic=reformat(replaceln($displaypic));
if($preview) $preview=reformat(replaceln($preview));
if($display) $dir=dirname($display);
if($dir) $dir=reformat(replaceln($dir));
/*
echo "display=".$display." ";
echo "displaypic=".$displaypic." ";
echo "preview=".$preview." ";
echo "dir=".$dir." ";
//*/
if(substr($root_dir,-1)!='/') $root_dir.='/';
if($dir && substr($dir,-1)!='/') $dir.='/';
//echo "dir=$dir root_dir=$root_dir ";
// /le code
function set_cookie_val($val)
{
global $cookiesite;
setcookie("LoginValue",$val,time()+(3600*24*365*3),"/");
}
function make_href($string) {
$ret="";
$ll=explode("\n",$string);
foreach($ll as $l) {
$wl=explode(" ",$l);
foreach($wl as $w) {
if(strstr($w,"http://")||
strstr($w,"ftp://")||
strstr($w,"telnet://")) {
$ret.=''.htmlentities($w).' ';
} else {
$ret.=htmlentities($w).' ';
}
}
$ret.="\n";
}
return $ret;
}
function get_comment($nom)
{
global $admin;
global $sDB,$nConnection,$sTable;
$cmd="select * from $sTable where name='".addslashes($nom)."'";
$res=mysql_db_query($sDB,$cmd,$nConnection);
$row=mysql_fetch_array($res);
$temp=explode("::",$row["descr"]);
if($admin==0)
return trim(nl2br(htmlentities($temp[0])));
$ret="";
foreach($temp as $v) {
if($ret!="")
$ret.="".trim($v)." ";
else
$ret.=$v;
}
return $ret;
}
function get_rating($nom)
{
global $sDB,$nConnection,$sTableRatings;
$cmd="select avg(rating), count(*) from $sTableRatings where pic_name='".addslashes($nom)."'";
$res=mysql_db_query($sDB,$cmd,$nConnection);
$row=mysql_fetch_array($res);
return ($row[1]?$row[0]:false);
}
function already_rated($nom)
{
global $sDB,$nConnection,$sTableRatings;
$cmd="select * from $sTableRatings where pic_name='".addslashes($nom)."' and ip='".getenv("REMOTE_ADDR")."'";
$res=mysql_db_query($sDB,$cmd,$nConnection);
$row=mysql_fetch_array($res);
return($row);
}
function get_level_db($nom)
{
return 0; /*
global $sDB,$nConnection,$sTable;
$cmd="select * from $sTable where name='".addslashes($nom)."'";
$res=mysql_db_query($sDB,$cmd,$nConnection);
$row=mysql_fetch_array($res);
return (int)$row["seclevel"];
*/
}
function get_level($pic) {
if(!strstr($pic,"/")) return (int)get_level_db($pic);
$l=get_level_db($pic);
if($l!=0) return (int)$l;
$l2=get_level_db($pic."/");
if($l2!=0) return (int)$l2;
return (int)(get_level(substr($pic,0,strrpos($pic,"/"))));
}
function reformat($s)
{
if($s) $s=StripSlashes($s);
if(!strstr($s,"..")) { } else $s=""; // ANTI HACK :)
return($s);
}
// sound/video/text functions
function get_movie_type($doc)
{
if (eregi("mov$", $doc)) {
return "video/quicktime";
}
if (eregi("avi$", $doc)) {
return "video/x-msvideo";
}
else if (eregi("mpe?g$", $doc)) {
return "video/mpeg";
}
return 0;
}
function get_sound_type($doc)
{
if (eregi("wav$", $doc)) {
return "audio/x-wav";
}
else if (eregi("mp3$", $doc)) {
return "audio/mp3";
}
return 0;
}
function get_text_type($doc)
{
if (eregi("txt$", $doc)) {
return "text/plain";
}
return 0;
}
// image convertion functions
function wait_convert_proc()
{
global $sem,$use_sem;
register_shutdown_function("end_convert_proc");
if($use_sem) {
$sem=sem_get(31337);
sem_acquire($sem);
}
}
function end_convert_proc()
{
global $sem,$use_sem;
if($use_sem) {
sem_release($sem);
}
register_shutdown_function("");
}
function convert_image($sourcepic,$destpic,$res,$quality)
{
global $my_convert_path,$thumb_generator;
global $my_bindir, $my_convert_tmp;
if (get_sound_type($sourcepic)) {
copy("icons/sound.gif", $destpic);
return;
}
else if (get_movie_type($sourcepic)) {
copy("icons/movie.gif", $destpic);
return;
} else if (get_text_type($sourcepic)) {
copy("icons/text.gif", $destpic);
return;
}
wait_convert_proc();
if($thumb_generator=="convert") {
$tofz_syscall = $my_convert_path." -geometry ".$res." -quality ".$quality." \"".$sourcepic."\" \"".$my_convert_tmp.basename($destpic)."\"";
@exec($tofz_syscall);
$tofz_syscall = $my_bindir."super ".$my_bindir."cp \"".$my_convert_tmp.basename($destpic)."\" \"".$destpic."\"";
@exec($tofz_syscall);
} else if($thumb_generator=="gd") {
if(eregi("\.(jpg|jpeg)$",$sourcepic))
$im=imagecreatefromjpeg($sourcepic);
else if (eregi("\.png$",$fn))
$im=imagecreatefrompng($createfn);
if ($im != "") {
$dims=explode("x",$res);
$newh=$dims[1];
$neww=$newh/imagesy($im) * imagesx($im);
if ($neww > imagesx($im)) {
$neww=imagesx($im);
$newh=imagesy($im);
}
if ($neww > $dims[0])
{
$neww=$dims[0];
$newh=$neww/imagesx($im) * imagesy($im);
}
$im2=ImageCreate($neww,$newh);
ImageCopyResized($im2,$im,0,0,0,0,$neww,$newh,imagesx($im),imagesy($im));
if (eregi("\.(jpg|jpeg)$",$sourcepic)) imagejpeg($im2,$destpic,$quality);
else if (eregi("\.png$",$fn)) imagepng($im2,$destpic);
ImageDestroy($im);
ImageDestroy($im2);
} else {
debug_image("Error loading file!");
}
}
end_convert_proc();
}
//show debug info in image format
function debug_image($str){
$im = ImageCreate (150, 50); /* Create a blank image */
$bgc = ImageColorAllocate ($im, 255, 255, 255);
$tc = ImageColorAllocate ($im, 0, 0, 0);
ImageFilledRectangle ($im, 0, 0, 150, 30, $bgc);
/* Output an errmsg */
ImageString ($im, 1, 5, 5, $str, $tc);
ImageJPEG($im);
}
// comments functions
function get_nb_comments($id)
{
global $sDB,$nConnection,$sTableComments;
$cmd="select * from ".$sTableComments." where pic_name='".addslashes($id)."'";
$res=mysql_db_query($sDB,$cmd,$nConnection);
return mysql_num_rows($res);
}
function display_comments($id)
{
global $sDB,$nConnection,$sTableComments,$admin;
global $txt_comments,$txt_add_comment,$txt_comment_from,$txt_comment_on;
?>
$cmd="select * from ".$sTableComments." where pic_name='".addslashes($id)."' order by datetime";
$res=mysql_db_query($sDB,$cmd,$nConnection);
while($row=mysql_fetch_array($res))
{
echo "
".$txt_comment_from."".htmlentities($row["user"])." ".$txt_comment_on.$row["datetime"];
if($admin)
{
echo " | Delete ";
}
echo "";
echo nl2br(make_href($row["comment"]))." ";
echo " ";
}
}
function smallarbo($prfx,$dir) {
global $tofz_arbo;
$handle=opendir($dir);
if($prfx!=""&&$prfx[strlen(prfx)-1]!='/') $prfx.='/';
while ($file = readdir($handle)) {
if(!stristr($file,"."))
if($file!='.'&&$file!='..'&&$file!='.thumbs') {
$f=$dir.'/'.$file;
if(is_dir($f)) {
$tofz_arbo[]=urlencode($prfx.$file);
smallarbo($prfx.$file,$dir.'/'.$file);
}
}
}
closedir($handle);
}
// logout ?
if($logout) {
set_cookie_val("");
header("Location: ".$SCRIPT_NAME);
//?>
exit;
}
// logging in ?
unset($user_row);
if($startlogin) {
$cmd="select * from ".$sTableUsers." where login='$user' and pass='$pass'";
$res = mysql_db_query($sDB,$cmd,$nConnection);
if(!$res || mysql_num_rows($res)==0 ) $error_login=1;
else {
$logged=1;
$user_row=mysql_fetch_array($res);
set_cookie_val($user_row["cookieval"]);
}
} else if($LoginValue) { // login cookie present ?
$cmd="select * from ".$sTableUsers." where cookieval='$LoginValue'";
$res = mysql_db_query($sDB,$cmd,$nConnection);
if($res && mysql_num_rows($res)>0 ) {
$logged=1;
$user_row=mysql_fetch_array($res);
}
}
$admin=($user_row["seclevel"]==999);
// pic rating update ?
if ($display&&$rating) {
if (!already_rated($display) && ($rating>0) && ($rating<=10)) {
$cmd="insert into $sTableRatings (datetime, pic_name, ip, rating) values (now(), '$display', '".getenv("REMOTE_ADDR")."', $rating)";
mysql_db_query($sDB,$cmd,$nConnection);
}
}
// pic comment update ?
if($updpic=="1"&&$admin) {
if (!get_magic_quotes_gpc()) {
$dsc = addslashes($dsc);
}
$cmd="replace into $sTable values('$display','$dsc','$lev',0,0)";
mysql_db_query($sDB,$cmd,$nConnection);
}
// dir level update ?
if($dirlevelchange&&$admin) {
$cmd="replace into $sTable values('$dir','','$dirlevel')";
mysql_db_query($sDB,$cmd,$nConnection);
}
//if($dir) $dir=reformat($dir);
//if($display) $display=reformat($display);
//if($displaypic) $displaypic=reformat($displaypic);
//if($preview) $preview=reformat($preview);
//if($display) $dir=dirname($display);
//if(substr($root_dir,-1)!='/') $root_dir.='/';
//if($dir && substr($dir,-1)!='/') $dir.='/';
// dir creation ?
if($dircreate&&$admin) {
mkdir($root_dir.$dir.$createdirname,0755);
}
// file uploaded ?
if($admin&&$picupload&&$picuploadname!="none") {
Exec("cp -f \"$picuploadname\" \"".$root_dir.$dir.$picuploadname_name."\"");
Exec("chmod 755 \"".$root_dir.$dir.$picuploadname_name."\"");
}
if ($newsend==1&&$admin)
{
include ("config.inc.php");
$da=date ("Y/m/d");
$query = "INSERT INTO tofz.newz(date,news) VALUES('".$da."','".$_POST['ta']."');";
if ($result = mysql_query($query))
echo ($query." entered successfully ".$result);
exit;
}
if ($newsgen==1&&$admin)
{
include ("config.inc.php");
$q=mysql_query("select * from tofz.newz order by date desc limit 10;")
or die ("Requ�te invalide");
echo ("10 last news; ")
;
$filename = 'news.last.inc.php';
$fp = fopen($filename, "w");
while ($row = mysql_fetch_array($q))
{$string=" ".$row[0]." ".$row[1]."
";
echo $string;;
$write = fputs($fp, $string."\n");
}
fclose($fp);
echo (" other news; ");
$q=mysql_query("select * from tofz.newz order by date desc limit 10,99999;")
or die ("Requ�te invalide");
$filename = 'news.old.inc.php';
$fp = fopen($filename, "w");
while ($row = mysql_fetch_array($q))
{$string=" ".$row[0]." ".$row[1]."
";
echo $string;;
$write = fputs($fp, $string."\n");
}
fclose($fp);
exit;
}
if ($newsedit==1&&$admin)
{
?>
newz edit
exit; }
// adding comment == title ?
if($addingcomment && (trim($comment) || trim($user))) {
$picname=reformat($picname);
if (!get_magic_quotes_gpc()) {
$comment = addslashes($comment);
$user = addslashes($user);
}
$cmd="insert into ".$sTableComments." values(0,'".addslashes($picname)."','$comment','".date("Y-m-d H:i:s")."','$user','$REMOTE_ADDR')";
mysql_db_query($sDB,$cmd,$nConnection);
?>
exit;
}
// deleting comment ?
if($delcom&&$admin) {
$cmd="delete from ".$sTableComments." where id=$delcom";
mysql_db_query($sDB,$cmd,$nConnection);
}
// picture displaying ?
if($displaypic && get_level($displaypic)<=(int)$user_row["seclevel"]) {
$comment=get_comment($displaypic);
$comment=str_replace(" ","_",$comment);
header("Content-type: image/jpeg");
$tofname="tofz_dot_org-";
if ($comment!=""){
$tofname.=$comment;}
else{
$tofname.=$displaypic;}
if(filesize($root_dir.$displaypic)>=$lr_limit && !$non_lr) {
// switch to lr_mode
$tofname.="-lo_res.jpg";
} else {
$tofname.="-hi_res.jpg";
}
header("Content-Disposition: inline; filename=".$tofname);
if(filesize($root_dir.$displaypic)>=$lr_limit && !$non_lr) {
// switch to lr_mode
$lrdir=$root_dir.dirname($displaypic)."/.thumbs";
$lrfile=$lrdir."/lr_".basename($displaypic);
if(!file_exists($lrfile)) {
if(!is_dir($lrdir)) mkdir($lrdir,2775);
convert_image($root_dir.$displaypic,$lrfile,$lr_res,$lr_quality);
}
readfile($lrfile);
} else readfile($root_dir.$displaypic);
exit;
}
if($preview) {
header("Content-type: image/jpeg");
$prdir=$root_dir.dirname($preview)."/.thumbs";
$prfile=$prdir."/thumb_".basename($preview);
if(!file_exists($prfile)) {
if(!is_dir($prdir)) mkdir($prdir,2775);
convert_image($root_dir.$preview,$prfile,$thumb_res,$thumb_quality);
}
readfile($prfile);
exit;
}
// random image?
if($random) {
$level=0;
if($logged) $level=(int)$user_row["seclevel"];
$ok=0;
srand ((double) microtime() * 1000000);
// exec('find '.$root_dir.' -type f -print | egrep -i "\.(jpg|jpeg|gif|png)$" | grep -v ".thumbs/"',$find_ar);
$find_ar=file("random_list");
$l=sizeof($find_ar);
for($try=0;!$ok && $try<32;$try++) {
$pickline=substr($find_ar[rand(0,$l)],strlen($root_dir)+2);
$ok = (get_level($pickline)<=$level);
}
$display = $pickline;
$dir = substr($display,0,strrpos($display,"/"))."/";
}
// generate all thumbnails/low res
if($genall&&$admin) {
echo "Generating all missing thumbnails/low res pictures: (be patient) ";
flush();
$gen_lr=0; $gen_th=0;
exec('find '.$root_dir.' -type f -print | egrep -i "\.(jpg|jpeg|gif|png)$" | grep -v ".thumbs/"',$find_ar);
for($i=0;$find_ar[$i];$i++) {
$pic=substr($find_ar[$i],strlen($root_dir));
$lrdir=$root_dir.dirname($pic)."/.thumbs";
if(!is_dir($lrdir)) mkdir($lrdir,0755);
// low res check
if(filesize($root_dir.$pic)>=$lr_limit) {
$lrfile=$lrdir."/lr_".basename($pic);
if(!file_exists($lrfile)) {
echo "Generating low res picture for $pic ";
flush();
convert_image($root_dir.$pic,$lrfile,$lr_res,$lr_quality);
$gen_lr++;
}
}
// thumbnail check
$prfile=$lrdir."/thumb_".basename($pic);
if(!file_exists($prfile)) {
echo "Generating thumbnail picture for $pic ";
flush();
convert_image($root_dir.$pic,$prfile,$thumb_res,$thumb_quality);
$gen_th++;
}
}
echo " ";
echo "Generated $gen_lr low res pictures and $gen_th thumbnails. ";
echo "Your library has ".sizeof($find_ar)." pictures. ";
exit;
}
// pic delete
if($updpic=="del"&&$admin) {
$cmd="delete from $sTable where name='$display'";
$db=mysql_db_query($sDB,$cmd,$nConnection);
$cmd="delete from $sTableComments where pic_name='$display'";
$db=mysql_db_query($sDB,$cmd,$nConnection);
$filename=$root_dir.$display;
$thumbname=$root_dir.dirname($display)."/.thumbs/thumb_".basename($display);
$lrname=$root_dir.dirname($display)."/.thumbs/lr_".basename($display);
if (file_exists($filename))unlink($filename);
if (file_exists($thumbname))unlink($thumbname);
if (file_exists($lrname))unlink($lrname);
//jump back to the directory after deleting the pic
$dir=dirname($display);
header("Location: ./?dir=$dir");
exit;
}
// test if display is video or sound
if ($display) {
if (($type = get_movie_type($display)) || ($type = get_sound_type($display)) || ($type = get_text_type($display))) {
header("Content-type: ".$type);
// header("Content-Disposition: inline; filename=".basename($display));
// header("Content-Disposition: inline; filename=tofz_dot_org_-_".get_comment($display).".jpg");
readfile($root_dir.$display);
return;
}
}
//BLOB
if($movdir) {
include("header.inc.php");
echo "MOVDIR! ";
// $src=stripslashes($src);
// $dest=stripslashes($dest);
echo $src;
echo " => $dest";
echo " ";
init_db_move();
movedir(stripslashes($src),stripslashes($dest));
done_db_move();
include("footer.inc.php");
exit();
}
if($move1tof) {
include("header.inc.php");
echo "MOVE 1 TOF! $whichone => $dest ";
//*
$execstr="cd /home/merou/pictures && /home/merou/bin/move $whichone $dest"; /*/
$execstr="/usr/bin/php -q /home/merou/bin/test.php";//*/
echo "";
// include("/home/merou/bin/test.php");
$argv[1]=$whichone;
$argv[2]=$dest;
$argc=3;
echo "---including move.php\n";
// chdir($root_dir);
putenv("PWD=/home/merou/pictures");
// include("/home/merou/bin/move.php");
init_db_move();
movetof($whichone,$dest);
done_db_move();
echo "uid:".getmyuid()."\n";
echo "user:".get_current_user()."\n";
echo "---done move.php\n";
echo " ";
//*
// echo "$execstr ";
// echo "".`$execstr`." ";
/*/
echo "";
readfile("/tmp/moveoutput");
echo " ";//*/
/*
$ret=array();
@exec($execstr,$ret);
echo "";
print_r($ret);
echo " ";
//*/
include("footer.inc.php");
exit();
}
// display home if nothing else
if (!$dir && !$addcomment && !$lastcomments && !$search && !$log &&!$topratings &&!$oldnews){
if ($lang=="fr") include ("home.fr.php");
else include ("home.php");
exit;
}
else{
include "header.inc.php"; // Login form
if($log) {
?>
echo $txt_login_form_login ?>
echo $txt_login_form_pass ?>
include "footer.inc.php";
exit;
} else if($create&&$admin) { // Create dir form
echo "Current directory : ".$dir." ";
?>
Directory to create:
include "footer.inc.php";
exit;
} else if($upload&&$admin) { // Create dir form
echo "Current directory : ".$dir." ";
?>
File to upload:
include "footer.inc.php";
exit;
} else if($addcomment) { // (little "add comment" popup window)
$id=reformat($id);
?>
include "footer.inc.php";
exit;
} else if($lastcomments) { // display last added comments
echo " ";
echo "Last added comments : ";
echo "";
echo " ";
$cmd="select * from ".$sTableComments." order by datetime desc";
$res=mysql_db_query($sDB,$cmd,$nConnection);
$i=0;
if ($nbc && $nbc<100) $j=$nbc;
else $j=20;
while(($row=mysql_fetch_array($res)) && $i<$j)
{
if(get_level($row["pic_name"])>(int)$user_row["seclevel"]) continue;
echo " ".$row["datetime"]." by ".htmlentities($row["user"])." : ";
$comment=get_comment($row["pic_name"]);
if(trim($comment)=="") $comment=$row["pic_name"];
echo "".$comment." ";
echo " ";
$i++;
}
echo " ";
echo "Go back ";
echo "
";
include "footer.inc.php";
exit;
} else if($topratings) { // display top ratings
echo "Top ".$nb_top_rating." rated pictures : ";
echo " ";
$cmd="select *,avg(rating) as rat from ".$sTableRatings." group by pic_name order by rat desc";
$res=mysql_db_query($sDB,$cmd,$nConnection);
$i=0;
while(($row=mysql_fetch_array($res)) && $i<$nb_top_rating)
{
if(get_level($row["pic_name"])>(int)$user_row["seclevel"]) continue;
echo "".($i+1).": ";
$comment=get_comment($row["pic_name"]);
if(trim($comment)=="") $comment=$row["pic_name"];
echo "".$comment." ";
echo " (".sprintf("%.1f", $row["rat"])." ) ";
echo " ";
$i++;
}
echo " ";
echo "Go back ";
echo " ";
include "footer.inc.php";
exit;
}
else if($search) { // display search results
echo " ";
echo "Search results for \"".$search."\" : ";
echo "tOfz matching by description : ";
echo " ";
$search=addslashes($search);
$cmd="select * from ".$sTable." where descr like '%".$search."%' OR name like '%".$search."%' limit 100";
$res=mysql_db_query($sDB,$cmd,$nConnection);
$num=mysql_num_rows($res);
if ($num==0) echo "no result... sorry! ";
else{
while($row=mysql_fetch_array($res))
{
if(get_level($row["name"])>(int)$user_row["seclevel"]) continue;
echo "";
// r0n rulez <---- w� ben k'il suce des teubz en enfair :p
// c'est moi qui ai """"cod�"""" le search =)))
$tmp_trim_title=explode("::",$row["descr"]);
echo "".$row["name"]." ".trim($tmp_trim_title[0])." ";
$i++;
}
if ($i==100) echo "only the ".$i." first matches displayed. refine your search! ";
else echo "".$i." tOfz found ";
}
echo "tOfz matching by comments : ";
$cmd="select * from ".$sTableComments." where comment like '%".$search."%' or user like '%".$search."%' limit 100";
$res=mysql_db_query($sDB,$cmd,$nConnection);
$num=mysql_num_rows($res);
if ($num==0) echo "no result... sorry! ";
else{
while($row=mysql_fetch_array($res))
{
if(get_level($row["pic_name"])>(int)$user_row["seclevel"]) continue;
echo "";
echo "".$row["pic_name"]." by: ".$row["user"]." : ".$row["comment"]." ";
$i++;
}
if ($i==100) echo "only the ".$i." first matches displayed. refine your search! ";
else echo "".$i." total tOfz found ";
}
echo " ";
echo "Go back ";
echo "
";
include "footer.inc.php";
exit;
}
else if($oldnews){
echo "";
include "footer.inc.php";
exit;
}
}
if(get_level($dir)>(int)$user_row["seclevel"]) exit; // antihack :)
// scan dir
$nb_dirs=0; $nb_files=0;
$dirs[0]=""; $files[0]="";
$dh=dir($root_dir.$dir);
//$dh=dir($root_dir.$dir);
while ($file=$dh->read()) {
if(substr($file,0,1)==".") continue;
// if(substr($file,-3)=="_lr") continue;
// if(substr($file,-6)=="_thumb") continue;
if(substr($file,-8)=="_comment") continue;
if(is_dir($root_dir.$dir.$file)) {
// directory
if(get_level($dir.$file."/")<=(int)$user_row["seclevel"])
$dirs[$nb_dirs++]=$file;
} else {
// file
if(get_level($dir.$file)<=(int)$user_row["seclevel"])
$files[$nb_files++]=$file;
}
}
$dh->close();
sort($dirs);
if (is_file($root_dir.$dir."/.desc"))
rsort($files);
else
sort($files);
?>
if($admin&&$dir&&!$display) {
echo "";
}
// display .welcome message if it exists
if(is_file($root_dir.$dir.".welcome") && !$display) {
echo "";
// system("cat \"".$root_dir.$dir.".welcome\"");
exec("cat ".$root_dir.$dir.".welcome",$welcome);
for($i=0;$i";
echo " ";
// echo " ";
}
?>
if(!$display) { ?>
// display the directory content ***
echo "";
if ($nb_dirs>0){ // display dirs
// if ($nb_files>1){
//echo "";}
// else { // dirty hack to float if no pic in dir
echo "
";//}
if (!$display){
for($i=0;$i<$nb_dirs;$i++) {
echo "
".$dirs[$i]." \n";
}
echo "
";
}}
// display thumbnailz
function echo_pic($i)
{
global $admin,$root_dir,$dir,$files,$sDB,$nConnection;
echo "
";
//BLOB
$comment=get_comment($dir.$files[$i]);
if($comment=="") $comment="sans l�gende...";//$files[$i];
echo "
".$comment." ";
if(($nbc=get_nb_comments($dir.$files[$i]))>0)
{
if($nbc==1)
echo "".$nbc." comment ";
else
echo "".$nbc." comments ";
}
if(is_file($root_dir.$dir."/.rate")){
if(($rtg=get_rating($dir.$files[$i]))!==false)
{
echo "rating : ".sprintf("%.1f", $rtg)." ";
}
}
echo "";
}
if(!$startpic) $startpic=0;
// this is where to put a custom # of columns !!
if($admin) echo "
";
echo "";
for($i=$startpic;$i<$nb_files && $i<($startpic+$nb_pic_max);$i++) {
echo "";
echo_pic($i);
echo " ";
}
echo "
";
$startpic2=$i;
for(;$i<$nb_files && $i<($startpic2+$nb_pic_max);$i++) {
echo "";
echo_pic($i);
echo " ";
}
echo "
";
if ($admin) echo " ";
echo "
";
echo "";
if ($nb_files) echo " ".($startpic+1)."-".$i." / ".$nb_files." ";
echo "";
if($startpic!=0) {
$a=$startpic-($nb_pic_max*2);
if($a<0) $a=0;
echo " ";
}
if($i!=$nb_files) {
echo " ";
}
echo " ";
} else {
//
// display the picture
// display the picture <-- that's H E R E !!!!!
// display the picture
//
for($i=0;$i<$nb_files && basename($display)!=$files[$i];$i++);
///// greffon
if(!$dir) echo " ".$txt_root_dir." - ";
else echo "";
//echo "";
if(get_level($display)<=(int)$user_row["seclevel"]) {
echo "
}
$comment=get_comment($display); /// comment == titre....
if($comment!="") echo $comment; else echo "sans l�gende...";//basename($display);
echo " (".($i+1)."/".$nb_files.") ";
if($i!=0) echo " ";
if(filesize($root_dir.$display)>=$lr_limit && !$non_lr) echo " ";
if(filesize($root_dir.$display)>=$lr_limit && $non_lr) echo " ";
if($files[$i+1]) echo " ";
// echo " ";
if ($use_rating && is_file($root_dir.$dir."/.rate") ) {
$pic_rating=get_rating($display);
echo" ";
if ($pic_rating===false) echo $txt_no_rating; else echo $txt_pic_rating."".sprintf("%.1f", $pic_rating)." ";
if (!already_rated($display)) {
$rate_url="?display=".rawurlencode($display);
if (strpos($rate_url, "?")!==false) $rate_url.="&rating="; else $rate_url.="?rating=";
echo "";
echo "".$txt_option_rating;
for ($a=1;$a<=10;$a++) echo " $a ";
echo " ";
}
}
//echo " ";
if($admin) { ?>
}
// display comment message if it exists
// if(is_file($root_dir.$display."_comment")) {
// echo "";
// system("cat \"".$root_dir.$display."_comment\"");
// echo "
";
//}
echo " ";
echo "
";
display_comments($display);
echo "
random tOf
";
}
?>
if($admin&&$display):
?>
elseif($admin&&$dir):
?>
endif;
?>