• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[Gesior AAC] Improved Signatures (now with cache!!!)

Status
Not open for further replies.

Chris

Inactive
Senator
Joined
Aug 11, 2008
Messages
2,628
Solutions
2
Reaction score
240
Hey guys.
I'm certain that some of you are using my old signature script, and some of you may also be aware of the fact that I improved the API a lot and released it in the Web development Resources department. What I did not do, however, is a finished product for Gesiors AAC. Hence, this topic.

Why should we use the improved signatures over the previous ones?
For several reasons, to be honest. In this new version, you will be able to disable the signature for every single character. If you wish to use the signature however, you may still disable certain parts of it (showing health/mana/experience bars and showing equipments are not required). You may also change the background. All of this can be accessed and altered through the account management page.

If, lets say, a character posses a helmet which you have no image of - the script will automatically attempt to create it and store it within the images folder. This may cause a bit of extra time for the signature to be loaded, but not to fear! This would only happen the first time the item was created, and eventually all (most, at least) of the lag would disappear.

Okay, sounds valid. Now how do I install it?
Well.. first of all I would like to add that you should always keep the data files (located within the data/ folder) up to date. Which are the Tibia.spr, Tibia.dat and items.otb files. Those files are required to make the image creation script properly function.

That being said, you may carry on by following these steps.


Step 1:
Download and extract the .RAR package within your htdocs/www folder (it is strongly advisable to remove the old signature system before installing the new one).

