maccms对接安卓app

1、首先确保你是maccmsv10

2、在application——api——controller——provide.php中加入以下代码

//获取开放类型 选项卡 新增代码 
public function getTypes()
{ 
$cursor= Db::name('type')->where('type_status','in',[1])->where('type_id','in',[1,2,3,4,20,21])->order('type_sort')->select(); echo json_encode($cursor,JSON_UNESCAPED_UNICODE); 
}

//获取轮播图 //新增代码 
public function getlunbo() 
{ 
$cursor= Db::name('vod')->where('vod_level','in',[9])->select(); echo json_encode($cursor,JSON_UNESCAPED_UNICODE);

} 
//登录 新增代码 
public function login($uname,$pwd) 
{
 $cursor= Db::name('user')->where('user_name',$uname)->where('user_pwd',$pwd)->select(); echo json_encode($cursor,JSON_UNESCAPED_UNICODE);

}

3、在application——api——controller——provide.php——vod中修改以下代码 

//修改代码将此段代码移至上面 
$order = 'vod_time desc'; $field = 'vod_id,vod_name,type_id,"" as type_name,vod_en,vod_time,vod_remarks,vod_play_from,vod_time';

 4、也可直接将在application——api——controller——provide.php中的全部代码替换(源码在后面)

 5、打开视频跟文章api

6、下载前端代码 对接maccms安卓app - DCloud 插件市场

7、进入项目修改common——api——reques.js——baseUrl项

8、本示例仅供学习参考,不得从事任何非法活动,出现任何问题自行承担!

9、 application——api——controller——provide.php源码

<?php
namespace app\api\controller;

use app\api\controller\v1\Vod;
use think\Controller;
use think\Cache;
use think\Db;

class Provide extends Base
{
    var $_param;

    public function __construct()
    {
        parent::__construct();
        $this->_param = input('', '', 'trim,urldecode');
    }

    public function index()
    {

    }
    //获取视频类型开始
    public function getType($type)
    {
        
//电影
if($type==1){
    $cursor= Db::name('vod')->where('type_id','in',[6,7,8,9,10,11,12])->select();
    echo json_encode($cursor,JSON_UNESCAPED_UNICODE);
}
//电视剧
else if($type==2){

    $cursor= Db::name('vod')->where('type_id','in',[2,13,14,15,16])->select();
    echo json_encode($cursor,JSON_UNESCAPED_UNICODE);
}
//综艺
else if($type==3){

    $cursor= Db::name('vod')->where('type_id','in',[3])->select();
    echo json_encode($cursor,JSON_UNESCAPED_UNICODE);
}
//动漫
else if($type==4){

    $cursor= Db::name('vod')->where('type_id','in',[4])->select();
    echo json_encode($cursor,JSON_UNESCAPED_UNICODE);
}

    }
    //获取视频类型结束

//获取开放类型  选项卡   新增代码
public function getTypes(){
    $cursor= Db::name('type')->where('type_status','in',[1])->where('type_id','in',[1,2,3,4,20,21])->order('type_sort')->select();
    echo json_encode($cursor,JSON_UNESCAPED_UNICODE);
}



//获取轮播图 //新增代码
public function getlunbo()
{
    $cursor= Db::name('vod')->where('vod_level','in',[9])->select();
    echo json_encode($cursor,JSON_UNESCAPED_UNICODE);

}

//登录  新增代码
public function login($uname,$pwd)
{
    $cursor= Db::name('user')->where('user_name',$uname)->where('user_pwd',$pwd)->select();
    echo json_encode($cursor,JSON_UNESCAPED_UNICODE);

}





