Post Pacific

Post Pacific (https://postpacific.loc-online.com/index.php)
-   Темы без сохранившегося раздела (https://postpacific.loc-online.com/forumdisplay.php?f=10001)
-   -   CacheD problem (https://postpacific.loc-online.com/showthread.php?t=6435)

SkyFabrik 16.12.2006 13:04

CacheD problem
 
Hi everyone.
Have some big problem with CacheD. When i add some stuff from CacheD after restart server, items disappear. Do any one know where is problem ? In php script or in CacheD server configuration ?

There is my php script
PHP Code:

   var $ip = "1xx.xx8.1.2";
   var 
$port = "2012";
   var 
$fp;
   var 
$conn;
   var 
$cmd;
   var 
$name;  

   function 
connect ($name="", $p0="") {
       
$this->name = $name;
       
$this->fp = fsockopen($this->ip, $this->port, $errno, $errstr, 5); 
       if(
$this->fp)
       {
          
$this->conn = 1;
          return 
1;
       }
       else
       {
          
$this->log("err", $p0, '', '', '', '', '', '', '', '', '', 'Error connecting to cached: '.$errstr.' ['.$this->name.']');
          
$this->conn = 0;
          die(
"<script>alert('Error connecting to cached: $errstr [server down??]')</script>");
       } 
   }
   function 
log($sub="---", $p0="---", $p1="---", $p2="---", $p3="---", $p4="---", $p5="---", $p6="---", $p7="---", $p8="---", $p9="---", $com="---")
   {
          
$date = date("[m][d][H:i:s]");
          
$ip = getenv("REMOTE_ADDR");
          
$this->mydb = new mydb($this->mydb_user, $this->mydb_pass, $this->mydb_name, $this->mydb_host);
          
$this->mydb->query("INSERT INTO `log_credits` VALUES ('', \"$p0\", \"$p1\", \"$p2\", \"$p3\", \"$p4\", \"$p5\", \"$p6\", \"$p7\", \"$p8\", \"$p9\", \"$sub\", \"$date\", \"$com\", \"$ip\")"); 

          
/*$filename = $this->name . "_" . $sub;
          $somecontent = $date . " msg: " . $msg . "\n";
          $handle = fopen($filename, 'a');
          fwrite($handle, $somecontent);
          fclose($handle); */
   
}
   function 
close () {
       if (
$this->fp) { fclose($this->fp); $this->conn = 0; }
   }
   function 
tounicode($string) {
       
$rs = ""; for($i = 0; $i < strlen($string); $i++) $rs .= $string[$i].chr(0);
       return(
$rs.chr(0).chr(0));
   }


   function 
CheckCharacterPacket($p0) {
       
$this->connect();
       
$rs = "x";
       
$buf = pack("c", 1); // 1 = CheckCharacterPacket();
       
$buf .= pack("i", $p0); //char_id

       
fwrite($this->fp, pack("s", (strlen($buf)+2)).$buf);
       
$len = unpack("v", fread($this->fp, 2)); $rid = unpack("c", fread($this->fp, 1));
       for (
$i = 0; $i < (($len[1]-4) / 4); $i++) { $read = unpack("i", fread($this->fp, 4)); $rs .= $read[1]; }
       
$this->close(); 

       return(
$rs);
   }

   function 
KickCharacterPacket($p0) {
       
$this->connect();
       
$rs = "x";
       
$buf = pack("c", 5); // 1 = CheckCharacterPacket();
       
$buf .= pack("i", $p0); //char_id
    
       
fwrite($this->fp, pack("s", (strlen($buf)+2)).$buf);
       
$len = unpack("v", fread($this->fp, 2)); $rid = unpack("c", fread($this->fp, 1));
       for (
$i = 0; $i < (($len[1]-4) / 4); $i++) { $read = unpack("i", fread($this->fp, 4)); $rs .= $read[1]; }
       
//$this->log('use', $p0, '', '', '', '', '', '', '', '', '', "$this->name Kick'as");
       
$this->close(); return($rs);
   }


   function 
AddItem2Packet($p0, $p1, $p2, $p3, $p4, $p5 , $p6, $p7, $p8, $p9, $name="") {
       
$this->connect($name, $p0);
       
$rs = "x";
       
$buf = pack("c", 66); // 4 = ChangeCharacterNamePacket();
       
$buf .= pack("i", $p0); //char_id
       
$buf .= pack("i", $p1); //ware
       
$buf .= pack("i", $p2); //item_id
       
$buf .= pack("i", $p3); //amount
       
$buf .= pack("i", $p4); //enchants
       
$buf .= pack("i", $p5); //eroded
       
$buf .= pack("i", $p6); //bless
       
$buf .= pack("i", $p7); //ident
       
$buf .= pack("i", $p8); //wished
       
$buf .= $this->tounicode($p9); //1

       

       
fwrite($this->fp, pack("s", (strlen($buf)+2)).$buf);
       
$len = unpack("v", fread($this->fp, 2)); $rid = unpack("c", fread($this->fp, 1));
       for (
$i = 0; $i < (($len[1]-4) / 4); $i++) { $read = unpack("i", fread($this->fp, 4)); $rs .= $read[1]; }
       
$this->log("use", $p0, $p1, $p2, $p3, $p4, $p5, $p6, $p7, $p8, $p9, "$this->name pirkimas");
       
$this->close(); return($rs);
   }


} 


Drag 16.12.2006 19:37

Let the CacheD save data into SQL :)
First try to log off then shutdown server.

SkyFabrik 17.12.2006 15:59

Ghmz sometimes item disappear sometimes still in inventor. If i sale item for 1 adena item doesnt disappear .


All times are GMT. The time now is 15:26.