Uutiset:

Wondering if this will always be free?  See why free is better.

Main Menu
Advertisement:

[HELP] Member signature won't show

Aloittaja MiXailo, tammikuu 08, 2014, 07:33:13 AP

« edellinen - seuraava »

MiXailo

SMF: 2.0.6
Problem: I found some code of member signatures on page 6 on this link and I do everything that need and it won't works!!
<?php

if (file_exists(dirname(__FILE__) . '/SSI.php')) {
require(
dirname(__FILE__) . '/SSI.php');
}
else die();

getinfos();
signature();

function 
getinfos()
{
global 
$smcFunc$context$memberContext;

$mommy '';

if (
$_GET['u'] >= 1)
    
$id_mem = isset($_GET['u']) ? (int) $_GET['u'] : die();
else die();

    
$result $smcFunc['db_query']('''
        SELECT member_name
        FROM {db_prefix}members
        WHERE id_member = '
. (int) $id_mem.' AND is_activated = 1
        LIMIT 1
        '
,
        array()
    );

     if (
$smcFunc['db_fetch_row']($result) > 0)  
{

 
$mprofile[] = (int) $id_mem;

loadMemberData($mprofilefalse'profile');

foreach (
$mprofile as $profile)
{
loadMemberContext($profile);


$context['item_comms'] = array();

$context['item_comms'][] = array(
    
'lbuser' => $memberContext[$id_mem]
);

foreach (
$context['item_comms'] as $item_comm)
    {
$context['membername'] = $item_comm['lbuser']['name'];
$context['posts'] = $item_comm['lbuser']['posts'];
$context['gender'] = $item_comm['lbuser']['gender']['image'];
$context['karmaBad'] = $item_comm['lbuser']['karma']['bad'];
$context['karmaGood'] = $item_comm['lbuser']['karma']['good'];
$context['avatar'] = $item_comm['lbuser']['avatar']['href'];
    }

} else die();

if (!empty(
$context['avatar']))
  {
  
$mommy = !empty($context['avatar']) ? $context['avatar'] : ''
  
$mommy preg_split('/;/',$mommy, -1PREG_SPLIT_OFFSET_CAPTURE);
  
$mommy $mommy [1][0];
  
$mommy trim(substr(strrchr($mommy'='), 1));

$result2 $smcFunc['db_query']('','
SELECT filename
FROM {db_prefix}attachments
WHERE id_attach = ' 
. (int) $mommy ' AND attachment_type = 0 AND approved = 1
LIMIT 1'
,
array()
);

list(
$count_result) = $smcFunc['db_fetch_row']($result2);

   
$context['filename_avatar'] = $count_result;
   
$smcFunc['db_free_result']($result2);
      
  }
  
  
$smcFunc['db_free_result']($result);
 }
 

function 
signature()
{
global 
$context$settings$modSettings;

$lemo '';
$img_url $settings['default_theme_url']; 

$membername $context['membername'];
$posts $context['posts'];

    if (!empty(
$context['filename_avatar'])) 
     {
       
$lemo $context['filename_avatar'];
     }
    else {
       
$lemo '';
     } 

$avatar $context['avatar'];
$gender $context['gender'];

if (
preg_match'/Male/'$gender))
{
    
$gender "male";
$img_gender "$img_url/images/Male.gif";

elseif (
preg_match'/Female/'$gender)) {
    
$gender "female";
    
$img_gender "$img_url/images/Female.gif"; }
else {
$gender "n/a"$img_gender "$img_url/images/star.gif";}

$karmaBad $context['karmaBad'];
$karmaGood $context['karmaGood'];   
if (
$modSettings['karmaMode'] == '1'

$karma $karmaGood $karmaBad;
} elseif (
$modSettings['karmaMode'] == '2')
{
$karma '+'.$karmaGood.' / '.'-'.$karmaBad;
} elseif (
$modSettings['karmaMode'] == '0'
{
$karma 'n/a';
}
// Your settings +++++++++++++++++++++++++++++++++++ 
$backimg "$img_url/images/sign.png"// or where you want 
$noavatar "$img_url/images/noavatar.png"// or where you want
$set_avatar_height 0//move avatar up/down
$set_avatar_width 0//move avatar left/right
$set_gender_style 0// 0 text , 1 image
$set_gender_height = -92//move gender up/down
$set_gender_width = -230//move gender left/right
// Your settings +++++++++++++++++++++++++++++++++++

if (!empty($avatar)) {$avatar $avatar;}
else {
$avatar $noavatar;}

if (!empty(
$lemo)) { $ext substr(strrchr($lemo'.'), 1); }
else {
$ext substr(strrchr($avatar'.'), 1);}

unset(
$lemo);

if (
$ext == 'png') {$img_bgr imagecreatefrompng($avatar); }
elseif (
$ext == 'jpg') {$img_bgr imagecreatefromjpeg($avatar); }
elseif (
$ext == 'gif') {$img_bgr imagecreatefromgif($avatar); }
else die();

$size getimagesize($backimg);

if (
$set_gender_style == 1) {
$img_bgr_gender imagecreatefromgif($img_gender);
$image_width_gender imagesx($img_bgr_gender);  
$image_height_gender imagesy($img_bgr_gender);
$dest_x_gender $size[0] - $image_width_gender $set_gender_width;  
$dest_y_gender $size[1] - $image_height_gender $set_gender_height;
}

$image_width imagesx($img_bgr);  
$image_height imagesy($img_bgr);

//______________avatar  width & height must be <=106
if ($image_width <=106 && $image_width >=10 && $image_height <=106 && $image_height >=10)
  {
$set_avatar_width =  $set_avatar_width + (($image_width 101) * 0.35);
$set_avatar_height =  $set_avatar_height + (($image_height 101) * 0.35);
 }
else { die();}

$image imagecreatetruecolor($image_width$image_height); 
$image imagecreatefrompng($backimg);  

$dest_x $size[0] - $image_width $set_avatar_width;  
$dest_y $size[1] - $image_height $set_avatar_height
imagecopymerge($image$img_bgr,  $dest_x$dest_y00$image_width$image_height100);
if (
$set_gender_style == 1) {
imagecopymerge($image$img_bgr_gender,  $dest_x_gender$dest_y_gender00$image_width_gender$image_height_gender100);
}
 
$green ImageColorAllocate ($image2312417); 
$blue ImageColorAllocate ($image00255); 
$red ImageColorAllocate ($image25500);
$white ImageColorAllocate ($image255255255);
$black ImageColorAllocate ($image000);

ImageString($image42035"Postova: $posts"$black);
ImageString($image42051"Karma: $karma"$black);
if (
$set_gender_style == 0) {
ImageString($image5314"$membername"$black);
ImageString($image42066"Pol: $gender"$black);
} else {
ImageString($image5444"$membername"$black);}

header("Content-Type: image/png"); 

$php PHP_VERSION
if (@
version_compare(PHP_VERSION'5.1.0'">="))
  {
  
// if PHP v5.1 ++
Imagepng($image,null,9,null); 
  }
else {
Imagepng($image,null,90,null); 
  }    
ImageDestroy ($image);
ImageDestroy ($img_bgr);  
}


?>

I have uploaded file sign.php in public_html where is my forum (up code)
I made some photos in photoshop
I'm uploaded this to Themes/default/images I named this as noavatar.png
and this I'm uploaded to Themes/default/images I named this as sign.png
When I put this in signature area shows this
I used this code
[img]http://www.gti-roleplay.net/sign.php?u=1[/img]
Sorry for bad English!

SoLoGHoST

There are too many false logics that go on in that code... For example, that code creates an array, where there doesn't need to be one, when there is a LIMIT 1 on the database query and than uses a foreach loop (which doesn't make sense since we are dealing with 1 return value).  There are other things that make no sense when looking at that code.  What are you trying to do exactly??  Are you trying to put in a default signature if there is not a signature defined?

MiXailo

Lainaus käyttäjältä: SoLoGHoST - tammikuu 08, 2014, 01:15:02 IP
There are too many false logics that go on in that code... For example, that code creates an array, where there doesn't need to be one, when there is a LIMIT 1 on the database query and than uses a foreach loop (which doesn't make sense since we are dealing with 1 return value).  There are other things that make no sense when looking at that code.  What are you trying to do exactly??  Are you trying to put in a default signature if there is not a signature defined?
I found that code on this forum , link : http://www.simplemachines.org/community/index.php?topic=46408.msg1271553#msg1271553 . And I followed steps, and it won't work. Can you make your version of this code?

SoLoGHoST

No problem, give me a sec...  I see what you are doing...  But also, you should check to be sure you have the proper PHP Modules enabled, like GD, etc.  But if Image Attachments work for you than so should my code...

SoLoGHoST

#4
Here is a bit better of a sign.php.  As far as I know the third parameter of imagepng function takes a number from 0 - 9, where 9 is the smallest filesize, but takes the longest for PHP to render.  0 is the largest filesize and is fastest for PHP to render.  Whatever you choose, it doesn't change the quality of the PNG, as it will always have the same quality (unlike with JPEGs).  6 is the default value for this if not specified, which is what I did.  Removed the PHP version check as it is not needed.  Commented out next line down that will give you a smaller filesize, but takes longer to render.  Made queries more secure and just makes more sense now and direct!  Not sure why you are using $mommy variable... lol.  In any case also moved avatar up into that spot on the upper left-hand side for you.

<?php

if (file_exists(dirname(__FILE__) . '/SSI.php')) {
require(
dirname(__FILE__) . '/SSI.php');
}
else die();

getinfos();
signature();

function 
getinfos()
{
global $smcFunc$context$memberContext;

$mommy '';

if (!empty($_GET['u']))
$id_mem = isset($_GET['u']) ? (int) $_GET['u'] : die();
else die();

$result $smcFunc['db_query']('''
SELECT IFNULL(member_name, real_name) AS username, id_member
FROM {db_prefix}members
WHERE id_member = {int:id_member} AND is_activated = 1
LIMIT 1'
,
array(
'id_member' => (int) $id_mem,
)
);

if ($smcFunc['db_num_rows']($result) == 0)
die();

list ($member_name$id_member) = $smcFunc['db_fetch_row']($result);

$smcFunc['db_free_result']($result);

// $mprofile[] = (int) $id_mem;
loadMemberData(array($id_member), false'profile');
loadMemberContext($id_member);

$context['membername'] = $memberContext[$id_member]['name'];
$context['posts'] = $memberContext[$id_member]['posts'];
$context['gender'] = $memberContext[$id_member]['gender']['image'];
$context['karmaBad'] = $memberContext[$id_member]['karma']['bad'];
$context['karmaGood'] = $memberContext[$id_member]['karma']['good'];
$context['avatar'] = $memberContext[$id_member]['avatar']['href'];

if (!empty($context['avatar']))
{
$mommy = !empty($context['avatar']) ? $context['avatar'] : ''
$mommy preg_split('/;/',$mommy, -1PREG_SPLIT_OFFSET_CAPTURE);
$mommy $mommy [1][0];
$mommy trim(substr(strrchr($mommy'='), 1));

$result2 $smcFunc['db_query']('','
SELECT filename
FROM {db_prefix}attachments
WHERE id_attach = {int:mommy} AND attachment_type = 0 AND approved = 1
LIMIT 1'
,
array(
'mommy' => (int) $mommy,
)
);

list($count_result) = $smcFunc['db_fetch_row']($result2);

$context['filename_avatar'] = $count_result;
$smcFunc['db_free_result']($result2);
}
}
 

