signature ( php -> jpg or png ) signature ( php -> jpg or png )
 

News:

CPG Release 1.6.26
Correct PHP8.2 issues with user and language managers.
Additional fixes for PHP 8.2
Correct PHP8 error with SMF 2.0 bridge.
Correct IPTC supplimental category parsing.
Download and info HERE

Main Menu

signature ( php -> jpg or png )

Started by pelhrimak, February 12, 2006, 09:12:57 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

pelhrimak

Hello, the signature from steverobbins

1. new example sig.php
<?php

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

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

   
$sum_x=2;
   
$pos=3;
   
$q=6;
   
$totheight 80;

   
   
$pics=mysql_query("SELECT filepath, filename FROM cpg132_pictures, cpg132_albums WHERE cpg132_albums.aid=cpg132_pictures.aid AND pwidth>0 AND pwidth>pheight AND visibility=0 ORDER BY rand() LIMIT 0,$q");
   
   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+2;
      
$ix[]=$width;
      
$iy[]=$height;
      
$im[]=imagecreatefromjpeg("albums/".$pr['filepath']."thumb_".$pr['filename']);
      
      
//echo "albums/".$pr['filepath']."thumb_".$pr['filename']."--";
   
}
   
   
$sum_x $sum_x 2;
   
$im_total = @imagecreatetruecolor($sum_x$totheight);
   
   
// create border
   
$bordercolour imagecolorallocate($im_total030255);
   
imagefilledrectangle($im_total00$sum_x$totheight$bordercolour);
      
   
   
// create white background
   
$backgroundcolour imagecolorallocate($im_total255255255);
   
imagefilledrectangle($im_total11$sum_x 2$totheight 2$backgroundcolour);
   
   
   
// add pictures  imagecopy ( resource dst_im, resource src_im, int dst_x, int dst_y, int src_x, int src_y, int src_w, int src_h )
   
for($pn 0$pn $q$pn++) {
   
      
imagecopy($im_total$im[$pn], $pos300$ix[$pn], $iy[$pn]);
      
$pos=$pos+$ix[$pn] + 2;
   
   }
   
   
// get some data from the database
   
   
$txt_totalhits 0;
   
   
$sql="SELECT hits FROM cpg132_pictures";
   
$result mysql_query($sql);
   
$txt_totalphotos mysql_num_rows($result);
   
   while (
$row mysql_fetch_array($resultMYSQL_BOTH))
   {
   
$txt_totalhits $txt_totalhits $row['hits'];
   }
   
   
$sql="SELECT aid FROM cpg132_albums";
   
$result mysql_query($sql);
   
$txt_totalalbums mysql_num_rows($result);
   
   
$sql="SELECT msg_id FROM cpg132_comments";
   
$result mysql_query($sql);
   
$txt_totalcomments mysql_num_rows($result);
   
   
//$sql="SELECT aid FROM cpg132_albums";
   //$result = mysql_query($sql);
   //$txt_totalalbums = mysql_num_rows($result);
   
   // Add text
   
$textcolor imagecolorallocate($im_total5050150);
   
   
$txt "Random photos from xxxxxxxxxxxx -  $txt_totalphotos photos, $txt_totalhits views, $txt_totalalbums albums, $txt_totalcomments comments.";
   
   
imagefilledrectangle($im_total264$sum_x 2$totheight 2$backgroundcolour);
   
// bool imagestring ( resource image, int font, int x, int y, string s, int col )
   
imagestring($im_total2464$txt$textcolor);
   
   
imagejpeg($im_total);

?>


!! prefix cpg132_ edit on you prefix !!


2. Upload your server and try it
example my: http://svet.pelhrim.cz/pic.php

3. Now uses php_gd2 - fce: imagestring


Joachim Müller

1) Not a plugin, as it doesn't use coppermine's plugin API. Moving accordingly.
2) Bound to break if not stored in coppermine's root folder.
3) Why include coppermine's init.inc.php and then hardcode the queries instead of using coppermine's built-in queries?
4) Hard-coded table prefix is bound to break things for most

Although we appreciate your willingsness to share, you should review this mod before it could actually go into the mods board (will be moved again if it actually qualifies as a working mod).

pelhrimak


Joachim Müller

works for you, won't work for others. Therefor not moving to mods board. Re-read my advice and do as suggested if you want this to go into the mods section. If you don't care, then leave as-is.