$trade_info['tag'] = $tag->tag; } } else { if (!empty($companyinfo)) { $trade_info['industry_id'] = $companyinfo['industry_id']; $trade_info['area_id'] = $companyinfo['area_id']; } else { $trade_info['area_id'] = $memberinfo['area_id']; } } if (!empty($trade_info['country_id'])) { $trade_info['country'] = $countries[$trade_info['country_id']]['picture']; } else { $trade_info['country'] = "blank.gif"; } $trade_types = $trade->GetArray("SELECT * FROM " . $tb_prefix . "tradetypes"); foreach ($trade_types as $key => $val) { if ($val['parent_id'] == 0) { $set_types[$val['id']] = $val; foreach ($trade_types as $key1 => $val1) { if ($val1['parent_id'] == $val['id']) { $set_types[$val['id']]['child'][$val1['id']] = $val1; } } } } setvar("select_tradetypes", $set_types); if (!empty($_GET['typeid'])) { setvar("type_id", intval($_GET['typeid'])); } else { setvar("type_id", $trade_info['type_id']);
/** * [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: 2116 $ */ function smarty_block_offer($params, $content, &$smarty, &$repeat) { global $_PB_CACHE; $conditions[] = "t.status='1'"; $param_count = count($smarty->_tag_stack); if (empty($params['name'])) { $params['name'] = "offer"; } if (!class_exists("Trades")) { uses("trade"); $trade = new Trades(); $trade_controller = new Trade(); } else { $trade = new Trades(); $trade_controller = new Trade(); } if ($_PB_CACHE['setting']['offer_expire_method']) { switch ($_PB_CACHE['setting']['offer_expire_method']) { case "2": $conditions[] = "t.expire_time>" . $trade->timestamp; break; case "3": $conditions[] = "t.expire_time>" . $trade->timestamp; break; default: break; } } if (isset($params['type'])) { $type = explode(",", $params['type']); $type = array_unique($type); foreach ($type as $val) { switch ($val) { case 'image': $conditions[] = "t.picture!=''"; break; case 'urgent': $conditions[] = "t.if_urgent='1'"; break; case 'company': $conditions[] = "t.company_id>0"; break; case 'commend': $conditions[] = "t.if_commend>0"; break; default: break; } } } if (isset($params['industryid'])) { if (isset($params['depth'])) { $depth = intval($params['depth']); if ($depth) { if (class_exists("Industries")) { $industry = new Industries(); $industry_controller = new Industry(); } else { uses("industry"); $industry = new Industries(); $industry_controller = new Industry(); } $ids_s = $industry->getConditionIds($params['industryid']); if (is_array($ids_s)) { $ids_s = array_filter($ids_s); $conditions['industry'] = "t.industry_id IN (" . implode(",", $ids_s) . ")"; } else { $conditions['industry'] = "t.industry_id='" . $ids_s . "'"; } } } else { $conditions[] = "t.industry_id = '" . $params['industryid'] . "'"; } } if (isset($params['areaid'])) { if (isset($params['depth'])) { $depth = intval($params['depth']); if ($depth) { global $industry; $ids_s = $industry->getConditionIds($params['areaid']); if (is_array($ids_s)) { $ids_s = array_filter($ids_s); $conditions['area'] = "t.area_id IN (" . implode(",", $ids_s) . ")"; } else { $conditions['area'] = "t.area_id='" . $ids_s . "'"; } } } else { $conditions['area'] = "t.area_id = '" . $params['areaid'] . "'"; } } if (!empty($_GET['industryid'])) { $conditions['industry'] = "t.industry_id=" . intval($_GET['industryid']); } if (!empty($_GET['areaid'])) { $conditions['area'] = "t.area_id=" . intval($_GET['areaid']); } if (isset($params['exclude'])) { $conditions[] = $trade->getExcludeIds($params['exclude']); } if (isset($params['include'])) { $conditions[] = $trade->getIncludeIds($params['include']); } if (isset($params['country_id'])) { $conditions[] = "t.country_id='" . $params['country_id'] . "'"; } if (isset($params['expday'])) { $conditions[] = "t.expire_time<'" . ($params['expday'] * 86400 + $trade->timestamp) . "'"; } if (isset($params['subday'])) { $conditions[] = "t.submit_time>'" . ($trade->timestamp - $params['expireday'] * 86400) . "'"; } if (isset($params['typeid'])) { if (!empty($params['typeid'])) { if (strpos($params['typeid'], ",") > 0) { $tmp_ids = explode(",", $params['typeid']); $conditions[] = "t.type_id in ('" . implode("','", $tmp_ids) . "')"; } else { $conditions[] = "t.type_id='" . $params['typeid'] . "'"; } } } if (isset($params['urgent'])) { $conditions[] = "t.if_urgent='1'"; } if (!empty($params['memberid'])) { $conditions[] = "t.member_id='" . $params['memberid'] . "'"; } if (!empty($params['companyid'])) { $conditions[] = "t.company_id='" . $params['companyid'] . "'"; } if (isset($params['cash'])) { $conditions[] = "t.require_point>0"; } $trade->setCondition($conditions); $orderby = null; $orderby = isset($params['orderby']) ? " ORDER BY " . trim($params['orderby']) . " " : " ORDER BY modified DESC"; $limit = $offset = 0; if (isset($params['row'])) { $limit = $params['row']; } if (isset($params['start'])) { $offset = $params['start']; } if (isset($_GET['pos'])) { $offset = intval($_GET['pos']); } $trade->setLimitOffset($offset, $limit); $mysql_limit = $trade->getLimitOffset(); if (isset($params['limit'])) { $mysql_limit = " " . trim($params['limit']); } if (!$params['recursive']) { $sql = "SELECT *,title as name,title as fulltitle,content as fullcontent FROM {$trade->table_prefix}trades t " . $trade->getCondition() . "{$orderby}" . $mysql_limit; } else { $sql = "SELECT *,content as fullcontent FROM {$trade->table_prefix}trades t " . $trade->getCondition() . " ORDER BY t.display_order ASC,t.id DESC" . $mysql_limit; } $offer_typenames = $trade_controller->getTradeTypes(); if (empty($smarty->blockvars[$param_count])) { $smarty->blockvars[$param_count] = $trade->GetArray($sql); if (!$smarty->blockvars[$param_count]) { return $repeat = false; } } if (!function_exists("smarty_function_the_url")) { require "function.the_url.php"; } if (list($key, $item) = each($smarty->blockvars[$param_count])) { $repeat = true; $item['rownum'] = $key; $item['iteration'] = ++$key; $url = smarty_function_the_url(array("id" => $item['id'], "typeid" => $item['type_id'], "module" => "offer")); $item['url'] = $url; $item['title'] = strip_tags($item['title']); $item['content'] = strip_tags($item['content']); if (isset($params['titlelen'])) { $item['title'] = mb_substr($item['title'], 0, $params['titlelen']); } if (isset($params['infolen'])) { $item['content'] = mb_substr($item['content'], 0, $params['infolen']); } if (isset($params['titlestart'])) { $item['title'] = $params['titlestart'] . $item['title']; } $item['pubdate'] = df($item['submit_time']); $item['typeid'] = $item['type_id']; $item['typename'] = $offer_typenames[$item['type_id']]; $item['src'] = $item['thumb'] = URL . "attachment/" . $item['picture'] . ".small.jpg"; $item['link'] = '<a title="' . $item['fulltitle'] . '" href="' . $url . '">' . $item['title'] . '</a>'; $item['style'] = parse_highlight($item['highlight']); $smarty->assign($params['name'], $item); } else { $repeat = false; reset($smarty->blockvars[$param_count]); } if (!is_null($content)) { print $content; } if (!$repeat) { $smarty->blockvars[$param_count] = array(); } }
function post() { global $G, $viewhelper; require CLASS_PATH . "validation.class.php"; $validate = new Validation(); if (session_id() == '') { require_once LIB_PATH . "session_php.class.php"; $session = new PbSessions(); } uses("trade", "member", "tradefield", "tag"); $tag = new Tags(); $offer = new Tradefields(); $member = new Members(); $trade = new Trades(); $expires = cache_read("typeoption", "offer_expire"); setvar("Genders", cache_read("typeoption", "gender", 1, array("0", "-1"))); setvar("PhoneTypes", cache_read("typeoption", "phone_type")); setvar("ImTypes", cache_read("typeoption", "im_type")); $if_visit_post = $G['setting']['vis_post']; if (!$if_visit_post) { $this->view->flash('visitor_forbid', URL, 0); } //for temp upgrade. if (!file_exists(CACHE_LANG_PATH . "locale.js")) { require LIB_PATH . "cache.class.php"; $cache = new Caches(); $cache->updateLanguages(); $cache->writeCache("javascript", "javascript"); } $trade_types = $trade->GetArray("SELECT * FROM " . $trade->table_prefix . "tradetypes"); foreach ($trade_types as $key => $val) { if ($val['parent_id'] == 0) { $set_types[$val['id']] = pb_lang_split_recursive($val); foreach ($trade_types as $key1 => $val1) { if ($val1['parent_id'] == $val['id']) { $set_types[$val['id']]['child'][$val1['id']] = pb_lang_split_recursive($val1); } } } } if (isset($_GET['typeid'])) { setvar("type_id", intval($_GET['typeid'])); } if (isset($_GET['industryid'])) { setvar("industry_id", intval($_GET['industryid'])); } if (isset($_GET['areaid'])) { setvar("area_id", intval($_GET['areaid'])); } setvar("select_tradetypes", $set_types); $viewhelper->setPosition(L("free_release_offer", "tpl")); setvar("OfferExpires", $expires); setvar("sid", md5(uniqid($offer->timestamp))); capt_check("capt_post_free"); render("offer/post"); }