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

WBOY
Release: 2016-05-17 08:51:52
Original
1655 people have browsed it

复制代码 代码如下:

$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 "没有文件";
}
?>

Related labels:
svn
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!