/*
*检查路径是否存在
*/
functioncheckDir($dir)
{
exec("/bin/ls$dir",$info,$status);
$sta=empty($info) ?$sta=1:$sta=0;//1路径不存在,0路径存在
return$sta;
}
//仓库是git还是svn
functionwarehouseCheck($warehouse)
{
if(preg_match("/.git$/i",$warehouse)) {
$sta=1;//1为git
}
if(preg_match("/^svn:\/\//i",$warehouse)) {
$sta=2;//2为svn
}
return$sta;
}
//环境选择
functionenvCheck($env_name,$ser_tmp)
{
if(strpos($env_name,"测试") !==false) {
$dir_tmp="$ser_tmp/cs";
}elseif(strpos($env_name,"预发布") !==false) {
$dir_tmp="$ser_tmp/yfb";
}elseif(strpos($env_name,"正式") !==false||strpos($env_name,"线上") !==false) {
$dir_tmp="$ser_tmp/zs";
}else{
$dir_tmp="";
}
return$dir_tmp;
}
//发邮件
functionsendMail($to,$subject,$content,$send_user){
header("content-type:text/html;charset=utf-8");
ini_set("magic_quotes_runtime",0);
vendor("Phpmailer.phpmailer");
try{
$mail=newPHPMailer(true);//实例化
$mail->IsSMTP();// 启用SMTP
$mail->CharSet='UTF-8';//设置邮件的字符编码,这很重要,不然中文乱码
$mail->SMTPAuth=true;//开启认证
$mail->Port=25;
$mail->Host="smtp.exmail.qq.com";
$mail->Username="ops@feibo.cn";
$mail->Password="feibo54321";
//$mail->IsSendmail(); //如果没有sendmail组件就注释掉,否则出现“Could not execute: /var/qmail/bin/sendmail ”的错误提示
//$mail->AddReplyTo("phpddt1990@163.com","mckee");//回复地址
$mail->From="ops@feibo.cn";
$mail->FromName=$send_user;
//$to = "linc@feibo.cn";
//dump($to);die;
foreach($toas$v){
$mail->AddAddress($v);
}
$content=str_replace('\n',"\",$content);
$mail->IsHTML(true);//支持html格式内容
$mail->Subject=$subject;
$mail->Body= $content;
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; //当邮件不支持html时备用显示,可以省略
$mail->WordWrap=80;// 设置每行字符串的长度
//$mail->AddAttachment("f:/test.png"); //可以添加附件
$mail->Send();
}catch(phpmailerException$e) {
echo"邮件发送失败:".$e->errorMessage();
}
}