/**
  * PopulateProjects
  *
  * Populates the internal list of projects
  *
  * @access protected
  * @throws Exception if file cannot be read
  */
 protected function PopulateProjects()
 {
     $projectRoot = GitPHP_Util::AddSlash(GitPHP_Config::GetInstance()->GetValue('projectroot'));
     foreach ($this->projectConfig as $proj => $projData) {
         try {
             if (is_string($projData)) {
                 // Just flat array of project paths
                 $projObj = new GitPHP_Project($projectRoot, $projData);
                 $this->projects[$projData] = $projObj;
             } else {
                 if (is_array($projData)) {
                     if (is_string($proj) && !empty($proj)) {
                         // Project key pointing to data array
                         $projObj = new GitPHP_Project($projectRoot, $proj);
                         $this->projects[$proj] = $projObj;
                         $this->ApplyProjectSettings($proj, $projData);
                     } else {
                         if (isset($projData['project'])) {
                             // List of data arrays with projects inside
                             $projObj = new GitPHP_Project($projectRoot, $projData['project']);
                             $this->projects[$projData['project']] = $projObj;
                             $this->ApplyProjectSettings(null, $projData);
                         }
                     }
                 }
             }
         } catch (Exception $e) {
             GitPHP_Log::GetInstance()->Log($e->getMessage());
         }
     }
 }
 /**
  * PopulateProjects
  *
  * Populates the internal list of projects
  *
  * @access protected
  * @throws Exception if file cannot be read
  */
 protected function PopulateProjects()
 {
     if (!($fp = fopen($this->projectConfig, 'r'))) {
         throw new Exception(sprintf(__('Failed to open project list file %1$s'), $this->projectConfig));
     }
     $projectRoot = GitPHP_Util::AddSlash(GitPHP_Config::GetInstance()->GetValue('projectroot'));
     while (!feof($fp) && ($line = fgets($fp))) {
         if (preg_match('/^([^\\s]+)(\\s.+)?$/', $line, $regs)) {
             if (is_file($projectRoot . $regs[1] . '/HEAD')) {
                 try {
                     $projObj = new GitPHP_Project($projectRoot, $regs[1]);
                     if (isset($regs[2]) && !empty($regs[2])) {
                         $projOwner = trim($regs[2]);
                         if (!empty($projOwner)) {
                             $projObj->SetOwner($projOwner);
                         }
                     }
                     $this->projects[$regs[1]] = $projObj;
                 } catch (Exception $e) {
                     GitPHP_Log::GetInstance()->Log($e->getMessage());
                 }
             } else {
                 GitPHP_Log::GetInstance()->Log(sprintf('%1$s is not a git project', $projectRoot . $regs[1]));
             }
         }
     }
     fclose($fp);
 }
 /**
  * PopulateProjects
  *
  * Populates the internal list of projects
  *
  * @access protected
  * @throws Exception if file cannot be read
  */
 protected function PopulateProjects()
 {
     $projectRoot = GitPHP_Util::AddSlash(GitPHP_Config::GetInstance()->GetValue('projectroot'));
     foreach ($this->projectConfig as $cat => $plist) {
         if (is_array($plist)) {
             foreach ($plist as $pname => $ppath) {
                 try {
                     $projObj = new GitPHP_Project($projectRoot, $ppath);
                     if ($cat != GITPHP_NO_CATEGORY) {
                         $projObj->SetCategory($cat);
                     }
                     $this->projects[$ppath] = $projObj;
                 } catch (Exception $e) {
                     GitPHP_Log::GetInstance()->Log($e->getMessage());
                 }
             }
         }
     }
 }
 /**
  * AddProject
  *
  * Add project to collection
  *
  * @access private
  */
 private function AddProject($projectPath)
 {
     try {
         $proj = new GitPHP_Project($this->projectDir, $projectPath);
         $category = trim(dirname($projectPath));
         if (!(empty($category) || strpos($category, '.') === 0)) {
             $proj->SetCategory($category);
         }
         if (!GitPHP_Config::GetInstance()->GetValue('exportedonly', false) || $proj->GetDaemonEnabled()) {
             $this->projects[$projectPath] = $proj;
         }
     } catch (Exception $e) {
         GitPHP_Log::GetInstance()->Log($e->getMessage());
     }
 }
 /**
  * LoadHeaders
  *
  * Loads headers for this template
  *
  * @access protected
  */
 protected function LoadHeaders()
 {
     if (isset($this->params['opml']) && $this->params['opml'] === true) {
         $this->headers[] = "Content-type: text/xml; charset=UTF-8";
         GitPHP_Log::GetInstance()->SetEnabled(false);
         $this->preserveWhitespace = true;
     } else {
         if (isset($this->params['txt']) && $this->params['txt'] === true) {
             $this->headers[] = "Content-type: text/plain; charset=utf-8";
             $this->headers[] = "Content-Disposition: inline; filename=\"index.aux\"";
             GitPHP_Log::GetInstance()->SetEnabled(false);
         }
     }
 }
 /**
  * PopulateProjects
  *
  * Populates the internal list of projects
  *
  * @access protected
  * @throws Exception if file cannot be read
  */
 protected function PopulateProjects()
 {
     $projectRoot = GitPHP_Util::AddSlash(GitPHP_Config::GetInstance()->GetValue('projectroot'));
     $use_errors = libxml_use_internal_errors(true);
     $xml = simplexml_load_file($this->projectConfig);
     libxml_clear_errors();
     libxml_use_internal_errors($use_errors);
     if (!$xml) {
         throw new Exception(sprintf('Could not load SCM manager config %1$s', $this->projectConfig));
     }
     foreach ($xml->repositories->repository as $repository) {
         if ($repository->type != 'git') {
             GitPHP_Log::GetInstance()->Log(sprintf('%1$s is not a git project', $repository->name));
             continue;
         }
         if ($repository->public != 'true') {
             GitPHP_Log::GetInstance()->Log(sprintf('%1$s is not public', $repository->name));
             continue;
         }
         $projName = trim($repository->name);
         if (empty($projName)) {
             continue;
         }
         if (is_file($projectRoot . $projName . '/HEAD')) {
             try {
                 $projObj = new GitPHP_Project($projectRoot, $projName);
                 $projOwner = trim($repository->contact);
                 if (!empty($projOwner)) {
                     $projObj->SetOwner($projOwner);
                 }
                 $projDesc = trim($repository->description);
                 if (!empty($projDesc)) {
                     $projObj->SetDescription($projDesc);
                 }
                 $this->projects[$projName] = $projObj;
             } catch (Exception $e) {
                 GitPHP_Log::GetInstance()->Log($e->getMessage());
             }
         } else {
             GitPHP_Log::GetInstance()->Log(sprintf('%1$s is not a git project', $projName));
         }
     }
 }