    public function vod()
    {
        if ($GLOBALS['config']['api']['vod']['status'] != 1) {
            echo 'closed';
            exit;
        }

        if ($GLOBALS['config']['api']['vod']['charge'] == 1) {
            $h = $_SERVER['REMOTE_ADDR'];
            if (!$h) {
                echo lang('api/auth_err');
                exit;
            } else {
                $auth = $GLOBALS['config']['api']['vod']['auth'];
                $auths = array();
                if (!empty($auth)) {
                    $auths = explode('#', $auth);
                    foreach ($auths as $k => $v) {
                        $auths[$k] = gethostbyname(trim($v));
                    }
                }
                if ($h != 'localhost' && $h != '127.0.0.1') {
                    if (!in_array($h, $auths)) {
                        echo lang('api/auth_err');
                        exit;
                    }
                }
            }
        }

        //修改代码将代码移至上面
        $order = 'vod_time desc';
        $field = 'vod_id,vod_name,type_id,"" as type_name,vod_en,vod_time,vod_remarks,vod_play_from,vod_time';
        //修改代码将代码移至上面结束
        $cache_time = intval($GLOBALS['config']['api']['vod']['cachetime']);
        $cach_name = $GLOBALS['config']['app']['cache_flag'] . '_' . 'api_vod_' . md5(http_build_query($this->_param));
        $html = Cache::get($cach_name);
        if (empty($html) || $cache_time == 0) {
            $where = [];
            //根据vod_id进行查找
            if (!empty($this->_param['ids'])) {
                $where['vod_id'] = ['in', $this->_param['ids']];
            }

            if (!empty($GLOBALS['config']['api']['vod']['typefilter'])) {
                $where['type_id'] = ['in', $GLOBALS['config']['api']['vod']['typefilter']];
            }
            //根据type_id进行视频分类查找
            if (!empty($this->_param['t'])) {
                if (empty($GLOBALS['config']['api']['vod']['typefilter']) || strpos($GLOBALS['config']['api']['vod']['typefilter'], $this->_param['t']) !== false) {
                    $where['type_id'] = ['in',$this->_param['t']];//代码加入in
                }
            }
            if (!empty($this->_param['h'])) {
                $todaydate = date('Y-m-d', strtotime('+1 days'));
                $tommdate = date('Y-m-d H:i:s', strtotime('-' . $this->_param['h'] . ' hours'));

                $todayunix = strtotime($todaydate);
                $tommunix = strtotime($tommdate);

                $where['vod_time'] = [['gt', $tommunix], ['lt', $todayunix]];
            }
            //根据视频名字模糊查找
            if (!empty($this->_param['wd'])) {
                //修改代码将代码加入代码
                $field = '*';
                $where['vod_name'] = ['like', '%' . $this->_param['wd'] . '%'];
            }
            //根据播放器名称模糊查找
            if (empty($GLOBALS['config']['api']['vod']['from']) && !empty($this->_param['from'])) {
                $GLOBALS['config']['api']['vod']['from'] = $this->_param['from'];
            }
            if (!empty($GLOBALS['config']['api']['vod']['from'])) {
                $where['vod_play_from'] = ['like', '%' . $GLOBALS['config']['api']['vod']['from'] . '%'];
            }

            if (!empty($GLOBALS['config']['api']['vod']['datafilter'])) {
                $where['_string'] .= ' ' . $GLOBALS['config']['api']['vod']['datafilter'];
            }
            if (empty($this->_param['pg'])) {
                $this->_param['pg'] = 1;
            }
            //查询视频详情
           

            if ($this->_param['ac'] == 'videolist' || $this->_param['ac'] == 'detail') {
                $field = '*';
            }
            $res = model('vod')->listData($where, $order, $this->_param['pg'], $GLOBALS['config']['api']['vod']['pagesize'], 0, $field, 0);

            if ($this->_param['at'] == 'xml') {
                $html = $this->vod_xml($res);
            } else {
                $html = json_encode($this->vod_json($res), JSON_UNESCAPED_UNICODE);
            }

            if ($cache_time > 0) {
                Cache::set($cach_name, $html, $cache_time);
            }
        }
        echo $html;
        exit;
    }

    public function vod_url_deal($urls, $froms, $from, $flag)
    {
        $res_xml = '';
        $res_json = [];
        $arr1 = explode("$$$", $urls);
        $arr1count = count($arr1);//有几个播放线路
        $arr2 = explode("$$$", $froms);
        $arr2count = count($arr2);//有几个播放器
        for ($i = 0; $i < $arr2count; $i++) {
            if ($arr1count >= $i) {
                if ($from != '') {
                    if ($arr2[$i] == $from) {
                        $res_xml .= '<dd flag="' . $arr2[$i] . '"><![CDATA[' . $arr1[$i] . ']]></dd>';
                        $res_json[$arr2[$i]] = $arr1[$i];
                    }
                } else {
                    $res_xml .= '<dd flag="' . $arr2[$i] . '"><![CDATA[' . $arr1[$i] . ']]></dd>';
                    $res_json[$arr2[$i]] = $arr1[$i];
                }
            }
        }
        $res = str_replace(array(chr(10), chr(13)), array('', '#'), $res_xml);
        return $flag == 'xml' ? $res_xml : $res_json;
    }

