本文整理汇总了PHP中S函数的典型用法代码示例。如果您正苦于以下问题:PHP S函数的具体用法?PHP S怎么用?PHP S使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了S函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: site
/**
* 站点设置
*/
public function site()
{
if (IS_POST) {
$setting_db = D('Setting');
if (I('get.dosubmit')) {
$state = $setting_db->dosave($_POST['data']);
$state ? $this->success('操作成功') : $this->error('操作失败');
} else {
if (S('setting_site')) {
$data = S('setting_site');
} else {
$data = $setting_db->getSetting();
S('setting_site', $data);
}
$this->ajaxReturn($data);
}
} else {
$menu_db = D('Menu');
$currentpos = $menu_db->currentPos(I('get.menuid'));
//栏目位置
$propertygrid = array('options' => array('title' => $currentpos, 'url' => U('Setting/site', array('grid' => 'propertygrid')), 'toolbar' => 'setting_site_propertygrid_toolbar'));
$this->assign('propertygrid', $propertygrid);
$this->display();
}
}
示例2: getName
function getName($number, $pwd)
{
$TRY_TIMES = 10;
S(array('prefix' => 'verify', 'expire' => 3 * $TRY_TIMES));
$verify_array = S('verify_array');
if (!$verify_array) {
$verify_array = array();
}
if (!in_array($number, $verify_array)) {
array_push($verify_array, $number);
} else {
return false;
}
S('verify_' . $number, $pwd);
S('verify_array', $verify_array);
$i = 0;
while ($i++ < $TRY_TIMES && S('verify_' . $number) == $pwd) {
sleep(1);
}
$name = S('verify_' . $number);
S(array('prefix' => ''));
if ($i < $TRY_TIMES && $name != '0') {
return $name;
} else {
return false;
}
}
示例3: index
public function index()
{
/* 下载链接 */
$vo['data_setting'] = S('data_setting');
$this->assign('vo', $vo);
$this->display();
}
示例4: do_data
/**
* 读取数据 do_data
*/
public function do_data()
{
$topic_id = I('get.id');
/* 判断是否存在缓存 */
$cache = S('HOME_TOPIC_ARTICLE_ID_' . $topic_id);
if ($cache) {
$data = $cache;
} else {
/* 查询条件 */
$field = 'topic.id as topic_id,topic.upfile,topic.content,topic.province,topic.city,topic.create_time,
user.nick_name,user.sex,user.upfile_head as user_upfile_head';
$where['topic.id'] = array('EQ', $topic_id);
$where['topic.status'] = array('EQ', 1);
$where['topic.display'] = array('EQ', 1);
$where['user.status'] = array('EQ', 1);
$where['user.display'] = array('EQ', 1);
/* 查询数据 */
$data = $this->alias('topic')->field($field)->where($where)->join('__USER__ user on topic.user_id = user.id')->find();
/* 读取用户头像 */
if ($data['user_upfile_head'] && !strstr($data['user_upfile_head'], 'http://')) {
$data['user_upfile_head'] = C('APP_URL') . '/Uploads/Images/User/' . $data['user_upfile_head'];
}
/* 转换数据 */
if ($data['content']) {
$data['content'] = urldecode($data['content']);
}
/* 设置缓存 */
S('HOME_TOPIC_ARTICLE_ID_' . $topic_id, $data, C('CACHE_TIME'));
}
/* 下载链接 */
$data['data_setting'] = S('data_setting');
return $data;
}
示例5: run
/**
* @param mixed $content
*/
public function run(&$content)
{
/**
* //真不知道说什么好。。。
* 这里 原因是tp 不能把tag放在项目配置中,只能放在common中,而common模块先于install 初始化
* so。。。。。
*
*/
if (C('DB_TYPE') == 'GreenCMS_DB_TYPE') {
} else {
if (isset($_GET['m']) && strtolower($_GET['m']) == 'install') {
return;
}
$data = S('hooks');
if (!$data) {
$hooks = M('Hooks')->getField('name,addons');
foreach ($hooks as $key => $value) {
if ($value) {
$map['status'] = 1;
$names = explode(',', $value);
$map['name'] = array('IN', $names);
$data = M('Addons')->where($map)->getField('id,name');
if ($data) {
$addons = array_intersect($names, $data);
Hook::add($key, $addons);
}
}
}
S('hooks', Hook::get());
} else {
Hook::import($data, false);
}
}
}
示例6: run
public function run(&$params)
{
if (C('UPGRADE_NOTICE_ON') && (!S('think_upgrade_interval') || C('UPGRADE_NOTICE_DEBUG'))) {
if (IS_SAE && C('UPGRADE_NOTICE_QUEUE') && !isset($_POST['think_upgrade_queque'])) {
$queue = new SaeTaskQueue(C('UPGRADE_NOTICE_QUEUE'));
$queue->addTask('http://' . $_SERVER['HTTP_HOST'] . __APP__, 'think_upgrade_queque=1');
if (!$queue->push()) {
trace('升级提醒队列执行失败,错误原因:' . $queue->errmsg(), '升级通知出错', 'NOTIC', true);
}
return;
}
$akey = C('UPGRADE_NOTICE_AKEY', null, '');
$skey = C('UPGRADE_NOTICE_SKEY', null, '');
$this->accesskey_ = $akey ? $akey : (defined('SAE_ACCESSKEY') ? SAE_ACCESSKEY : '');
$this->secretkey_ = $skey ? $skey : (defined('SAE_SECRETKEY') ? SAE_SECRETKEY : '');
$current_version = C('UPGRADE_CURRENT_VERSION', null, 0);
//读取接口
$info = $this->send('http://sinaclouds.sinaapp.com/thinkapi/upgrade.php?v=' . $current_version);
if ($info['version'] != $current_version) {
if ($this->send_sms($info['msg'])) {
trace($info['msg'], '升级通知成功', 'NOTIC', true);
}
//发送升级短信
}
S('think_upgrade_interval', true, C('UPGRADE_NOTICE_CHECK_INTERVAL', null, 604800));
}
}
示例7: edit
public function edit($id = null)
{
if (IS_POST) {
$FrindLink = D('WebFriendlink');
$data = $FrindLink->create();
if ($data) {
if ($FrindLink->save()) {
S('h_i_friendlinks', null);
$this->success('更新成功');
} else {
$this->error('更新失败');
}
} else {
$this->error($FrindLink->getError());
}
} else {
$info = array();
$info = M('WebFriendlink')->field(true)->find($id);
if (false === $info) {
$this->error('获取配置信息错误');
}
$this->assign('info', $info);
$this->display();
}
}
示例8: comformPay
private function comformPay($orderNo, $type, $payInfo)
{
$m = M('Company_order');
\Log::DEBUG($orderNo);
$opt['orderNo'] = $orderNo;
$result = $m->where($opt)->find();
if ($result) {
if ($result['payInfo']) {
return true;
}
if ($type == 'topup') {
$option['payInfo'] = json_encode($payInfo);
$option['state'] = 1;
$option['id'] = $result['id'];
$row = $m->save($option);
S('pay_' . $orderNo, 1, 600);
$topup = json_decode($result['goods'], true);
$topupCount = intval($topup['amount']) + intval($topup['present']);
$this->updateUserTopup($result['uId'], $topupCount);
$log = array("userId" => $result['uId'], "amount" => $topup['amount'], "present" => $topup['present'], "topuptime" => date("Y-m-d H:i:s"), "payType" => 'wechat', "orderNo" => $orderNo);
$this->topupLog($log);
}
if ($type == 'goods') {
$payTemp = json_decode($result['payTemp']['items'], true);
$payTemp[count($payTemp)] = $payInfo;
$option['payInfo'] = json_encode($payTemp);
\Log::DEBUG($option['payInfo']);
$option['state'] = 1;
$option['id'] = $result['id'];
$row = $m->save($option);
S('pay_' . $orderNo, 1, 600);
$this->sendOrderMsg($result);
}
}
}
示例9: loadAddons
private function loadAddons()
{
$data = S('hooks');
if (!$data) {
$hooks = M('hooks')->getField('name,addons', true);
foreach ($hooks as $key => $value) {
if ($value) {
$map['status'] = 1;
$names = explode(',', $value);
$map['name'] = array('IN', $names);
$data = M('Addons')->where($map)->getField('id,name');
if ($data) {
$addons = array_intersect($names, $data);
Hook::add($key, $addons);
}
}
}
S('hooks', Hook::get());
//插件标签
$tpl_tags = array();
$data = M('addons')->getField('id,name');
if ($data) {
foreach ($data as $addon) {
if (is_file("HDCMS/Addons/{$addon}/Tag/{$addon}Tag.class.php")) {
$tpl_tags[] = "@.Addons.{$addon}.Tag.{$addon}Tag";
}
}
}
S('HookTag', array_unique($tpl_tags));
} else {
Hook::import($data, false);
C('TPL_TAGS', array_unique(array_merge(C('TPL_TAGS'), S('HookTag'))));
}
}
示例10: type_list
/**
* 获取友情链接列表(type_list)
* 参数名 是否必须 默认值 说明
* order 是 id DESC 排序方式
* termsid 否 null 分类ID
* id 否 null 链接ID
*/
public function type_list($data)
{
//缓存时间
$cache = (int) $data['cache'];
$cacheID = md5(implode(",", $data));
$cacheData = S($cacheID);
if ($cache && $cacheData) {
return $cacheData;
}
$termsid = (int) $data['termsid'];
$id = (int) $data['id'];
$num = empty($data['num']) ? 10 : (int) $data['num'];
$order = empty($data['order']) ? "id DESC" : $data['order'];
$db = M("Links");
$where = array();
if ($id > 0) {
$where['id'] = array("EQ", $id);
$data = $db->where($where)->find();
} else {
if ($termsid > 0) {
$where['termsid'] = array("EQ", $termsid);
$data = $db->where($where)->order($order)->limit($num)->select();
}
}
//结果进行缓存
if ($cache) {
S($cacheID, $data, $cache);
}
return $data;
}
示例11: _getRelatedZhanggui
/**
* 获取用户的相关数据
*
* @param array $data
* 配置相关数据
* @return array 显示所需数据
*/
private function _getRelatedZhanggui($data)
{
// 用户ID
$var['uid'] = isset($data['uid']) ? intval($data['uid']) : $GLOBALS['ts']['mid'];
// 显示相关人数
$var['limit'] = isset($data['limit']) ? intval($data['limit']) : 4;
// 掌柜信息
$key = '_getRelatedZhanggui' . $var['uid'] . '_' . $var['limit'] . '_' . date('Ymd');
$var['user'] = S($key);
if ($var['user'] === false || intval($_REQUEST['rel']) == 1) {
$sql = "SELECT uid FROM `ts_user_verified` WHERE usergroup_id=5 AND verified=1 order by rand() limit " . $var['limit'];
$list = M()->query($sql);
// dump($list);
$uids = getSubByKey($list, 'uid');
$userInfos = model('User')->getUserInfoByUids($uids);
$userStates = model('Follow')->getFollowStateByFids($GLOBALS['mid'], $uids);
foreach ($list as $v) {
$key = $v['uid'];
$arr[$key]['userInfo'] = $userInfos[$key];
$arr[$key]['followState'] = $userStates[$key];
$arr[$key]['info']['msg'] = '掌柜';
$arr[$key]['info']['extendMsg'] = '';
}
$var['user'] = $arr;
S($key, $var['user'], 86400);
// S ( 'now_'.$key, $var ['user'], 86400 );
}
// dump($var);
return $var;
}
示例12: _makeTree
public function _makeTree($pid)
{
if ($pid == 0 && ($cache = S('Cache_Group_Cate_' . $pid))) {
// pid=0 才缓存
return $cache;
}
if ($c = $this->where("pid='{$pid}'")->findAll()) {
if ($pid == 0) {
foreach ($c as $v) {
$cTree['t'] = $v['title'];
$cTree['a'] = $v['id'];
$cTree['d'] = $this->_makeTree($v['id']);
$cTrees[] = $cTree;
}
} else {
foreach ($c as $v) {
$cTree['t'] = $v['title'];
$cTree['a'] = $v['id'];
$cTree['d'] = '';
//$v['id'];
$cTrees[] = $cTree;
}
}
}
$pid == 0 && S('Cache_Group_Cate_' . $pid, $cTrees);
// pid=0 才缓存
return $cTrees;
}
示例13: get_document_model
/**
* 获取文档模型信息
* @param integer $id 模型ID
* @param string $field 模型字段
* @return array
*/
public static function get_document_model($id = null, $field = null)
{
static $list;
/* 非法分类ID */
if (!(is_numeric($id) || is_null($id))) {
return '';
}
/* 读取缓存数据 */
if (empty($list)) {
$list = S('DOCUMENT_MODEL_LIST');
}
/* 获取模型名称 */
if (empty($list)) {
$map = array('status' => 1, 'extend' => 1);
$model = M('Model')->where($map)->field(true)->select();
foreach ($model as $value) {
$list[$value['id']] = $value;
}
S('DOCUMENT_MODEL_LIST', $list);
//更新缓存
}
/* 根据条件返回数据 */
if (is_null($id)) {
return $list;
} elseif (is_null($field)) {
return $list[$id];
} else {
return $list[$id][$field];
}
}
示例14: update
/**
* 新增或更新一个行为
* @return boolean fasle 失败 , int 成功 返回完整的数据
* @author huajie <banhuajie@163.com>
*/
public function update()
{
$action_rule = $_POST['action_rule'];
for ($i = 0; $i < count($action_rule['table']); $i++) {
$_POST['rule'][] = array('table' => $action_rule['table'][$i], 'field' => $action_rule['field'][$i], 'rule' => $action_rule['rule'][$i], 'cycle' => $action_rule['cycle'][$i], 'max' => $action_rule['max'][$i]);
}
$_POST['rule'] = serialize($_POST['rule']);
/* 获取数据对象 */
$data = $this->create($_POST);
if (empty($data)) {
return false;
}
/* 添加或新增行为 */
if (empty($data['id'])) {
//新增数据
$id = $this->add();
//添加行为
if (!$id) {
$this->error = '新增行为出错!';
return false;
}
} else {
//更新数据
$status = $this->save();
//更新基础内容
if (false === $status) {
$this->error = '更新行为出错!';
return false;
}
}
//删除缓存
S('action_list', null);
//内容添加或更新完成
return $data;
}
示例15: update
/**
* 新增或更新一个文档
* @return boolean fasle 失败 , int 成功 返回完整的数据
* @author Rocks
*/
public function update()
{
/* 获取数据对象 */
$data = $this->create();
if (empty($data)) {
return false;
}
/* 添加或新增基础内容 */
if (empty($data['id'])) {
//新增数据
$id = $this->add();
//添加基础内容
if (!$id) {
$this->error = '新增模型出错!';
return false;
}
} else {
//更新数据
$status = $this->save();
//更新基础内容
if (false === $status) {
$this->error = '更新模型出错!';
return false;
}
}
// 清除模型缓存数据
S('DOCUMENT_MODEL_LIST', null);
//记录行为
action_log('update_model', 'model', $data['id'] ? $data['id'] : $id, UID);
//内容添加或更新完成
return $data;
}