Step 2:
Go to your phpMyAdmin (or any other tool that you may be using) and access your main database. Run this piece of code:
Code:
ALTER TABLE `players` ADD `madphp_signature` TINYINT( 4 ) NOT NULL DEFAULT '1' COMMENT 'Absolute Mango © MadPHP.org', ADD `madphp_signature_bg` VARCHAR( 50 ) NOT NULL COMMENT 'Absolute Mango © MadPHP.org' AFTER `madphp_signature`, ADD `madphp_signature_eqs` TINYINT( 4 ) NOT NULL DEFAULT '0' COMMENT 'Absolute Mango © MadPHP.org' AFTER `madphp_signature_bg`, ADD `madphp_signature_bars` TINYINT( 4 ) NOT NULL DEFAULT '1' COMMENT 'Absolute Mango © MadPHP.org' AFTER `madphp_signature_eqs`, ADD `madphp_signature_cache` INT( 11 ) NOT NULL COMMENT 'Absolute Mango © MadPHP.org' AFTER `madphp_signature_bars`;
Step 3:
Open up your accountmanagement.php file and locate this line:
PHP:
$new_hideacc = (int) $_POST['accountvisible'];
Below it, paste this:
PHP:
// MadPHP.org Signature
$madphp_signature      = (int) $_POST['madphp_signature'];
$madphp_signature_bg   = htmlspecialchars(stripslashes(trim( $_POST['madphp_signature_bg'] )));
$madphp_signature_bars = (int) $_POST['madphp_signature_bars'];
$madphp_signature_eqs  = (int) $_POST['madphp_signature_eqs'];
// MadPHP.org Signature
Now, locate this line a few lines further down.
PHP:
$player->setCustomField("comment", $new_comment);
Below it, paste this:
PHP:
// MadPHP.org Signature
$player->setCustomField( 'madphp_signature', $madphp_signature );
if ( $madphp_signature == 1 ) {
    $player->setCustomField( 'madphp_signature_bg', $madphp_signature_bg );
    $player->setCustomField( 'madphp_signature_bars', $madphp_signature_bars );
    $player->setCustomField( 'madphp_signature_eqs', $madphp_signature_eqs );
}
// MadPHP.org Signature
Yet again, a few more lines further down you will find these lines:
PHP:
$main_content .= 'Here you can see and edit the information about your character.<br/>If you do not want to specify a certain field, just leave it blank.<br/><br/><form action="?subtopic=accountmanagement&action=changecomment" method="post" ><div class="TableContainer" >  <table class="Table5" cellpadding="0" cellspacing="0" >    <div class="CaptionContainer" >      <div class="CaptionInnerContainer" >        <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Edit Character Information</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>      </div>    </div>    <tr>      <td>        <div class="InnerTableContainer" >          <table style="width:100%;" ><tr><td><div class="TableShadowContainerRightTop" >  <div class="TableShadowRightTop" style="background-image:url('.$layout_name.'/images/content/table-shadow-rt.gif);" ></div></div><div class="TableContentAndRightShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-rm.gif);" >  <div class="TableContentContainer" >    <table class="TableContent" width="100%" ><tr><td class="LabelV" >Name:</td><td style="width:80%;" >'.$player_name.'</td></tr><tr><td class="LabelV" >Hide Account:</td><td>';
if($player->getCustomField("hide_char") == 1) {
    $main_content .= '<input type="checkbox" name="accountvisible"  value="1" checked="checked">';
}
else
{
    $main_content .= '<input type="checkbox" name="accountvisible"  value="1" >';
}
$main_content .= ' check to hide your account information</td></tr>    </table>  </div></div><div class="TableShadowContainer" >  <div class="TableBottomShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-bm.gif);" >    <div class="TableBottomLeftShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-bl.gif);" ></div>    <div class="TableBottomRightShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-br.gif);" ></div>  </div></div></td></tr><tr><td><div class="TableShadowContainerRightTop" >  <div class="TableShadowRightTop" style="background-image:url('.$layout_name.'/images/content/table-shadow-rt.gif);" ></div></div><div class="TableContentAndRightShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-rm.gif);" >  <div class="TableContentContainer" >    <table class="TableContent" width="100%" ><tr><td class="LabelV" ><span >Comment:</span></td><td style="width:80%;" ><textarea name="comment" rows="10" cols="50" wrap="virtual" >'.$player->getCustomField("comment").'</textarea><br>[max. length: 2000 chars, 50 lines (ENTERs)]</td></tr>    </table>  </div></div><div class="TableShadowContainer" >  <div class="TableBottomShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-bm.gif);" ><div class="TableBottomLeftShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-bl.gif);" ></div><div class="TableBottomRightShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-br.gif);" ></div></div></div></td></tr></td></tr>          </table>        </div>  </table></div></td></tr><br/><table style="width:100%" ><tr align="center" ><td><table border="0" cellspacing="0" cellpadding="0" ><tr><td style="border:0px;" ><input type="hidden" name="name" value="'.$player->getName().'"><input type="hidden" name="changecommentsave" value="1"><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/buttons/_sbutton_submit.gif" ></div></div></td><tr></form></table></td><td><table border="0" cellspacing="0" cellpadding="0" ><form action="?subtopic=accountmanagement" method="post" ><tr><td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/buttons/_sbutton_back.gif" ></div></div></td></tr></form></table></td></tr></table>';
Replace them with:
PHP:
$main_content .= 'Here you can see and edit the information about your character.<br/>If you do not want to specify a certain field, just leave it blank.<br/><br/><form action="?subtopic=accountmanagement&action=changecomment" method="post" ><div class="TableContainer" >  <table class="Table5" cellpadding="0" cellspacing="0" >    <div class="CaptionContainer" >      <div class="CaptionInnerContainer" >        <span class="CaptionEdgeLeftTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightTop" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionBorderTop" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionVerticalLeft" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <div class="Text" >Edit Character Information</div>        <span class="CaptionVerticalRight" style="background-image:url('.$layout_name.'/images/content/box-frame-vertical.gif);" /></span>        <span class="CaptionBorderBottom" style="background-image:url('.$layout_name.'/images/content/table-headline-border.gif);" ></span>        <span class="CaptionEdgeLeftBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>        <span class="CaptionEdgeRightBottom" style="background-image:url('.$layout_name.'/images/content/box-frame-edge.gif);" /></span>      </div>    </div>    <tr>      <td>        <div class="InnerTableContainer" >          <table style="width:100%;" ><tr><td><div class="TableShadowContainerRightTop" >  <div class="TableShadowRightTop" style="background-image:url('.$layout_name.'/images/content/table-shadow-rt.gif);" ></div></div><div class="TableContentAndRightShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-rm.gif);" >  <div class="TableContentContainer" >    <table class="TableContent" width="100%" ><tr><td class="LabelV" >Name:</td><td style="width:80%;" >'.$player_name.'</td></tr><tr><td class="LabelV" >Hide Account:</td><td>';
if($player->getCustomField("hide_char") == 1) {
    $main_content .= '<input type="checkbox" name="accountvisible"  value="1" checked="checked">';
}
else
{
    $main_content .= '<input type="checkbox" name="accountvisible"  value="1" >';
}
$main_content .= ' check to hide your account information</td></tr>';
$main_content .= '</table>  </div></div><div class="TableShadowContainer" >  <div class="TableBottomShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-bm.gif);" >    <div class="TableBottomLeftShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-bl.gif);" ></div>    <div class="TableBottomRightShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-br.gif);" ></div>  </div></div></td></tr><tr><td><div class="TableShadowContainerRightTop" >  <div class="TableShadowRightTop" style="background-image:url('.$layout_name.'/images/content/table-shadow-rt.gif);" ></div></div>';