    public function vod_json($res)
    {
        $type_list = model('Type')->getCache('type_list');
        foreach ($res['list'] as $k => &$v) {
            $type_info = $type_list[$v['type_id']];
            $v['type_name'] = $type_info['type_name'];
            $v['vod_time'] = date('Y-m-d H:i:s', $v['vod_time']);

            if (substr($v["vod_pic"], 0, 4) == "mac:") {
                $v["vod_pic"] = str_replace('mac:', 'http:', $v["vod_pic"]);
            } elseif (!empty($v["vod_pic"]) && substr($v["vod_pic"], 0, 4) != "http" && substr($v["vod_pic"], 0, 2) != "//") {
                $v["vod_pic"] = $GLOBALS['config']['api']['vod']['imgurl'] . $v["vod_pic"];
            }

            if ($this->_param['ac'] == 'videolist' || $this->_param['ac'] == 'detail') {
                if ($GLOBALS['config']['api']['vod']['from'] != '') {
                    $arr_from = explode('$$$', $v['vod_play_from']);
                    $arr_url = explode('$$$', $v['vod_play_url']);
                    $arr_server = explode('$$$', $v['vod_play_server']);
                    $arr_note = explode('$$$', $v['vod_play_note']);

                    $key = array_search($GLOBALS['config']['api']['vod']['from'], $arr_from);
                    $res['list'][$k]['vod_play_from'] = $GLOBALS['config']['api']['vod']['from'];
                    $res['list'][$k]['vod_play_url'] = $arr_url[$key];
                    $res['list'][$k]['vod_play_server'] = $arr_server[$key];
                    $res['list'][$k]['vod_play_note'] = $arr_note[$key];

                }

            } else {
                if ($GLOBALS['config']['api']['vod']['from'] != '') {
                    $res['list'][$k]['vod_play_from'] = $GLOBALS['config']['api']['vod']['from'];
                } else {
                    $res['list'][$k]['vod_play_from'] = str_replace('$$$', ',', $v['vod_play_from']);
                }
            }
        }


        if ($this->_param['ac'] != 'videolist' && $this->_param['ac'] != 'detail') {
            $class = [];
            $typefilter = explode(',', $GLOBALS['config']['api']['vod']['typefilter']);

            foreach ($type_list as $k => &$v) {

                if (!empty($GLOBALS['config']['api']['vod']['typefilter'])) {
                    if (in_array($v['type_id'], $typefilter)) {
                        $class[] = ['type_id' => $v['type_id'], 'type_name' => $v['type_name']];
                    }
                } else {
                    $class[] = ['type_id' => $v['type_id'], 'type_name' => $v['type_name']];
                }
            }
            $res['class'] = $class;
        }
        return $res;
    }

    public function vod_xml($res)
    {
        $xml = '<?xml version="1.0" encoding="utf-8"?>';
        $xml .= '<rss version="5.1">';
        $type_list = model('Type')->getCache('type_list');

        //视频列表开始
        $xml .= '<list page="' . $res['page'] . '" pagecount="' . $res['pagecount'] . '" pagesize="' . $res['limit'] . '" recordcount="' . $res['total'] . '">';
        foreach ($res['list'] as $k => &$v) {
            $type_info = $type_list[$v['type_id']];
            $xml .= '<video>';
            $xml .= '<last>' . date('Y-m-d H:i:s', $v['vod_time']) . '</last>';
            $xml .= '<id>' . $v['vod_id'] . '</id>';
            $xml .= '<tid>' . $v['type_id'] . '</tid>';
            $xml .= '<name><![CDATA[' . $v['vod_name'] . ']]></name>';
            $xml .= '<type>' . $type_info['type_name'] . '</type>';
            if (substr($v["vod_pic"], 0, 4) == "mac:") {
                $v["vod_pic"] = str_replace('mac:', 'http:', $v["vod_pic"]);
            } elseif (!empty($v["vod_pic"]) && substr($v["vod_pic"], 0, 4) != "http" && substr($v["vod_pic"], 0, 2) != "//") {
                $v["vod_pic"] = $GLOBALS['config']['api']['vod']['imgurl'] . $v["vod_pic"];
            }

            if ($this->_param['ac'] == 'videolist' || $this->_param['ac'] == 'detail') {
                $tempurl = $this->vod_url_deal($v["vod_play_url"], $v["vod_play_from"], $GLOBALS['config']['api']['vod']['from'], 'xml');

                $xml .= '<pic>' . $v["vod_pic"] . '</pic>';
                $xml .= '<lang>' . $v['vod_lang'] . '</lang>';
                $xml .= '<area>' . $v['vod_area'] . '</area>';
                $xml .= '<year>' . $v['vod_year'] . '</year>';
                $xml .= '<state>' . $v['vod_serial'] . '</state>';
                $xml .= '<note><![CDATA[' . $v['vod_remarks'] . ']]></note>';
                $xml .= '<actor><![CDATA[' . $v['vod_actor'] . ']]></actor>';
                $xml .= '<director><![CDATA[' . $v['vod_director'] . ']]></director>';
                $xml .= '<dl>' . $tempurl . '</dl>';
                $xml .= '<des><![CDATA[' . $v['vod_content'] . ']]></des>';
            } else {
                if ($GLOBALS['config']['api']['vod']['from'] != '') {
                    $xml .= '<dt>' . $GLOBALS['config']['api']['vod']['from'] . '</dt>';
                } else {
                    $xml .= '<dt>' . str_replace('$$$', ',', $v['vod_play_from']) . '</dt>';
                }
                $xml .= '<note><![CDATA[' . $v['vod_remarks'] . ']]></note>';
            }
            $xml .= '</video>';
        }
        $xml .= '</list>';

        //视频列表结束

        if ($this->_param['ac'] != 'videolist' && $this->_param['ac'] != 'detail') {
            //分类列表开始
            $xml .= "<class>";
            $typefilter = explode(',', $GLOBALS['config']['api']['vod']['typefilter']);
            foreach ($type_list as $k => &$v) {
                if ($v['type_mid'] == 1) {
                    if (!empty($GLOBALS['config']['api']['vod']['typefilter'])) {
                        if (in_array($v['type_id'], $typefilter)) {
                            $xml .= "<ty id=\"" . $v["type_id"] . "\">" . $v["type_name"] . "</ty>";
                        }
                    } else {
                        $xml .= "<ty id=\"" . $v["type_id"] . "\">" . $v["type_name"] . "</ty>";
                    }
                }
            }
            unset($rs);
            $xml .= "</class>";
            //分类列表结束

        }
        $xml .= "</rss>";
        return $xml;
    }

