1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- <?php
- namespace app\api\controller;
- use app\api\model\Area;
- use app\common\controller\Api;
- use app\common\library\Ip;
- use fast\Version;
- use think\Config;
- /**
- * 公共接口
- */
- class Common extends Api
- {
- protected $noNeedLogin = '*';
- protected $noNeedRight = '*';
- public function _initialize()
- {
- parent::_initialize();
- }
- /**
- * 加载初始化
- *
- * 必选参数:version<br>
- * 可选参数:lng,lat
- */
- public function init()
- {
- if ($version = $this->request->request('version'))
- {
- $lng = $this->request->request('lng');
- $lat = $this->request->request('lat');
- $content = [
- 'citydata' => Area::getCityFromLngLat($lng, $lat),
- 'versiondata' => Version::check($version),
- 'uploaddata' => Config::get('upload'),
- 'coverdata' => Config::get("cover"),
- ];
- $this->success('', $content);
- }
- else
- {
- $this->error(__('Invalid parameters'));
- }
- }
- /**
- * 获取IP及地域信息
- */
- public function ip()
- {
- $format = $this->request->param('format', 'json');
- if ($format == 'json') {
- $this->success('', ['ip' => Ip::ip(), 'city' => Ip::city(), 'province' => Ip::province(), 'country' => Ip::country(), 'info'=>Ip::str()]);
- }
- }
- }
|