当前位置: 首页>>代码示例>>PHP>>正文


PHP api函数代码示例

本文整理汇总了PHP中api函数的典型用法代码示例。如果您正苦于以下问题:PHP api函数的具体用法?PHP api怎么用?PHP api使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了api函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: login

 /**
  * 后台用户登录
  *
  * @author Rocks
  */
 public function login($email = null, $password = null, $verify = null)
 {
     if (IS_POST) {
         $Admin = D('AdminAdmin');
         $adminid = $Admin->login($email, $password);
         if (0 < $adminid) {
             $this->success('登录成功!', U('Home/Index/index'));
         } else {
             switch ($adminid) {
                 case -1:
                     $error = '用户不存在或被禁用!';
                     break;
                 case -2:
                     $error = '密码错误!';
                     break;
                 default:
                     $error = '未知错误!';
                     break;
             }
             $this->error($error);
         }
     } else {
         if (is_admin_login()) {
             $this->redirect('Home/Index/index');
         } else {
             $config = S('DB_CONFIG_DATA');
             if (!$config) {
                 $config = api('SystemConfig/lists');
                 S('DB_CONFIG_DATA', $config);
             }
             C($config);
             $this->display();
         }
     }
 }
开发者ID:nullog,项目名称:zhanglubao,代码行数:40,代码来源:LoginController.class.php

示例2: __construct

 /**
  * 架构函数 取得模板对象实例
  * @access public
  */
 public function __construct()
 {
     if (is_file('./Conf/user.php')) {
         //已经安装了
         $moduleModel = D('Common/Module');
         /*读取站点配置*/
         $config = api('Config/lists');
         C($config);
         //添加配置
         $module = $moduleModel->getModule(MODULE_NAME);
         if (strtolower(MODULE_NAME) != 'install' && strtolower(MODULE_NAME) != 'admin') {
             if (!C('WEB_SITE_CLOSE')) {
                 header("Content-Type: text/html; charset=utf-8");
                 exit('站点已经关闭,请稍后访问~');
             }
             if (strtolower(MODULE_NAME) != 'install' && strtolower(MODULE_NAME) != 'admin') {
                 $moduleModel->checkCanVisit(MODULE_NAME);
             }
         }
     }
     Hook::listen('action_begin', $this->config);
     //实例化视图类
     $this->view = Think::instance('Think\\View');
     if (!empty($module)) {
         $this->view->assign('MODULE_INFO', $module);
         $this->view->assign('MODULE_ALIAS', $module['alias']);
     }
     //控制器初始化
     if (method_exists($this, '_initialize')) {
         $this->_initialize();
     }
 }
开发者ID:chenyongze,项目名称:bighaha,代码行数:36,代码来源:Controller.class.php

示例3: _initialize

 protected function _initialize()
 {
     /* 读取站点配置 */
     $config = api('Config/lists');
     C($config);
     //添加配置
     if (!C('WEB_SITE_CLOSE')) {
         $this->error('站点已经关闭,请稍后访问~');
     }
     /**垂直菜单**/
     $category = D('Category')->getCategory();
     $this->assign('category', $category);
     /**购物车**/
     $cart = D('shopcart')->getcart();
     $this->assign('usercart', $cart);
     /* 热门搜索 */
     $str = M('config')->where('id="40"')->getField("value");
     $hotsearch = explode(",", $str);
     $this->assign('hotsearch', $hotsearch);
     /* 广告位 */
     $adData = D('ad')->getlist();
     $this->assign('adData', $adData);
     /**底部菜单**/
     $footer = D('Category')->getfooter();
     $this->assign('footer', $footer);
     /**所在地**/
     if (!session("user_area")) {
         $arr = get_ip_address();
         $area = $arr->city;
     } else {
         $area = session("user_area");
     }
     $this->assign("user_area", $area);
 }
开发者ID:gitchenze,项目名称:soloshop,代码行数:34,代码来源:HomeController.class.php

