diff --git a/application/project/controller/File.php b/application/project/controller/File.php index 33e012b..2f94497 100644 --- a/application/project/controller/File.php +++ b/application/project/controller/File.php @@ -36,9 +36,9 @@ class File extends BasicApi $this->error("请选择项目"); } $where = []; - $where[] = ['organization_code', '=', $orgCode]; +// $where[] = ['organization_code', '=', $orgCode]; $where[] = ['project_code', '=', $projectCode]; - $where[] = ['create_by', '=', $memberCode]; +// $where[] = ['create_by', '=', $memberCode]; $where[] = ['deleted', '=', $deleted]; $list = $this->model->_list($where); if ($list['list']) { diff --git a/application/project/controller/Login.php b/application/project/controller/Login.php index ab10a2c..9b59ca1 100644 --- a/application/project/controller/Login.php +++ b/application/project/controller/Login.php @@ -8,6 +8,7 @@ use controller\BasicApi; use service\LogService; use service\NodeService; use service\RandomService; +use sms\Sms; use think\Db; use think\db\exception\DataNotFoundException; use think\db\exception\ModelNotFoundException; @@ -59,6 +60,9 @@ class Login extends BasicApi // 'password.require' => '登录密码不能为空!', // 'password.min' => '登录密码长度不能少于4位有效字符!', // ]); + if (session('captcha') != Request::param('captcha')) { + $this->error('验证码错误', 203); + } $data = [ 'account' => $this->request->post('account', ''), 'password' => $this->request->post('password', ''), @@ -103,9 +107,25 @@ class Login extends BasicApi $this->success('', ['member' => $member, 'organizationList' => $organizationList]); } + /** + * 获取验证码 + */ public function getCaptcha() { - $this->success('', RandomService::numeric(6)); + $mobile = $this->request->post('mobile', ''); + $code = RandomService::numeric(6); + $sms = new Sms(); + $result = $sms->vSend($mobile, [ + 'data' => [ + 'project' => 'DWYsW1', + 'code' => $code + ], + ]); + if (isError($result)) { + $this->error('系统繁忙'); + } + session('captcha', $code); + $this->success('', config('sms.debug') ? $code : ''); } public function register() @@ -139,6 +159,9 @@ class Login extends BasicApi if ($member) { $this->error('该手机已被注册', 202); } + if (session('captcha') != $data['captcha']) { + $this->error('验证码错误', 203); + } $memberData = [ 'email' => $data['email'], 'name' => $data['name'], diff --git a/config/sms.php b/config/sms.php index 5a8b2a9..1236a98 100644 --- a/config/sms.php +++ b/config/sms.php @@ -1,6 +1,7 @@ false, //debug模式下不发送短信 // HTTP 请求的超时时间(秒) 'timeout' => 5.0, diff --git a/extend/sms/Sms.php b/extend/sms/Sms.php index b5cdec0..86b0707 100644 --- a/extend/sms/Sms.php +++ b/extend/sms/Sms.php @@ -18,7 +18,7 @@ class Sms extends EasySms public function __construct() { parent::__construct(config('sms.')); - Log::init(['path' => 'log/sms/order']); + Log::init(['path' => 'log/sms']); } /** @@ -30,32 +30,19 @@ class Sms extends EasySms */ public function vSend($to, $message, array $gateways = []) { - $result = false; + if (config('sms.debug')) { + return true; + } try { $result = $this->send($to, $message, $gateways); } catch (InvalidArgumentException $e) { - Log::write(json_encode($e->getResults()), "sms-exception"); +// Log::write($e->getResults(), "sms-exception"); + return error(1); } catch (NoGatewayAvailableException $e) { - Log::write(json_encode($e->getResults()), "sms-exception"); +// Log::write($e->getResults(), "sms-exception"); + return error(1); } - Log::write(json_encode($result), "sms"); - return $result; - } - - /** - * 暂时保留 - * @param $phoneNumber - * @param $content - * @param string $vars - * @return mixed - */ - public function sends($phoneNumber, $content, $vars = '') - { - - $sms = new SubmailSms(); - $result = $sms->send($phoneNumber, $content); -// $result = $sms->multiSend($phoneNumber, $content, $vars); - Log::write(json_encode($result), "sms"); + Log::write($result, "sms"); return $result; } } diff --git a/extend/sms/SubmailSms.php b/extend/sms/SubmailSms.php deleted file mode 100644 index e7b4b29..0000000 --- a/extend/sms/SubmailSms.php +++ /dev/null @@ -1,55 +0,0 @@ -messageSend = new MESSAGEsend($message_configs); - @$this->messageMultiSend = new MESSAGEMultiSend($message_configs); - - } - - public function send($phoneNumber, $content) - { - $this->messageSend->SetTo($phoneNumber); - $this->messageSend->SetContent("{$this->signName}{$content}"); - return $this->messageSend->send(); - } - - public function multiSend($phoneNumbers, $content, $vars) - { - if ($phoneNumbers) { - foreach ($phoneNumbers as $phoneNumber) { - $multi = new Multi(); - $multi->setTo($phoneNumber); - foreach ($vars as $key => $var) { - $multi->addVar($key, $var); - } - $this->messageMultiSend->addMulti($multi->build()); - } - } - $this->messageMultiSend->SetContent("{$this->signName}{$content}"); - return $this->messageMultiSend->multisend(); - } -} diff --git a/extend/sms/submail/SUBMAILAutoload.php b/extend/sms/submail/SUBMAILAutoload.php deleted file mode 100644 index a31e910..0000000 --- a/extend/sms/submail/SUBMAILAutoload.php +++ /dev/null @@ -1,30 +0,0 @@ -=')) { - if (version_compare(PHP_VERSION, '5.3.0', '>=')) { - spl_autoload_register('SUBMAILAutoload', true, true); - } else { - spl_autoload_register('SUBMAILAutoload'); - } - } else { - //function __autoload($classname){ - function spl_autoload_register($classname){ - SUBMAILAutoload($classname); - } - } diff --git a/extend/sms/submail/app_config.php b/extend/sms/submail/app_config.php deleted file mode 100644 index c3c126c..0000000 --- a/extend/sms/submail/app_config.php +++ /dev/null @@ -1,298 +0,0 @@ -configs=$configs; - } - - public function setAddress($address,$name=''){ - $this->Address=$name.'<'.$address.'>'; - } - - public function setAddressbook($target){ - $this->Target=$target; - } - - protected function buildRequest(){ - $request=array(); - $request['address']=$this->Address; - if($this->Target!=''){ - $request['target']=$this->Target; - } - return $request; - } - - public function subscribe(){ - $addressbook=new mail($this->configs); - return $addressbook->subscribe($this->buildRequest()); - } - public function unsubscribe(){ - $addressbook=new mail($this->configs); - return $addressbook->unsubscribe($this->buildRequest()); - } - - } \ No newline at end of file diff --git a/extend/sms/submail/lib/addressbookmessage.php b/extend/sms/submail/lib/addressbookmessage.php deleted file mode 100644 index 5bc8432..0000000 --- a/extend/sms/submail/lib/addressbookmessage.php +++ /dev/null @@ -1,40 +0,0 @@ -configs=$configs; - } - - public function setAddress($address){ - $this->Address=$address; - } - - public function setAddressbook($target){ - $this->Target=$target; - } - - protected function buildRequest(){ - $request=array(); - $request['address']=$this->Address; - if($this->Target!=''){ - $request['target']=$this->Target; - } - return $request; - - } - public function subscribe(){ - $addressbook=new message($this->configs); - return $addressbook->subscribe($this->buildRequest()); - } - public function unsubscribe(){ - $addressbook=new message($this->configs); - return $addressbook->unsubscribe($this->buildRequest()); - } - - } \ No newline at end of file diff --git a/extend/sms/submail/lib/internationalsmsmultixsend.php b/extend/sms/submail/lib/internationalsmsmultixsend.php deleted file mode 100644 index 70fff09..0000000 --- a/extend/sms/submail/lib/internationalsmsmultixsend.php +++ /dev/null @@ -1,39 +0,0 @@ -configs=$configs; - } - - public function AddMulti($multi){ - array_push($this->Multi,$multi); - } - - public function AddAddressbook($addressbook){ - array_push($this->Addressbook,$addressbook); - } - - public function SetProject($project){ - $this->Project=$project; - } - - public function buildRequest(){ - $request=array(); - $request['project']=$this->Project; - if(!empty($this->Multi)){ - $request['multi']=json_encode($this->Multi); - } - return $request; - } - - public function multixsend(){ - $intersms=new intersms($this->configs); - return $intersms->multixsend($this->buildRequest()); - } - } \ No newline at end of file diff --git a/extend/sms/submail/lib/internationalsmssend.php b/extend/sms/submail/lib/internationalsmssend.php deleted file mode 100644 index aa52a9d..0000000 --- a/extend/sms/submail/lib/internationalsmssend.php +++ /dev/null @@ -1,36 +0,0 @@ -configs=$configs; - } - - public function SetTo($address){ - $this->To=trim($address); - } - - public function SetContent($content){ - $this->Content=$content; - } - - public function AddVar($key,$val){ - $this->Vars[$key]=$val; - } - - public function buildRequest(){ - $request=array(); - $request['to']=$this->To; - $request['content']=$this->Content; - return $request; - } - public function send(){ - $intersms=new intersms($this->configs); - return $intersms->send($this->buildRequest()); - } - } \ No newline at end of file diff --git a/extend/sms/submail/lib/internationalsmsxsend.php b/extend/sms/submail/lib/internationalsmsxsend.php deleted file mode 100644 index 813fdfe..0000000 --- a/extend/sms/submail/lib/internationalsmsxsend.php +++ /dev/null @@ -1,56 +0,0 @@ -configs=$configs; - } - - public function SetTo($address){ - $this->To=trim($address); - } - - public function AddAddressbook($addressbook){ - array_push($this->Addressbook,$addressbook); - } - - public function SetProject($project){ - $this->Project=$project; - } - - public function AddVar($key,$val){ - $this->Vars[$key]=$val; - } - - public function buildRequest(){ - $request=array(); - $request['to']=$this->To; - if(!empty($this->Addressbook)){ - $request['addressbook']=''; - foreach($this->Addressbook as $tmp){ - $request['addressbook'].=$tmp.','; - } - $request['addressbook'] = substr($request['addressbook'],0,count($request['addressbook'])-2); - } - - $request['project']=$this->Project; - if(!empty($this->Vars)){ - $request['vars']=json_encode($this->Vars); - } - return $request; - } - public function xsend(){ - $intersms=new intersms($this->configs); - return $intersms->xsend($this->buildRequest()); - } - - } \ No newline at end of file diff --git a/extend/sms/submail/lib/intersms.php b/extend/sms/submail/lib/intersms.php deleted file mode 100644 index 04be554..0000000 --- a/extend/sms/submail/lib/intersms.php +++ /dev/null @@ -1,147 +0,0 @@ -intersms_configs=$intersms_configs; - if(!empty($intersms_configs['server'])){ - $this->base_url=$intersms_configs['server']; - } - } - - protected function createSignature($request){ - $r=""; - switch($this->signType){ - case 'normal': - $r=$this->intersms_configs['appkey']; - break; - case 'md5': - $r=$this->buildSignature($this->argSort($request)); - break; - case 'sha1': - $r=$this->buildSignature($this->argSort($request)); - break; - } - return $r; - } - - protected function buildSignature($request){ - $arg=""; - $app=$this->intersms_configs['appid']; - $appkey=$this->intersms_configs['appkey']; - while (list ($key, $val) = each ($request)) { - $arg.=$key."=".$val."&"; - } - $arg = substr($arg,0,count($arg)-2); - if(get_magic_quotes_gpc()){$arg = stripslashes($arg);} - - if($this->signType=='sha1'){ - $r=sha1($app.$appkey.$arg.$app.$appkey); - }else{ - $r=md5($app.$appkey.$arg.$app.$appkey); - } - return $r; - } - - protected function argSort($request) { - ksort($request); - reset($request); - return $request; - } - - protected function getTimestamp(){ - $api=$this->base_url.'service/timestamp.json'; - $ch = curl_init($api) ; - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ; - curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ; - $output = curl_exec($ch) ; - $timestamp=json_decode($output,true); - - return $timestamp['timestamp']; - } - - protected function APIHttpRequestCURL($api,$post_data,$method='post'){ - if($method!='get'){ - $ch = curl_init(); - curl_setopt_array($ch, array( - CURLOPT_URL => $api, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_POSTFIELDS => http_build_query($post_data), - CURLOPT_CUSTOMREQUEST => strtoupper($method), - CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded") - )); - }else{ - $url=$api.'?'.http_build_query($post_data); - $ch = curl_init($url) ; - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ; - curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1) ; - } - $output = curl_exec($ch); - curl_close($ch); - $output = trim($output, "\xEF\xBB\xBF"); - return json_decode($output,true); - } - - public function send($request){ - $api=$this->base_url.'internationalsms/send.json'; - $request['appid']=$this->intersms_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->intersms_configs['sign_type']) - || $this->intersms_configs['sign_type']=="" - || $this->intersms_configs['sign_type']!="normal" - || $this->intersms_configs['sign_type']!="md5" - || $this->intersms_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->intersms_configs['sign_type']; - $request['sign_type']=$this->intersms_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - $send=$this->APIHttpRequestCURL($api,$request); - return $send; - } - - public function xsend($request){ - $api=$this->base_url.'internationalsms/xsend.json'; - $request['appid']=$this->intersms_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->intersms_configs['sign_type']) - || $this->intersms_configs['sign_type']=="" - || $this->intersms_configs['sign_type']!="normal" - || $this->intersms_configs['sign_type']!="md5" - || $this->intersms_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->intersms_configs['sign_type']; - $request['sign_type']=$this->intersms_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - $send=$this->APIHttpRequestCURL($api,$request); - return $send; - } - public function multixsend($request){ - $api=$this->base_url.'internationalsms/multixsend.json'; - $request['appid']=$this->intersms_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->intersms_configs['sign_type']) - || $this->intersms_configs['sign_type']=="" - || $this->intersms_configs['sign_type']!="normal" - || $this->intersms_configs['sign_type']!="md5" - || $this->intersms_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->intersms_configs['sign_type']; - $request['sign_type']=$this->intersms_configs['sign_type']; - } - - - $request['signature']=$this->createSignature($request); - $send=$this->APIHttpRequestCURL($api,$request); - return $send; - } - } diff --git a/extend/sms/submail/lib/mail.php b/extend/sms/submail/lib/mail.php deleted file mode 100644 index f43177d..0000000 --- a/extend/sms/submail/lib/mail.php +++ /dev/null @@ -1,168 +0,0 @@ -mail_configs=$mail_config; - if(!empty($mail_config['server'])){ - $this->base_url=$mail_config['server']; - } - echo $this->base_url; - } - - protected function createSignature($request){ - $r=""; - switch($this->signType){ - case 'normal': - $r=$this->mail_configs['appkey']; - break; - case 'md5': - $r=$this->buildSignature($this->argSort($request)); - break; - case 'sha1': - $r=$this->buildSignature($this->argSort($request)); - break; - } - return $r; - } - - protected function buildSignature($request){ - $arg=""; - $app=$this->mail_configs['appid']; - $appkey=$this->mail_configs['appkey']; - while (list ($key, $val) = each ($request)) { - if (strpos($key,"attachments")===false){ - $arg.=$key."=".$val."&"; - } - } - $arg = substr($arg,0,count($arg)-2); - if(get_magic_quotes_gpc()){$arg = stripslashes($arg);} - if($this->signType=='sha1'){ - $r=sha1($app.$appkey.$arg.$app.$appkey); - }else{ - $r=md5($app.$appkey.$arg.$app.$appkey); - } - return $r; - } - - protected function argSort($request) { - ksort($request); - reset($request); - return $request; - } - - public function getTimestamp(){ - $api=$this->base_url.'service/timestamp.json'; - $ch = curl_init($api) ; - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ; - curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ; - $output = curl_exec($ch) ; - $timestamp=json_decode($output,true); - - return $timestamp['timestamp']; - } - - protected function APIHttpRequestCURL($api,$post_data,$method='post'){ - if($method!='get'){ - $ch = curl_init(); - curl_setopt_array($ch, array( - CURLOPT_URL => $api, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_POSTFIELDS => http_build_query($post_data), - CURLOPT_CUSTOMREQUEST => strtoupper($method), - CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded") - )); - }else{ - $url=$api.'?'.http_build_query($post_data); - $ch = curl_init($url) ; - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ; - curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1) ; - } - $output = curl_exec($ch); - curl_close($ch); - $output = trim($output, "\xEF\xBB\xBF"); - return json_decode($output,true); - } - - - public function send($request){ - $api=$this->base_url.'mail/send.json'; - $request['appid']=$this->mail_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->mail_configs['sign_type']) - && $this->mail_configs['sign_type']=="" - && $this->mail_configs['sign_type']!="normal" - && $this->mail_configs['sign_type']!="md5" - && $this->mail_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->mail_configs['sign_type']; - $request['sign_type']=$this->mail_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - $send=$this->APIHttpRequestCURL($api,$request); - - return $send; - } - - public function xsend($request){ - $api=$this->base_url.'mail/xsend.json'; - $request['appid']=$this->mail_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->mail_configs['sign_type']) - && $this->mail_configs['sign_type']=="" - && $this->mail_configs['sign_type']!="normal" - && $this->mail_configs['sign_type']!="md5" - && $this->mail_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->mail_configs['sign_type']; - $request['sign_type']=$this->mail_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - $xsend=$this->APIHttpRequestCURL($api,$request); - return $xsend; - } - - public function subscribe($request){ - $api=$this->base_url.'addressbook/mail/subscribe.json'; - $request['appid']=$this->mail_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->mail_configs['sign_type']) - && $this->mail_configs['sign_type']=="" - && $this->mail_configs['sign_type']!="normal" - && $this->mail_configs['sign_type']!="md5" - && $this->mail_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->mail_configs['sign_type']; - $request['sign_type']=$this->mail_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - $subscribe=$this->APIHttpRequestCURL($api,$request); - return $subscribe; - } - - public function unsubscribe($request){ - $api=$this->base_url.'addressbook/mail/unsubscribe.json'; - $request['appid']=$this->mail_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->mail_configs['sign_type']) - && $this->mail_configs['sign_type']=="" - && $this->mail_configs['sign_type']!="normal" - && $this->mail_configs['sign_type']!="md5" - && $this->mail_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->mail_configs['sign_type']; - $request['sign_type']=$this->mail_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - $unsubscribe=$this->APIHttpRequestCURL($api,$request); - return $unsubscribe; - } - } diff --git a/extend/sms/submail/lib/mailsend.php b/extend/sms/submail/lib/mailsend.php deleted file mode 100644 index 02b3342..0000000 --- a/extend/sms/submail/lib/mailsend.php +++ /dev/null @@ -1,179 +0,0 @@ -configs=$configs; - } - - public function AddTo($address,$name=''){ - array_push($this->To,array('address'=>$address,'name'=>$name)); - } - - public function AddAddressbook($addressbook){ - array_push($this->Addressbook,$addressbook); - } - - public function SetSender($sender,$name=''){ - $this->From=$sender; - $this->From_name=$name; - } - - public function SetReply($reply){ - $this->Reply=$reply; - } - - public function AddCc($address,$name=''){ - array_push($this->Cc,array('address'=>$address,'name'=>$name)); - } - - public function AddBcc($address,$name=''){ - array_push($this->Bcc,array('address'=>$address,'name'=>$name)); - } - - public function SetSubject($subject){ - $this->Subject=$subject; - } - - public function SetText($text){ - $this->Text=$text; - } - - public function SetHtml($html){ - $this->Html=$html; - } - - public function AddVar($key,$val){ - $this->Vars[$key]=$val; - } - - public function AddLink($key,$val){ - $this->Links[$key]=$val; - } - - public function AddAttachment($attachment){ - array_push($this->Attachments,$attachment); - } - - public function AddHeaders($key,$val){ - $this->Headers[$key]=$val; - } - - public function setAsynchronous($asynchronous){ - if($asynchronous==true){ - $this->asynchronous=true; - }else{ - $this->asynchronous=false; - } - } - - protected function buildRequest(){ - $request=array(); - if(!empty($this->To)){ - $request['to']=''; - foreach($this->To as $tmp){ - $request['to'].=$tmp['name'].'<'.$tmp['address'].'>,'; - } - $request['to'] = substr($request['to'],0,count($request['to'])-2); - } - if(!empty($this->Addressbook)){ - $request['addressbook']=''; - foreach($this->Addressbook as $tmp){ - $request['addressbook'].=$tmp.','; - } - $request['addressbook'] = substr($request['addressbook'],0,count($request['addressbook'])-2); - } - $request['from']=$this->From; - if($this->From_name!=''){ - $request['from_name']=$this->From_name; - } - if($this->Reply!=''){ - $request['reply']=$this->Reply; - } - if(!empty($this->Cc)){ - $request['cc']=''; - foreach($this->Cc as $tmp){ - $request['cc'].=$tmp['name'].'<'.$tmp['address'].'>,'; - } - $request['cc'] = substr($request['cc'],0,count($request['cc'])-2); - } - if(!empty($this->Bcc)){ - $request['bcc']=''; - foreach($this->Bcc as $tmp){ - $request['bcc'].=$tmp['name'].'<'.$tmp['address'].'>,'; - } - $request['bcc'] = substr($request['bcc'],0,count($request['bcc'])-2); - } - $request['subject']=$this->Subject; - if($this->Text!=''){ - $request['text']=$this->Text; - } - - if($this->Html!=''){ - $request['html']=$this->Html; - } - - if(!empty($this->Vars)){ - $request['vars']=json_encode($this->Vars); - } - - if(!empty($this->Links)){ - $request['links']=json_encode($this->Links); - } - - if(!empty($this->Attachments)){ - for($i=0;$iAttachments);$i++){ - //$request['attachments['.$i.']']="@".$this->Attachments[$i]; - $request['attachments['.$i.']'] = curl_file_create($this->Attachments[$i]); - } - } - - if(!empty($this->asynchronous)){ - $request['asynchronous']= $this->asynchronous; - } - - if(!empty($this->Headers)){ - $request['headers']=json_encode($this->Headers); - } - - return $request; - } - - public function send(){ - $mail=new mail($this->configs); - return $mail->send($this->buildRequest()); - } - } diff --git a/extend/sms/submail/lib/mailxsend.php b/extend/sms/submail/lib/mailxsend.php deleted file mode 100644 index 1754184..0000000 --- a/extend/sms/submail/lib/mailxsend.php +++ /dev/null @@ -1,166 +0,0 @@ -configs=$configs; - } - - public function AddTo($address,$name=''){ - array_push($this->To,array('address'=>$address,'name'=>$name)); - } - - public function AddAddressbook($addressbook){ - array_push($this->Addressbook,$addressbook); - } - - public function SetSender($sender,$name=''){ - $this->From=$sender; - $this->From_name=$name; - } - - public function SetReply($reply){ - $this->Reply=$reply; - } - - public function AddCc($address,$name=''){ - array_push($this->Cc,array('address'=>$address,'name'=>$name)); - } - - public function AddBcc($address,$name=''){ - array_push($this->Bcc,array('address'=>$address,'name'=>$name)); - } - - public function SetSubject($subject){ - $this->Subject=$subject; - } - - public function SetProject($project){ - $this->Project=$project; - } - - public function AddVar($key,$val){ - $this->Vars[$key]=$val; - } - - public function AddLink($key,$val){ - $this->Links[$key]=$val; - } - - public function AddHeaders($key,$val){ - $this->Headers[$key]=$val; - } - - public function setAsynchronous($asynchronous){ - if($asynchronous==true){ - $this->asynchronous="true"; - }else{ - $this->asynchronous="false"; - } - } - - protected function buildRequest(){ - $request=array(); - - if(!empty($this->To)){ - $request['to']=''; - foreach($this->To as $tmp){ - $request['to'].=$tmp['name'].'<'.$tmp['address'].'>,'; - } - $request['to'] = substr($request['to'],0,count($request['to'])-2); - } - - if(!empty($this->Addressbook)){ - $request['addressbook']=''; - foreach($this->Addressbook as $tmp){ - $request['addressbook'].=$tmp.','; - } - $request['addressbook'] = substr($request['addressbook'],0,count($request['addressbook'])-2); - } - - if($this->From!=''){ - $request['from']=$this->From; - } - - if($this->From_name!=''){ - $request['from_name']=$this->From_name; - } - - - if($this->Reply!=''){ - $request['reply']=$this->Reply; - } - - if(!empty($this->Cc)){ - $request['cc']=''; - foreach($this->Cc as $tmp){ - $request['cc'].=$tmp['name'].'<'.$tmp['address'].'>,'; - } - $request['cc'] = substr($request['cc'],0,count($request['cc'])-2); - } - - if(!empty($this->Bcc)){ - $request['bcc']=''; - foreach($this->Bcc as $tmp){ - $request['bcc'].=$tmp['name'].'<'.$tmp['address'].'>,'; - } - $request['bcc'] = substr($request['bcc'],0,count($request['bcc'])-2); - } - - if($this->Subject!=''){ - $request['subject']=$this->Subject; - } - - $request['project']=$this->Project; - - if(!empty($this->Vars)){ - $request['vars']=json_encode($this->Vars); - } - - if(!empty($this->Links)){ - $request['links']=json_encode($this->Links); - } - - if(!empty($this->asynchronous)){ - $request['asynchronous']= $this->asynchronous; - } - - if(!empty($this->Headers)){ - $request['headers']=json_encode($this->Headers); - } - return $request; - - } - - public function xsend(){ - $mail=new mail($this->configs); - return $mail->xsend($this->buildRequest()); - } - } \ No newline at end of file diff --git a/extend/sms/submail/lib/message.php b/extend/sms/submail/lib/message.php deleted file mode 100644 index bffd909..0000000 --- a/extend/sms/submail/lib/message.php +++ /dev/null @@ -1,283 +0,0 @@ -message_configs=$message_configs; - if(!empty($message_configs['server'])){ - $this->base_url=$message_configs['server']; - } - } - - protected function createSignature($request){ - $r=""; - switch($this->signType){ - case 'normal': - $r=$this->message_configs['appkey']; - break; - case 'md5': - $r=$this->buildSignature($this->argSort($request)); - break; - case 'sha1': - $r=$this->buildSignature($this->argSort($request)); - break; - } - return $r; - } - - protected function buildSignature($request){ - $arg=""; - $app=$this->message_configs['appid']; - $appkey=$this->message_configs['appkey']; - while (list ($key, $val) = each ($request)) { - $arg.=$key."=".$val."&"; - } - $arg = substr($arg,0,count($arg)-2); - if(get_magic_quotes_gpc()){$arg = stripslashes($arg);} - - if($this->signType=='sha1'){ - $r=sha1($app.$appkey.$arg.$app.$appkey); - }else{ - $r=md5($app.$appkey.$arg.$app.$appkey); - } - return $r; - } - - protected function argSort($request) { - ksort($request); - reset($request); - return $request; - } - - protected function getTimestamp(){ - $api=$this->base_url.'service/timestamp.json'; - $ch = curl_init($api) ; - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ; - curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ; - $output = curl_exec($ch) ; - $timestamp=json_decode($output,true); - - return $timestamp['timestamp']; - } - - protected function APIHttpRequestCURL($api,$post_data,$method='post'){ - if($method!='get'){ - $ch = curl_init(); - curl_setopt_array($ch, array( - CURLOPT_URL => $api, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_POSTFIELDS => http_build_query($post_data), - CURLOPT_CUSTOMREQUEST => strtoupper($method), - CURLOPT_SSL_VERIFYPEER => false, - CURLOPT_SSL_VERIFYHOST => false, - CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded") - )); - }else{ - $url=$api.'?'.http_build_query($post_data); - $ch = curl_init($url) ; - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ; - curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1) ; - curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false); - curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false); - } - $output = curl_exec($ch); - curl_close($ch); - $output = trim($output, "\xEF\xBB\xBF"); - return json_decode($output,true); - } - - public function send($request){ - $api=$this->base_url.'message/send.json'; - $request['appid']=$this->message_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->message_configs['sign_type']) - && $this->message_configs['sign_type']=="" - && $this->message_configs['sign_type']!="normal" - && $this->message_configs['sign_type']!="md5" - && $this->message_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->message_configs['sign_type']; - $request['sign_type']=$this->message_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - return $this->APIHttpRequestCURL($api,$request); - } - - public function xsend($request){ - $api=$this->base_url.'message/xsend.json'; - $request['appid']=$this->message_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->message_configs['sign_type']) - && $this->message_configs['sign_type']=="" - && $this->message_configs['sign_type']!="normal" - && $this->message_configs['sign_type']!="md5" - && $this->message_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->message_configs['sign_type']; - $request['sign_type']=$this->message_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - return $this->APIHttpRequestCURL($api,$request); - } - public function multixsend($request){ - $api=$this->base_url.'message/multixsend.json'; - $request['appid']=$this->message_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->message_configs['sign_type']) - && $this->message_configs['sign_type']=="" - && $this->message_configs['sign_type']!="normal" - && $this->message_configs['sign_type']!="md5" - && $this->message_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->message_configs['sign_type']; - $request['sign_type']=$this->message_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - return $this->APIHttpRequestCURL($api,$request); - } - - public function multisend($request){ - $api=$this->base_url.'message/multisend.json'; - $request['appid']=$this->message_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->message_configs['sign_type']) - && $this->message_configs['sign_type']=="" - && $this->message_configs['sign_type']!="normal" - && $this->message_configs['sign_type']!="md5" - && $this->message_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->message_configs['sign_type']; - $request['sign_type']=$this->message_configs['sign_type']; - } - - $request['signature']=$this->createSignature($request); - return $this->APIHttpRequestCURL($api,$request); - } - - public function subscribe($request){ - $api=$this->base_url.'addressbook/message/subscribe.json'; - $request['appid']=$this->message_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->message_configs['sign_type']) - && $this->message_configs['sign_type']=="" - && $this->message_configs['sign_type']!="normal" - && $this->message_configs['sign_type']!="md5" - && $this->message_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->message_configs['sign_type']; - $request['sign_type']=$this->message_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - return $this->APIHttpRequestCURL($api,$request); - } - - public function unsubscribe($request){ - $api=$this->base_url.'addressbook/message/unsubscribe.json'; - $request['appid']=$this->message_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->message_configs['sign_type']) - && $this->message_configs['sign_type']=="" - && $this->message_configs['sign_type']!="normal" - && $this->message_configs['sign_type']!="md5" - && $this->message_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->message_configs['sign_type']; - $request['sign_type']=$this->message_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - return $this->APIHttpRequestCURL($api,$request); - } - public function log($request){ - $api=$this->base_url.'log/message.json'; - $request['appid']=$this->message_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->message_configs['sign_type']) - && $this->message_configs['sign_type']=="" - && $this->message_configs['sign_type']!="normal" - && $this->message_configs['sign_type']!="md5" - && $this->message_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->message_configs['sign_type']; - $request['sign_type']=$this->message_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - return $this->APIHttpRequestCURL($api,$request); - } - public function getTemplate($request){ - $api=$this->base_url.'message/template.json'; - $request['appid']=$this->message_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->message_configs['sign_type']) - && $this->message_configs['sign_type']=="" - && $this->message_configs['sign_type']!="normal" - && $this->message_configs['sign_type']!="md5" - && $this->message_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->message_configs['sign_type']; - $request['sign_type']=$this->message_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - return $this->APIHttpRequestCURL($api,$request,'get'); - } - public function postTemplate($request){ - $api=$this->base_url.'message/template.json'; - $request['appid']=$this->message_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->message_configs['sign_type']) - && $this->message_configs['sign_type']=="" - && $this->message_configs['sign_type']!="normal" - && $this->message_configs['sign_type']!="md5" - && $this->message_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->message_configs['sign_type']; - $request['sign_type']=$this->message_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - return $this->APIHttpRequestCURL($api,$request,'post'); - } - public function putTemplate($request){ - $api=$this->base_url.'message/template.json'; - $request['appid']=$this->message_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->message_configs['sign_type']) - && $this->message_configs['sign_type']=="" - && $this->message_configs['sign_type']!="normal" - && $this->message_configs['sign_type']!="md5" - && $this->message_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->message_configs['sign_type']; - $request['sign_type']=$this->message_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - return $this->APIHttpRequestCURL($api,$request,'PUT'); - } - public function deleteTemplate($request){ - $api=$this->base_url.'message/template.json'; - $request['appid']=$this->message_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->message_configs['sign_type']) - && $this->message_configs['sign_type']=="" - && $this->message_configs['sign_type']!="normal" - && $this->message_configs['sign_type']!="md5" - && $this->message_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->message_configs['sign_type']; - $request['sign_type']=$this->message_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - return $this->APIHttpRequestCURL($api,$request,'DELETE'); - } - } diff --git a/extend/sms/submail/lib/messagelog.php b/extend/sms/submail/lib/messagelog.php deleted file mode 100644 index 1775a76..0000000 --- a/extend/sms/submail/lib/messagelog.php +++ /dev/null @@ -1,113 +0,0 @@ -configs=$configs; - } - - public function setRecipient($recipient){ - $this->recipient=$recipient; - } - - public function setProject($project){ - $this->project=$project; - } - - public function setResultStatus($result_status){ - if($result_status=='delivered' || $result_status=='dropped'){ - $this->result_status=$result_status; - } - } - - public function setStartDate($start_date){ - if($start_date!=''){ - $this->start_date=strtotime($start_date); - } - } - - public function setEndDate($end_date){ - if($end_date!=''){ - $this->end_date=strtotime($end_date); - } - } - - public function setOrderBy($order_by){ - if($order_by=='asc' || $order_by=='desc'){ - $this->order_by=$order_by; - } - } - - public function setRows($rows){ - if($rows>=10 && $rows<=1000){ - $this->rows=$rows; - } - } - - public function setOffset($offset){ - if($offset>=0){ - $this->offset=$offset; - } - } - - public function buildRequest(){ - $request=array(); - - if($this->recipient!=''){ - $request['recipient']=$this->recipient; - } - - if($this->project!=''){ - $request['project']=$this->project; - } - - if($this->result_status!=''){ - $request['result_status']=$this->result_status; - } - - if($this->start_date!=''){ - $request['start_date']=$this->start_date; - } - - if($this->end_date!=''){ - $request['end_date']=$this->end_date; - } - - if($this->order_by!=''){ - $request['order_by']=$this->order_by; - } - - if($this->rows!=''){ - $request['rows']=$this->rows; - } - - if($this->offset!=''){ - $request['offset']=$this->offset; - } - - return $request; - } - - public function log(){ - $message=new message($this->configs); - return $message->log($this->buildRequest()); - } - - } \ No newline at end of file diff --git a/extend/sms/submail/lib/messagemultisend.php b/extend/sms/submail/lib/messagemultisend.php deleted file mode 100644 index d5a2cc6..0000000 --- a/extend/sms/submail/lib/messagemultisend.php +++ /dev/null @@ -1,35 +0,0 @@ -configs=$configs; - } - - public function AddMulti($multi){ - array_push($this->Multi,$multi); - } - - public function SetContent($content){ - $this->Content=$content; - } - - public function buildRequest(){ - $request=array(); - $request['content']=$this->Content; - if(!empty($this->Multi)){ - $request['multi']=json_encode($this->Multi); - } - return $request; - } - - public function multisend(){ - $message=new message($this->configs); - return $message->multisend($this->buildRequest()); - } - - } \ No newline at end of file diff --git a/extend/sms/submail/lib/messagemultixsend.php b/extend/sms/submail/lib/messagemultixsend.php deleted file mode 100644 index d31a501..0000000 --- a/extend/sms/submail/lib/messagemultixsend.php +++ /dev/null @@ -1,39 +0,0 @@ -configs=$configs; - } - - public function AddMulti($multi){ - array_push($this->Multi,$multi); - } - - public function AddAddressbook($addressbook){ - array_push($this->Addressbook,$addressbook); - } - - public function SetProject($project){ - $this->Project=$project; - } - - public function buildRequest(){ - $request=array(); - $request['project']=$this->Project; - if(!empty($this->Multi)){ - $request['multi']=json_encode($this->Multi); - } - return $request; - } - - public function multixsend(){ - $message=new message($this->configs); - return $message->multixsend($this->buildRequest()); - } - - } \ No newline at end of file diff --git a/extend/sms/submail/lib/messagesend.php b/extend/sms/submail/lib/messagesend.php deleted file mode 100644 index bb2c524..0000000 --- a/extend/sms/submail/lib/messagesend.php +++ /dev/null @@ -1,39 +0,0 @@ -configs=$configs; - } - - public function SetTo($address){ - $this->To=trim($address); - } - - - public function SetContent($content){ - $this->Content=$content; - } - - public function AddVar($key,$val){ - $this->Vars[$key]=$val; - } - - public function buildRequest(){ - $request=array(); - $request['to']=$this->To; - $request['content']=$this->Content; - return $request; - } - public function send(){ - $message=new message($this->configs); - return $message->send($this->buildRequest()); - } - - } \ No newline at end of file diff --git a/extend/sms/submail/lib/messagetemplatedelete.php b/extend/sms/submail/lib/messagetemplatedelete.php deleted file mode 100644 index c8d3b23..0000000 --- a/extend/sms/submail/lib/messagetemplatedelete.php +++ /dev/null @@ -1,28 +0,0 @@ -configs=$configs; - } - - public function SetTemplate($template_id){ - $this->template_id=trim($template_id); - } - - public function buildRequest(){ - $request=array(); - - $request['template_id']=$this->template_id; - - return $request; - } - public function deleteTemplate(){ - $message=new message($this->configs); - return $message->deleteTemplate($this->buildRequest()); - } - - } \ No newline at end of file diff --git a/extend/sms/submail/lib/messagetemplateget.php b/extend/sms/submail/lib/messagetemplateget.php deleted file mode 100644 index b5dcca4..0000000 --- a/extend/sms/submail/lib/messagetemplateget.php +++ /dev/null @@ -1,28 +0,0 @@ -configs=$configs; - } - - public function SetTemplate($template_id){ - $this->template_id=trim($template_id); - } - - public function buildRequest(){ - $request=array(); - if(!empty($this->template_id)){ - $request['template_id']=$this->template_id; - } - return $request; - } - public function getTemplate(){ - $message=new message($this->configs); - return $message->getTemplate($this->buildRequest()); - } - - } \ No newline at end of file diff --git a/extend/sms/submail/lib/messagetemplatepost.php b/extend/sms/submail/lib/messagetemplatepost.php deleted file mode 100644 index 233e0c6..0000000 --- a/extend/sms/submail/lib/messagetemplatepost.php +++ /dev/null @@ -1,45 +0,0 @@ -configs=$configs; - } - - public function SetTitle($sms_title){ - $this->sms_title=trim($sms_title); - } - - public function SetSignature($sms_signature){ - $this->sms_signature=trim($sms_signature); - } - - public function SetContent($sms_content){ - $this->sms_content=trim($sms_content); - } - - public function buildRequest(){ - $request=array(); - if(!empty($this->sms_title)){ - $request['sms_title']=$this->sms_title; - } - - $request['sms_signature']=$this->sms_signature; - - $request['sms_content']=$this->sms_content; - - return $request; - } - public function postTemplate(){ - $message=new message($this->configs); - return $message->postTemplate($this->buildRequest()); - } - - } \ No newline at end of file diff --git a/extend/sms/submail/lib/messagetemplateput.php b/extend/sms/submail/lib/messagetemplateput.php deleted file mode 100644 index 0c41bb9..0000000 --- a/extend/sms/submail/lib/messagetemplateput.php +++ /dev/null @@ -1,55 +0,0 @@ -configs=$configs; - } - - public function SetTemplate($template_id){ - $this->template_id=trim($template_id); - } - - public function SetTitle($sms_title){ - $this->sms_title=trim($sms_title); - } - - public function SetSignature($sms_signature){ - $this->sms_signature=trim($sms_signature); - } - - public function SetContent($sms_content){ - $this->sms_content=trim($sms_content); - } - - public function buildRequest(){ - $request=array(); - - $request['template_id']=$this->template_id; - - if(!empty($this->sms_title)){ - $request['sms_title']=$this->sms_title; - } - - $request['sms_signature']=$this->sms_signature; - - $request['sms_content']=$this->sms_content; - - return $request; - } - public function putTemplate(){ - $message=new message($this->configs); - return $message->putTemplate($this->buildRequest()); - } - - } \ No newline at end of file diff --git a/extend/sms/submail/lib/messagexsend.php b/extend/sms/submail/lib/messagexsend.php deleted file mode 100644 index 162e4d4..0000000 --- a/extend/sms/submail/lib/messagexsend.php +++ /dev/null @@ -1,55 +0,0 @@ -configs=$configs; - } - - public function SetTo($address){ - $this->To=trim($address); - } - - public function AddAddressbook($addressbook){ - array_push($this->Addressbook,$addressbook); - } - - public function SetProject($project){ - $this->Project=$project; - } - - public function AddVar($key,$val){ - $this->Vars[$key]=$val; - } - - public function buildRequest(){ - $request=array(); - $request['to']=$this->To; - if(!empty($this->Addressbook)){ - $request['addressbook']=''; - foreach($this->Addressbook as $tmp){ - $request['addressbook'].=$tmp.','; - } - $request['addressbook'] = substr($request['addressbook'],0,count($request['addressbook'])-2); - } - - $request['project']=$this->Project; - if(!empty($this->Vars)){ - $request['vars']=json_encode($this->Vars); - } - return $request; - } - public function xsend(){ - $message=new message($this->configs); - return $message->xsend($this->buildRequest()); - } - - } diff --git a/extend/sms/submail/lib/mobiledata.php b/extend/sms/submail/lib/mobiledata.php deleted file mode 100644 index 9ebebf5..0000000 --- a/extend/sms/submail/lib/mobiledata.php +++ /dev/null @@ -1,148 +0,0 @@ -mobiledata_configs=$configs; - if(!empty($configs['server'])){ - $this->base_url=$configs['server']; - } - } - - protected function createSignature($request){ - $r=""; - switch($this->signType){ - case 'normal': - $r=$this->mobiledata_configs['appkey']; - break; - case 'md5': - $r=$this->buildSignature($this->argSort($request)); - break; - case 'sha1': - $r=$this->buildSignature($this->argSort($request)); - break; - } - return $r; - } - - protected function buildSignature($request){ - $arg=""; - $app=$this->mobiledata_configs['appid']; - $appkey=$this->mobiledata_configs['appkey']; - while (list ($key, $val) = each ($request)) { - $arg.=$key."=".$val."&"; - } - $arg = substr($arg,0,count($arg)-2); - if(get_magic_quotes_gpc()){$arg = stripslashes($arg);} - - if($this->signType=='sha1'){ - $r=sha1($app.$appkey.$arg.$app.$appkey); - }else{ - $r=md5($app.$appkey.$arg.$app.$appkey); - } - - return $r; - } - - protected function argSort($request) { - ksort($request); - reset($request); - return $request; - } - - protected function getTimestamp(){ - $api=$this->base_url.'service/timestamp.json'; - $ch = curl_init($api) ; - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ; - curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ; - $output = curl_exec($ch) ; - $timestamp=json_decode($output,true); - - return $timestamp['timestamp']; - } - - protected function APIHttpRequestCURL($api,$post_data,$method='post'){ - if($method!='get'){ - $ch = curl_init(); - curl_setopt_array($ch, array( - CURLOPT_URL => $api, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_POSTFIELDS => http_build_query($post_data), - CURLOPT_CUSTOMREQUEST => strtoupper($method), - CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded") - )); - }else{ - $url=$api.'?'.http_build_query($post_data); - $ch = curl_init($url) ; - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ; - curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1) ; - } - $output = curl_exec($ch); - curl_close($ch); - $output = trim($output, "\xEF\xBB\xBF"); - return json_decode($output,true); - } - - public function package($request){ - $api=$this->base_url.'mobiledata/package.json'; - $request['appid']=$this->mobiledata_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->mobiledata_configs['sign_type']) - && $this->mobiledata_configs['sign_type']=="" - && $this->mobiledata_configs['sign_type']!="normal" - && $this->mobiledata_configs['sign_type']!="md5" - && $this->mobiledata_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->mobiledata_configs['sign_type']; - $request['sign_type']=$this->mobiledata_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - $package=$this->APIHttpRequestCURL($api,$request); - return $package; - } - - public function TOService($request){ - $api=$this->base_url.'mobiledata/toservice.json'; - $request['appid']=$this->mobiledata_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->mobiledata_configs['sign_type']) - && $this->mobiledata_configs['sign_type']=="" - && $this->mobiledata_configs['sign_type']!="normal" - && $this->mobiledata_configs['sign_type']!="md5" - && $this->mobiledata_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->mobiledata_configs['sign_type']; - $request['sign_type']=$this->mobiledata_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - $TOService=$this->APIHttpRequestCURL($api,$request); - return $TOService; - } - - public function charge($request){ - $api=$this->base_url.'mobiledata/charge.json'; - $request['appid']=$this->mobiledata_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->mobiledata_configs['sign_type']) - && $this->mobiledata_configs['sign_type']=="" - && $this->mobiledata_configs['sign_type']!="normal" - && $this->mobiledata_configs['sign_type']!="md5" - && $this->mobiledata_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->mobiledata_configs['sign_type']; - $request['sign_type']=$this->mobiledata_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - $charge=$this->APIHttpRequestCURL($api,$request); - return $charge; - } - - } diff --git a/extend/sms/submail/lib/mobiledatacharge.php b/extend/sms/submail/lib/mobiledatacharge.php deleted file mode 100644 index 6fc6715..0000000 --- a/extend/sms/submail/lib/mobiledatacharge.php +++ /dev/null @@ -1,73 +0,0 @@ -configs=$configs; - } - - public function AddTo($address){ - array_push($this->To,trim($address)); - } - - public function AddAddressbook($addressbook){ - array_push($this->Addressbook,$addressbook); - } - - public function SetCM($cm){ - $this->cm=$cm; - } - - public function SetCU($cu){ - $this->cu=$cu; - } - - public function SetCT($ct){ - $this->ct=$ct; - } - - public function buildRequest(){ - $request=array(); - if(!empty($this->To)){ - $request['to']=''; - foreach($this->To as $tmp){ - $request['to'].=$tmp.','; - } - $request['to'] = substr($request['to'],0,count($request['to'])-2); - } - if($this->cm !=''){ - $request['cm']=$this->cm; - } - if($this->cu !=''){ - $request['cu']=$this->cu; - } - if($this->ct !=''){ - $request['ct']=$this->ct; - } - if(!empty($this->Addressbook)){ - $request['addressbook']=''; - foreach($this->Addressbook as $tmp){ - $request['addressbook'].=$tmp.','; - } - $request['addressbook'] = substr($request['addressbook'],0,count($request['addressbook'])-2); - } - return $request; - } - public function charge(){ - $mobiledata=new mobiledata($this->configs); - return $mobiledata->charge($this->buildRequest()); - } - - } \ No newline at end of file diff --git a/extend/sms/submail/lib/mobiledatapackage.php b/extend/sms/submail/lib/mobiledatapackage.php deleted file mode 100644 index b9da173..0000000 --- a/extend/sms/submail/lib/mobiledatapackage.php +++ /dev/null @@ -1,19 +0,0 @@ -configs=$configs; - } - - public function buildRequest(){ - $request=array(); - return $request; - } - public function package(){ - $mobiledata=new mobiledata($this->configs); - return $mobiledata->package($this->buildRequest()); - } - - } \ No newline at end of file diff --git a/extend/sms/submail/lib/mobiledatatoservice.php b/extend/sms/submail/lib/mobiledatatoservice.php deleted file mode 100644 index dce5e16..0000000 --- a/extend/sms/submail/lib/mobiledatatoservice.php +++ /dev/null @@ -1,46 +0,0 @@ -configs=$configs; - } - - public function AddTo($address){ - array_push($this->To,trim($address)); - } - - public function AddAddressbook($addressbook){ - array_push($this->Addressbook,$addressbook); - } - - public function buildRequest(){ - $request=array(); - if(!empty($this->To)){ - $request['to']=''; - foreach($this->To as $tmp){ - $request['to'].=$tmp.','; - } - $request['to'] = substr($request['to'],0,count($request['to'])-2); - } - if(!empty($this->Addressbook)){ - $request['addressbook']=''; - foreach($this->Addressbook as $tmp){ - $request['addressbook'].=$tmp.','; - } - $request['addressbook'] = substr($request['addressbook'],0,count($request['addressbook'])-2); - } - return $request; - } - public function TOService(){ - $mobiledata=new mobiledata($this->configs); - return $mobiledata->TOService($this->buildRequest()); - } - - } \ No newline at end of file diff --git a/extend/sms/submail/lib/multi.php b/extend/sms/submail/lib/multi.php deleted file mode 100644 index 4dc2224..0000000 --- a/extend/sms/submail/lib/multi.php +++ /dev/null @@ -1,21 +0,0 @@ -To=$address; - } - - public function AddVar($key,$val){ - $this->Vars[$key]=$val; - } - - public function Build(){ - $multi=array("to"=>$this->To,"vars"=>$this->Vars); - unset($this->To); - unset($this->Vars); - return $multi; - } - } \ No newline at end of file diff --git a/extend/sms/submail/lib/voice.php b/extend/sms/submail/lib/voice.php deleted file mode 100644 index 7fbdf8d..0000000 --- a/extend/sms/submail/lib/voice.php +++ /dev/null @@ -1,163 +0,0 @@ -voice_configs=$voice_configs; - if(!empty($voice_configs['server'])){ - $this->base_url=$voice_configs['server']; - } - } - - protected function createSignature($request){ - $r=""; - switch($this->signType){ - case 'normal': - $r=$this->voice_configs['appkey']; - break; - case 'md5': - $r=$this->buildSignature($this->argSort($request)); - break; - case 'sha1': - $r=$this->buildSignature($this->argSort($request)); - break; - } - return $r; - } - - protected function buildSignature($request){ - $arg=""; - $app=$this->voice_configs['appid']; - $appkey=$this->voice_configs['appkey']; - while (list ($key, $val) = each ($request)) { - $arg.=$key."=".$val."&"; - } - $arg = substr($arg,0,count($arg)-2); - if(get_magic_quotes_gpc()){$arg = stripslashes($arg);} - - if($this->signType=='sha1'){ - $r=sha1($app.$appkey.$arg.$app.$appkey); - }else{ - $r=md5($app.$appkey.$arg.$app.$appkey); - } - - return $r; - } - - protected function argSort($request) { - ksort($request); - reset($request); - return $request; - } - - protected function getTimestamp(){ - $api=$this->base_url.'service/timestamp.json'; - $ch = curl_init($api) ; - curl_setopt($ch, CURLOPT_RETURNTRANSFER, true) ; - curl_setopt($ch, CURLOPT_BINARYTRANSFER, true) ; - $output = curl_exec($ch) ; - $timestamp=json_decode($output,true); - - return $timestamp['timestamp']; - } - - protected function APIHttpRequestCURL($api,$post_data,$method='post'){ - if($method!='get'){ - $ch = curl_init(); - curl_setopt_array($ch, array( - CURLOPT_URL => $api, - CURLOPT_RETURNTRANSFER => true, - CURLOPT_POSTFIELDS => http_build_query($post_data), - CURLOPT_CUSTOMREQUEST => strtoupper($method), - CURLOPT_HTTPHEADER => array("Content-Type: application/x-www-form-urlencoded") - )); - }else{ - $url=$api.'?'.http_build_query($post_data); - $ch = curl_init($url) ; - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1) ; - curl_setopt($ch, CURLOPT_BINARYTRANSFER, 1) ; - } - $output = curl_exec($ch); - curl_close($ch); - $output = trim($output, "\xEF\xBB\xBF"); - return json_decode($output,true); - } - - public function verify($request){ - $api=$this->base_url.'voice/verify.json'; - $request['appid']=$this->voice_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->voice_configs['sign_type']) - && $this->voice_configs['sign_type']=="" - && $this->voice_configs['sign_type']!="normal" - && $this->voice_configs['sign_type']!="md5" - && $this->voice_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->voice_configs['sign_type']; - $request['sign_type']=$this->voice_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - $send=$this->APIHttpRequestCURL($api,$request); - return $send; - } - public function xsend($request){ - $api=$this->base_url.'voice/xsend.json'; - $request['appid']=$this->voice_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->voice_configs['sign_type']) - && $this->voice_configs['sign_type']=="" - && $this->voice_configs['sign_type']!="normal" - && $this->voice_configs['sign_type']!="md5" - && $this->voice_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->voice_configs['sign_type']; - $request['sign_type']=$this->voice_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - $send=$this->APIHttpRequestCURL($api,$request); - return $send; - } - public function send($request){ - $api=$this->base_url.'voice/send.json'; - $request['appid']=$this->voice_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->voice_configs['sign_type']) - && $this->voice_configs['sign_type']=="" - && $this->voice_configs['sign_type']!="normal" - && $this->voice_configs['sign_type']!="md5" - && $this->voice_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->voice_configs['sign_type']; - $request['sign_type']=$this->voice_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - $send=$this->APIHttpRequestCURL($api,$request); - return $send; - } - public function multixsend($request){ - $api=$this->base_url.'voice/multixsend.json'; - $request['appid']=$this->voice_configs['appid']; - $request['timestamp']=$this->getTimestamp(); - if(empty($this->voice_configs['sign_type']) - && $this->voice_configs['sign_type']=="" - && $this->voice_configs['sign_type']!="normal" - && $this->voice_configs['sign_type']!="md5" - && $this->voice_configs['sign_type']!="sha1"){ - $this->signType='normal'; - }else{ - $this->signType=$this->voice_configs['sign_type']; - $request['sign_type']=$this->voice_configs['sign_type']; - } - $request['signature']=$this->createSignature($request); - $send=$this->APIHttpRequestCURL($api,$request); - return $send; - } - } diff --git a/extend/sms/submail/lib/voicemultixsend.php b/extend/sms/submail/lib/voicemultixsend.php deleted file mode 100644 index 61cd4bb..0000000 --- a/extend/sms/submail/lib/voicemultixsend.php +++ /dev/null @@ -1,40 +0,0 @@ -configs=$configs; - } - - public function AddMulti($multi){ - array_push($this->Multi,$multi); - } - - public function AddAddressbook($addressbook){ - array_push($this->Addressbook,$addressbook); - } - - public function SetProject($project){ - $this->Project=$project; - } - - public function buildRequest(){ - $request=array(); - $request['project']=$this->Project; - if(!empty($this->Multi)){ - $request['multi']=json_encode($this->Multi); - } - return $request; - } - - public function multixsend(){ - $voice=new voice($this->configs); - return $voice->multixsend($this->buildRequest()); - } - - } diff --git a/extend/sms/submail/lib/voicesend.php b/extend/sms/submail/lib/voicesend.php deleted file mode 100644 index d9f33a3..0000000 --- a/extend/sms/submail/lib/voicesend.php +++ /dev/null @@ -1,37 +0,0 @@ -configs=$configs; - } - - public function SetTo($address){ - $this->To=trim($address); - } - - - public function SetContent($content){ - $this->Content=$content; - } - - public function AddVar($key,$val){ - $this->Vars[$key]=$val; - } - - public function buildRequest(){ - $request=array(); - $request['to']=$this->To; - $request['content']=$this->Content; - return $request; - } - public function send(){ - $voice=new voice($this->configs); - return $voice->send($this->buildRequest()); - } - - } diff --git a/extend/sms/submail/lib/voiceverify.php b/extend/sms/submail/lib/voiceverify.php deleted file mode 100644 index 943c4f6..0000000 --- a/extend/sms/submail/lib/voiceverify.php +++ /dev/null @@ -1,33 +0,0 @@ -configs=$configs; - } - - public function SetTo($address){ - $this->To=trim($address); - } - - public function SetCode($code){ - $this->Code=$code; - } - - public function buildRequest(){ - $request=array(); - $request['to']=$this->To; - $request['code']=$this->Code; - return $request; - } - public function verify(){ - $voice=new voice($this->configs); - return $voice->verify($this->buildRequest()); - } - - } \ No newline at end of file diff --git a/extend/sms/submail/lib/voicexsend.php b/extend/sms/submail/lib/voicexsend.php deleted file mode 100644 index c778d2d..0000000 --- a/extend/sms/submail/lib/voicexsend.php +++ /dev/null @@ -1,52 +0,0 @@ -configs=$configs; - } - - public function SetTo($address){ - $this->To=trim($address); - } - - public function SetProject($project){ - $this->Project=$project; - } - - public function AddVar($key,$val){ - $this->Vars[$key]=$val; - } - - public function buildRequest(){ - $request=array(); - $request['to']=$this->To; - if(!empty($this->Addressbook)){ - $request['addressbook']=''; - foreach($this->Addressbook as $tmp){ - $request['addressbook'].=$tmp.','; - } - $request['addressbook'] = substr($request['addressbook'],0,count($request['addressbook'])-2); - } - - $request['project']=$this->Project; - if(!empty($this->Vars)){ - $request['vars']=json_encode($this->Vars); - } - return $request; - } - public function xsend(){ - $voice=new voice($this->configs); - return $voice->xsend($this->buildRequest()); - } - - }