![]() |
|
php tools - Printable Version +- LCKB (https://lckb.dev/forum) +-- Forum: ** OLD LCKB DATABASE ** (https://lckb.dev/forum/forumdisplay.php?fid=109) +--- Forum: Programmers Gateway (https://lckb.dev/forum/forumdisplay.php?fid=196) +---- Forum: Coders Talk (https://lckb.dev/forum/forumdisplay.php?fid=192) +---- Thread: php tools (/showthread.php?tid=3893) |
- Tano - 07-23-2014 Hi all! Anyone have the guide for php tools wizatek had published dv zone? - Wizatek - 07-23-2014 class_lcfile.php <?php class LCFile { var $fp; /** * Creates a new binary file to write to * @param string $fileName The name of the file to create */ function Create($fileName) { $this->fp = fopen($fileName, 'wb'); if ( !$this->fp ) return false; return true; } /** * Write a signed 32bit integer to the file * @param int $val the integer to write to the file */ function WriteInt($val) { fwrite($this->fp, pack('l', $val)); } /** * Writes a signed short to the file * @param short $val the value to write to the file */ function WriteShort($val) { fwrite($this->fp, pack('s', $val)); } /** * Writes a signed byte to the file * @param byte $val the value to write to the file */ function WriteByte($val) { fwrite($this->fp, pack('C', $val)); } /** * Writes a float to the file * @param float $val the value to write to the file */ function WriteFloat($val) { fwrite($this->fp, pack('f', $val)); } /** * Writes a string to the file * @param string $val the value to write to the file */ function WriteString($val) { if ( strlen($val) > 0 ) { $this->WriteInt(strlen($val)); fwrite($this->fp, $val); } else $this->WriteInt(0); } } ?> rareoption.php <?php mysql_connect('localhost', 'root', 'root'); mysql_select_db('newproject_data'); require_once 'class_lcfile.php'; // Create a new file $file = new LCFile(); if(!$file->Create('rareoption_usa.lod')) die('Cannot create file'); // Get max id $result = mysql_query("SELECT max(a_index) FROM t_rareoption"); $row = mysql_fetch_row($result); $max = $row[0]; // Write max id $file->WriteInt($max); // Get all records $result = mysql_query("SELECT * FROM t_rareoption ORDER BY a_index"); while($r = mysql_fetch_array($result)) { $file->WriteInt($r['a_index']); $file->WriteInt($r['a_grade']); $file->WriteInt($r['a_type']); $file->WriteString($r['a_prefix_usa']); $file->WriteInt($r['a_attack']); $file->WriteInt($r['a_defense']); $file->WriteInt($r['a_magic']); $file->WriteInt($r['a_resist']); for($i=0; $i<10; $i++) { $file->WriteInt($r['a_option_index'.$i]); $file->WriteInt($r['a_option_level'.$i]); } } echo 'Done!'; ?> - Walletman987 - 07-23-2014 class_lcfile.php <?php class LCFile { var $fp; /** * Creates a new binary file to write to * @param string $fileName The name of the file to create */ function Create($fileName) { $this->fp = fopen($fileName, 'wb'); if ( !$this->fp ) return false; return true; } /** * Write a signed 32bit integer to the file * @param int $val the integer to write to the file */ function WriteInt($val) { fwrite($this->fp, pack('l', $val)); } /** * Writes a signed short to the file * @param short $val the value to write to the file */ function WriteShort($val) { fwrite($this->fp, pack('s', $val)); } /** * Writes a signed byte to the file * @param byte $val the value to write to the file */ function WriteByte($val) { fwrite($this->fp, pack('C', $val)); } /** * Writes a float to the file * @param float $val the value to write to the file */ function WriteFloat($val) { fwrite($this->fp, pack('f', $val)); } /** * Writes a string to the file * @param string $val the value to write to the file */ function WriteString($val) { if ( strlen($val) > 0 ) { $this->WriteInt(strlen($val)); fwrite($this->fp, $val); } else $this->WriteInt(0); } } ?> rareoption.php <?php mysql_connect('localhost', 'root', 'root'); mysql_select_db('newproject_data'); require_once 'class_lcfile.php'; // Create a new file $file = new LCFile(); if(!$file->Create('rareoption_usa.lod')) die('Cannot create file'); // Get max id $result = mysql_query("SELECT max(a_index) FROM t_rareoption"); $row = mysql_fetch_row($result); $max = $row[0]; // Write max id $file->WriteInt($max); // Get all records $result = mysql_query("SELECT * FROM t_rareoption ORDER BY a_index"); while($r = mysql_fetch_array($result)) { $file->WriteInt($r['a_index']); $file->WriteInt($r['a_grade']); $file->WriteInt($r['a_type']); $file->WriteString($r['a_prefix_usa']); $file->WriteInt($r['a_attack']); $file->WriteInt($r['a_defense']); $file->WriteInt($r['a_magic']); $file->WriteInt($r['a_resist']); for($i=0; $i<10; $i++) { $file->WriteInt($r['a_option_index'.$i]); $file->WriteInt($r['a_option_level'.$i]); } } echo 'Done!'; ?> Thanks wiza, this is what I need. I'll be adding onto that list you made in lcdevzone. - Tano - 07-23-2014 Wizatek, thank you very much! |