/** * @example 广告添加 */ public function adsAdd() { $Public = new PublicController(); if (IS_POST) { $Ads = D('Ads'); $data = $Ads->create(); $img = $this->getFilePath(); if (!$img) { $this->error('图片上传失败,请重新上传'); } $Ads->img = $img; if (!$Ads->add()) { $this->error('广告添加失败'); } $query = $this->updateApi($data['webid'], 'getAds', $Ads->getLastInsId()); $query ? $this->success('添加成功') : $this->error('添加失败'); } else { $webid = I('get.webid'); $Website = M('website'); $web = $Website->getById($webid); if (!is_dir($web['filename'] . '/reource')) { mkdir($web['filename'] . '/reource'); } $filepath = urlencode(str_replace('/', '.', $web['filename'] . '/reource')); $this->assign('filepath', $filepath); $Public->showHeader(); $this->display('Ads/adsAdd'); $Public->showFooter(); } }
public function index() { $Public = new PublicController(); $Website = D('website'); $data['gw_id'] = array('eq', I('get.gw_id', '')); $data['rid'] = array('eq', I('get.id', '')); $data['_logic'] = 'or'; $websites = $Website->where($data)->select(); $this->assign('websites', $websites); $Public->showHeader(); $Public->showFooter(); }
public function showQRcode() { $Web = D('Website'); $webid = I('get.webid', ''); $query = $Web->field('filename')->getById($webid); $url = 'http://' . $_SERVER['HTTP_HOST'] . $query['filename'] . '/index.php?webid=' . $webid; $this->assign('url', $url); $Public = new PublicController(); $Public->showHeader(); $this->display('Public/QRcode'); $Public->showFooter(); }
/** * 导航编辑 */ 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(); } }
public function proAdd() { $Pro = M('product'); $Public = new PublicController(); if (IS_POST) { $Website = M('website'); $insert = $Pro->create(); $webid = $insert['webid']; $web = $Website->getById(I('post.webid', '')); if ($mainImg = $this->getFilePath()) { $Pro->main_img = $mainImg; } $query = $Pro->add(); //更新wifidog接口信息 $Api = M('webapi'); $data = array(); $data['state'] = '1'; $web_ap = M('web_ap')->field('id')->where(array('webid' => $webid))->select(); $arr = array(); foreach ($web_ap as $v) { $arr[] = $v['id']; } // var_dump($web_ap); $where = array('api' => 'getProducts', 'webid' => array('in', implode(',', $arr))); $Api->where($where)->data(array('state' => '1'))->save(); //生成静态页面 if (file_exists(WEB_ROOT . $web['filename'] . '/cateList.php')) { $hd = fopen(WEB_ROOT . $web['filename'] . '/cat_' . $insert['cat_id'] . '.html', 'w'); $content = file_get_contents('http://' . $_SERVER['HTTP_HOST'] . $web['filename'] . '/cateList.php?webid=' . $webid . '&cat_id=' . $insert['cat_id']); fwrite($hd, $content); fclose($hd); } if (file_exists(WEB_ROOT . $web['filename'] . '/detail.php')) { $hd = fopen(WEB_ROOT . $web['filename'] . '/pro_' . $query . '.html', 'w'); $content = file_get_contents('http://' . $_SERVER['HTTP_HOST'] . $web['filename'] . '/detail.php?webid=' . $webid . '&pro_id=' . $query); fwrite($hd, $content); fclose($hd); } $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 (file_exists(WEB_ROOT . $web['filename'] . '/islua.flag')) { /*$data = array(); $web_ap = M('web_ap')->field('id')->where(array('webid'=>$webid))->select(); $arr = array(); foreach($web_ap as $v){ $arr[] = $v['id']; } // var_dump($web_ap); $where = array('api'=>'getProducts','webid'=>array('in',implode(',', $arr))); $oldid = $Api->where($where)->field('influ_ids')->find(); $data['influ_ids'] = empty($oldid['influ_ids'])?$query:$oldid['influ_ids'].','.$query; $data['influ_ids'] = implode(',', array_unique(explode(',', $data['influ_ids']))); $Api->where($where)->data($data)->save();*/ $this->updApi($webid, 'getProducts', $query); } // echo $Api->getLastSql();die; // echo $Api->getLastSql();die; $query ? $this->success('添加成功', U('Product/proList') . '?webid=' . I('post.webid', '')) : $this->error('添加失败'); } else { $webid = I('get.webid'); $Website = M('website'); $web = $Website->getById($webid); //获取商品添加模板 $filepath = urlencode(str_replace('/', '.', $web['filename'] . '/reource')); $this->assign('filepath', $filepath); $cates = $this->Cate->where(array('webid' => I('get.webid', ''), 'type' => 'product'))->select(); $this->assign('cates', $cates); $Public->showHeader(); $this->display('Product/proAdd'); $Public->showFooter(); } }