Example #1
0
 /**
  * Loads the svn-log-content via a system-call
  * @param string $strSingleRevision use this param if you want so make sure a given id is included
  * @return string
  */
 private function loadLoghistoryViaSvn($strSingleRevision = false)
 {
     $strSvnLogLines = "";
     $strErrors = "";
     //build the command
     $arrCommand = array();
     $arrCommand[] = escapeshellcmd($this->objConfig->getStrSvnBinaryPath());
     $arrCommand[] = "log -v --xml --no-auth-cache";
     $arrCommand[] = escapeshellarg($this->objConfig->getStrSvnUrl());
     if ($strSingleRevision !== false && $strSingleRevision != "") {
         $arrCommand[] = " -r " . escapeshellarg(intval($strSingleRevision));
     } else {
         $arrCommand[] = " -l " . escapeshellarg($this->objConfig->getIntLogAmount());
     }
     if ($this->objConfig->getStrSvnUsername() != "") {
         $arrCommand[] = "--username " . escapeshellarg($this->objConfig->getStrSvnUsername());
     }
     if ($this->objConfig->getStrSvnPassword() != "") {
         $arrCommand[] = "--password " . escapeshellarg($this->objConfig->getStrSvnPassword());
     }
     //create a new process
     $arrProcessDescSpec = array(0 => array("pipe", "r"), 1 => array("pipe", "w"), 2 => array("pipe", "w"));
     $arrPipes = array();
     $objProcess = proc_open(implode(" ", $arrCommand), $arrProcessDescSpec, $arrPipes);
     if (is_resource($objProcess)) {
         //accept certificate temporarily
         fwrite($arrPipes[0], "t\r\n");
         //read logfile
         while (!feof($arrPipes[1])) {
             $strSvnLogLines .= fread($arrPipes[1], 4096);
         }
         //read errors
         while (!feof($arrPipes[2])) {
             $strErrors .= fread($arrPipes[2], 4096);
         }
         fclose($arrPipes[0]);
         fclose($arrPipes[1]);
         fclose($arrPipes[2]);
         proc_close($objProcess);
     }
     if ($strSvnLogLines == 0) {
         return $strSvnLogLines;
     }
     throw new Svn2RssException("Error loading svn-log content, errors: " . $strErrors);
 }