How to center "Paying" icon inside php image file ?

Discussion in 'PHP' started by idev, Feb 20, 2011.

  1. #1
    Hello DP'ers

    I wonder if someone could help me to center the "Paying" image icon
    inside a php image file please.

    Link to the image:
    http://idev.freehostingnoads.net/monitoring/img.php?id=10

    The code for the php image,
    
    <?php
    if(strlen($_GET['id'])>0)
    	{
    	include('./config/config.php');
    	if($result=mysql_query("SELECT `nazwa`, `status` FROM `programs` WHERE `id_program`='". $_GET['id'] ."' AND `blacklist`='' AND `status`>'0'") and $payout=mysql_query("SELECT `data` FROM `payouts` WHERE `id_program`='". $_GET['id'] ."' ORDER BY `data` DESC LIMIT 1"))
    		{
    		if(mysql_num_rows($result)==1)
    			{
    			$name=mysql_result($result, 0, 0);
    			$status=mysql_result($result, 0, 1);
    			if(mysql_num_rows($payout)==1)
    				$last_payout=mysql_result($payout, 0, 0);
    			else
    				$last_payout='no payouts';
    			mysql_free_result($result);
    
    			$img=imagecreatefrompng('gfx/banner.png');
    			$black=imagecolorallocate($img, 0, 0, 0);
    			$name=((strlen($name)>15) ? substr($name, 0, 13). '...' : $name);
    			$x = floor((ImageSX($img) / 2) - ((ImageFontWidth(2) * strlen($name)) / 2));
    			imagestring($img, 2, $x, 63, $name, $black);
    			imagestring($img, 2, 25, 83, $last_payout, $black);
    			if ($p=imagecreatefrompng('./gfx/icons/status_'. $status .'.png'))
    				{
    				imagecopyresampled($img, $p, 1, 103, 0, 0, 108, 16, 108, 16);
    				imagedestroy($p);
    				}
    			header("Content-type: image/png");
    			imagepng($img);
    		}
    	}
    }
    ?>
    
    PHP:
    Thanks
     
    idev, Feb 20, 2011 IP
  2. Arttu

    Arttu Member

    Messages:
    139
    Likes Received:
    2
    Best Answers:
    8
    Trophy Points:
    40
    #2
    $statusImageX = floor((ImageSX($img)/2)-floor((ImageSX($p)/2);
     
    Arttu, Feb 20, 2011 IP
  3. idev

    idev Member

    Messages:
    112
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #3
    Where do i add this please ?
     
    idev, Feb 20, 2011 IP
  4. Arttu

    Arttu Member

    Messages:
    139
    Likes Received:
    2
    Best Answers:
    8
    Trophy Points:
    40
    #4
    <?php
    if(strlen($_GET['id'])>0)
        {
        include('./config/config.php');
        if($result=mysql_query("SELECT `nazwa`, `status` FROM `programs` WHERE `id_program`='". $_GET['id'] ."' AND `blacklist`='' AND `status`>'0'") and $payout=mysql_query("SELECT `data` FROM `payouts` WHERE `id_program`='". $_GET['id'] ."' ORDER BY `data` DESC LIMIT 1"))
            {
            if(mysql_num_rows($result)==1)
                {
                $name=mysql_result($result, 0, 0);
                $status=mysql_result($result, 0, 1);
                if(mysql_num_rows($payout)==1)
                    $last_payout=mysql_result($payout, 0, 0);
                else
                    $last_payout='no payouts';
                mysql_free_result($result);
    
                $img=imagecreatefrompng('gfx/banner.png');
                $black=imagecolorallocate($img, 0, 0, 0);
                $name=((strlen($name)>15) ? substr($name, 0, 13). '...' : $name);
                $x = floor((ImageSX($img) / 2) - ((ImageFontWidth(2) * strlen($name)) / 2));
                imagestring($img, 2, $x, 63, $name, $black);
                imagestring($img, 2, 25, 83, $last_payout, $black);
                if ($p=imagecreatefrompng('./gfx/icons/status_'. $status .'.png'))
                    {
    		$statusImageX = floor((ImageSX($img)/2))-floor((ImageSX($p)/2));
                    imagecopyresampled($img, $p, $statusImageX, 103, 0, 0, 108, 16, 108, 16);
                    imagedestroy($p);
                    }
                header("Content-type: image/png");
                imagepng($img);
            }
        }
    }
    
    Code (markup):
     
    Arttu, Feb 21, 2011 IP
  5. idev

    idev Member

    Messages:
    112
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    28
    #5
    Thank you i will try it shortly,
    But i seem to have an error come out of no where now,
    i wonder if you have a fix for it, if you have time of course.

    Error
    Lines 256 - 268
    
    //AUTORYZACJE
    function auth()
    	{
    	$r=false;
    	$login=$_SESSION['login'];
    	if(strlen($login) > 0 && $login=='admin')
    		{
    		if ($passDB=mysql_query("SELECT `haslo` AS `p` FROM `users` WHERE `login`='admin' LIMIT 1"))
    			{
    			$p=@mysql_result($passDB, 0, 0);
    			$r=(($_SESSION['login']=='admin') && (decode($_SESSION['password'])==decode($p)))?true:false;
    			}
    		}
    
    PHP:
    Thanks
     
    idev, Feb 21, 2011 IP