// MadPHP.org Signature
$main_content .= '<div class="TableContentAndRightShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-rm.gif);" >  <div class="TableContentContainer" >    <table class="TableContent" width="100%" >';
$main_content .= '<tr><td class="LabelV">Enable Signature</td><td style="width:80%;">';
    $main_content .= '<input type="checkbox" id="madphp_signature" name="madphp_signature" value="1"'.( $player->getCustomField( 'madphp_signature' ) == 1 ? ' checked="checked"' : null ).' /> untick to disable the signature of this character</td></tr>';
$main_content .= '<tr><td class="LabelV">Background</td><td style="width:80%;">';
    $main_content .= '<select name="madphp_signature_bg">';
    foreach( scandir( 'signatures/backgrounds/' ) as $background )
    {
        if ( !in_array( $background, array( '.', '..' ) ) )
        {
            $extension = end( explode( '.', $background ) );
            if ( in_array( strtolower( $extension ), array ( 'png', 'jpeg', 'jpg', 'gif' ) ) )
            {
                $main_content .= '<option value="'.strtolower( $background ).'"'.( $player->getCustomField( 'madphp_signature_bg' ) == strtolower( $background ) ? ' selected="selected"' : null ).'>'.ucwords( $background ).'</option>';
            }
        }
    }
    $main_content .= '</select> pick the background you prefer the most</td></tr>';
$main_content .= '<tr><td class="LabelV">Hide Bars</td><td style="width:80%;">';
    $main_content .= '<input type="checkbox" id="madphp_signature_bars" name="madphp_signature_bars" value="1"'.( $player->getCustomField( 'madphp_signature_bars' ) == 1 ? ' checked="checked"' : null ).' /> tick to hide the information bars</td></tr>';
$main_content .= '<tr><td class="LabelV">Hide Equipments</td><td style="width:80%;">';
    $main_content .= '<input type="checkbox" id="madphp_signature_eqs"  name="madphp_signature_eqs"  value="1"'.( $player->getCustomField( 'madphp_signature_eqs' )  == 1 ? ' checked="checked"' : null ).' /> tick to hide the equipments</td></tr>';
// MadPHP.org Signature

