Beispiel #1
0
 function show()
 {
     $group_flag = $this->input['fid'];
     $offset = $this->input['offset'] ? $this->input['offset'] : 0;
     $count = $this->input['offset'] ? $this->input['count'] : 30;
     $conditions = '';
     $auth_node_pos = $_auth_node_group = array();
     $auth_node = get_auth_group_or_pos(MOD_UNIQUEID, 'show', $this->user);
     if ($this->user['group_type'] > MAX_ADMIN_TYPE && $auth_node) {
         if (!$group_flag) {
             if (!$auth_node) {
                 $this->errorOutput(NO_PRIVILEGE);
             }
             if ($auth_node['first']) {
                 $conditions .= implode('","', $auth_node['first']);
             }
             if ($auth_node['second']) {
                 if ($conditions) {
                     $conditions .= '","';
                 }
                 $conditions .= implode('","', $auth_node['second']);
             }
             $conditions = ' AND flag in("' . $conditions . '")';
         } else {
             if ($auth_node['three'][$group_flag]) {
                 $conditions .= ' AND p.id IN(' . implode(',', $auth_node['three'][$group_flag]) . ')';
             }
         }
     }
     if ($group_flag) {
         $sql = 'SELECT p.id,p.zh_name,gp.group_flag FROM  ' . DB_PREFIX . 'group_pos gp LEFT JOIN ' . DB_PREFIX . 'advpos p ON gp.pos_id = p.id WHERE 1 AND  gp.group_flag IN("' . $group_flag . '")' . $conditions;
         $out = array();
         $query = $this->db->query($sql);
         while ($row = $this->db->fetch_array($query)) {
             $m = array('id' => $row['group_flag'] . SPLIT_FLAG . $row['id'], "name" => $row['zh_name'], "fid" => $this->input['fid'], "depath" => 2, 'is_last' => 1);
             $this->addItem($m);
         }
     } else {
         $sql = 'SELECT id,flag,name FROM ' . DB_PREFIX . 'advgroup where 1 ' . $conditions . ' limit ' . $offset . ', ' . $count;
         //$this->errorOutput($sql);
         $query = $this->db->query($sql);
         while ($row = $this->db->fetch_array($query)) {
             $m = array('id' => $row['flag'], "name" => $row['name'], "fid" => $this->input['fid'], "depath" => 1, 'is_last' => 0);
             $this->addItem($m);
         }
     }
     $this->output();
 }
Beispiel #2
0
 function getadvpos($group = array())
 {
     //
     $advpos = array();
     $groups = $this->input['flag'] ? trim(urldecode($this->input['flag'])) : @implode('","', $group);
     if (!$groups) {
         return $advpos;
     }
     $auth_node = get_auth_group_or_pos(MOD_UNIQUEID, 'publish', $this->user);
     $sql = 'SELECT gp.pos_id,p.zh_name,gp.group_flag FROM ' . DB_PREFIX . 'group_pos gp LEFT JOIN ' . DB_PREFIX . 'advpos p ON gp.pos_id=p.id WHERE p.is_use=1 AND gp.group_flag IN("' . $groups . '")';
     $q = $this->db->query($sql);
     while ($row = $this->db->fetch_array($q)) {
         if ($auth_node) {
             if (!in_array($row['group_flag'], (array) $auth_node['first']) && !in_array($row['pos_id'], (array) $auth_node['three'][$row['group_flag']])) {
                 continue;
             }
         }
         $advpos[$row['group_flag']][$row['pos_id']] = $row['zh_name'];
     }
     //ajax请求根据客户端返回广告位
     if ($this->input['flag']) {
         $this->addItem($advpos[$this->input['flag']]);
         $this->output();
     }
     return $advpos;
 }