Mike 8 år sedan
förälder
incheckning
b46df65721

+ 44 - 0
server/app/Helper/SmsHelper.php

xqd
@@ -0,0 +1,44 @@
+<?php
+namespace App\Http\HelperTraits;
+
+use GuzzleHttp\Client as GuzzleHttpClient;
+use GuzzleHttp\Exception\RequestException;
+
+trait SmsHelper
+{
+    public function sendSms($msg, $mobile) {
+        $url = "http://api.106txt.com/smsGBK.aspx?";
+        $account = "swufecredit2017";
+        $password = "mask751002";
+        $password = strtoupper(md5($password));
+        $gwid = 53;
+        $message = iconv("UTF-8", "GB2312", $msg);
+
+        try {
+            $client = new GuzzleHttpClient();
+            $data = [
+                'action'      => 'Send',
+                'username'        => $account,
+                'password'       => $password,
+                'gwid'      => $gwid,
+                'mobile'    => $mobile,
+                'message'       => $message,
+            ];
+            $apiRequest = $client->post($url, [
+                'form_params'      => $data,
+            ]);
+            $resp = $apiRequest->getBody()->getContents();
+            $res = iconv("GB2312", "UTF-8", $resp);
+            $re = json_decode($res, true);
+            \Log::info("发送短信 到手机:$mobile 内容:$msg RESULT:".$re['RESULT']);
+            if (trim($re['CODE']) == '1') {
+                return true;
+            }
+        } catch (RequestException $re) {
+            \Log::info("发送短信错误:".$re->getMessage());
+            return false;
+        }
+        return false;
+    }
+
+}

+ 151 - 151
server/app/Helper/functions.inc.php

xqd
@@ -591,154 +591,154 @@ if( ! function_exists('widget'))
 }
 
 
