Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2343349
  • 博文数量: 276
  • 博客积分: 5998
  • 博客等级: 大校
  • 技术积分: 5175
  • 用 户 组: 普通用户
  • 注册时间: 2010-12-24 14:43
文章分类

全部博文(276)

文章存档

2014年(25)

2013年(11)

2012年(69)

2011年(167)

2010年(4)

分类: LINUX

2011-07-16 13:23:21



# cat message.php
if ($_GET['item'] != mail) {
        echo $_GET['item'];
        $phone = $_GET['phone'];
        $msg = $_GET['msg'];
        $msg = urldecode($msg);
        echo "$phone $msg";
        $a = `/usr/bin/fetion.sh phone="$phone" msg='$msg'`;
        echo "$a" ;
} else {
        $mailto = $_GET['mailto'];
        $subject = $_GET['subject'];
        $msg = $_GET['msg'];
        if (!$mailto)
             $mailto = $_POST['mailto'];
        if (!$subject)
             $subject = $_POST['subject'];
        if (!$msg)
             $msg = $_POST['msg'];
        $msg = urldecode($msg);
        $a = `/usr/local/shell/mailinterface/mail.pl "$mailto" $subject "$msg"`;
        echo "$a" ;
}
 
 
# cat /usr/bin/fetion.sh
#!/bin/sh
#help
if [ -z $@ ] || [ "$1" == "--help" ] || [ "$1" == "-h" ] ; then
   echo "Use it like:"
   echo -e "\r"
   echo '    fetion.sh phone="dianhuahaoma" msg="fetion is working."'
   echo -e "\r"
   echo 'By xxxx'
   exit 1
fi 2>/dev/null

year=`date +%Y/%m/%d`
day=`date +%Y%m%d`
result=/usr/local/fetion/fx/result.txt
logpath=/usr/local/fetion/history/`date +%Y/%m/%d`
log=$logpath/$day-warn.txt
#[ ! -e $logpath ] && mkdir -p $logpath
echo $1
echo $2
echo $@
singlephoneid=`echo "$@" | awk -F"msg" '{ print $1 }'| sed 's/phone=//g'| sed 's/,/ /g'`
#echo $singlephoneid
msg=`echo "$@" | awk -F"msg" '{ print $2 }' | sed 's/^=//g'`
#echo $msg
starlevel=('                      ' '                    ★' '                  ★★' '                ★★★' '              ★★★★' '            ★★★★★' '          ★★★★★★' '        ★★★★★★★' '      ★★★★★★★★' '    ★★★★★★★★★' '  ★★★★★★★★★★' )
level=`echo $msg|grep 'Lv.'|awk -F 'Lv.' '{print $2}'|awk '{print $1}'`
if [ -z $level ];then
level=0
fi
#echo "$msg"
echo "${starlevel[$level]}"  $msg >> $log
#warn
#1xxxxxxxxxxxxxxx
##ep: usefetion fetionID=fetionPWD $phoneid "$msg"
usefetion () {
fetionID=`echo $1|awk -F '=' '{printf $1}'`
fetionPWD=`echo $1|awk -F '=' '{printf $2}'`
/usr/local/fetion/fx/fetion  --mobile=$fetionID --pwd=$fetionPWD  --to=$2 --msg-utf8="$3" --exit-on-verifycode=1 > $result
}
for  phoneid in $singlephoneid   dianhuahaoma d; do
echo $phoneid
  for fetionAccount in `cat /usr/local/shell/fetionAccount.txt|grep -v "#"`; do
    if [ $fetionAccount = "EOF"  ]; then
        break
    fi
    usefetion $fetionAccount  $phoneid "$msg"
    result1=`cat $result|grep "Send SMS OK"`
    if [ -n "$result1" ]; then
       break
    fi
  done
  if [ $fetionAccount = "EOF"  ]; then
         wget   --output-document=/dev/null  '!QAZ2wsx&to=$phoneid&content=$msg'
        # break
  fi
done
 
# cat /usr/local/shell/fetionAccount.txt
shoujihuaoma1=mima1
shoujihuaoma2=mima2
shoujihuaoma3=mima3
shoujihuaoma4=mima4
EOF
 

# cat /usr/local/shell/mailinterface/mail.pl
#!/usr/bin/perl

use Net::SMTP;
my $mailto = @ARGV[0];
my @mailto = split( /,/, $mailto);
my $content = @ARGV[2];
my @content = split( /\|/, $content);
print $content,"\n";
my $subject= @ARGV[1];
print $subject,"\n";
print "

";
print $content,"\n";
print "

";
print @mailto;

my $mailhost="smtp.263xmail.com";
my ;
#open (PH, "$file") ;
#my @text=;
#close (PH);
$smtp = Net::SMTP->new($mailhost,Hello=>'263xmail.com',Timeout=>120,Debug=>1) ;
$smtp->auth();
my @mailto = split( /,/, $mailto);
my @mailto = (@mailto,"xxxxx\@xxxx.com");
foreach my $mailto (@mailto) {
print $mailto,"\n";
$smtp->mail($mailfrom);
$smtp->to($mailto);
$smtp->data();
$smtp->datasend("To: @mailto\r\n");
$smtp->datasend("From: $mailfrom\r\n");
$smtp->datasend("Subject: $subject\r\n");
$smtp->datasend("\r\n");
foreach my $content (@content) {
        chomp $_;
        $smtp->datasend("$content\r\n");
}
$smtp->dataend();
}
$smtp->quit;
阅读(2789) | 评论(0) | 转发(0) |
0

上一篇:mysql 优化的一些小窍门

下一篇:CPU Affinity

给主人留下些什么吧!~~