Esempio n. 1
0
 /**
  * @see	SCM::getHeadRevision()
  */
 public static function getHeadRevision($url, array $loginDetails = array(), array $options = array())
 {
     try {
         self::validateGitPath();
         // not very nice or fast method to find out, but it should work
         self::checkout($url, GIT_TEMPORARY_DIRECTORY, $loginDetails, $options);
         $dir = explode('/', $url);
         $dir = str_replace('.git', '', $dir[count($dir) - 1]);
         $headdir = explode(" ", file_get_contents(FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator(GIT_TEMPORARY_DIRECTORY)) . $dir . '/.git/HEAD'));
         $return = file_get_contents(FileUtil::addTrailingSlash(FileUtil::unifyDirSeperator(GIT_TEMPORARY_DIRECTORY)) . $dir . '/.git/' . trim($headdir[1]));
         $dir = DirectoryUtil::getInstance(FileUtil::addTrailingSlash(GIT_TEMPORARY_DIRECTORY) . $dir);
         $dir->removeComplete();
         return $return;
     } catch (GitException $e) {
         throw $e;
     } catch (SystemException $e) {
     }
 }
 /**
  * @see	Page::readData()
  */
 public function readData()
 {
     parent::readData();
     // validate
     if (!is_dir(CMS_DIR . 'cms_files/') or !is_readable(CMS_DIR . 'cms_files')) {
         throw new NamedUserException(WCF::getLanguage()->get('cms.filemanager.invalidDir'));
     }
     $directory = DirectoryUtil::getInstance(CMS_DIR . 'cms_files/');
     $this->fileList = $directory->getFilesObj();
     foreach ($this->fileList as $fileInfo) {
         if ($fileInfo->isDir()) {
             $this->dirObjects[$fileInfo->getPathname()] = new RecursiveDirectoryIterator(FileUtil::addTrailingSlash($fileInfo->getPathname()));
         }
     }
     print_r($this->dirObjects);
     // display warning if no htaccess file exists
     if (!file_exists(CMS_DIR . 'cms_files/.htaccess')) {
         WCF::getTPL()->assign('displayNoHtaccessWarning');
     }
 }
 public function readPackages()
 {
     WCF::getCache()->addResource('packages-' . $this->source->sourceID, PB_DIR . 'cache/cache.packages-' . $this->source->sourceID . '.php', PB_DIR . 'lib/system/cache/CacheBuilderPackages.class.php');
     $packages = WCF::getCache()->get('packages-' . $this->source->sourceID);
     // read current builds
     $files = DirectoryUtil::getInstance($this->source->buildDirectory, false)->getFiles();
     foreach ($files as $file) {
         if (strrpos($file, '.tar.gz') !== false) {
             $package = new PackageReader($this->source->sourceID, $this->source->buildDirectory . $file, true);
             $data = $package->getPackageData();
             $this->packages[$data['name']][$data['version']] = array('file' => $file, 'xml' => $package->getXML());
         }
     }
 }
 /**
  * Deletes this source.
  */
 public function delete($removeDirs = true)
 {
     if ($removeDirs) {
         try {
             $dir = DirectoryUtil::getInstance($this->sourceDirectory);
             $dir->removeComplete();
         } catch (SystemException $e) {
         }
         try {
             $dir = DirectoryUtil::getInstance($this->buildDirectory);
             $dir->removeComplete();
         } catch (SystemException $e) {
         }
     }
     self::removePosition($this->position);
     // remove main database entry
     $sql = "DELETE\tFROM pb" . PB_N . "_source\n\t\t\tWHERE\tsourceID = " . $this->sourceID;
     WCF::getDB()->sendQuery($sql);
     // remove cached packages
     $sql = "DELETE\tFROM pb" . PB_N . "_source_package\n\t\t\tWHERE\tsourceID = " . $this->sourceID;
     WCF::getDB()->sendQuery($sql);
     // remove cached reference data
     $sql = "DELETE\tFROM pb" . PB_N . "_referenced_package\n\t\t\tWHERE\tsourceID = " . $this->sourceID;
     WCF::getDB()->sendQuery($sql);
     // remove package pre-selections
     $sql = "DELETE\tFROM pb" . PB_N . "_selected_package\n\t\t\tWHERE\tsourceID = " . $this->sourceID;
     WCF::getDB()->sendQuery($sql);
     $this->removePermissions();
 }
 /**
  * Add files and sourceDirectory recursive
  *
  * @param	object	$archive
  * @param	string	$directory
  * @param	string	$file
  * @param	string	$removeDir
  */
 public function addFilesRecursive(&$archive, $directory, $file, $removeDir = '')
 {
     // handle files
     if (!is_dir($directory . $file)) {
         // add file
         $archive->add($directory . $file, '', $directory . $removeDir);
         return;
     }
     // add trailing slash
     $file = FileUtil::addTrailingSlash($file);
     // write directory header
     $directoryHeader = str_replace($removeDir, '', $file);
     if (!empty($directoryHeader)) {
         $status = $archive->writeHeaderBlock($directoryHeader, 0, filemtime($directory . $file), fileperms($directory . $file), '5');
         if ($status === false) {
             throw new SystemException('Unable to write header block for "' . $directory . $file . '".');
         }
     }
     $dir = DirectoryUtil::getInstance($directory . $file, false);
     // proceed with directory content
     foreach ($dir->getFiles() as $filename) {
         if (in_array($filename, $this->excludeFiles)) {
             continue;
         }
         if ($this->ignoreDotFiles && substr($filename, 0, 1) == '.' && !in_array($filename, $this->allowedDotFiles)) {
             continue;
         }
         $this->addFilesRecursive($archive, $directory, $file . $filename, $removeDir);
     }
 }