Ejemplo n.º 1
0
 /**
  * Load the requested artifacts file and output it to the browser
  *
  * @param array $params
  */
 private function _getDeliverableFile($params)
 {
     /**$projectName = $params['p'];
        $buildTime = $params['buildtime'];
        $file = $params['file'];*/
     $query = urldecode($_SERVER['REQUEST_URI']);
     preg_match("/\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*)/", $query, $matches);
     if (count($matches) != 8) {
         echo "Could not find deliverable";
         die;
     }
     $projectName = $matches[5];
     $buildTime = $matches[6];
     // if buildtime==latest, get latest build
     // latest
     // Xinc_Build_History::get()
     $file = $matches[7];
     $file = str_replace('/', DIRECTORY_SEPARATOR, $file);
     $project = new Xinc_Project();
     $project->setName($projectName);
     try {
         /**$build = Xinc_Build::unserialize($project,
            $buildTime,
            Xinc_Gui_Handler::getInstance()->getStatusDir());*/
         if ($buildTime == 'latest-successful') {
             $build = Xinc_Build_Repository::getLastSuccessfulBuild($project);
             $statusDir = Xinc_Build_History::getLastSuccessfulBuildDir($project);
         } else {
             if ($buildTime == 'latest') {
                 $build = Xinc_Build_Repository::getLastBuild($project);
                 $statusDir = Xinc_Build_History::getLastBuildDir($project);
             } else {
                 $build = Xinc_Build_Repository::getBuild($project, $buildTime);
                 $statusDir = Xinc_Build_History::getBuildDir($project, $buildTime);
             }
         }
         $statusDir .= DIRECTORY_SEPARATOR . Xinc_Plugin_Repos_Deliverable::DELIVERABLE_DIR . DIRECTORY_SEPARATOR;
         /**
          * Replace multiple / slashes with just one
          */
         $fileName = $statusDir . $file;
         $fileName = preg_replace('/\\' . DIRECTORY_SEPARATOR . '+/', DIRECTORY_SEPARATOR, $fileName);
         $realfile = realpath($fileName);
         if ($realfile != $fileName) {
             // check if we have an alias name
             $deliverables = $build->getInternalProperties()->get('deliverables');
             if (is_array($deliverables)) {
                 $aliasTest = basename($file);
                 if (isset($deliverables['aliases']) && isset($deliverables['aliases'][$aliasTest])) {
                     $aliasFile = $deliverables['deliverables'][$deliverables['aliases'][$aliasTest]];
                     if (file_exists($aliasFile) && is_file($aliasFile)) {
                         return $this->_outputDeliverable($aliasFile);
                     }
                 }
             }
             echo "Could not find artifact";
             die;
         } else {
             if (file_exists($fileName) && is_file($realfile)) {
                 return $this->_outputDeliverable($fileName);
             } else {
                 echo "Could not find deliverable";
                 die;
             }
         }
     } catch (Exception $e) {
         echo "Could not find any deliverable";
         die;
     }
 }
Ejemplo n.º 2
0
 /**
  * Load the requested artifacts file and output it to the browser
  *
  * @param array $params
  */
 private function _getDocumentationFile($params)
 {
     /**$projectName = $params['p'];
        $buildTime = $params['buildtime'];
        $file = $params['file'];*/
     $query = urldecode($_SERVER['REQUEST_URI']);
     preg_match("/\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*)/", $query, $matches);
     if (count($matches) != 8) {
         echo "Could not find documentation 1";
         die;
     }
     $projectName = $matches[5];
     $buildTime = $matches[6];
     // if buildtime==latest, get latest build
     // latest
     // Xinc_Build_History::get()
     $file = $matches[7];
     //$file = urldecode($file);
     $file = str_replace('/', DIRECTORY_SEPARATOR, $file);
     $project = new Xinc_Project();
     $project->setName($projectName);
     try {
         /**$build = Xinc_Build::unserialize($project,
            $buildTime,
            Xinc_Gui_Handler::getInstance()->getStatusDir());*/
         if ($buildTime == 'latest-successful') {
             $build = Xinc_Build_Repository::getLastSuccessfulBuild($project);
             $statusDir = Xinc_Build_History::getLastSuccessfulBuildDir($project);
         } else {
             if ($buildTime == 'latest') {
                 $build = Xinc_Build_Repository::getLastBuild($project);
                 $statusDir = Xinc_Build_History::getLastBuildDir($project);
             } else {
                 $build = Xinc_Build_Repository::getBuild($project, $buildTime);
                 $statusDir = Xinc_Build_History::getBuildDir($project, $buildTime);
             }
         }
         $statusDir .= DIRECTORY_SEPARATOR . Xinc_Plugin_Repos_Documentation::DOCUMENTATION_DIR . DIRECTORY_SEPARATOR;
         /**
          * Replace multiple / slashes with just one
          */
         $fileName = $statusDir . $file;
         $fileName = preg_replace('/\\' . DIRECTORY_SEPARATOR . '+/', DIRECTORY_SEPARATOR, $fileName);
         $realfile = realpath($fileName);
         if ($realfile != $fileName) {
             echo "Could not find documentation 2";
             die;
         } else {
             if (file_exists($fileName) && is_file($realfile)) {
                 return $this->_outputDoc($fileName);
             } else {
                 echo "Could not find documentation 3";
                 die;
             }
         }
     } catch (Exception $e) {
         echo "Could not find any documentation";
         die;
     }
 }
