/**
  * Get file full path
  *
  * @param string $path     file path
  * @param string $basepath file base path
  */
 public function GetFullPath(&$path, $basepath = '')
 {
     // When parsing CSS need to pass temporary basepath -
     // so links are relative to current stylesheet
     if (!$basepath) {
         $basepath = $this->basepath;
     }
     //Fix path value
     $path = str_replace('\\', '/', $path);
     //If on Windows
     // mPDF 5.7.2
     if (substr($path, 0, 2) == '//') {
         $tr = parse_url($basepath);
         $path = $tr['scheme'] . ':' . $path;
         // mPDF 6
     }
     $regexp = '|^./|';
     // Inadvertently corrects "./path/etc"
     //and "//www.domain.com/etc"
     $path = preg_replace($regexp, '', $path);
     if (substr($path, 0, 1) == '#') {
         return;
     }
     if (preg_match('@^(mailto|tel|fax):.*@i', $path)) {
         return;
     }
     if (substr($path, 0, 3) == '../') {
         $filepath = str_replace('../', '', $path);
         $objFile = new \Cx\Lib\FileSystem\FileSystemFile($filepath);
         $path = $objFile->getAbsoluteFilePath();
     } elseif (strpos($path, ':/') === false || strpos($path, ':/') > 10) {
         $objFile = new \Cx\Lib\FileSystem\FileSystemFile($path);
         $path = $objFile->getAbsoluteFilePath();
     }
 }
 public function makeWritable()
 {
     $this->initConnection();
     // fetch current permissions on loaded file through FileSystemFile object
     try {
         $objFile = new \Cx\Lib\FileSystem\FileSystemFile($this->passedFilePath);
         $filePerms = $objFile->getFilePermissions();
         \DBG::msg('FTPFile: Fetched file permissions of ' . $this->passedFilePath . ': ' . substr(sprintf('%o', $filePerms), -4));
     } catch (FileSystemFileException $e) {
         throw new FTPFileException($e->getMessage());
     }
     // abort process in case the file is already writable
     // test: check write access for file owner
     if ($filePerms & \Cx\Lib\FileSystem\FileSystem::CHMOD_USER_WRITE) {
         return true;
     }
     // this is probably not required for FTP - TD / 11/1/2012
     /*$parentDirectory = dirname($this->passedFilePath);
       if (!is_writable($parentDirectory)) {
           if (strpos($parentDirectory, ASCMS_DOCUMENT_ROOT) === 0) {
               // parent directory lies within the Cloudrexx installation directory,
               // therefore, we shall try to make it writable
               \Cx\Lib\FileSystem\FileSystem::makeWritable($parentDirectory);
           } else {
               \DBG::msg('Parent directory '.$parentDirectory.' lies outside of Cloudrexx installation and can therefore not be made writable!');
           }
       }*/
     // set write access to file owner
     $filePerms |= \Cx\Lib\FileSystem\FileSystem::CHMOD_USER_WRITE;
     // log file permissions into the humand readable chmod() format
     \DBG::msg('FTPFile: CHMOD: ' . substr(sprintf('%o', $filePerms), -4));
     if (!ftp_chmod($this->connection, $filePerms, $this->filePath . '/' . $this->file)) {
         throw new FTPFileException('FTPFile: Unable to set write access to file ' . $this->filePath . '/' . $this->file . '!');
     }
 }