function ole_pps_file($sNm, $sData = false, $sFile = false) { $this->No = false; $this->Name = $sNm; $this->Type = PpsType_File; $this->PrevPps = false; $this->NextPps = false; $this->DirPps = false; $this->Time1st = false; $this->Time2nd = false; $this->StartBlock = false; $this->Size = false; $this->Data = $sFile === false ? $sData : ''; $this->Child = false; if ($sFile !== false) { if (is_ressource($sFile)) { $this->_PPS_FILE = $sFile; } elseif ($sFile == "") { $fname = tempnam("php_ole"); $this->_PPS_FILE = fopen($fname, "r+b"); } else { $fname = $sFile; $this->_PPS_FILE = fopen($fname, "r+b"); } if ($sData !== false) { fputs($this->_PPS_FILE, $sData); } } }
public function __construct($ressource) { if (!is_ressource($ressource)) { throw new Exception("Ce n'est pas une ressource"); } $this->_collection = $ressource; }
function write($data, $how = ERASE, $mode = CLOSEFILE) { if ($this->mode & WRITE) { if ($mode == NOTCLOSEFILE && !is_ressource($this->fd) || $mode == CLOSEFILE) { if (!($this->fd = @fopen($this->path, $how == ADD ? 'a' : 'w'))) { return false; } } $bytes_to_write = strlen($data); $bytes_written = 0; while ($bytes_written < $bytes_to_write) { $bytes = fwrite($this->fd, substr($data, $bytes_written, 4096)); if ($bytes === false || $bytes == 0) { break; } $bytes_written += $bytes; } parent::write(); return $bytes_written == $bytes_to_write; } else { user_error('File ' . $this->path . ' is open in the read only mode, it can\'t be written.'); } }
function connectDb($server, $username, $pw, $db) { if (isset($this->connect) && is_ressource($this->connect)) { return TRUE; } $this->connect = @mysql_connect($server, $username, $pw); $this->selectdb = @mysql_select_db($db); if (!$this->connect || !$this->selectdb) { return FALSE; } else { return $this->connect; } }