Example #1
0
 /**
  * 获取当前项目的根目录的URL
  */
 public function get_base_url()
 {
     return Controller::get_base_url();
 }
Example #2
0
 /**
  * 删除
  */
 public function del($id, $catid)
 {
     $cat = get_category_data();
     $table = $cat[$catid]['tablename'];
     if (empty($table) || empty($id)) {
         return false;
     }
     $data = $this->find($id);
     if (empty($data)) {
         return false;
     }
     $this->delete('id=' . $id);
     if ($data['thumb'] && file_exists($data['thumb'])) {
         @unlink($data['thumb']);
     }
     $this->query('delete from ' . $this->prefix . $table . ' where id=' . $id);
     if (empty($data['sysadd']) && $data['username'] && is_numeric($data['userid'])) {
         $this->credits($data['userid'], 0);
     }
     $file = substr($data['url'], strlen(Controller::get_base_url()));
     //去掉主域名
     $file = substr($file, 0, 9) == 'index.php' ? null : $file;
     //是否为动态链接
     //删除关联表单数据
     $form = $this->execute('SELECT * FROM `' . $this->prefix . 'model` WHERE `joinid`=' . (int) $cat[$catid]['modelid']);
     if ($form) {
         foreach ($form as $t) {
             $this->query('DELETE FROM `' . $this->prefix . $t['tablename'] . '` WHERE `cid`=' . $id);
         }
     }
     if ($file && file_exists($file)) {
         @unlink($file);
     }
     //删除扩展表
     $this->query('delete from ' . $this->prefix . 'content_' . App::get_site_id() . '_extend where id=' . $id);
     //删除审核表
     $this->query('delete from ' . $this->prefix . 'content_' . App::get_site_id() . '_verify where id=' . $id);
     //删除推荐位信息
     $this->query('delete from ' . $this->prefix . 'position_data where contentid=' . $id);
 }
Example #3
0
 public function formAction()
 {
     $cid = (int) $this->get('cid');
     $type = (int) $this->get('type');
     $page = $this->get('page') ? (int) $this->get('page') : 1;
     $status = isset($_GET['status']) ? (int) $this->get('status') : -1;
     $modelid = (int) $this->get('modelid');
     if (!isset($this->form[$modelid]) || empty($this->form[$modelid])) {
         $this->memberMsg(lang('m-con-24'));
     }
     $table = $this->model($this->form[$modelid]['tablename']);
     if ($this->isPostForm() && $this->post('ids')) {
         //删除
         $ids = '';
         foreach ($this->post('ids') as $i) {
             $ids .= ',' . (int) $i;
         }
         $ids = trim($ids, ',');
         if (empty($ids)) {
             $this->memberMsg(lang('m-con-25'));
         }
         $data = $table->where("userid=" . $this->memberinfo['id'] . " and username='******'username'] . "' and id in(" . $ids . ")")->select();
         if (empty($data)) {
             $this->memberMsg(lang('m-con-25'));
         }
         foreach ($data as $t) {
             $file = substr(form_show_url($modelid, $t), strlen(Controller::get_base_url()));
             //去掉主域名
             $file = substr($file, 0, 9) == 'index.php' ? null : $file;
             //是否为动态链接
             if ($file && file_exists($file)) {
                 @unlink($file);
             }
             $table->update(array('status' => 3), 'id=' . $t['id']);
         }
     }
     $showme = isset($this->form[$modelid]['joinid']) && isset($this->form[$modelid]['setting']['form']['showme']) ? $this->form[$modelid]['setting']['form']['showme'] : 0;
     $pagelist = $this->instance('pagelist');
     $pagelist->loadconfig();
     $pagesize = isset($this->memberconfig['pagesize']) && $this->memberconfig['pagesize'] ? $this->memberconfig['pagesize'] : 8;
     if ($this->form[$modelid]['joinid'] && $type && $showme) {
         $where = empty($cid) ? '`cid` IN (SELECT `id` FROM `' . $this->content->prefix . 'content_' . $this->siteid . '` WHERE `modelid`=' . $this->form[$modelid]['joinid'] . ' AND `sysadd`=0 AND `status`>0 AND `userid`=' . $this->memberinfo['id'] . ' AND `username`="' . $this->memberinfo['username'] . '")' : '`cid` IN (SELECT `id` FROM `' . $this->content->prefix . 'content_' . $this->siteid . '` WHERE `modelid`=' . $this->form[$modelid]['joinid'] . ' AND `sysadd`=0 AND `status`>0 AND `userid`=' . $this->memberinfo['id'] . ' AND `username`="' . $this->memberinfo['username'] . '" AND id=' . $cid . ')';
     } else {
         $where = (empty($cid) ? '' : '`cid`=' . $cid . ' AND ') . '`userid`=' . $this->memberinfo['id'] . ' AND `username`="' . $this->memberinfo['username'] . '"';
     }
     $where .= $status > 0 && $status < 3 ? ' AND `status`=' . $status : '';
     $data = $table->page_limit($page, $pagesize)->order('updatetime DESC')->where($where)->select();
     $total = $table->count($this->form[$modelid]['tablename'], 'id', $where);
     $pagelist = $pagelist->total($total)->url(url('member/content/form', array('modelid' => $modelid, 'type' => $type, 'status' => $status, 'page' => '{page}')))->num($pagesize)->page($page)->output();
     $this->view->assign(array('list' => $data, 'page' => $page, 'type' => $type, 'form' => $this->form[$modelid], 'join' => $this->form[$modelid]['joinid'] ? $this->form[$modelid]['joinname'] : 0, 'status' => $status, 'showme' => $showme, 'modelid' => $modelid, 'pagelist' => $pagelist, 'listdata' => $data, 'meta_title' => $this->form[$modelid]['joinname'] . $this->form[$modelid]['modelname'] . '-' . lang('member') . '-' . $this->site['SITE_NAME'], 'showfields' => isset($this->form[$modelid]['setting']['form']['membershow']) ? $this->form[$modelid]['setting']['form']['membershow'] : array()));
     $this->view->display('member/form_list');
 }
Example #4
0
 /**
  * 删除静态文件
  */
 private function delFile($id)
 {
     $data = $this->form->find((int) $id);
     $file = substr(form_show_url($this->modelid, $data), strlen(Controller::get_base_url()));
     //去掉主域名
     $file = substr($file, 0, 9) == 'index.php' ? null : $file;
     //是否为动态链接
     if ($file && file_exists($file)) {
         @unlink($file);
     }
 }