Jump to content

Big Bunch of code i just can't understand...


FrozenGod

Recommended Posts

Hello guys i'am new here, i'am helping a friend with something that works on MSSQL (Game Server),

i have downloaded a system thad shows the "Inventory/Items/Equip" of the character,

but its not what i need - i need it to SEND values to MSSQL (With exactly the same structure, so it will work on he's game)

and i just can't understand this structure and the way it built! i know that |Binary| is Image, but in this case it isn't a image..

 

<?php
$name=$_GET['name'];
$inf=$_GET['inf'];
?>
<form action="" method="GET" name="name">
<input type="hidden" name="act" value="char" />
<input type="hidden" name="inf" value="<?php echo $inf; ?>" />
<input type="text" name="name" value="<?php echo $name; ?>" size=20 class="nb10" />
<input type="submit" value="search" class="b10" />  
<?php
if(is_array($_SESSION["hist"]["search"])&&count($_SESSION["hist"]["search"])){
    $arr=array();
    $n_arr=array();
    for($i=count($_SESSION["hist"]["search"])-1;$i>=count($_SESSION["hist"]["search"])-5;$i--){
        $n=$_SESSION["hist"]["search"][$i];
        if($n){
            $arr[]="<a href=\"?act=char&inf=".$inf."&name=".$n."\" class=\"ia10link\">".$n."</a>";
            $n_arr[]=$n;
        }
    }
    $_SESSION["hist"]["search"]=array_reverse($n_arr);
    echo "<font class=\"nb10\">".implode(" | ",$arr)."</font>";
}

?>
</form>
<P />
<?php


if($name){
if(strpos($name," ")!==false||strpos($name,"'")!==false)die("Wrong name");
$a=mssql_query("Select CID from CharInfo Where name ='".$name."'");
$b=mssql_fetch_row($a);
$id=$b[0];
if($id || $ids){
if(!is_array($_SESSION["hist"]["search"])||!in_array($name,$_SESSION["hist"]["search"]))$_SESSION["hist"]["search"][]=$name;
$script=loadScript("quest.txt");
$itemScript=loadItemScript("ItemScript.txt");

$idArr=array();
if($ids)$idArr=explode(",",$ids);
if($id)$idArr[]=$id;
$perPage=8;

if(!$inf){
////////////////////////// USER INFO ///////////////////
function drawUInfoTable($name,$data){
?>
<table width="200" height="150" style="background-color:#99aaFF;border:1px solid black">
<tr><td width="100%" valign="top"><table>
<tr><td colspan=4 class="b12"><?php echo $name; ?></td></tr>
<?php
foreach($data as $n=>$v){
    echo "<tr><td width=\"10\"></td><td class=\"b10\">".$n."</td><td></td><td class=\"nb10\">".$v."</td></tr>";
}
?>
</table></td></tr>
</table>
<?php
}

$ignoreInfoCols=array("Equip");
$maxRows=5;
$classes=array("","Fighter","Rogue","Mage","Acolyte","Defender","Warrior","Asassin","Archer","Sorcerer","Enchanter","Priest","Cleric",
        "","","","","Combatant","Officiator","Templar","Attacker","Gunner","Rune Off.","Life Off.","Shadow Off.");
$a=mssql_query("Select * FROM CharInfo Where cid IN (".implode(", ",$idArr).")");
while($b=mssql_fetch_array($a)){
    $id=$b['CID'];

    /// Replace Race with Name of Race ///
    If($b['Race'] == 0){
        $b["Race"]="Human";}
    ElseIf($b['Race'] == 1) {
        $b["Race"]="Akkan";}
    /// End of Race Replacement ///

    $b["Class"]=$classes[$b["Class"]];
    $accChars=array();
    $c=mssql_query("Select * FROM UserInfo WHERE (Char1=$id OR Char2=$id OR Char3=$id OR Char4=$id OR Char5=$id)");
    $d=mssql_fetch_array($c);
    if($d){
        $b["UID"]=$d['UID'];
        /// Replace Number of Nation with Name ///
        If($d['Nation'] == 1){
            $b["Nation"]="Kartefant";}
        ElseIf($d['Nation'] == 2) {
            $b["Nation"]="Merkhadian";}
        /// End of Nation Replacement ///

        mssql_select_db("pay_gamemyth");
        $e=mssql_query("Select * FROM TblCurrentUser WHERE UID=".$d['UID']);
        $f=mssql_fetch_array($e);
        if($f){
            $b["Login"]=$f['strClientID'];
            $b["IPa"]=$f['strIP'];
        }else{
            /// Fixed Else by Stealthy ///
            mssql_select_db("Youxiuser");
            $query=mssql_query("Select * FROM Usertbl WHERE UID=".$d['UID']);
            $result=mssql_fetch_row($query);
            $b["Login"]=$result[1];
            $b["IPa"]="Not online.";
        }
        mssql_select_db($def_db);
        ?>
        <table>
        <?php
        for($i=1;$i<6;$i++){
            $n=nameForCid($d['Char'.$i]);
            if($n)$accChars["Pos ".$i]="<a href=\"?act=char&name=".$n."\" class=\"b10link\">".$n."</a>";
        }
        ?>
        </table><br>
        <?php
    }
$mInfo=array(
    "User is"=>($b["IPa"]=="Not online."?"<font color=\"#FF0000\">offline</font>":"<font color=\"#00FF00\">online</fornt>"),
    "Account"=>$b["Login"]." (".$b["UID"].")",
    "Char"=>$b["Name"]." (".$b["CID"].")",
    "IP"=>$b["IPa"],
    "Nation"=>$b["Nation"],
    "Race"=>$b["Race"],
    "Class"=>$b["Class"],
    "Level"=>$b["Level"]
);
$lookInfo=array(
    "Sex"=>$b["Sex"],
    "Hair"=>$b["Hair"],
    "Face"=>$b["Face"],
    " "=>" ",
    "Guild"=>$b["Guild"],
    "Party"=>$b["Party"]
);
$pointsInfo=array(
    "STR"=>$b["STR"],
    "DEX"=>$b["DEX"],
    "CON"=>$b["CON"],
    "INT"=>$b["Intell"],
    "WIS"=>$b["WIS"],
    "Unused"=>$b["IP"]
);
$statsInfo=array(
    "Fame"=>$b["Fame"],
    "Medals"=>$b["Mileage"],
    "Gold"=>number_format($b["Gold"], 0, '', ' '),
    "HP"=>$b["HP"],
    "MP"=>$b["MP"],
    "Exp"=>number_format($b["Exp"], 0, '', ' '),
    "Chance"=>$b["Chance"]
);
?>
    <table><tr><td width="100"></td><td><table>
    <tr><td colspan=3 align="center"><?php drawUInfoTable("Main info",$mInfo); ?></td></tr>
    <tr><td height="5"></td></tr>
    <tr><td><?php drawUInfoTable("Status",$statsInfo); ?></td><td width="5"></td><td><?php drawUInfoTable("Status points",$pointsInfo); ?></td></tr>
    <tr><td height="5"></td></tr>
    <tr><td><?php drawUInfoTable("Look",$lookInfo); ?></td><td></td><td><?php drawUInfoTable("Account chars",$accChars); ?></td></tr>
    </table></td></tr></table>
<?php

}

} // if ! inf
if($inf=="quest"){
//////////////////////////// QUESTS /////////////////
$a = mssql_query("Select c.CID, c.Name, CAST(q.Quest as image) as Quest, CAST(q.History as image) as History from Quest q, CharInfo c where c.CID IN (".implode(", ",$idArr)." ) and q.cid=c.cid"); 
while($b=mssql_fetch_array($a)){
    $cid=$b[0];
    $name=$b[1];
    $quests=array_reverse(getQuestList($b['Quest']));
    $hist=array_reverse(getHistoryList($b['History']));
?>
    <table><tr><td colspan=2 class="b10">Char <?php echo $name; ?>, ID <?php echo $cid; ?></td></tr>
        <tr><td width="300" style="border:1px solid black;background-color: red" class="b12">Active quests (Total of <?php echo count($quests); ?>)</td><td width="20"></td><td width="300" style="border:1px solid black;background-color: green" class="b12">Completed quests (Total of <?php echo count($hist); ?>)</td></tr>
        <tr>
        <td valign="top"><table width="100%" style="">
<?php
    if($b['Quest']){
        $cnt=8;
        $page=0;
        foreach($quests as $arr){
            if($cnt>7){ $cnt=0; $page++; echo "<tr><td style=\"border: 1px solid black;background-color: #22FF33\" class=\"b10\">Page ".$page."/".ceil(count($quests)/$perPage)."</td></tr>"; }
            $qDesc = $script[$arr[0]];
            $qiid=strtoupper(dechex($arr[0]));
            $qiid=str_repeat("0",(4-strlen($qiid))).$qiid;
            if(!$qDesc)$qDesc=array("Unknown quest","LV ??",array("??"),array("??"));
            echo "<tr><td><table style=\"border:1px solid black;background-color:#FFFF99\" width=\"100%\">";
            echo "<tr><td class=\"nb10punane\"><b>[0x".$qiid."] ".$qDesc[0]." (".$qDesc[1].")</b></td><td align=\"right\" class=\"nb10punane\"><b>".floor(($arr[1]/count($qDesc[2]))*100)."%</b></td></tr>";
            echo "<tr><td class=\"nb10\">Next task:<br>".str_replace("\\\\","<br>",$qDesc[2][$arr[1]])."</td><td valign=\"top\" class=\"b10\">Phase Nr. ".$arr[1]."</td></tr>";
            echo "<tr><td class=\"nb10\" colspan=\"2\">Trigger: ".$qDesc[3][$arr[1]]."</td></tr>";
            echo "<tr><td class=\"nb10\" colspan=\"2\">Phase has ".($qDesc[4][$arr[1]]?$qDesc[4][$arr[1]]:"no")." marked location".($qDesc[4][$arr[1]]<>1?"s":"")."</td></tr>";
            echo "</table></td></tr>";
            $cnt++;
        }
    }
?>
        </table></td><td></td>
        <td valign="top"><table width="100%" style="">
<?php
    if($b['History']){
        $cnt=8;
        $page=0;
        foreach($hist as $qid){
            if($cnt>7){ $cnt=0; $page++; echo "<tr><td style=\"border: 1px solid black;background-color: #22FF33\" class=\"b10\">Page ".$page."/".ceil(count($hist)/$perPage)."</td></tr>"; }
            $qDesc = $script[$qid];
            $qiid=strtoupper(dechex($qid));
            $qiid=str_repeat("0",(4-strlen($qiid))).$qiid;
            if(!$qDesc)$qDesc=array("Unknown quest","LV ??",array("??"));
            echo "<tr><td><table style=\"border:1px solid black;background-color:#FFFF99\" width=\"100%\">";
            echo "<tr><td class=\"nb10\">[0x".$qiid."] ".$qDesc[0]." (".$qDesc[1].")</td></tr>";
            echo "</table></td></tr>";
            $cnt++;
        }
    }
?>
        </table></td>
        </tr>
    </table><p />
<?php

}
} // if inf = quest
if($inf=="eq"){
/////////////////////////////////////////////////// EQ ///////////////////////////////////////////
$gemNames=array("Free",
    "Ruby(s)","Emerald(s)","Saphire(s)","Diamond(s)","Blackmoon(s)",
    "Ruby(m)","Emerald(m)","Saphire(m)","Diamond(m)","Blackmoon(m)",
    "Ruby(L)","Emerald(L)","Saphire(L)","Diamond(L)","Blackmoon(L)"
);
$statNames=array("","Max dmg","Min dmg","Defence","Hit rate","Evade","Max HP","HP recovery","MP","MP recovery","Critical","Block rate","Speed","Magic","Magic resistance");
$a = mssql_query("Select c.CID, c.Name, CAST(q.Equip as image) as Equip, CAST(q.Inventory as image) as Inventory from CharItem q, CharInfo c where c.CID IN (".implode(", ",$idArr)." ) and q.cid=c.cid"); 
while($b=mssql_fetch_array($a)){
    $cid=$b['CID'];
    $name=$b['Name'];
    $inv=getItem($b['Inventory']);
    $eq=getItem($b['Equip']);
    ?>
    <table><tr><td colspan=2 class="b10">Char <?php echo $name; ?>, ID <?php echo $cid; ?></td></tr>
        <tr><td width="200" style="border:1px solid black;background-color: red" class="b12">Equipment (Total of <?php echo count($eq); ?>)</td><td width="15"></td><td width="200" style="border:1px solid black;background-color: red" class="b12">Inventory (Total of <?php echo count($inv); ?>)</td></tr>
        <tr>
        <td valign="top"><table width="100%">
    <?php
    foreach($eq as $item){
        $data=$itemScript[$item[1]];
        $name="Unknown";
        $limit=$limitStat=$typeName="";
        $adds=array();
        if($data){
            $name=$data["ItemName"];
            $typeName=$data["TypeName"];
            if(count($item[5])>0){
                $limitStat=$data["LimitStat"];
                $limit=$data["Limit"];
                $adds[1]=$data["MaxDamage"];
                $adds[2]=$data["MinDamage"];
                $adds[3]=$data["Defence"];
                $adds[11]=$data["Block"];
                foreach($adds as $kk=>$vv)if($vv>0)$item[5][3][$kk]+=$vv;
            }
        }
        echo "<tr><td><table style=\"border:1px solid black;background-color:#FFFF99\" width=\"100%\"><tr><td class=\"nb10punane\">";
        echo "Name: <b>".$name."</b> [".$item[1]."] ".(count($item[5])==0?"<b>X ".$item[3]."</b>":"").($_GET["full"]?"<br> Serial: ".$item[0]:"");
        echo "</td></tr><tr><td align=\"center\" class=\"nb10\">";
        if($typeName)echo "<span class=\"b10\">".$typeName."</span><br>";
        if(count($item[5])>0){ // EQ
            if($limit&&$limitStat)echo "<span class=\"b10\">".$limit." ".$limitStat."</span><br />";
            if($limitStat!="LEVEL")echo "Durability: ".$item[3]."/".$item[5][1]."<br>";
            foreach($item[5][3] as $sI=>$sN){
                echo $statNames[$sI].":".$sN."+<br>";
            }
            if($item[5][4]>0){
                echo "<b>Socks:</b><br>";
                for($sI=0;$sI<$item[5][4];$sI++){
                    $gem=$item[5][2][$sI];
                    echo $gemNames[($gem?$gem:0)].($sI<$item[5][4]-1?" <b>I</b> ":"");
                }
            }
            if($item[5][0]>0)echo "<br>Crafted level: +".$item[5][0]."";
        }
        
        echo "</td></tr></table></td></tr>";
    }
    ?>
        </table></td><td></td><td valign="top"><table width="100%">
    <?php
    $prevPage=-1;
    foreach($inv as $item){
        $data=$itemScript[$item[1]];
        $name="Unknown";
        $limit=$limitStat=$typeName="";
        $adds=array();
        if($data){
            $name=$data["ItemName"];
            $typeName=$data["TypeName"];
            if(count($item[5])>0){
                $limitStat=$data["LimitStat"];
                $limit=$data["Limit"];
                $adds[1]=$data["MaxDamage"];
                $adds[2]=$data["MinDamage"];
                $adds[3]=$data["Defence"];
                $adds[11]=$data["Block"];
                foreach($adds as $kk=>$vv)if($vv>0)$item[5][3][$kk]+=$vv;
            }
        }
        if($item[4][2]<>$prevPage){ $prevPage=$item[4][2]; echo "<tr><td style=\"border: 1px solid black;background-color: #22FF33\" class=\"b10\">Page ".($item[4][2]+1).($item[4][2]==3?" (Quest items)":"")."</td></tr>"; }
        echo "<tr><td><table style=\"border:1px solid black;background-color:#FFFF99\" width=\"100%\"><tr><td class=\"nb10punane\">";
        echo "Name: <b>".$name."</b> [".$item[1]."] ".(count($item[5])==0?"<b>X ".$item[3]."</b>":"").($_GET["full"]?"<br> Serial: ".$item[0]:"");
        echo "</td></tr><tr><td align=\"center\" class=\"nb10\">";
        if($typeName)echo "<span class=\"b10\">".$typeName."</span><br>";
        if(count($item[5])>0){ // EQ
            if($limit&&$limitStat)echo "<span class=\"b10\">".$limit." ".$limitStat."</span><br />";
            if($limitStat!="LEVEL")echo "Durability: ".$item[3]."/".$item[5][1]."<br>";
            foreach($item[5][3] as $sI=>$sN){
                echo $statNames[$sI].":".$sN."+<br>";
            }
            if($item[5][4]>0){
                echo "<b>Socks:</b><br>";
                for($sI=0;$sI<$item[5][4];$sI++){
                    $gem=$item[5][2][$sI];
                    echo $gemNames[($gem?$gem:0)].($sI<$item[5][4]-1?" <b>I</b> ":"");
                }
            }
            if($item[5][0]>0)echo "<br>Crafted level: +".$item[5][0]."";
        }
        
        echo "</td></tr></table></td></tr>";
    }
    
    ?>
        </tr></table></td></tr></table><p />
    <?php
}
} // if inf=eq

} // ids
else echo "<b>The player named \"".$name."\" could not found in the database.</b>";
} // name
?>

 

(Put attention only to the Equip, if someone will know about the quests it will be great to)

 

Some Help on doing page like this but to send values, like "Pack1" - will have couple of items and the user will click it and get the values of this pack with the DB's structure..

 

Thanks Guys!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.