-
-if( ! function_exists('sendSms')) {
-    // return string 'success' 为成功
-    function sendSms($msg, $mobile){
-        $post_data = array();
-        $post_data['un'] ="N9304000";
-        $post_data['pw'] = "Mask751002@";
-        $post_data['msg']="【小洲蔬菜】$msg";
-        $post_data['phone'] =$mobile;
-        $post_data['rd']=1;
-
-        $post_data['needstatus']='true';
-        $url='https://sms.253.com/msg/send';
-        $data=http_build_query($post_data);
-
-        if(function_exists('curl_init')){
-            $curl = curl_init();
-            curl_setopt($curl, CURLOPT_URL, $url);
-
-            if (!empty($data)){
-                curl_setopt($curl, CURLOPT_POST, 1);
-                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
-            }
-            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
-            $output = curl_exec($curl);
-            curl_close($curl);
-            $result=preg_split("/[,\r\n]/",$output);
-            if($result[1]==0){
-                $res = "success";
-            }else{
-                $res = "curl error:".$result[1];
-            }
-        }elseif(function_exists('file_get_contents')){
-            $output=file_get_contents($url.$data);
-            $result=preg_split("/[,\r\n]/",$output);
-            if($result[1]==0){
-                $res = "success";
-            }else{
-                $res = "error:".$result[1];
-            }
-        }else{
-            $res="error";
-        }
-        return $res;
-    }
-}
-
-if( ! function_exists('sendMultiSms')) {
-    //  群发短信 $mobiles电话号码之间用英文逗号分割
-    // return string 'success' 为成功
-    function sendMultiSms($msg, $mobiles){
-        $post_data = array();
-        $post_data['un'] ="M3512322";
-        $post_data['pw'] = "N8ecbXn0A7dc18";
-        $post_data['msg']="【小洲蔬菜】$msg 回复TD退订";
-        $post_data['phone'] =$mobiles;
-        $post_data['rd']=1;
-
-        $post_data['needstatus']='true';
-        $url='https://sms.253.com/msg/send';
-        $data=http_build_query($post_data);
-
-        if(function_exists('curl_init')){
-            $curl = curl_init();
-            curl_setopt($curl, CURLOPT_URL, $url);
-
-            if (!empty($data)){
-                curl_setopt($curl, CURLOPT_POST, 1);
-                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
-            }
-            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
-            $output = curl_exec($curl);
-            curl_close($curl);
-            $result=preg_split("/[,\r\n]/",$output);
-            if($result[1]==0){
-                $res = "success";
-            }else{
-                $res = "curl error:".$result[1];
-            }
-        }elseif(function_exists('file_get_contents')){
-            $output=file_get_contents($url.$data);
-            $result=preg_split("/[,\r\n]/",$output);
-            if($result[1]==0){
-                $res = "success";
-            }else{
-                $res = "error:".$result[1];
-            }
-        }else{
-            $res="error";
-        }
-        return $res;
-    }
-}
-
-
-if( ! function_exists('sendCaixin')) {
-    //return  true or false
-    function sendCaixin($mobile){
-
-        $post_data =$data =$msgdata = array();
-
-        $url ="http://www.baidu.com";//回调URL
-        $key ="6MG5jNK4Q15907";//密码
-//文字body
-        $data['frame']="1"; //文字标识
-        $data['part']  ="1";//文字标识
-        $data['type']="1" ;
-        $data['content']=base64_encode('亲爱的朋友,“芜湖小洲蔬菜”,芜湖人的掌上菜篮子,已是我每天买菜必备工具。好东西首先想到了您,赶快关注使用吧!');
-
-//图片body
-        $msgdata['frame']="1";
-        $msgdata['part']  ="2";//图片标识
-        $msgdata['type']="2" ;//图片标识
-        $msgdata['content']=base64_encode(file_get_contents(public_path('app/wap/images/')."qrcode.jpg"));//图片
-
-        $post_data['account'] ="C8636841";//账号
-        $post_data['ext_id']="72175534217316595927";//自传参数
-        $post_data['msg']=json_encode(array($data,$msgdata)) ;//json
-        $post_data['phones']  = $mobile;//手机
-        $post_data['timestamp'] = time();//时间戳
-
-        $post_data['title']= '芜湖小洲蔬菜'; //标题
-
-        $sign ='account=' . $post_data['account'].'ext_id=' . $post_data['ext_id'].'msg=' . $post_data['msg'].'phones=' . $post_data['phones'].'timestamp=' . $post_data['timestamp'].'title=' . $post_data['title'].'url=' . $url.'key=' . $key;
-        $sign=md5($sign); //加密
-        $post_data['sign']=$sign;
-        $post_data['url']=$url;
-
-        $url='http://caixin.253.com/api/send?';
-        $data = http_build_query($post_data);
-
-        if(function_exists('curl_init')){
-            $curl = curl_init();
-            curl_setopt($curl, CURLOPT_URL, $url);
-
-            if (!empty($data)){
-                curl_setopt($curl, CURLOPT_POST, 1);
-                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
-            }
-            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
-            $output = curl_exec($curl);
-            curl_close($curl);
-            $res = json_decode($output);
-            if(is_array($res)&&$res['code']==1){
-                return true;
-            }
-
-        }
-        return false;
-    }
-}
+//
+//if( ! function_exists('sendSms')) {
+//    // return string 'success' 为成功
+//    function sendSms($msg, $mobile){
+//        $post_data = array();
+//        $post_data['un'] ="N9304000";
+//        $post_data['pw'] = "Mask751002@";
+//        $post_data['msg']="【小洲蔬菜】$msg";
+//        $post_data['phone'] =$mobile;
+//        $post_data['rd']=1;
+//
+//        $post_data['needstatus']='true';
+//        $url='https://sms.253.com/msg/send';
+//        $data=http_build_query($post_data);
+//
+//        if(function_exists('curl_init')){
+//            $curl = curl_init();
+//            curl_setopt($curl, CURLOPT_URL, $url);
+//
+//            if (!empty($data)){
+//                curl_setopt($curl, CURLOPT_POST, 1);
+//                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
+//            }
+//            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+//            $output = curl_exec($curl);
+//            curl_close($curl);
+//            $result=preg_split("/[,\r\n]/",$output);
+//            if($result[1]==0){
+//                $res = "success";
+//            }else{
+//                $res = "curl error:".$result[1];
+//            }
+//        }elseif(function_exists('file_get_contents')){
+//            $output=file_get_contents($url.$data);
+//            $result=preg_split("/[,\r\n]/",$output);
+//            if($result[1]==0){
+//                $res = "success";
+//            }else{
+//                $res = "error:".$result[1];
+//            }
+//        }else{
+//            $res="error";
+//        }
+//        return $res;
+//    }
+//}
+//
+//if( ! function_exists('sendMultiSms')) {
+//    //  群发短信 $mobiles电话号码之间用英文逗号分割
+//    // return string 'success' 为成功
+//    function sendMultiSms($msg, $mobiles){
+//        $post_data = array();
+//        $post_data['un'] ="M3512322";
+//        $post_data['pw'] = "N8ecbXn0A7dc18";
+//        $post_data['msg']="【小洲蔬菜】$msg 回复TD退订";
+//        $post_data['phone'] =$mobiles;
+//        $post_data['rd']=1;
+//
+//        $post_data['needstatus']='true';
+//        $url='https://sms.253.com/msg/send';
+//        $data=http_build_query($post_data);
+//
+//        if(function_exists('curl_init')){
+//            $curl = curl_init();
+//            curl_setopt($curl, CURLOPT_URL, $url);
+//
+//            if (!empty($data)){
+//                curl_setopt($curl, CURLOPT_POST, 1);
+//                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
+//            }
+//            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+//            $output = curl_exec($curl);
+//            curl_close($curl);
+//            $result=preg_split("/[,\r\n]/",$output);
+//            if($result[1]==0){
+//                $res = "success";
+//            }else{
+//                $res = "curl error:".$result[1];
+//            }
+//        }elseif(function_exists('file_get_contents')){
+//            $output=file_get_contents($url.$data);
+//            $result=preg_split("/[,\r\n]/",$output);
+//            if($result[1]==0){
+//                $res = "success";
+//            }else{
+//                $res = "error:".$result[1];
+//            }
+//        }else{
+//            $res="error";
+//        }
+//        return $res;
+//    }
+//}
+//
+//
+//if( ! function_exists('sendCaixin')) {
+//    //return  true or false
+//    function sendCaixin($mobile){
+//
+//        $post_data =$data =$msgdata = array();
+//
+//        $url ="http://www.baidu.com";//回调URL
+//        $key ="6MG5jNK4Q15907";//密码
+////文字body
+//        $data['frame']="1"; //文字标识
+//        $data['part']  ="1";//文字标识
+//        $data['type']="1" ;
+//        $data['content']=base64_encode('亲爱的朋友,“芜湖小洲蔬菜”,芜湖人的掌上菜篮子,已是我每天买菜必备工具。好东西首先想到了您,赶快关注使用吧!');
+//
+////图片body
+//        $msgdata['frame']="1";
+//        $msgdata['part']  ="2";//图片标识
+//        $msgdata['type']="2" ;//图片标识
+//        $msgdata['content']=base64_encode(file_get_contents(public_path('app/wap/images/')."qrcode.jpg"));//图片
+//
+//        $post_data['account'] ="C8636841";//账号
+//        $post_data['ext_id']="72175534217316595927";//自传参数
+//        $post_data['msg']=json_encode(array($data,$msgdata)) ;//json
+//        $post_data['phones']  = $mobile;//手机
+//        $post_data['timestamp'] = time();//时间戳
+//
+//        $post_data['title']= '芜湖小洲蔬菜'; //标题
+//
+//        $sign ='account=' . $post_data['account'].'ext_id=' . $post_data['ext_id'].'msg=' . $post_data['msg'].'phones=' . $post_data['phones'].'timestamp=' . $post_data['timestamp'].'title=' . $post_data['title'].'url=' . $url.'key=' . $key;
+//        $sign=md5($sign); //加密
+//        $post_data['sign']=$sign;
+//        $post_data['url']=$url;
+//
+//        $url='http://caixin.253.com/api/send?';
+//        $data = http_build_query($post_data);
+//
+//        if(function_exists('curl_init')){
+//            $curl = curl_init();
+//            curl_setopt($curl, CURLOPT_URL, $url);
+//
+//            if (!empty($data)){
+//                curl_setopt($curl, CURLOPT_POST, 1);
+//                curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
+//            }
+//            curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
+//            $output = curl_exec($curl);
+//            curl_close($curl);
+//            $res = json_decode($output);
+//            if(is_array($res)&&$res['code']==1){
+//                return true;
+//            }
+//
+//        }
+//        return false;
+//    }
+//}

