function exportExcel($expTitle, $expCellName, $expTableData) { $xlsTitle = iconv('utf-8', 'gb2312', $expTitle); //文件名称 $fileName = $_SESSION['account'] . date('_YmdHis'); //or $xlsTitle 文件名称可根据自己情况设定 $cellNum = count($expCellName); $dataNum = count($expTableData); vendor("PHPExcel.PHPExcel"); $objPHPExcel = new \PHPExcel(); $cellName = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ'); $objPHPExcel->getActiveSheet(0)->mergeCells('A1:' . $cellName[$cellNum - 1] . '1'); //合并单元格 for ($i = 0; $i < $cellNum; $i++) { $objPHPExcel->setActiveSheetIndex(0)->setCellValue($cellName[$i] . '2', $expCellName[$i][1]); } for ($i = 0; $i < $dataNum; $i++) { for ($j = 0; $j < $cellNum; $j++) { $objPHPExcel->getActiveSheet(0)->setCellValue($cellName[$j] . ($i + 3), $expTableData[$i][$expCellName[$j][0]]); } } header('pragma:public'); header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $xlsTitle . '.xls"'); header("Content-Disposition:attachment;filename={$fileName}.xls"); //attachment新窗口打印inline本窗口打印 $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); //$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); $objWriter->save('php://output'); exit; }
function _initialize() { $url = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; if ($_GET != null) { $info["openid"] = $_GET["openid"]; cookie('USER_INFO', $info, 3600 * 24 * 365); } $time = date("Y-m-d"); if (D("time")->where(array("time" => $time))->find() != null) { D("time")->where(array("time" => $time))->setInc("no"); } else { D("time")->add(array("time" => $time, "no" => 1)); } $temp = get_config(); $this->assign("con", $temp); // cookie('USER_INFO', array('openid' => 'ooJsMuBae9b3XHJVptSqp1Jr9Tw4'), 3600 * 521); $user = cookie('USER_INFO'); $openid = $user['openid']; vendor('Wx.Jssdk'); $jssdk = new JSSDK($temp["AppId"], $temp["AppSecret"]); $signPackage = $jssdk->GetSignPackage(); $this->assign("signPackage", $signPackage); $one = D("Account")->where(array("openid" => $openid))->find(); if ($one["nickname"] == "" || $one["nickname"] != null) { D("Account")->where(array("openid" => $openid))->save(array("nickname" => $user["nickname"])); } if (empty($openid)) { //$this->redirect("Auth/oauth"); header("Location:" . 'http://mt.magicgell.com/user/openid?redirect=' . $url); } else { } }
/** * [keyword 获取关键词] * @param [type] $text [文本] * @param string $filter [过滤条件] * @return [type] [description] */ public function keyword($text, $filter = '') { $filter = $this->makeFilter($filter); vendor('pscws4.class#pscws4'); $pscws = new PSCWS4(); $pscws->set_charset('utf-8'); $pscws->send_text($text); $some = $pscws->get_tops(10, $filter); $_result = $this->makeAttr($some); $filter_reg = explode(',', str_replace('~', '', $filter)); if (!empty($filter)) { if ($filter != "~") { foreach ($_result as $k => $v) { if (in_array($v['attr'], $filter_reg)) { $_res[] = $v; } } } else { $_res = $_result; } } else { $_res = $_result; } return $_res; }
public function get_user_openid($code) { //url:https://api.weixin.qq.com/sns/oauth2/access_token?appid=APPID&secret=SECRET&code=CODE&grant_type=authorization_code $url = 'https://api.weixin.qq.com/sns/oauth2/access_token'; vendor('Weixinpay.WxPayJsApiPay'); $appid = \WxPayConfig::APPID; $crypt = \WxPayConfig::APPSECRET; $param = array('appid' => $appid, 'secret' => $crypt, 'code' => $code, 'grant_type' => 'authorization_code'); $result = get($url, $param); $result = json_decode($result); //处理object $result = object_array($result); //获取长久一点的access_token //url:https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=APPID&grant_type=refresh_token&refresh_token=REFRESH_TOKEN $result = get("https://api.weixin.qq.com/sns/oauth2/refresh_token?appid=" . $appid . "&grant_type=refresh_token&refresh_token=" . $result['refresh_token'] . ""); $result = json_decode($result); //处理object $result = object_array($result); //如果返回错误信息 if (!empty($result['errcode'])) { $this->error('网站错误,请联系管理员' . $result['errcode'] . ''); } else { return $result; } }
public function __construct() { vendor("wechat"); $wechat = new wechat(); $wechat->valid(); $wechat->createMenu(); }
public function index() { if (!session('openid_' . $this->token)) { $this->info = M('wxuser')->where(array('token' => $this->token))->find(); vendor("Oauth2.OAuth2", LIB_PATH . '../Extend/Vendor'); vendor("Oauth2.Provider.Wechat", LIB_PATH . '../Extend/Vendor'); $wechat = new Wechat(); $wechat->config(array('id' => $this->info['appid'], 'secret' => $this->info['appsecret'])); $redirect_uri = C('site_url') . '/index.php/Wap/Coupons/index?token=' . $this->token . '&coupon_id=' . $this->coupon_id; if (!$_GET['code']) { // By sending no options it'll come back here $url = $wechat->authorize(array('redirect_uri' => $redirect_uri)); redirect($url); } else { try { // Have a go at creating an access token from the code $token = $wechat->access($_GET['code'], array('redirect_uri' => $redirect_uri)); // Use this object to try and get some user details (username, full name, etc) $user = $wechat->get_user_info($token); $this->openid = $user->openid; session('openid_' . $this->token, $user->openid); } catch (OAuth2_Exception $e) { print_r($e); die; } } } else { $this->openid = session('openid_' . $this->token); } $url = C('site_url') . "/index.php?g=Wap&m=Coupon&a=index&type=1&token=" . $this->token . '&id=' . $this->coupon_id . '&wecha_id=' . $this->openid; header('Location:' . $url); }
public function index() { //TODO: 生成二维码 vendor("Org.PhpQrcode.QrcodeHelper"); $qrcode = new QrcodeHelper(); dump($qrcode); }
/** * 架构函数 */ public function __construct() { //控制器初始化 if (method_exists($this, '_initialize')) { $this->_initialize(); } //导入类库 vendor('Hprose.Hprose', COMMON_PATH . 'Vendor/'); //实例化HproseHttpServer $server = new \HproseHttpServer(); if (empty($this->allowMethodList)) { $methods = get_class_methods($this); $methods = array_diff($methods, array('__construct', '__call', '_initialize')); } else { $methods = $this->allowMethodList; } $server->addMethods($methods, $this); if (APP_DEBUG || $this->debug) { $server->setDebugEnabled(TRUE); } //Hprose设置 $server->setCrossDomainEnabled($this->crossDomain); $server->setP3PEnabled($this->P3P); $server->setGetEnabled($this->get); //启动server $server->start(); }
function SendMail($address, $message) { vendor('PHPMailer.class#phpmailer'); $mail = new PHPMailer(); // 设置PHPMailer使用SMTP服务器发送Email $mail->IsSMTP(); // 设置邮件的字符编码,若不指定,则为'UTF-8' $mail->IsHTML(true); //支持html格式内容 $mail->CharSet = 'UTF-8'; // 添加收件人地址,可以多次使用来添加多个收件人 $mail->AddAddress($address); // 设置邮件正文 $mail->Body = $message; // 设置邮件头的From字段。 $mail->From = C('MAIL_ADDRESS'); // 设置发件人名 $mail->FromName = C('MAIL_FORMNAME'); // 设置邮件标题 $mail->Subject = C('MAIL_TITLE'); // 设置SMTP服务器。 $mail->Host = C('MAIL_SMTP'); // 设置为"需要验证" ThinkPHP 的C方法读取配置文件 $mail->SMTPAuth = true; // 设置用户名和密码。 $mail->Username = C('MAIL_LOGINNAME'); $mail->Password = C('MAIL_PASSWORD'); // 发送邮件。 return $mail->Send(); }
/** * Initializes the pager. Must be called before using the component. * * Takes user configuration and creates pager object ($this->Pager) * * @access public * @param array $config Configuration options for Pager::factory() method * @see http://pear.php.net/manual/en/package.html.pager.factory.php * @return void */ function init($config) { // Get the correct URL, even with admin routes $here = array(); if (defined('CAKE_ADMIN') && !empty($this->Controller->params[CAKE_ADMIN])) { $here[0] = $this->Controller->params[CAKE_ADMIN]; $here[2] = substr($this->Controller->params['action'], strlen($this->Controller->params[CAKE_ADMIN]) + 1); } else { $here[2] = $this->Controller->params['action']; } $here[1] = Inflector::underscore($this->Controller->params['controller']); ksort($here); $url = implode('/', $here); // Set up the default configuration vars $this->params = array('mode' => 'Sliding', 'perPage' => 10, 'delta' => 5, 'totalItems' => '', 'httpMethod' => 'GET', 'currentPage' => 1, 'linkClass' => 'pager', 'altFirst' => 'First page', 'altPrev ' => 'Previous page', 'altNext' => 'Next page', 'altLast' => 'Last page', 'separator' => '', 'spacesBeforeSeparator' => 1, 'spacesAfterSeparator' => 1, 'useSessions' => false, 'firstPagePre' => '', 'firstPagePost' => '', 'firstPageText' => '<img src="' . $this->Controller->base . '/img/first.gif" alt="">', 'lastPagePre' => '', 'lastPagePost' => '', 'lastPageText' => '<img src="' . $this->Controller->base . '/img/last.gif" alt="">', 'prevImg' => '<img src="' . $this->Controller->base . '/img/prev.gif" alt="">', 'nextImg' => '<img src="' . $this->Controller->base . '/img/next.gif" alt="">', 'altPage' => 'Page', 'clearIfVoid' => true, 'append' => false, 'path' => '', 'fileName' => $this->Controller->base . DS . $url . DS . '%d', 'urlVar' => ''); vendor('Pear/Pager/Pager'); // Merge with user config $this->params = array_merge($this->params, $config); // sanitize requested page number if (!in_array($this->params['currentPage'], range(1, ceil($this->params['totalItems'] / $this->params['perPage'])))) { $this->params['currentPage'] = 1; } $this->Pager =& Pager::factory($this->params); // Set the template vars $this->Controller->set('pageLinks', $this->Pager->getLinks()); $this->Controller->set('currentPage', $this->params['currentPage']); $this->Controller->set('isFirstPage', $this->Pager->isFirstPage()); $this->Controller->set('isLastPage', $this->Pager->isLastPage()); }
/** * @param class doUpload 文件上传封装类 * @const ACCESS SECRET 七牛云的秘钥 * @param array $file 前台name的上传文件名 * @return string $key 文件路径 * @author GIO 645074190@qq.com */ public function doUpload($file = array()) { vendor('php-sdk-master.autoload'); $auth = new Auth(self::ACCESS, self::SECRET); //实例化一个Auth类 $bucket = 'xmmusic'; //要上传的空间名 $token = $auth->uploadToken($bucket); //生成上传的Token $filePath = $file['tmp_name']; //上传的本地文件路径 $str = $file['name']; $pathInfo = pathinfo($str); $suffix = $pathInfo['dirname'] . $pathInfo['extension']; //生成上传文件的后缀名 if (empty($suffix)) { $this->error('请上传扫描文件', 'index'); } else { $key = date('Ymd', time()) . mt_rand(1000, 9000) . $suffix; /*上传到七牛云后保存的随机文件名*/ $uploadMgr = new UploadManager(); /*初始化 UploadManager 对象并进行文件的上传*/ list($ret, $err) = $uploadMgr->putFile($token, $key, $filePath); return $key; } }
function read() { vendor('Excel' . DS . 'reader'); $this->SER = new Spreadsheet_Excel_Reader(); $this->SER->setOutputEncoding = $this->setOutputEncoding; $this->SER->read($this->file); }
public function init($type) { ini_set('display_errors', 1); error_reporting(E_ALL); vendor("OAuth2.Autoloader"); $loader = new Autoloader(); $loader::register(); //数据库存储 $storage = $this->getMysqlStorage(); // Pass a storage object or array of storage objects to the OAuth2 server class if ($type == self::IMPLICIT) { $server = new Server($storage, array('allow_implicit' => true)); } else { $server = new Server($storage, array('allow_implicit' => false)); } if ($type == self::CLIENT_CREDENTIALS) { // 客户端授权类型 $server->addGrantType(new ClientCredentials($storage, array('allow_credentials_in_request_body => true'))); } elseif ($type == self::AUTHORIZATION_CODE) { // 增加授权码模式授权类型 $server->addGrantType(new AuthorizationCode($storage)); } elseif ($type == self::PASSWORD) { // 增加password模式授权类型 $server->addGrantType(new UserCredentials($storage)); } else { // 增加password模式授权类型 $server->addGrantType(new UserCredentials($storage)); // 增加授权码模式授权类型 $server->addGrantType(new AuthorizationCode($storage)); // 客户端授权类型 $server->addGrantType(new ClientCredentials($storage)); } return $server; }
/** * Push * * @param string $message * Message content * @param int $receiver_type * Receiver type(1:IMEI(Must special appKeys first),2:tag,3:alias,4:broadcast * @param string $receiver_value * Relative with Reciever type * @param int $is_system * (1:yes,0:no) * @param int|null $goods_id * Goods id * @return boolean */ function push($message, $receiver_type = 4, $receiver_value = '', $is_system = 1, $goods_id = null) { vendor('jpush.JPushClient'); $jPush_config = C('JPush'); $url = 'http://api.jpush.cn:8800/v2/push'; $param = ''; $param .= '&sendno=1'; $param .= '&app_key=' . $jPush_config['app_key']; $param .= '&receiver_type=' . $receiver_type; $param .= '&receiver_value=' . $receiver_value; $masterSecret = $jPush_config['master_secret']; $verification_code = md5(1 . $receiver_type . $receiver_value . $masterSecret); $param .= '&verification_code=' . $verification_code; $param .= '&msg_type=1'; $message = json_encode(array('n_content' => $message, 'n_extras' => array('ios' => array('content-available' => 1), 'is_system' => $is_system, 'goods_id' => $goods_id))); $param .= '&msg_content=' . $message; $param .= '&platform=' . $jPush_config['platform']; if (empty($url) || empty($param)) { return false; } $postUrl = $url; $curlPost = $param; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $postUrl); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $curlPost); $data = json_decode(curl_exec($ch)); curl_close($ch); return $data->errcode ? false : true; }
/** * 邮件发送函数 */ function sendMail($to, $subject, $content) { vendor('PHPMailer.PHPMailerAutoload'); $mail = new PHPMailer(); // 装配邮件服务器 if (C('MAIL_SMTP')) { $mail->IsSMTP(); } $mail->Host = C('MAIL_HOST'); $mail->SMTPAuth = C('MAIL_SMTPAUTH'); $mail->Username = C('MAIL_USERNAME'); $mail->Password = C('MAIL_PASSWORD'); $mail->SMTPSecure = C('MAIL_SECURE'); $mail->CharSet = C('MAIL_CHARSET'); // 装配邮件头信息 $mail->From = C('MAIL_USERNAME'); $mail->AddAddress($to); $mail->FromName = '憨豆儿笑园'; $mail->IsHTML(C('MAIL_ISHTML')); // 装配邮件正文信息 $mail->Subject = $subject; $mail->Body = $content; // 发送邮件 if (!$mail->Send()) { return false; } else { return true; } }
public function __construct() { Vendor('phpexcel.PHPExcel'); Vendor('phpexcel.PHPExcel.IOFactory'); Vendor('phpexcel.PHPExcel.Reader.Excel5'); vendor('phpexcel.PHPExcel.Reader.Excel2007'); }
public function fetch_tb($url) { $id = $this->get_id($url); if (!$id) { return false; } $item_site = M('items_site')->where(array('code' => $this->_code))->find(); $api_config = unserialize($item_site['config']); //使用淘宝开放平台API vendor('Taobaotop.TopClient'); vendor('Taobaotop.RequestCheckUtil'); vendor('Taobaotop.Logger'); $tb_top = new TopClient(); $tb_top->appkey = $api_config['app_key']; $tb_top->secretKey = $api_config['app_secret']; //淘客信息 $req = $tb_top->load_api('TaobaokeItemsDetailGetRequest'); $req->setFields("num_iid,title,nick,pic_url,click_url,price,detail_url,auction_point,commission"); $req->setNumIids($id); $resp = $tb_top->execute($req); if (isset($resp->taobaoke_item_details)) { $taoke = (array) $resp->taobaoke_item_details->taobaoke_item_detail; if ($taoke['click_url']) { $taoke['click_url'] = Url::replace($taoke['click_url'], array('spm' => '2014.' . $api_config['app_key'] . '.1.0')); } return $taoke; } return false; }
public function _initialize() { vendor('Alipay.Corefunction'); vendor('Alipay.Md5function'); vendor('Alipay.Notify'); vendor('Alipay.Submit'); }
private function _dealWeixinPost() { $content = wp_file_get_contents('php://input'); vendor('WXBiz.wxBizMsgCrypt'); $this->sReqTimeStamp = I('get.timestamp'); $this->sReqNonce = I('get.nonce'); $this->sEncryptMsg = I('get.msg_signature'); $this->wxcpt = new \WXBizMsgCrypt('weiphp', '0c79e1fa963cd80cc0be99b20a18faeb', 'wx2685aca90abe2895'); $sMsg = ""; // 解析之后的明文 $errCode = $this->wxcpt->DecryptMsg($this->sEncryptMsg, $this->sReqTimeStamp, $this->sReqNonce, $content, $sMsg); if ($errCode != 0) { addWeixinLog($_GET, "DecryptMsg Error: " . $errCode); return false; } else { // 解密成功,sMsg即为xml格式的明文 $content = $sMsg; } $data = new \SimpleXMLElement($content); // $data || die ( '参数获取失败' ); foreach ($data as $key => $value) { $this->data[$key] = safe(strval($value)); } return $data; }
/** * 支付宝回调 */ public static function alipayNotify() { vendor('Alipay.Notify', COMMON_PATH . 'Vendor'); $alipay_config = C('ALIPAY'); $AlipayNotify = new \AlipayNotify($alipay_config); return $AlipayNotify->verifyNotify(); }
public function sendMail($address, $send_user, $from, $title, $message) { vendor('mail.mail'); $message = eregi_replace("[\\]", '', $message); // preg_replace('/\\\\/','', $message); $mail = new PHPMailer(); $mail->IsSMTP(); // 设置PHPMailer使用SMTP服务器发送Email $mail->CharSet = 'UTF-8'; // 设置邮件的字符编码,若不指定,则为'UTF-8' $mail->Port = $this->setting['mail_port']; //端口号 $mail->AddAddress($address); // 添加收件人地址,可以多次使用来添加多个收件人 //$mail->Body=$message; // 设置邮件正文 $mail->MsgHTML($message); //$mail->From=$this->setting['mail_username']; // 设置邮件头的From字段。 $mail->From = $from; // 设置邮件头的From字段。 $mail->FromName = $this->setting['mail_fromname']; // 设置发件人名字 $mail->Subject = $title; // 设置邮件标题 $mail->Host = $this->setting['mail_smtp']; // 设置SMTP服务器。 $mail->SMTPAuth = true; // 设置为“需要验证” //$mail->Username=$this->setting['mail_username']; // 设置用户名和密码。 $mail->Username = $send_user; // 设置用户名和密码。 $mail->Password = $this->setting['mail_password']; // 发送邮件。 return $mail->Send(); }
public function __construct() { if ($_REQUEST['doNotInit']) { return true; } $content = wp_file_get_contents('php://input'); !empty($content) || die('这是微信请求的接口地址,直接在浏览器里无效'); if ($_GET['encrypt_type'] == 'aes') { vendor('WXBiz.wxBizMsgCrypt'); $this->sReqTimeStamp = I('get.timestamp'); $this->sReqNonce = I('get.nonce'); $this->sEncryptMsg = I('get.msg_signature'); $map['id'] = I('get.id'); $info = M('member_public')->where($map)->find(); get_token($info['token']); // 设置token $this->wxcpt = new \WXBizMsgCrypt('weiphp', $info['encodingaeskey'], $info['appid']); $sMsg = ""; // 解析之后的明文 $errCode = $this->wxcpt->DecryptMsg($this->sEncryptMsg, $this->sReqTimeStamp, $this->sReqNonce, $content, $sMsg); if ($errCode != 0) { addWeixinLog($_GET, "DecryptMsg Error: " . $errCode); exit; } else { // 解密成功,sMsg即为xml格式的明文 $content = $sMsg; } } $data = new \SimpleXMLElement($content); // $data || die ( '参数获取失败' ); foreach ($data as $key => $value) { $this->data[$key] = strval($value); } }
function index() { if (!session('openid_' . $this->token)) { $this->info = M('wxuser')->where(array('token' => $this->token))->find(); vendor("Oauth2.OAuth2", LIB_PATH . '../Extend/Vendor'); vendor("Oauth2.Provider.Wechat", LIB_PATH . '../Extend/Vendor'); $wechat = new Wechat(); $wechat->config(array('id' => $this->info['appid'], 'secret' => $this->info['appsecret'])); $redirect_uri = C('site_url') . '/index.php/Wap/Login/index?token=' . $this->token . '&url=' . $this->url; if (!$_GET['code']) { // By sending no options it'll come back here $url = $wechat->authorize(array('redirect_uri' => $redirect_uri)); redirect($url); } else { try { // Have a go at creating an access token from the code $access_token = $wechat->access($_GET['code'], array('redirect_uri' => $redirect_uri)); // Use this object to try and get some user details (username, full name, etc) $user = $wechat->get_user_info($access_token); $this->save_wechat_user($user); session('openid_' . $this->token, $user->openid); } catch (OAuth2_Exception $e) { print_r($e); die; } } } if ($this->url) { redirect($this->url); } }
public function _initialize() { vendor('Corefunction'); vendor('Md5function'); vendor('Notify'); vendor('Submit'); }
/** * 邮件发送函数 */ function sendMail($to, $title, $content) { // Vendor('PHPMailer.PHPMailerAutoload'); vendor('phpmailer.class#phpmailer'); $mail = new PHPMailer(); //实例化 $mail->IsSMTP(); // 启用SMTP $mail->Host = C('MAIL_HOST'); //smtp服务器的名称(这里以QQ邮箱为例) $mail->SMTPAuth = C('MAIL_SMTPAUTH'); //启用smtp认证 $mail->Username = C('MAIL_USERNAME'); //你的邮箱名 $mail->Password = C('MAIL_PASSWORD'); //邮箱密码 $mail->From = C('MAIL_FROM'); //发件人地址(也就是你的邮箱地址) $mail->FromName = C('MAIL_FROMNAME'); //发件人姓名 $mail->AddAddress($to, "尊敬的客户,你的密码是"); $mail->WordWrap = 50; //设置每行字符长度 $mail->IsHTML(C('MAIL_ISHTML')); // 是否HTML格式邮件 $mail->CharSet = C('MAIL_CHARSET'); //设置邮件编码 $mail->Subject = $title; //邮件主题 $mail->Body = $content; //邮件内容 $mail->AltBody = "这是一个纯文本的身体在非营利的HTML电子邮件客户端"; //邮件正文不支持HTML的备用显示 return $mail->Send(); }
public function sendSMS($tel) { //>>1. 随机生成一个数字 $randomNumber = String::randString(6, 1); session('SMS_CODE', $randomNumber); //为了和用户输入的短信验证码进行验证码 //>>2.将该数字发送到$tel手机号D:\thinkphp\ThinkPHP\Library\Vendor\SMS vendor('SMS.TopSdk'); $c = new \TopClient(); date_default_timezone_set('Asia/Shanghai'); //设置时区 $c->appkey = '23268864'; //创建应用上面的appkey $c->secretKey = '69f0728011dec573eb02f3f57583cb80'; //创建应用上面的secretKey $req = new \AlibabaAliqinFcSmsNumSendRequest(); // $req->setExtend("123456"); $req->setSmsType("normal"); //不改变 $req->setSmsFreeSignName("注册验证"); //用来验证 $req->setSmsParam("{'code':'{$randomNumber}','product':'源代码商城'}"); $req->setRecNum($tel); //接收的电话 $req->setSmsTemplateCode("SMS_2345004"); //模板id $resp = $c->execute($req); //判定发送的状态 // return ((string)$resp->result->success)==='true'; return $resp->result->success; }
/** * Think 基础函数库 * @category Think * @package Common * @author liu21st <*****@*****.**> */ function SendMail($address, $title, $message) { vendor('PHPMailer.phpmailer'); $mail = new PHPMailer(); // 设置PHPMailer使用SMTP服务器发送Email $mail->IsSMTP(); // 设置邮件的字符编码,若不指定,则为'UTF-8' $mail->CharSet = 'UTF-8'; // 添加收件人地址,可以多次使用来添加多个收件人 $mail->AddAddress($address); // 设置邮件正文 $mail->Body = $message; $mail->Port = 25; // 设置邮件头的From字段。 $mail->From = C('MAIL_ADDRESS'); // 设置发件人名字 $mail->FromName = 'Laundry'; // 设置邮件标题 $mail->Subject = $title; // 设置SMTP服务器。 $mail->Host = C('MAIL_SMTP'); // 设置为"需要验证" $mail->SMTPAuth = true; // 设置用户名和密码。 $mail->Username = C('MAIL_LOGINNAME'); $mail->Password = C('MAIL_PASSWORD'); // 发送邮件。 return $mail->Send(); }
public function dealAl() { vendor('Alipay.Corefunction'); vendor('Alipay.Md5function'); vendor('Alipay.Notify'); vendor('Alipay.Submit'); }
public function read($filename, $encode, $file_type) { if (strtolower($file_type) == 'xls') { vendor("Excel.PHPExcel.Reader.Excel5", LIB_PATH . '../Extend/Vendor'); $objReader = PHPExcel_IOFactory::createReader('Excel5'); } else { if (strtolower($file_type) == 'xlsx') { vendor("Excel.PHPExcel.Reader.Excel2007", LIB_PATH . '../Extend/Vendor'); $objReader = PHPExcel_IOFactory::createReader('Excel2007'); } } $objReader->setReadDataOnly(true); $objPHPExcel = $objReader->load($filename); $objWorksheet = $objPHPExcel->getActiveSheet(); $highestRow = $objWorksheet->getHighestRow(); $highestColumn = $objWorksheet->getHighestColumn(); $highestColumnIndex = PHPExcel_Cell::columnIndexFromString($highestColumn); $excelData = array(); for ($row = 1; $row <= $highestRow; $row++) { for ($col = 0; $col < $highestColumnIndex; $col++) { $excelData[$row][] = (string) $objWorksheet->getCellByColumnAndRow($col, $row)->getValue(); } } return $excelData; }
function convert($input, $outputdir = "files/File/", $output, $width = 320, $height = 240, $samplerate = 22050, $bitrate = 32) { vendor('ffmpeg'); define('OS_WINDOWS', false); $ffmpeg = new ffmpeg(); $ffmpeg->on_error_die = FALSE; $ok = $ffmpeg->setInputFile($input); if (!$ok) { // if there was an error then get it echo $ffmpeg->getLastError() . "<br />\r\n"; $ffmpeg->reset(); continue; } $ffmpeg->setVideoOutputDimensions($width, $height); $ffmpeg->setFormatToFLV($samplerate, $bitrate); $ok = $ffmpeg->setOutput($outputdir, $output . '.flv', TRUE); // check the return value in-case of error if (!$ok) { // if there was an error then get it echo $ffmpeg->getLastError() . "<br />\r\n"; $ffmpeg->reset(); continue; } $result = $ffmpeg->execute(TRUE); if (!$result) { // if there was an error then get it echo $ffmpeg->getLastError() . "<br />\r\n"; $ffmpeg->reset(); continue; } // reset $ffmpeg->reset(); }