isSoap) throw new SoapFault($errorType, $msg); else exit(json_encode(array("error" => $msg))); } public function initWS($username, $password, $sessionID, $setPathOnly, $isSoap) { $this->user = trim($username); if (isset($sessionID)) $this->sessionID = trim($sessionID); if (isset($password)) $this->passwd = trim($password); $this->isSoap = $isSoap; if (isset($password) && ! $setPathOnly) { // Check if user has DD session already open, otherwise - login if ($this->ddCheckUser() != 0) { if ($this->ddLogin() != 0) { // DD Login if user is not registered $this->throwError("loginError", "Login procedure failed for $username : Check your password"); } if ($this->ddCheckUser() != 0) { $this->throwError("loginError", "CheckUser procedure failed for $username : Check your password"); } } } $this->userdir = USERPATH."/".$this->user."/"; if (!is_dir($this->userdir)) { if (!$this->createDir()) { $this->throwError("loginError", "Cannot create UserDir"); } } $this->setPath(); if ( $setPathOnly ) return array('success' => true); $this->makeLocalTree(); $this->makeRemoteTree(); return array('success' => true); } } ?>