$main_content .= '</table>  </div></div><div class="TableShadowContainer" >  <div class="TableBottomShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-bm.gif);" >    <div class="TableBottomLeftShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-bl.gif);" ></div>    <div class="TableBottomRightShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-br.gif);" ></div>  </div></div></td></tr><tr><td><div class="TableShadowContainerRightTop" >  <div class="TableShadowRightTop" style="background-image:url('.$layout_name.'/images/content/table-shadow-rt.gif);" ></div></div>';
$main_content .= '<div class="TableContentAndRightShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-rm.gif);" >  <div class="TableContentContainer" >    <table class="TableContent" width="100%" ><tr><td class="LabelV" ><span >Comment:</span></td><td style="width:80%;" ><textarea name="comment" rows="10" cols="50" wrap="virtual" >'.$player->getCustomField("comment").'</textarea><br>[max. length: 2000 chars, 50 lines (ENTERs)]</td></tr>    </table>  </div></div><div class="TableShadowContainer" >  <div class="TableBottomShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-bm.gif);" ><div class="TableBottomLeftShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-bl.gif);" ></div><div class="TableBottomRightShadow" style="background-image:url('.$layout_name.'/images/content/table-shadow-br.gif);" ></div></div></div></td></tr></td></tr>          </table>        </div>  </table></div></td></tr><br/><table style="width:100%" ><tr align="center" ><td><table border="0" cellspacing="0" cellpadding="0" ><tr><td style="border:0px;" ><input type="hidden" name="name" value="'.$player->getName().'"><input type="hidden" name="changecommentsave" value="1"><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Submit" alt="Submit" src="'.$layout_name.'/images/buttons/_sbutton_submit.gif" ></div></div></td><tr></form></table></td><td><table border="0" cellspacing="0" cellpadding="0" ><form action="?subtopic=accountmanagement" method="post" ><tr><td style="border:0px;" ><div class="BigButton" style="background-image:url('.$layout_name.'/images/buttons/sbutton.gif)" ><div onMouseOver="MouseOverBigButton(this);" onMouseOut="MouseOutBigButton(this);" ><div class="BigButtonOver" style="background-image:url('.$layout_name.'/images/buttons/sbutton_over.gif);" ></div><input class="ButtonText" type="image" name="Back" alt="Back" src="'.$layout_name.'/images/buttons/_sbutton_back.gif" ></div></div></td></tr></form></table></td></tr></table>';
Step 4:
Open up your characters.php file, and find this line:
PHP:
if(!empty($comment))
{
    if(is_int($number_of_rows / 2)) { $bgcolor = $config['site']['darkborder']; } else { $bgcolor = $config['site']['lightborder']; } $number_of_rows++;
    $main_content .= '<TR BGCOLOR="'.$bgcolor.'"><TD VALIGN=top>Comment:</TD><TD>'.$comment.'</TD></TR>';
}
}
Below it, paste this:
PHP:
// MadPHP.org Signature
if ( $player->getCustomField( 'madphp_signature' ) == 1 )
{
    $main_content .= '<br><TABLE BORDER=0><TR><TD></TD></TR></TABLE><TABLE BORDER=0 CELLSPACING=1 CELLPADDING=4 WIDTH=100%><TR BGCOLOR='.$config['site']['vdarkborder'].'><TD COLSPAN=2 CLASS=white><B>Signature</B></TD></TR>';
    $main_content .= "<TR BGCOLOR=".$config['site']['darkborder']."><TD WIDTH=20%>Forum Link:</TD><TD><input type='text' size='75' onclick='this.select();' value='[url=\"http://" . $_SERVER['HTTP_HOST'] . "\"][IMG]http://" . $_SERVER['HTTP_HOST'] . "/signature.php?character=" .$player->getName(). "[/IMG][/url]' /></TD></TR>";
    $main_content .= "<TR BGCOLOR=".$config['site']['lightborder']."><TD WIDTH=20%>Direct Link:</TD><TD><input type='text' size='75' onclick='this.select();' value='http://" . $_SERVER['HTTP_HOST'] . "/signature.php?character=" .$player->getName(). "' /></TD></TR>";
    $main_content .= "<TR BGCOLOR=".$config['site']['darkborder']."><TD COLSPAN='2' style='text-align: center;'><img src='signature.php?character=" .$player->getName(). "' alt='' /></TD></TR>";
    $main_content .= '</TD></TR></TABLE>';
}
// MadPHP.org Signature
That should be it, if I managed to miss anything or you just can't get it to work - please let me know!


If you're wondering why there's a picture of a bag inside the items folder, that is due to the simple fact that the item creator did not succeed in creating a bag for some odd reason I have yet to discover. If, you would encounter the same issue with another sprite, just download the sprite from tibia wikia and override the existing black image in your items folder.


DOWNLOAD: Signature.rar

PREVIEW:
126507116782.png


126512538882.png


126512541521.png