示例4: edit

 /**
  * 编辑用户资料
  * @author ChenDenlu <530003247@vip.qq.com>
  */
 public function edit($id = 0)
 {
     if (IS_POST) {
         //过滤非编辑字段
         foreach ($_POST as $key => $value) {
             if (!in_array($key, array('nickname', 'cate_group', 'ucpassword', 'id', 'score', 'lastkeyword', 'lastmodel', 'lastclick'))) {
                 unset($_POST[$key]);
             }
         }
         $id = $_POST['id'];
         unset($_POST['id']);
         $updata = array('id' => $id, 'data' => $_POST);
         $info = api('Wxuser/update_info', $updata);
         return false === $info ? $this->error('编辑用户信息失败!') : $this->success('编辑用户信息成功!');
     } else {
         $id = I('id');
         if (empty($id)) {
             $this->error('请选择要查看的用户');
         }
         $info = array();
         $sex = array('0' => '女', '1' => '男');
         /* 获取数据 */
         $info = api('Wxuser/get_info', array('id' => $id));
         $info['sex'] = $sex[$info['sex']];
         $this->assign('info', $info);
         $this->assign('meta_title', '关注者管理');
         $this->display();
     }
 }
开发者ID:wmk223,项目名称:amango_V3,代码行数:33,代码来源:WxuserController.class.php

示例5: _initialize

 protected function _initialize()
 {
     if (!($city = session('user_city'))) {
         // $ip = $_SERVER['REMOTE_ADDR'];
         $ip = '221.2.170.181';
         //开始取得城市信息
         $city = get_city_by_lee_ip($ip);
         //如果有区域参数,则获取区域id
         $city_id = M('district')->where(array('name' => $city))->getField('id');
         //开始取得城市信息  end
         //把城市信息存到session中
         session('user_city', array('city_name' => $city, 'city_id' => $city_id));
         $this->city_name = $city;
         $this->city_id = $city_id;
     } else {
         $this->city_name = $city['city_name'];
         $this->city_id = $city['city_id'];
     }
     if (is_login()) {
         $this->user_info();
     }
     //header("Content-type:text/html;charset=uft-8");
     /*读取站点配置*/
     $config = api('Config/lists');
     C($config);
     //添加配置
     if (!C('WEB_SITE_CLOSE')) {
         $this->error('站点已经关闭,请稍后访问~');
     }
 }
开发者ID:smartymoon,项目名称:fang1001,代码行数:30,代码来源:BaseController.class.php

示例6: initSite

 /**
  * 应用信息初始化
  *
  * @access private
  * @return void
  */
 private function initSite()
 {
     /* 读取数据库中的配置 */
     $config = S('DB_CONFIG_DATA');
     if (!$config) {
         $config = api('Config/lists');
         S('DB_CONFIG_DATA', $config);
     }
     C($config);
     // 添加配置
     // dump($config);
     if (!C('WEB_SITE_CLOSE') && strtolower(MODULE_NAME) != 'admin') {
         $this->error('站点已经关闭,请稍后访问~');
     }
     // 通用表单的控制开关
     $this->assign('add_button', true);
     $this->assign('del_button', true);
     $this->assign('search_button', true);
     $this->assign('check_all', true);
     $this->assign('top_more_button', $this->top_more_button);
     $diff = array('_addons' => 1, '_controller' => 1, '_action' => 1, 'm' => 1, 'id' => 1);
     $GLOBALS['get_param'] = $this->get_param = array_diff_key($_GET, $diff);
     $this->assign('get_param', $this->get_param);
     // js,css的版本
     if (APP_DEBUG) {
         defined('SITE_VERSION') or define('SITE_VERSION', time());
     } else {
         defined('SITE_VERSION') or define('SITE_VERSION', C('SYSTEM_UPDATRE_VERSION'));
     }
     // 版权信息
     $this->assign('system_copy_right', C('COPYRIGHT'));
 }
开发者ID:HivenKay,项目名称:ESalon,代码行数:38,代码来源:Controller.class.php

示例7: _initialize

 protected function _initialize()
 {
     /* 读取站点配置和rewrite信息 */
     $config = api('Config/lists');
     C($config);
     //添加配置
     //加载rewrite
     //$this->loadRewrite();
     $nav = D('Category')->getTree();
     $lists = D('Document')->lists(null);
     $this->assign('nav', $nav);
     //栏目
     $this->assign('lists', $lists);
     //列表
     $this->assign('page', D('Document')->page);
     //分页
     /*幻灯片*/
     $type = M('category as d');
     $slidemap['d.pid'] = 11;
     $slide = $type->where($slidemap)->field('d.id,d.title,a.path')->join('zs_picture as a on d.icon=a.id', 'LEFT')->select();
     $this->assign('slide', $slide);
     // dump($slide); die;
     if (!C('WEB_SITE_CLOSE')) {
         $this->error('站点已经关闭,请稍后访问~');
     }
 }
开发者ID:qhorse,项目名称:thinkphp-zcms,代码行数:26,代码来源:HomeController.class.php

示例8: _initialize

 /**
  * 前台台控制器初始化
  */
 protected function _initialize()
 {
     // plugin('Fangke');
     /* 读取数据库中的配置 */
     $config = F('DB_CONFIG_DATA');
     if (!$config || APP_DEBUG) {
         $config = api('Config/lists');
         F('DB_CONFIG_DATA', $config);
     }
     C($config);
     //添加配置
     C('TMPL_PARSE_STRING', array('__STATIC__' => __ROOT__ . '/Public/Static', '__IMG__' => __ROOT__ . '/Public/' . MODULE_NAME . '/' . C('DEFAULT_THEME') . '/images', '__CSS__' => __ROOT__ . '/Public/' . MODULE_NAME . '/' . C('DEFAULT_THEME') . '/css', '__JS__' => __ROOT__ . '/Public/' . MODULE_NAME . '/' . C('DEFAULT_THEME') . '/js'));
     defined('__DB_PREFIX__') or define('__DB_PREFIX__', C('DB_PREFIX'));
     defined('UID') or define('UID', is_login());
     if (C('WEB_SITE_CLOSE') && UID != 1) {
         $this->show('网站维护中请稍后访问');
         die;
     }
     $str = run_plugin_method('Spider', 'addinfo');
     //var_dump($config);
     if (UID) {
         //登陆的情况
         //赋值当前登陆用户信息
         $uinfo = session('uinfo');
         $map[get_account_type($uinfo['username'])] = $uinfo['username'];
         $jin = __DB_PREFIX__ . "member_group as a on " . __DB_PREFIX__ . "member.member_group_id=a.member_group_id";
         $field = "*," . __DB_PREFIX__ . "member.status as status";
         $user = D('Member')->field($field)->where($map)->join($jin)->find();
         session('uinfo', $user);
         $this->assign('uinfo', $user);
     }
 }
开发者ID:735579768,项目名称:Ainiku,代码行数:35,代码来源:HomeController.class.php

示例9: _initialize

 public function _initialize()
 {
     /* 读取站点配置 */
     $config = api('Config/lists');
     C($config);
     //添加配置
     if (!C('WEB_SITE_CLOSE')) {
         $this->error('站点已经关闭,请稍后访问~');
     }
     // define(WEB_SITE_TITLE, C('WEB_SITE_TITLE'));
     // define(TONGJI, C('TONGJI'));
     C('DEFAULT_THEME', C('HOME_DEFAULT_THEME'));
     define(UID, is_login());
     if (UID) {
         $this->my = D('Member')->info(UID);
         $this->assign('my', $this->my);
     }
     $this->mod = MODULE_NAME;
     $this->act = CONTROLLER_NAME;
     $this->pre = C('DB_PREFIX');
     $this->nav();
     $this->friendlink();
     $this->hotArticle();
     $this->metatags();
     $this->searchkeyword();
     $this->support();
     $this->assign('setting', $this->setting);
     $this->assign('mod', strtolower($this->mod));
     $this->assign('act', strtolower($this->act));
     $this->assign('my', $this->my);
 }
开发者ID:MRdou325,项目名称:lvyou,代码行数:31,代码来源:HomeController.class.php

示例10: init_config

 public function init_config($modulename)
 {
     /* 读取数据库中的配置 */
     $config = S('DB_CONFIG_DATA');
     if (!$config) {
         $config = api('Config/lists');
         S('DB_CONFIG_DATA', $config);
     }
     //添加配置
     C($config);
     $this->init_theme(C('WEB_SITE_THEME'), $modulename);
     if (!C('WEB_SITE_CLOSE')) {
         $this->error('站点已经关闭,请稍后访问~');
     }
     //浏览器参数
     $this->assign('browser_type', session('browser_type'));
     //申明全局变量   默认网站信息
     global $_W;
     $_W = $config;
     $accountmodel = M('Account');
     $map = array();
     $defaultlist = $accountmodel->where(array('account_default' => 'default'))->find();
     $map['account_default'] = array('neq', 'default');
     $otherlist = $accountmodel->where($map)->select();
     //申明全局变量   默认微信公众号信息
     global $_K;
     $_K['DEFAULT'] = $defaultlist;
     $_K['OTHER'] = $otherlist;
     return true;
 }
开发者ID:Luckyseal,项目名称:amango,代码行数:30,代码来源:AmangothemeController.class.php

示例11: initSite

 /**
  * 应用信息初始化
  *
  * @access private
  * @return void
  */
 private function initSite()
 {
     /* 读取数据库中的配置 */
     $config = S('DB_CONFIG_DATA');
     if (!$config) {
         $config = api('Config/lists');
         S('DB_CONFIG_DATA', $config);
     }
     C($config);
     // 添加配置
     if (!C('WEB_SITE_CLOSE') && strtolower(MODULE_NAME) != 'admin') {
         $this->error('站点已经关闭,请稍后访问~');
     }
     // 通用表单的控制开关
     $this->assign('add_button', true);
     $this->assign('del_button', true);
     $this->assign('search_button', true);
     $this->assign('check_all', true);
     // js,css的版本
     if (APP_DEBUG) {
         defined('SITE_VERSION') or define('SITE_VERSION', time());
     } else {
         defined('SITE_VERSION') or define('SITE_VERSION', C('SYSTEM_UPDATRE_VERSION'));
     }
     // 版权信息
     $this->assign('system_copy_right', C('COPYRIGHT'));
 }
开发者ID:pondyond,项目名称:WeiPHP,代码行数:33,代码来源:Controller.class.php

示例12: run

 /**
  * Api 路由器
  *
  * @return api()->response();
  *
  * @author AlpFish 2016/7/24 10:55
  */
 public static function run()
 {
     //获取路径
     $path = ab_path(self::$path);
     if (!file_exists($path)) {
         return api('data')->status(500, '服务器Api目录设置错误')->response();
     }
     //获取method
     if (!request('method') && empty(self::$method)) {
         return api('data')->status(400, '缺少请求参数:method')->response();
     }
     $method = self::get_real_method($path);
     //版本处理
     $v = request('version') ? request('version') : self::$version;
     if (!file_exists($path .= $v . '/')) {
         return api('data')->status(404, 'Api版本不正确')->response();
     }
     //路由寻址
     $method = explode('.', $method);
     $count = count($method);
     for ($i = 0; $i <= $count - 3; $i++) {
         $path .= $method[$i] . '/';
     }
     $controller = $method[$count - 2] . self::$suffix;
     $action = $method[$count - 1];
     if (is_file($file = $path . strtolower($controller . self::$suffix . '.php'))) {
         require_once $file;
         if (class_exists($controller) && method_exists($controller, $action)) {
             $class = new $controller();
             return $class->{$action}();
         }
     }
     return api('data')->status(404, '错误的 api 名称:' . request('method'))->response();
 }
开发者ID:alpfish,项目名称:me,代码行数:41,代码来源:Router.php

示例13: _initialize

 protected function _initialize()
 {
     /* 读取站点配置 */
     $config = api('Config/lists');
     C($config);
     //添加配置
     if (!C('WEB_SITE_CLOSE')) {
         $this->error('站点已经关闭,请稍后访问~');
     }
     $sub_menu = array('left' => array(array('tab' => 'home', 'title' => '首页', 'href' => U('blog/index/index'))));
     $category = D('Category')->getTree();
     $this->assign('categories', $category);
     //栏目
     //dump($category);exit;
     foreach ($category as $cat) {
         if ($cat['_']) {
             $children = array();
             $children[] = array('tab' => 'cat_' . $cat['id'], 'title' => '全部', 'href' => U('blog/article/lists', array('category' => $cat['id'])));
             foreach ($cat['_'] as $child) {
                 $children[] = array('tab' => 'cat_' . $cat['id'], 'title' => $child['title'], 'href' => U('blog/article/lists', array('category' => $child['id'])));
             }
         }
         $menu_item = array('children' => $children, 'tab' => 'cat_' . $cat['id'], 'title' => $cat['title'], 'href' => U('blog/article/lists', array('category' => $cat['id'])));
         $sub_menu['left'][] = $menu_item;
         unset($children);
     }
     $this->assign('sub_menu', $sub_menu);
     $this->setTitle('博客');
 }
开发者ID:yaomoo,项目名称:bbs,代码行数:29,代码来源:BlogController.class.php

示例14: index

 /**
  * 主题管理首页
  */
 public function index($themes_dir = '')
 {
     if (!$themes_dir) {
         $themes_dir = AMANGO_FILE_ROOT . '/Application/Home/' . C('default_v_layer') . '/';
     }
     $dirs = array_map('basename', glob($themes_dir . '*', GLOB_ONLYDIR));
     if ($dirs === FALSE || !file_exists($themes_dir)) {
         $this->error = '插件目录不可读或者不存在';
         return FALSE;
     }
     //读取已有参数
     $WEB_SITE_THEME = M('Config')->where(array('name' => 'WEB_SITE_THEME'))->getField('value');
     $newthemelist = array();
     //过滤非英文字符串
     foreach ($dirs as $key => $value) {
         $tpl_info = array();
         if (preg_match('/[^\\x00-\\x80]/', $value)) {
             unset($dirs[$key]);
         } else {
             $tpl_info = api('System/getThemeinfo', array('themename' => $value, 'config' => ''));
             //基础信息
             $newthemelist[$key] = $tpl_info['INFO'];
             $newthemelist[$key]['config'] = $tpl_info['CONFIG'];
             //使用状态
             if ($value != $WEB_SITE_THEME) {
                 $newthemelist[$key]['uninstall'] = 1;
             }
         }
     }
     $this->assign('meta_title', '主题管理');
     $this->assign('themes', count($newthemelist));
     $this->assign('_list', $newthemelist);
     $this->display();
 }
开发者ID:Luckyseal,项目名称:amango,代码行数:37,代码来源:ThemeController.class.php

示例15: _initialize

 /**
  * 前台台控制器初始化
  */
 protected function _initialize()
 {
     /* 读取数据库中的配置 */
     $config = S('DB_CONFIG_DATA');
     if (!$config || APP_DEBUG) {
         $config = api('Config/lists');
         S('DB_CONFIG_DATA', $config);
     }
     //trace($config);
     C($config);
     //添加配置
     //定义数据表前缀
     defined('DBPREFIX') or define('DBPREFIX', C('DB_PREFIX'));
     defined('__DB_PREFIX__') or define('__DB_PREFIX__', C('DB_PREFIX'));
     C('TMPL_PARSE_STRING', array('__STATIC__' => __ROOT__ . '/Public/Static', '__IMG__' => __ROOT__ . '/Public/' . MODULE_NAME . '/' . C('DEFAULT_THEME') . '/images', '__CSS__' => __ROOT__ . '/Public/' . MODULE_NAME . '/' . C('DEFAULT_THEME') . '/css', '__JS__' => __ROOT__ . '/Public/' . MODULE_NAME . '/' . C('DEFAULT_THEME') . '/js'));
     define('UID', 1);
     //过滤掉支付接口的异步通知url
     if (CONTROLLER_NAME != 'Buy' && ACTION_NAME != 'dopayok') {
         defined('UID') or define('UID', auto_login());
         if (!UID) {
             //没有登陆的情况
             if (IS_AJAX) {
                 $this->error($this->fetch('Public/ajaxlogin'));
             } else {
                 redirect(U('Public/login'));
             }
         } else {
             //赋值当前登陆用户信息
             $map['member_id'] = UID;
             $user = D('MemberView')->where($map)->find();
             $this->uinfo = $user;
         }
     }
 }
开发者ID:735579768,项目名称:Ainiku,代码行数:37,代码来源:LoginController.class.php


注:本文中的api函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。