コード例 #1
0
 public function sms()
 {
     $model = M('Sms_mb');
     $mb = $model->where('model="Student"')->find();
     if ($mb) {
         $map['id'] = array('in', $_POST['ids']);
         $name = $this->getActionName();
         $model = M($name);
         $vo = $model->where($map)->select();
         if ($vo > getSmsNum()) {
             $this->error('您的短信剩余条数不足以完成本次发送,剩余条数' . getSmsNum());
         } else {
             foreach ($vo as $key => $value) {
                 $name = getStudentinfo($value['id'], 'nickname');
                 $xuehao = getStudentinfo($value['id'], 'account');
                 $class = getClass(getStudentinfo($value['id'], 'class_id'));
                 $gender = getStudentinfo($value['id'], 'gender');
                 $tel = getStudentinfo($value['id'], 'tel');
                 $content = str_replace('{name}', $name, $mb['content']);
                 $content = str_replace('{xuehao}', $xuehao, $content);
                 $content = str_replace('{class}', $class, $content);
                 $content = str_replace('{gender}', $gender, $content);
                 $content = str_replace('{tel}', $tel, $content);
                 sendSms($tel, $content);
             }
             $this->success('发送成功!');
         }
     } else {
         $this->error('请先设置模板');
     }
 }
コード例 #2
0
ファイル: CommonAction.class.php プロジェクト: diycp/stusys
 public function sendsms()
 {
     $id = $_REQUEST['id'];
     $name = getStudentinfo($id, 'nickname');
     $xuehao = getStudentinfo($id, 'account');
     $class = getClass(getStudentinfo($id, 'class_id'));
     $gender = getStudentinfo($id, 'gender');
     $tel = getStudentinfo($id, 'tel');
     $content = $_REQUEST['content'];
     $content = str_replace('{name}', $name, $content);
     $content = str_replace('{xuehao}', $xuehao, $content);
     $content = str_replace('{class}', $class, $content);
     $content = str_replace('{gender}', $gender, $content);
     $content = str_replace('{tel}', $tel, $content);
     $num = sendSms($tel, $content);
     if ($num == '1') {
         $this->success("发送成功");
     } else {
         $this->error("发送失败,错误代码为" . $num);
     }
 }