• Signature image v2.3 5 0 5 1
Currently:  

Author Topic: Signature image v2.3  (Read 642810 times)

0 Members and 2 Guests are viewing this topic.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Signature image v2.23
« Reply #390 on: July 17, 2009, 03:40:30 PM »
and line 280 is...


Is there any other errors?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sebas Bonito

  • Sr. Member
  • ****
  • Posts: 271
  • Sebas Bonito
    • View Profile
Re: Signature image v2.23
« Reply #391 on: July 19, 2009, 03:34:28 AM »
Code: [Select]
ImageString($im, $val[0], $val[1], $i, $val[2], $$val[3]);...but I guess the prob is somewhere else, would you'd like to take a look on the whole php?
No other probs I've found with the script. Thx!

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Signature image v2.23
« Reply #392 on: July 19, 2009, 05:13:50 AM »
would you'd like to take a look on the whole php?
yes, that could help.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sebas Bonito

  • Sr. Member
  • ****
  • Posts: 271
  • Sebas Bonito
    • View Profile
Re: Signature image v2.23
« Reply #393 on: July 19, 2009, 03:24:16 PM »
Code: [Select]
<?php
$random_image 
1//show random image
$random_fast 1//if your mysql account doesn't have permission to create/delete temporary tables, set this to 0
$debug 0//turning this on, will ignore expiration time, meaning every request will create a new image. change this to 0 before u publish your signature!
$expire 30//seconds before image will be expired and recompilled with new random image and information (lower this will encrease server load!)
$type "png"//image type: png or jpeg
$quality "100"//image quality when used jpeg
define('ROOT_PATH''./'); //path to your 4images root dir with trailing slash! must be ralative ( ./ or ../ or combination of these) and NOT full internet or local (http://example/4images/ or /www/blah/4images/)
$signature_template_dir "./signatures/"//directory with signature template images WITH TRAILING SLASH!!!
$signature_template "signature.png"//default signature template image filename
$signature_template_random 0//use random template image? (0 = no | 1 = yes)
$path "/tmp/"// WRITEBLE dir (chmod 777), where compilled image will be stored (does not requere access from web)
$tmpfname $path."signature.tmp"// filename for the compilled image (extension does not metter)
$tmptname $path."signature.id"// filename for the file where some extra info will be stored in (image id)
$template "default"//name of the template which icons will be used, if thumbnail not found
$sitename ""//signature header
$fonts_dir ""//directory with custom fonts WITH TRAILING SLASH! (leave blank if no fonts)
$fonts = array(); // an array with font names the first number is the number that u can use in $fsize variable, it must be sequenced! and first item must have number 6 or larger!
/*
//an example array:
$fonts = array(
               6  => "micross8px.gdf",
               7  => "micross9px.gdf",
               8  => "micross10px.gdf",
               9  => "micross12px.gdf"
);
*/

$fsize 2//font type (1 to 5 for build-in fonts and 6 to XX for your custom fonts (see $font array above)
$offset = -13//offset from the left, right and bottom, uses for random image and the text (not used if random image disabled)
$offset2 74//extra offset from the left (place where random image will be embeded if its enabled. Not used if random image disabled)
$spacing 9//height of each line of text
$start 19//offset from top (space where header shows)
$tiny 20//an extra space at the begining of each line (needed for offset from the random image space)
$not_in_cat "0"//list of categories which should not be included for random image, separated by coma (i.e. "1,2,3,7") "0" - means disabled
$auth 0//permission level for auth_viewimage (0 = All, 2 = Members, 3 = Private or 9 = Admin) Refer in /includes/constants.php
$peruser 0//alow per user random image (images uploaded by XX user. Usage: signature.php?user=XX)
$noimage "rs.gif"//icon name if no random image was found
$new_cutoff 7//Days when images treated as new
$lang_hits "Aufrufe: ";
$lang_images "Fotos/Videos:  ";
$lang_users "Mitglieder:  ";
$lang_cat "Kategorien:  ";
$lang_new_user "Neu dabei:  ";
$lang_online "Online:  ";
$lang_comments "Kommentare:  ";
// --------- End Config ----------

