• 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!

[PHP] Character Signature - v4

ok.

And how to make the text size bigger?

I got one more idea:) Status, if the player is Premium/Free
Yeah I can do that. I will also import a text-size changer in the config later. For now, find row 127 and 132, change the 2 to whatever of your choice.

i was wondering how you could get the script to read the players_skills and record each skill and ect..

And also.. is there a way to make the text print differently on each picture??


And i cannot see your above code
I can do so you can choose to show skills later on. Concerning the code: pastebin - collaborative debugging tool
 
I got one more idea:) Status, if the player is Premium/Free

As requested above:

PHP:
<?PHP

	class signature
    {
    	
    	# v-- CONFIGURATION BELOW --v #
    	var $config = array
	    (
	        'database'    => array ( "localhost" , "root" , "password" , "theforgottenserver" ),
	        'vocations'   => array ( "No Vocation" , "Sorcerer" , "Druid" , "Paladin" , "Knight" , "Master Sorcerer" , "Elder Druid" , "Royal Paladin" , "Elite Knight" ),
	        'towns'       => array ( 0 => "Rookgaard" , 1 => "Thais" , 2 => "Venore" ),
	        'groups'      => array ( 2 => "Tutor" , 3 => "Senior Tutor" , 4 => "Gamemaster" , 5 => "Community Manager" , 6 => "God" , 7 => "God" ),
	        'backgrounds' => array ( 'background1' , 'background2' ),
	        'color'       => "#FF0000"
	    );
    	# ^-- CONFIGURATION ABOVE --^ #
	    
	    
	    
	    
	    
        
        
        
        
        // Database functions.
        function connectDatabase ( $database ) { @mysql_connect ( $database[0] , $database[1] , $database[2] ); @mysql_select_db ( $database[3] ); }
        function query ( $query ) { return @mysql_query ( $query ); }
        function fetchArray ( $query ) { return @mysql_fetch_array ( $query ); }
        function secure ( $query ) { return @mysql_real_escape_string ( $query ); }
        function numRows ( $query ) { return @mysql_num_rows ( $query ); }
        
        
        // Convert the color (HEX) into RGB format.
        function convertHex ( $hex )
		{
			
			$hex   = ereg_replace ( "#" , "" , $hex );
			$color = array();
		
			if ( strlen ( $hex ) == 6 ):
			
				$color['r'] = hexdec ( substr ( $hex , 0 , 2 ) );
				$color['g'] = hexdec ( substr ( $hex , 2 , 2 ) );
				$color['b'] = hexdec ( substr ( $hex , 4 , 2 ) );
			
			endif;
			
			return $color;
			
		}


        // Signature functions.
        function character ( $character )
        {
            
            // Define presets.
            $query     = "SELECT `id` , `account_id` , `group_id` , `name` , `sex` , `promotion` , `vocation` , `town_id` , `rank_id` , `online` , `level` , `lastlogin` FROM `players` WHERE `name` = '{$character}'";
	    $fetchRow  = $this -> fetchArray ( $this -> query ( $query ) );
            $numRows   = $this -> numRows    ( $this -> query ( $query ) );
            $rank      = $this -> fetchArray ( $this -> query ( "SELECT `guild_id` , `name` FROM `guild_ranks` WHERE `id` = '{$fetchRow[rank_id]}'" ) );
            $guild     = $this -> fetchArray ( $this -> query ( "SELECT `name` FROM `guilds` WHERE `id` = '{$rank[guild_id]}'" ) );
	    $status    = $this -> fetchArray ( $this -> query ( "SELECT `premdays` FROM `accounts` WHERE `account_id` = '{$numRows[account_id]}'" ) );
            
            // Define certain arrays into one variable.
            $arrays['status']      = ( $fetchRow['online'] == 1 ? 'online' : 'offline' );
            $arrays['gender']      = ( $fetchRow['sex'] == 1 ? 'Male' : 'Female' );
            $arrays['vocation']    = ( $fetchRow['promotion'] != 0 ? $this -> config['vocations'][$fetchRow['vocation']+4] : $this -> config['vocations'][$fetchRow['vocation']] );
            $arrays['guild']       = ( $fetchRow['rank_id'] > 0 ? "Guild: " . ( $fetchRow['sex'] == 1 ? 'He' : 'She' ) . " is " . $rank['name'] . " of the " . $guild['name'] . "\q" : NULL );
            $arrays['position']    = ( $fetchRow['group_id'] > 1 ? "Position: " . $this -> config['groups'][$fetchRow['group_id']] . "\q" : NULL );
	    $arrays['lastlogin']   = ( date ( "M d Y, H:i:s" , $fetchRow['lastlogin'] "\q" ) );
            $arrays['statusprem']  = ( $status['premdays'] < 1 ? 'free account' : 'premium account' );
			
            // Showable fields (\q equals new line, had to create my own shortcut as I clear all whitespaces further down in the script).
            $return = "
				Name: 		{$fetchRow[name]} ({$arrays[status]})			\q
				Sex: 		{$arrays[gender]}					\q
				Level: 		{$fetchRow[level]}					\q
				Profession:     {$arrays[vocation]}					\q
				Residence: 	{$this -> config[towns][$fetchRow[town_id]]}	        \q
						{$arrays[guild]}
						{$arrays[position]}
				Last Login:     {$arrays[lastlogin]}					\q
				Status:		{$arrays[statusprem]}
			";
			
			// Make certain fields bold.
			$bolds = "Name: \nSex: \nLevel: \nProfession: \nResidence: \n" . ( $fetchRow['rank_id'] > 0 ? "Guild: \n" : NULL ) . ( $fetchRow['group_id'] > 1 ? "Position: \n" : NULL ) . "Last Login:";
			
			// Return output.
            if ( $numRows == 1 )
                return $return . "|||" . $bolds;
            else
                return "A character with that name does not exist.";
            
        }
        
        // Create a function to generate the signature.
        function generate ( $character , $background )
        {
            
	    	// Connect to the database.
	    	$this -> connectDatabase ( $this -> config['database'] );
	        $split = explode ( "|||" , $this -> character ( $this -> secure ( $character ) ) );
	    
	    	header ( "Content-type: image/png" );
	        
	        // Check if the background exists, if not - create one.
	        if ( file_exists ( "{$this -> config[backgrounds][$background]}.png" ) != 1 ):
			                  
	            $image = imagecreate ( 400 , 120 );
	            imagecolorallocate ( $image , 255 , 255 , 255 );
	            $split[0] = "The requested image does not exist.";
	            $split[1] = NULL;
	            
	        else:
	        
	            $image = imagecreatefrompng ( $this -> config['backgrounds'][$background] . ".png" );
	           	
	        endif;
	        
	        $color	 = $this -> convertHex ( $this -> config['color'] );
	        $content = explode ( "\q" , str_replace ( array ( "\n" , "\r" , "\t" , "\o" , "\xOB" ) , '' , $split[0] ) );
	        $bolds   = explode ( "\n" , str_replace ( array ( "\r" , "\t" , "\o" , "\xOB" ) , '' , $split[1] ) );
	        
	        // Print text.
	        for ( $i = 0.5; $i <= count ( $content ) ; $i++ ):
	            imagestring ( $image, 2, 7, 12 * $i, $content[$i], imagecolorallocate ( $image , $color['r'] , $color['g'] , $color['b'] ) );
	        endfor;
	        
	        // Print bold text.
	        for ( $i = 0.5; $i <= count ( $bolds ) ; $i++ ):
	            imagestring ( $image, 2, 6, 12 * $i, $bolds[$i], imagecolorallocate ( $image , $color['r'] , $color['g'] , $color['b'] ) );
	        endfor;
	            
	        imagepng ( $image );
	        imagedestroy ( $image );
        	
        }
        
    }
    
    
    
    
    $signature = new signature();
    
   	// Check if it should print the signature or the form.
	if ( !empty ( $_GET ) ):
	
		$signature -> generate ( $_GET['character'] , $_GET['image'] );
		
	else:
    
        ?>
        <form method="get">
            Name: <input type="text" name="character" /><br /><br />
            <?PHP
            	// Loop backgrounds.
				foreach ( $signature -> config['backgrounds'] as $bg => $value ):
                    echo '<input type="radio" name="image" value="' . $bg . '" /> <img src="' . $value . '.png" /><br />';
                endforeach;
            ?>
            <input type="submit" value="Create Signature" />
        </form>
        <?PHP
		
	endif;
	
?>
 
Last edited:
That doesnt work it looks like this then:
signaturephp.png
 
@UP

Sorry, this script messes up when put into OtLand for some reason o_O :S

I'll upload to speedyshare

Edit:

Here you are:

http://www.speedy*****malware.localhost/937971939.html
 
when i did everything that text only appeared to me...

Btw i added 2 backgrounds (images) extention .png also put them in the signature folder with the script and called them background1.png and background2.png

i don get the problem really. any idea?


Untitled8.gif
 
Also, the image you made, you have to put it on your htdocs.

And then
PHP:
 'backgrounds' => array ( 'background1' , 'background2' ),
Take a look at this, this is the name of the images should be... in htdocs, so change your image name to backgrounds, or change that backgrounds to your image name.
 
my images name is "background1" and "background2" already. but i put them in the signatures folder in htdocs and also in htdocs and in the layout foler and in tibiacom folder so as any works but non and all are called background1 and background2

arent the backgrounds the images that the information of the char is written on? or it is the bafkgound of the page or what exactly. i guess i am lost :(

sorry for triple post but i can edit my post i donno why :S .

Tkae a look then Brighty Server - signature
 
Last edited by a moderator:
Back
Top