+ 0 - 1
server/app/Http/Controllers/Controller.php

xqd
@@ -2,7 +2,6 @@
 
 namespace App\Http\Controllers;
 
-use App\Models\UserInfoModel;
 use Illuminate\Foundation\Bus\DispatchesJobs;
 use Illuminate\Routing\Controller as BaseController;
 use Illuminate\Foundation\Validation\ValidatesRequests;

+ 2 - 0
server/app/Http/Kernel.php

xqd
@@ -18,6 +18,8 @@ class Kernel extends HttpKernel
         \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
         \App\Http\Middleware\TrimStrings::class,
         \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
+
+        \App\Http\Middleware\Cors::class, //跨域问题
     ];
 
     /**

+ 1 - 1
server/app/Models/BaseSettingsModel.php

xqd
@@ -16,7 +16,7 @@ class BaseSettingsModel extends BaseModel
      * @var string
      *
      */
-    protected $table = 'base_settings_info';
+    protected $table = 'base_settings';
     /**
     主键
      */

+ 2 - 2
server/resources/views/admin/base/index/index.blade.php

xqd xqd
@@ -40,7 +40,7 @@
                                 <li><a target="_blank" href="<?php echo 'http://' . config('sys.sys_www_domain')?>">网站首页</a></li>
                                 <li><a href="/security/auth/toUpdateMyPassword" target="_blank">修改密码</a></li>
                                 <li class="divider"></li>
-                                <li><a href="/logout">安全退出</a>
+                                <li><a href="/admin/logout">安全退出</a>
                                 </li>
                             </ul>
                         </div>
@@ -116,7 +116,7 @@
                         </li>
                     </ul>
                 </div>
-                <a href="/logout" class="roll-nav roll-right J_tabExit"><i class="fa fa fa-sign-out"></i> 退出</a>
+                <a href="/admin/logout" class="roll-nav roll-right J_tabExit"><i class="fa fa fa-sign-out"></i> 退出</a>
             </div>
             <div class="row J_mainContent" id="content-main">
                 <iframe class="J_iframe" name="iframe0" width="100%" height="100%" src="{{ U('Base/Index/welcome')}}" frameborder="0" data-id="index_v1.html" seamless></iframe>