首页 > 代码库 > PHP编写一些检查项函数
PHP编写一些检查项函数
/*
*检查路径是否存在
*/
function checkDir($dir)
{
exec("/bin/ls $dir", $info, $status);
$sta = empty($info) ? $sta = 1 : $sta = 0;//1路径不存在,0路径存在
return $sta;
}
//仓库是git还是svn
function warehouseCheck($warehouse)
{
if (preg_match("/.git$/i", $warehouse)) {
$sta = 1; //1为git
}
if (preg_match("/^svn:\/\//i", $warehouse)) {
$sta = 2; //2为svn
}
return $sta;
}
//环境选择
function envCheck($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;
}
//发邮件
function sendMail($to, $subject, $content,$send_user){
header("content-type:text/html;charset=utf-8");
ini_set("magic_quotes_runtime",0);
vendor("Phpmailer.phpmailer");
try {
$mail = new PHPMailer(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($to as $v){
$mail->AddAddress($v);
}
$content = str_replace(‘\n‘,"\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();
}
}
本文出自 “源源不断” 博客,转载请与作者联系!
PHP编写一些检查项函数
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。