    public function art()
    {
        if ($GLOBALS['config']['api']['art']['status'] != 1) {
            echo 'closed';
            die;
        }

        if ($GLOBALS['config']['api']['art']['charge'] == 1) {
            $h = $_SERVER['REMOTE_ADDR'];
            if (!$h) {
                echo lang('api/auth_err');
                exit;
            } else {
                $auth = $GLOBALS['config']['api']['art']['auth'];
                $auths = array();
                if (!empty($auth)) {
                    $auths = explode('#', $auth);
                    foreach ($auths as $k => $v) {
                        $auths[$k] = gethostbyname(trim($v));
                    }
                }
                if ($h != 'localhost' && $h != '127.0.0.1') {
                    if (!in_array($h, $auths)) {
                        echo lang('api/auth_err');
                        exit;
                    }
                }
            }
        }
        //移至上面
        $order = 'art_time desc';
        $field = 'art_id,art_name,type_id,"" as type_name,art_en,art_time,art_author,art_from,art_remarks,art_pic,art_time';
        $cache_time = intval($GLOBALS['config']['api']['art']['cachetime']);
        $cach_name = $GLOBALS['config']['app']['cache_flag'] . '_' . 'api_art_' . md5(http_build_query($this->_param));
        $html = Cache::get($cach_name);
        if (empty($html) || $cache_time == 0) {
            $where = [];
            if (!empty($this->_param['ids'])) {
                $where['art_id'] = ['in', $this->_param['ids']];
            }
            if (!empty($this->_param['t'])) {
                if (empty($GLOBALS['config']['api']['art']['typefilter']) || strpos($GLOBALS['config']['api']['art']['typefilter'], $this->_param['t']) !== false) {
                    $field = 'art_id,art_name,type_id,"" as type_name,art_en,art_time,art_author,art_from,art_remarks,art_pic,art_time,art_content';
                    $where['type_id'] = $this->_param['t'];
                }
            }

            if (!empty(intval($this->_param['h']))) {
                $todaydate = date('Y-m-d', strtotime('+1 days'));
                $tommdate = date('Y-m-d', strtotime('-' . $this->_param['h'] . ' hours'));

                $todayunix = strtotime($todaydate);
                $tommunix = strtotime($tommdate);

                $where['art_time'] = [['gt', $tommunix], ['lt', $todayunix]];
            }
            if (!empty($this->_param['wd'])) {
                $where['art_name'] = ['like', '%' . $this->_param['wd'] . '%'];
            }
            if (!empty($GLOBALS['config']['api']['art']['datafilter'])) {
                $where['_string'] = $GLOBALS['config']['api']['art']['datafilter'];
            }
            if (empty(intval($this->_param['pg']))) {
                $this->_param['pg'] = 1;
            }

           

            if ($this->_param['ac'] == 'detail') {
                $field = '*';
            }

            $res = model('art')->listData($where, $order, $this->_param['pg'], $GLOBALS['config']['api']['art']['pagesize'], 0, $field, 0);

            if ($res['code'] > 1) {
                echo $res['msg'];
                exit;
            }

            $type_list = model('Type')->getCache('type_list');
            foreach ($res['list'] as $k => &$v) {
                $type_info = $type_list[$v['type_id']];
                $v['type_name'] = $type_info['type_name'];
                $v['art_time'] = date('Y-m-d H:i:s', $v['art_time']);

                if (substr($v["art_pic"], 0, 4) == "mac:") {
                    $v["art_pic"] = str_replace('mac:', 'http:', $v["art_pic"]);
                } elseif (!empty($v["art_pic"]) && substr($v["art_pic"], 0, 4) != "http" && substr($v["art_pic"], 0, 2) != "//") {
                    $v["art_pic"] = $GLOBALS['config']['api']['art']['imgurl'] . $v["art_pic"];
                }

                if ($this->_param['ac'] == 'detail') {

                } else {

                }
            }

            if ($this->_param['ac'] != 'detail') {
                $class = [];
                $typefilter = explode(',', $GLOBALS['config']['api']['art']['typefilter']);

                foreach ($type_list as $k => &$v) {
                    if ($v['type_mid'] == 2) {

                        if (!empty($GLOBALS['config']['api']['art']['typefilter'])) {
                            if (in_array($v['type_id'], $typefilter)) {
                                $class[] = ['type_id' => $v['type_id'], 'type_name' => $v['type_name']];
                            }
                        } else {
                            $class[] = ['type_id' => $v['type_id'], 'type_name' => $v['type_name']];
                        }
                    }
                }
                $res['class'] = $class;
            }
            $html = json_encode($res, JSON_UNESCAPED_UNICODE);

            if ($cache_time > 0) {
                Cache::set($cach_name, $html, $cache_time);
            }
        }
        echo $html;
        exit;
    }

