function __construct() { parent::__construct(); $this->model = new PbModel(); $this->allowed_search = array("info" => "news", "offer" => "offer", "product" => "product", "yellow_page" => "company"); if (isset($_GET['module'])) { $this->module = trim(strtolower($_GET['module'])); } $this->option = $this->module; if (!empty($this->module) && !in_array($this->module, $this->allowed_search)) { flash(); } $search_word = !empty($_GET['q']) ? htmlspecialchars(trim($_GET['q']), ENT_QUOTES) : ''; switch ($this->module) { case "company": $this->condition[] = 'status=1'; if (!empty($search_word)) { $this->condition[] = "name LIKE '%{$search_word}%'"; } $this->extra = ",name AS title,description AS content"; break; case "offer": $condition[] = 'status=1'; if (!empty($search_word)) { $this->condition[] = "title LIKE '%{$search_word}%'"; } $this->option = "offer"; $this->module = "trade"; break; case "product": $condition[] = 'status=1'; if (!empty($search_word)) { $this->condition[] = "name LIKE '%{$search_word}%'"; } $this->extra = ",name AS title"; break; default: $condition[] = 'status=1'; if (!empty($search_word)) { $this->condition[] = "title LIKE '%{$search_word}%'"; } break; } $search_controller = new PbController(); $this->model_name = htmlspecialchars($this->module, ENT_QUOTES); $this->model_name = strtolower($search_controller->pluralize(ucwords($this->model_name))); $this->view->setTemplateDir(PHPB2B_ROOT . "templates/wap/3g" . DS, 'wap'); $this->view->setCompileDir(DATA_PATH . "templates_c" . DS . $this->lang . DS . "wap" . DS . "3g" . DS); }
} } if ($i > 0) { flash("success"); } else { flash(); } } // @unlink($attachment->out_file_full_path); break; case "export": require_once LIB_PATH . "excel_export.class.php"; $excel = new excel_xml(); $header_style = array('bold' => 1, 'size' => '10', 'color' => '#FFFFFF', 'bgcolor' => '#4F81BD'); $excel->add_style('header', $header_style); $table_name = PbController::pluralize($_POST['tb_name']); $record_amount = intval($_POST['record_amount']); if (empty($record_amount)) { $record_amount = 1000; } $result = $pdb->GetArray("SELECT * FROM " . $tb_prefix . $table_name . " ORDER BY id DESC LIMIT {$record_amount};"); $xml = simplexml_to_array(simplexml_load_file(DATA_PATH . "exchange" . DS . $_POST['tb_name'] . ".xml", "SimpleXMLElement", LIBXML_NOCDATA)); $rows = array_keys($xml['items']); $excel->add_row($xml['items'], 'header'); foreach ($result as $key => $val) { foreach ($rows as $key1 => $val1) { $cols[$val1] = htmlspecialchars($val[$val1]); } $excel->add_row($cols); } $excel->create_worksheet($_POST['tb_name']);
/** * [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved. * The contents of this file are subject to the License; you may not use this file except in compliance with the License. * * @version $Revision: 2075 $ */ function smarty_block_getdata($params, $content, Smarty_Internal_Template $sTemplate, &$repeat) { $conditions = $orderbys = array(); $mysql_limit = $mysql_orderby = $image_col = $_seperate = ''; $target = "_blank"; extract($params); if (!isset($params['assign'])) { $assign = 'row'; } if (!empty($params['name'])) { $assign = trim($params['name']); } $C = new PbController(); $M = new PbModel(); $M->condition = ''; //Initial any last conditions $_table = $params['module']; switch ($params['module']) { case "offer": case "trade": $_table = "trade"; break; case "fair": case "expo": $_table = "expo"; break; case "announce": $_table = "announcement"; break; case "ads": $_table = "adses"; break; case "adword": $_table = "spread"; break; case "price": $_table = "productprice"; break; case "adses": break; default: break; } if (method_exists($sTemplate, 'get_template_vars')) { $_bindex = $sTemplate->getTemplateVars('_bindex'); } else { $_bindex = $sTemplate->getVariable('_bindex')->value; } if (!$_bindex) { $_bindex = array(); } if (isset($params['name'])) { if (!isset($_bindex[$params['name']])) { $_bindex[$params['name']] = 1; } else { $_bindex[$params['name']]++; } } $sTemplate->assign('_bindex', $_bindex); if (!isset($sTemplate->block_data)) { $sTemplate->block_data = array(); } $iTags = count($sTemplate->_tag_stack); /** * set condition */ $limit = $offset = 0; if (isset($params['row'])) { $limit = $params['row']; } if (isset($params['start'])) { $offset = $params['start']; } if (isset($_GET['pos'])) { $_pos = intval($_GET['pos']); $offset = ceil($_pos / $limit) * $row; } if (!empty($params['flag'])) { $conditions[] = "flag='" . $params['flag'] . "'"; } if ($_table == "industry" or $_table == "area") { if (isset($params['parentid'])) { if (!empty($params['parentid'])) { $conditions['parentid'] = "parent_id='" . intval($params['parentid']) . "' OR id=" . intval($params['parentid']); } else { $conditions['parentid'] = "parent_id=0"; } } else { $conditions['parentid'] = "parent_id=0"; } } if (!empty($params['level'])) { if ($_table == "newstype") { $conditions[] = "level_id='" . $params['level'] . "'"; } else { $conditions[] = "level='" . $params['level'] . "'"; } } if (isset($params['type'])) { $type = explode(",", $params['type']); $type = array_unique($type); foreach ($type as $val) { switch ($val) { case 'image': if ($module == "friendlink") { $image_col = "logo"; } else { $image_col = "picture"; } $conditions[] = "{$image_col}!=''"; break; case 'hot': $orderbys[] = "hits DESC"; break; case 'commend': $conditions[] = "if_commend='1'"; break; default: break; } } } if (isset($params['exclude'])) { $conditions[] = $M->getExcludeIds($params['exclude']); } if (isset($params['include'])) { $conditions[] = $M->getIncludeIds($params['include']); } if (isset($params['orderby'])) { $orderbys[] = trim($params['orderby']); } if (!empty($row) && $row != 'all' && $row != -1) { $M->setLimitOffset($offset, $limit); $mysql_limit = $M->getLimitOffset(); } if (!empty($params['limit'])) { $mysql_limit = " " . trim($params['limit']); } if (!empty($_GET['producttypeid'])) { $conditions[] = "type_id=" . intval($_GET['producttypeid']); } if (!empty($params['companyid'])) { $conditions[] = "company_id=" . intval($params['companyid']); } if (!empty($params['industryid'])) { $conditions[] = "industry_id=" . intval($params['industryid']); } if (!empty($params['typeid'])) { if ($_table == 'adses') { $conditions[] = "adzone_id=" . intval($params['typeid']); } else { $conditions[] = "type_id=" . intval($params['typeid']); } } if (empty($sTemplate->block_data[$iTags])) { # ************************************************************************ # Main content $M->setCondition($conditions); $M->setOrderby($orderbys); $sql = sprintf("SELECT * FROM %s%s %s %s %s", $M->table_prefix, $C->pluralize($_table), $M->getCondition(), $M->getOrderby(), $mysql_limit); $sTemplate->block_data[$iTags] = $M->GetArray($sql); //如果没有数据,那就不用再执行了(repeat) if (!$sTemplate->block_data[$iTags]) { return $repeat = false; } if (isset($stat)) { $_total_count = $M->dbstuff->GetOne(sprintf("SELECT count(*) FROM %s%s %s", $M->table_prefix, $C->pluralize($_table), $M->getCondition())); $sTemplate->assign('total_count', $_total_count); $sTemplate->assign("paging", array('total' => $_total_count)); } # End main content # ************************************************************************ } if (!$sTemplate->block_data[$iTags]) { $repeat = false; return ''; } if (!function_exists("smarty_function_the_url")) { require "function.the_url.php"; } $counts = count($sTemplate->block_data[$iTags]); if (list($key, $item) = each($sTemplate->block_data[$iTags])) { $_title = $_title_full = $_content = $_content_full = ''; $item['rownum'] = $key; $item['iteration'] = ++$key; if (!empty($item['url'])) { $url = $item['url']; } else { $url = smarty_function_the_url(array("do" => $module, "id" => $item['id'], "action" => 'detail')); } if ($module == "company") { $url = smarty_function_the_url(array("id" => $item['id'], "do" => "company", "userid" => $item['cache_spacename'])); } elseif ($module == "tag") { $url = smarty_function_the_url(array("do" => "product", "action" => 'lists', "q" => $item['name'])); } $item['url'] = $url; if (isset($item['title'])) { $_title = $item['name'] = $item['title']; } elseif (isset($item['name'])) { $_title = $item['title'] = $item['name']; } elseif (isset($item['subject'])) { $_title = $item['title'] = $item['subject']; } elseif (isset($item['word'])) { $_title = $item['title'] = $item['word']; } $_title_full = $_title; $item['title'] = $_title = strip_tags(pb_lang_split($_title)); $_title_full = strip_tags(pb_lang_split($_title_full)); if (!empty($titlelen)) { $_title = mb_substr($_title, 0, $titlelen); } if (isset($item['description'])) { $_content = $item['description']; } elseif (isset($item['content'])) { $_content = $item['content']; } if (isset($item['clicked'])) { $item['hits'] = $item['clicked']; } $_content_full = $_content; if (!empty($_content) && isset($infolen)) { $_content = mb_substr($_content, 0, $infolen); } if (isset($item['created'])) { $item['pubdate'] = df($item['created'], "m-d"); } elseif (isset($item['submit_time'])) { $item['pubdate'] = df($item['submit_time']); } if (!empty($params['sep'])) { $_seperate = $params['sep']; } $item['content'] = $_content = strip_tags(pb_lang_split($_content)); // if($seperate) $_title = ($key==$counts-1)?$_title:$_title.$seperate; $item['link'] = '<a title="' . $_title_full . '" href="' . $url . '" target="' . $target . '">' . $_title . '</a>' . $_seperate; $media_url = ''; if (!empty($item['picture'])) { $media_url = $item['picture']; if (!empty($media_url)) { $item['thumb'] = $item['src'] = pb_get_attachmenturl($media_url, '', 'small'); } } if (!empty($item['source_url'])) { $media_url = $item['source_url']; if (!empty($media_url)) { $item['thumb'] = $item['src'] = $media_url; } } if (isset($item['highlight'])) { $item['style'] = parse_highlight($item['highlight']); } $sTemplate->assign($assign, $item); $repeat = true; } else { $repeat = false; reset($sTemplate->block_data[$iTags]); if (isset($params['name'])) { unset($_bindex[$params['name']]); $sTemplate->assign('_bindex', $_bindex); } } if (!is_null($content)) { print $content; } if (!$repeat) { $sTemplate->block_data[$iTags] = array(); } }
$return["error"] = L("no_perm"); $return['msg'] = L("access_denied"); } ajax_exit($return); break; default: break; } } if (isset($_GET['action'])) { $action = trim($_GET['action']); switch ($action) { case "selection": $result = array(); if (in_array($_GET['module'], array("industry", "area"))) { $sql = "SELECT id AS region_id,name AS region_name FROM " . $tb_prefix . PbController::pluralize($_GET['module']) . " WHERE parent_id='" . intval($_GET['parent_id']) . "' AND available=1"; $result = $pdb->GetArray($sql); for ($i = 0; $i < count($result); $i++) { $result[$i]['region_name'] = pb_lang_split($result[$i]['region_name']); } } ajax_exit($result); break; case "checkusername": if (isset($_GET['username'])) { $result = call_user_func_array($action, array($_GET['username'])); if ($result == true) { $return["isError"] = 1; } else { $return["isError"] = 0; }
case "fair": $do = "expo"; $option = "fair"; break; case "offer": $option = "offer"; $do = "trade"; break; default: $option = $do; break; } $search_controller = new PbController(); $model_name = htmlspecialchars($do, ENT_QUOTES); uses($model_name); $model_name = $search_controller->pluralize(ucwords($model_name)); $model_object = new $model_name(); $model_object->initSearch(); $result = array(); if ($model_object->amount > 0) { $result = $model_object->Search($pos, $limit); } //lft cat nav switch ($do) { case "product": $typeoption = "productsort"; break; case "trade": $typeoption = "offertype"; break; default:
function lists() { global $time_start, $viewhelper, $pos, $smarty, $theme_name; $cache_types = cache_read("type"); $viewhelper->setTitle(L("advanced_search", 'tpl')); $module = trim(strtolower($_GET['module'])); if (in_array($module, $this->allowed_search)) { $tpl_file = "search/list"; setvar('highlight_str', $this->keyword); switch ($module) { case "fair": $module = "expo"; $option = "fair"; break; case "offer": $option = "offer"; $module = "trade"; break; default: $option = $module; break; } $search_controller = new PbController(); $model_name = htmlspecialchars($module, ENT_QUOTES); uses($model_name); $model_name = $search_controller->pluralize(ucwords($model_name)); $model_object = new $model_name(); $model_object->initSearch(); $result = array(); if ($model_object->amount > 0) { $result = $model_object->Search($pos, $this->displaypg); } //lft cat nav switch ($module) { case "product": $typeoption = "productsort"; break; case "trade": $typeoption = "offertype"; break; default: $typeoption = $module . "type"; break; } if ($module == "company") { $cache_options = cache_read('typeoption'); $types = $cache_options['manage_type']; } else { $types = $cache_types[$typeoption]; } if (!empty($types)) { setvar("cats", $types); } foreach ($this->allowed_search as $k => $v) { $modules[$v] = L(array_search($v, $this->allowed_search)); } ksort($modules); setvar("top_modules", $modules); setvar("current_module", $option); unset($modules[$option]); array_unshift($modules, L(array_search($option, $this->allowed_search))); setvar("modules", $modules); //similar require CLASS_PATH . "segment.class.php"; $segment = new Segments(); $search_q = $similar_result = ''; if (!empty($this->keyword)) { $similar_q = $segment->Split($this->keyword); } if (!empty($similar_q)) { $similar_result = $similar_q; } elseif (!empty($search_q)) { $similar_result = $model_object->GetArray("SELECT *,name AS title FROM " . $tb_prefix . "tags WHERE name like '%" . $search_q . "%' ORDER BY id DESC LIMIT 0,10"); } setvar("similar_search", $similar_result); setvar("items", $result); $from = $pos == 0 ? 0 : $pos + 1; setvar("paging", array('total' => $model_object->amount, 'from' => $from, 'to' => ($to = $pos + $this->displaypg) > $model_object->amount ? $model_object->amount : $to)); setvar("TimeSpend", number_format(getmicrotime() - $time_start, 3)); $tpl = $theme_name . DS . $option . DS . 'list' . $smarty->tpl_ext; $viewhelper->setTitle(L(array_search($option, $this->allowed_search), 'tpl')); if ($search_q) { $viewhelper->setTitle($search_q); } setvar("no_result_tip", L("no_search_result_for_you", "tpl", $search_q)); if (isset($_GET['typeid'])) { $viewhelper->setTitle($types[$_GET['typeid']]); } render($tpl_file); } else { unset($_GET); flash("record_not_exists"); } }
$condition[] = 'status=1'; if (!empty($search_word)) { $condition[] = "name LIKE '%{$search_word}%'"; } $extra = ",name AS title"; break; default: $condition[] = 'status=1'; if (!empty($search_word)) { $condition[] = "title LIKE '%{$search_word}%'"; } break; } $search_controller = new PbController(); $model_name = htmlspecialchars($do, ENT_QUOTES); $model_name = strtolower($search_controller->pluralize(ucwords($model_name))); if (!empty($_GET['id'])) { $id = intval($_GET['id']); $result = $pdb->GetRow("SELECT *" . $extra . " FROM " . $tb_prefix . $model_name . " WHERE id=" . $id); setvar("item", $result); $tpl_file = "wap/detail"; } else { $model_common = new PbModel(); $model_common->setCondition($condition); //pager $pagesize = 10; $page = isset($_GET["page"]) ? intval($_GET["page"]) : 1; $total = $pdb->GetOne("SELECT count(id) FROM " . $tb_prefix . $model_name . $model_common->getCondition()); $pagecount = ceil($total / $pagesize); if ($page > $pagecount) { $page = $pagecount;
/** * [PHPB2B] Copyright (C) 2007-2099, Ualink Inc. All Rights Reserved. * The contents of this file are subject to the License; you may not use this file except in compliance with the License. * * @version $Revision: 2214 $ */ function smarty_function_get($params, &$smarty) { $op = null; extract($params); global $tb_prefix, $pdb; if (empty($var)) { $var = "item"; } if (!empty($from)) { switch ($from) { case "market": $num = 4; if (isset($params['row'])) { $num = intval($params['row']); } $latest_commend_markets = $industry->GetArray("SELECT * FROM " . $tb_prefix . "markets WHERE if_commend='1' AND status='1' AND picture!='' ORDER BY id DESC LIMIT " . $num); $urls = $infos = $images = array(); if (!empty($latest_commend_markets)) { while (list($key, $val) = each($latest_commend_markets)) { $urls[] = $industry->getPermaLink($val['id'], null, 'market'); $infos[] = pb_lang_split($val['name']); $images[] = pb_get_attachmenturl($val['picture'], '', $size); } $items['url'] = implode("|", $urls); $items['info'] = implode("|", $infos); $items['image'] = implode("|", $images); $return = $items; } break; case "area": if (class_exists("Areas")) { $area = new Areas(); } else { uses("area"); $area = new Areas(); } $return = $area->getLevelAreas(); break; case "industry": //depth if (class_exists("Industries")) { $industry = new Industries(); $obj_controller = new Industry(); } else { uses("industry"); $industry = new Industries(); $obj_controller = new Industry(); } $return = $industry->getCacheIndustry(); break; case "type": if (!empty($name)) { //depth if (class_exists("Industries")) { $industry = new Industries(); $obj_controller = new PbController(); } else { uses("industry"); $industry = new Industries(); $obj_controller = new PbController(); } $name = $obj_controller->pluralize($name); $industry->findIt($name); $return = $industry->params['data'][1]; if (isset($multi)) { $return = $obj_controller->flatten_array($return); } if (empty($var)) { $var = "Items"; } } break; default: $return = cache_read($name, $key); break; } } if (!empty($sql)) { //replace table prefix $pdb->setFetchMode(ADODB_FETCH_ASSOC); $sql = str_replace("pb_", $tb_prefix, $sql); //for secure if (eregi('insert|update|delete|union|into|load_file|outfile|replace', $sql)) { trigger_error('no supported sql.'); } //mysql_escape_string() $return = $industry->GetArray($sql); } if (isset($name)) { switch ($name) { case "language": global $G; $languages = unserialize($G['setting']['languages']); if (!empty($languages)) { if (!isset($echo)) { $smarty->assign($var, $languages); } else { foreach ($languages as $lang_key => $lang_val) { $tmp = "<a href='" . URL . 'redirect.php?url=' . pb_getenv("REQUEST_URI") . "&app_lang=" . $lang_key . "' title='" . $lang_val['title'] . "'>"; if ($image && !empty($lang_val['img'])) { $tmp .= "<img src='" . $lang_val['img'] . "' alt='" . $lang_val['title'] . "' />"; } else { $tmp .= $lang_val['title']; } $tmp .= "</a>"; if ($sep) { $tmp .= $sep; } if (isset($title_li) && $title_li == "list") { $op .= "<li>" . $tmp . "</li>"; } else { $op .= $tmp; } } } } break; case "nav": $_nav = cache_read("nav"); $navs = $_nav['navs']; if (!empty($exclude)) { $_exclude_navs = explode(",", $exclude); foreach ($_exclude_navs as $_exkey => $_exval) { unset($navs[$_exval]); } } if (empty($echo)) { $smarty->assign($var, $navs); } else { foreach ($navs as $nav) { $op .= '<li id="mn_' . $nav['id'] . '" class="nav_item nav-item-' . $nav['id']; $file_name = pb_getenv('REQUEST_URI'); if (strpos($file_name, $nav['url']) !== false && $nav['url'] != 'index.php') { $op .= ' current_nav_item'; } $op .= '"><a href="' . $nav['url'] . '" target="_self"><span>' . pb_lang_split($nav['name']) . '</span></a></li>'; } } break; default: if (is_file(CACHE_COMMON_PATH . "cache_" . $name . ".php")) { require CACHE_COMMON_PATH . "cache_" . $name . ".php"; } if (isset($_PB_CACHE)) { $smarty->assign($var, $_PB_CACHE); } break; } } if (!empty($return)) { $smarty->assign($var, $return); } return $op; }
} else { $tf = "special/" . $topic_info['templet']; } if ($smarty->template_exists($smarty->template_dir . $theme_name . DS . $tf . $smarty->tpl_ext)) { $tpl_file = $tf; } } $viewhelper->setTitle($topic_info['title']); $viewhelper->setMetaDescription(mb_substr($topic_info['description'], 0, 100)); $viewhelper->setMetaKeyword($topic_info['title']); setvar("topic", $topic_info); } else { if (isset($_GET['id'])) { $model_name = htmlspecialchars($mod, ENT_QUOTES); uses($model_name); $model_name = $special_controller->pluralize(ucwords($model_name)); $model_object = new $model_name(); $mod_id = intval($_GET['id']); //for sub-station setvar($mod . "_id", $mod_id); $model_object->setInfo($mod_id); if (!empty($model_object->info)) { $cache_id = $mod_id; $viewhelper->setTitle($model_object->info['name'] . L("sub_" . $mod, "tpl")); if (empty($model_object->info['description'])) { $model_object->info['description'] = nl2br(L("sub_default_desc", "tpl", $model_object->info['name'])); } $viewhelper->setMetaDescription($model_object->info['description']); $viewhelper->setMetaKeyword(implode(",", array($model_object->info['name'] . L("offer", "tpl"), $model_object->info['name'] . L("market", "tpl"), $model_object->info['name'] . L("product_center", "tpl"), $model_object->info['name'] . L("yellow_page", "tpl"), $model_object->info['name'] . L("info", "tpl")))); setvar("item", $model_object->info); }