function 
signature()
{
global $context$settings$modSettings;

$lemo '';
$img_url $settings['default_theme_url']; 

$membername $context['membername'];
$posts $context['posts'];

if (!empty($context['filename_avatar'])) 
   $lemo $context['filename_avatar'];
else
   $lemo '';

$avatar $context['avatar'];
$gender $context['gender'];

if (preg_match'/Male/'$gender))
{
$gender "male";
$img_gender "$img_url/images/Male.gif";

elseif (preg_match'/Female/'$gender))
{
$gender "female";
$img_gender "$img_url/images/Female.gif";
}
else
$gender "n/a"$img_gender "$img_url/images/star.gif";

$karmaBad $context['karmaBad'];
$karmaGood $context['karmaGood'];

if ($modSettings['karmaMode'] == '1')  
$karma $karmaGood $karmaBad;
elseif ($modSettings['karmaMode'] == '2')
$karma '+'.$karmaGood.' / '.'-'.$karmaBad;
elseif ($modSettings['karmaMode'] == '0'
$karma 'n/a';

// Your settings +++++++++++++++++++++++++++++++++++ 
$backimg "$img_url/images/sign.png"// or where you want 
$noavatar "$img_url/images/noavatar.png"// or where you want
$set_avatar_height = -100//move avatar up/down
$set_avatar_width = -249//move avatar left/right
$set_gender_style 0// 0 text , 1 image
$set_gender_height = -92//move gender up/down
$set_gender_width = -230//move gender left/right
// Your settings +++++++++++++++++++++++++++++++++++

if (!empty($avatar)) {$avatar $avatar;}
else {$avatar $noavatar;}

if (!empty($lemo)) { $ext substr(strrchr($lemo'.'), 1); }
else {$ext substr(strrchr($avatar'.'), 1);}

unset($lemo);

if ($ext == 'png') {$img_bgr imagecreatefrompng($avatar); }
elseif ($ext == 'jpg') {$img_bgr imagecreatefromjpeg($avatar); }
elseif ($ext == 'gif') {$img_bgr imagecreatefromgif($avatar); }
else die();

$size getimagesize($backimg);

if ($set_gender_style == 1) {
$img_bgr_gender imagecreatefromgif($img_gender);
$image_width_gender imagesx($img_bgr_gender);  
$image_height_gender imagesy($img_bgr_gender);
$dest_x_gender $size[0] - $image_width_gender $set_gender_width;  
$dest_y_gender $size[1] - $image_height_gender $set_gender_height;
}

$image_width imagesx($img_bgr);  
$image_height imagesy($img_bgr);

//______________avatar  width & height must be <=106
if ($image_width <=106 && $image_width >=10 && $image_height <=106 && $image_height >=10)
{
$set_avatar_width =  $set_avatar_width + (($image_width 101) * 0.35);
$set_avatar_height =  $set_avatar_height + (($image_height 101) * 0.35);
}
else die();

$image imagecreatetruecolor($image_width$image_height); 
$image imagecreatefrompng($backimg);  

$dest_x $size[0] - $image_width $set_avatar_width;  
$dest_y $size[1] - $image_height $set_avatar_height
imagecopymerge($image$img_bgr,  $dest_x$dest_y00$image_width$image_height100);

if ($set_gender_style == 1)
imagecopymerge($image$img_bgr_gender,  $dest_x_gender$dest_y_gender00$image_width_gender$image_height_gender100);
 
$green imagecolorallocate($image2312417); 
$blue imagecolorallocate($image00255); 
$red imagecolorallocate($image25500);
$white imagecolorallocate($image255255255);
$black imagecolorallocate($image000);

imagestring($image42035"Postova: $posts"$black);
imagestring($image42051"Karma: $karma"$black);
if ($set_gender_style == 0)
{
imagestring($image5314"$membername"$black);
imagestring($image42066"Pol: $gender"$black);

else
imagestring($image5444"$membername"$black);

header("Content-Type: image/png");
header('Content-Disposition: inline; filename='.$membername);

        
imagepng($imageNULL);
// imagepng($image, null, 9, null);

imagedestroy($image);
imagedestroy($img_bgr);  
}


?>


Image Looks like this:

Source:  http://devs.dream-portal.net/smf206/sign.php?u=2

If this still does not work for you than, PHP Version would be kind of the next step in asking... though it should support PHP 4, not guaranteed to though.  Also, this uses the GD PHP Library Module, so you would need that installed in PHP.  This is usually installed by default on PHP, but you never know...

MiXailo

Lainaus käyttäjältä: SoLoGHoST - tammikuu 09, 2014, 03:28:00 IP
Here is a bit better of a sign.php.  As far as I know the third parameter of imagepng function takes a number from 0 - 9, where 9 is the smallest filesize, but takes the longest for PHP to render.  0 is the largest filesize and is fastest for PHP to render.  Whatever you choose, it doesn't change the quality of the PNG, as it will always have the same quality (unlike with JPEGs).  6 is the default value for this if not specified, which is what I did.  Removed the PHP version check as it is not needed.  Commented out next line down that will give you a smaller filesize, but takes longer to render.  Made queries more secure and just makes more sense now and direct!  Not sure why you are using $mommy variable... lol.  In any case also moved avatar up into that spot on the upper left-hand side for you.

<?php

if (file_exists(dirname(__FILE__) . '/SSI.php')) {
require(
dirname(__FILE__) . '/SSI.php');
}
else die();

getinfos();
signature();

function 
getinfos()
{
global $smcFunc$context$memberContext;

$mommy '';

if (!empty($_GET['u']))
$id_mem = isset($_GET['u']) ? (int) $_GET['u'] : die();
else die();

$result $smcFunc['db_query']('''
SELECT IFNULL(member_name, real_name) AS username, id_member
FROM {db_prefix}members
WHERE id_member = {int:id_member} AND is_activated = 1
LIMIT 1'
,
array(
'id_member' => (int) $id_mem,
)
);

if ($smcFunc['db_num_rows']($result) == 0)
die();

list ($member_name$id_member) = $smcFunc['db_fetch_row']($result);

$smcFunc['db_free_result']($result);

// $mprofile[] = (int) $id_mem;
loadMemberData(array($id_member), false'profile');
loadMemberContext($id_member);

$context['membername'] = $memberContext[$id_member]['name'];
$context['posts'] = $memberContext[$id_member]['posts'];
$context['gender'] = $memberContext[$id_member]['gender']['image'];
$context['karmaBad'] = $memberContext[$id_member]['karma']['bad'];
$context['karmaGood'] = $memberContext[$id_member]['karma']['good'];
$context['avatar'] = $memberContext[$id_member]['avatar']['href'];

if (!empty($context['avatar']))
{
$mommy = !empty($context['avatar']) ? $context['avatar'] : ''
$mommy preg_split('/;/',$mommy, -1PREG_SPLIT_OFFSET_CAPTURE);
$mommy $mommy [1][0];
$mommy trim(substr(strrchr($mommy'='), 1));

$result2 $smcFunc['db_query']('','
SELECT filename
FROM {db_prefix}attachments
WHERE id_attach = {int:mommy} AND attachment_type = 0 AND approved = 1
LIMIT 1'
,
array(
'mommy' => (int) $mommy,
)
);

list($count_result) = $smcFunc['db_fetch_row']($result2);

$context['filename_avatar'] = $count_result;
$smcFunc['db_free_result']($result2);
}
}
 

function 
signature()
{
global $context$settings$modSettings;

$lemo '';
$img_url $settings['default_theme_url']; 

$membername $context['membername'];
$posts $context['posts'];

if (!empty($context['filename_avatar'])) 
   $lemo $context['filename_avatar'];
else
   $lemo '';

$avatar $context['avatar'];
$gender $context['gender'];

if (preg_match'/Male/'$gender))
{
$gender "male";
$img_gender "$img_url/images/Male.gif";

elseif (preg_match'/Female/'$gender))
{
$gender "female";
$img_gender "$img_url/images/Female.gif";
}
else
$gender "n/a"$img_gender "$img_url/images/star.gif";

$karmaBad $context['karmaBad'];
$karmaGood $context['karmaGood'];

if ($modSettings['karmaMode'] == '1')  
$karma $karmaGood $karmaBad;
elseif ($modSettings['karmaMode'] == '2')
$karma '+'.$karmaGood.' / '.'-'.$karmaBad;
elseif ($modSettings['karmaMode'] == '0'
$karma 'n/a';

// Your settings +++++++++++++++++++++++++++++++++++ 
$backimg "$img_url/images/sign.png"// or where you want 
$noavatar "$img_url/images/noavatar.png"// or where you want
$set_avatar_height = -100//move avatar up/down
$set_avatar_width = -249//move avatar left/right
$set_gender_style 0// 0 text , 1 image
$set_gender_height = -92//move gender up/down
$set_gender_width = -230//move gender left/right
// Your settings +++++++++++++++++++++++++++++++++++

if (!empty($avatar)) {$avatar $avatar;}
else {$avatar $noavatar;}

if (!empty($lemo)) { $ext substr(strrchr($lemo'.'), 1); }
else {$ext substr(strrchr($avatar'.'), 1);}

unset($lemo);

if ($ext == 'png') {$img_bgr imagecreatefrompng($avatar); }
elseif ($ext == 'jpg') {$img_bgr imagecreatefromjpeg($avatar); }
elseif ($ext == 'gif') {$img_bgr imagecreatefromgif($avatar); }
else die();

$size getimagesize($backimg);

if ($set_gender_style == 1) {
$img_bgr_gender imagecreatefromgif($img_gender);
$image_width_gender imagesx($img_bgr_gender);  
$image_height_gender imagesy($img_bgr_gender);
$dest_x_gender $size[0] - $image_width_gender $set_gender_width;  
$dest_y_gender $size[1] - $image_height_gender $set_gender_height;
}

$image_width imagesx($img_bgr);  
$image_height imagesy($img_bgr);

//______________avatar  width & height must be <=106
if ($image_width <=106 && $image_width >=10 && $image_height <=106 && $image_height >=10)
{
$set_avatar_width =  $set_avatar_width + (($image_width 101) * 0.35);
$set_avatar_height =  $set_avatar_height + (($image_height 101) * 0.35);
}
else die();

$image imagecreatetruecolor($image_width$image_height); 
$image imagecreatefrompng($backimg);  

$dest_x $size[0] - $image_width $set_avatar_width;  
$dest_y $size[1] - $image_height $set_avatar_height
imagecopymerge($image$img_bgr,  $dest_x$dest_y00$image_width$image_height100);

if ($set_gender_style == 1)
imagecopymerge($image$img_bgr_gender,  $dest_x_gender$dest_y_gender00$image_width_gender$image_height_gender100);
 
$green imagecolorallocate($image2312417); 
$blue imagecolorallocate($image00255); 
$red imagecolorallocate($image25500);
$white imagecolorallocate($image255255255);
$black imagecolorallocate($image000);

imagestring($image42035"Postova: $posts"$black);
imagestring($image42051"Karma: $karma"$black);
if ($set_gender_style == 0)
{
imagestring($image5314"$membername"$black);
imagestring($image42066"Pol: $gender"$black);

else
imagestring($image5444"$membername"$black);

header("Content-Type: image/png");
header('Content-Disposition: inline; filename='.$membername);

        
imagepng($imageNULL);
// imagepng($image, null, 9, null);

imagedestroy($image);
imagedestroy($img_bgr);  
}


?>


Image Looks like this:

Source:  http://devs.dream-portal.net/smf206/sign.php?u=2 [nofollow]

If this still does not work for you than, PHP Version would be kind of the next step in asking... though it should support PHP 4, not guaranteed to though.  Also, this uses the GD PHP Library Module, so you would need that installed in PHP.  This is usually installed by default on PHP, but you never know...
It won't work, again!  >:( >:( >:( >:( >:(
I have installed PHP 5.3.27. I checked GD, in php info and it's installed.
I have screenshot of screen. It shows me blank page.

I tried on localhost and shows this errors:

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in D:\Xampp\htdocs\Sources\Load.php(183) : runtime-created function on line 3

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in D:\Xampp\htdocs\Sources\Load.php(183) : runtime-created function on line 3
п»ї
Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in D:\Xampp\htdocs\Sources\Subs.php on line 2513

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in D:\Xampp\htdocs\Sources\Load.php(183) : runtime-created function on line 3

Notice: Undefined offset: 1 in D:\Xampp\htdocs\sign.php on line 52

SoLoGHoST

#6
Use this code instead.  The $mommy variable is not needed and $lemo is misleading and that seems to be your main problem.  The code was creating a lot of variables in different spots causing confusion... so didn't bother to edit it, but after looking at it, lol, seems that the variables $mommy and $lemo, creating an $context variable additionally for this... was not needed... so removed it all.  No preg_split even needed for this as I originally thought.

<?php

if (file_exists(dirname(__FILE__) . '/SSI.php')) {
require(
dirname(__FILE__) . '/SSI.php');
}
else die();

getinfos();
signature();

function 
getinfos()
{
global $smcFunc$context$memberContext;

if (!empty($_GET['u']))
$id_mem = (int) $_GET['u'];
else die();

$result $smcFunc['db_query']('''
SELECT IFNULL(member_name, real_name) AS username, id_member
FROM {db_prefix}members
WHERE id_member = {int:id_member} AND is_activated = 1
LIMIT 1'
,
array(
'id_member' => (int) $id_mem,
)
);

if ($smcFunc['db_num_rows']($result) == 0)
die();

list ($member_name$id_member) = $smcFunc['db_fetch_row']($result);

$smcFunc['db_free_result']($result);

loadMemberData(array($id_member), false'profile');
loadMemberContext($id_member);

$context['membername'] = $memberContext[$id_member]['name'];
$context['posts'] = $memberContext[$id_member]['posts'];
$context['gender'] = $memberContext[$id_member]['gender']['image'];
$context['karmaBad'] = $memberContext[$id_member]['karma']['bad'];
$context['karmaGood'] = $memberContext[$id_member]['karma']['good'];
$context['avatar'] = $memberContext[$id_member]['avatar']['href'];
}
 

function 
signature()
{
global $context$settings$modSettings;

$img_url $settings['default_theme_url']; 

$membername $context['membername'];
$posts $context['posts'];
$gender $context['gender'];

if (preg_match'/Male/'$gender))
{
$gender "male";
$img_gender "$img_url/images/Male.gif";

elseif (preg_match'/Female/'$gender))
{
$gender "female";
$img_gender "$img_url/images/Female.gif";
}
else
$gender "n/a";

$img_gender "$img_url/images/star.gif";
$karmaBad $context['karmaBad'];
$karmaGood $context['karmaGood'];

if ($modSettings['karmaMode'] == '1')  
$karma $karmaGood $karmaBad;
elseif ($modSettings['karmaMode'] == '2')
$karma '+'.$karmaGood.' / '.'-'.$karmaBad;
elseif ($modSettings['karmaMode'] == '0'
$karma 'n/a';

// Your settings +++++++++++++++++++++++++++++++++++ 
$backimg "$img_url/images/sign.png"// or where you want 
$noavatar "$img_url/images/noavatar.png"// or where you want
$set_avatar_height = -100//move avatar up/down
$set_avatar_width = -249//move avatar left/right
$set_gender_style 0// 0 text , 1 image
$set_gender_height = -92//move gender up/down
$set_gender_width = -230//move gender left/right
// Your settings +++++++++++++++++++++++++++++++++++

$avatar = !empty($context['avatar']) ? $context['avatar'] : $noavatar;
$ext substr(strrchr($avatar'.'), 1);

if ($ext == 'png') { $img_bgr imagecreatefrompng($avatar); }
elseif ($ext == 'jpg') { $img_bgr imagecreatefromjpeg($avatar); }
elseif ($ext == 'gif') { $img_bgr imagecreatefromgif($avatar); }
else die();

$size getimagesize($backimg);

if ($set_gender_style == 1) {
$img_bgr_gender imagecreatefromgif($img_gender);
$image_width_gender imagesx($img_bgr_gender);  
$image_height_gender imagesy($img_bgr_gender);
$dest_x_gender $size[0] - $image_width_gender $set_gender_width;  
$dest_y_gender $size[1] - $image_height_gender $set_gender_height;
}

$image_width imagesx($img_bgr);  
$image_height imagesy($img_bgr);

//______________avatar  width & height must be <=106
if ($image_width <=106 && $image_width >=10 && $image_height <=106 && $image_height >=10)
{
$set_avatar_width =  $set_avatar_width + (($image_width 101) * 0.35);
$set_avatar_height =  $set_avatar_height + (($image_height 101) * 0.35);
}
else die();

$image imagecreatetruecolor($image_width$image_height); 
$image imagecreatefrompng($backimg);  

$dest_x $size[0] - $image_width $set_avatar_width;  
$dest_y $size[1] - $image_height $set_avatar_height
imagecopymerge($image$img_bgr,  $dest_x$dest_y00$image_width$image_height100);

if ($set_gender_style == 1)
imagecopymerge($image$img_bgr_gender,  $dest_x_gender$dest_y_gender00$image_width_gender$image_height_gender100);
 
$green imagecolorallocate($image2312417); 
$blue imagecolorallocate($image00255); 
$red imagecolorallocate($image25500);
$white imagecolorallocate($image255255255);
$black imagecolorallocate($image000);

imagestring($image42035"Postova: $posts"$black);
imagestring($image42051"Karma: $karma"$black);
if ($set_gender_style == 0)
{
imagestring($image5314"$membername"$black);
imagestring($image42066"Pol: $gender"$black);

else
imagestring($image5444"$membername"$black);

header("Content-Type: image/png");
header('Content-Disposition: inline; filename='.$membername);

imagepng($imageNULL);
imagedestroy($image);
imagedestroy($img_bgr);  
}


?>


Just a bunch of sloppy code to go through and fix.  But this should do it for you.  Let me know how it goes and try testing this on a live server also before you disregard it as not working.  XAMMP and Live Server are 2 different things.

Arantor

I'd also love to know why you're getting PHP 5.5 errors on 5.3.27 (preg deprecating /e only happened in 5.5)
Holder of controversial views, all of which my own.


MiXailo

Lainaus käyttäjältä: Sir Cumber-Patcher - tammikuu 12, 2014, 02:10:30 AP
I'd also love to know why you're getting PHP 5.5 errors on 5.3.27 (preg deprecating /e only happened in 5.5)
I got errors on localhost. Now on live server I got this
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.

Apache/2.2.26 (Unix) mod_ssl/2.2.26 OpenSSL/0.9.8e-fips-rhel5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635 mod_qos/10.10 mod_perl/2.0.6 Perl/v5.8.8 Server at gti-roleplay.net Port 80

When I type URL:
http://gti-roleplay.net/sign.php?u=1

SoLoGHoST

Looks like there are other issues with your server.  Did you check the error log?  Should be located in your SMF Root where sign.php is I would think.  Check out your error log and let us know what that says maybe.

MiXailo

Lainaus käyttäjältä: SoLoGHoST - tammikuu 12, 2014, 07:57:08 IP
Looks like there are other issues with your server.  Did you check the error log?  Should be located in your SMF Root where sign.php is I would think.  Check out your error log and let us know what that says maybe.
I opened error log in cPanel, and I found line where it says:
[Mon Jan 13 16:20:01 2014] [error] [client 46.217.30.23] SoftException in Application.cpp:256: File "/home/gtirolep/public_html/sign.php" is writeable by group, referer: http://www.balkan-smf.com/forum/index.php?topic=8947.0
On SMF error log where is ssi and sign.php I found this:
[11-Jan-2014 17:03:44 Europe/Belgrade] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/gtirolep/public_html/sign.php:1) in /home/gtirolep/public_html/Sources/Subs.php on line 3386
[11-Jan-2014 17:03:44 Europe/Belgrade] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/gtirolep/public_html/sign.php:1) in /home/gtirolep/public_html/Sources/Subs.php on line 3387
[11-Jan-2014 17:03:44 Europe/Belgrade] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/gtirolep/public_html/sign.php:1) in /home/gtirolep/public_html/Sources/Subs.php on line 3393
[11-Jan-2014 17:03:44 Europe/Belgrade] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/gtirolep/public_html/sign.php:1) in /home/gtirolep/public_html/Sources/Subs.php on line 3396
[11-Jan-2014 17:04:00 Europe/Belgrade] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/gtirolep/public_html/sign.php:1) in /home/gtirolep/public_html/Sources/Subs.php on line 3386
[11-Jan-2014 17:04:00 Europe/Belgrade] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/gtirolep/public_html/sign.php:1) in /home/gtirolep/public_html/Sources/Subs.php on line 3387
[11-Jan-2014 17:04:00 Europe/Belgrade] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/gtirolep/public_html/sign.php:1) in /home/gtirolep/public_html/Sources/Subs.php on line 3393
[11-Jan-2014 17:04:00 Europe/Belgrade] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/gtirolep/public_html/sign.php:1) in /home/gtirolep/public_html/Sources/Subs.php on line 3396
[11-Jan-2014 17:05:25 Europe/Belgrade] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/gtirolep/public_html/sign.php:1) in /home/gtirolep/public_html/Sources/Subs.php on line 3386
[11-Jan-2014 17:05:25 Europe/Belgrade] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/gtirolep/public_html/sign.php:1) in /home/gtirolep/public_html/Sources/Subs.php on line 3387
[11-Jan-2014 17:05:25 Europe/Belgrade] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/gtirolep/public_html/sign.php:1) in /home/gtirolep/public_html/Sources/Subs.php on line 3393
[11-Jan-2014 17:05:25 Europe/Belgrade] PHP Warning:  Cannot modify header information - headers already sent by (output started at /home/gtirolep/public_html/sign.php:1) in /home/gtirolep/public_html/Sources/Subs.php on line 3396


SoLoGHoST

Have a look here:  http://joshhighland.com/blog/2009/01/18/troubleshooting-softexception-in-applicationcpp544/

and here:  https://www.jamit.com.au/support/index.php?_m=knowledgebase&_a=viewarticle&kbarticleid=233

In short, try chmodding your sign.php file differently.  If if is at 777, change it to 755 and try it again.  If that doesn't work, try changing it to the same file permissions as Settings.php.

Arantor

Um, it's kind of clear what the first problem is: the file permissions are too high as per the error message (writeable by group)
Holder of controversial views, all of which my own.


MiXailo

It works !! On localhost and freehost(000webhost) it works but on paid it didn't works.  Big big big thank YOU!!

Advertisement: