Jump to content

Recommended Posts

Posted

This is my code, I think is same but your error is the $file var.

 

For example:

 

You have: $file = fopen('ftp://localhost/'.$name.'_'.$crest.'.bmp', 'r'); //fopen($filename,'rb');

 

Try to change, think that the file crest.php is in the same machine that server, replace "localhost" for the folder tree.

 

My $file var:

 

$file = fopen('/home/admin/gameserver/data/crests/'.$name.'_'.$crest.'.bmp', 'r'); //fopen($filename,'rb');

 

Because my server work under Linux and "fopen" read the folders in the machine.

 

 

I don't know to use with ftp protocol but if you want to use localhost take my mode.

 

If you use Windows probably is: $file = fopen('C:/server/gameserver/data/crests/'.$name.'_'.$crest.'.bmp', 'r'); //fopen($filename,'rb');

 

I'm not sure.

 

 

Hope that helps  ::)

 

 

<?


if(!empty($_GET['clan_crest'])){
$name = 'Crest';
$crest = $_GET['clan_crest'];
}
else if(!empty($_GET['ally_crest'])){
$name = 'AllyCrest';
$crest = $_GET['ally_crest'];
}
else
die('No Crest!');


$file = fopen('/home/admin/gameserver/data/crests/'.$name.'_'.$crest.'.bmp', 'r'); //fopen($filename,'rb');

$dds = fread($file,4);


if ($dds!=='DDS ') die("Error: no hay imagen DDS");


//DDS header

$hdrSize = readInt($file);

$hdrFlags = readInt($file);

$imgHeight = readInt($file)-4;

$imgWidth = readInt($file);

$imgPitch = readShort($file);



//DXT1 header

fseek($file, 84);

$dxt1 = fread($file,4);

if ($dxt1!=='DXT1') die("Error: no es formato DX1");


//here we go

fseek($file, 128);

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

$img=imagecreatetruecolor($imgWidth,$imgHeight);


for ($y=-1; $y<$imgHeight/4; $y++)

{

  for ($x=0; $x<$imgWidth/4; $x++)

  {

    $color0_16 = readShort($file);

    $color1_16 = readShort($file);

    $r0 = ($color0_16 >> 11) << 3;

    $g0 = (($color0_16 >> 5) & 63) << 2;

    $b0 = ($color0_16 & 31) << 3;

    $r1 = ($color1_16 >> 11) << 3;

    $g1 = (($color1_16 >> 5) & 63) << 2;

    $b1 = ($color1_16 & 31) << 3;

    $color0_32 = imagecolorallocate($img,$r0,$g0,$b0);

    $color1_32 = imagecolorallocate($img,$r1,$g1,$b1);

    $color01_32 = imagecolorallocate($img,$r0/2+$r1/2,$g0/2+$g1/2,$b0/2+$b1/2);

    $black = imagecolorallocate($img,0,0,0);

    $data = readInt($file);

    for ($yy=0;$yy<4;$yy++)

    {

      for ($xx=0;$xx<4;$xx++)

      {

        $bb = $data & 3;

        $data = $data >> 2;

        switch ($bb)

        {

          case 0: $c = $color0_32; break;

          case 1: $c = $color1_32; break;

          case 2: $c = $color01_32; break;

          default: $c = $black; break;

        }

        imagesetpixel($img,$x*4+$xx,$y*4+$yy,$c);

      }

    }

  }

}



imagepng($img);



## Functions needed

function readInt($file)

{

  $b4 = ord(fgetc($file));

  $b3 = ord(fgetc($file));

  $b2 = ord(fgetc($file));

  $b1 = ord(fgetc($file));

  return ($b1<<24)|($b2<<16)|($b3<<8)|$b4;

}



function readShort($file)

{

  $b2 = ord(fgetc($file));

  $b1 = ord(fgetc($file));

  return ($b1<<8)|$b2;

}


?> 

Posted

Thank You very much friend I finally got it to work. I have wait so long to get this script working and if wasn't for your help I was never gonna get it done.

It is working perfectly.