$peruser = ($peruser && isset($_GET['user']) && intval($_GET['user'])) ? intval($_GET['user']) : "";
$tmpfname .= $peruser;
$tmptname .= $peruser;
if (isset(
$_GET['go']) && $_GET['go'])
{
  if (
$handle = @fopen($tmptname"rb"))
  {
    while (!
feof($handle))
    {
      
$buffer fgets($handle4096);
      
$imgid intval($buffer);
    }
    
fclose($handle);
  }
  
$nozip 1;
  
define('GET_CACHES'1);
  include(
ROOT_PATH.'global.php');
  require(
ROOT_PATH.'includes/sessions.php');
  
$user_access get_permission();
  
$url $site_sess->url(ROOT_PATH."index.php""&");
  if (
$imgid && $random_image)
  {
    
$sql "SELECT cat_id
            FROM "
.IMAGES_TABLE."
            WHERE image_id = 
$imgid";
    if (
$row $site_db->query_firstrow($sql))
    {
      if (
check_permission("auth_viewcat"$row['cat_id']) || check_permission("auth_viewimage"$row['cat_id']))
      {
        
$url = (check_permission("auth_viewimage"$row['cat_id']) && check_permission("auth_viewcat"$row['cat_id'])) ? $site_sess->url(ROOT_PATH."details.php?image_id=".$imgid) : ((check_permission("auth_viewcat"$row['cat_id'])) ? $site_sess->url(ROOT_PATH."categories.php?cat_id=".$row['cat_id']) : $url);
      }
    }
  }
  
header("Location: ".$url);
  exit;
}
$imageid 0;
$time = @filemtime($tmpfname);
if (
$handle = @fopen($tmptname"r"))
{
  if (!
feof($handle))
  {
    
$buffer fgets($handle4096);
    
$imageid intval($buffer);
  }
  
fclose($handle);
}
$current_time time();
if (!
$time || (($current_time $time) > $expire || ($current_time $time) < 0) || $debug)
{
  
$show = array();
  include(
ROOT_PATH.'config.php');
  include(
ROOT_PATH.'includes/constants.php');
  include(
ROOT_PATH.'includes/db_mysql.php');
  
define('MEDIA_PATH'ROOT_PATH.MEDIA_DIR);
  
define('THUMB_PATH'ROOT_PATH.THUMB_DIR);
  
define('MEDIA_TEMP_PATH'ROOT_PATH.MEDIA_TEMP_DIR);
  
define('THUMB_TEMP_PATH'ROOT_PATH.THUMB_TEMP_DIR);
  
define('TEMPLATE_PATH'ROOT_PATH.TEMPLATE_DIR."/".$template);
  
define('ICON_PATH'ROOT_PATH.TEMPLATE_DIR."/".$template."/icons");
  include(
ROOT_PATH.'includes/functions.php');
  
$site_db = new Db($db_host$db_user$db_password$db_name);

// --- Random image -----
  
if ($random_image)
  {
    if (
$random_fast)
    {
      
mt_srand((double)microtime() * intval(session_id()));
      
$temptab "tab_".mt_rand(0,1000000);
      
$sql "CREATE TEMPORARY TABLE ".$temptab." TYPE  =  HEAP
              SELECT i.image_id, i.cat_id
              FROM "
.IMAGES_TABLE." i
              LEFT JOIN "
.CATEGORIES_TABLE." c ON c.cat_id = i.cat_id
              WHERE i.image_active = 1 AND c.auth_viewcat = 
$auth AND i.cat_id NOT IN ($not_in_cat)".(($peruser) ? " AND i.user_id = ".$peruser "").(($imageid) ? " AND i.image_id <> ".$imageid "")."
              ORDER  BY RAND()
              LIMIT 1"
;
      
$result $site_db->query($sql);
      
$sql "SELECT t.image_id, t.cat_id, i.user_id, i.image_name, i.image_media_file, i.image_thumb_file
              FROM "
.$temptab." AS t
              LEFT JOIN "
.IMAGES_TABLE." AS i ON i.image_id=t.image_id";
      
$imagedata $site_db->query_firstrow($sql);
      
$sql "DROP TABLE ".$temptab;
      
$result $site_db->query($sql);
    }
    else
    {
      
$sql "SELECT i.image_id, i.cat_id, i.user_id, i.image_name, i.image_media_file, i.image_thumb_file
              FROM "
.IMAGES_TABLE." i
              LEFT JOIN "
.CATEGORIES_TABLE." c ON c.cat_id = i.cat_id
              WHERE i.image_active = 1 AND c.auth_viewcat = 
$auth AND i.cat_id NOT IN ($not_in_cat)".(($peruser) ? " AND i.user_id = ".$peruser "").(($imageid) ? " AND i.image_id <> ".$imageid "")."
              ORDER  BY RAND()
              LIMIT 1"
;
      
$imagedata $site_db->query_firstrow($sql);
    }
    
$thumb = (empty($imagedata)) ? ICON_PATH."/".$noimage get_file_path($imagedata['image_media_file'], "thumb"$imagedata['cat_id']);
  }

// --- Total users -----
  
$sql "SELECT COUNT(*) AS total_users
          FROM "
.USERS_TABLE."
          WHERE user_level > "
.USER_AWAITING;
  
$row $site_db->query_firstrow($sql);
  
$show['total_users'] = $row['total_users'];

// --- Total not activated users -----
  
$sql "SELECT COUNT(*) AS total_users
          FROM "
.USERS_TABLE."
          WHERE user_level = "
.USER_AWAITING;
  
$row $site_db->query_firstrow($sql);
  
$show['total_users_awaiting'] = $row['total_users'];

// --- Lattest username -----
  
$sql "SELECT user_name
          FROM "
.USERS_TABLE."
          WHERE user_level > "
.USER_AWAITING."
          ORDER BY user_id DESC"
;
  
$row $site_db->query_firstrow($sql);
  
$show['new_user'] = stripslashes($row['user_name']);

// --- Total images -----
  
$sql "SELECT COUNT(*) AS total_images
          FROM "
.IMAGES_TABLE."
          WHERE image_active = 1"
;
  
$row $site_db->query_firstrow($sql);
  
$show['total_images'] = $row['total_images'];

// --- Total new images -----
  
$new_cutoff time() - 60 60 24 $new_cutoff;
  
$sql "SELECT COUNT(*) AS total_new_images
          FROM "
.IMAGES_TABLE."
          WHERE image_active = 1 AND image_date > "
.$new_cutoff;
  
$row $site_db->query_firstrow($sql);
  
$show['total_new_images'] = $row['total_new_images'];

// --- Total categories -----
  
$sql "SELECT COUNT(*) AS total_categories
          FROM "
.CATEGORIES_TABLE;
  
$row $site_db->query_firstrow($sql);
  
$show['total_categories'] = $row['total_categories'];

  
$sql "SELECT SUM(image_hits) AS hit
          FROM "
.IMAGES_TABLE;
  
$row $site_db->query_firstrow($sql);
  
$show['hits'] = $row['hit'];
// --- Total comments -----
  
$sql "SELECT SUM(image_comments) AS sum
          FROM "
.IMAGES_TABLE;
  
$row $site_db->query_firstrow($sql);
  
$show['comments'] = $row['sum'];

// --- Online users -----
  
$time_out time() - 300;
  
$sql "SELECT session_user_id, session_ip
          FROM "
.SESSIONS_TABLE."
          WHERE session_lastaction >= 
$time_out";
  
$result $site_db->query($sql);
  
$show['guests_online'] = $show['reg_online'] = 0;
  while (
$row $site_db->fetch_array($result))
  {
    if (
$row['session_user_id'] != GUEST)
    {
      if (!isset(
$prev_user_ids[$row['session_user_id']]))
      {
        
$show['reg_online']++;
      }
      
$prev_user_ids[$row['session_user_id']] = 1;
    }
    else
    {
      if (!isset(
$prev_session_ips[$row['session_ip']]))
      {
        
$show['guests_online']++;
      }
    }
    
$prev_session_ips[$row['session_ip']] = 1;
  }
//-----------------------

  
if (!empty($fonts_dir) && count($fonts))
  {
    foreach (
$fonts as $key => $val)
    {
      
imageloadfont($fonts_dir.$val);
    }
  }
  
$total_online $show['reg_online'] + $show['guests_online'];
  
$online " (".$show['reg_online']." member".(($show['reg_online'] > || !$show['reg_online'])? "s" "")." and ".$show['guests_online']." guest".(($show['guests_online'] > || !$show['guests_online'])? "s" "").")";
  
$far $offset2+$tiny+(strlen($lang_new_user))*($fsize+4);
  
//array with data:
  //[0] - font type
  //[1] - offset
  //[2] - text
  //[3] - color (i.e. "text_color" will use $text_color variable)
  
$stats = array(
                  array(array(
$fsize78$lang_images"text_color"), array($fsize$far-7$show['total_images']." (davon ".$show['total_new_images']." neu)""text_color")),
                  array(array(
$fsize,78$lang_hits"text_color"), array($fsize$far-7$show['hits'], "text_color")),   
                  array(array(
$fsize78$lang_comments"text_color"), array($fsize$far-7$show['comments'], "text_color")),
                  array(array(
$fsize78$lang_users"text_color"), array($fsize$far-7$show['total_users']+$show['total_users_awaiting'], "text_color"), array($fsize$far+12+strlen($show['total_users'])*($fsize+4)))
  );
  if (
$signature_template_random)
  {
    if (
$dir = @opendir($signature_template_dir))
    {
      
$list = array();
      while (
$file = @readdir($dir))
      {
        if (!
is_dir($signature_template_dir.$file) && is_file($signature_template_dir.$file) && strtolower(substr(strrchr($file,"."), 1)) == "png")
        {
          
$list[] = $file;
        }
      }
      @
closedir($dir);
      
$signature_template $list[array_rand($list)];
    }
  }
  
$im ImageCreateFromPNG($signature_template_dir.$signature_template);
  
$width imagesx($im);
  
$height imagesy($im);
  
$text_color ImageColorAllocate ($im000);
  
$red ImageColorAllocate ($im25500);
  
ImageString($im3$offset2+$tiny4$sitename$text_color);
  
$i $start;
  foreach (
$stats as $key)
  {
    if (
$key[0][2] == $lang_online && !$total_online)
    {
      continue;
    }
    foreach (
$key as $val)
    {
      
ImageString($im$val[0], $val[1], $i$val[2], $$val[3]);
    }
    
$i $i $spacing;
  }
  if (
$random_image)
  {
    
$image_info getimagesize($thumb);
    
$types = array(=> "gif"=> "jpeg"=> "png");
    
$th "imagecreatefrom".$types[$image_info[2]];
    
$width_start $image_info[0];
    
$height_start $image_info[1];
    
$dimension $offset2-$offset*2;
    if (
$height $image_info[1] < $offset && $height $offset2 $offset)
    {
      
$dimension $height $offset;
    }
    
$width_end $dimension;
    
$height_end $dimension;
    if ((
$width_start $width_end || $height_start $height_end) && $width_start && $height_start && $width_end && $height_end)
    {
       
$ratio $width_start $height_start;
      if (
$ratio 1)
      {
        
$width_end $dimension;
        
$height_end round(($dimension/$width_start) * $height_start);
      }
      else
      {
        
$width_end round(($dimension/$height_start) * $width_start);
        
$height_end $dimension;
       }
    }
    elseif (
$width_start || $height_start)
    {
       
$width_end $width_start;
       
$height_end $height_start;
    }
    
$temp imagecreateTrueColor($width_end$height_end);
    if (
$image $th($thumb))
    {
      
imagecopyresampled($temp$image0000$width_end$height_endImageSX($image), ImageSY($image));
    }
    
$posx round(($offset2-$width_end)/2);
    
$posy round(($height-$height_end)/2);
    
imagecopymerge($im,$temp$posx$posy00$width_end$height_end100);
    
ImageRectangle($im$posx-1$posy-1$posx+$width_end-1$posy+$height_end-1$text_color);
  }
  
$function "Image".$type;
  
$function($im,$tmpfname,(($type == "png") ? $quality)); 
  
ImageDestroy($im);
  
$handle = @fopen($tmptname"wb");
  
$contents = @fwrite($handle, (($random_image) ? $imagedata['image_id'] : 0));
  @
fclose($handle);
//end compilling new image
header('Last-Modified: '.gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate'); // HTTP/1.1
header('Cache-Control: pre-check=0, post-check=0, max-age=0'); // HTTP/1.1
header("Content-disposition: filename=signature".MD5(time()).".".$type);
header("Content-Type: image/".$type);
header("Content-Length: ".filesize($tmpfname));
readfile($tmpfname);
?>
« Last Edit: July 19, 2009, 11:17:18 PM by Schnick und Schnack »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Signature image v2.23
« Reply #394 on: July 19, 2009, 11:00:17 PM »
the problem is in this part of your code:
Code: [Select]
array($fsize, $far+12+strlen($show['total_users'])*($fsize+4))this array contains only 2 values, but it must have 4.
I don't know what you were trying to show with it, but either remove it or, add 2 more parameters as all other arrays.

P.S. if you remove it, make sure you remove a quote before it too.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sebas Bonito

  • Sr. Member
  • ****
  • Posts: 271
  • Sebas Bonito
    • View Profile
Re: Signature image v2.23
« Reply #395 on: July 19, 2009, 11:12:54 PM »
I've deleted the part
Code: [Select]
, array($fsize, $far+12+strlen($show['total_users'])*($fsize+4))in line 247, and now there are no errors in the server-logs any longer. Thx for it!

BUT the cropped images are still there



Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Signature image v2.23
« Reply #396 on: July 20, 2009, 02:34:51 AM »
I think I figured what's causing it. It might be the server is caching filesize of signature image...
find:
  @fclose($handle);

insert below:
  clearstatcache();

See if it fixes it.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sebas Bonito

  • Sr. Member
  • ****
  • Posts: 271
  • Sebas Bonito
    • View Profile
Re: Signature image v2.23
« Reply #397 on: July 20, 2009, 02:53:19 AM »
Thx a lot, I gues that has fixed it  :idea:   8)

Offline Lunique

  • Full Member
  • ***
  • Posts: 109
  • V 1.7.7
    • View Profile
Re: Signature image v2.23
« Reply #398 on: July 21, 2009, 03:36:06 AM »
Is it possible to change the font size?
I don't know where to get gdf-fonts so I can only use the ones already working and changing them in this line does not bring the result I need
$fsize = 3; //font type (1 to 5 for build-in fonts and 6 to XX for your custom fonts (see $font array above)


I just want to have the smallest readable font as possible.

Offline softxgame

  • Newbie
  • *
  • Posts: 12
    • View Profile
Re: Signature image v2.23
« Reply #399 on: July 24, 2009, 06:20:14 PM »
Very beautiful
Links from my profile were removed and I'm about to get banned for spam.
One more stupid post and I'm gone. Ops, I did it again..."thank you for the subject" - what kind of reply is this? now I'm banned for sure.

Offline Hagen-Roderich

  • Full Member
  • ***
  • Posts: 127
    • View Profile
    • Hof Jokers
Re: Signature image v2.23
« Reply #400 on: August 07, 2009, 02:51:08 PM »
Thanks for this great MOD.
How to add the date/time of the newest/last picture, behind "picture: 100 (5 new) last from 07.08.2009 14:50" ?
How to add the "cat_name" under the picture?
« Last Edit: August 26, 2009, 09:04:05 AM by Hagen-Roderich »

Offline clubsociety

  • Newbie
  • *
  • Posts: 22
    • View Profile
Re: Signature image v2.23
« Reply #401 on: August 25, 2009, 07:48:02 PM »
Hi,

how can I get the image to my 4images comments now?

Regards Clubsociety

Offline live@ct

  • Sr. Member
  • ****
  • Posts: 348
    • View Profile
Re: Signature image v2.23
« Reply #402 on: September 14, 2009, 07:14:24 PM »
How can I show 2 signatures from the same site in a 1 page,

I modify the code to specified the image id to show an specific image, reduce the time to 0 to every time i access the image it will create a new image signature

but when I use 2 images signatures in the same page it create 2 images of the same image ID one itīs complete and the second its the same image but showed only the half of the image

to access the image I use the rewrite mode to access the images like: site.com/img000.png and the php original its signature.php?img=000

thanks for your help
Existen 10 tipos de personas, los que entienden el codigo binario y los que no.

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Signature image v2.23
« Reply #403 on: September 15, 2009, 01:50:16 AM »
in your signature2.php use this:
$tmpfname $path."signature2.tmp"// filename for the compilled image (extension does not metter)
$tmptname $path."signature2.id"// filename for the file where some extra info will be stored in (image id)
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Lunique

  • Full Member
  • ***
  • Posts: 109
  • V 1.7.7
    • View Profile
Re: Signature image v2.23
« Reply #404 on: October 28, 2009, 05:40:05 PM »
Is it possible to change the font size?
I don't know where to get gdf-fonts so I can only use the ones already working and changing them in this line does not bring the result I need
$fsize = 3; //font type (1 to 5 for build-in fonts and 6 to XX for your custom fonts (see $font array above)


I just want to have the smallest readable font as possible.


Can someone please help me?