/*
*檢查路徑是否存在
*/
functioncheckDir($dir)
{
exec("/bin/ls$dir",$info,$status);
$sta=empty($info) ?$sta=1:$sta=0;//1路徑不存在,0路徑存在
return$sta;
}
//倉(cāng)庫(kù)是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;
}
//環(huán)境選擇
functionenvCheck($env_name,$ser_tmp)
{
if(strpos($env_name,"測(cè)試") !==false) {
$dir_tmp="$ser_tmp/cs";
}elseif(strpos($env_name,"預(yù)發(fā)布") !==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;
}
//發(fā)郵件
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);//實(shí)例化
$mail->IsSMTP();// 啟用SMTP
$mail->CharSet='UTF-8';//設(shè)置郵件的字符編碼,這很重要,不然中文亂碼
$mail->SMTPAuth=true;//開啟認(rèn)證
$mail->Port=25;
$mail->Host="smtp.exmail.qq.com";
$mail->Username="ops@feibo.cn";
$mail->Password="feibo54321";
//$mail->IsSendmail(); //如果沒有sendmail組件就注釋掉,否則出現(xiàn)“Could not execute: /var/qmail/bin/sendmail ”的錯(cuò)誤提示
//$mail->AddReplyTo("phpddt1990@163.com","mckee");//回復(fù)地址
$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格式內(nèi)容
$mail->Subject=$subject;
$mail->Body= $content;
//$mail->AltBody = "To view the message, please use an HTML compatible email viewer!"; //當(dāng)郵件不支持html時(shí)備用顯示,可以省略
$mail->WordWrap=80;// 設(shè)置每行字符串的長(zhǎng)度
//$mail->AddAttachment("f:/test.png"); //可以添加附件
$mail->Send();
}catch(phpmailerException$e) {
echo"郵件發(fā)送失?。?.$e->errorMessage();
}
}
標(biāo)題名稱:PHP編寫一些檢查項(xiàng)函數(shù)
本文路徑:
http://weahome.cn/article/jsjohe.html