forum.coppermine-gallery.net

No Support => Modifications/Add-Ons/Hacks => Mods: Statistics => Topic started by: Deus on October 12, 2005, 01:15:59 am

Title: signature code like mine...
Post by: Deus on October 12, 2005, 01:15:59 am
"nod to GeorgeCC for the Code"

This can be used on any forum that uses either img or html, and thats quite a few, this generates a HUGE amount of hits for my galleries.

Tested with 1.3.2 and 1.3.5 1.4.2 and 1.4.3


Upload to the root of your gallery.
copy this text and save it... using notepad...as pic.php

Code: [Select]
<?php

define
('IN_COPPERMINE'true);
define('INDEX_PHP'true);

require(
'include/init.inc.php');
header('content-type: image/jpeg');

$mlink=mysql_connect('localhost','your gallery Database''your password');
mysql_select_db('your gallery database'$mlink);
$sum_x=4;
$pos=4;

if(isset($_GET['q'])) {
$q=$_GET['q'];
} else {
$q=3;
}

if(isset($_GET['alb'])) {
$pics=mysql_query("select filepath, filename from cpg_pictures where aid=".$_GET['alb']." and pwidth>0 order by rand() limit 0,$q");
} else {
$pics=mysql_query("select filepath, filename from cpg_pictures, cpg_albums where cpg_albums.aid=cpg_pictures.aid and pwidth>0 and visibility=0 order by rand() limit 0,$q");
}
if(isset($_GET['txt'])) {
$txt=$_GET['txt'];
} else {
$txt="www.yourwebsiteurl.com";
}


while($pr=mysql_fetch_array($pics)) {
$fname[]="albums/".$pr['filepath']."thumb_".$pr['filename'];
list($width$height$type$attr) = getimagesize("albums/".$pr['filepath']."thumb_".$pr['filename']);
$sum_x+=$width+4;
$ix[]=$width;
$im[]=imagecreatefromjpeg("albums/".$pr['filepath']."thumb_".$pr['filename']); //echo "albums/".$pr['filepath']."thumb_".$pr['filename']."--";
}

$im_total = @imagecreatetruecolor($sum_x128);
for($pn=0$pn<$q$pn++) {
imagecopy($im_total$im[$pn], $pos400$ix[$pn], 120);
$pos=$pos+$ix[$pn]+4;
}
$pos=$pos-$ix[$pn]-4;
//imagecopy($im_total, $im[1], $pos, 4, 0, 0, $ix[1], 120);
//$pos=$pos+$ix[1]+4;
//imagecopy($im_total, $im[2], $pos, 4, 0, 0, $ix[2], 120);

$textcolor imagecolorallocate($im_total255255255);
$last_x=max($pos,168);
imagefilledrectangle($im_total$last_x-168111$last_x+21260);
imagestring($im_total4$last_x-166111$txt$textcolor);
imagejpeg($im_total);

?>


note the parts that need editing at the top and your website url.

next .htacess

Code: [Select]
RewriteEngine on

RewriteRule ^([^/\&\?]*)pic\.jpg$ pic.php?$1
RewriteRule ^([^/\&\?]*)pic([0-9]*)\.jpg$ pic.php?alb=$2
RewriteRule ^([^/\&\?]*)pic([0-9]*)/([0-9]*)/(.*)\.jpg$ pic.php?alb=$2&txt=$4&q=$3
RewriteRule ^([^/\&\?]*)pic([0-9]*)/(.*)\.jpg$ pic.php?alb=$2&txt=$3

copy and save this as .htaccess