    public function actor()
    {
        if ($GLOBALS['config']['api']['actor']['status'] != 1) {
            echo 'closed';
            die;
        }

        if ($GLOBALS['config']['api']['actor']['charge'] == 1) {
            $h = $_SERVER['REMOTE_ADDR'];
            if (!$h) {
                echo lang('api/auth_err');
                exit;
            } else {
                $auth = $GLOBALS['config']['api']['actor']['auth'];
                $auths = array();
                if (!empty($auth)) {
                    $auths = explode('#', $auth);
                    foreach ($auths as $k => $v) {
                        $auths[$k] = gethostbyname(trim($v));
                    }
                }
                if ($h != 'localhost' && $h != '127.0.0.1') {
                    if (!in_array($h, $auths)) {
                        echo lang('api/auth_err');
                        exit;
                    }
                }
            }
        }

        $cache_time = intval($GLOBALS['config']['api']['actor']['cachetime']);
        $cach_name = $GLOBALS['config']['app']['cache_flag'] . '_' . 'api_actor_' . md5(http_build_query($this->_param));
        $html = Cache::get($cach_name);
        if (empty($html) || $cache_time == 0) {
            $where = [];
            if (!empty($this->_param['ids'])) {
                $where['actor_id'] = ['in', $this->_param['ids']];
            }
            if (!empty($this->_param['t'])) {
                if (empty($GLOBALS['config']['api']['actor']['typefilter']) || strpos($GLOBALS['config']['api']['actor']['typefilter'], $this->_param['t']) !== false) {
                    $where['type_id'] = $this->_param['t'];
                }
            }
            if (!empty(intval($this->_param['h']))) {
                $todaydate = date('Y-m-d', strtotime('+1 days'));
                $tommdate = date('Y-m-d', strtotime('-' . $this->_param['h'] . ' hours'));

                $todayunix = strtotime($todaydate);
                $tommunix = strtotime($tommdate);

                $where['actor_time'] = [['gt', $tommunix], ['lt', $todayunix]];
            }
            if (!empty($this->_param['wd'])) {
                $where['actor_name'] = ['like', '%' . $this->_param['wd'] . '%'];
            }
            if (!empty($GLOBALS['config']['api']['actor']['datafilter'])) {
                $where['_string'] = $GLOBALS['config']['api']['actor']['datafilter'];
            }
            if (empty(intval($this->_param['pg']))) {
                $this->_param['pg'] = 1;
            }

            $order = 'actor_time desc';
            $field = 'actor_id,actor_name,type_id,"" as type_name,actor_en,actor_area,actor_time,actor_alias,actor_sex,actor_pic';

            if ($this->_param['ac'] == 'detail') {
                $field = '*';
            }

            $res = model('actor')->listData($where, $order, $this->_param['pg'], $GLOBALS['config']['api']['actor']['pagesize'], 0, $field, 0);

            if ($res['code'] > 1) {
                echo $res['msg'];
                exit;
            }

            $type_list = model('Type')->getCache('type_list');
            foreach ($res['list'] as $k => &$v) {
                $type_info = $type_list[$v['type_id']];
                $v['type_name'] = $type_info['type_name'];
                $v['actor_time'] = date('Y-m-d H:i:s', $v['actor_time']);

                if (substr($v["actor_pic"], 0, 4) == "mac:") {
                    $v["actor_pic"] = str_replace('mac:', 'http:', $v["actor_pic"]);
                } elseif (!empty($v["actor_pic"]) && substr($v["actor_pic"], 0, 4) != "http" && substr($v["actor_pic"], 0, 2) != "//") {
                    $v["actor_pic"] = $GLOBALS['config']['api']['actor']['imgurl'] . $v["actor_pic"];
                }

                if ($this->_param['ac'] == 'detail') {

                } else {

                }
            }

            if ($this->_param['ac'] != 'detail') {
                $class = [];
                $typefilter = explode(',', $GLOBALS['config']['api']['actor']['typefilter']);

                foreach ($type_list as $k => &$v) {
                    if ($v['type_mid'] == 8) {

                        if (!empty($GLOBALS['config']['api']['actor']['typefilter'])) {
                            if (in_array($v['type_id'], $typefilter)) {
                                $class[] = ['type_id' => $v['type_id'], 'type_name' => $v['type_name']];
                            }
                        } else {
                            $class[] = ['type_id' => $v['type_id'], 'type_name' => $v['type_name']];
                        }
                    }
                }
                $res['class'] = $class;
            }

            $html = json_encode($res, JSON_UNESCAPED_UNICODE);

            if ($cache_time > 0) {
                Cache::set($cach_name, $html, $cache_time);
            }
        }
        echo $html;
        exit;
    }

