Home  >  Article  >  Backend Development  >  PHP运行SVN命令显示某用户的文件更新记录的代码_php技巧

PHP运行SVN命令显示某用户的文件更新记录的代码_php技巧

WBOY
WBOYOriginal
2016-05-17 08:51:521638browse

复制代码 代码如下:

$user=trim($_GET['user']);
$d=$_GET['date'];
if(!$d){
 $d=date('Ymd',time()-86400*14);
}
if(empty($user)){
 echo "例如:svn_log.php?user=wang&date=20130118";
 exit;
}

$cmd='/usr/bin/svn log -v -r {'.$d.'}:"HEAD" --username 用户名 --password 密码 --no-auth-cache | sed -n "/'.$user.'/,/-----$/ p" 2>&1';

$p=dirname(__FILE__);

exec('cd '.$p,$output);

exec($cmd,$output);

$d=date('Y年m月d日',strtotime($d));
echo $user.'自'.$d.'以来:
';
echo '---------------------------------------------
';
$out='';

krsort($output);

if(!empty($output)){
 foreach($output as $v){
  $p1=strpos($v,'/branch/');
  $p2=strpos($v,'/tg/');
  if($p1!==false || $p2!==false){
   if($p1!==false){
    $v=substr($v,$p1+9);
   }else{
    $v=substr($v,$p2+4);
   }
   if($out==''){
    $out=$v;
    echo $v.'
';
   }else{
    if(strpos($out,$v)===false){
     $out.=','.$v;
     echo $v.'
';
    }
   }
  }
 }
}else{
 echo "没有文件";
}
?>

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn