rtopnb

  • Nombre de sujets
    3
  • Nombre de messages
    5
  • Nombre de commentaires
    Aucun
  • Nombre de news
    Aucune
  • Niveau en PHP
    Débutant

Ses derniers messages sur les forums

rtopnb
le 30/11/2006 à 15:14
fichier .htacces
je voudrais protégéter mon répertoire image. J'ai trouvé ce scrit à mettre dans le dossier images.
le fichier .htacces qui contient :

addhandler images jpg
action WaterMark.php

et le fichier WaterMark.php
qui lui est :
<?php

// Chemin et nom de fichier du fichier PNG à insérer dans l'image
// Pour ne pas utiliser d'image, commentez la ligne suivante

// Define('WATERMARK_IMAGE', './test.png');

// Intensité de transition en pourcentage
Define('WATERMARK_PERCENT', '60');

// Texte copyright à insérer dans l'image
// Pour ne pas utiliser de texte, commentez la ligne suivante

Define('WATERMARK_TEXT', 'Copyright (c) 2006 www.visualprod.net');

// Taille de la police de caractère ( 1 / 2 / 3 / 4 / 5 )
Define('WATERMARK_TEXT_FONT', '3');

// Le texte en mode Shadow (1 = oui - 2 = non)
Define('TEXT_SHADOW', '1');

// Couleur du texte
Define('TEXT_COLOR', '#FFFFFF');


// PARAMETRES GENERAUX
Define('WATERMARK_ALIGN_H', 'right'); // left / right / center
Define('WATERMARK_ALIGN_V', 'bottom'); // top / bottom / center
Define('WATERMARK_MARGIN', '10');

// --------------------------------------------------

$dr=preg_replace('/WaterMark.php.+/', '', $_SERVER['PHP_SELF']);
$filename=str_replace($dr, './', $_SERVER['PATH_INFO']);
$lst=GetImageSize($filename);
$image_width=$lst[0];
$image_height=$lst[1];
$image_format=$lst[2];

if ($image_format==1) {
Header("Content-Type:image/gif");
readfile($filename);
exit;
} elseif ($image_format==2) {
$old_image=imagecreatefromjpeg($filename);
} elseif ($image_format==3) {
$old_image=imagecreatefrompng($filename);
} else {
readfile($filename);
exit;
}


if (Defined('WATERMARK_TEXT') && WATERMARK_TEXT!='') {

$color = eregi_replace("#","", TEXT_COLOR);
$red = hexdec(substr($color,0,2));
$green = hexdec(substr($color,2,2));
$blue = hexdec(substr($color,4,2));

$text_color = imagecolorallocate ($old_image, $red, $green, $blue);

$text_height=imagefontheight(WATERMARK_TEXT_FONT);

$text_width=strlen(WATERMARK_TEXT)*imagefontwidth(WATERMARK_TEXT_FONT);
$wt_y=WATERMARK_MARGIN;
if (WATERMARK_ALIGN_V=='top') {
$wt_y=WATERMARK_MARGIN;
} elseif (WATERMARK_ALIGN_V=='bottom') {

$wt_y=$image_height-$text_height-WATERMARK_MARGIN;
} elseif (WATERMARK_ALIGN_V=='center') {
$wt_y=(int)($image_height/2-$text_height/2);
}

$wt_x=WATERMARK_MARGIN;
if (WATERMARK_ALIGN_H=='left') {
$wt_x=WATERMARK_MARGIN;
} elseif (WATERMARK_ALIGN_H=='right') {
$wt_x=$image_width-$text_width-WATERMARK_MARGIN;
} elseif (WATERMARK_ALIGN_H=='center') {
$wt_x=(int)($image_width/2-$text_width/2);
}

if (TEXT_SHADOW=='1') {
imagestring($old_image, WATERMARK_TEXT_FONT, $wt_x+1, $wt_y+1, WATERMARK_TEXT, 0);
}
imagestring($old_image, WATERMARK_TEXT_FONT, $wt_x, $wt_y, WATERMARK_TEXT, $text_color);
}