    public function role()
    {
        if ($GLOBALS['config']['api']['role']['status'] != 1) {
            echo 'closed';
            die;
        }

        if ($GLOBALS['config']['api']['role']['charge'] == 1) {
            $h = $_SERVER['REMOTE_ADDR'];
            if (!$h) {
                echo lang('api/auth_err');
                exit;
            } else {
                $auth = $GLOBALS['config']['api']['role']['auth'];
                $auths = array();
                if (!empty($auth)) {
                    $auths = explode('#', $auth);
                    foreach ($auths as $k => $v) {
                        $auths[$k] = gethostbyname(trim($v));
                    }
                }
                if ($h != 'localhost' && $h != '127.0.0.1') {
                    if (!in_array($h, $auths)) {
                        echo lang('api/auth_err');
                        exit;
                    }
                }
            }
        }

        $cache_time = intval($GLOBALS['config']['api']['role']['cachetime']);
        $cach_name = $GLOBALS['config']['app']['cache_flag'] . '_' . 'api_role_' . md5(http_build_query($this->_param));
        $html = Cache::get($cach_name);
        if (empty($html) || $cache_time == 0) {
            $where = [];
            if (!empty($this->_param['ids'])) {
                $where['role_id'] = ['in', $this->_param['ids']];
            }
            if (!empty($this->_param['t'])) {
                if (empty($GLOBALS['config']['api']['role']['typefilter']) || strpos($GLOBALS['config']['api']['role']['typefilter'], $this->_param['t']) !== false) {
                    $where['type_id'] = $this->_param['t'];
                }
            }
            if (!empty(intval($this->_param['h']))) {
                $todaydate = date('Y-m-d', strtotime('+1 days'));
                $tommdate = date('Y-m-d', strtotime('-' . $this->_param['h'] . ' hours'));

                $todayunix = strtotime($todaydate);
                $tommunix = strtotime($tommdate);

                $where['role_time'] = [['gt', $tommunix], ['lt', $todayunix]];
            }
            if (!empty($this->_param['wd'])) {
                $where['role_name'] = ['like', '%' . $this->_param['wd'] . '%'];
            }
            if (!empty($GLOBALS['config']['api']['role']['datafilter'])) {
                $where['_string'] = $GLOBALS['config']['api']['role']['datafilter'];
            }
            if (empty(intval($this->_param['pg']))) {
                $this->_param['pg'] = 1;
            }

            $order = 'role_time desc';
            $field = 'role_id,role_name,role_rid,role_en,role_actor,role_time,role_pic';

            if ($this->_param['ac'] == 'detail') {
                $field = '*';
            }

            $res = model('role')->listData($where, $order, $this->_param['pg'], $GLOBALS['config']['api']['role']['pagesize'], 0, $field, 1);

            if ($res['code'] > 1) {
                echo $res['msg'];
                exit;
            }

            foreach ($res['list'] as $k => &$v) {
                $v['role_time'] = date('Y-m-d H:i:s', $v['role_time']);
                $v['douban_id'] = $v['data']['vod_douban_id'];
                $v['vod_name'] = $v['data']['vod_name'];
                $v['vod_director'] = $v['data']['vod_director'];
                unset($v['data']);
                if (substr($v["role_pic"], 0, 4) == "mac:") {
                    $v["role_pic"] = str_replace('mac:', 'http:', $v["role_pic"]);
                } elseif (!empty($v["role_pic"]) && substr($v["role_pic"], 0, 4) != "http" && substr($v["role_pic"], 0, 2) != "//") {
                    $v["role_pic"] = $GLOBALS['config']['api']['role']['imgurl'] . $v["role_pic"];
                }

                if ($this->_param['ac'] == 'detail') {

                } else {

                }
            }

            if ($this->_param['ac'] != 'detail') {
                $class = [];
                $typefilter = explode(',', $GLOBALS['config']['api']['role']['typefilter']);

                $res['class'] = $class;
            }

            $html = json_encode($res, JSON_UNESCAPED_UNICODE);

            if ($cache_time > 0) {
                Cache::set($cach_name, $html, $cache_time);
            }
        }
        echo $html;
        exit;
    }

    public function website()
    {
        if ($GLOBALS['config']['api']['website']['status'] != 1) {
            echo 'closed';
            die;
        }

        if ($GLOBALS['config']['api']['website']['charge'] == 1) {
            $h = $_SERVER['REMOTE_ADDR'];
            if (!$h) {
                echo lang('api/auth_err');
                exit;
            } else {
                $auth = $GLOBALS['config']['api']['website']['auth'];
                $auths = array();
                if (!empty($auth)) {
                    $auths = explode('#', $auth);
                    foreach ($auths as $k => $v) {
                        $auths[$k] = gethostbyname(trim($v));
                    }
                }
                if ($h != 'localhost' && $h != '127.0.0.1') {
                    if (!in_array($h, $auths)) {
                        echo lang('api/auth_err');
                        exit;
                    }
                }
            }
        }

        $cache_time = intval($GLOBALS['config']['api']['website']['cachetime']);
        $cach_name = $GLOBALS['config']['app']['cache_flag'] . '_' . 'api_website_' . md5(http_build_query($this->_param));
        $html = Cache::get($cach_name);
        if (empty($html) || $cache_time == 0) {
            $where = [];
            if (!empty($this->_param['ids'])) {
                $where['website_id'] = ['in', $this->_param['ids']];
            }
            if (!empty($this->_param['t'])) {
                if (empty($GLOBALS['config']['api']['website']['typefilter']) || strpos($GLOBALS['config']['api']['website']['typefilter'], $this->_param['t']) !== false) {
                    $where['type_id'] = $this->_param['t'];
                }
            }
            if (!empty(intval($this->_param['h']))) {
                $todaydate = date('Y-m-d', strtotime('+1 days'));
                $tommdate = date('Y-m-d', strtotime('-' . $this->_param['h'] . ' hours'));

                $todayunix = strtotime($todaydate);
                $tommunix = strtotime($tommdate);

                $where['website_time'] = [['gt', $tommunix], ['lt', $todayunix]];
            }
            if (!empty($this->_param['wd'])) {
                $where['website_name'] = ['like', '%' . $this->_param['wd'] . '%'];
            }
            if (!empty($GLOBALS['config']['api']['website']['datafilter'])) {
                $where['_string'] = $GLOBALS['config']['api']['website']['datafilter'];
            }
            if (empty(intval($this->_param['pg']))) {
                $this->_param['pg'] = 1;
            }

            $order = 'website_time desc';
            $field = 'website_id,website_name,type_id,"" as type_name,website_en,website_time,website_area,website_lang,website_pic';

            if ($this->_param['ac'] == 'detail') {
                $field = '*';
            }

            $res = model('website')->listData($where, $order, $this->_param['pg'], $GLOBALS['config']['api']['website']['pagesize'], 0, $field, 0);

            if ($res['code'] > 1) {
                echo $res['msg'];
                exit;
            }

            $type_list = model('Type')->getCache('type_list');
            foreach ($res['list'] as $k => &$v) {
                $type_info = $type_list[$v['type_id']];
                $v['type_name'] = $type_info['type_name'];
                $v['website_time'] = date('Y-m-d H:i:s', $v['website_time']);

                if (substr($v["website_pic"], 0, 4) == "mac:") {
                    $v["website_pic"] = str_replace('mac:', 'http:', $v["website_pic"]);
                } elseif (!empty($v["website_pic"]) && substr($v["website_pic"], 0, 4) != "http" && substr($v["website_pic"], 0, 2) != "//") {
                    $v["website_pic"] = $GLOBALS['config']['api']['website']['imgurl'] . $v["website_pic"];
                }

                if ($this->_param['ac'] == 'detail') {

                } else {

                }
            }

            if ($this->_param['ac'] != 'detail') {
                $class = [];
                $typefilter = explode(',', $GLOBALS['config']['api']['website']['typefilter']);

                foreach ($type_list as $k => &$v) {
                    if ($v['type_mid'] == 11) {

                        if (!empty($GLOBALS['config']['api']['website']['typefilter'])) {
                            if (in_array($v['type_id'], $typefilter)) {
                                $class[] = ['type_id' => $v['type_id'], 'type_name' => $v['type_name']];
                            }
                        } else {
                            $class[] = ['type_id' => $v['type_id'], 'type_name' => $v['type_name']];
                        }
                    }
                }
                $res['class'] = $class;
            }

            $html = json_encode($res, JSON_UNESCAPED_UNICODE);

            if ($cache_time > 0) {
                Cache::set($cach_name, $html, $cache_time);
            }
        }
        echo $html;
        exit;
    }

