public function webAdd() { $Public = new PublicController(); $Web = M('website'); $Web_Ap = M('web_ap'); if (IS_AJAX) { $data['tpl_style'] = I('post.tpl_style'); $data['web_name'] = I('post.title', ''); $data['address'] = I('post.address', ''); $data['copyright'] = I('post.copyright', ''); $data['phone'] = I('post.phone', ''); $ssid = I('post.ssid', ''); $ssid_arr = array_unique(explode(',', $ssid)); sort($ssid_arr); $len = count($ssid_arr); //echo json_encode(array('state'=>1,'msg'=>$len));exit; for ($i = 0; $i < $len; $i++) { $apsingle = explode('_', $ssid_arr[$i]); if ($Web_Ap->where(array('ssid' => $apsingle[0], 'gw_id' => $apsingle[1]))->find()) { echo json_encode(array('state' => 1, 'msg' => '路由:' . $apsingle[1] . ',对应热点:' . $apsingle[0] . '已存在站点,请先删除站点!')); exit; } } $data['uid'] = session('userId') ? session('userId') : 1; $filename = $data['tpl_style'] . date('YmdHis', time()) . rand(0, 999); if (!is_dir(WEB_ROOT . '/Down/' . session('name'))) { mkdir(WEB_ROOT . '/Down/' . session('name')); } $dst = WEB_ROOT . '/Down/' . session('name') . '/' . $filename; $Public->recurse_copy(WEB_ROOT . '/MediaTpl/' . $data['tpl_style'], $dst); $data['filename'] = '/Down/' . session('name') . '/' . $filename; $webFileName = $data['filename']; if (file_exists(WEB_ROOT . '/MediaTpl/' . $data['tpl_style'] . '/dingcan.flag')) { $data['type'] = '1'; } $insertId = $Web->data($data)->add(); //生成微信菜单 $Api = M('webapi'); // echo json_encode(array('state'=>0,'msg'=>$len)); for ($i = 0; $i < $len; $i++) { $apsingle = array(); $apsingle = explode('_', $ssid_arr[$i]); $leng = count($apsingle); $data['gw_id'] = $apsingle[$leng - 1]; unset($apsingle[$leng - 1]); $ssid = implode('_', $apsingle); $data['ssid'] = $ssid; $data['webid'] = $insertId; $Web_Ap->data($data)->add(); $queryId = $Web_Ap->getLastInsID(); $data = array('api' => 'downTpl', 'webid' => $queryId, 'order' => '100', 'state' => '1'); $Api->data($data)->add(); } if ($queryId) { echo json_encode(array('state' => 0, 'msg' => '建站成功', 'url' => '/Webbuild/index.php/Webconf/webConf/id/' . $insertId)); } else { echo json_encode(array('state' => 1, 'msg' => '建站失败')); } } else { $Public->show404(); } }
public function __construct() { parent::__construct(); $Public = new PublicController(); $Public->checkLogin(); }
/** * 导航编辑 */ public function navEdit() { $Public = new PublicController(); $Nav = M('webnav'); if (IS_POST) { $data['id'] = I('post.id', ''); $data['navname'] = I('post.navname', ''); $data['url'] = I('post.url', ''); $data['order'] = I('post.order', ''); $query = $Nav->data($data)->save(); $web = $Nav->getById($data['id']); //提示wifidog更新导航信息 $api = array(); $where = array(); $Web_Ap = M('web_ap'); $query = $Web_Ap->where(array('webid' => $web['webid']))->field('id')->select(); $WebApi = M('webapi'); foreach ($query as $item) { $where['api'] = 'getNav'; $where['webid'] = $item['id']; $api['state'] = '1'; $WebApi->where($where)->data($api)->save(); } $where['api'] = 'getNav'; //更新首页静态文件 $Web = M('website'); $web = $Web->find($web['webid']); $webid = $web['webid']; $hd = fopen(WEB_ROOT . $web['filename'] . '/index.html', 'w'); $content = file_get_contents('http://' . $_SERVER['HTTP_HOST'] . $web['filename'] . '/index.php?webid=' . $webid); fwrite($hd, $content); fclose($hd); if ($query) { $this->success('编辑成功', 'navList?webid=' . I('post.webid', '')); } else { $this->error('编辑失败'); } } else { $data['id'] = I('get.id'); $nav = $Nav->where($data)->find(); if (empty($nav)) { $Public->error('资源不存在'); } $this->assign('nav', $nav); $html['mode'] = 'edit'; $this->assign('html', $html); $Public->showHeader(); $this->display('navEdit'); $Public->showFooter(); } }
/** * 404 */ public function _empty() { $Public = new PublicController(); $Public->show404(); }