Exemple #7
0
 /**
  * Execute
  *
  * Executes a command
  *
  * @param string $command the command to execute
  * @param array $args arguments
  * @return string result of command
  */
 public function Execute($command, $args)
 {
     $fullCommand = $this->CreateCommand($command, $args);
     GitPHP_Log::GetInstance()->Log('Begin executing "' . $fullCommand . '"');
     $ret = shell_exec($fullCommand);
     GitPHP_Log::GetInstance()->Log('Finish executing "' . $fullCommand . '"' . "\nwith result: " . $ret);
     return $ret;
 }
 /**
  * ReadQuery
  *
  * Read query into parameters
  *
  * @access protected
  */
 protected function ReadQuery()
 {
     if (isset($_GET['hb'])) {
         $this->params['hashbase'] = $_GET['hb'];
     } else {
         $this->params['hashbase'] = 'HEAD';
     }
     if (isset($_GET['f'])) {
         $this->params['file'] = $_GET['f'];
     }
     if (isset($_GET['h'])) {
         $this->params['hash'] = $_GET['h'];
     }
     if (isset($_GET['o']) && $_GET['o'] == 'js') {
         $this->params['js'] = true;
         GitPHP_Log::GetInstance()->SetEnabled(false);
     }
 }
 /**
  * ReadQuery
  *
  * Read query into parameters
  *
  * @access protected
  */
 protected function ReadQuery()
 {
     GitPHP_Log::GetInstance()->SetEnabled(false);
 }
 /**
  * LoadHeaders
  *
  * Loads headers for this template
  *
  * @access protected
  */
 protected function LoadHeaders()
 {
     if (isset($this->params['plain']) && $this->params['plain'] === true) {
         GitPHP_Log::GetInstance()->SetEnabled(false);
         $this->headers[] = 'Content-type: text/plain; charset=UTF-8';
     }
 }
 /**
  * ReadQuery
  *
  * Read query into parameters
  *
  * @access protected
  */
 protected function ReadQuery()
 {
     if (isset($_GET['h'])) {
         $this->params['hash'] = $_GET['h'];
     }
     if (isset($_GET['f'])) {
         $this->params['path'] = $_GET['f'];
     }
     if (isset($_GET['prefix'])) {
         $this->params['prefix'] = $_GET['prefix'];
     }
     if (isset($_GET['fmt'])) {
         $this->params['format'] = $_GET['fmt'];
     } else {
         $this->params['format'] = GitPHP_Config::GetInstance()->GetValue('compressformat', GITPHP_COMPRESS_ZIP);
     }
     GitPHP_Log::GetInstance()->SetEnabled(false);
 }