One more time Thank you.

Posted

After a while, still

Warning: mysql_fetch_assoc() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\heroes.php on line 100

in heroes.php, some1 have any ideea?

  • 1 year later...
  • 2 months later...
  • 3 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now



  • Posts

    • Dear partners! At the moment we are in great need of the following positions: — Snapchat old and new accounts | With snapscores | Geo: Europe/USA | Full access via email/phone number — Reddit old (brute or hacked origin, self-registered) accounts with post and comment karma from 100 to 100,000+ | Full email access included — LinkedIn old accounts with real connections | Geo: Europe/USA | Full email access + active 2FA password — Instagram old accounts (2010–2023) | Full email access (possibly with active 2FA password) — Facebook old accounts (2010–2023) | Full email access (possibly with active 2FA password) | With friends or without friends | Geo: Europe/USA/Asia — Threads accounts | Full email access (possibly with active 2FA password) — TikTok/Facebook/Google ADS Agency advertising accounts — Email accounts: mail.ru, yahoo.com, gazeta.pl, gmx.ch / gmx.de / gmx.net (BUT NOT gmx.com) — Google ADS Manual Farm accounts (verified via email and phone number) | GEO: USA/Europe, mostly USA. — WhatsApp OLD Accounts — Twitter accounts with followers and posts (old accounts) Contact us via the details below. We will be glad to cooperate! We are also ready to consider other partnership and collaboration options. Active links to our projects: Digital goods store (Website): Go to Store Telegram bot: Go to – convenient access to the store via the Telegram messenger. Virtual numbers service: Go to Telegram bot for purchasing Telegram Stars: Go to – fast and profitable purchase of Stars in Telegram. SMM Panel: Go to – promotion of your social media accounts. Contacts and support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • Dear partners! At the moment we are in great need of the following positions: — Snapchat old and new accounts | With snapscores | Geo: Europe/USA | Full access via email/phone number — Reddit old (brute or hacked origin, self-registered) accounts with post and comment karma from 100 to 100,000+ | Full email access included — LinkedIn old accounts with real connections | Geo: Europe/USA | Full email access + active 2FA password — Instagram old accounts (2010–2023) | Full email access (possibly with active 2FA password) — Facebook old accounts (2010–2023) | Full email access (possibly with active 2FA password) | With friends or without friends | Geo: Europe/USA/Asia — Threads accounts | Full email access (possibly with active 2FA password) — TikTok/Facebook/Google ADS Agency advertising accounts — Email accounts: mail.ru, yahoo.com, gazeta.pl, gmx.ch / gmx.de / gmx.net (BUT NOT gmx.com) — Google ADS Manual Farm accounts (verified via email and phone number) | GEO: USA/Europe, mostly USA. — WhatsApp OLD Accounts — Twitter accounts with followers and posts (old accounts) Contact us via the details below. We will be glad to cooperate! We are also ready to consider other partnership and collaboration options. Active links to our projects: Digital goods store (Website): Go to Store Telegram bot: Go to – convenient access to the store via the Telegram messenger. Virtual numbers service: Go to Telegram bot for purchasing Telegram Stars: Go to – fast and profitable purchase of Stars in Telegram. SMM Panel: Go to – promotion of your social media accounts. Contacts and support: ➡ Telegram: https://t.me/socnet_support ➡ WhatsApp: https://wa.me/79051904467 ➡ Discord: socnet_support ➡ ✉ Email: solomonbog@socnet.store
    • 冬天是享受优惠、省钱的好时机。 首次下单时使用促销码 SOCNET 即可获得 15% 折扣 ,适用于全场商品! 前往商店(网站) 前往商店(Telegram 机器人)
    • Winter is the time to save with benefits. Activate the promo code SOCNET on your first order and get a 15% discount on the entire assortment! Go to the store (website) Go to the store (Telegram bot)
    • Winter is the time to save with benefits. Activate the promo code SOCNET on your first order and get a 15% discount on the entire assortment! Go to the store (website) Go to the store (Telegram bot)
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock