/** * 内容页SEO信息 * @param int $data * @param int $page * @return array */ function showSeo($data, $page = 1) { $cats = get_category_data(); $cat = $cats[$data['catid']]; $listseo = listSeo($cat); $meta_title = $meta_keywords = $meta_description = ''; $meta_title = (isset($data['stitle']) && $data['stitle'] ? $data['stitle'] . '-' . $data['title'] . '-' : $data['title'] . '-' . ($page > 1 ? lang('fun-1', array('1' => $page)) . '-' : '')) . $listseo['meta_title']; $meta_keywords = empty($data['keywords']) ? $listseo['meta_keywords'] : $data['keywords'] . ',' . $listseo['meta_keywords']; $meta_description = empty($data['description']) ? $listseo['meta_description'] : $data['description']; return array('meta_title' => $meta_title, 'meta_keywords' => $meta_keywords, 'meta_description' => $meta_description); }
/** * 删除 */ 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); }
/** * 解析标签list */ protected function _listdata($param) { $_param = explode(' ', $param); $param = array(); foreach ($_param as $p) { $mark = strpos($p, '='); if ($p && $mark !== false) { $var = substr($p, 0, $mark); $val = substr($p, $mark + 1); if (isset($var) && $var) { $param[$var] = $val; } } } $system = $fields = $_fields = $not = $in = $or = $between = $like = array(); $dbcache = isset($param['cache']) ? (int) $param['cache'] : 0; unset($param['cache']); if (is_array($param)) { foreach ($param as $key => $val) { //参数归类 if (in_array($key, array('return', 'more', 'page', 'urlrule', 'num', 'join', 'on', 'order', 'table', 'pagesize', 'pagerule', 'action', 'tag', 'extend', 'site', 'form', 'fields'))) { $system[$key] = $val; } else { if (substr($key, 0, 3) == 'NOT') { $key = substr($key, 3); $not[] = $key; } elseif (substr($key, 0, 2) == 'OR') { $key = substr($key, 2); $or[] = $key; } elseif (substr($key, 0, 2) == 'IN') { $key = substr($key, 2); $in[] = $key; } elseif (substr($key, 0, 2) == 'BW') { $key = substr($key, 2); $between[] = $key; } elseif (substr($key, 0, 4) == 'LIKE') { $key = substr($key, 4); $like[] = $key; } $fields[$key] = $val; $_fields[] = $key; } } } $where = ''; //设置站点id $system['site'] = !isset($system['site']) || empty($system['site']) ? App::get_site_id() : $system['site']; //Action判断 if (isset($system['action']) && $system['action'] == 'position') { //推荐位 $data = position($system['site'], $fields['id'], isset($fields['catid']) ? $fields['catid'] : 0, isset($system['num']) ? $system['num'] : 0); if ($data) { $db = Controller::model('content'); foreach ($data as $i => $t) { if ($t['contentid']) { $row = $db->db->where('id', $t['contentid'])->get('content_' . $system['site'])->row_array(); $data[$i] = $t + $row; } } } if (isset($system['return']) && $system['return'] && $system['return'] != 't') { return array('return_' . $system['return'] => $data, 'total_' . $system['return'] => count($data)); } return array('return' => $data, 'total' => count($data)); } elseif (isset($system['action']) && $system['action'] == 'keywords') { //搜索关键字 $search = Controller::model('search'); $num = $system['num'] ? (int) $system['num'] : 5; if (isset($system['order']) && $system['order']) { $order = null; $orders = explode(',', $system['order']); foreach ($orders as $t) { list($_field, $_order) = explode('_', $t); if (in_array($_field, array('id', 'keywords', 'addtime', 'total'))) { $_orderby = isset($_order) && strtoupper($_order) == 'ASC' ? 'ASC' : 'DESC'; $order .= '`' . $_field . '` ' . $_orderby . ','; } } if (substr($order, -1) == ',') { $order = substr($order, 0, -1); } } else { $order = '`total` DESC'; } $data = $search->execute('select distinct keywords as title from ' . $search->prefix . 'search order by ' . $order . ' limit ' . $num, true, $dbcache); if (isset($system['return']) && $system['return'] && $system['return'] != 't') { return array('return_' . $system['return'] => $data, 'total_' . $system['return'] => count($data)); } return array('return' => $data, 'total' => count($data)); } elseif (isset($system['action']) && $system['action'] == 'sql') { // } elseif (isset($system['action']) && $system['action'] == 'relation') { if (isset($system['tag']) && $system['tag']) { //按关键字搜索 if (isset($fields['id']) && $fields['id']) { $where .= '`id`<>' . (int) $fields['id']; } $tags = @explode(',', $system['tag']); $kwhere = $k = NULL; foreach ($tags as $tag) { if ($tag) { if (empty($k)) { $kwhere .= '`title` like "%' . $tag . '%"'; } else { $kwhere .= ' OR `title` like "%' . $tag . '%"'; } $k = 1; } } if ($kwhere) { $where .= ' AND (' . $kwhere . ')'; } unset($k, $tags, $tag, $kwhere, $system['table'], $fields['id']); } else { //手动设置的相关文章 $data = $this->relation($fields['id'], $system['num']); if (isset($system['return']) && $system['return'] && $system['return'] != 't') { return array('return_' . $system['return'] => $data, 'total_' . $system['return'] => count($data)); } return array('return' => $data, 'total' => count($data)); } } elseif (isset($system['action']) && $system['action'] == 'field') { //字段信息 $mods = get_model_data(); $mod = $mods[$fields['modelid']]; $data = array(); if ($mod['fields']) { foreach ($mod['fields']['data'] as $t) { if ($fields['name'] == $t['field']) { //加载字段配置文件 App::auto_load('fields'); $data_fields = ''; $data_fields .= '<tr id="fine_' . $t['field'] . '">'; $data_fields .= '<th>' . (isset($t['not_null']) && $t['not_null'] ? '<font color="red">*</font> ' : '') . $t['name'] . ':</th>'; $data_fields .= '<td>'; $func = 'content_' . $t['formtype']; //防止出错,把字段内容转换成数组格式 $content = array($fields['value']); $content = var_export($content, true); $field_config = var_export($t, true); if (function_exists($func)) { eval("\$data_fields .= " . $func . "(" . $t['field'] . ", " . $content . ", " . $field_config . ");"); } $data_fields .= $t['tips'] ? '<div class="onShow">' . $t['tips'] . '</div>' : ''; $data_fields .= '<span id="ck_' . $t['field'] . '"></span>'; $data_fields .= '</td>'; $data_fields .= '</tr>'; $data[0]['form'] = $data_fields; if ($t['setting']) { $c = string2array($t['setting']); if ($c['content']) { $select = explode(PHP_EOL, $c['content']); $vdata = array(); foreach ($select as $i => $c) { list($n, $v) = explode('|', $c); $vdata[trim($n)] = $v === null ? trim($n) : trim($v); } $data[0]['data'] = $vdata; } } } } } if (isset($system['return']) && $system['return'] && $system['return'] != 't') { return array('return_' . $system['return'] => $data); } return array('return' => $data); } //主表判断 if (isset($system['table']) && $system['table']) { $table = $system['table']; } elseif (isset($system['form']) && $system['form']) { $table = 'form_' . $system['site'] . '_' . $system['form']; } else { $table = 'content'; } //加载Model实例 if (strpos($table, '.') !== false) { list($plugin, $table) = explode('.', $table); $db = App::plugin_model($plugin, $table); } else { $db = Controller::model('content'); if (strpos($table, 'content') === 0) { $table .= '_' . $system['site']; } } $table = $db->prefix . $table; $db->table_name = $table; $table_join = $table_data = $table_fields = $table_join_fields = $table_data_fields = $arrchilds = null; $_table_fields = $db->get_table_fields(); $table_fields = array_intersect($_fields, $_table_fields); //status判断 if (in_array('status', $_table_fields)) { $where .= ($where ? ' AND ' : ' ') . ' `' . $table . '`.`status`=1'; } if (isset($fields['catid']) && $fields['catid']) { //栏目信息 $cats = get_category_data($system['site']); $cat = $cats[$fields['catid']]; } if (isset($system['join']) && $system['join'] && $system['on']) { //JOIN联合查询 $table_join = $system['join']; //加载Model实例 if (strpos($table_join, '.') !== false) { list($plugin, $table_join) = explode('.', $table_join); $db_join = App::plugin_model($plugin, $table_join); } else { $db_join = Controller::model($table_join); } $_table_join_fields = $db_join->get_table_fields(); $table_join_fields = array_intersect($_fields, $_table_join_fields); foreach ($table_join_fields as $k => $c) { if (in_array($c, $table_fields)) { unset($table_join_fields[$k]); } } $table_join = $db->prefix . $table_join; } if (isset($system['more']) && $system['more']) { //附表 $model = null; if ($table == $db->prefix . 'content_' . $system['site']) { $models = get_model_data('content', $system['site']); if (isset($fields['catid']) && $fields['catid'] && isset($cat) && $cat) { $model = $models[$cat['modelid']]; } elseif (isset($fields['modelid']) && $fields['modelid']) { $model = $models[$fields['modelid']]; } } elseif ($table == $db->prefix . 'member' && isset($fields['modelid']) && $fields['modelid']) { $cache = new cache_file(); $models = $cache->get('model_member'); $model = $models[$fields['modelid']]; } if ($model) { $table_data = $model['tablename']; $db_data = Controller::model($table_data); $_table_data_fields = $db_data->get_table_fields(); $table_data_fields = array_intersect($_fields, $_table_data_fields); foreach ($table_data_fields as $k => $c) { if (in_array($c, $table_fields)) { unset($table_data_fields[$k]); } } $table_data = $db->prefix . $table_data; } } //WHERE整合 $fieldsAll = array($table => $table_fields, $table_join => $table_join_fields, $table_data => $table_data_fields); foreach ($fieldsAll as $_table => $t) { if (is_array($t)) { foreach ($t as $f) { if ($fields[$f] == '') { continue; } $and_or = in_array($f, $or) ? 'OR' : 'AND'; //栏目条件根据子栏目来做为条件 if ($f == 'catid' && isset($fields['catid']) && $fields['catid']) { if (isset($cat) && $cat && $cat['child']) { $arrchilds = $cat['arrchilds']; $not_in = in_array($f, $not) ? 'NOT IN' : 'IN'; $where .= ' ' . $and_or . ' `' . $_table . '`.`catid` ' . $not_in . ' (' . $arrchilds . ')'; } elseif (strpos($fields['catid'], ',') !== false) { $not_in = in_array($f, $not) ? 'NOT IN' : 'IN'; $where .= ' ' . $and_or . ' `' . $_table . '`.`catid` ' . $not_in . ' (' . $fields['catid'] . ')'; } else { $not_in = in_array($f, $not) ? '<>' : '='; $where .= ' ' . $and_or . ' `' . $_table . '`.`catid`' . $not_in . $fields['catid']; } } elseif ($f == 'thumb' && isset($fields['thumb']) && is_numeric($fields['thumb'])) { $where .= $fields['thumb'] ? ' ' . $and_or . ' `' . $_table . '`.`thumb`<>""' : ' ' . $and_or . ' `' . $_table . '`.`thumb`=""'; } else { $not_in = in_array($f, $in) ? 'IN' : ''; $not_in = in_array($f, $not) ? 'NOT IN' : $not_in; if (in_array($f, $between)) { if (strpos($fields[$f], '_') !== false) { list($v1, $v2) = explode('_', $fields[$f]); $v1 = is_numeric($v1) ? $v1 : '"' . addslashes($v1) . '"'; $v2 = is_numeric($v2) ? $v2 : '"' . addslashes($v2) . '"'; $where .= ' ' . $and_or . ' `' . $_table . '`.`' . $f . '` BETWEEN ' . $v1 . ' AND ' . $v2; } elseif (strpos($fields[$f], ',') !== false) { list($v1, $v2) = explode(',', $fields[$f]); $v1 = is_numeric($v1) ? $v1 : '"' . addslashes($v1) . '"'; $v2 = is_numeric($v2) ? $v2 : '"' . addslashes($v2) . '"'; $where .= ' ' . $and_or . ' `' . $_table . '`.`' . $f . '` BETWEEN ' . $v1 . ' AND ' . $v2; } else { continue; } } elseif ($not_in) { $where .= ' ' . $and_or . ' `' . $_table . '`.`' . $f . '` ' . $not_in . ' (' . $fields[$f] . ')'; } elseif (in_array($f, $like)) { $value = addslashes($fields[$f]); $where .= ' ' . $and_or . ' `' . $_table . '`.`' . $f . '` LIKE "' . $value . '"'; } else { $value = is_numeric($fields[$f]) ? $fields[$f] : '"' . addslashes($fields[$f]) . '"'; $where .= ' ' . $and_or . ' `' . $_table . '`.`' . $f . '`=' . $value . ''; } } } } } if ($where) { if (substr($where, 0, 4) == ' AND') { $where = ' WHERE' . substr($where, 4); } elseif (substr($where, 0, 3) == ' OR') { $where = ' WHERE' . substr($where, 3); } else { $where = ' WHERE' . $where; } //对WHERE延展 if (isset($system['extend']) && substr($system['extend'], 0, 6) == 'WHERE.') { $where .= ' ' . str_replace('-', ' ', substr($system['extend'], 6)); unset($system['extend']); } } //延展list $extend = ''; if (isset($system['extend']) && $system['extend']) { $extend = ' ' . str_replace('-', ' ', $system['extend']); } //FROM整合 $from = 'FROM ' . $table; if ($table_data) { $from .= ' LEFT JOIN ' . $table_data . ' ON `' . $table . '`.`' . $db->get_primary_key() . '`=`' . $table_data . '`.`' . $db_data->get_primary_key() . '`'; } if ($table_join && $system['on']) { $_join_name = null; if (in_array($system['on'], $_table_fields)) { $_join_name = $table; } elseif (isset($_table_data_fields) && in_array($system['on'], $_table_data_fields)) { $_join_name = $table_data; } if ($_join_name) { $from .= ' LEFT JOIN ' . $table_join . ' ON `' . $table_join . '`.`' . $db_join->get_primary_key() . '`=`' . $_join_name . '`.`' . $system['on'] . '`'; } } //ORDER排序 $order = ''; if (isset($system['order']) && $system['order']) { if (strtoupper($system['order']) == 'RAND()') { $order .= ' ORDER BY RAND()'; } else { $orders = explode(',', $system['order']); foreach ($orders as $t) { list($_field, $_order) = explode('_', $t); $_name = null; if (in_array($_field, $_table_fields)) { $_name = $table; } elseif (isset($_table_data_fields) && in_array($_field, $_table_data_fields)) { $_name = $table_data; } elseif (isset($_table_join_fields) && in_array($_field, $_table_join_fields)) { $_name = $table_join; } $_orderby = isset($_order) && strtoupper($_order) == 'ASC' ? 'ASC' : 'DESC'; if ($_name) { $order .= ' `' . $_name . '`.`' . $_field . '` ' . $_orderby . ','; } } if (substr($order, -1) == ',') { $order = ' ORDER BY' . substr($order, 0, -1); } } } //limit与分页 $limit = ''; if (isset($system['num']) && $system['num']) { $limit = ' LIMIT ' . $system['num']; } elseif (isset($system['page'])) { $pageurl = ''; $system['page'] = (int) $system['page'] ? (int) $system['page'] : 1; if ($system['urlrule']) { $pageurl = str_replace(array('_page_', '[page]'), '{page}', $system['urlrule']); $pagesize = $system['pagesize'] ? $system['pagesize'] : (isset($cat['pagesize']) ? $cat['pagesize'] : 10); } elseif ($cat) { $pageurl = getCaturl($cat, '{page}'); $pagesize = $system['pagesize'] ? $system['pagesize'] : $cat['pagesize']; } else { $pagesize = $system['pagesize'] ? $system['pagesize'] : 10; $pageurl = '{page}'; } $sql = 'SELECT count(*) AS total ' . $from . ' ' . $where; $count = $db->execute($sql, false, $dbcache); $total = $count['total']; $pagelist = Controller::instance('pagelist'); $pagelist->loadconfig($system['pagerule'] ? $system['pagerule'] : 'pagerule'); $start_id = $pagesize * ($system['page'] - 1); $limit = ' LIMIT ' . $start_id . ',' . $pagesize; $pagelist = $pagelist->total($total)->url($pageurl)->num($pagesize)->page($system['page'])->output(); } //查询字段筛选 if (isset($system['fields']) && $system['fields']) { $fields_array = explode(',', $system['fields']); //字段参数转为数组 $select_array = array(); foreach ($fields_array as $t) { //遍历字段参数数组,筛选无用字段、字段附加表前缀 if (in_array($t, $_table_fields)) { //主表字段 $select_array[] = '`' . $table . '`.`' . $t . '`'; } elseif (isset($_table_data_fields) && in_array($t, $_table_data_fields)) { //附表字段 $select_array[] = '`' . $table_data . '`.`' . $t . '`'; } elseif (isset($_table_join_fields) && in_array($t, $_table_join_fields)) { //联合表字段 $select_array[] = '`' . $table_join . '`.`' . $t . '`'; } } $select_field = empty($select_array) ? ' * ' : ' ' . implode(',', $select_array) . ' '; //组合成sql查询格式 unset($select_array, $fields_array); } else { $select_field = ' * '; } //查询结果 $sql = 'SELECT' . $select_field . $from . $where . $order . $limit . $extend; $data = $db->execute($sql, true, $dbcache); //释放变量 unset($_param, $param, $par, $p, $fields, $_fields, $not, $in, $or, $between, $dbcache, $like); unset($table, $db, $table_join, $table_data, $table_fields, $table_join_fields, $table_data_fields, $arrchilds, $_table_fields); unset($fieldsAll, $_table_data_fields, $cache, $db_join, $cats, $cat, $models, $model, $db_data, $where, $order, $from); if (isset($system['return']) && $system['return'] && $system['return'] != 't') { return array('sql_' . $system['return'] => $sql, 'total_' . $system['return'] => isset($total) ? $total : count($data), 'return_' . $system['return'] => $data, 'pagelist_' . $system['return'] => $pagelist); } return array('pagelist' => $pagelist, 'return' => $data, 'sql' => $sql, 'total' => isset($total) ? $total : count($data)); }
/** * 相关文章列表 */ protected function relation($id, $num = 10, $more = 0) { if (empty($id)) { return false; } $db = Controller::model('content'); $row = $db->from('content_' . App::get_site_id() . '_extend')->where('id=' . (int) $id)->select(false); if (empty($row) || empty($row['relation'])) { return null; } $ids = $row['relation']; $num = $num ? $num : 10; if ($more) { $cats = get_category_data(App::get_site_id()); $models = get_model_data('content', App::get_site_id()); $table = $models[$cats[$row['catid']]['modelid']]['tablename']; if ($table) { $sql = 'select * from `' . $this->ci->db->dbprefix('content_' . App::get_site_id()) . '` as a left join `' . $this->ci->db->dbprefix($table) . '` as b on a.id=b.id where a.id IN (' . $ids . ') order by a.listorder desc, a.updatetime desc limit ' . $num; $data = $this->ci->db->query($sql)->result_array(); return $data; } } $data = $db->from('content_' . App::get_site_id())->where('id in (' . $ids . ')')->order('listorder desc, updatetime desc')->limit($num)->select(); return $data; }
/** * 删除栏目及数据 * @param int $catid * @return boolean */ public function del($catid) { if (empty($catid)) { return false; } $this->repair($catid); //修复该栏目数据 $catids = $this->child($catid, true); if (empty($catids)) { return false; } $catids = substr($catids, -1) == ',' ? substr($catids, 0, -1) : $catids; //删除栏目数据 $this->delete('catid IN (' . $catids . ')'); //查询内容id集合 $ids = ''; $data = $this->execute('SELECT id FROM `' . $this->prefix . 'content_' . App::get_site_id() . '` WHERE `catid` IN (' . $catids . ')'); if ($data) { //删除内容扩展 $this->query('DELETE FROM `' . $this->prefix . 'content_' . App::get_site_id() . '_extend` WHERE `catid` IN (' . $catids . ')'); foreach ($data as $t) { $ids .= $t['id'] . ','; } $ids = substr($ids, -1) == ',' ? substr($ids, 0, -1) : $ids; $cats = get_category_data(); $catids = explode(',', $catids); foreach ($catids as $catid) { //删除内容表数据 if ($cats[$catid]['tablename']) { $this->query('DELETE FROM `' . $this->prefix . 'content_' . App::get_site_id() . '` WHERE `catid`=' . $catid); $this->query('DELETE FROM `' . $this->prefix . $cats[$catid]['tablename'] . '` WHERE `catid`=' . $catid); } //删除关联表单数据 $form = $this->execute('SELECT * FROM `' . $this->prefix . 'model` WHERE `joinid`=' . (int) $cats[$catid]['modelid']); if ($form) { foreach ($form as $t) { $this->query('DELETE FROM `' . $this->prefix . $t['tablename'] . '` WHERE `cid` IN (' . $ids . ')'); } } } } return true; }
private function getSQL($param, $kw, $kw_fields, $kw_or) { $site_id = App::get_site_id(); $tablename = 'content_' . $site_id; $this->set_table_name($tablename); //���õ�ǰģ��Ϊ����ģ�� $_fields = $this->get_table_fields(); if (is_array($param) && $param) { $where_or = $param_fields = $_data_fields = $table_fields = $data_fields = array(); $category = get_category_data(); //��Ŀ��� foreach ($param as $key => $val) { //������� if (substr($key, 0, 2) == 'OR') { unset($param[$key]); $key = substr($key, 2); $where_or[] = $key; $param[$key] = $val; } } if (isset($param['modelid']) && $param['modelid']) { $cache = get_model_data(); //����ģ����� $table = $cache[$param['modelid']]['tablename']; if ($table) { $this->set_table_name($table); $_data_fields = $this->get_table_fields(true); } } elseif (isset($param['catid']) && $param['catid']) { $table = $category[$param['catid']]['tablename']; if ($table) { $this->set_table_name($table); $_data_fields = $this->get_table_fields(true); } } $more = isset($param['more']) && $param['more'] && $table && $_data_fields ? true : false; foreach ($param as $k => $v) { if (in_array($k, $_fields)) { $table_fields[] = $k; } elseif (isset($_data_fields) && in_array($k, $_data_fields)) { $more = true; $data_fields[] = $k; } } } else { if (empty($kw)) { return false; } } $where = '`' . $this->prefix . $tablename . '`.`status`=1'; if ($kw) { $kw = addslashes($kw); if ($kw_fields) { $kw_fields = explode(',', $kw_fields); $kw_where = ''; $kw_count = 0; foreach ($kw_fields as $f) { $andor = empty($kw_count) ? '' : ($kw_or ? ' OR' : ' AND'); if (in_array($f, $_fields)) { //���� $kw_where .= $andor . ' `' . $this->prefix . $tablename . '`.`' . $f . '` LIKE \'%' . $kw . '%\''; } elseif (isset($table) && isset($_data_fields) && in_array($f, $_data_fields)) { //���� $kw_where .= $andor . ' `' . $this->prefix . $table . '`.`' . $f . '` LIKE \'%' . $kw . '%\''; $more = true; } $kw_count = 1; } $where .= ' AND (' . $kw_where . ')'; } else { $where .= ' AND `' . $this->prefix . $tablename . '`.`title` LIKE \'%' . $kw . '%\''; } } if (isset($param['modelid']) && $param['modelid']) { $where .= ' AND `' . $this->prefix . $tablename . '`.`modelid`=' . (int) $param['modelid']; } if (isset($param['catid']) && $param['catid']) { $cat = $category[$param['catid']]; $where .= $cat['child'] ? ' AND `' . $this->prefix . $tablename . '`.`catid` IN (' . $cat['arrchilds'] . ')' : ' AND `' . $this->prefix . $tablename . '`.`catid`=' . (int) $param['catid']; } unset($param['catid'], $param['modelid']); if ($table_fields) { foreach ($table_fields as $field) { if (isset($param[$field]) && $param[$field]) { $value = $param[$field]; $andor = is_array($where_or) && in_array($field, $where_or) ? 'OR' : 'AND'; if (is_numeric($value)) { $where .= ' ' . $andor . ' `' . $this->prefix . $tablename . '`.`' . $field . '`=' . $value; } elseif (substr($value, 0, 1) == '%' && substr($value, -1, 1) == '%') { $where .= ' ' . $andor . ' `' . $this->prefix . $tablename . '`.`' . $field . '` LIKE \'' . $value . '\''; } else { $where .= ' ' . $andor . ' `' . $this->prefix . $tablename . '`.`' . $field . '`=\'' . $param[$field] . '\''; } } } } if ($data_fields && $table && $more) { foreach ($data_fields as $field) { if (isset($param[$field]) && $param[$field]) { $value = $param[$field]; $andor = is_array($where_or) && in_array($field, $where_or) ? 'OR' : 'AND'; if (is_numeric($value)) { $where .= ' ' . $andor . ' `' . $this->prefix . $table . '`.`' . $field . '`=' . $value; } elseif (substr($value, 0, 1) == '%' && substr($value, -1, 1) == '%') { $where .= ' ' . $andor . ' `' . $this->prefix . $table . '`.`' . $field . '` LIKE \'' . $value . '\''; } else { $where .= ' ' . $andor . ' `' . $this->prefix . $table . '`.`' . $field . '`=\'' . $param[$field] . '\''; } } } } $from = $more && $table ? $this->prefix . $tablename . ' LEFT JOIN ' . $this->prefix . $table . ' ON `' . $this->prefix . $tablename . '`.`id`=`' . $this->prefix . $table . '`.`id`' : $this->prefix . $tablename . ''; $sql = 'SELECT * FROM ' . $from . ' WHERE ' . $where . ' ORDER BY `' . $this->prefix . $tablename . '`.`updatetime` DESC LIMIT 500'; return array($sql, $from); }
error_log(' Generate profile (f): ' . date('d m Y H:i:s')); echo $json_data_profile; error_log(' Generate Results (f): ' . date('d m Y H:i:s')); die; } /***** VALIDATIONS ****/ $message = array('message_code' => NULL, 'description' => NULL); $category = NULL; if (!(isset($_GET['username']) and !empty($_GET['username']))) { $message['message_code'] = 1; $message['description'] = 'Profile not found'; } elseif (!(isset($_GET['category']) and !empty($_GET['category']))) { $message['message_code'] = 2; $message['description'] = 'Category not found'; } else { $category = get_category_data($_GET['category']); if (empty($category)) { $message['message_code'] = 2; $message['description'] = 'Category not found'; } } if ($message['message_code'] !== NULL) { echo json_encode($message); die; } /***** END - VALIDATIONS ****/ function get_category_data($category_slug) { $query = 'SELECT id_category, category FROM instagram_category WHERE category = \'$1\';'; $categories = db_query($query, array($category_slug)); if ($fila = mysql_fetch_assoc($categories)) {
<?php loadProductUiHelpers(); $base_category = get_category_data($node->taxonomy); $category_key = array_shift(array_keys($node->taxonomy)); $category = $node->taxonomy[$category_key]->name; // find out images for this node. $nodeImgs = $node->content['field_image_cache']['field']['items'][0]["#node"]->field_image_cache; if ($nodeImgs) { $main_img = $nodeImgs[0]['view']; $thumbs = ""; $fulls = ""; foreach ($nodeImgs as $item) { // loop through all images and generate thumbs for the left column //print $item['view']; $patterns = array("/\\.jpg\$/", "/\\./"); $replace = array('', '-'); $className = preg_replace($patterns, $replace, $item['filename']); $thumbs .= l(theme('imagecache', 'page_thumb', $item['filepath']), $item['filepath'], array('html' => TRUE, 'attributes' => array('class' => $className))); $fulls .= l(theme('imagecache', 'product_full', $item['filepath']), $item['filepath'], array('html' => TRUE, 'attributes' => array('class' => "prettyPhoto", "id" => $className))); } } //echo "<pre>"; //print_r($node); //echo "</pre>"; ?> <div class="content-filters clearfix"> <div class="filter left"> <span class="input_wrapper"><?php print learn_taxonomy_ancestry(10);