    public function comment()
    {

    }
}

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 2
    评论
2021最新原生安卓影视app源码 对接苹果CMS支持PC+WAP+APP 附完整视频教程 包含苹果CMS后台的搭建采集视频教程, Android打包修改 详细视频教程 广告位修改和个性自定义链接 详细视频教程 原生安卓影视app对接苹果CMSV10影视支持PC+WAP+自适应+安卓APP+微信 JAVA影视APP源码 开发环境java 安卓:Android Stodio 无ios只有安卓! 3月25日修复功能 1、增加自动播放下一集功能 2、播放器自带选集功能 3、增加播放器投屏功能 4、修复上一版本下载错误问题 APP内置5大广告位 1开屏广告 2.首页推荐页面4个广告位 3.播放器播放前1个广告位 4.播放器下方1个广告位 5.我的-个人中心1个广告位 源码内容: 安卓+对应版本cms+对接文件+教程+文档+视频教程 注:视频教程不包括教你怎么安装Android Stodio软件和配置jdk环境 教程基本内容就是 安装 对接 编译打包 源码只有安卓,要对应版本的苹果cmsv10 目前测试其他版本可能连不上首页 拍安装服务:提供安装苹果cms对接文件,需要提供宝塔,不包打包编译, 如果需要打包编译另拍编译打包服务,修改+编译打包 提供演示的同时自行测试功能! 请看好演示在购买,不要盲目购买! 后台是苹果cms 自行搭建观看,对接文件不是后台!广告 公告等等需要直接改文件的代码!(文档提供路径修改方式) 上传源码 导入数据库 修改数据库配置 application/database.php 修改数据库配置 APP/CMS/config/dbs.php 模板改成自己的模板!模板改成自己的模板! 模板路径/template 上传了模板进后台吧设置里的模板改成你上传的 后台账号admin 密码xiaoyu520. 安装后还原数据库,还原后数据库账号admin 密码admin888 打开以下目录 template\ikan\js 找到这两个js jquery.html.js jquery.stem.js 搜索 mac02.hui11.top 然后替换成自己的域名地址,无需http(s):// 记住必须要修改两个js 才行 把网站全部替换成自己的网站就行 用notepad++ 检索模板代码 把mac02.hui11.top 全部替换为自己的网站 把秘趣影视源码 全部替换为自己的网站名 幻灯片是推荐9 二维码修改 \ikan\html\system\jq_content.html 第3-4行 \ikan\html\vod\play.html 第29行
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

洋气又优秀。

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值