2014-07-23, 09:30 AM
Hi all, i would like to add a background image in all attachments on my forum, i tested some plugins but i don't want to add manually the logo on every attach, i'm looking for smart solution...
So i added .htaccess in uploads folder to redirect all the requests for the image file into watermark.php, but something is wrong , can u help me ?
this is watermark.php
So i added .htaccess in uploads folder to redirect all the requests for the image file into watermark.php, but something is wrong , can u help me ?
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f
RewriteRule \.(gif|jpeg|jpg|png|attach)$ watermark.php [QSA,NC]
this is watermark.php
<?php
$path = $_SERVER['DOCUMENT_ROOT'].$_SERVER['REQUEST_URI'];
$image = imagecreatefromstring(file_get_contents($path));
$w = imagesx($image);
$h = imagesy($image);
$watermark = imagecreatefrompng('watermark.png');
$ww = imagesx($watermark);
$wh = imagesy($watermark);
imagecopy($image, $watermark, $w-$ww, $h-$wh, 0, 0, $ww, $wh);
eregi('\.(gif|jpeg|jpg|png)$',$path,$regs);
switch( $regs[1] ) {
case 'gif':
header('Content-type: image/gif');
imagegif($image);
break;
case 'jpg':
case 'jpeg':
header('Content-type: image/jpeg');
imagejpeg($image);
break;
case 'png':
header('Content-type: image/png');
imagepng($image);
break;
}
exit();
?>