public function get_photo($id) { $sql = "SELECT a.original_pic,a.title FROM " . $this->table('album_photos') . " as a WHERE a.id = '" . $id . "'"; $result = $this->getRow($sql); $result['title'] = hy_dig_filter($result['title']); return $result; }
public function get_adlist() { $res = array('error' => 1, 'content' => ''); $set_time = Model('index')->get_cfg('temp_ad'); $set_time = yf_time() - $set_time * 24 * 60 * 60; $list = Model('index')->get_ad_list($set_time); if ($list) { foreach ($list as $k => $v) { $list[$k]['title'] = hy_dig_filter($v['title'], 1); $list[$k]['author'] = hy_dig_filter($v['author'], 1); $list[$k]['content'] = hy_dig_filter($v['content'], 1); $list[$k]['store_name'] = Model('index')->getOne("select store_name from " . Model('index')->table('store') . " where store_id=" . $v['cat_id']); $list[$k]['url'] = "index.php?g=mobile&m=store&a=goods&id=" . $v['id']; } $res = array('error' => 0, 'content' => $list); } else { $res['content'] = "暂时没有公告更新"; } $this->showMsg($res); }
public function cat_child($cfg = array()) { if ($cfg['limit']) { $num = $cfg['limit']; } else { $num = 10; } $sql = "SELECT id,name,type FROM " . $this->table('category') . " WHERE code='" . $cfg['code'] . "'"; $parent = $this->getRow($sql); if ($parent['id']) { $parent['name'] = hy_dig_filter($parent['name']); if (REWRITE == 1) { switch ($parent['type']) { case 1: $parent['url'] = "/" . $cfg['code'] . "/article/index.html"; break; case 2: $parent['url'] = "/" . $cfg['code'] . "/article/photo.html"; break; case 3: $parent['url'] = "/" . $cfg['code'] . "/article/page.html"; break; } } else { switch ($parent['type']) { case 1: $parent['url'] = "index.php?g=home&m=article&a=index&code=" . $cfg['code']; break; case 2: $parent['url'] = "index.php?g=home&m=article&a=photo&code=" . $cfg['code']; break; case 3: $parent['url'] = "index.php?g=home&m=article&a=page&code=" . $cfg['code']; break; } } $sql = "SELECT id,name,type,code FROM " . $this->table('category') . " WHERE parent_id='" . $parent['id'] . "' ORDER BY created LIMIT " . $num; $parent['child'] = $this->getALL($sql); if ($parent['child']) { foreach ($parent['child'] as $k => $v) { if (REWRITE == 1) { switch ($v['type']) { case 1: $parent['child'][$k]['url'] = "/" . $v['code'] . "/article/index.html"; break; case 2: $parent['child'][$k]['url'] = "/" . $v['code'] . "/article/photo.html"; break; case 3: $parent['child'][$k]['url'] = "/" . $v['code'] . "/article/page.html"; break; } } else { switch ($v['type']) { case 1: $parent['child'][$k]['url'] = "index.php?g=home&m=article&a=index&code=" . $v['code']; break; case 2: $parent['child'][$k]['url'] = "index.php?g=home&m=article&a=photo&code=" . $v['code']; break; case 3: $parent['child'][$k]['url'] = "index.php?g=home&m=article&a=page&code=" . $v['code']; break; } } } } } return $parent; }
/** * 获得管理字段信息 * @param $id * @param $page * @param $limit * @return */ public function get_form_info($id, $page, $limit = 10) { $sql = "select a.*, b.name, b.type as field_type, b.data FROM " . $this->table('forms_word') . " as a left join " . $this->table('fields') . " as b on a.fields_id=b.id where a.form_id=" . $id; $result = $this->show_page($sql, $page, $limit); if ($result['result']) { foreach ($result['result'] as $k => $v) { switch ($v['field_type']) { case 0: $result['result'][$k]['field_type'] = '单行文本'; break; case 1: $result['result'][$k]['field_type'] = '多行文本'; break; case 2: $result['result'][$k]['field_type'] = '单选按钮'; break; case 3: $result['result'][$k]['field_type'] = '多选按钮'; break; case 4: $result['result'][$k]['field_type'] = '下拉列表'; break; case 5: $result['result'][$k]['field_type'] = '上传'; break; } $result['result'][$k]['name'] = hy_dig_filter($v['name'], 1); } } return $result; }
public function get_goods_spec($id) { $sql = 'SELECT id,name,type,field FROM ' . $this->table('goods_spec') . " WHERE type_id='" . $id . "'"; $res = $this->getAll($sql); foreach ($res as $k => $v) { $res[$k]['name'] = hy_dig_filter($v['name'], 1); $ch_field = hy_dig_filter($v['field'], 1); $en_field = hy_dig_filter($v['field'], 2); if ($v['type'] == 1 || $v['type'] == 3) { $temp = explode(',', $ch_field); $temp2 = explode(',', $en_field); foreach ($temp as $kk => $vv) { $res[$k]['field_list'][$kk]['id'] = $v['id']; $res[$k]['field_list'][$kk]['val'] = CH_SC . $vv . DIG_EC . EN_SC . $temp2[$kk] . DIG_EC; $res[$k]['field_list'][$kk]['name'] = $vv; } } } return $res; }
/** * 获取所有的文章 * @param $sort * @return */ public function get_all_art($sort = array()) { $where = '1=1'; $sql = "SELECT a.id,a.title,a.ordering,c.name FROM (" . $this->table('article') . " as a) LEFT JOIN " . $this->table('category') . " as c ON a.cat_id=c.id WHERE " . $where . " ORDER BY a.id DESC"; $result = $this->getAll($sql); foreach ($result as $k => $v) { $result[$k]['title'] = hy_dig_filter($v['title'], 1); $result[$k]['name'] = hy_dig_filter($v['name'], 1); $result[$k]['url'] = 'http://' . $_SERVER['HTTP_HOST'] . '/index.php?g=mobile&m=article&a=view&id=' . $v['id']; } return $result; }
public function get_ad($opt) { $option = array(); $sql = "SELECT id FROM " . $this->table('block') . " WHERE code ='" . $opt['code'] . "'"; $flash_id = $this->getOne($sql); if ($flash_id) { $sql = "SELECT weight,height FROM " . $this->table('block') . " WHERE id ='" . $flash_id . "'"; $flash_cfg = $this->getRow($sql); $sql = "SELECT * FROM " . $this->table('block_content') . " WHERE block_id ='" . $flash_id . "' ORDER BY ordering DESC"; $flash_img = $this->getAll($sql); foreach ($flash_img as $k => $v) { $flash_img[$k]['ch_title'] = hy_dig_filter($v['title'], 1); $flash_img[$k]['en_title'] = hy_dig_filter($v['title'], 2); $flash_img[$k]['title'] = hy_dig_filter($v['title']); $flash_img[$k]['description'] = hy_dig_filter(str_replace(PHP_EOL, '<br>', $v['description'])); } } return $flash_img; }
/** * 不分页获取菜单列表 * * @access public * @param int page 当前页 * @param int pagesize 每页显示数量 * @param int show_extend_link 是否显示外链 * @return array */ public function get_cat_list($sort = array()) { $where = ' WHERE 1=1 '; $sql = 'SELECT name,id,parent_id,ordering,type FROM ' . $this->table('category') . $where; $cat = $this->getAll($sql); foreach ($cat as $k => $v) { $cat[$k]['name'] = hy_dig_filter($v['name'], 1); switch ($v['type']) { case 1: $cat[$k]['cat_type'] = '文章模块'; break; case 2: $cat[$k]['cat_type'] = '相册模块'; break; case 3: $cat[$k]['cat_type'] = '单页模块'; break; case 4: $cat[$k]['cat_type'] = '产品模块'; break; } } $res = self::sortdata($cat, 0, '----|'); if (!empty($sort)) { foreach ($res as $k => $v) { if ($sort['type']) { if (is_array($sort['type'])) { if (!in_array($v['type'], $sort['type'])) { unset($res[$k]); } } else { if ($v['type'] != $sort['type']) { unset($res[$k]); } } } } } return $res; }
public function get_art($id) { $result = array(); if ($id) { $sql = "SELECT title,abstract,keywords,author,created,source_url,content,page_title,hits,source,thumb FROM " . $this->table('article') . " WHERE id = '" . $id . "'"; $result = $this->getRow($sql); if ($result) { $result['title'] = hy_dig_filter($result['title']); $result['author'] = hy_dig_filter($result['author']); $result['content'] = stripslashes(hy_dig_filter($result['content'])); return $result; } else { return $result; } } return $result; }
public function selecttype() { $result = array('error' => 1, 'content' => '获取数据失败', 'data' => ''); $id = intval($_POST['id']); $attr = Model('goods')->get_goods_spec($id); $html = ''; $tpl = '<div class="am-g am-margin-top"><div class="am-u-sm-2 am-text-right">%s</div><div class="am-u-sm-4 am-u-end">%s</div></div>'; if (!empty($attr)) { foreach ($attr as $k => $v) { if ($v['type'] == 1) { $input = '<div class="am-btn-group" data-am-button>'; foreach ($v['field_list'] as $kk => $vv) { $input .= '<label class="am-btn am-btn-default am-btn-xs"><input type="radio" name="val_spec_' . $v['id'] . '" value="' . $vv['val'] . '" >' . $vv['name'] . '</label>'; } $input .= '</div>'; } elseif ($v['type'] == 2) { $ch_txt = hy_dig_filter($v['field'], 1); $en_txt = hy_dig_filter($v['field'], 2); $input = '<input type="text" value="' . $ch_txt . '" name="val_spec_' . $v['id'] . '" />'; if (DIGLOSSIA) { $input .= '<br>'; $input .= '<input type="text" value="' . $en_txt . '" name="val_spec_' . $v['id'] . '" />'; } } elseif ($v['type'] == 3) { $input = '<div class="am-btn-group" data-am-button>'; foreach ($v['field_list'] as $kk => $vv) { $input .= '<label class="am-btn am-btn-default am-btn-xs"><input type="checkbox" name="val_spec_' . $v['id'] . '" value="' . $vv['val'] . '" >' . $vv['name'] . '</label>'; } $input .= '</div>'; } $html .= sprintf($tpl, '<input type="hidden" value="' . $v['name'] . '" name="spec_' . $v['id'] . '" />' . $v['name'], $input); } $result['error'] = 0; $result['content'] = 'ok'; $result['data'] = $html; } print_r(json_encode($result)); }
public function get_goods_detial($id) { $sql = "update " . $this->table('article') . " set hits=hits+1 where id=" . $id; $this->query($sql); $sql = "select * from " . $this->table('article') . " where id=" . $id; $data = $this->getRow($sql); $data['created'] = date('Y-m-d H:i:s', $data['created']); $data['title'] = hy_dig_filter($data['title'], 1); $data['content'] = hy_dig_filter($data['content'], 1); return $data; }
public function get_good($id) { $result = array(); if ($id) { $sql = "SELECT g.* FROM " . $this->table('goods') . " as g WHERE id = '" . $id . "'"; $result = $this->getRow($sql); if ($result) { // print_r($result['external_chain']); $result['external_chain'] = explode(PHP_EOL, $result['external_chain']); $result['goods_name'] = hy_dig_filter($result['goods_name']); $result['goods_brief'] = hy_dig_filter($result['goods_brief']); $result['content'] = stripslashes(hy_dig_filter($result['content'])); //获取品牌 $sql = "SELECT brand_name FROM " . $this->table('goods_brand') . " WHERE id = '" . $result['brand_id'] . "'"; $result['brand_name'] = hy_dig_filter($this->getOne($sql)); //获取相册集 $sql = "SELECT p.* FROM " . $this->table('goods_gallery') . " as p WHERE p.goods_id = '" . $id . "'"; $photo = $this->getAll($sql); $result['gallery'] = $photo; //获取属性 $sql = 'SELECT ge.attr_id,ge.attr_value,ge.goods_img,ga.name FROM ' . $this->table('goods_attr_extend') . ' as ge,' . $this->table('goods_attr') . " as ga WHERE ga.id=ge.attr_id AND ge.goods_id='" . $id . "'"; $res = $this->getAll($sql); $attr = array(); foreach ($res as $k => $v) { $attr[$v['attr_id']]['name'] = hy_dig_filter($v['name']); $temp = (array) json_decode($v['attr_value']); $attr[$v['attr_id']]['value'][$k]['attr_text'] = hy_dig_filter(urldecode($temp['name'])); $attr[$v['attr_id']]['value'][$k]['goods_img'] = $v['goods_img']; if ($temp['color'] != '') { $attr[$v['attr_id']]['value'][$k]['type'] = '1'; $attr[$v['attr_id']]['value'][$k]['attr_value'] = $temp['color']; } elseif ($temp['thumb'] != '') { $attr[$v['attr_id']]['value'][$k]['type'] = '2'; $attr[$v['attr_id']]['value'][$k]['attr_value'] = $temp['thumb']; } else { $attr[$v['attr_id']]['value'][$k]['type'] = '3'; $attr[$v['attr_id']]['value'][$k]['attr_value'] = hy_dig_filter(urldecode($temp['name'])); } } $result['attr'] = $attr; //获取规格-start //$spec_arr=$this->get_goods_spec($res['goods_type']); $sql = 'SELECT spec_id,spec_value FROM ' . $this->table('goods_spec_extend') . " WHERE goods_id='" . $id . "'"; $temp = $this->getAll($sql); foreach ($temp as $k => $v) { $sql = 'SELECT name FROM ' . $this->table('goods_spec') . " WHERE id='" . $v['spec_id'] . "'"; $goods_spec[$v['spec_id']]['name'] = hy_dig_filter($this->getOne($sql)); $goods_spec[$v['spec_id']]['value'] = hy_dig_filter($v['spec_value']); } $result['spec'] = $goods_spec; return $result; } else { return $result; } } return $result; }
public function cat_child($cfg = array()) { if ($cfg['limit']) { $num = $cfg['limit']; } else { $num = 10; } $sql = "SELECT id,name,type FROM " . $this->table('category') . " WHERE code='" . $cfg['code'] . "'"; $parent = $this->getRow($sql); if ($parent['id']) { $sql = "SELECT parent_id FROM " . $this->table('category') . " WHERE id='" . $parent['id'] . "'"; $temp = $this->getRow($sql); $parent['id'] = $this->find_parent($parent['id']); if ($temp['parent_id'] == 0) { $parent['name'] = hy_dig_filter($parent['name']); } else { //如果是有父类就获取父类名称 $sql = "SELECT name FROM " . $this->table('category') . " WHERE id='" . $temp['parent_id'] . "'"; $pname = $this->getOne($sql); $parent['name'] = hy_dig_filter($pname); } if (REWRITE == 1) { switch ($parent['type']) { case 1: $parent['url'] = "/" . $cfg['code'] . "/article/index.html"; break; case 2: $parent['url'] = "/" . $cfg['code'] . "/article/photo.html"; break; case 3: $parent['url'] = "/" . $cfg['code'] . "/article/page.html"; break; case 4: $parent['url'] = "/goods/list.html?id=" . $parent['id']; break; } } else { switch ($parent['type']) { case 1: $parent['url'] = "index.php?g=home&m=article&a=index&code=" . $cfg['code']; break; case 2: $parent['url'] = "index.php?g=home&m=article&a=photo&code=" . $cfg['code']; break; case 3: $parent['url'] = "index.php?g=home&m=article&a=page&code=" . $cfg['code']; break; case 4: $parent['url'] = "index.php?g=home&m=goods&a=glist&id=" . $parent['id']; break; } } $sql = "SELECT id,name,type,code,redirect_url FROM " . $this->table('category') . " WHERE parent_id='" . $parent['id'] . "' ORDER BY created LIMIT " . $num; $parent['child'] = $this->getALL($sql); if ($parent['child']) { foreach ($parent['child'] as $k => $v) { $parent['child'][$k]['name'] = hy_dig_filter($v['name']); if ($_GET['code'] == $v['code'] || $cfg['code'] == $v['code']) { $parent['child'][$k]['current'] = 1; } if (REWRITE == 1) { switch ($v['type']) { case 1: $parent['child'][$k]['url'] = "/" . $v['code'] . "/article/index.html"; break; case 2: $parent['child'][$k]['url'] = "/" . $v['code'] . "/article/photo.html"; break; case 3: $parent['child'][$k]['url'] = "/" . $v['code'] . "/article/page.html"; break; case 4: $parent['child'][$k]['url'] = "/goods/list.html?id=" . $v['id']; break; } } else { switch ($v['type']) { case 1: $parent['child'][$k]['url'] = "index.php?g=home&m=article&a=index&code=" . $v['code']; break; case 2: $parent['child'][$k]['url'] = "index.php?g=home&m=article&a=photo&code=" . $v['code']; break; case 3: $parent['child'][$k]['url'] = "index.php?g=home&m=article&a=page&code=" . $v['code']; break; case 4: $parent['child'][$k]['url'] = "index.php?g=home&m=goods&a=glist&id=" . $v['id']; break; } } $parent['child'][$k]['url'] = $parent['child'][$k]['url'] == '' ? $v['redirect_url'] : $parent['child'][$k]['url']; } } } return $parent; }
/** * 获取版块详细的信息 * @param $id * @return */ public function getGroup($id) { $sql = "SELECT * FROM " . $this->table('block') . " WHERE id = '" . $id . "'"; $result = $this->getRow($sql); if ($result) { //获取相册集 $sql = "SELECT p.* FROM " . $this->table('block_content') . " as p WHERE p.block_id = '" . $id . "'"; $photo = $this->getAll($sql); foreach ($photo as $k => $v) { $arr = hy_dig_filter($v['title'], 3); $photo[$k]['title'] = $arr[0]; } $result['photo'] = $photo; return $result; } else { return $result = array(); } }
public function get_goods_info($id) { $sql = "select * from " . $this->table('store_goods') . " where id=" . $id; $data['msg'] = $this->getRow($sql); if ($data['msg']) { $data['msg']['title'] = hy_dig_filter($data['msg']['title'], 1); $data['msg']['author'] = hy_dig_filter($data['msg']['author'], 1); $data['msg']['content'] = hy_dig_filter($data['msg']['content'], 1); } // $sql = "select * from ".$this->table('album_photos')." where aid=".$id; // $data['photo'] = $this->getAll($sql); // if($data['photo']) // { // $arr = array(); // foreach($data['photo'] as $kk => $vv) // { // $arr[] = "'http://".$_SERVER['HTTP_HOST'].$vv['original_pic']."'"; // $data['photo'][$kk]['original_pic'] = "http://".$_SERVER['HTTP_HOST'].$vv['original_pic']; // } // $data['pic'] = implode(",", $arr); // } return $data; }