本文整理匯總了PHP中think_encrypt函數的典型用法代碼示例。如果您正苦於以下問題:PHP think_encrypt函數的具體用法?PHP think_encrypt怎麽用?PHP think_encrypt使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了think_encrypt函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: enc
public function enc()
{
echo $str = think_encrypt('123fejf', 'fjejf339fd3j', 15);
$str1 = think_decrypt($str, 'fjejf339fd3j');
S('t', $str);
dump(S('t'));
}
示例2: save
/**
* 批量保存配置
* @author 麥當苗兒 <zuojiazi@vip.qq.com>
*/
public function save($config)
{
$old['artid'] = M('Config')->where(array('name' => 'WXARTID'))->getField('value');
if ($config && is_array($config)) {
$Config = M('Config');
foreach ($config as $name => $value) {
$map = array('name' => $name);
if ($name == 'WXARTID') {
if ($old['artid'] != $value) {
asyn_sendwx();
//$WX->sendwx();
}
}
if ($name == 'WXPASS') {
$value = think_encrypt($value, UC_AUTH_KEY);
}
$Config->where($map)->setField('value', $value);
}
}
S('DB_CONFIG_DATA', null);
$config_file = './App/Home/Conf/theme.php';
$themename = (include $config_file);
if ($config['WEB_THEME'] != $themename['DEFAULT_THEME']) {
//寫入配置文件
$theme['DEFAULT_THEME'] = $config['WEB_THEME'];
file_put_contents($config_file, "<?php \nreturn " . var_export($theme, true) . ";", LOCK_EX);
dir_delete(RUNTIME_PATH);
}
$this->mtReturn(200, '網站配置保存成功!', '', 'forward', U('group'));
}
示例3: upload
public function upload()
{
/* 返回標準數據 */
$return = array('status' => 1, 'info' => '上傳成功', 'data' => '');
/* 獲取當前分類附件配置信息 */
$default = C('ATTACHMENT_DEFAULT');
$category = get_category(I('get.category'));
/* 分類正確性檢測 */
if (empty($category)) {
$return['status'] = 0;
$return['info'] = '沒有指定分類或分類不正確;';
} else {
$config = $category['extend']['attachment'];
$config = empty($config) ? $default : array_merge($default, $config);
/* 檢測並上傳附件 */
if (in_array('2', str2arr($config['allow_type']))) {
$setting = C('ATTACHMENT_UPLOAD');
/* 調用文件上傳組件上傳文件 */
$File = M('File');
$info = $File->upload($_FILES, $setting, $config['driver'], $config['driver_config']);
/* 記錄附件信息 */
if ($info) {
$return['data'] = think_encrypt(json_encode($info['attachment']));
} else {
$return['status'] = 0;
$return['info'] = $File->getError();
}
} else {
$return['info'] = '該分類不允許上傳文件附件!';
$return['status'] = 0;
}
}
/* 返回JSON數據 */
$this->ajaxReturn($return);
}
示例4: artc
public function artc()
{
$id = I('id');
$info = D('Article')->get_info($id);
if (!$info) {
$this->error('非法ID!', U('Index/index'), false, true);
}
$info['description'] = stripcslashes($info['description']);
preg_match_all("/(?<=\\[attach\\])([\\d]*)(?=\\[\\/attach\\])/", $info['description'], $arr);
preg_match_all("/(?<=\\[qnattach\\])([\\d]*)(?=\\[\\/qnattach\\])/", $info['description'], $qnarr);
foreach ($arr[0] as $key => $vo) {
$replace = '<a href="' . U('File/download', array('id' => think_encrypt($vo))) . '" target="_blank" >' . getattachname($vo) . '</a><span class="attachspan">(下載次數:' . getattachdnum($vo) . '次;大小:' . format_bytes(getattachsize($vo)) . ')</span>';
$info['description'] = str_replace('[attach]' . $vo . '[/attach]', $replace, $info['description']);
}
foreach ($qnarr[0] as $key1 => $vo1) {
$replace1 = '<a href="' . U('File/download', array('qn' => 1, 'id' => think_encrypt($vo1))) . '" target="_blank" >' . getqnattachname($vo1) . '</a><span class="attachspan">(下載次數:' . getqnattachdnum($vo1) . '次;大小:' . format_bytes(getqnattachsize($vo1)) . ')</span>';
$info['description'] = str_replace('[qnattach]' . $vo1 . '[/qnattach]', $replace1, $info['description']);
}
if ($info['status'] != 1 && $info['uid'] != $_SESSION['cs_home']['user_auth']['uid']) {
$this->error('你無權查看該內容!', '', false, true);
}
$focus['rowid'] = $info['id'];
$focus['type'] = 1;
if ($sccount = M('focus')->where($focus)->count() != $info['sccount']) {
D('Article')->where(array('id' => $id))->setField('sccount', $sccount);
}
D('Article')->where(array('id' => $id))->setInc('view', 1);
if (!empty($info['tag'])) {
$tags = explode(',', $info['tag']);
$info['linktag'] = '';
foreach ($tags as $key1 => $vo1) {
$maptag['title'] = $vo1;
$maptag['type'] = 1;
$tagid = M('tags')->where($maptag)->getField('id');
$url = CSU('/tagart/' . $tagid, 'Index/tagart', array('id' => $tagid));
$info['linktag'] .= '<a style="margin-left:5px;" href="' . $url . '">[' . $vo1 . ']</a>';
$info['tagarr'][$key1] = '<a class="tag" href="' . $url . '">' . $vo1 . '</a>';
}
}
$shareurl = 'http://' . $_SERVER['HTTP_HOST'] . CSU('/artc/' . $info['id'], 'Index/artc', array('id' => $info['id']));
$sharedes = '原文鏈接:' . $shareurl;
$sharetitle = $info['title'] . '-' . C('WEB_SITE_TITLE');
$authorinfo = query_user(array('space_url', 'signature', 'avatar64', 'nickname'), $info['uid']);
$map['id'] = is_login();
$map['rowid'] = $info['id'];
$map['type'] = 1;
if (M('Focus')->where($map)->count() > 0) {
$hassc = true;
}
$this->assign('shareurl', $shareurl);
$this->assign('hassc', $hassc);
$this->assign('sharedes', $sharedes);
$this->assign('sharetitle', $sharetitle);
$this->assign('authorinfo', $authorinfo);
$this->assign('info', $info);
$this->assign('webdescription', $info['title']);
$this->assign('webkeyword', $info['title']);
$this->assign('webtitle', $info['title']);
$this->display();
}
示例5: login
/**
* 登陸驗證
* @param [type] $u [用戶名]
* @param [type] $p [密碼]
* @return [type] sid [sid]
* @return [type] uid [用戶ID]
* @return [type] emp_name [用戶姓名]
* @return [type] emp_no [用戶名]
* @return [type] head [頭像]
* @return [type] dept [部門]
* @return [type] position [職位]
* @return [type] rank [職級]
* @return [type] mobile_tel [電話]
* @return [type] email [郵箱]
* @return [type] sex [性別]
* @return [type] duty [業務介紹]
* @return [type] chek_flow [審核公文權限]
* @return [type] submited_flow [提交公文權限]
* @return [type] add_meeting [添加會議權限]
* @return [type] check_meeting [<審核會議權限>]
*/
function login($u, $p)
{
$result = D('User')->apiLogin($u, $p, -1, '1,2');
// var_dump($result);
// exit;
if (is_array($result)) {
//登陸成功返回accesskey
$data['sid'] = think_encrypt($result['id'], C('UID_KEY'));
$data['uid'] = $result['id'];
$data['emp_name'] = $result['emp_name'];
//姓名
$data['emp_no'] = $result['emp_no'];
//用戶名
$data['head'] = $result['pic'];
//頭像
$data['dept'] = $result['dept_id'];
//部門
$data['position'] = $result['position_id'];
//職位
$data['rank'] = $result['rank_id'];
//職級
$data['mobile_tel'] = $result['mobile_tel'];
//電話
$data['email'] = $result['email'];
//郵箱
$data['sex'] = $result['sex'];
//性別
$data['duty'] = $result['duty'];
//業務介紹
$auth = $this->getAuth($result['id']);
if ($auth) {
// $data['add_flow'] = $auth['flow']?$auth['flow']:'';
$data['add_meeting'] = $auth['meeting'] ? $auth['meeting'] : '';
$data['check_meeting'] = $auth['meeting_check'] ? $auth['meeting_check'] : '';
$data['chek_flow'] = $auth['chek_flow'] ? $auth['chek_flow'] : '';
$data['submited_flow'] = $auth['submited_flow'] ? $auth['submited_flow'] : '';
}
// var_dump($data);
// exit;
$this->result('1', '登陸成功', $data);
} else {
switch ($result) {
case 0:
$msg = '參數錯誤!';
break;
case -1:
$msg = '用戶不存在或被禁用!';
break;
case -2:
$msg = '密碼錯誤!';
break;
case -3:
$msg = '沒有登陸權限!';
break;
default:
$msg = '未知錯誤!';
}
$this->result(0, $msg, '');
}
}
示例6: getBackPwd
public function getBackPwd()
{
$where['admin_email'] = $rootemail = I('post.rootemail');
$where['name'] = $name = I('post.rootname');
$pattern = '/^[0-9A-Za-z-\\._]+@\\w+(\\.(\\w){1,3}){1,3}$/';
$subject = $rootemail;
if (!preg_match($pattern, $subject)) {
$this->redirect(U('Server/Admin'));
die;
} else {
$tplObj = M('sys_email_templates');
$tpl_status = $tplObj->field('subject,content,status')->where($where)->find();
if ($tpl_status['status']) {
//發郵件
$to = $rootemail;
//接收郵件郵箱
$subject = $tpl_status['subject'];
$content = $tpl_status['content'];
//模板中包含標示
// 自定義郵件發送內容
$url = 'http://' . I('server.HTTP_HOST') . __APP__ . __CONTROLLER__ . '/repwd/code/' . think_encrypt($to);
//此處加密未隨機待完善
$username = '您於' . date('Y年m月d分 H時i分s秒') . '申請找回密碼<strong style="color:#00acff;">' . $rootemail . '</strong>';
$sy_webname = C('site_name');
$url = '<a href="' . $url . '">' . $url . '</a>';
$sy_webcopyright = C('copyright');
// 郵件內容正則
$pattern = array('/{sy_webname}/', '/{sy_webcopyright}/', '/{username}/', '/{url}/');
$replacement = array($sy_webname, $sy_webcopyright, $username, $url);
//替換模板中標簽成實際內容
$newSubject = preg_replace($pattern, $replacement, $subject);
$newContent = preg_replace($pattern, $replacement, $content);
//dump($newSubject);
//dump($newContent);exit;
$email = sendEMail($to, $newSubject, $newContent);
//發送成功直接修改數據密碼
if ($email) {
//修改發送郵件時間,便用於郵件過期處理
$Model = M('root_admin');
$Model->where("name='{$name}'")->setField('this_time', time());
} else {
$this->success('郵件發送失敗,返回重試', U('Server/Admin'), 3);
}
} else {
$this->error('管理員關閉找回密碼功能', U('Server/Admin'), 3);
}
}
//考慮調試郵箱登陸接口(未嘗試過)
$this->success('請查收您的郵件', U('Admin/index'), 3);
/*
$to ='zyajf1314@163.com';
$subject = '主題';
$content = '內容';
$email = sendEMail($to, $subject, $content);*/
//dump($email);
}
示例7: upload
public function upload()
{
$return = array('status' => 1, 'info' => '上傳成功', 'data' => '');
$qiniuconfig = json_decode(M('addons')->where(array('name' => 'Qiniu'))->getField('config'), true);
if ($qiniuconfig['open'] == 1) {
$addon = new QiniuAddon();
$return = $addon->upload($_FILES);
$exts = explode('.', strrev($_FILES['download']['name']));
if (in_array(strtolower(strrev($exts[0])), array('jpg', 'gif', 'png', 'jpeg'))) {
$return['ext'] = 3;
} else {
$return['ext'] = 4;
}
$this->ajaxReturn($return);
} else {
$exts = explode('.', strrev($_FILES['download']['name']));
if (in_array(strtolower(strrev($exts[0])), array('jpg', 'gif', 'png', 'jpeg'))) {
$return['ext'] = 1;
/* 調用文件上傳組件上傳文件 */
$Picture = D('Picture');
$pic_driver = C('PICTURE_UPLOAD_DRIVER');
$info = $Picture->upload($_FILES, C('PICTURE_UPLOAD'), C('PICTURE_UPLOAD_DRIVER'), C("UPLOAD_{$pic_driver}_CONFIG"));
//TODO:上傳到遠程服務器
/* 記錄圖片信息 */
if ($info) {
$return['status'] = 1;
$info['download']['path'] = (is_ssl() ? 'https://' : 'http://') . $_SERVER['HTTP_HOST'] . '/' . C('WEB_DIR') . $info['download']['path'];
// $info['Picture']['path']=$GLOBALS['_root'].$info['Picture']['path'];
$return = array_merge($info['download'], $return);
$return['info'] = $info[0]['path'];
// $return['info'] =$_FILES['download']['name'];
} else {
$return['status'] = 0;
$return['info'] = $Picture->getError();
}
$this->ajaxReturn($return);
} else {
$return['ext'] = 2;
/* 調用文件上傳組件上傳文件 */
$File = D('File');
$file_driver = C('DOWNLOAD_UPLOAD_DRIVER');
$info = $File->upload($_FILES, C('DOWNLOAD_UPLOAD'), C('DOWNLOAD_UPLOAD_DRIVER'), C("UPLOAD_{$file_driver}_CONFIG"));
/* 記錄附件信息 */
if ($info) {
$return['status'] = 1;
$return['data'] = U('File/download', array('id' => think_encrypt($info['download']['id'])));
$return['info'] = $info['download']['id'];
} else {
$return['status'] = 0;
$return['info'] = $File->getError();
}
/* 返回JSON數據 */
$this->ajaxReturn($return, 'JSON');
}
}
}
示例8: detail
/**
* 獲取模型詳細信息
* @param integer $id 文檔ID
* @return array 當前模型詳細信息
* @author huajie <banhuajie@163.com>
*/
public function detail($id)
{
$data = $this->field(true)->find($id);
if (!$data) {
$this->error = '獲取詳細信息出錯!';
return false;
}
$file = D('File')->field(true)->find($data['file_id']);
$data['file'] = think_encrypt(json_encode($file));
$data['file_id'] = $file;
return $data;
}
示例9: ssoList
public function ssoList()
{
//讀取規則列表
$map = array('status' => array('EGT', 0));
$model = M('sso_app');
$appList = $model->where($map)->order('id asc')->select();
foreach ($appList as &$v) {
$url = $v['url'] . '/' . $v['path'] . '?code=' . urlencode(think_encrypt('action=test&time=' . time()));
$arr = $this->check_link($url);
$v['link_status'] = $v['status'] == 1 ? $arr === 'success' ? '<span style="color:green">連接成功</span>' : '<span style="color:red">連接失敗</span>' : '<span style="color:red">連接失敗-已被禁用</span>';
}
unset($v);
//顯示頁麵
$builder = new AdminListBuilder();
$builder->title('單點登錄應用列表')->buttonNew(U('editSsoApp'))->setStatusUrl(U('setSsoAppStatus'))->buttonEnable()->buttonDisable()->buttonDelete()->keyId()->keyTitle()->keyText('url', '網站路徑')->keyText('path', 'api目錄')->keyStatus()->keyText('link_status', '連接狀態')->keyDoActionEdit('editSsoApp?id=###')->data($appList)->display();
}
示例10: creatPay
/**
* @param 創建訂單
* @return 加密後的站內訂單編號
* @author lussen <lussen@xingluxin.cn>
*/
public function creatPay()
{
$site_order = time_format(time(), 'YmdHis') . rand(100, 999);
$data['uid'] = is_login();
$data['pay_money'] = I('post.money');
$data['pay_item'] = I('post.pay_item');
$data['site_order'] = $site_order;
$data['isdone'] = 0;
$data['create_time'] = time();
$result = $this->data($data)->add();
if ($result !== false) {
return think_encrypt($site_order);
} else {
return false;
}
}
示例11: ssoList
public function ssoList()
{
//讀取規則列表
$map = array('status' => array('EGT', 0));
$model = D('sso_app');
$appList = $model->where($map)->order('id asc')->select();
foreach ($appList as &$v) {
$url = $v['url'] . '/' . $v['path'] . '?code=' . urlencode(think_encrypt('action=test&time=' . time()));
$arr = $this->check_link($url);
$v['link_status'] = $v['status'] == 1 ? $arr === 'success' ? '<span style="color:green">' . L('_SUCCESS__LINK_') . '</span>' : '<span style="color:red">' . L('_FAIL__LINK_') . '</span>' : '<span style="color:red">' . L('_FAIL__LINK_LIMITED_') . '</span>';
}
unset($v);
//顯示頁麵
$builder = new AdminListBuilder();
$builder->title(L('_SINGLE_POINT_LOGIN_APPLICATION_LIST_'))->buttonNew(U('editSsoApp'))->setStatusUrl(U('setSsoAppStatus'))->buttonEnable()->buttonDisable()->buttonDelete()->keyId()->keyTitle()->keyText('url', L('_WEBSITE_PATH_'))->keyText('path', L('_CATEGORY_API_'))->keyStatus()->keyText('link_status', L('_CONNECTED_STATE_'))->keyDoActionEdit('editSsoApp?id=###')->data($appList)->display();
}
示例12: upload
public function upload()
{
$return = array('status' => 1, 'info' => '上傳成功', 'data' => '');
/* 調用文件上傳組件上傳文件 */
$File = D('File');
$file_driver = C('DOWNLOAD_UPLOAD_DRIVER');
$info = $File->upload($_FILES, C('DOWNLOAD_UPLOAD'), C('DOWNLOAD_UPLOAD_DRIVER'), C("UPLOAD_{$file_driver}_CONFIG"));
/* 記錄附件信息 */
if ($info) {
$return['data'] = think_encrypt(json_encode($info['download']));
} else {
$return['status'] = 0;
$return['info'] = $File->getError();
}
/* 返回JSON數據 */
$this->ajaxReturn($return);
}
示例13: upload
public function upload()
{
//TODO: 用戶登錄檢測
/* 返回標準數據 */
$return = array('status' => 1, 'info' => '上傳成功', 'data' => '');
/* 調用文件上傳組件上傳文件 */
$File = D('File');
$info = $File->upload($_FILES, C('DOWNLOAD_UPLOAD'));
//TODO:上傳到遠程服務器
/* 記錄附件信息 */
if ($info) {
$return['data'] = think_encrypt(json_encode($info['download']));
} else {
$return['status'] = 0;
$return['info'] = $File->getError();
}
/* 返回JSON數據 */
$this->ajaxReturn($return);
}
示例14: addMoney
public function addMoney($moeny, $uid)
{
echo $uid;
$map['uid'] = $uid;
$row = $this->where($map)->find();
if (empty($row['id'])) {
$data['uid'] = $uid;
$data['money'] = think_encrypt($money);
$result = $this->data($data)->add();
} else {
$map['uid'] = $uid;
$data['money'] = think_encrypt(think_decrypt($row['money']) + $moeny);
$result = $this->data($data)->where($map)->save();
if ($result !== false) {
return true;
} else {
return false;
}
}
}
示例15: array_encode
/**
* 數組加密方法
* @param string $data 要加密的字符串
* @param string $key 加密密鑰
* @param int $expire 過期時間 單位 秒
* @return string
* @author 麥當苗兒 <zuojiazi@vip.qq.com>
*/
function array_encode($data, $key = '', $expire = 0)
{
$data = json_encode($data);
return think_encrypt($data, $key, $expire);
}