本文整理汇总了PHP中vendor函数的典型用法代码示例。如果您正苦于以下问题:PHP vendor函数的具体用法?PHP vendor怎么用?PHP vendor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了vendor函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: exportExcel
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;
}
示例2: _initialize
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 {
}
}
示例3: keyword
/**
* [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;
}
示例4: get_user_openid
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;
}
}
示例5: __construct
public function __construct()
{
vendor("wechat");
$wechat = new wechat();
$wechat->valid();
$wechat->createMenu();
}
示例6: index
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);
}
示例7: index
public function index()
{
//TODO: 生成二维码
vendor("Org.PhpQrcode.QrcodeHelper");
$qrcode = new QrcodeHelper();
dump($qrcode);
}
示例8: __construct
/**
* 架构函数
*/
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();
}
示例9: SendMail
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();
}
示例10: init
/**
* 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());
}
示例11: doUpload
/**
* @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;
}
}
示例12: read
function read()
{
vendor('Excel' . DS . 'reader');
$this->SER = new Spreadsheet_Excel_Reader();
$this->SER->setOutputEncoding = $this->setOutputEncoding;
$this->SER->read($this->file);
}
示例13: init
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;
}
示例14: push
/**
* 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;
}
示例15: sendMail
/**
* 邮件发送函数
*/
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;
}
}