Герой
Регистрация: 21.03.2010
Сообщений: 1,065
Отблагодарили 563 раз(а)
|
Re: Исходники базы знаний под ГФ
почти все из базы серва, из клиента в основном описания, а так же названия иконок
да и вобще я очень сильно переработал сами по себе скрипты самой бз. вот хотя бы для сравнения показ списка предметов:
в старой бз (которую ты колупаешь):
PHP код:
<?
function accessibility_icon($item, $type)
{
global $dirs, $ss, $i2_size;
if ($type=="trade"&&$item["is_luxor"])
$item["is_trade"]=true;
if ($type=="ssq"&&($item["is_priest"]||$item["is_mammon_trader"]||$item["is_change"]||$item["is_upgrade"]))
$item["is_ssq"]=true;
if ($item["is_$type"]>0)
{
if ($type!="ssq"&&$type!="trade")
$item["$type"]="<a href='?part=item_details&type=$type&id=".$item["id"]."'>".$ss->img($dirs["accessibility"].$type."_1.png", "class=ib-gold, width=$i2_size, height=$i2_size")."</a>";
else
$item["$type"]="<a href='?part=item_details&type=trade&id=".$item["id"]."'>".$ss->img($dirs["accessibility"].$type."_1.png", "class=ib-gold, width=$i2_size, height=$i2_size")."</a>";
}
else
$item["$type"]=$ss->img($dirs["accessibility"].$type."_0.png", "class=ib-gray, width=$i2_size, height=$i2_size");
return $item;
}
function draw_items_list($arr, $type, $subtype, $flags=array(true, true, 1))
{
// flags:
// [0] - show/hide accessibility icons
// [1] - show/hide screenshot icon
// [2] - list type (1 - normal, 2 - drop/spoil list, 3 - search list, 4 - sa list)
global $dirs, $ext, $grades, $i1_size, $i2_size, $small_icons, $ss, $li;
$parents=load_parent_ids($dirs["screens_items"]."parents.dat");
$ss->table_s("spacing=1");
$ss->tr_s();
$ss->table_h(array(""), array(str("name")), "cell-h", false);
if ($flags[1]&&($type=="weapon"||($type=="armor"&&in_array($subtype, array("chest", "legs", "onepiece", "feet", "gloves", "shield", "hair")))))
$ss->table_h(array("", $i1_size), "cell-h", false);
if ($flags[2]==1||$flags[2]==4)
{
if ($type=="armor"&&!in_array($subtype, array("hair", "agathon")))
$ss->table_h(array(str("p_def"), 40), "cell-h", false);
if ($type=="weapon")
{
$ss->table_h(array(str("p_atk"), 40), array(str("m_atk"), 40), array(str("hands"), 40), array(str("ss"), 30), array(str("sps"), 30), array(str("atk_speed"), 40), "cell-h", false);
if ($subtype=="bow"||$subtype=="shadow")
$ss->table_h(false, array(str("mp"), 30));
}
if ($type=="accessary"&&!in_array($subtype, array("bracelet", "talisman")))
$ss->table_h(array(str("m_def"), 40), array(str("+mp"), 30), "cell-h", false);
if ($type=="armor"&&$subtype=="shield")
$ss->table_h(array(str("def_rate"), 40), array(str("avoid_mod"), 45), "cell-h", false);
if ($type=="armor"&&($subtype=="chest"||$subtype=="legs"||$subtype=="onepiece"))
$ss->table_h(array(str("armor_type"), 60), array(str("+mp"), 40), "cell-h", false);
if (in_array($type, array("armor", "weapon", "accessary"))&&!in_array($subtype, array("pet", "hair", "agathon", "shadow", "bracelet", "talisman")))
$ss->table_h(array(str("crystals"), 65), "cell-h", false);
if ($type=="recipe")
$ss->table_h(array(str("level"), 40), array(str("chance"), 40), "cell-h", false);
if ($type=="etc"||$type=="recipe"||$type=="quest")
$ss->table_h(array(str("stackable"), 40), "cell-h", false);
$ss->table_h(array(str("weight"), 40), "cell-h", false);
if ($subtype!="shadow")
$ss->table_h(array(str("price"), 70), "cell-h", false);
}
if ($flags[2]==2)
$ss->table_h(array(str("count"), 110), array(str("chance"), 55), "cell-h", false);
if ($subtype=="shadow"||$subtype=="talisman")
$ss->table_h(array(str("life_time"), 50), "cell-h", false);
if ($flags[0])
if ($flags[2]!=2)
if ($small_icons)
$ss->table_h(array("", $i2_size*6+15), "cell-h", false);
else
$ss->table_h(array("", $i2_size*3+7), "cell-h", false);
else
if ($small_icons)
$ss->table_h(array("", $i2_size), "cell-h", false);
else
$ss->table_h(array("", $i1_size), "cell-h", false);
$ss->tr_e();
for ($x=0; $x<count($arr); $x++)
{
if (file_exists($dirs["icons"].$arr[$x]["icon"].$ext))
$arr[$x]["icon"]=$ss->img($dirs["icons"].$arr[$x]["icon"].$ext, "class=ib-gold, width=$i1_size, height=$i1_size");
else
$arr[$x]["icon"]=$ss->img($dirs["images"]."blank.gif", "class=ib-gray, width=$i1_size, height=$i1_size");
if ($flags[2]!=4)
$hint=$li->item_hint($arr[$x]);
else
$hint="";
$arr[$x]["name"]="<a href='?part=item_details&id=".$arr[$x]["id"]."'$hint>".$arr[$x]["name"]."</a>";
if (trim($arr[$x]["add_name"])!="")
$arr[$x]["name"].=" [<span class='item-add-name'>".$arr[$x]["add_name"]."</span>]";
if ($arr[$x]["mp_consume"]==0)
$arr[$x]["mp_consume"]="-";
if ($flags[2]==4)
$arr[$x]["name"].="<br> ".$arr[$x]["sa_desc"];
if (in_array($type, array("weapon", "armor", "accessary"))&&!in_array($subtype, array("bracelet", "talisman")))
{
$gwidth=16;
if ($arr[$x]["crystal_type"]>0)
if ($arr[$x]["crystal_type"]<6)
$grade=$ss->img($dirs["grade"].$arr[$x]["crystal_type"].".png");
else
{
$grade=$ss->img($dirs["grade"]."5.png").$ss->img($dirs["grade"]."80.png");
$gwidth=32;
}
else
$grade=" ";
$arr[$x]["name"]="<table width=\"100%\" border=0 cellspacing=0 cellpadding=0><tr><td>".$arr[$x]["name"]."</td><td width=$gwidth>$grade</td></tr></table>";
}
if ($flags[2]==1||$flags[2]==4)
{
if ($arr[$x]["crystal_type"]==0)
$arr[$x]["crystal_count"]="<span class='grade_0'>-</span>";
else
$arr[$x]["crystal_count"]="<span class='grade_".$arr[$x]["crystal_type"]."'>".number_format($arr[$x]["crystal_count"])." ".$grades["crystal"][$arr[$x]["crystal_type"]]."x</span>";
if ($arr[$x]["mp_bonus"]==0)
$arr[$x]["mp_bonus"]="-";
if ($subtype=="shield")
$arr[$x]["physical_defense"]=$arr[$x]["shield_defense"];
if ($arr[$x]["slot_bit_type"]=="rhand")
$arr[$x]["hands"]="1H";
else
$arr[$x]["hands"]="2H";
if (!is_empty($arr[$x]["consume_type"]))
$arr[$x]["stackable"]="<span class=yes>".str("yes")."</span>";
else
$arr[$x]["stackable"]="<span class=no>".str("no")."</span>";
if ($arr[$x]["default_price"]>0)
$arr[$x]["price"]=$arr[$x]["default_price"];
else
$arr[$x]["price"]="-";
}
if ($flags[2]==2)
{
if ($arr[$x]["max_count"]==$arr[$x]["min_count"])
$arr[$x]["count"]=$arr[$x]["max_count"];
else
$arr[$x]["count"]=$arr[$x]["min_count"]." - ".$arr[$x]["max_count"];
if ($arr[$x]["percentage"]>=20)
$arr[$x]["chance"]=round($arr[$x]["percentage"], 4)."%";
else
$arr[$x]["chance"]="1/".round((1/$arr[$x]["percentage"])*100);
}
if ($flags[0])
if ($flags[2]!=2)
{
$arr[$x]=accessibility_icon($arr[$x], "drop");
$arr[$x]=accessibility_icon($arr[$x], "spoil");
$arr[$x]=accessibility_icon($arr[$x], "craft");
$arr[$x]=accessibility_icon($arr[$x], "trade");
$arr[$x]=accessibility_icon($arr[$x], "fishing");
$arr[$x]=accessibility_icon($arr[$x], "ssq");
}
else
if ($arr[$x]["type"]==1)
$arr[$x]=accessibility_icon($arr[$x], "spoil");
else
$arr[$x]=accessibility_icon($arr[$x], "drop");
$arr[$x]["screen"]=" ";
if ($flags[1]&& ($type=="weapon"||($type=="armor"&&in_array($subtype, array("chest", "legs", "onepiece", "feet", "gloves", "shield", "hair")))))
{
if (file_exists($dirs["screens_items"].$arr[$x]["id"].".jpg") || ($parents[$arr[$x]["id"]]>0 && file_exists($dirs["screens_items"].$parents[$arr[$x]["id"]].".jpg")))
$img_height=450;
elseif(file_exists($dirs["screens_items"].$arr[$x]["id"]."_0_1.jpg") || ($parents[$arr[$x]["id"]]>0 && file_exists($dirs["screens_items"].$parents[$arr[$x]["id"]]."_0_1.jpg")))
$img_height=480;
else
$img_height=0;
if ($img_height>0)
$arr[$x]["screen"]="<a href=\"pages/show_screen.php?type=item&id=".$arr[$x]["id"]."\" onclick=\"return hs.htmlExpand(this, { objectType: 'iframe', objectHeight: $img_height, width: 410 } )\">".$ss->img($dirs["images"]."screen_1.png", "class=ib-gold, width=$i2_size, height=$i2_size")."</a>";
else
$arr[$x]["screen"]=$ss->img($dirs["images"]."screen_0.png", "class=ib-gray, width=$i2_size, height=$i2_size");
}
$ss->tr_s();
$ss->table_v(array($arr[$x]["icon"], "cell-i-$i1_size"), array($arr[$x]["name"], "cell-n p5"), false);
if ($flags[1]&&($type=="weapon"||($type=="armor"&&in_array($subtype, array("chest", "legs", "onepiece", "feet", "gloves", "shield", "hair")))))
$ss->table_v(array($arr[$x]["screen"], "cell-i-$i1_size"), false);
if ($flags[2]==1||$flags[2]==4)
{
if ($type=="armor"&&!in_array($subtype, array("hair", "agathon")))
$ss->table_v(array($arr[$x]["physical_defense"], "cell-n ar p5"), false);
if ($type=="weapon")
{
$ss->table_v(array($arr[$x]["physical_damage"], "ar p5"), array($arr[$x]["magical_damage"], "ar p5"), array($arr[$x]["hands"], "ac"), array($arr[$x]["soulshot_count"], "ac"), array($arr[$x]["spiritshot_count"], "ac"), array($arr[$x]["attack_speed"], "ac"), "cell-n", false);
if ($subtype=="bow"||$subtype=="shadow")
$ss->table_v(array($arr[$x]["mp_consume"], "cell-n ac"), false);
}
if ($type=="accessary"&&!in_array($subtype, array("bracelet", "talisman")))
$ss->table_v(array($arr[$x]["magical_defense"], "ar p5"), array($arr[$x]["mp_bonus"], "ar p5"), "cell-n", false);
if ($type=="armor"&&$subtype=="shield")
$ss->table_v(array($arr[$x]["shield_defense_rate"]."%", "ac"), array($arr[$x]["avoid_modify"], "ac"), "cell-n", false);
if ($type=="armor"&&($subtype=="chest"||$subtype=="legs"||$subtype=="onepiece"))
$ss->table_v(array(str("armor_".$arr[$x]["armor_type"]), "ac"), array($arr[$x]["mp_bonus"], "ar p5"), "cell-n", false);
if (in_array($type, array("armor", "weapon", "accessary"))&&!in_array($subtype, array("pet", "hair", "agathon", "shadow", "bracelet", "talisman")))
$ss->table_v(array($arr[$x]["crystal_count"], "cell-n ar p5"), false);
if ($type=="recipe")
$ss->table_v(array($arr[$x]["lvl"], "ac"), array($arr[$x]["success_rate"]."%", "ar p5"), "cell-n", false);
if ($type=="etc"||$type=="recipe"||$type=="quest")
$ss->table_v(array($arr[$x]["stackable"], "cell-n ac"), false);
$ss->table_v(array(number_format($arr[$x]["weight"]), "cell-n ar p5"), false);
if ($subtype!="shadow")
$ss->table_v(array(format_price($arr[$x]["price"]), "cell-n ar p5"), false);
}
if ($flags[2]==2)
$ss->table_v(array($arr[$x]["count"], "ac p5"), array($arr[$x]["chance"], "ar p5"), "cell-n", false);
if ($subtype=="shadow"||$subtype=="talisman")
$ss->table_v(array($arr[$x]["life_time"]."m", "cell-n ar p5"), false);
if ($flags[0])
if ($flags[2]!=2)
{
$ss->td_s();
$ss->table_s("spacing=1");
if ($small_icons)
$ss->table_v(array($arr[$x]["drop"]), array($arr[$x]["spoil"]), array($arr[$x]["craft"]), array($arr[$x]["fishing"]), array($arr[$x]["trade"]), array($arr[$x]["ssq"]));
else
{
$ss->table_v(array($arr[$x]["drop"]), array($arr[$x]["fishing"]), array($arr[$x]["trade"]));
$ss->table_v(array($arr[$x]["spoil"]), array($arr[$x]["craft"]), array($arr[$x]["ssq"]));
}
$ss->table_e();
$ss->td_e();
}
else
{
$ss->td_s();
$ss->table_s("spacing=1");
if ($flags[2]!=2)
if ($small_icons)
$ss->table_v(array($arr[$x]["drop"]), array($arr[$x]["spoil"]));
else
{
$ss->table_v(array($arr[$x]["drop"]));
$ss->table_v(array($arr[$x]["spoil"]));
}
else
if ($arr[$x]["type"]>1)
$ss->table_v(array($arr[$x]["drop"], "cell-i-$i1_size"));
else
$ss->table_v(array($arr[$x]["spoil"], "cell-i-$i1_size"));
$ss->table_e();
$ss->td_e();
}
$ss->tr_e();
}
$ss->table_e();
}
?>
и в новой версии:
PHP код:
<?
if ($hide_unless_items) $cond.=" AND visible=1";
db_connect();
$result=$db->query("SELECT COUNT(id) AS count FROM items WHERE $cond");
$total_count=$db->fetch_assoc($result, "count");
if ($total_count>$rpp)
{
$pages_count=ceil($total_count/$rpp);
$start=($page-1)*$rpp;
$count=$rpp;
if ($type=="armor" && in_array($subtype, array("chest", "legs", "fullarmor")))
pages_control($page, $pages_count, "PAGES", "?show=items&type=$type&subtype=$subtype&class=$class", 25);
else
pages_control($page, $pages_count, "PAGES", "?show=items&type=$type&subtype=$subtype", 25);
}
else
{
$start=0;
$count=$total_count;
}
$result=$db->query("SELECT * FROM items WHERE $cond ORDER BY $sort LIMIT $start, $count");
$data=$db->get_array($result);
if (count($data)>0)
{
for ($x=0; $x<count($data); $x++)
{
if ($data[$x]["add_name"]!="") $data[$x]["name"].=" [<span class='add-name'>{$data[$x]['add_name']}</span>]";
$hint=(trim($data[$x]["info"])!="") ? hint($data[$x]["name"], $data[$x]["info"], 400) : "";
$data[$x]["name"]="<a href='?show=item_info&id={$data[$x]['id']}' $hint>{$data[$x]['name']}</a>";
$data[$x]["crystal_count"]=($data[$x]["crystal_type"]>0 && $data[$x]["crystal_count"]>0 && $data[$x]["crystallizable"]==1) ? "<span class='grade_{$data[$x]['crystal_type']}'>".number_format($data[$x]["crystal_count"])." {$grade_list[$data[$x]['crystal_type']]}x</span>" : "-";
$tpl->insert_loop("main.body.list.$type.item",
array(ID=>$data[$x]["id"],
ICON=>$data[$x]["icon"],
NAME=>$data[$x]["name"],
CRY_TYPE=>$data[$x]["crystal_type"],
CRY_COUNT=>$data[$x]["crystal_count"],
P_ATK=>$data[$x]["p_atk"],
M_ATK=>$data[$x]["m_atk"],
P_DEF=>($type!="shield") ? $data[$x]["p_def"] : $data[$x]["shield_def"],
M_DEF=>$data[$x]["m_def"],
ATK_SPEED=>$data[$x]["atk_speed"],
CRITICAL=>$data[$x]["critical"],
MP_CONSUME=>$data[$x]["mp_consume"],
MP_BONUS=>$data[$x]["mp_bonus"],
WEIGHT=>number_format($data[$x]["weight"]),
LIFE_TIME=>(($data[$x]["durability"]>0 && in_array($type, array("weapon", "armor", "accesory"))) || ($data[$x]["durability"]>0 && $data[$x]["temporal"]==1)) ? "{$data[$x]['durability']}m" : "∞",
PRICE=>str_price($data[$x]["price"]),
SS=>$data[$x]["ss"],
SPS=>$data[$x]["sps"],
HANDS=>($data[$x]["bodypart"]=="lrhand") ? "2H" : "1H",
DROP=>($data[$x]["drop_flag"]==1) ? "[<a href='?show=item_info&type=drop&id={$data[$x]['id']}'><span class='yes'>drop</span></a>] " : "",
SPOIL=>($data[$x]["spoil_flag"]==1) ? "[<a href='?show=item_info&type=spoil&id={$data[$x]['id']}'><span class='yes'>spoil</span></a>] " : "",
CRAFT=>($data[$x]["craft_flag"]==1) ? "[<a href='?show=item_info&type=craft&id={$data[$x]['id']}'><span class='yes'>craft</span></a>] " : "",
TRADE=>($data[$x]["trade_flag"]==1) ? "[<a href='?show=item_info&type=trade&id={$data[$x]['id']}'><span class='yes'>trade</span></a>] " : "",
MULTISELL=>($data[$x]["multisell_flag"]==1) ? "[<a href='?show=item_info&type=trade&id={$data[$x]['id']}'><span class='yes'>multisell</span></a>] " : "",
MANOR=>($data[$x]["manor_flag"]==1) ? "[<a href='?show=item_info&type=manor&id={$data[$x]['id']}'><span class='yes'>manor</span></a>] " : "",
FISHING=>($data[$x]["fishing_flag"]==1) ? "[<a href='?show=item_info&type=fishing&id={$data[$x]['id']}'><span class='yes'>fishing</span></a>] " : "",
QUEST=>($data[$x]["quest_flag"]==1) ? "[<a href='?show=item_info&type=quest&id={$data[$x]['id']}'><span class='yes'>quest</span></a>] " : "",
STYLE=>$x%2,
));
}
$tpl->parse("main.body.list.$type");
$tpl->parse("main.body.list");
}
else
$tpl->parse("main.body.no_data");
?>
пусть пока и по функциональности новая верси послабее, но разница в удобстве и простоте чтения кода как видишь налицо
|