Exemple #12
0
        $controller->Render();
    }
} catch (Exception $e) {
    if (GitPHP_Config::GetInstance()->GetValue('debug', false)) {
        throw $e;
    }
    if (!GitPHP_Resource::Instantiated()) {
        /*
         * In case an error was thrown before instantiating
         * the resource manager
         */
        GitPHP_Resource::Instantiate('en_US');
    }
    require_once GITPHP_CONTROLLERDIR . 'Controller_Message.class.php';
    $controller = new GitPHP_Controller_Message();
    $controller->SetParam('message', $e->getMessage());
    if ($e instanceof GitPHP_MessageException) {
        $controller->SetParam('error', $e->Error);
        $controller->SetParam('statuscode', $e->StatusCode);
    } else {
        $controller->SetParam('error', true);
    }
    $controller->RenderHeaders();
    $controller->Render();
}
if (GitPHP_Log::GetInstance()->GetEnabled()) {
    $entries = GitPHP_Log::GetInstance()->GetEntries();
    foreach ($entries as $logline) {
        echo "<br />\n" . $logline;
    }
}
 /**
  * LoadHeaders
  *
  * Loads headers for this template
  *
  * @access protected
  */
 protected function LoadHeaders()
 {
     if (isset($this->params['plain']) && $this->params['plain']) {
         GitPHP_Log::GetInstance()->SetEnabled(false);
         $this->preserveWhitespace = true;
         // XXX: Nasty hack to cache headers
         if (!$this->tpl->isCached('blobheaders.tpl', $this->GetFullCacheKey())) {
             if (isset($this->params['file'])) {
                 $saveas = $this->params['file'];
             } else {
                 $saveas = $this->params['hash'] . ".txt";
             }
             $headers = array();
             $mime = null;
             if (GitPHP_Config::GetInstance()->GetValue('filemimetype', true)) {
                 if (!isset($this->params['hash']) && isset($this->params['file'])) {
                     $commit = $this->project->GetCommit($this->params['hashbase']);
                     $this->params['hash'] = $commit->PathToHash($this->params['file']);
                 }
                 $blob = $this->project->GetBlob($this->params['hash']);
                 $blob->SetPath($this->params['file']);
                 $mime = $blob->FileMime();
             }
             if ($mime) {
                 $headers[] = "Content-type: " . $mime;
             } else {
                 $headers[] = "Content-type: text/plain; charset=UTF-8";
             }
             $headers[] = "Content-disposition: inline; filename=\"" . $saveas . "\"";
             $this->tpl->assign("blobheaders", serialize($headers));
         }
         $out = $this->tpl->fetch('blobheaders.tpl', $this->GetFullCacheKey());
         $this->headers = unserialize(trim($out));
     }
 }
 /**
  * ReadQuery
  *
  * Read query into parameters
  *
  * @access protected
  */
 protected function ReadQuery()
 {
     if (isset($_GET['h'])) {
         $this->params['hash'] = $_GET['h'];
     }
     if (isset($_GET['o']) && $_GET['o'] == 'jstip') {
         $this->params['jstip'] = true;
         GitPHP_Log::GetInstance()->SetEnabled(false);
     }
 }