Mon problème c’est que je ne capte pas grand-chose au PHP. A mon avis c’est dans mon fichier index.php que ça se passe… Bon ça va être lourd mais je balance le code du fichier si jamais quelqu’un a le courage et le temps de jeter un oeil. Merci d’avance à celui-là
En tout cas je n’ai trouvé nul part les fonctions imagescreate, imagescreatetruecolor, imagesresize ou imageresample.
[cpp]<?
/*
- Copyright © 2004-2005 JiM / aEGIS (jim@aegis-corp.org)
- Copyright © 2000-2001 Christophe Thibault
- Rating system added by sIX / aEGIS (six@aegis-corp.org)
-
- 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.
*/
include_once “config.inc.php”;
include_once “filetypes.inc.php”;
include_once “functions_exif.inc.php”;
$phpgraphy_version=“0.9.8pre5”;
if($database_type==“mysql”) include_once “db_mysql.inc.php”;
elseif($database_type==“file”) include_once “db_file.inc.php”;
else die(“ERROR: Please choose either ‘mysql’ or ‘file’ as database type in your config file”);
// Configuration Checks (application die if a check fail)
if($convert_path) {
$my_convert_path[0]=$convert_path;
if (!is_executable($my_convert_path[0])) die(“ERROR: Could not access your convert executable, please correct the path you’ve specified in the config file or consider using ‘GD’ or ‘manual’ as thumb generator”);
}
else if($thumb_generator==“convert”) {
@exec(“which convert”, $my_convert_path);
if($my_convert_path[0]=="" || !is_executable($my_convert_path[0])) die(“ERROR: Could not find convert, try to specify its path directly in the config or consider using ‘GD’ or ‘manual’ as thumb generator”);
}
if($thumb_generator==“gd” && !function_exists(gd_info)) die(“ERROR: You have choosen GD as thumb generator but your php isn’t compiled with GD support, consider using ‘convert’ or ‘manual’ as thumb generator.”);
if (is_file($language_file)) include_once $language_file; else die(“ERROR: Can NOT open language file”);
if (!is_readable($root_dir)) die(“ERROR: Please configure correctly the root_dir directory in your config file”);
if ($database_type == “file”) {
if (!is_dir($data_dir)) die(“ERROR: Please configure correctly the data directory in your config file”);
if (!is_writable($data_dir)) die(“ERROR: your data directory is NOT writable, check the permissions”);
}
if ($use_exif && !is_dir($data_dir)) die(“WARNING: data directory not found. Please configure it correctly in your config file or disable the use of exif functions”);
if ($use_sem && !function_exists(sem_get)) die(“WARNING: use_sem is actually set to active in your config file but your php was not compiled with the semaphore option. Please disable it as you may encounter problems”);
// Functions
function set_cookie_val($val)
{
global $cookiesite;
setcookie(“LoginValue”,$val,time()+(360024365*3),"/");
}
function get_level($pic) {
if(!strstr($pic,"/")) {
$l=get_level_db($pic);
if($l!=0) return (int)$l;
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 get_level_real($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_real(substr($pic,0,strrpos($pic,"/"))));
}
function reformat($s)
{
// ANTI HACK stuff
if(substr($s,0,1)==".") $s="";
if(substr($s,0,1)=="/") $s="";
if($s) $s=StripSlashes($s);
if(strstr(dirname($s),"…")) $s="";
if(strstr(dirname($s),"./")) $s="";
if(strstr($s,".thumbs")) $s="";
if(strstr($s,"/.")) $s="";
if($s=="." || $s=="./") $s="";
if($s=="…" || $s=="…/") $s="";
return($s);
}
// 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;
wait_convert_proc();
if($thumb_generator==“convert”) {
// New way (removes any ICM, EXIF, IPTC, or other profiles that might be present in the input and aren’t needed in the thumbnail)
@exec($my_convert_path[0]." -size “.$res.” -quality “.$quality.” “”.$sourcepic."" -resize “.$res.” +profile “*” “”.$destpic.""");
} 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 display_comments($id)
{
global $sDB,$nConnection,$sTableComments,$admin;
global $txt_comments,$txt_add_comment,$txt_comment_from,$txt_comment_on;
?>
<?
$user_comments=get_user_comments($id);
for($i=0;$i<sizeof($user_comments);$i++)
{
echo "
".$txt_comment_from."[b]".htmlentities($user_comments[$i][0])."[/b]".$txt_comment_on.$user_comments[$i][1];
if($admin)
{
echo " | Delete[/url]";
}
echo "";
echo nl2br(htmlentities($user_comments[$i][2]))."
";
echo "
";
}
}
function version_check($vercheck)
{
// Used to check PHP version
$minver = explode(".", $vercheck);
$curver = explode(".", phpversion());
if(($curver[0] <= $minver[0]) && ($curver[1] <= $minver[1]) && ($curver[1] <= $minver[1]) && ($curver[2][0] < $minver[2][0])) return true;
else return false;
}
// logout ?
if($logout) {
set_cookie_val("");
header("Location: ".$SCRIPT_NAME);
exit;
}
// logging in ?
unset($user_row);
$logged=0;
if($startlogin) {
if($user_row=db_is_login_ok($user,$pass)) {
$logged=1;
set_cookie_val($user_row[“cookieval”]);
} else $error_login=1;
} else if($LoginValue) { // login cookie present ?
if($user_row=db_get_login($LoginValue)) $logged=1;
}
$admin=($user_row[“seclevel”]==999);
// pic rating update ?
if ($display&&$rating) {
if (!already_rated($display) && ($rating>0) && ($rating<=10)) {
db_add_rating($display,$rating);
}
}
// pic comment update ?
if($updpic==“1”&&$admin) db_update_pic($display,$dsc,$lev);
// dir level update ?
if($dirlevelchange&&$admin) db_update_pic($dir,"",$dirlevel);
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.”"");
}
// adding comment ?
if($addingcomment && (trim($comment) || trim($user))) {
$picname=reformat($picname);
db_add_user_comment($picname,$comment,$user);
?> <?
exit;
}
// deleting comment ?
if($delcom&&$admin) db_del_user_comment($display,$delcom);
// picture displaying ?
if($displaypic && get_level($displaypic)<=(int)$user_row[“seclevel”]) {
header(“Content-type: image/jpeg”);
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,0755);
convert_image($root_dir.$displaypic,$lrfile,$lr_res,$lr_quality);
}
readfile($lrfile);
} elseif (filesize($root_dir.$displaypic)<$lr_limit || $logged) readfile($root_dir.$displaypic);
exit;
}
if($preview) {
if($ft=is_filetype($preview)) {
header(“Content-type: “.$ft[“mime”]);
readfile(“icons/”.$ft[“icon”]);
exit;
}
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,0755);
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);
$l=sizeof($find_ar);
for($try=0;!$ok && $try<32;$try++) {
$pickline=substr($find_ar[rand(0,$l)],strlen($root_dir));
$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<br>";
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<br>";
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) {
db_delete_pic($display);
$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&startpic=$i”);
exit;
}
// Delete thumbs and lr pictures (handfull function when generation has failed for some reasons)
if($updpic==“delthumb”&&$admin) {
$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($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&startpic=$i”);
exit;
}
// test if handled filetypes from filetypes.inc.php
if ($display) {
if($ft=is_filetype($display)) {
header("Content-type: ".$ft[“mime”]);
header(“Content-Disposition: inline; filename=”.basename($display));
readfile($root_dir.$display);
exit;
}
}
?>
<? include "header.inc.php" ?>
<? // Login form
if($login) {
?>
<? 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);
?>
<? echo $txt_comment_form_name ?>
<? echo $txt_comment_form_comment ?>
<?
include "footer.inc.php";
exit;
} else if($lastcomments) { // display last added comments
echo "[u]Last commented pictures :[/u]
";
echo "
";
$c=get_last_user_comments($_GET['lastcomments']);
for($i=0;$i<sizeof($c)&&$i<20;$i++) {
if (is_array($c[$i])):
echo "
";
$pic=$c[$i][0];
if(get_level($pic)>(int)$user_row["seclevel"]) continue;
echo "[/url]";
echo "
|
";
echo "";
echo $c[$i][1]." by [b]".stripcslashes(htmlentities($c[$i][2]))."[/b]";
$comment=get_comment($pic);
if(trim($comment)=="") $comment=$pic;
echo " ".$comment."[/url]";
echo "
|
";
endif;
}
echo "
";
echo "
Go back[/url]";
echo "
";
include "footer.inc.php";
exit;
} else if($topratings) { // display top ratings
echo "[u]Top ".$nb_top_rating." rated pictures :[/u]
";
echo "
";
$c=get_top_ratings();
for($i=0;$i(int)$user_row["seclevel"]) continue;
echo "
".($i+1).": ";
$comment=get_comment($pic);
if(trim($comment)=="") $comment=$pic;
echo "
".$comment."[/url]";
echo " ([b]".sprintf("%.1f", $c[$i][1])."[/b])";
echo "
";
}
echo "
";
echo "Go back[/url]
";
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]="";
if (!is_dir($root_dir.$dir)) die("[b]ERROR:[/b] The directory doesn't exists");
$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 (file_exists($root_dir.$dir."/.desc"))
rsort($files);
else
sort($files);
?>
<?
// display dirs
for($i=0;$i<$nb_dirs;$i++) {
echo "
".$dirs[$i]."[/url]
\n";
}
?>
<?
if($admin&&$dir&&!$display) {
echo "".$txt_dir_sec_lev."";
echo "";
echo "";
echo " ".$txt_inh_lev.get_level($dir)."";
}
?>
<?
// display .welcome message if it exists
if(file_exists($root_dir.$dir.".welcome") && !$display && !$startpic) {
echo "";
include $root_dir.$dir.".welcome";
/* system("cat \"".$root_dir.$dir.".welcome\"");
exec("cat ".$root_dir.$dir.".welcome",$welcome);
for($i=0;$i<sizeof($welcome);$i++)
echo $welcome[$i]."
";*/
echo "
";
// echo "
";
}
?>
<? if(!$display) { ?>
<?
// display the directory content
function echo_pic($i)
{
global $dir,$files,$sDB,$nConnection;
echo “
<a href=”?display=".rawurlencode($dir.$files[$i]).""><img src="?preview=".rawurlencode($dir.$files[$i])."" border=0>[/url] | ";
$comment=get_comment($dir.$files[$i]);
if($comment=="") $comment=$files[$i];
echo “<a href=”?display=".rawurlencode($dir.$files[$i])."">".nl2br(htmlentities($comment))."[/url]";
if(($nbc=get_nb_comments($dir.$files[$i]))>0)
{
echo “ <span class=“small”>”.$nbc." comments";
}
if(($rtg=get_rating($dir.$files[$i]))!==false)
{
echo “
<span class=“small”>rating : “.sprintf(”%.1f", $rtg)."”;
}
echo “ | ”;
}
if(!$startpic) $startpic=0;
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 “ |
”;
echo “
”;
echo “”;
if($startpic!=0) {
$a=$startpic-($nb_pic_max*2);
if($a<0) $a=0;
echo “<a href=”?dir=".rawurlencode($dir)."&startpic=".$a."">".$txt_previous_page."[/url] ";
}
if ($nb_pic_max2 < $nb_files) {
$nb_pages=ceil($nb_files/($nb_pic_max2));
for ($page_nb=1;$page_nb<=$nb_pages;$page_nb++) {
$page_startpic=($page_nb*$nb_pic_max2)-$nb_pic_max2;
echo " “;
if ($page_startpic != $startpic) echo “<a href=”?dir=”.rawurlencode($dir)."&startpic=".$page_startpic."">";
echo $page_nb;
if ($page_startpic != $startpic) echo “[/url]”;
echo " ";
}
}
if($i!=$nb_files) {
echo “<a href=”?dir=".rawurlencode($dir)."&startpic=".$i."">".$txt_next_page."[/url]";
}
echo “”;
?>
<? } else {
// display the picture
for($i=0;$i<$nb_files && basename($display)!=$files[$i];$i++);
echo "";
echo "
[b]";
$comment=get_comment($display);
if($comment!="") echo nl2br(htmlentities($comment)); else echo basename($display);
echo "[/b]";
if($i!=0) echo "
".$txt_previous_image."[/url] ";
$startpic=0;
while ($i+1>$startpic+($nb_pic_max*2)) { $startpic=$startpic+$nb_pic_max*2; }
echo "$txt_back_dir[/url]";
echo " (".($i+1)."/".$nb_files.") ";
if(filesize($root_dir.$display)>=$lr_limit && !$non_lr && $logged) echo " ".$txt_hires_image."[/url] ";
if(filesize($root_dir.$display)>=$lr_limit && $non_lr) echo " ".$txt_lores_image."[/url] ";
if($files[$i+1]) echo "".$txt_next_image."[/url]";
echo "
";
if ($use_rating) {
$pic_rating=get_rating($display);
if ($pic_rating===false) echo $txt_no_rating; else echo $txt_pic_rating."[b]".sprintf("%.1f", $pic_rating)."[/b]";
echo "
";
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) { ?>
<?echo $txt_description ?>
<? echo get_comment($display) ?>
|
<?echo $txt_sec_lev ?>
<? echo $txt_inh_lev.get_level($dir) ?>
|
|
<? }
// display comment message if it exists
if(file_exists($root_dir.$display."_comment")) {
echo “
”;
system(“cat “”.$root_dir.$display.”_comment"");
echo “ |
”;
}
if(get_level($display)<=(int)$user_row[“seclevel”]) {
if($files[$i+1]) echo “<a href=”?display=".rawurlencode($dir.$files[$i+1])."">";
?>
<img src="?displaypic=<? echo rawurlencode($display) ?>&non_lr=<? echo $non_lr ?>" border=0 <? if($files[$i+1]) echo "alt=\"$txt_next_image\"" ?>>
<?
if($files[$i+1]) echo "[/url]";
} ?>
<?
if ($use_exif) display_exif();
display_comments($display);
} ?>
<? include "footer.inc.php" ?>
[/cpp]