if (Defined('WATERMARK_IMAGE') && WATERMARK_IMAGE!='' && file_exists(WATERMARK_IMAGE)) {

$lst2=GetImageSize(WATERMARK_IMAGE);
$image2_width=$lst2[0];
$image2_height=$lst2[1];
$image2_format=$lst2[2];

if ($image2_format==2) {
$wt_image=imagecreatefromjpeg(WATERMARK_IMAGE);
} elseif ($image2_format==3) {
$wt_image=imagecreatefrompng(WATERMARK_IMAGE);
}

if ($wt_image) {

$wt_y=WATERMARK_MARGIN;
if (WATERMARK_ALIGN_V=='top') {
$wt_y=WATERMARK_MARGIN;
} elseif (WATERMARK_ALIGN_V=='bottom') {
$wt_y=$image_height-$image2_height-WATERMARK_MARGIN;
} elseif (WATERMARK_ALIGN_V=='center') {
$wt_y=(int)($image_height/2-$image2_height/2);
}

$wt_x=WATERMARK_MARGIN;
if (WATERMARK_ALIGN_H=='left') {
$wt_x=WATERMARK_MARGIN;
} elseif (WATERMARK_ALIGN_H=='right') {
$wt_x=$image_width-$image2_width-WATERMARK_MARGIN;
} elseif (WATERMARK_ALIGN_H=='center') {
$wt_x=(int)($image_width/2-$image2_width/2);
}

imagecopymerge($old_image,$wt_image,$wt_x,$wt_y,0,0,$image2_width,$image2_height,WATERMARK_PERCENT);
}
}

if ($image_format==2) {
imageJpeg($old_image);
}
if ($image_format==3) {
imagePng($old_image);
}

?>

mon problème c que mes images ne s'affiche pas
ma page est test.php à la racine du site et mon répertoires images ce nomme images
rtopnb
le 16/11/2006 à 10:11
Opendir() et affichage par ordre croissant
Je réalise une petite galerie et pour cela j'ai lu mon répertoire avec la fonction opendir(). Comment puis classer l'affichage par ordre croissant . voici mon script :

<?php
$nb=1;
$i=0;
$dir = opendir("images");
while($file = readdir($dir)) {
if (substr($file,-4)==".jpg") {
echo "<TD><IMG SRC=\"$file\">"."<br>".basename($file,'.jpg')."</TD>\n";

}
}
closedir($dir);
?>
rtopnb
le 15/11/2006 à 10:15
Affichage des 5 derniers enregistrement sans afficher le nouvel id
merci de vos réponses, j'ai essayé et en mettant ça :

SELECT news.id_news, news.titre, news.contenu, news.url, news.visible, news.photo, news.resume, news.title, news.publie, news.image_fond,DATE_FORMAT(fin_date,'%d-%m-%y'),DATE_FORMAT(date_saisie,'%d/%m/%y')date_saisie
FROM news
WHERE visible = 1
ORDER BY news.date_saisie DESC LIMIT 1,5


le test dans dreamweaver m'affiche bien les bon enregistrement mais dans l'affichage de ma page je ne vois qu'un enregistrement. g essayé de faire une région répété et la g un conflit entre la région répété et la requête avec limit.
comment puis je faire affiché mais enregistrement

merci de votre aide
rtopnb
le 14/11/2006 à 17:13
Affichage des 5 derniers enregistrement sans afficher le nouvel id
Bonjour,
je cherche à faire affiché les 5 derniers id de ma table news sauf le dernier id incrémenté qui est affiché différement. J'ai essayé ça marche en local sur mon pc (PHP Version 4.2.0
/ mysql 3.23) mais pas sur le serveur version php 4.0.


SELECT id_news, titre, contenu, url, visible, DATE_FORMAT(fin_date,'%d-%m-%y'),DATE_FORMAT(date_saisie,'%d/%m/%y')date_saisie, news.photo, news.title
FROM news
WHERE id_news < LAST_INSERT_ID() AND visible = 1
ORDER BY id_news DESC



Merci de votre aide
LoadingChargement en cours