PS. I did not create the sprite creation script, NMagus did. What is worth mentioning though, is that I rewrote the entire script to clean it up a bit, and also added some slight modifications to it, to support the usage of it within my GD API etc.
 
Last edited:
Preview added to the main post.
 
Tibia.spr, Tibia.dat and items.otb are there so the item creation script will function properly. Lets say your character has moon backpack, and you don't have an image of the moon backpack. The image creation script will then read the .dat, the .spr and the .otb files to create an image of the moon backpack. This way, you won't have any problems with missing images.
 
Parse error: syntax error, unexpected T_ELSE in C:\xampp\htdocs\accountmanagement.php on line 490
pffffffffffff =/
 
that hapends when I try to login on the page help ¬¬
 
What is this wrong functions
PHP:
					/** Merital Status **/
					if ( $player->getMarriage() != null )
					{
						$MadGD->addText( 'Marital status:', $MadGD->textBold )->setPosition( 17, $i * $eachRow );
						$MadGD->addText( 'married to '.$player->getMarriage()->getName() )->setPosition( ); $i++;
					}
 
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'madphp_signature_bars' in 'field list'' in D:\Program Files\paki\xampp\htdocs\server\pot\OTS_Player.php:1811 Stack trace: #0 D:\Program Files\paki\xampp\htdocs\server\pot\OTS_Player.php(1811): PDO->query('SELECT `madphp_...') #1 D:\Program Files\paki\xampp\htdocs\server\signature.php(42): OTS_Player->getCustomField('madphp_signatur...') #2 {main} thrown in D:\Program Files\paki\xampp\htdocs\server\pot\OTS_Player.php on line 1811

;(
 
Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE[42S22]: Column not found: 1054 Unknown column 'madphp_signature_bars' in 'field list'' in D:\Program Files\paki\xampp\htdocs\server\pot\OTS_Player.php:1811 Stack trace: #0 D:\Program Files\paki\xampp\htdocs\server\pot\OTS_Player.php(1811): PDO->query('SELECT `madphp_...') #1 D:\Program Files\paki\xampp\htdocs\server\signature.php(42): OTS_Player->getCustomField('madphp_signatur...') #2 {main} thrown in D:\Program Files\paki\xampp\htdocs\server\pot\OTS_Player.php on line 1811

