March 21, 2010, 03:31:21 am *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Private messages disabled
Caused by the massive abuse of the PM system in the past, the sending of personal messages has been disabled for all regular users on the Coppermine forum.
[more]
   Home   Help Search Board rules Login Register  
Pages: [1] 2 3   Go Down
  Print  
Author Topic: signature code like mine...  (Read 32434 times)
0 Members and 1 Guest are viewing this topic.
Deus Topic starter
Contributor
***
Gender: Male
United Kingdom United Kingdom

Posts: 141



WWW
« on: October 12, 2005, 12: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:
<?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:
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
(http://mess-hall.co.uk/gallery/pic68.jpg)
or
http://www.mess-hall.co.uk/gallery/pic.jpg
(http://mess-hall.co.uk/gallery/pic60.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.
And change the text inline.

like this
http://mess-hall.co.uk/gallery/pic68/5/Dazbobaby.com.jpg
(http://mess-hall.co.uk/gallery/pic68/5/Dazbobaby.com.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.

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.

« Last Edit: March 30, 2009, 09:54:01 am by Deus » Logged

http://www.mess-hall.co.uk/
Gallery, blog/news and PS3 gaming forum
Deus Topic starter
Contributor
***
Gender: Male
United Kingdom United Kingdom

Posts: 141



WWW
« Reply #1 on: October 12, 2005, 12: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?
Logged

http://www.mess-hall.co.uk/
Gallery, blog/news and PS3 gaming forum
Nibbler
Dev Team member
****
Gender: Male
United Kingdom United Kingdom

Posts: 19610



WWW
« Reply #2 on: October 12, 2005, 12: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.
Logged

I don't care about what they say, I won't live or die that way.
Deus Topic starter
Contributor
***
Gender: Male
United Kingdom United Kingdom

Posts: 141



WWW
« Reply #3 on: October 12, 2005, 12:37:06 pm »

Tried it on 1.4.1 it didnt work... sorry, i dont know why.
Logged

http://www.mess-hall.co.uk/
Gallery, blog/news and PS3 gaming forum
NevilleX
Coppermine novice
*
Posts: 34


WWW
« Reply #4 on: October 12, 2005, 03:21:46 pm »

Thanks for this great script!
What line to change to adjust text?
Logged

Deus Topic starter
Contributor
***
Gender: Male
United Kingdom United Kingdom

Posts: 141



WWW
« Reply #5 on: October 12, 2005, 04: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.
Logged

http://www.mess-hall.co.uk/
Gallery, blog/news and PS3 gaming forum
NevilleX
Coppermine novice
*
Posts: 34


WWW
« Reply #6 on: October 12, 2005, 07:25:02 pm »

Thanks!  Wink
Logged

Deus Topic starter
Contributor
***
Gender: Male
United Kingdom United Kingdom

Posts: 141



WWW
« Reply #7 on: October 12, 2005, 07:30:15 pm »

no problemo.
Logged

http://www.mess-hall.co.uk/
Gallery, blog/news and PS3 gaming forum
blobnl
Coppermine newbie

Posts: 16


« Reply #8 on: October 12, 2005, 07: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

 Huh Huh
Logged

(http://82.156.219.246/fotoforum/pic.jpg)
Deus Topic starter
Contributor
***
Gender: Male
United Kingdom United Kingdom

Posts: 141



WWW
« Reply #9 on: October 12, 2005, 09: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?
Logged

http://www.mess-hall.co.uk/
Gallery, blog/news and PS3 gaming forum
Deus Topic starter
Contributor
***
Gender: Male
United Kingdom United Kingdom

Posts: 141



WWW
« Reply #10 on: October 12, 2005, 10: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:
$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;
« Last Edit: October 12, 2005, 10:41:55 pm by Deus » Logged

http://www.mess-hall.co.uk/
Gallery, blog/news and PS3 gaming forum
Nibbler
Dev Team member
****
Gender: Male
United Kingdom United Kingdom

Posts: 19610



WWW
« Reply #11 on: October 12, 2005, 10:40:52 pm »

Remove the @ on this line and see what message you get.

Code:
$im_total = @imagecreatetruecolor($sum_x, 128);

Note: This mod requires GD2
Logged

I don't care about what they say, I won't live or die that way.
Deus Topic starter
Contributor
***
Gender: Male
United Kingdom United Kingdom

Posts: 141



WWW
« Reply #12 on: October 12, 2005, 10: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.
« Last Edit: October 12, 2005, 11:11:14 pm by Deus » Logged

http://www.mess-hall.co.uk/
Gallery, blog/news and PS3 gaming forum
snork13
Contributor
***
Gender: Male
Posts: 260


Internet! Is that thing still around?


WWW
« Reply #13 on: October 17, 2005, 03:13:34 pm »

thanks Deus for sharing...

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

(http://www.snork13.net/gallery/pic.php)
Logged
londonhogfan
Coppermine novice
*
Posts: 28


WWW
« Reply #14 on: October 17, 2005, 04:40:09 pm »

Thanks, Works great.
Logged

(http://www.razorbacklegacy.com/hog_archive/pic.jpg)
Deus Topic starter
Contributor
***
Gender: Male
United Kingdom United Kingdom

Posts: 141



WWW
« Reply #15 on: October 17, 2005, 06:29:51 pm »

your both welcome, i hope it help generates traffic for you... It does for me.
Logged

http://www.mess-hall.co.uk/
Gallery, blog/news and PS3 gaming forum
adik
Coppermine newbie

Posts: 13


« Reply #16 on: October 18, 2005, 08:40:03 am »

How to change the script to get image only from one selected album ??
Logged

Deus Topic starter
Contributor
***
Gender: Male
United Kingdom United Kingdom

Posts: 141



WWW
« Reply #17 on: October 18, 2005, 11:21:59 am »

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.
« Last Edit: March 30, 2009, 10:03:17 am by Deus » Logged

http://www.mess-hall.co.uk/
Gallery, blog/news and PS3 gaming forum
Deus Topic starter
Contributor
***
Gender: Male
United Kingdom United Kingdom

Posts: 141



WWW
« Reply #18 on: January 24, 2006, 05: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
« Last Edit: February 01, 2006, 08:53:56 am by Deus » Logged

http://www.mess-hall.co.uk/
Gallery, blog/news and PS3 gaming forum
Rush_To_Me
Coppermine newbie

Gender: Male
Posts: 17

Crazy Mechanic Engineer


WWW
« Reply #19 on: January 27, 2006, 05:22:40 am »

Hi there mate some questions...

1. It says:

Code:
$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....  Huh because im new with php and MySQL and i'm having a hard time configuring this signature.. but im willing to try it Wink

Regards
Logged

Pages: [1] 2 3   Go Up
  Print  
 
Jump to:  

Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC
Page created in 0.093 seconds with 15 queries.