Ejemplo n.º 3
0
 public function handleEvent($eventId)
 {
     $this->projectName = $_GET['project'];
     if (isset($_GET['timestamp'])) {
         $this->buildTimeStamp = $_GET['timestamp'];
     }
     $this->project = new Xinc_Project();
     $this->project->setName($this->projectName);
     switch ($eventId) {
         case Xinc_Gui_Event::PAGE_LOAD:
             $handler = Xinc_Gui_Handler::getInstance();
             $statusDir = $handler->getStatusDir();
             if ($this->buildTimeStamp != null) {
                 $fullStatusDir = Xinc_Build_History::getBuildDir($this->project, $this->buildTimeStamp);
             } else {
                 $fullStatusDir = Xinc_Build_History::getLastBuildDir($this->project);
                 $this->buildTimeStamp = Xinc_Build_History::getLastBuildTime($this->project);
             }
             //$statusFile = $fullStatusDir . DIRECTORY_SEPARATOR . 'build.ser';
             $this->build = Xinc_Build::unserialize($this->project, $this->buildTimeStamp, Xinc_Gui_Handler::getInstance()->getStatusDir());
             $timezone = $this->build->getConfigDirective('timezone');
             if ($timezone !== null) {
                 Xinc_Timezone::set($timezone);
             }
             $detailDir = $fullStatusDir;
             /**
              * get History Builds
              */
             //$this->historyBuilds = $this->getHistoryBuilds($statusDir);
             /**
              * Generate the build selector on the right
              */
             $this->_generateBuildsView();
             /**
              * Overview info tab
              */
             $this->_generateSummaryView();
             /**
              * Generate the tab for the log messages
              */
             $this->_generateLogView();
             /**
              * Generate the external tabs that were registered through a hook
              */
             $this->_generateExternalExtensions();
             include Xinc_Data_Repository::getInstance()->getWeb('templates' . DIRECTORY_SEPARATOR . 'dashboard' . DIRECTORY_SEPARATOR . 'detail' . DIRECTORY_SEPARATOR . 'projectDetail.phtml');
             break;
         default:
             break;
     }
     /**
      * restore to system timezone
      */
     $xincTimezone = Xinc_Gui_Handler::getInstance()->getConfigDirective('timezone');
     if ($xincTimezone !== null) {
         Xinc_Timezone::set($xincTimezone);
     } else {
         Xinc_Timezone::reset();
     }
 }
Ejemplo n.º 4
0
 /**
  * Load the requested artifacts file and output it to the browser
  *
  * @param array $params
  */
 private function _getArtifactFile($params)
 {
     /**$projectName = $params['p'];
        $buildTime = $params['buildtime'];
        $file = $params['file'];*/
     $query = urldecode($_SERVER['REQUEST_URI']);
     preg_match("/\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/(.*?)\\/([\\w\\-\\.\\/]+[^#?]+)/", $query, $matches);
     if (count($matches) != 8) {
         echo "Could not find artifact";
         die;
     }
     $projectName = $matches[5];
     $buildTime = $matches[6];
     // if buildtime==latest, get latest build
     // latest
     // Xinc_Build_History::get()
     $file = $matches[7];
     $file = str_replace('/', DIRECTORY_SEPARATOR, $file);
     $project = new Xinc_Project();
     $project->setName($projectName);
     try {
         /**$build = Xinc_Build::unserialize($project,
            $buildTime,
            Xinc_Gui_Handler::getInstance()->getStatusDir());*/
         if ($buildTime == 'latest-successful') {
             $build = Xinc_Build_Repository::getLastSuccessfulBuild($project);
             $statusDir = Xinc_Build_History::getLastSuccessfulBuildDir($project);
         } else {
             if ($buildTime == 'latest') {
                 $build = Xinc_Build_Repository::getLastBuild($project);
                 $statusDir = Xinc_Build_History::getLastBuildDir($project);
             } else {
                 $build = Xinc_Build_Repository::getBuild($project, $buildTime);
                 $statusDir = Xinc_Build_History::getBuildDir($project, $buildTime);
             }
         }
         $statusDir .= DIRECTORY_SEPARATOR . Xinc_Plugin_Repos_Artifacts::ARTIFACTS_DIR . DIRECTORY_SEPARATOR;
         /**
          * Replace multiple / slashes with just one
          */
         $fileName = $statusDir . $file;
         $fileName = preg_replace('/\\' . DIRECTORY_SEPARATOR . '+/', DIRECTORY_SEPARATOR, $fileName);
         $realfile = realpath($fileName);
         if ($realfile != $fileName) {
             echo "Could not find artifact";
             die;
         } else {
             if (file_exists($fileName) && is_file($realfile)) {
                 //echo "here";
                 $contentType = $this->mime_content_type2($fileName);
                 if (!empty($contentType)) {
                     header("Content-Type: " . $contentType);
                 }
                 readfile($fileName);
                 die;
             } else {
                 echo "Could not find artifact";
                 die;
             }
         }
     } catch (Exception $e) {
         echo "Could not find any artifacts";
         die;
     }
 }