;(
You must add this:
ALTER TABLE `players` ADD `madphp_signature` TINYINT( 4 ) NOT NULL DEFAULT '1' COMMENT 'Absolute Mango © MadPHP.org', ADD `madphp_signature_bg` VARCHAR( 50 ) NOT NULL COMMENT 'Absolute Mango © MadPHP.org' AFTER `madphp_signature`, ADD `madphp_signature_eqs` TINYINT( 4 ) NOT NULL DEFAULT '0' COMMENT 'Absolute Mango © MadPHP.org' AFTER `madphp_signature_bg`, ADD `madphp_signature_bars` TINYINT( 4 ) NOT NULL DEFAULT '1' COMMENT 'Absolute Mango © MadPHP.org' AFTER `madphp_signature_eqs`;
in base mysql
 
o thx..

Warning: Cannot modify header information - headers already sent by (output started at D:\Program Files\paki\xampp\htdocs\server\config-and-functions.php:486) in D:\Program Files\paki\xampp\htdocs\server\signatures\gd.class.php on line 203..??;/
 
nice o_O
so now I can write script loading itenm image for character section from .spr
nice, but slow I guess ;d
 
Redbull915 are you in state assistance?

Warning: Cannot modify header information - headers already sent by (output started at D:\Program Files\paki\xampp\htdocs\server\config-and-functions.php:486) in D:\Program Files\paki\xampp\htdocs\server\signatures\gd.class .php on line 203..??;/
 
Redbull915 are you in state assistance?

Warning: Cannot modify header information - headers already sent by (output started at D:\Program Files\paki\xampp\htdocs\server\config-and-functions.php:486) in D:\Program Files\paki\xampp\htdocs\server\signatures\gd.class .php on line 203..??;/

mayby this help you but i don't know more from this script
PHP:
		public function display( $path = false )
		{
			if ( !$this->testMode )
			{
				header( 'Content-Type: image/png' );
				if ( !$path )
				{
					imagepng( $this->instance, '', 9 );
				}
				else
				{
					imagepng( $this->instance, $path, 9 );
				}
				imagedestroy( $this->instance );
				unset( $this );
			}
		}
 
gd.class

PHP:
<?PHP

	/**
	 * @author Christopher Eklund
	 * @copyright MadPHP.org 2009
	 * @version 2.4.5
	**/
	class MadGD
	{
		public $textConfig = array( 'font' => 2, 'size' => 9, 'color' => 'FFFFFF', 'shadow' => true );
		public $textBold   = array( 'font' => 3, 'size' => 9, 'color' => 'FFFFFF', 'shadow' => true );
		public $testMode   = false;
		public $background = null;
		public $extension  = null;
		public $instance   = null;
		
		public $equipment  = array( 
			'pos' => array(
				'x' => 339,
				'y' => 3
			),
			'x' => array( ),
			'y' => array( )
		);

		public $x = 0;
		public $y = 0;
		public $l = 0;

		
		/**
		 * @access public
		 * @return null
		**/
		public function __construct( $path = null )
		{
			if ( $path != null )
			{
				$this->setBackground( $path );
			}
			$this->setEquipments( );
		}
		
		
		/**
		 * @access public
		 * @return null
		**/
		private function setEquipments( )
		{
			$equipments = array(
				'amulet'     => array( 1, 15 ),
				'helmet'     => array( 38, 1 ),
				'backpack'   => array( 76, 15 ),
				'lefthand'   => array( 1, 52 ),
				'armor'      => array( 38, 38 ),
				'righthand'  => array( 75, 52 ),
				'ring'       => array( 1, 89 ),
				'legs'       => array( 38, 75 ),
				'ammunition' => array( 75, 89 ),
				'boots'      => array( 38, 112 )
			);
			
			foreach( $equipments as $eq => $positions )
			{
				$this->equipment['x'][$eq] = $this->equipment['pos']['x'] + $positions[0];
				$this->equipment['y'][$eq] = $this->equipment['pos']['y'] + $positions[1];
			}
		}
		
		
		/**
		 * @param string $path
		 * @access public
		 * @return instance
		**/
		public function setBackground( $path )
		{
			$this->background = $path;
			$this->extension  = strtolower( pathinfo( $path, PATHINFO_EXTENSION ) );

			switch( $this->extension )
			{
				case MADGD_PNG:
					$this->instance = imagecreatefrompng( $this->background );
					break;

				case MADGD_GIF:
					$this->instance = imagecreatefromgif( $this->background );
					break;

				case MADGD_JPG:
				case MADGD_JPEG:
					$this->instance = imagecreatefromjpeg( $this->background );
					break;
			}
			return $this->instance;
		}
		
		
		/**
		 * @param string $image
		 * @param integer $x
		 * @param integer $y
		 * @access public
		 * @return null
		**/
		public function setEquipmentBackground( $image, $x = false, $y = false )
		{
			if ( $x )
			{
				$this->equipment['pos']['x'] = $x;
			}	
			if ( $y )
			{
				$this->equipment['pos']['y'] = $y;
			}
			
			$this->setEquipments( );
			return $this->addIcon( $image )->setPosition( $this->equipment['pos']['x'], $this->equipment['pos']['y'] );
		}
		
		
		/**
		 * @param string/int $regular
		 * @param string/int $bold
		 * @param int $size
		 * @param string $color
		 * @param boolean $shadow
		 * @access public
		 * @return null
		**/
		public function setDefaultStyle( $regular = 2, $bold = 3, $size = 9, $color = 'FFFFFF', $shadow = true )
		{
			$this->textConfig = array( 'font' => $regular, 'size' => $size, 'color' => $color, 'shadow' => $shadow );
			$this->textBold   = array( 'font' => $bold,    'size' => $size, 'color' => $color, 'shadow' => $shadow );
		}
		

		/**
		 * @param string $text
		 * @param array $style
		 * @access public
		 * @return instance
		**/
		public function addText( $text, $style = array( ) )
		{
			foreach( $this->textConfig as $key => $value )
			{
				if ( !array_key_exists( $key, $style ) )
				{
					$style[$key] = $value;
				}
			}
			return new MadGDText( $this, array( $text, $style ) );
		}


		/**
		 * @param string $icon
		 * @access public
		 * @return instance
		**/
		public function addIcon( $icon, $width = null, $height = null )
		{
			return new MadGDIcon( $this, $icon, $width, $height );
		}


		/**
		 * @param string $hex
		 * @param boolean/int $index
		 * @access public
		 * @return array $hex
		**/
		public function HexRGB( $hex, $index = false )
		{
			if ( !is_array( $hex ) )
			{
				$hex = preg_replace( '/#/', null, $hex );
				if ( strlen( $hex ) == 6 )
				{
					$hex = array(
						hexdec( substr( $hex, 0, 2 ) ),
						hexdec( substr( $hex, 2, 2 ) ),
						hexdec( substr( $hex, 4, 2 ) )
					);
				}
			}
			return ( in_array( $index, array( 0, 1, 2 ) ) ? $hex[$index] : $hex );
		}


		/**
		 * @param string $path
		 * @access public
		 * @return null
		**/
		public function display( $path = false )
		{
			if ( !$this->testMode )
			{
				header( 'Content-Type: image/png' );
				if ( !$path )
				{
					imagepng( $this->instance, '', 9 );
				}
				else
				{
					imagepng( $this->instance, $path, 9 );
				}
				imagedestroy( $this->instance );
				unset( $this );
			}
		}
	}


	class MadGDText
	{
		private $parent = null;
		private $text   = null;
		private $style  = array( );

		/**
		 * @param instance $parent
		 * @param array $object
		 * @access public
		 * @return null
		**/
		public function __construct( $parent, $object )
		{
			$this->parent = $parent;
			$this->text   = $object[0];
			$this->style  = $object[1];
		}


		/**
		 * @param int $x
		 * @param int $y
		 * @access public
		 * @return null
		**/
		public function setPosition( $x = MADGD_STACK, $y = 5 )
		{
			$textSize = ( !is_int( $this->style['font'] ) ? imagettfbbox( $this->style['size'], 0, $this->style['font'], $this->text ) : null );

			$this->parent->x = ( $x === MADGD_STACK ? $this->parent->x + $this->parent->l + $y : $x );
			$this->parent->y = ( $x === MADGD_STACK ? $this->parent->y : $y );
			$this->parent->l = ( is_int( $this->style['font'] ) ? imagefontwidth( $this->style['font'] ) * strlen( $this->text ) : $textSize[2] );

			if ( is_int( $this->style['font'] ) )
			{
				if ( $this->style['shadow'] )
				{
					imagestring( $this->parent->instance, $this->style['font'], $this->parent->x + 1, $this->parent->y + 1, $this->text, imagecolorallocate( $this->parent->instance, 0, 0, 0 ) );
				}
				imagestring( $this->parent->instance, $this->style['font'], $this->parent->x, $this->parent->y, $this->text, imagecolorallocate( $this->parent->instance, $this->parent->HexRGB( $this->style['color'], 0 ), $this->parent->HexRGB( $this->style['color'], 1 ), $this->parent->HexRGB( $this->style['color'], 2 ) ) );
			}
			else
			{
				if ( $this->style['shadow'] )
				{
					imagettftext( $this->parent->instance, $this->style['size'], 0, $this->parent->x + 1, $this->parent->y + 11, imagecolorallocate( $this->parent->instance, 0, 0, 0 ), $this->style['font'], $this->text );
				}
				imagettftext( $this->parent->instance, $this->style['size'], 0, $this->parent->x, $this->parent->y + 10, imagecolorallocate( $this->parent->instance, $this->parent->HexRGB( $this->style['color'], 0 ), $this->parent->HexRGB( $this->style['color'], 1 ), $this->parent->HexRGB( $this->style['color'], 2 ) ), $this->style['font'], $this->text );
			}
		}
	}


	class MadGDIcon
	{
		public $extension = null;
		public $instance  = null;
		public $parent    = null;
		public $height    = null;
		public $width     = null;
		public $icon      = null;

		/**
		 * @param instance $parent
		 * @param string $icon
		 * @param int $width
		 * @param int $height
		 * @access public
		 * @return null
		**/
		public function __construct( $parent, $icon, $width, $height )
		{
			$this->parent    = $parent;
			$this->height    = $height;
			$this->width     = $width;
			$this->icon      = $icon;
			$this->extension = strtolower( pathinfo( $this->icon, PATHINFO_EXTENSION ) );
		}


		/**
		 * @param int $x
		 * @param int $y
		 * @access public
		 * @return null
		**/
		public function setPosition( $x = MADGD_STACK, $y = 5 )
		{
			$this->parent->x = ( $x === MADGD_STACK ? $this->parent->x + $this->parent->l + $y : $x );
			$this->parent->y = ( $x === MADGD_STACK ? $this->parent->y : $y );

			list( $imageWidth, $imageHeight ) = getimagesize( $this->icon );
			$this->parent->l = $imageWidth;

			switch( $this->extension )
			{
				case MADGD_PNG:
					$this->instance = imagecreatefrompng( $this->icon );
					break;

				case MADGD_GIF:
					$this->instance = imagecreatefromgif( $this->icon );
					break;

				case MADGD_JPG:
				case MADGD_JPEG:
					$this->instance = imagecreatefromjpeg( $this->icon );
					break;
			}
			return imagecopyresampled( $this->parent->instance, $this->instance, $this->parent->x, $this->parent->y, 0, 0, ( $this->width != null ? $this->width : $imageWidth ), ( $this->height != null ? $this->height : $imageHeight ), $imageWidth, $imageHeight );
		}
	}

	define( 'MADGD_PNG', 'png' );
	define( 'MADGD_JPG', 'jpg' );
	define( 'MADGD_JPEG', 'jpeg' );
	define( 'MADGD_GIF', 'gif' );
	define( 'MADGD_STACK', 'stack' );
	define( 'X_SLOT', 'X_SLOT_' );
	define( 'Y_SLOT', 'Y_SLOT_' );
 
Parse error: syntax error, unexpected T_CLASS, expecting T_FUNCTION in D:\Program Files\paki\xampp\htdocs\server\signatures\gd.class.php on line 217
 
What will happen if you got a sprite-edited client? :p
That doesn't matter?
Shouldn't matter at all, I suppose.

Love your Api's
Thank you very much!

Parse error: syntax error, unexpected T_ELSE in C:\xampp\htdocs\accountmanagement.php on line 490
pffffffffffff =/
I believe you forgot one of the } at the end of that specific code block.