the code worlks like this...
http://www.mess-hall.co.uk/gallery/pic.jpg - this one pulls images from ALL the albums at random.
or
http://mess-hall.co.uk/gallery/pic68.jpg
(https://forum.coppermine-gallery.net/proxy.php?request=http%3A%2F%2Fmess-hall.co.uk%2Fgallery%2Fpic68.jpg&hash=7d229ff0bd52e6115402018aec250ecb180976d0)
or
http://www.mess-hall.co.uk/gallery/pic.jpg
(https://forum.coppermine-gallery.net/proxy.php?request=http%3A%2F%2Fmess-hall.co.uk%2Fgallery%2Fpic60.jpg&hash=e30e90987a5b58bb2eadb09c83bf5a0fe9060448)


the number after pic## is the number of the album you want.
by default, the code chooses 3 pics, but you can select as many or as few as you want.
And change the text inline.

like this
http://mess-hall.co.uk/gallery/pic68/5/Dazbobaby.com.jpg
(https://forum.coppermine-gallery.net/proxy.php?request=http%3A%2F%2Fmess-hall.co.uk%2Fgallery%2Fpic68%2F5%2FDazbobaby.com.jpg&hash=74696a80d4a15a1ebf68a93c65a55170db5723a9)

Notice that this time i have included the url at the end, this can be whatever you want. If your text doesnt fit you will need to adjust some of the code, found at the bottom of pic.php.

Also change all the 120's to what ever your default thumbnail size it, if its 50, change them from 120 to 50, but you will need to adjust the postion of the text for your url, I didnt write the code, so i cant tell you how to do this, just play around.




Now Works with 1.4* too.


Updated: Urls were completely out of date.
All working now.

Title: Re: signature code like mine...
Post by: Deus on October 12, 2005, 01:31:45 am
Thanks nibbler, i wold have posted it in here, but it would'nt let me.
Is this normal or is there something wrong with my account?
Title: Re: signature code like mine...
Post by: Nibbler on October 12, 2005, 01:33:55 am
It's normal - Regular users can't start new threads in this board - post your hack on the support board instead - it will be moved here if it really is a new mod/hack.

Also links to adult content are fine so long as they are marked as such.
Title: Re: signature code like mine...
Post by: Deus on October 12, 2005, 01:37:06 pm
Tried it on 1.4.1 it didnt work... sorry, i dont know why.
Title: Re: signature code like mine...
Post by: NevilleX on October 12, 2005, 04:21:46 pm
Thanks for this great script!
What line to change to adjust text?
Title: Re: signature code like mine...
Post by: Deus on October 12, 2005, 05:54:10 pm

   
   $textcolor = imagecolorallocate($im_total, 255, 255, 255);
   $last_x=max($pos,168);
   imagefilledrectangle($im_total, $last_x-168, 111, $last_x+2, 126, 0);
   imagestring($im_total, 4, $last_x-166, 111, $txt, $textcolor);
   imagejpeg($im_total);


just before $txt and the next to bottom line is the text postion...but as i said earlier, have a play around.
Title: Re: signature code like mine...
Post by: NevilleX on October 12, 2005, 08:25:02 pm
Thanks!  ;)
Title: Re: signature code like mine...
Post by: Deus on October 12, 2005, 08:30:15 pm
no problemo.
Title: Re: signature code like mine...
Post by: blobnl on October 12, 2005, 08:34:46 pm
I get:

<br />
<b>Warning</b>:  imagecopy(): supplied argument is not a valid Image resource in <b>C:\Program Files\xampp\htdocs\fotoforum\pic.php</b> on line <b>42</b><br />
<br />
<b>Warning</b>:  imagecopy(): supplied argument is not a valid Image resource in <b>C:\Program Files\xampp\htdocs\fotoforum\pic.php</b> on line <b>42</b><br />
<br />
<b>Warning</b>:  imagecopy(): supplied argument is not a valid Image resource in <b>C:\Program Files\xampp\htdocs\fotoforum\pic.php</b> on line <b>42</b><br />
JFIF>CREATOR: gd-jpeg v1.0 (using IJG JPEG v62), default quality
C      

 $.' ",#(7),01444'9=82<.342C          

2!!22222222222222222222222222222222222222222222222222P"   
ĵ}!1AQa"q2#BR$3br   
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz   
ĵw!1AQaq"2B   #3Rbr
$4%&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz

 ??? ???
Title: Re: signature code like mine...
Post by: Deus on October 12, 2005, 10:06:29 pm
I've never set this up on a local machine, but i'll hazard a guess at Program Files or at least the space in between.
either that or your using a different version of CPG?
Title: Re: signature code like mine...
Post by: Deus on October 12, 2005, 11:32:58 pm
Sorry BobNL, i cant help you, i didnt write the code, i had someone make it just for me, and i posted it for the benefit of everyone.
If you want help, hang around, somebody will reply eventually.
Please dont PM me asking for help as it would'nt be in the best interest of the community.
Thanks
Deus

My only suggestion... move the path from program files to c:\xampp

now this is around line 42 and relates to your error...

Code: [Select]
$im_total = @imagecreatetruecolor($sum_x, 128);
for($pn=0; $pn<$q; $pn++) {
imagecopy($im_total, $im[$pn], $pos, 4, 0, 0, $ix[$pn], 120);
$pos=$pos+$ix[$pn]+4;
Title: Re: signature code like mine...
Post by: Nibbler on October 12, 2005, 11:40:52 pm
Remove the @ on this line and see what message you get.

Code: [Select]
$im_total = @imagecreatetruecolor($sum_x, 128);
Note: This mod requires GD2
Title: Re: signature code like mine...
Post by: Deus on October 12, 2005, 11:44:19 pm
glad you noticed it needs GD2 nibbler, I never did manage to get GD installed in windows... maybe thats the problem?
But thanks for your input...
Looks like i'm creating work... as ususal.

I've just reinstalled wamp to try and replicate the error, so far, no luck, as soon as i copy .htaccess to coppermine, coppermine is no longer accessable, seems like an apache problem.

So as you can see, it was written specifically for me, I just hope others can benfit from it too.
Sorry Devs if it creates work for you... as you know, I know nothing about coding, I just wanted to share it.
Title: Re: signature code like mine...
Post by: snork13 on October 17, 2005, 04:13:34 pm
thanks Deus for sharing...

one thing i had to do was change my cpg prefix to cpg130...

(https://forum.coppermine-gallery.net/proxy.php?request=http%3A%2F%2Fwww.snork13.net%2Fgallery%2Fpic.php&hash=71818bd0e09559cc8bb755254557553b13efe465) (http://www.snork13.net)
Title: Re: signature code like mine...
Post by: londonhogfan on October 17, 2005, 05:40:09 pm
Thanks, Works great.
Title: Re: signature code like mine...
Post by: Deus on October 17, 2005, 07:29:51 pm
your both welcome, i hope it help generates traffic for you... It does for me.
Title: Re: signature code like mine...
Post by: adik on October 18, 2005, 09:40:03 am
How to change the script to get image only from one selected album ??
Title: Re: signature code like mine...
Post by: Deus on October 18, 2005, 12:21:59 pm
How to change the script to get image only from one selected album ??

the code worlks like this...
http://www.widescreenwallpapers.co.uk/wallpaper/pic.jpg - this one pulls images from ALL the albums at random. ** Produces some blank images, I thinks its a problem with my install, but if anyone else has this problem. plesae notify me **
or
http://mess-hall.co.uk/gallery/pic1.jpg
or
http://www.mess-hall.co.uk/gallery/pic12.jpg

the number after pic## is the number of the album you want.
by default, the code chooses 3 pics, but you can select as many or as few as you want.

like this
http://www.mess-hall.co.uk/gallery/pic1/7/Widescreenwallpapers.jpg

Notice that this time i have included the url at the end, this can be whatever you want. If your text doesnt fit you will need to adjust some of the code, found at the bottom of pic.php.
Title: Re: signature code like mine...
Post by: Deus on January 24, 2006, 06:35:49 am
this is to display any number of images from 1 to the number in that album...


http://www.widescreenwallpapers.co.uk/wallpaper/pic1/1/.jpg - games album
or
http://www.widescreenwallpapers.co.uk/wallpaper/pic2/1/.jpg - movies album

just add /1/ before .jpg or add 20 if you like !

Also works with 1.4.3
Title: Re: signature code like mine...
Post by: Rush_To_Me on January 27, 2006, 06:22:40 am
Hi there mate some questions...

1. It says:

Code: [Select]
$mlink=mysql_connect('localhost','your gallery Database', 'your password');
mysql_select_db('your gallery database', $mlink);

In the $mlink=mysql_connect('localhost','your gallery Database', code the second where it says your gallery database isnt your user to the database???
And for the password wich one is it? the one for the Database? or the password to CPG admin??

Wich lines i have to update?

Because i son't know if i have to edit this ones:

Quote
"select filepath, filename from cpg_pictures where aid=".$_GET['alb']." and pwidth>0 order by rand() limit 0,$q"

2. Does it work if CPG is bridged??

3. Might sound stupid but can u make a more detailed explanation....  ??? because im new with php and MySQL and i'm having a hard time configuring this signature.. but im willing to try it ;)

Regards
Title: Re: signature code like mine...
Post by: Deus on January 27, 2006, 06:34:44 am
ok, valid questions...
its definetely the database name, (could be database user, as my db user and db name are the same) database password - not cpg password, and data base name again.

Yes it works on bridged setup.

one thing i have noticed too, it wont take images from private albums unless you tell it to by using the pic#.jpg #=album number.
Title: Re: signature code like mine...
Post by: Rush_To_Me on January 27, 2006, 06:54:21 am
 ;D Thank you very much that helped

However if you try this www.enlaces-digitales.com/gallery/pic.php (http://www.enlaces-digitales.com/gallery/pic.php) doesn't load any image if you see hard enough :P you can see a partial "w" to my website

do i have to add some code to the filepath question?

Thanx again in advanced and thank you very for both things the mod & support ;D
Title: Re: signature code like mine...
Post by: Deus on January 27, 2006, 07:38:41 am
i'm not sure whats going on there... maybe a code junkie could help please?
Title: Re: signature code like mine...
Post by: Tranz on January 27, 2006, 07:50:50 am
Could you post the code you are using, and star out confidential information?
Title: Re: signature code like mine...
Post by: Rush_To_Me on January 27, 2006, 07:59:00 am
Sure.. the only difference is th URL....  ;D

Code: [Select]
<?php

define
('IN_COPPERMINE'true);
define('INDEX_PHP'true);

require(
'include/init.inc.php');
header('content-type: image/jpeg');

$mlink=mysql_connect('localhost','DATABASE''PASSWORD');
mysql_select_db('DATABASE'$mlink);
$sum_x=4;
$pos=4;

if(isset($_GET['q'])) {
$q=$_GET['q'];
} else {
$q=3;
}

if(isset($_GET['alb'])) {
$pics=mysql_query("select filepath, filename from cpg_pictures where aid=".$_GET['alb']." and pwidth>0 order by rand() limit 0,$q");
} else {
$pics=mysql_query("select filepath, filename from cpg_pictures, cpg_albums where cpg_albums.aid=cpg_pictures.aid and pwidth>0 and visibility=0 order by rand() limit 0,$q");
}
if(isset($_GET['txt'])) {
$txt=$_GET['txt'];
} else {
$txt="www.Enlaces-Digitales.com";
}


while($pr=mysql_fetch_array($pics)) {
$fname[]="albums/".$pr['filepath']."thumb_".$pr['filename'];
list($width$height$type$attr) = getimagesize("albums/".$pr['filepath']."thumb_".$pr['filename']);
$sum_x+=$width+4;
$ix[]=$width;
$im[]=imagecreatefromjpeg("albums/".$pr['filepath']."thumb_".$pr['filename']); //echo "albums/".$pr['filepath']."thumb_".$pr['filename']."--";
}

$im_total = @imagecreatetruecolor($sum_x128);
for($pn=0$pn<$q$pn++) {
imagecopy($im_total$im[$pn], $pos400$ix[$pn], 120);
$pos=$pos+$ix[$pn]+4;
}
$pos=$pos-$ix[$pn]-4;
//imagecopy($im_total, $im[1], $pos, 4, 0, 0, $ix[1], 120);
//$pos=$pos+$ix[1]+4;
//imagecopy($im_total, $im[2], $pos, 4, 0, 0, $ix[2], 120);

$textcolor imagecolorallocate($im_total255255255);
$last_x=max($pos,168);
imagefilledrectangle($im_total$last_x-168111$last_x+21260);
imagestring($im_total4$last_x-166111$txt$textcolor);
imagejpeg($im_total);

?>

AS you can see it's the same code....

Regards
Title: Re: signature code like mine...
Post by: Tranz on January 27, 2006, 08:09:26 am
And you added the .htaccess file? If so, are you certain the server allows for mod rewrite?
Title: Re: signature code like mine...
Post by: Deus on January 27, 2006, 10:05:52 am
Thanks TranzNDance for helping where I cannot.
Title: Re: signature code like mine...
Post by: Rush_To_Me on January 27, 2006, 07:07:45 pm
Yes i uploaded the .htacces file, but how can i know tha my webserver allows mod rewrite? is there something tu run like phpinfo()

Altough is uploaded in the root of my site or the galler...  ??? (kinda new here  ;D)

And as Deus pointed:

Thanks TranzNDance for helping where I cannot.

Thank you very much

Regards
Manuel
Title: Re: signature code like mine...
Post by: Rush_To_Me on January 27, 2006, 07:27:38 pm
 8) I want to apologize to post so quickly, i found that the webserver allows the mod rewrite.. I'll show you how i noticed it :P


In deus's first post:

http://www.ripoffbritain.org/wallpaper/pic75/5/www.ripoffbritain.org.jpg (http://www.ripoffbritain.org/wallpaper/pic75/5/www.ripoffbritain.org.jpg) If you try this and put another thing in the www.domain.com you can change it..

In my site http://www.enlaces-digitales.com/gallery/pic5/5/www.ripoffbritain.org.jpg (http://www.enlaces-digitales.com/gallery/pic5/5/www.ripoffbritain.org.jpg) you can do it too, (the problem is that the rectangle is so small... i think).

Sorry for this post
Title: Re: signature code like mine...
Post by: Deus on January 27, 2006, 07:54:54 pm
well, I can tell you, its nothing to do with the database access, I've just entered for username "Any", Database "any", and password "any" so its not a typo in there.!! LOL
My suggestion would be to now ask your webhost to tell you if that mod rewrite is enabled for you, if not, ask them if they could enable it.

Title: Re: signature code like mine...
Post by: Rush_To_Me on January 28, 2006, 12:13:32 am
first of all i enter the panel and i saw that the hotlinking feature was enable, after that i took a look to the .htaccess from there an i found this:

Code: [Select]
RewriteEngine on
RewriteCond %{HTTP_REFERER} !^$
RewriteCond %{HTTP_REFERER} !^http://enlaces-digitales.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://enlaces-digitales.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.enlaces-digitales.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.enlaces-digitales.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.enlaces-digitales.com/gallery/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.enlaces-digitales.com/gallery$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.enlaces-digitales.com/gallery/albums/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.enlaces-digitales.com/gallery/albums$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.google.com/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.google.com$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.google.com.mx/.*$      [NC]
RewriteCond %{HTTP_REFERER} !^http://www.google.com.mx$      [NC]
RewriteRule .*\.(jpg|jpeg|gif|png|bmp)$ www.juras.com [R,NC]

Do i have to deactivate this feature and add the lines or can just add the lines???

Code: [Select]
RewriteEngine on
RewriteRule ^([^/\&\?]*)pic\.jpg$ pic.php?$1
RewriteRule ^([^/\&\?]*)pic([0-9]*)\.jpg$ pic.php?alb=$2
RewriteRule ^([^/\&\?]*)pic([0-9]*)/([0-9]*)/(.*)\.jpg$ pic.php?alb=$2&txt=$4&q=$3
RewriteRule ^([^/\&\?]*)pic([0-9]*)/(.*)\.jpg$ pic.php?alb=$2&txt=$3
Title: Re: signature code like mine...
Post by: Deus on January 28, 2006, 09:14:42 am
i believe you just add
Code: [Select]
RewriteRule ^([^/\&\?]*)pic\.jpg$ pic.php?$1
RewriteRule ^([^/\&\?]*)pic([0-9]*)\.jpg$ pic.php?alb=$2
RewriteRule ^([^/\&\?]*)pic([0-9]*)/([0-9]*)/(.*)\.jpg$ pic.php?alb=$2&txt=$4&q=$3
RewriteRule ^([^/\&\?]*)pic([0-9]*)/(.*)\.jpg$ pic.php?alb=$2&txt=$3
to the htaccess, try it anyway, it cant hurt.
Title: Re: signature code like mine...
Post by: Abbas Ali on January 28, 2006, 10:01:11 am
One very basic mistake in above given code.

Code: [Select]
if(isset($_GET['alb'])) {
$pics=mysql_query("select filepath, filename from cpg_pictures where aid=".$_GET['alb']." and pwidth>0 order by rand() limit 0,$q");
} else {
$pics=mysql_query("select filepath, filename from cpg_pictures, cpg_albums where cpg_albums.aid=cpg_pictures.aid and pwidth>0 and visibility=0 order by rand() limit 0,$q");
}

In all queries cpg_ should be replaced by the prefix you are using. This should solve the problem.
Title: Re: signature code like mine...
Post by: Deus on January 28, 2006, 11:54:02 am
er... Hi Abbas, thanks for helping out here :D and helping get my site sorted.

Deus.
Title: Re: signature code like mine...
Post by: Tranz on January 28, 2006, 03:16:31 pm
Good find, Abbas.

@Deus, what you can do is replace references to the tablenames with variables like these: {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']}

It will take into account the user's table prefix. This would make your code work regardless of mysql setup.
Title: Re: signature code like mine...
Post by: Rush_To_Me on January 28, 2006, 11:25:37 pm
 ;D Thank you very much Abbas but i can't geit it to work i've just changed the prefix to cpg143_ Because um using that version... :P

Thank you all ... i think i found the problem, it's Cpanel... if i use the hotlinking feature it mess up my settings so what i did was:

1. Change the prefix in pic.php  @Thank you Abbas.
2. Disable the hotlinking feature from CPanel.
3. Put my own .htaccess
But guess.... nothing happended   :'(

It shows a tiny vertical rectangle with a partial "w"

I have CPG configured in spanish... does the installation be different for the language???

Thanx again

Manuel
Title: Re: signature code like mine...
Post by: Abbas Ali on January 30, 2006, 06:14:55 am
If you have updated from cpg1.3.5 to cpg1.4.3 then your prefix would still be cpg135_ since upgradation doesn't change the prefix. I would recommend to use the method suggested by TranzNDance.... i.e. replace cpg_pictures with {$CONFIG['TABLE_PICTURES']} etc... in all queires.
Title: Re: signature code like mine...
Post by: Rush_To_Me on January 31, 2006, 01:08:25 am
Good find, Abbas.

@Deus, what you can do is replace references to the tablenames with variables like these: {$CONFIG['TABLE_PICTURES']}, {$CONFIG['TABLE_ALBUMS']}

It will take into account the user's table prefix. This would make your code work regardless of mysql setup.

If you have updated from cpg1.3.5 to cpg1.4.3 then your prefix would still be cpg135_ since upgradation doesn't change the prefix. I would recommend to use the method suggested by TranzNDance.... i.e. replace cpg_pictures with {$CONFIG['TABLE_PICTURES']} etc... in all queires.

Done i wasnt reading with attention until i found Abbas Post, i did that and the rectangle wont open wide enough to display the photos ;(

By the way my CPG its 143 Fresh, i mean i didn't upgrade it

Again Thankx a lot..

Manuel
Title: Re: signature code like mine...
Post by: Abbas Ali on January 31, 2006, 12:28:43 pm
I don't know what to suggest.... may be we need to debug that script. If you want you can you PM me your site access so that i can take a look.
Title: Re: signature code like mine...
Post by: Abbas Ali on February 01, 2006, 07:05:57 am
After debugging i found that mysql_query() function was failing and hence was causing problem. I replaced mysql_query() with cpg_db_query() and it started working. I think now Rush_To_Me's script is working....

Abbas
Title: Re: signature code like mine...
Post by: Deus on February 01, 2006, 09:37:36 am
If Abbas has it working, can we see your sig now please Rush?
Title: Re: signature code like mine...
Post by: Rush_To_Me on February 01, 2006, 07:27:16 pm
THANKS A LOT!!!  ;D You  guys surely are awsome so here it goes:

 http://www.enlaces-digitales.com/gallery/pic.php (http://www.enlaces-digitales.com/gallery/pic.php)

@Deus Thank you for the script!
@TranzNDance Thank you for your comments
@Abbas Ali I don't have enough words to repay the favor

I will study PHP a little more to help people like you guys ;)

One again Thank you for all

Manuel
Title: Re: signature code like mine...
Post by: dirtytricks on February 23, 2006, 08:11:12 pm
i configured the code to my liking but i cant seem to get the ".jpg" extension to work.

i have added in my .htaccess:
Code: [Select]
RewriteEngine on
RewriteRule ^([^/\&\?]*)pic\.jpg$ pic.php?$1
RewriteRule ^([^/\&\?]*)pic([0-9]*)\.jpg$ pic.php?alb=$2
RewriteRule ^([^/\&\?]*)pic([0-9]*)/([0-9]*)/(.*)\.jpg$ pic.php?alb=$2&txt=$4&q=$3
RewriteRule ^([^/\&\?]*)pic([0-9]*)/(.*)\.jpg$ pic.php?alb=$2&txt=$3

http://www.teamdirtytricks.net/drunktank/pic.php (http://www.teamdirtytricks.net/drunktank/pic.php) works just fine, but
http://www.teamdirtytricks.net/drunktank/pic.jpg (http://www.teamdirtytricks.net/drunktank/pic.jpg) produces a 404 error
Title: Re: signature code like mine...
Post by: Abbas Ali on February 24, 2006, 06:06:29 am
Make sure the mod_rewrite is allowed on your server. Ask your webhost for the same.
Title: Re: signature code like mine...
Post by: dirtytricks on February 25, 2006, 07:08:53 pm
it is, they said:
Quote
ModRewrite is fully enabled in the server your account is on.
Unfortunatly we cannot provide technical assistance with creating
RewriteRule.

anyone got any ideas?
Title: Re: signature code like mine...
Post by: Pascal YAP on May 23, 2006, 09:23:12 pm
Morning,

Is there any security risk if i use only pic.php without .htaccess ?
Because it's work fine as standalone for me !
RewriteRule and mod_rewrite are not allowed on my host  ???

PYAP
Title: Re: signature code like mine...
Post by: Abbas Ali on May 24, 2006, 08:10:51 am
No security risk. You can use it like that. mod_rewrite is used only to make the urls look pretty.
Title: Re: signature code like mine...
Post by: Pascal YAP on May 24, 2006, 09:07:53 am
Thanx Abbas  ;D
Look like that :
(http://) http://www.pays-dignois.com/galerie/random.php (oh oh... this link do not work on 11-30-2006  ??? )

PYAP
Title: Re: signature code like mine...
Post by: peps on May 28, 2006, 09:08:15 pm
awesome script there guys. I had almost no probs "installing" it. The thing is that I get an image only with pic.jpg, the other options don't work. I wonder what is wrong! I would like to configure pic1 to be in another resolution after all this is the point in having pic, pic1, ...pic#. Anyone that can help me out here.

here is the link to the pic file: http://paparak.info/pic.jpg

here is the code

Code: [Select]
<?php

define
('IN_COPPERMINE'true);
define('INDEX_PHP'true);

require(
'include/init.inc.php');
header('content-type: image/jpeg');

$mlink=mysql_connect('localhost','***''***');
mysql_select_db('***'$mlink);
$sum_x=4;
$pos=4;

if(isset($_GET['q'])) {
$q=$_GET['q'];
} else {
$q=5;
}

if(isset($_GET['alb'])) {
$pics=mysql_query("select filepath, filename from pictures where aid=".$_GET['alb']." and pwidth>0 order 

by rand() limit 0,
$q");
} else {
$pics=mysql_query("select filepath, filename from {$CONFIG['TABLE_PICTURES']}

{$CONFIG['TABLE_ALBUMS']} where {$CONFIG['TABLE_ALBUMS']}.aid={$CONFIG['TABLE_PICTURES']}.aid and pwidth>0 

and visibility=0 order by rand() limit 0,
$q");
}
if(isset($_GET['txt'])) {
$txt=$_GET['txt'];
} else {
$txt="http://paparak.info";
}


while($pr=mysql_fetch_array($pics)) {
$fname[]="albums/".$pr['filepath']."th_".$pr['filename'];
list($width$height$type$attr) = getimagesize("albums/".$pr['filepath']."th_".$pr['filename']);
$sum_x+=$width+4;
$ix[]=$width;
$im[]=imagecreatefromjpeg("albums/".$pr['filepath']."th_".$pr['filename']); //echo 

"albums/".$pr['filepath']."th_".$pr['filename']."--";
}

$im_total = @imagecreatetruecolor($sum_x100);
for($pn=0$pn<$q$pn++) {
imagecopy($im_total$im[$pn], $pos400$ix[$pn], 92);
$pos=$pos+$ix[$pn]+4;
}
$pos=$pos-$ix[$pn]-4;
//imagecopy($im_total, $im[1], $pos, 4, 0, 0, $ix[1], 100);
//$pos=$pos+$ix[1]+4;
//imagecopy($im_total, $im[2], $pos, 4, 0, 0, $ix[2], 100);

$textcolor imagecolorallocate($im_total255255255);
$last_x=max($pos,150);
imagefilledrectangle($im_total$last_x-15280$last_x+21270);
imagestring($im_total4$last_x-15280$txt$textcolor);
imagejpeg($im_total);

?>

Thanks in advance
Title: Re: signature code like mine...
Post by: younk on June 01, 2006, 01:04:57 pm
I have tried this, but i wont work right.. It i prehaps just me who have forgot something.
http://www.babez.dk/galleri/pic.jpg

I hope you can help me.

Thanks in advange!
Title: Re: signature code like mine...
Post by: Dr Preacox on June 01, 2006, 03:18:19 pm
This is a damn handy script!!!

Here's a copy of the script with all the needed changes in it, or at least all the ones that need to make it work on newer versions.

Code: [Select]
<?php

define
('IN_COPPERMINE'true);
define('INDEX_PHP'true);

require(
'include/init.inc.php');
header('content-type: image/jpeg');

$mlink=mysql_connect('localhost','dcclorvv_gallery''6iuni2fr');
mysql_select_db('your gallery database'$mlink);
$sum_x=4;
$pos=4;

if(isset($_GET['q'])) {
$q=$_GET['q'];
} else {
$q=3;
}

if(isset($_GET['alb'])) {
$pics=mysql_query("select filepath, filename from {$CONFIG['TABLE_PICTURES']} where aid=".$_GET['alb']." and pwidth>0 order by rand() limit 0,$q");
} else {
$pics=cpg_db_query("select filepath, filename from {$CONFIG['TABLE_PICTURES']}{$CONFIG['TABLE_ALBUMS']} where {$CONFIG['TABLE_ALBUMS']}.aid={$CONFIG['TABLE_PICTURES']}.aid and pwidth>0 and visibility=0 order by rand() limit 0,$q");
}
if(isset($_GET['txt'])) {
$txt=$_GET['txt'];
} else {
$txt="www.dc-6.com/gallery/";
}


while($pr=mysql_fetch_array($pics)) {
$fname[]="albums/".$pr['filepath']."thumb_".$pr['filename'];
list($width$height$type$attr) = getimagesize("albums/".$pr['filepath']."thumb_".$pr['filename']);
$sum_x+=$width+4;
$ix[]=$width;
$im[]=imagecreatefromjpeg("albums/".$pr['filepath']."thumb_".$pr['filename']); //echo "albums/".$pr['filepath']."thumb_".$pr['filename']."--";
}

$im_total = @imagecreatetruecolor($sum_x128);
for($pn=0$pn<$q$pn++) {
imagecopy($im_total$im[$pn], $pos400$ix[$pn], 120);
$pos=$pos+$ix[$pn]+4;
}
$pos=$pos-$ix[$pn]-4;
//imagecopy($im_total, $im[1], $pos, 4, 0, 0, $ix[1], 120);
//$pos=$pos+$ix[1]+4;
//imagecopy($im_total, $im[2], $pos, 4, 0, 0, $ix[2], 120);

$textcolor imagecolorallocate($im_total255255255);
$last_x=max($pos,168);
imagefilledrectangle($im_total$last_x-168111$last_x+21260);
imagestring($im_total4$last_x-166111$txt$textcolor);
imagejpeg($im_total);

?>


.htaccess
Code: [Select]
RewriteEngine on

RewriteRule ^([^/\&\?]*)pic\.jpg$ pic.php?$1
RewriteRule ^([^/\&\?]*)pic([0-9]*)\.jpg$ pic.php?alb=$2
RewriteRule ^([^/\&\?]*)pic([0-9]*)/([0-9]*)/(.*)\.jpg$ pic.php?alb=$2&txt=$4&q=$3
RewriteRule ^([^/\&\?]*)pic([0-9]*)/(.*)\.jpg$ pic.php?alb=$2&txt=$3
Title: Re: signature code like mine...
Post by: Lordi on June 11, 2006, 01:33:43 pm
Tnx it works great.
Title: Re: signature code like mine...
Post by: klax on November 30, 2006, 04:56:32 pm
This is great stuff !!!

(https://forum.coppermine-gallery.net/proxy.php?request=http%3A%2F%2Fwww.laurayluis.com%2Fgaleria%2Fpic.jpg&hash=7aaadefd16e08f237da1624963f567e8aa8c78a4) (http://www.laurayluis.com/galeria)
Title: Re: signature code like mine...
Post by: madhatt on July 27, 2007, 07:38:33 pm
Here is mine.

Still testing

(https://forum.coppermine-gallery.net/proxy.php?request=http%3A%2F%2Fwww.madhatt.com%2Fgallery%2Fpic.php&hash=77ae8bb8d11310998a5b20a50a72ebbe026f7f7f)
Title: Re: signature code like mine...
Post by: Deus on December 08, 2008, 07:27:12 pm
Digging up an old thread.

Is there a way of this code being slightly modified to show just one image from a gallery of the users choice?
ie, I'd like to show a full size signature image, without text, and just the one image?
But it does need to work alongside the same code.
does this make sense?

Thanks in advance,
Darron.
Title: Re: signature code like mine...
Post by: Deus on February 05, 2009, 01:59:49 am
I am wondering if anyone fancies commenting in the script.
I've just had an hour of fun randomly changing numbers to get it to work correctly.
I have NO clue of whats what and would love to know what to change to fix things in future.
Title: Re: signature code like mine...
Post by: Deus on March 30, 2009, 10:55:08 am
updated URLs, all out of date and broken.
Now they're all ok.
Title: Re: signature code like mine...
Post by: Pascal YAP on March 30, 2009, 07:49:55 pm
With an injection => http://mess-hall.co.uk/gallery/pic.php?q=0 or http://mess-hall.co.uk/gallery/pic.php?q=-1
Breaked  ???
Title: Re: signature code like mine...
Post by: kpfan on January 26, 2011, 11:00:34 pm
Where do I edit my template. I don't know what option in the admin controls to chose. To allow me to add my stat code to the footer.
Title: Re: signature code like mine...
Post by: Deus on August 25, 2014, 10:43:33 am
it looks like the code isn't working, or at least for me, has anything changed in CPG 1.5.x for it to break the code?
http://cpg.mess-hall.co.uk/pic45.jpg
Title: Re: signature code like mine...
Post by: Deus on August 25, 2014, 12:14:20 pm
Thanks Dr Preacox for the changes, just reaplced the old code with yours and it works again :)
Title: Re: signature code like mine...
Post by: Deus on December 06, 2023, 01:11:01 am
Can anyone / does anyone fancy updating this for 1.6?
It was always beyond me, now so much has changed in PHP I don't stand a chance.