Сообщений: 34
Тем: 3
Зарегистрирован: Mar 2010
Репутация:
122
всем 3 ку! Не подскажите где храняться эмблемы кланов после их установки в игре. сборка l2phoenix 17 рева.
Сообщений: 146
Тем: 11
Зарегистрирован: Mar 2009
Репутация:
3,303
в базе данных: колонки `crest`, `largecrest`, таблица `clan_data`
C#, Delphi, Java, WMI, MSSQL, MySQL, Ruby(on Rails)
Сообщений: 34
Тем: 3
Зарегистрирован: Mar 2010
Репутация:
122
тогда след вопрос
как его прочитать?
Сообщений: 146
Тем: 11
Зарегистрирован: Mar 2009
Репутация:
3,303
Вопрос не в том как его прочитать, а как его вывести. Иконки хранятся в формате DDS(DirectDraw Surface). таким образом нужен декодер данного формата в формат известный браузеру. В некоторых обвязках возможно есть этот декодер, попробуйте найти обвязку которая выводит иконки кланов, а далее дело техники.
C#, Delphi, Java, WMI, MSSQL, MySQL, Ruby(on Rails)
Сообщений: 34
Тем: 3
Зарегистрирован: Mar 2010
Репутация:
122
это я всё уже знаю, вот тока незнаю обвязку где выводит.
Сообщений: 734
Тем: 6
Зарегистрирован: Sep 2009
Репутация:
4,302
Сообщений: 146
Тем: 11
Зарегистрирован: Mar 2009
Репутация:
3,303
connection.php
PHP код:
<?php
$db_user = "root" ; //your sql username goes here
$db_pass = "*****" ; //your sql password goes here
$db_name = "l2pdb" ; //your database name goes here
$db_serv = "localhost" ; //the address of the database goes here
$db = mysql_connect ( $db_serv , $db_user , $db_pass ) or die ( "Coudn't connect to [ $db_serv ]" );
mysql_select_db ( $db_name );
?>
crest.php
PHP код:
<?php
/*
* Функции
*/
function empty_image ()
{
@ header ( "Content-type: image/gif" );
@ header ( "Cache-Control: max-age=3600" );
$img = imagecreatetruecolor ( 1 , 1 );
imagecolortransparent ( $img , 0 );
imagegif ( $img );
imagedestroy ( $img );
exit();
}
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 ;
}
/*
* Переменные
*/
$id = isset( $_REQUEST [ "id" ]) ? $_REQUEST [ "id" ] : 0 ;
if ( $id == 0 ) empty_image ();
include( "connection.php" );
$query = mysql_query ( "SELECT crest FROM clan_data WHERE clan_id = ' $id '" , $db );
if (@ mysql_num_rows ( $query ) > 0 )
{
$result = @ mysql_fetch_assoc ( $query );
$clan_crest = $result [ 'crest' ];
}
else
{
empty_image ();
}
$file = tmpfile ();
fwrite ( $file , $clan_crest );
fseek ( $file , 0 );
$dds = fread ( $file , 4 );
if ( $dds !== 'DDS ' ) die( "Error: изображение 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: не найден формат DX1" );
//here we go
fseek ( $file , 128 );
@ header ( "Content-type: image/png" );
@ header ( "Cache-Control: max-age=3600" );
$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 );
fclose ( $file );
exit;
?>
вывод изображения
<img src='crest.php?id=270684088' />
C#, Delphi, Java, WMI, MSSQL, MySQL, Ruby(on Rails)
Сообщений: 34
Тем: 3
Зарегистрирован: Mar 2010
Репутация:
122
спс большое прикрутил, работает.
Сообщений: 146
Тем: 11
Зарегистрирован: Mar 2009
Репутация:
3,303
Если ваш хостинг поддерживает mod_rewrite, и разрешены .htaccess, то можете воспользоваться более интересным решением:
.htaccess
PHP код:
<?php
RewriteEngine On
RewriteBase /
RewriteRule ^([ ac ])( \d +). png $ crest . php ? prefix =$ 1 & id =$ 2
и использовать в html - <img src='a<ally_id>.png' /><img src='a<clan_id>.png' />
например, <IMG src="a268947921.png"><IMG src="c269160639.png">
Файлы вложений
crest.zip (Размер: 1.19 KB / Загрузок: 8)
C#, Delphi, Java, WMI, MSSQL, MySQL, Ruby(on Rails)
Сообщений: 119
Тем: 16
Зарегистрирован: Nov 2009
Репутация:
69
04-16-2010, 01:58 PM
(Сообщение последний раз редактировалось: 04-16-2010, 03:24 PM Ametist .)
atukal Написал: connection.php
PHP код:
<?php
$db_user = "root" ; //your sql username goes here
$db_pass = "*****" ; //your sql password goes here
$db_name = "l2pdb" ; //your database name goes here
$db_serv = "localhost" ; //the address of the database goes here
$db = mysql_connect ( $db_serv , $db_user , $db_pass ) or die ( "Coudn't connect to [ $db_serv ]" );
mysql_select_db ( $db_name );
?>
crest.php
PHP код:
<?php
/*
* Функции
*/
function empty_image ()
{
@ header ( "Content-type: image/gif" );
@ header ( "Cache-Control: max-age=3600" );
$img = imagecreatetruecolor ( 1 , 1 );
imagecolortransparent ( $img , 0 );
imagegif ( $img );
imagedestroy ( $img );
exit();
}
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 ;
}
/*
* Переменные
*/
$id = isset( $_REQUEST [ "id" ]) ? $_REQUEST [ "id" ] : 0 ;
if ( $id == 0 ) empty_image ();
include( "connection.php" );
$query = mysql_query ( "SELECT crest FROM clan_data WHERE clan_id = ' $id '" , $db );
if (@ mysql_num_rows ( $query ) > 0 )
{
$result = @ mysql_fetch_assoc ( $query );
$clan_crest = $result [ 'crest' ];
}
else
{
empty_image ();
}
$file = tmpfile ();
fwrite ( $file , $clan_crest );
fseek ( $file , 0 );
$dds = fread ( $file , 4 );
if ( $dds !== 'DDS ' ) die( "Error: изображение 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: не найден формат DX1" );
//here we go
fseek ( $file , 128 );
@ header ( "Content-type: image/png" );
@ header ( "Cache-Control: max-age=3600" );
$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 );
fclose ( $file );
exit;
?>
вывод изображения
<img src='crest.php?id=270684088' />
Попытался прицепить этот код на сайт, почему то не работает, к базе коннект есть.
Как я понимаю надо указать ведь путь к папке с эмблемами ?
Объясните поподробнее пожалуйста,
atukal
Добавлено через 1 час 25 минут
Помогите пожалуйста ...
Помог ? Нажми: