View Single Post
ישן 13-08-07, 13:38   # 8
guycohen
חבר מתקדם
 
מיני פרופיל
תאריך הצטרפות: Jul 2007
מיקום: באר שבע
גיל: 36
הודעות: 690

guycohen לא מחובר  

יש לי בעיקרון בעיה בקוד הבא:

PHP קוד:
<?php
require_once 'constants.inc.php';

class 
DB
{
    var
$_d;var$_f;var$_p;
    function 
DB(){$this->_d=array();$this->_f='';$p=false;}
    function 
open($f,$c=false){if(!is_file($f)){return$c?$this->create($f):0;}$p=@fopen($f,'ab+');if(!$p||!flock($p,LOCK_SH))return 0;include$f;$this->_f=$f;$this->_p=&$p;set_file_buffer($this->_p,0);return 1;}
    function 
create($f){if(!touch($f))return 0;chmod($f,0777);return 1;}
    function 
remove($f){if(is_file($f)){return@unlink($f);}return 1;}
    function 
uset($f){unset($this->_d[$f]);}
    function 
set($f,$v=0){if(is_array($f)){if($v){$this->_d=$f;}else{while(list($k,$v)=each($f))$this->set($k,$v);}}else$this->_d[$f]=$v;}
    function 
get($f){return isset($this->_d[$f])?$this->_d[$f]:exit("Field '$f' does not exist in ".$this->_f);}
    function 
all(){return $this->_d;}
    function 
close(){if($this->_p)fclose($this->_p);$this->DB();}
    function 
save(){$p=&$this->_p;if(!$p)exit("Can't save, no file opened.");$buf=sprintf("<?php\n\$this->_d=%s;\n?>",var_export($this->_d,1));if($p&&flock($p,LOCK_EX)){ftruncate($p,0);fseek($p,0);fwrite($p,$buf);fflush($p);fclose($p);}else exit ( 'Could not open ' $this->_f ' for writting.');}
}
?>
__________________
בברכה, גיא
  Reply With Quote