What is this wrong functions
PHP:
                    /** Merital Status **/
                    if ( $player->getMarriage() != null )
                    {
                        $MadGD->addText( 'Marital status:', $MadGD->textBold )->setPosition( 17, $i * $eachRow );
                        $MadGD->addText( 'married to '.$player->getMarriage()->getName() )->setPosition( ); $i++;
                    }
The getMarriage() method doesn't seem to be returning an instance. This would disallow you to use the ->getName() method like you do. I don't know POT enough to tell you which way would be the best to solve it, but you could always create a new player instance, with the ID you get from the getMarriage() method and print his name that way.

o thx..

Warning: Cannot modify header information - headers already sent by (output started at D:\Program Files\paki\xampp\htdocs\server\config-and-functions.php:486) in D:\Program Files\paki\xampp\htdocs\server\signatures\gd.class.php on line 203..??;/
Try adding ob_start(); at the top of the gd.class.php file (below <?PHP) and and ob_end_flush(); at the very bottom.

nice o_O
so now I can write script loading itenm image for character section from .spr
nice, but slow I guess ;d
Yeah exactly. But seeing as it saves the images, it would only be a bit slow the first time it creates an image. :)

Parse error: syntax error, unexpected T_CLASS, expecting T_FUNCTION in D:\Program Files\paki\xampp\htdocs\server\signatures\gd.class.php on line 217
It is possible that you have removed another } by accident. Try re-downloading it.
 
Status
Not open for further replies.
Back
Top