function tpl_function_qishi_hunter_list($params, &$smarty)
{
    global $db, $_CFG;
    $arrset = explode(',', $params['set']);
    foreach ($arrset as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "列表名":
                $aset['listname'] = $a[1];
                break;
            case "显示数目":
                $aset['row'] = $a[1];
                break;
            case "开始位置":
                $aset['start'] = $a[1];
                break;
            case "猎头名长度":
                $aset['hunterlen'] = $a[1];
                break;
            case "公司名长度":
                $aset['companynamelen'] = $a[1];
                break;
            case "擅长行业长度":
                $aset['goodtradelen'] = $a[1];
                break;
            case "擅长职能长度":
                $aset['goodcategorylen'] = $a[1];
                break;
            case "描述长度":
                $aset['brieflylen'] = $a[1];
                break;
            case "填补字符":
                $aset['dot'] = $a[1];
                break;
            case "地区分类":
                $aset['citycategory'] = $a[1];
                break;
            case "地区大类":
                $aset['district'] = $a[1];
                break;
            case "地区小类":
                $aset['sdistrict'] = $a[1];
                break;
            case "猎头头衔":
                $aset['rank'] = $a[1];
                break;
            case "日期范围":
                $aset['settr'] = $a[1];
                break;
            case "排序":
                $aset['displayorder'] = $a[1];
                break;
            case "分页显示":
                $aset['page'] = $a[1];
                break;
            case "会员UID":
                $aset['uid'] = $a[1];
                break;
            case "猎头页面":
                $aset['huntershow'] = $a[1];
                break;
            case "列表页":
                $aset['listpage'] = $a[1];
                break;
            case "关键字":
                $aset['key'] = $a[1];
                break;
        }
    }
    $aset = array_map("get_smarty_request", $aset);
    $aset['listname'] = isset($aset['listname']) ? $aset['listname'] : "list";
    $aset['listpage'] = isset($aset['listpage']) ? $aset['listpage'] : "QS_hunterlist";
    $aset['row'] = intval($aset['row']) > 0 ? intval($aset['row']) : 10;
    if ($aset['row'] > 30) {
        $aset['row'] = 30;
    }
    $aset['start'] = isset($aset['start']) ? intval($aset['start']) : 0;
    $aset['hunterlen'] = isset($aset['hunterlen']) ? intval($aset['hunterlen']) : 8;
    $aset['companynamelen'] = isset($aset['companynamelen']) ? intval($aset['companynamelen']) : 15;
    $aset['goodtradelen'] = isset($aset['goodtradelen']) ? intval($aset['goodtradelen']) : 13;
    $aset['goodcategorylen'] = isset($aset['goodcategorylen']) ? intval($aset['goodcategorylen']) : 13;
    $aset['rank'] = isset($aset['rank']) ? intval($aset['rank']) : 0;
    $aset['brieflylen'] = isset($aset['brieflylen']) ? intval($aset['brieflylen']) : 0;
    $orderbysql = " ORDER BY refreshtime desc ";
    if (isset($aset['displayorder'])) {
        $arr = explode('>', $aset['displayorder']);
        // 排序方式
        if ($arr[1] == 'desc') {
            $arr[1] = "desc";
        } elseif ($arr[1] == "asc") {
            $arr[1] = "asc";
        } else {
            $arr[1] = "desc";
        }
        if ($arr[0] == "rtime") {
            $orderbysql = " ORDER BY refreshtime {$arr[1]}";
        } elseif ($arr[0] == "atime") {
            $orderbysql = " ORDER BY addtime {$arr[1]}";
        } elseif ($arr[0] == "hot") {
            $orderbysql = " ORDER BY click {$arr[1]}";
        } else {
            $orderbysql = " ORDER BY refreshtime {$arr[1]}";
        }
    }
    $wheresql .= " AND audit=1 ";
    if (isset($aset['settr']) && $aset['settr'] != '') {
        $settr = intval($aset['settr']);
        if ($settr > 0) {
            $settr_val = intval(strtotime("-" . $aset['settr'] . " day"));
            $wheresql .= " AND refreshtime>" . $settr_val;
        }
    }
    if (isset($aset['uid']) && $aset['uid'] != '') {
        $wheresql .= " AND uid=" . intval($aset['uid']);
    }
    if (isset($aset['rank']) && $aset['rank'] != '') {
        $wheresql .= " AND rank=" . intval($aset['rank']) . " ";
    }
    if (!empty($aset['citycategory'])) {
        $dsql = $xsql = "";
        $arr = explode("_", $aset['citycategory']);
        $arr = array_unique($arr);
        if (count($arr) > 10) {
            exit;
        }
        foreach ($arr as $sid) {
            $cat = explode(".", $sid);
            if (intval($cat[1]) === 0) {
                $dsql .= " OR district =" . intval($cat[0]);
            } else {
                $xsql .= " OR sdistrict =" . intval($cat[1]);
            }
        }
        $wheresql .= " AND  (" . ltrim(ltrim($dsql . $xsql), 'OR') . ") ";
    } else {
        if (isset($aset['district']) && $aset['district'] != '') {
            if (strpos($aset['district'], "-")) {
                $or = $orsql = "";
                $arr = explode("-", $aset['district']);
                $arr = array_unique($arr);
                if (count($arr) > 20) {
                    exit;
                }
                $sqlin = implode(",", $arr);
                if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                    $wheresql .= " AND district IN  ({$sqlin}) ";
                }
            } else {
                $wheresql .= " AND district =" . intval($aset['district']);
            }
        }
        if (isset($aset['sdistrict']) && $aset['sdistrict'] != '') {
            if (strpos($aset['sdistrict'], "-")) {
                $or = $orsql = "";
                $arr = explode("-", $aset['sdistrict']);
                $arr = array_unique($arr);
                if (count($arr) > 10) {
                    exit;
                }
                $sqlin = implode(",", $arr);
                if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                    $wheresql .= " AND sdistrict IN  ({$sqlin}) ";
                }
            } else {
                $wheresql .= " AND sdistrict =" . intval($aset['sdistrict']);
            }
        }
    }
    if (isset($aset['key']) && !empty($aset['key'])) {
        $key = help::addslashes_deep(trim($aset['key']));
        $akey = explode(' ', $key);
        if (count($akey) > 1) {
            $akey = array_filter($akey);
            $akey = array_slice($akey, 0, 2);
            $akey = array_map("fulltextpad", $akey);
            $key = '+' . implode(' +', $akey);
            $mode = ' IN BOOLEAN MODE';
        } else {
            $key = fulltextpad($key);
            $mode = ' ';
        }
        $wheresql .= " AND  MATCH (`key`) AGAINST ('{$key}'{$mode}) ";
    }
    if (!empty($wheresql)) {
        $wheresql = " WHERE " . ltrim(ltrim($wheresql), 'AND');
    }
    if (isset($aset['page'])) {
        require_once QISHI_ROOT_PATH . 'include/page.class.php';
        $total_sql = "SELECT COUNT(*) AS num FROM " . table('hunter_profile') . " {$wheresql}";
        $total_count = $db->get_total($total_sql);
        $page = new page(array('total' => $total_count, 'perpage' => $aset['row'], 'alias' => $aset['listpage'], 'getarray' => $_GET));
        $currenpage = $page->nowindex;
        $aset['start'] = abs($currenpage - 1) * $aset['row'];
        $countpage = $total_count % $aset['row'] == 0 ? $total_count / $aset['row'] : intval($total_count / $aset['row']) + 1;
        $smarty->assign('countpage', $countpage);
        $smarty->assign('page', $page->show(3));
        $smarty->assign('pagemin', $page->show(4));
        $smarty->assign('currenpage', $currenpage);
        $smarty->assign('total', $total_count);
    }
    $limit = " LIMIT {$aset['start']} , {$aset['row']}";
    $list = $id = array();
    $result = $db->query("SELECT id,uid,refreshtime,huntername,companyname,contents,goodtrade_cn,goodcategory_cn,worktime_start,photo_img,district_cn FROM " . table('hunter_profile') . $wheresql . $orderbysql . $limit);
    while ($row = $db->fetch_array($result)) {
        $row['refreshtime_cn'] = daterange(time(), $row['refreshtime'], 'Y-m-d', "#FF3300");
        $row['huntername'] = cut_str($row['huntername'], $aset['hunterlen'], 0, $aset['dot']);
        $row['companyname'] = cut_str($row['companyname'], $aset['companynamelen'], 0, $aset['dot']);
        if ($aset['brieflylen'] > 0) {
            $row['contents'] = cut_str(strip_tags($row['contents']), $aset['brieflylen'], 0, $aset['dot']);
        } else {
            $row['contents'] = strip_tags($row['contents']);
        }
        if ($aset['goodtradelen'] > 0) {
            $row['goodtrade_cn'] = cut_str(strip_tags($row['goodtrade_cn']), $aset['goodtradelen'], 0, $aset['dot']);
        } else {
            $row['goodtrade_cn'] = strip_tags($row['goodtrade_cn']);
        }
        if ($aset['goodcategorylen'] > 0) {
            $row['goodcategory_cn'] = cut_str(strip_tags($row['goodcategory_cn']), $aset['goodcategorylen'], 0, $aset['dot']);
        } else {
            $row['goodcategory_cn'] = strip_tags($row['goodcategory_cn']);
        }
        $row['companyname_'] = $row['companyname'];
        $row['huntername_'] = $row['huntername'];
        $row['years'] = date('Y') + 1 - $row['worktime_start'];
        if ($row['photo_img']) {
            $row['photosrc'] = $_CFG['hunter_photo_dir'] . $row['photo_img'];
        } else {
            $row['photosrc'] = $_CFG['hunter_photo_dir'] . "no_photo.gif";
        }
        $timenow = time();
        if ($_CFG['operation_mode'] == '1') {
            $wheresql1 .= "  AND audit=1  AND display=1 ";
        } elseif ($_CFG['operation_train_mode'] == '2') {
            $wheresql1 .= "  AND audit=1 AND display=1 AND setmeal_id>0 AND (setmeal_deadline>{$timenow} OR setmeal_deadline=0)";
        }
        $row['countjobs'] = $db->get_total("select count(*) as num from " . table('hunter_jobs') . " where uid=" . $row['uid'] . " " . $wheresql1);
        $jobs = $db->getall("select id,jobs_name,refreshtime from " . table('hunter_jobs') . " where uid=" . $row['uid'] . " " . $wheresql1 . " limit 4");
        foreach ($jobs as $key => $value) {
            $row['jobslist'][$key]['jobs_name'] = cut_str($value['jobs_name'], 10, 0, "..");
            $row['jobslist'][$key]['refreshtime'] = date("Y-m-d", $value['refreshtime']);
            $row['jobslist'][$key]['jobs_url'] = url_rewrite("QS_hunter_jobsshow", array("id" => $value['id']));
        }
        $timenow = time();
        if ($_CFG['operation_mode'] == '1') {
            $wheresql1 .= "  AND audit=1  AND display=1 ";
        } elseif ($_CFG['operation_train_mode'] == '2') {
            $wheresql1 .= "  AND audit=1 AND display=1 AND setmeal_id>0 AND (setmeal_deadline>{$timenow} OR setmeal_deadline=0)";
        }
        $row['countjobs'] = $db->get_total("select count(*) as num from " . table('hunter_jobs') . " where uid=" . $row['uid'] . " " . $wheresql1);
        $list[] = $row;
        unset($row);
    }
    $smarty->assign($aset['listname'], $list);
}
示例#2
0
session_save_path('/data/tmp/session/');
session_start();
require_once QISHI_ROOT_PATH . 'data/config.php';
header("Content-Type:text/html;charset=" . QISHI_CHARSET);
require_once QISHI_ROOT_PATH . 'include/help.class.php';
require_once QISHI_ROOT_PATH . 'include/common.fun.php';
require_once QISHI_ROOT_PATH . 'include/74cms_version.php';
$QSstarttime = exectime();
if (!empty($_GET)) {
    $_GET = help::addslashes_deep($_GET);
}
if (!empty($_POST)) {
    $_POST = help::addslashes_deep($_POST);
}
$_COOKIE = help::addslashes_deep($_COOKIE);
$_REQUEST = help::addslashes_deep($_REQUEST);
date_default_timezone_set("PRC");
$timestamp = time();
$online_ip = getip();
$ip_address = convertip($online_ip);
$_NAV = get_cache('nav');
$_PAGE = get_cache('page');
$_CFG = get_cache('config');
$_SUBSITE = get_cache('subsite');
$_M_SUBSITE = get_cache('m_subsite');
$_CFG['statistics'] = htmlspecialchars_decode($_CFG['statistics']);
$_PLUG = get_cache('plug');
if ($_CFG['uc_open'] == "1") {
    require_once QISHI_ROOT_PATH . 'data/cache_uc_config.php';
}
$QS_cookiedomain = get_cookiedomain();
function tpl_function_qishi_curriculum_list($params, &$smarty)
{
    global $db, $_CFG;
    $arrset = explode(',', $params['set']);
    foreach ($arrset as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "列表名":
                $aset['listname'] = $a[1];
                break;
            case "显示数目":
                $aset['row'] = $a[1];
                break;
            case "开始位置":
                $aset['start'] = $a[1];
                break;
            case "课程名长度":
                $aset['courselen'] = $a[1];
                break;
            case "机构名长度":
                $aset['trainnamelen'] = $a[1];
                break;
            case "描述长度":
                $aset['brieflylen'] = $a[1];
                break;
            case "填补字符":
                $aset['dot'] = $a[1];
                break;
            case "课程类别":
                $aset['coursecategory'] = $a[1];
                break;
            case "地区分类":
                $aset['citycategory'] = $a[1];
                break;
            case "地区大类":
                $aset['district'] = $a[1];
                break;
            case "地区小类":
                $aset['sdistrict'] = $a[1];
                break;
            case "上课班制":
                $aset['classtype'] = $a[1];
                break;
            case "推荐":
                $aset['recommend'] = $a[1];
                break;
            case "关键字":
                $aset['key'] = $a[1];
                break;
            case "关键字类型":
                $aset['keytype'] = $a[1];
                break;
            case "日期范围":
                $aset['refre'] = $a[1];
                break;
            case "开课时间":
                $aset['starttime'] = $a[1];
                break;
            case "排序":
                $aset['displayorder'] = $a[1];
                break;
            case "分页显示":
                $aset['page'] = $a[1];
                break;
            case "会员UID":
                $aset['uid'] = $a[1];
                break;
            case "机构页面":
                $aset['trainshow'] = $a[1];
                break;
            case "课程页面":
                $aset['courseshow'] = $a[1];
                break;
            case "讲师页面":
                $aset['teachershow'] = $a[1];
                break;
            case "列表页":
                $aset['listpage'] = $a[1];
                break;
        }
    }
    $timenow = time();
    $aset = array_map("get_smarty_request", $aset);
    $aset['listname'] = isset($aset['listname']) ? $aset['listname'] : "list";
    $aset['listpage'] = isset($aset['listpage']) ? $aset['listpage'] : "QS_courselist";
    $aset['row'] = intval($aset['row']) > 0 ? intval($aset['row']) : 10;
    if ($aset['row'] > 30) {
        $aset['row'] = 30;
    }
    $aset['start'] = isset($aset['start']) ? intval($aset['start']) : 0;
    $aset['courselen'] = isset($aset['courselen']) ? intval($aset['courselen']) : 8;
    $aset['trainnamelen'] = isset($aset['trainnamelen']) ? intval($aset['trainnamelen']) : 15;
    $aset['brieflylen'] = isset($aset['brieflylen']) ? intval($aset['brieflylen']) : 0;
    $aset['recommend'] = isset($aset['recommend']) ? intval($aset['recommend']) : '';
    $aset['trainshow'] = isset($aset['trainshow']) ? $aset['trainshow'] : 'QS_train_agencyshow';
    $aset['courseshow'] = isset($aset['courseshow']) ? $aset['courseshow'] : 'QS_train_curriculumshow';
    $aset['teachershow'] = isset($aset['teachershow']) ? $aset['teachershow'] : 'QS_train_lecturershow';
    if (isset($aset['displayorder'])) {
        $arr = explode('>', $aset['displayorder']);
        // 排序方式
        if ($arr[1] == 'desc') {
            $arr[1] = "desc";
        } elseif ($arr[1] == "asc") {
            $arr[1] = "asc";
        } else {
            $arr[1] = "desc";
        }
        if ($arr[0] == "rtime") {
            $orderbysql = " ORDER BY refreshtime {$arr[1]}";
        } elseif ($arr[0] == "atime") {
            $orderbysql = " ORDER BY addtime {$arr[1]}";
        } elseif ($arr[0] == "stime") {
            $orderbysql = " ORDER BY starttime {$arr[1]}";
        } elseif ($arr[0] == "hot") {
            $orderbysql = " ORDER BY click {$arr[1]}";
        } else {
            $orderbysql = " ORDER BY refreshtime {$arr[1]}";
        }
    }
    if (intval($_CFG['subsite_id']) > 0) {
        $wheresql .= " AND subsite_id=" . intval($_CFG['subsite_id']) . " ";
    }
    if (isset($aset['refre']) && $aset['refre'] != '') {
        $settr = intval($aset['refre']);
        if ($settr > 0) {
            $settr_val = intval(strtotime("-" . $aset['refre'] . " day"));
            $wheresql .= " AND refreshtime>" . $settr_val;
        }
    }
    if (isset($aset['starttime']) && $aset['starttime'] != '') {
        $trart = intval($aset['starttime']);
        if ($trart > 0) {
            $trart_val = intval(strtotime("+" . $aset['starttime'] . " day"));
            $wheresql .= " AND starttime>{$timenow} AND starttime<" . $trart_val;
        }
    }
    if (isset($aset['uid']) && $aset['uid'] != '') {
        $wheresql .= " AND uid=" . intval($aset['uid']);
    }
    if (isset($aset['recommend']) && $aset['recommend'] != '') {
        $wheresql .= " AND recommend=" . intval($aset['recommend']);
    }
    if (isset($aset['classtype']) && $aset['classtype'] != '') {
        $wheresql .= " AND classtype=" . intval($aset['classtype']) . " ";
    }
    if (!empty($aset['citycategory'])) {
        $dsql = $xsql = "";
        $arr = explode("_", $aset['citycategory']);
        $arr = array_unique($arr);
        if (count($arr) > 10) {
            exit;
        }
        foreach ($arr as $sid) {
            $cat = explode(".", $sid);
            if (intval($cat[1]) === 0) {
                $dsql .= " OR district =" . intval($cat[0]);
            } else {
                $xsql .= " OR sdistrict =" . intval($cat[1]);
            }
        }
        $wheresql .= " AND  (" . ltrim(ltrim($dsql . $xsql), 'OR') . ") ";
    } else {
        if (isset($aset['district']) && $aset['district'] != '') {
            if (strpos($aset['district'], "-")) {
                $or = $orsql = "";
                $arr = explode("-", $aset['district']);
                $arr = array_unique($arr);
                if (count($arr) > 20) {
                    exit;
                }
                $sqlin = implode(",", $arr);
                if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                    $wheresql .= " AND district IN  ({$sqlin}) ";
                }
            } else {
                $wheresql .= " AND district =" . intval($aset['district']);
            }
        }
        if (isset($aset['sdistrict']) && $aset['sdistrict'] != '') {
            if (strpos($aset['sdistrict'], "-")) {
                $or = $orsql = "";
                $arr = explode("-", $aset['sdistrict']);
                $arr = array_unique($arr);
                if (count($arr) > 10) {
                    exit;
                }
                $sqlin = implode(",", $arr);
                if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                    $wheresql .= " AND sdistrict IN  ({$sqlin}) ";
                }
            } else {
                $wheresql .= " AND sdistrict =" . intval($aset['sdistrict']);
            }
        }
    }
    //不支持多个类型搜索
    if (!empty($aset['coursecategory']) && $aset['coursecategory'] != '') {
        $wheresql .= " AND category =" . intval($aset['coursecategory']);
    }
    if (isset($aset['key']) && !empty($aset['key'])) {
        if ($_CFG['courseearch_purview'] == '2') {
            if ($_SESSION['username'] == '') {
                header("Location: " . url_rewrite('QS_login') . "?url=" . urlencode($_SERVER["REQUEST_URI"]));
            }
        }
        $key = help::addslashes_deep(trim($aset['key']));
        if ($_CFG['courseearch_type'] == '1') {
            $akey = explode(' ', $key);
            if (count($akey) > 1) {
                $akey = array_filter($akey);
                $akey = array_slice($akey, 0, 2);
                $akey = array_map("fulltextpad", $akey);
                $key = '+' . implode(' +', $akey);
                $mode = ' IN BOOLEAN MODE';
            } else {
                $key = fulltextpad($key);
                $mode = ' ';
            }
            $wheresql .= " AND  MATCH (`key`) AGAINST ('{$key}'{$mode}) ";
        } else {
            $wheresql .= " AND likekey LIKE '%{$key}%' ";
        }
    }
    $wheresql .= $_CFG['outdated_course'] == '1' ? " AND deadline > {$timenow} " : ' ';
    if ($_CFG['operation_train_mode'] == '1') {
        $wheresql .= "  AND audit=1  AND display=1 AND add_mode=1 ";
    } elseif ($_CFG['operation_train_mode'] == '2') {
        $wheresql .= "  AND audit=1  AND display=1 AND add_mode=2 AND setmeal_id>0 AND (setmeal_deadline>{$timenow} OR setmeal_deadline=0)";
    }
    if (!empty($wheresql)) {
        $wheresql = " WHERE " . ltrim(ltrim($wheresql), 'AND');
    }
    if (isset($aset['page'])) {
        require_once QISHI_ROOT_PATH . 'include/page.class.php';
        $total_sql = "SELECT COUNT(*) AS num FROM " . table('course') . " {$wheresql}";
        //echo $total_sql;
        //echo "<br>";
        $total_count = $db->get_total($total_sql);
        if ($_CFG['course_list_max'] > 0) {
            $total_count > intval($_CFG['course_list_max']) && ($total_count = intval($_CFG['course_list_max']));
        }
        $page = new page(array('total' => $total_count, 'perpage' => $aset['row'], 'alias' => $aset['listpage'], 'getarray' => $_GET));
        $currenpage = $page->nowindex;
        $aset['start'] = abs($currenpage - 1) * $aset['row'];
        if ($total_count > $aset['row']) {
            $smarty->assign('page', $page->show(3));
            $smarty->assign('pagemin', $page->show(7));
            $smarty->assign('pagenow', $page->show(6));
        }
        $smarty->assign('total', $total_count);
    }
    $limit = " LIMIT {$aset['start']} , {$aset['row']}";
    $list = $id = array();
    $result = $db->query("SELECT id,subsite_id,course_name,refreshtime,starttime,contents,trainname,train_id,teacher_id,teacher_cn,category_cn,classtype_cn,train_expenses,favour_expenses,district_cn,classhour FROM " . table('course') . $wheresql . $orderbysql . $limit);
    while ($row = $db->fetch_array($result)) {
        $row['course_name_'] = $row['course_name'];
        $row['refreshtime_cn'] = daterange(time(), $row['refreshtime'], 'Y-m-d', "#FF3300");
        $row['starttime_cn'] = date("Y-m-d", $row['starttime']);
        $row['course_name'] = cut_str($row['course_name'], $aset['courselen'], 0, $aset['dot']);
        if ($aset['brieflylen'] > 0) {
            $row['briefly'] = cut_str(strip_tags($row['contents']), $aset['brieflylen'], 0, $aset['dot']);
        } else {
            $row['briefly'] = strip_tags($row['contents']);
        }
        $row['briefly_'] = strip_tags($row['contents']);
        $row['trainname_'] = $row['trainname'];
        $row['trainname'] = cut_str($row['trainname'], $aset['trainnamelen'], 0, $aset['dot']);
        $row['course_url'] = url_rewrite($aset['courseshow'], array('id' => $row['id']), 1, $row['subsite_id']);
        $row['train_url'] = url_rewrite($aset['trainshow'], array('id' => $row['train_id']));
        $row['teacher_url'] = url_rewrite($aset['teachershow'], array('id' => $row['teacher_id']));
        $list[] = $row;
    }
    $smarty->assign($aset['listname'], $list);
}
示例#4
0
function tpl_function_qishi_shop_list($params, &$smarty)
{
    global $db, $_CFG;
    $arrset = explode(',', $params['set']);
    foreach ($arrset as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "列表名":
                $aset['listname'] = $a[1];
                break;
            case "显示数目":
                $aset['row'] = $a[1];
                break;
            case "标题长度":
                $aset['titlelen'] = $a[1];
                break;
            case "开始位置":
                $aset['start'] = $a[1];
                break;
            case "填补字符":
                $aset['dot'] = $a[1];
                break;
            case "分类ID":
                $aset['scategory'] = $a[1];
                break;
            case "关键字":
                $aset['key'] = $a[1];
                break;
            case "推荐":
                $aset['recommend'] = $a[1];
                break;
            case "排序":
                $aset['displayorder'] = $a[1];
                break;
            case "分页显示":
                $aset['paged'] = $a[1];
                break;
            case "积分区间":
                $aset['points_interval'] = $a[1];
                //0|1000
                break;
            case "会员积分":
                $aset['user_points'] = $a[1];
                //我能兑换的
                break;
        }
    }
    if (is_array($aset)) {
        $aset = array_map("get_smarty_request", $aset);
    }
    $aset['listname'] = isset($aset['listname']) ? $aset['listname'] : "list";
    $aset['row'] = isset($aset['row']) ? intval($aset['row']) : 10;
    $aset['start'] = isset($aset['start']) ? intval($aset['start']) : 0;
    $aset['titlelen'] = isset($aset['titlelen']) ? intval($aset['titlelen']) : 15;
    $aset['dot'] = isset($aset['dot']) ? $aset['dot'] : '';
    $aset['recommend'] = isset($aset['recommend']) ? intval($aset['recommend']) : 1;
    if (isset($aset['displayorder'])) {
        $arr = explode('>', $aset['displayorder']);
        // 排序方式
        if ($arr[1] == 'desc') {
            $arr[1] = "desc";
        } elseif ($arr[1] == "asc") {
            $arr[1] = "asc";
        } else {
            $arr[1] = "desc";
        }
        if ($arr[0] == "shop_points") {
            $orderbysql = " ORDER BY shop_points {$arr[1]},id desc ";
        } elseif ($arr[0] == "click") {
            $orderbysql = " ORDER BY click {$arr[1]},id desc ";
        } else {
            if ($aset['recommend'] > 0) {
                $orderbysql = " ORDER BY recommend desc,addtime {$arr[1]},id desc ";
            } else {
                $orderbysql = " ORDER BY addtime {$arr[1]},id desc ";
            }
        }
    }
    // 积分区间
    if (isset($aset['points_interval']) && !empty($aset['points_interval'])) {
        $points_arr = explode('-', $aset['points_interval']);
        $points_min = $points_arr[0];
        $points_max = $points_arr[1];
        $wheresql .= " AND shop_points>{$points_min} AND shop_points<{$points_max} ";
    }
    // 我能兑换的 user_points
    if (isset($aset['user_points']) && !empty($aset['user_points'])) {
        $user_points = intval($aset['user_points']);
        $wheresql .= " AND shop_points<{$user_points} ";
    }
    if ($aset['scategory']) {
        $wheresql .= " AND scategory=" . intval($aset['scategory']) . " ";
    }
    if (isset($aset['key']) && !empty($aset['key'])) {
        $key = help::addslashes_deep(trim($aset['key']));
        $wheresql .= " AND shop_title LIKE '%{$key}%' ";
    }
    if (!empty($wheresql)) {
        $wheresql = " WHERE " . ltrim(ltrim($wheresql), 'AND');
    }
    if (isset($aset['paged'])) {
        require_once QISHI_ROOT_PATH . 'include/page.class.php';
        $total_sql = "SELECT  COUNT(*) AS num  FROM " . table("shop_goods") . $wheresql;
        $total_count = $db->get_total($total_sql);
        $page = new page(array('total' => $total_count, 'perpage' => $aset['row'], 'getarray' => $_GET));
        $currenpage = $page->nowindex;
        $aset['start'] = abs($currenpage - 1) * $aset['row'];
        if ($total_count > $aset['row']) {
            $smarty->assign('page', $page->show(3));
            $smarty->assign('pagemin', $page->show(7));
        }
        $smarty->assign('total', $total_count);
        $smarty->assign('pagenow', $page->show(6));
    }
    $limit = " LIMIT {$aset['start']} , {$aset['row']}";
    $result = $db->query("SELECT * FROM " . table('shop_goods') . " " . $wheresql . $orderbysql . $limit);
    $list = array();
    $config = get_cache('config');
    while ($row = $db->fetch_array($result)) {
        $row['shop_title_'] = cut_str($row['shop_title'], $aset['titlelen'], 0, $aset['dot']);
        $row['shop_url'] = url_rewrite('QS_shop_show', array('id' => $row['id']));
        $list[] = $row;
    }
    $smarty->assign($aset['listname'], $list);
}
function tpl_function_qishi_simple_resume_list($params, &$smarty)
{
    global $db, $_CFG;
    $arrset = explode(',', $params['set']);
    foreach ($arrset as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "列表名":
                $aset['listname'] = $a[1];
                break;
            case "显示数目":
                $aset['row'] = $a[1];
                break;
            case "开始位置":
                $aset['start'] = $a[1];
                break;
            case "姓名长度":
                $aset['unamelen'] = $a[1];
                break;
            case "描述长度":
                $aset['brieflylen'] = $a[1];
                break;
            case "填补字符":
                $aset['dot'] = $a[1];
                break;
            case "关键字":
                $aset['key'] = $a[1];
                break;
            case "关键字类型":
                $aset['keytype'] = $a[1];
                break;
            case "日期范围":
                $aset['settr'] = $a[1];
                break;
            case "排序":
                $aset['displayorder'] = $a[1];
                break;
            case "分页显示":
                $aset['page'] = $a[1];
                break;
            case "页面":
                $aset['simpleresumeshow'] = $a[1];
                break;
            case "地区分类":
                $aset['citycategory'] = $a[1];
                break;
        }
    }
    $aset = array_map("get_smarty_request", $aset);
    $aset['listname'] = isset($aset['listname']) ? $aset['listname'] : "list";
    $aset['row'] = isset($aset['row']) ? intval($aset['row']) : 10;
    $aset['start'] = isset($aset['start']) ? intval($aset['start']) : 0;
    $aset['unamelen'] = isset($aset['unamelen']) ? intval($aset['unamelen']) : 8;
    $aset['brieflylen'] = isset($aset['brieflylen']) ? intval($aset['brieflylen']) : 0;
    $aset['simpleresumeshow'] = isset($aset['simpleresumeshow']) ? $aset['simpleresumeshow'] : 'QS_simpleresumeshow';
    if (isset($aset['displayorder'])) {
        if (strpos($aset['displayorder'], '>')) {
            $arr = explode('>', $aset['displayorder']);
            // 排序字段
            if ($arr[0] == 'refreshtime') {
                $arr[0] = "refreshtime";
            } elseif ($arr[0] == "id") {
                $arr[0] = "id";
            } elseif ($arr[0] == "click") {
                $arr[0] == "click";
            } else {
                $arr[0] = "";
            }
            // 排序方式
            if ($arr[1] == 'desc') {
                $arr[1] = "desc";
            } elseif ($arr[1] == "asc") {
                $arr[1] = "asc";
            } else {
                $arr[1] = "";
            }
            if ($arr[0] && $arr[1]) {
                $orderbysql = " ORDER BY  `is_hot`  {$arr[1]} , {$arr[0]} {$arr[1]}";
            }
        }
    } else {
        $orderbysql = " ORDER BY   `is_hot`  DESC";
    }
    $wheresql = " AND audit=1 ";
    if (intval($_CFG['subsite_id']) > 0) {
        $wheresql .= " AND subsite_id=" . intval($_CFG['subsite_id']) . " ";
    }
    if (isset($aset['settr']) && $aset['settr'] != '') {
        $settr = intval($aset['settr']);
        if ($settr > 0) {
            $settr_val = intval(strtotime("-" . $aset['settr'] . " day"));
            $wheresql .= " AND refreshtime>" . $settr_val;
        }
    }
    if (isset($aset['key']) && !empty($aset['key'])) {
        $aset['key'] = help::addslashes_deep(trim($aset['key']));
        if ($aset['keytype'] == "1" || $aset['keytype'] == "") {
            $wheresql .= " AND  likekey like '%{$aset['key']}%'";
            $orderbysql = "";
        } elseif ($aset['keytype'] == "2") {
            $wheresql .= " AND  MATCH (`key`) AGAINST ('" . fulltextpad($aset['key']) . "') ";
            $orderbysql = "";
        }
    }
    if (!empty($aset['citycategory'])) {
        $dsql = $xsql = "";
        $arr = explode("_", $aset['citycategory']);
        $arr = array_unique($arr);
        if (count($arr) > 10) {
            exit;
        }
        foreach ($arr as $sid) {
            $cat = explode(".", $sid);
            if (intval($cat[1]) === 0) {
                $dsql .= " OR district =" . intval($cat[0]);
            } else {
                $xsql .= " OR sdistrict =" . intval($cat[1]);
            }
        }
        $wheresql .= " AND  (" . ltrim(ltrim($dsql . $xsql), 'OR') . ") ";
    } else {
        if (isset($aset['district']) && $aset['district'] != '') {
            if (strpos($aset['district'], "-")) {
                $or = $orsql = "";
                $arr = explode("-", $aset['district']);
                $arr = array_unique($arr);
                if (count($arr) > 20) {
                    exit;
                }
                $sqlin = implode(",", $arr);
                if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                    $wheresql .= " AND district IN  ({$sqlin}) ";
                }
            } else {
                $wheresql .= " AND district =" . intval($aset['district']);
            }
        }
        if (isset($aset['sdistrict']) && $aset['sdistrict'] != '') {
            if (strpos($aset['sdistrict'], "-")) {
                $or = $orsql = "";
                $arr = explode("-", $aset['sdistrict']);
                $arr = array_unique($arr);
                if (count($arr) > 10) {
                    exit;
                }
                $sqlin = implode(",", $arr);
                if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                    $wheresql .= " AND sdistrict IN  ({$sqlin}) ";
                }
            } else {
                $wheresql .= " AND sdistrict =" . intval($aset['sdistrict']);
            }
        }
    }
    if (!empty($wheresql)) {
        $wheresql = " WHERE " . ltrim(ltrim($wheresql), 'AND');
    }
    if (isset($aset['page'])) {
        require_once QISHI_ROOT_PATH . 'include/page.class.php';
        $total_sql = "SELECT COUNT(*) AS num FROM " . table('simple_resume') . $wheresql;
        //echo $total_sql;
        $total_count = $db->get_total($total_sql);
        $page = new page(array('total' => $total_count, 'perpage' => $aset['row'], 'alias' => 'QS_simpleresumelist', 'getarray' => $_GET));
        $currenpage = $page->nowindex;
        $aset['start'] = ($currenpage - 1) * $aset['row'];
        $smarty->assign('page', $page->show(3));
        $smarty->assign('total', $total_count);
    }
    $limit = " LIMIT " . abs($aset['start']) . ',' . $aset['row'];
    $result = $db->query("SELECT id,subsite_id,uname,detailed,refreshtime,category,is_hot,sex,age,experience_cn,deadline,district_cn,sdistrict_cn FROM " . table('simple_resume') . " " . $wheresql . $orderbysql . $limit);
    $list = array();
    //echo "SELECT * FROM ".table('jobs')." ".$wheresql.$orderbysql.$limit;
    while ($row = $db->fetch_array($result)) {
        $row['uname_'] = $row['uname'];
        $row['uname'] = cut_str($row['uname'], $aset['unamelen'], 0, $aset['dot']);
        $row['detailed_'] = strip_tags($row['detailed']);
        if ($aset['brieflylen'] > 0) {
            $row['detailed'] = cut_str($row['detailed_'], $aset['brieflylen'], 0, $aset['dot']);
        } else {
            $row['detailed'] = $row['detailed_'];
        }
        if (strlen($row['detailed_']) > $aset['brieflylen'] * 2) {
            $row['show_detail'] = true;
        } else {
            $row['show_detail'] = false;
        }
        // $row['comname_']=$row['comname'];
        $row['refreshtime_cn'] = daterange(time(), $row['refreshtime'], 'Y-m-d', "#FF3300");
        // $row['comname']=cut_str($row['comname'],$aset['companynamelen'],0,$aset['dot']);
        $row['simple_url'] = url_rewrite($aset['simpleresumeshow'], array('id' => $row['id']), 1, $row['subsite_id']);
        $row['intention_jobs'] = $row['category'];
        $list[] = $row;
    }
    $smarty->assign($aset['listname'], $list);
}
示例#6
0
         if ($subclass != '') {
             $wheresql .= " AND `subclass` = " . $subclass;
         }
     }
 }
 if ($wage != '') {
     $wheresql .= " AND `wage` = " . $wage;
 }
 if ($recommend != '') {
     $wheresql .= " AND `recommend` = " . $recommend;
 }
 if ($emergency != '') {
     $wheresql .= " AND `emergency` = " . $emergency;
 }
 if (!empty($key)) {
     $key = help::addslashes_deep(trim($key));
     if ($_CFG['jobsearch_type'] == '1') {
         $akey = explode(' ', $key);
         if (count($akey) > 1) {
             $akey = array_filter($akey);
             $akey = array_slice($akey, 0, 2);
             $akey = array_map("fulltextpad", $akey);
             $key = '+' . implode(' +', $akey);
             $mode = ' IN BOOLEAN MODE';
         } else {
             $key = fulltextpad($key);
             $mode = ' ';
         }
         $wheresql .= " AND  MATCH (`key`) AGAINST ('{$key}'{$mode}) ";
     } else {
         $wheresql .= " AND likekey LIKE '%{$key}%' ";
function tpl_function_qishi_resume_list($params, &$smarty)
{
    global $db, $_CFG;
    $arrset = explode(',', $params['set']);
    foreach ($arrset as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "列表名":
                $aset['listname'] = $a[1];
                break;
            case "显示数目":
                $aset['row'] = $a[1];
                break;
            case "应届生简历":
                $aset['campu_sresume'] = $a[1];
                break;
            case "院校名称":
                $aset['campusname'] = $a[1];
                break;
            case "更新时间":
                $aset['refreshtime'] = $a[1];
                break;
            case "开始位置":
                $aset['start'] = $a[1];
                break;
            case "姓名长度":
                $aset['namelen'] = $a[1];
                break;
            case "特长描述长度":
                $aset['specialtylen'] = $a[1];
                break;
            case "意向职位长度":
                $aset['jobslen'] = $a[1];
                break;
            case "专业长度":
                $aset['majorlen'] = $a[1];
                break;
            case "填补字符":
                $aset['dot'] = $a[1];
                break;
            case "日期范围":
                $aset['settr'] = $a[1];
                break;
            case "职位分类":
                $aset['jobcategory'] = trim($a[1]);
                break;
            case "职位大类":
                $aset['category'] = trim($a[1]);
                break;
            case "职位小类":
                $aset['subclass'] = trim($a[1]);
                break;
            case "地区分类":
                $aset['citycategory'] = trim($a[1]);
                break;
            case "地区大类":
                $aset['district'] = $a[1];
                break;
            case "地区小类":
                $aset['sdistrict'] = $a[1];
                break;
            case "行业":
                $aset['trade'] = trim($a[1]);
                break;
            case "专业":
                $aset['major'] = trim($a[1]);
                break;
            case "标签":
                $aset['tag'] = $a[1];
                break;
            case "学历":
                $aset['education'] = $a[1];
                break;
            case "工作经验":
                $aset['experience'] = $a[1];
                break;
            case "等级":
                $aset['talent'] = $a[1];
                break;
            case "性别":
                $aset['sex'] = $a[1];
                // 添加搜索条件  男 女
                break;
            case "照片":
                $aset['photo'] = $a[1];
                break;
            case "关键字":
                $aset['key'] = $a[1];
                break;
            case "排序":
                $aset['displayorder'] = $a[1];
                break;
            case "分页显示":
                $aset['paged'] = $a[1];
                break;
            case "页面":
                $aset['showname'] = $a[1];
                break;
            case "列表页":
                $aset['listpage'] = $a[1];
                break;
            case "浏览过的简历":
                $aset['readresume'] = $a[1];
                break;
        }
    }
    if (is_array($aset)) {
        $aset = array_map("get_smarty_request", $aset);
    }
    $aset['listname'] = isset($aset['listname']) ? $aset['listname'] : "list";
    $aset['row'] = intval($aset['row']) > 0 ? intval($aset['row']) : 20;
    if ($aset['row'] > 20) {
        $aset['row'] = 20;
    }
    $aset['start'] = isset($aset['start']) ? intval($aset['start']) : 0;
    $aset['namelen'] = isset($aset['namelen']) ? intval($aset['namelen']) : 4;
    $aset['specialtylen'] = isset($aset['specialtylen']) ? intval($aset['specialtylen']) : 0;
    $aset['jobslen'] = isset($aset['jobslen']) ? intval($aset['jobslen']) : 0;
    $aset['majorlen'] = isset($aset['majorlen']) ? intval($aset['majorlen']) : 50;
    $aset['dot'] = isset($aset['dot']) ? $aset['dot'] : null;
    $aset['showname'] = isset($aset['showname']) ? $aset['showname'] : 'QS_resumeshow';
    $aset['listpage'] = isset($aset['listpage']) ? $aset['listpage'] : 'QS_resumelist';
    $resumetable = table('resume_search_rtime');
    if (isset($aset['displayorder'])) {
        $arr = explode('>', $aset['displayorder']);
        // 排序方式
        if ($arr[1] == 'desc') {
            $arr[1] = "desc";
        } elseif ($arr[1] == "asc") {
            $arr[1] = "asc";
        } else {
            $arr[1] = "desc";
        }
        if ($arr[0] == "rtime") {
            $orderbysql = " ORDER BY r.refreshtime {$arr[1]},id desc ";
        }
    } else {
        $orderbysql = " ORDER BY r.refreshtime desc,id desc ";
    }
    if (intval($_CFG['subsite_id']) > 0) {
        $wheresql .= " AND subsite_id=" . intval($_CFG['subsite_id']) . " ";
    }
    //应届生简历
    if (isset($aset['campu_sresume']) && !empty($aset['campu_sresume'])) {
        $wheresql .= " AND r.experience='-1' ";
    }
    //指定院校简历
    if (isset($aset['campusname']) && !empty($aset['campusname'])) {
        $joinwheresql_campusname .= " WHERE  school = '{$aset['campusname']}' ";
        $joinsql = "  INNER  JOIN  ( SELECT DISTINCT pid FROM " . table('resume_education') . " {$joinwheresql_campusname} )AS e ON  r.id=e.pid ";
    }
    //更新时间
    if (isset($aset['refreshtime']) && !empty($aset['refreshtime'])) {
        $refreshtime_min = strtotime("-" . $aset['refreshtime'] . "day");
        $wheresql .= " AND r.refreshtime > {$refreshtime_min} ";
    }
    if (!empty($aset['category']) || !empty($aset['subclass']) || !empty($aset['jobcategory'])) {
        if (!empty($aset['jobcategory'])) {
            $dsql = $xsql = "";
            $arr = explode("_", $aset['jobcategory']);
            $arr = array_unique($arr);
            foreach ($arr as $sid) {
                $cat = explode(".", $sid);
                if (intval($cat[2]) === 0) {
                    $dsql .= " OR category =" . intval($cat[1]);
                } else {
                    $xsql .= " OR subclass =" . intval($cat[2]);
                }
            }
            $joinwheresql .= " WHERE " . ltrim(ltrim($dsql . $xsql), 'OR');
        } else {
            if (!empty($aset['category'])) {
                if (strpos($aset['category'], "-")) {
                    $or = $orsql = "";
                    $arr = explode("-", $aset['category']);
                    $sqlin = implode(",", $arr);
                    if (count($arr) > 10) {
                        exit;
                    }
                    $sqlin = implode(",", $arr);
                    if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                        $joinwheresql .= " AND topclass IN  ({$sqlin}) ";
                    }
                } else {
                    $joinwheresql .= " AND  topclass=" . intval($aset['category']);
                }
            }
            if (!empty($aset['subclass'])) {
                if (strpos($aset['subclass'], "-")) {
                    $or = $orsql = "";
                    $arr = explode("-", $aset['subclass']);
                    if (count($arr) > 10) {
                        exit;
                    }
                    $sqlin = implode(",", $arr);
                    if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                        $joinwheresql .= " AND category IN  ({$sqlin}) ";
                    }
                } else {
                    $joinwheresql .= " AND category=" . intval($aset['subclass']);
                }
            }
            if (!empty($joinwheresql)) {
                $joinwheresql = " WHERE " . ltrim(ltrim($joinwheresql), 'AND');
            }
        }
        $joinsql = "  INNER  JOIN  ( SELECT DISTINCT pid FROM " . table('resume_jobs') . " {$joinwheresql} )AS j ON  r.id=j.pid ";
    }
    if (!empty($aset['trade'])) {
        if (strpos($aset['trade'], "_")) {
            $or = $orsql = "";
            $arr = explode("_", $aset['trade']);
            if (count($arr) > 10) {
                exit;
            }
            $sqlin = implode(",", $arr);
            if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                $joinwheresql_trade .= " AND trade IN  ({$sqlin}) ";
            }
        } else {
            $joinwheresql_trade .= " AND trade=" . intval($aset['trade']);
        }
        if (!empty($joinwheresql_trade)) {
            $joinwheresql_trade = " WHERE " . ltrim(ltrim($joinwheresql_trade), 'AND');
        }
        $joinsql = $joinsql == "" ? "  INNER  JOIN  ( SELECT DISTINCT pid FROM " . table('resume_trade') . " {$joinwheresql_trade} )AS t ON  r.id=t.pid " : $joinsql . "  INNER  JOIN  ( SELECT DISTINCT pid FROM " . table('resume_trade') . " {$joinwheresql_trade} )AS t ON  r.id=t.pid ";
    }
    if (isset($aset['settr']) && $aset['settr'] != '') {
        $settr = intval($aset['settr']);
        if ($settr > 0) {
            $settr_val = intval(strtotime("-" . $aset['settr'] . " day"));
            $wheresql .= " AND refreshtime>" . $settr_val;
        }
    }
    // major 专业搜索
    if (!empty($aset['major'])) {
        if (strpos($aset['major'], "_")) {
            $or = $orsql = "";
            $arr = explode("_", $aset['major']);
            if (count($arr) > 10) {
                exit;
            }
            $sqlin = implode(",", $arr);
            if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                $wheresql .= " AND r.major IN  ({$sqlin}) ";
            }
        } else {
            $wheresql .= " AND r.major=" . intval($aset['major']);
        }
    }
    if (!empty($aset['district']) || !empty($aset['sdistrict']) || !empty($aset['citycategory'])) {
        if (!empty($aset['citycategory'])) {
            $dsql = $xsql = "";
            $arr = explode("_", $aset['citycategory']);
            $arr = array_unique($arr);
            foreach ($arr as $sid) {
                $cat = explode(".", $sid);
                if (intval($cat[1]) === 0) {
                    $dsql .= " OR r.district =" . intval($cat[0]);
                } else {
                    $xsql .= " OR r.sdistrict =" . intval($cat[1]);
                }
            }
            $wheresql .= " AND  (" . ltrim(ltrim($dsql . $xsql), 'OR') . ") ";
        } else {
            if (isset($aset['district']) && $aset['district'] != '') {
                if (strpos($aset['district'], "-")) {
                    $or = $orsql = "";
                    $arr = explode("-", $aset['district']);
                    $arr = array_unique($arr);
                    if (count($arr) > 10) {
                        exit;
                    }
                    $sqlin = implode(",", $arr);
                    if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                        $wheresql .= " AND r.district IN  ({$sqlin}) ";
                    }
                } else {
                    $wheresql .= " AND r.district=" . intval($aset['district']) . " ";
                }
            }
            if (isset($aset['sdistrict']) && $aset['sdistrict'] != '') {
                if (strpos($aset['sdistrict'], "-")) {
                    $or = $orsql = "";
                    $arr = explode("-", $aset['sdistrict']);
                    $arr = array_unique($arr);
                    if (count($arr) > 10) {
                        exit;
                    }
                    $sqlin = implode(",", $arr);
                    if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                        $wheresql .= " AND r.sdistrict IN  ({$sqlin}) ";
                    }
                } else {
                    $wheresql .= " AND r.sdistrict=" . intval($aset['sdistrict']) . " ";
                }
            }
        }
    }
    if (isset($aset['experience']) && !empty($aset['experience'])) {
        $wheresql .= " AND r.experience=" . intval($aset['experience']) . " ";
    }
    if (isset($aset['education']) && !empty($aset['education'])) {
        $wheresql .= " AND r.education=" . intval($aset['education']) . " ";
    }
    if (isset($aset['talent']) && !empty($aset['talent'])) {
        $wheresql .= " AND r.talent=" . intval($aset['talent']) . " ";
    }
    if (isset($aset['sex']) && !empty($aset['sex'])) {
        $wheresql .= " AND r.sex=" . intval($aset['sex']) . " ";
        // 添加搜索条件  男 女
    }
    if (isset($aset['photo']) && !empty($aset['photo'])) {
        $wheresql .= " AND r.photo='" . intval($aset['photo']) . "' ";
    }
    if (isset($aset['key']) && !empty($aset['key'])) {
        if ($_CFG['resumesearch_purview'] == '2') {
            if ($_SESSION['username'] == '') {
                header("Location: " . url_rewrite('QS_login') . "?url=" . urlencode($_SERVER["REQUEST_URI"]));
            }
        }
        $key = help::addslashes_deep(trim($aset['key']));
        if ($_CFG['resumesearch_type'] == '1') {
            $akey = explode(' ', $key);
            if (count($akey) > 1) {
                $akey = array_filter($akey);
                $akey = array_slice($akey, 0, 2);
                $akey = array_map("fulltextpad", $akey);
                $key = '+' . implode(' +', $akey);
                $mode = ' IN BOOLEAN MODE';
            } else {
                $key = fulltextpad($key);
                $mode = ' ';
            }
            $wheresql .= " AND  MATCH (r.`key`) AGAINST ('{$key}'{$mode}) ";
        } else {
            $wheresql .= " AND r.likekey LIKE '%{$key}%' ";
        }
        $resumetable = table('resume_search_key');
    }
    if (!empty($aset['tag'])) {
        if (strpos($aset['tag'], ",")) {
            $or = $orsql = "";
            $arr = explode(",", $aset['tag']);
            if (count($arr) > 10) {
                exit;
            }
            $sqlin = implode(",", $arr);
            if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                $joinwheresql_tag .= " AND tag IN  ({$sqlin}) ";
            }
        } else {
            $joinwheresql_tag .= " AND tag=" . intval($aset['tag']);
        }
        if (!empty($joinwheresql_tag)) {
            $joinwheresql_tag = " WHERE " . ltrim(ltrim($joinwheresql_tag), 'AND');
        }
        $joinsql = $joinsql == "" ? "  INNER  JOIN  ( SELECT DISTINCT pid FROM " . table('resume_tag') . " {$joinwheresql_tag} )AS g ON  r.id=g.pid " : $joinsql . "  INNER  JOIN  ( SELECT DISTINCT pid FROM " . table('resume_tag') . " {$joinwheresql_tag} )AS g ON  r.id=g.pid ";
    }
    /* 搜索 时间范围 */
    $moth = intval($_CFG['search_time']);
    if ($moth > 0) {
        $moth_time = $moth * 3600 * 24 * 30;
        $time = time() - $moth_time;
        $wheresql .= " AND r.refreshtime>{$time} ";
    }
    $wheresql .= " AND r.display='1' AND r.audit='1' ";
    if (!empty($wheresql)) {
        $wheresql = " WHERE " . ltrim(ltrim($wheresql), 'AND');
    }
    if (isset($aset['paged'])) {
        require_once QISHI_ROOT_PATH . 'include/page.class.php';
        $total_sql = "SELECT  COUNT(*) AS num  FROM  {$resumetable} AS r " . $joinsql . $wheresql;
        $total_count = $db->get_total($total_sql);
        if (intval($_CFG['resume_list_max']) > 0) {
            $total_count > intval($_CFG['resume_list_max']) && ($total_count = intval($_CFG['resume_list_max']));
        }
        //如果是浏览过的简历 总数应该算cookie中的
        if ($aset['readresume']) {
            $total_count = count($_COOKIE['QS']['view_resume_log']);
        }
        //echo $total_sql;
        //echo "SELECT  COUNT(DISTINCT r.id) AS num  FROM  ".table('resume')." AS r ".$wheresql;
        $page = new page(array('total' => $total_count, 'perpage' => $aset['row'], 'alias' => $aset['listpage'], 'getarray' => $_GET));
        $currenpage = $page->nowindex;
        $aset['start'] = abs($currenpage - 1) * $aset['row'];
        if ($total_count > $aset['row']) {
            $smarty->assign('page', $page->show(8));
            $smarty->assign('pagemin', $page->show(7));
            $smarty->assign('pagenow', $page->show(6));
        }
        $smarty->assign('total', $total_count);
    }
    $limit = " LIMIT {$aset['start']} , {$aset['row']}";
    $list = $id = array();
    $idresult = $db->query("SELECT id FROM {$resumetable}  AS r" . $joinsql . $wheresql . $orderbysql . $limit);
    //echo "SELECT id FROM {$resumetable}  AS r".$joinsql.$wheresql.$orderbysql.$limit;
    // 如果是浏览过的简历,从cookie中获取简历的id
    if ($aset['readresume']) {
        foreach ($_COOKIE['QS']['view_resume_log'] as $value) {
            $id[] = $value;
        }
    } else {
        while ($row = $db->fetch_array($idresult)) {
            $id[] = $row['id'];
        }
    }
    if (!empty($id)) {
        $wheresql = " WHERE id IN (" . implode(',', $id) . ") and display!=3 ";
        $result = $db->query("SELECT id,subsite_id,uid,display,display_name,nature_cn,fullname,sex,major_cn,specialty,intention_jobs,trade_cn,photo,photo_img,photo_display,refreshtime,birthdate,tag_cn,talent,education_cn,sex_cn,wage_cn,experience_cn,district_cn,current_cn FROM " . table('resume') . "  AS r " . $joinsql . $wheresql . $orderbysql);
        while ($row = $db->fetch_array($result)) {
            if ($row['display_name'] == "2") {
                $row['fullname'] = "N" . str_pad($row['id'], 7, "0", STR_PAD_LEFT);
                $row['fullname_'] = $row['fullname'];
            } elseif ($row['display_name'] == "3") {
                if ($row['sex'] == 1) {
                    $row['fullname'] = cut_str($row['fullname'], 1, 0, "先生");
                } elseif ($row['sex'] == 2) {
                    $row['fullname'] = cut_str($row['fullname'], 1, 0, "女士");
                } else {
                    $row['fullname'] = cut_str($row['fullname'], 1, 0, "**");
                }
            } else {
                $row['fullname_'] = $row['fullname'];
                $row['fullname'] = cut_str($row['fullname'], $aset['namelen'], 0, $aset['dot']);
            }
            if (in_array($row['id'], $_COOKIE['QS']['view_resume_log'])) {
                $row['checked'] = true;
            } else {
                $row['checked'] = false;
            }
            $row['specialty_'] = strip_tags($row['specialty']);
            if ($aset['specialtylen'] > 0) {
                $row['specialty'] = cut_str(strip_tags($row['specialty']), $aset['specialtylen'], 0, $aset['dot']);
            }
            $row['intention_jobs_'] = $row['intention_jobs'];
            if ($aset['jobslen'] > 0) {
                $row['intention_jobs'] = cut_str(strip_tags($row['intention_jobs']), $aset['jobslen'], 0, $aset['dot']);
            }
            if ($aset['majorlen'] > 0) {
                $row['major_cn'] = cut_str(strip_tags($row['major_cn']), $aset['majorlen'], 0, $aset['dot']);
            }
            $row['trade_cn_'] = $row['trade_cn'];
            $row['trade_cn'] = cut_str(strip_tags($row['trade_cn']), 10, 0, "..");
            $row['resume_url'] = url_rewrite($aset['showname'], array('id' => $row['id']), 1, $row['subsite_id']);
            $row['refreshtime_cn'] = daterange(time(), $row['refreshtime'], 'Y-m-d', "#FF3300");
            $row['age'] = date("Y") - $row['birthdate'];
            if ($row['tag_cn']) {
                $tag_cn = explode(',', $row['tag_cn']);
                $row['tag_cn'] = $tag_cn;
            } else {
                $row['tag_cn'] = array();
            }
            // 照片显示方式
            if ($row['photo'] == "1") {
                if ($row['photo_display'] == "1") {
                    $row['photosrc'] = $_CFG['resume_photo_dir_thumb'] . $row['photo_img'];
                } else {
                    $row['photosrc'] = $_CFG['resume_photo_dir_thumb'] . "no_photo_display.gif";
                }
            } else {
                $row['photosrc'] = $_CFG['resume_photo_dir_thumb'] . "no_photo.gif";
            }
            //判断手机是否验证
            $is_audit_phone = $db->getone("SELECT mobile_audit FROM " . table('members') . " WHERE uid={$row['uid']}  LIMIT 1 ");
            $row['is_audit_mobile'] = $is_audit_phone['mobile_audit'];
            //语言能力
            $language = $db->getall("SELECT * FROM " . table('resume_language') . " WHERE pid={$row['id']} ");
            $row['language'] = $language;
            $list[] = $row;
        }
    } else {
        $list = array();
    }
    $smarty->assign($aset['listname'], $list);
}
示例#8
0
function tpl_function_qishi_news_list($params, &$smarty)
{
    global $db, $_CFG;
    $arrset = explode(',', $params['set']);
    foreach ($arrset as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "列表名":
                $aset['listname'] = $a[1];
                break;
            case "显示数目":
                $aset['row'] = $a[1];
                break;
            case "图片":
                $aset['img'] = $a[1];
                break;
            case "属性":
                $aset['attribute'] = $a[1];
                break;
            case "资讯大类":
                $aset['parentid'] = $a[1];
                break;
            case "资讯小类":
                $aset['type_id'] = $a[1];
                break;
            case "标题长度":
                $aset['titlelen'] = $a[1];
                break;
            case "摘要长度":
                $aset['infolen'] = $a[1];
                break;
            case "开始位置":
                $aset['start'] = $a[1];
                break;
            case "填补字符":
                $aset['dot'] = $a[1];
                break;
            case "日期范围":
                $aset['settr'] = $a[1];
                break;
            case "排序":
                $aset['displayorder'] = $a[1];
                break;
            case "关键字":
                $aset['key'] = $a[1];
                break;
            case "分页显示":
                $aset['paged'] = $a[1];
                break;
            case "页面":
                $aset['showname'] = $a[1];
                break;
            case "列表页":
                $aset['listpang'] = $a[1];
                break;
        }
    }
    if (is_array($aset)) {
        $aset = array_map("get_smarty_request", $aset);
    }
    $aset['listname'] = isset($aset['listname']) ? $aset['listname'] : "list";
    $aset['row'] = isset($aset['row']) ? intval($aset['row']) : 10;
    $aset['start'] = isset($aset['start']) ? intval($aset['start']) : 0;
    $aset['titlelen'] = isset($aset['titlelen']) ? intval($aset['titlelen']) : 15;
    $aset['infolen'] = isset($aset['infolen']) ? intval($aset['infolen']) : 0;
    $aset['showname'] = isset($aset['showname']) ? $aset['showname'] : 'QS_newsshow';
    $aset['listpang'] = isset($aset['listpang']) ? $aset['listpang'] : 'QS_newslist';
    if ($aset['displayorder']) {
        if (strpos($aset['displayorder'], '>')) {
            $arr = explode('>', $aset['displayorder']);
            // 排序字段
            if ($arr[0] == 'click') {
                $arr[0] = "click";
            } elseif ($arr[0] == "id") {
                $arr[0] = "id";
            } elseif ($arr[0] = 'article_order') {
                $arr[0] = 'article_order';
            } else {
                $arr[0] = "";
            }
            // 排序方式
            if ($arr[1] == 'desc') {
                $arr[1] = "desc";
            } elseif ($arr[1] == "asc") {
                $arr[1] = "asc";
            } else {
                $arr[1] = "";
            }
            if ($arr[0] && $arr[1]) {
                $orderbysql = " ORDER BY " . $arr[0] . " " . $arr[1];
            }
            if ($arr[0] == "article_order") {
                $orderbysql .= " ,id DESC ";
            }
        }
    }
    $wheresql = " WHERE is_display=1";
    isset($aset['parentid']) ? $wheresql .= " AND parentid=" . intval($aset['parentid']) . " " : '';
    isset($aset['type_id']) ? $wheresql .= " AND type_id=" . intval($aset['type_id']) . " " : '';
    isset($aset['attribute']) ? $wheresql .= " AND focos=" . intval($aset['attribute']) . " " : '';
    isset($aset['img']) ? $wheresql .= " AND Small_img<>'' " : '';
    if (isset($aset['settr'])) {
        $settr_val = strtotime("-" . intval($aset['settr']) . " day");
        $wheresql .= " AND addtime > " . $settr_val;
    }
    if (!empty($aset['key'])) {
        $key = help::addslashes_deep(trim($aset['key']));
        $wheresql .= " AND title like '%{$key}%'";
    }
    if (isset($aset['paged'])) {
        require_once QISHI_ROOT_PATH . 'include/page.class.php';
        $total_sql = "SELECT COUNT(*) AS num FROM " . table('article') . $wheresql;
        $total_count = $db->get_total($total_sql);
        $pagelist = new page(array('total' => $total_count, 'perpage' => $aset['row'], 'alias' => $aset['listpang'], 'getarray' => $_GET));
        $currenpage = $pagelist->nowindex;
        $aset['start'] = ($currenpage - 1) * $aset['row'];
        if ($total_count > $aset['row']) {
            $smarty->assign('page', $pagelist->show(3));
        } else {
            $smarty->assign('page', '');
        }
        $smarty->assign('total', $total_count);
    }
    $limit = " LIMIT " . abs($aset['start']) . ',' . $aset['row'];
    $result = $db->query("SELECT id,type_id,parentid,title,content,tit_color,tit_b,Small_img,author,source,focos,is_url,seo_description,seo_keywords,click,addtime FROM " . table('article') . " " . $wheresql . $orderbysql . $limit);
    $list = array();
    while ($row = $db->fetch_array($result)) {
        $row['title_'] = $row['title'];
        $style_color = $row['tit_color'] ? "color:" . $row['tit_color'] . ";" : '';
        $style_font = $row['tit_b'] == "1" ? "font-weight:bold;" : '';
        $row['title'] = cut_str($row['title'], $aset['titlelen'], 0, $aset['dot']);
        if ($style_color || $style_font) {
            $row['title'] = "<span style=" . $style_color . $style_font . ">" . $row['title'] . "</span>";
        }
        if (!empty($row['is_url']) && $row['is_url'] != 'http://') {
            $row['url'] = $row['is_url'];
        } else {
            $row['url'] = url_rewrite($aset['showname'], array('id' => $row['id']));
        }
        $row['content'] = str_replace('&nbsp;', '', $row['content']);
        $row['briefly_'] = strip_tags($row['content']);
        if ($aset['infolen'] > 0) {
            $row['briefly'] = cut_str(strip_tags($row['content']), $aset['infolen'], 0, $aset['dot']);
        }
        $row['img'] = $_CFG['thumb_dir'] . $row['Small_img'];
        $row['bimg'] = $_CFG['upfiles_dir'] . $row['Small_img'];
        $row['isimg'] = $row['Small_img'];
        // 不带路径,判断是否有缩略图,在news.htm页面用到
        $list[] = $row;
    }
    $smarty->assign($aset['listname'], $list);
}
示例#9
0
function tpl_function_qishi_jobs_list($params, &$smarty)
{
    global $db, $_CFG;
    $arrset = explode(',', $params['set']);
    foreach ($arrset as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "列表名":
                $aset['listname'] = $a[1];
                break;
            case "显示数目":
                $aset['row'] = $a[1];
                break;
            case "开始位置":
                $aset['start'] = $a[1];
                break;
            case "职位名长度":
                $aset['jobslen'] = $a[1];
                break;
            case "企业名长度":
                $aset['companynamelen'] = $a[1];
                break;
            case "描述长度":
                $aset['brieflylen'] = $a[1];
                break;
            case "填补字符":
                $aset['dot'] = $a[1];
                break;
            case "应届生职位":
                $aset['graduate'] = $a[1];
                break;
            case "职位分类":
                $aset['jobcategory'] = $a[1];
                break;
            case "职位大类":
                $aset['category'] = $a[1];
                break;
            case "职位小类":
                $aset['subclass'] = $a[1];
                break;
            case "地区分类":
                $aset['citycategory'] = $a[1];
                break;
            case "地区大类":
                $aset['district'] = $a[1];
                break;
            case "地区小类":
                $aset['sdistrict'] = $a[1];
                break;
            case "道路":
                $aset['street'] = $a[1];
                break;
            case "写字楼":
                $aset['officebuilding'] = $a[1];
                break;
            case "标签":
                $aset['tag'] = $a[1];
                break;
            case "行业":
                $aset['trade'] = $a[1];
                break;
            case "学历":
                $aset['education'] = $a[1];
                break;
            case "工作经验":
                $aset['experience'] = $a[1];
                break;
            case "工资":
                $aset['wage'] = $a[1];
                break;
            case "职位性质":
                $aset['nature'] = $a[1];
                break;
            case "公司规模":
                $aset['scale'] = $a[1];
                break;
            case "紧急招聘":
                $aset['emergency'] = $a[1];
                break;
            case "悬赏招聘":
                $aset['reward'] = $a[1];
                break;
            case "推荐":
                $aset['recommend'] = $a[1];
                break;
            case "关键字":
                $aset['key'] = $a[1];
                break;
            case "关键字类型":
                $aset['keytype'] = $a[1];
                break;
            case "日期范围":
                $aset['settr'] = $a[1];
                break;
            case "排序":
                $aset['displayorder'] = $a[1];
                break;
            case "分页显示":
                $aset['page'] = $a[1];
                break;
            case "会员UID":
                $aset['uid'] = $a[1];
                break;
            case "公司页面":
                $aset['companyshow'] = $a[1];
                break;
            case "职位页面":
                $aset['jobsshow'] = $a[1];
                break;
            case "列表页":
                $aset['listpage'] = $a[1];
                break;
            case "合并":
                $aset['mode'] = $a[1];
                break;
            case "公司列表名":
                $aset['comlistname'] = $a[1];
                break;
            case "公司职位页面":
                $aset['companyjobs'] = $a[1];
                break;
            case "单个公司显示职位数":
                $aset['companyjobs_row'] = $a[1];
                break;
            case "浏览过的职位":
                $aset['view_jobs'] = $a[1];
                break;
            case "风格模板":
                $aset['tpl_compnay'] = $a[1];
                break;
        }
    }
    $aset = array_map("get_smarty_request", $aset);
    $aset['listname'] = isset($aset['listname']) ? $aset['listname'] : "list";
    $aset['listpage'] = isset($aset['listpage']) ? $aset['listpage'] : "QS_jobslist";
    $aset['row'] = intval($aset['row']) > 0 ? intval($aset['row']) : 20;
    if ($aset['row'] > 20) {
        $aset['row'] = 20;
    }
    $aset['companyjobs_row'] = intval($aset['companyjobs_row']) > 0 ? intval($aset['companyjobs_row']) : 3;
    $aset['start'] = isset($aset['start']) ? intval($aset['start']) : 0;
    $aset['jobslen'] = isset($aset['jobslen']) ? intval($aset['jobslen']) : 8;
    $aset['companynamelen'] = isset($aset['companynamelen']) ? intval($aset['companynamelen']) : 15;
    $aset['brieflylen'] = isset($aset['brieflylen']) ? intval($aset['brieflylen']) : 0;
    $aset['companyshow'] = isset($aset['companyshow']) ? $aset['companyshow'] : 'QS_companyshow';
    $aset['jobsshow'] = isset($aset['jobsshow']) ? $aset['jobsshow'] : 'QS_jobsshow';
    $aset['companyjobs'] = isset($aset['companyjobs']) ? $aset['companyjobs'] : 'QS_companyjobs';
    $aset['mode'] = isset($aset['mode']) ? intval($aset['mode']) : 0;
    $openorderby = false;
    if (isset($aset['displayorder'])) {
        $arr = explode('>', $aset['displayorder']);
        // 排序方式
        if ($arr[1] == 'desc') {
            $arr[1] = "desc";
        } elseif ($arr[1] == "asc") {
            $arr[1] = "asc";
        } else {
            $arr[1] = "desc";
        }
        if ($arr[0] == "rtime") {
            $orderbysql = " ORDER BY  refreshtime {$arr[1]} , setmeal_id {$arr[1]}";
            $jobstable = table('jobs_search_rtime');
        } elseif ($arr[0] == "stickrtime") {
            $orderbysql = " ORDER BY stick {$arr[1]} , refreshtime {$arr[1]}  , setmeal_id {$arr[1]} ";
            $jobstable = table('jobs_search_stickrtime');
        } elseif ($arr[0] == "hot") {
            $orderbysql = " ORDER BY  click {$arr[1]} , setmeal_id {$arr[1]}";
            $jobstable = table('jobs_search_hot');
        } elseif ($arr[0] == "scale") {
            $orderbysql = " ORDER BY scale {$arr[1]} , refreshtime {$arr[1]} , setmeal_id {$arr[1]}  ";
            $jobstable = table('jobs_search_scale');
        } elseif ($arr[0] == "wage") {
            $orderbysql = " ORDER BY  wage {$arr[1]} ,refreshtime {$arr[1]}  , setmeal_id {$arr[1]}";
            $jobstable = table('jobs_search_wage');
        } elseif ($arr[0] == "key") {
            $jobstable = table('jobs_search_key');
        } elseif ($arr[0] == "null") {
            $orderbysql = "";
            $jobstable = table('jobs_search_rtime');
        } else {
            $orderbysql = " ORDER BY stick {$arr[1]} , setmeal_id {$arr[1]} , refreshtime {$arr[1]}";
            $jobstable = table('jobs_search_stickrtime');
        }
    } else {
        $orderbysql = " ORDER BY stick DESC , refreshtime DESC , setmeal_id desc ";
        $jobstable = table('jobs_search_stickrtime');
    }
    //应届生职位
    if (isset($aset['graduate']) && !empty($aset['graduate'])) {
        $wheresql .= " AND graduate=1 ";
    }
    if (isset($aset['settr']) && $aset['settr'] != '') {
        $settr = intval($aset['settr']);
        if ($settr > 0) {
            $settr_val = intval(strtotime("-" . $aset['settr'] . " day"));
            $wheresql .= " AND refreshtime>" . $settr_val;
        }
    }
    if (isset($aset['uid']) && $aset['uid'] != '') {
        $wheresql .= " AND uid=" . intval($aset['uid']);
    }
    if (isset($aset['emergency']) && $aset['emergency'] != '') {
        $wheresql .= " AND emergency=" . intval($aset['emergency']);
    }
    if (isset($aset['reward']) && $aset['reward'] != '') {
        $wheresql .= " AND reward=" . intval($aset['reward']);
    }
    if (isset($aset['recommend']) && $aset['recommend'] != '') {
        $wheresql .= " AND recommend=" . intval($aset['recommend']);
    }
    if (isset($aset['nature']) && $aset['nature'] != '') {
        if (strpos($aset['nature'], "-")) {
            $or = $orsql = "";
            $arr = explode("-", $aset['nature']);
            if (count($arr) > 10) {
                exit;
            }
            $sqlin = implode(",", $arr);
            if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                $wheresql .= " AND nature IN  (" . $sqlin . ") ";
            }
        } else {
            $wheresql .= " AND nature=" . intval($aset['nature']) . " ";
        }
    }
    if (isset($aset['scale']) && $aset['scale'] != '') {
        $wheresql .= " AND scale=" . intval($aset['scale']);
    }
    if (isset($aset['education']) && $aset['education'] != '') {
        $wheresql .= " AND education=" . intval($aset['education']);
    }
    if (isset($aset['wage']) && $aset['wage'] != '') {
        $wheresql .= " AND wage=" . intval($aset['wage']);
    }
    if (isset($aset['experience']) && $aset['experience'] != '') {
        $wheresql .= " AND experience=" . intval($aset['experience']);
    }
    if (isset($aset['trade']) && $aset['trade'] != '') {
        if (strpos($aset['trade'], "_")) {
            $or = $orsql = "";
            $arr = explode("_", $aset['trade']);
            $arr = array_unique($arr);
            if (count($arr) > 10) {
                exit;
            }
            $sqlin = implode(",", $arr);
            if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                $wheresql .= " AND trade IN  ({$sqlin}) ";
            }
        } else {
            $wheresql .= " AND trade=" . intval($aset['trade']) . " ";
        }
    }
    if (!empty($aset['citycategory'])) {
        $dsql = $xsql = "";
        $arr = explode("_", $aset['citycategory']);
        $arr = array_unique($arr);
        if (count($arr) > 10) {
            exit;
        }
        foreach ($arr as $sid) {
            $cat = explode(".", $sid);
            if (intval($cat[1]) === 0) {
                $dsql .= " OR district =" . intval($cat[0]);
            } else {
                $xsql .= " OR sdistrict =" . intval($cat[1]);
            }
        }
        $wheresql .= " AND  (" . ltrim(ltrim($dsql . $xsql), 'OR') . ") ";
    } else {
        if (isset($aset['district']) && $aset['district'] != '') {
            if (strpos($aset['district'], "-")) {
                $or = $orsql = "";
                $arr = explode("-", $aset['district']);
                $arr = array_unique($arr);
                if (count($arr) > 20) {
                    exit;
                }
                $sqlin = implode(",", $arr);
                if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                    $wheresql .= " AND district IN  ({$sqlin}) ";
                }
            } else {
                $wheresql .= " AND district =" . intval($aset['district']);
            }
        }
        if (isset($aset['sdistrict']) && $aset['sdistrict'] != '') {
            if (strpos($aset['sdistrict'], "-")) {
                $or = $orsql = "";
                $arr = explode("-", $aset['sdistrict']);
                $arr = array_unique($arr);
                if (count($arr) > 10) {
                    exit;
                }
                $sqlin = implode(",", $arr);
                if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                    $wheresql .= " AND sdistrict IN  ({$sqlin}) ";
                }
            } else {
                $wheresql .= " AND sdistrict =" . intval($aset['sdistrict']);
            }
        }
    }
    if (isset($aset['street']) && $aset['street'] != '') {
        $wheresql .= " AND street=" . intval($aset['street']);
    }
    if (isset($aset['officebuilding']) && $aset['officebuilding'] != '') {
        $wheresql .= " AND officebuilding=" . intval($aset['officebuilding']);
    }
    if (!empty($aset['jobcategory'])) {
        $dsql = $xsql = "";
        $arr = explode("_", $aset['jobcategory']);
        $arr = array_unique($arr);
        if (count($arr) > 10) {
            exit;
        }
        foreach ($arr as $sid) {
            $cat = explode(".", $sid);
            if (intval($cat[2]) === 0) {
                $dsql .= " OR category =" . intval($cat[1]);
            } else {
                $xsql .= " OR subclass =" . intval($cat[2]);
            }
        }
        $wheresql .= " AND  (" . ltrim(ltrim($dsql . $xsql), 'OR') . ") ";
    } else {
        if (isset($aset['category']) && $aset['category'] != '') {
            if (strpos($aset['category'], "-")) {
                $or = $orsql = "";
                $arr = explode("-", $aset['category']);
                $arr = array_unique($arr);
                if (count($arr) > 10) {
                    exit;
                }
                $sqlin = implode(",", $arr);
                if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                    $wheresql .= " AND topclass IN  ({$sqlin}) ";
                }
            } else {
                $wheresql .= " AND topclass = " . intval($aset['category']);
            }
        }
        if (isset($aset['subclass']) && $aset['subclass'] != '') {
            if (strpos($aset['subclass'], "-")) {
                $or = $orsql = "";
                $arr = explode("-", $aset['subclass']);
                $arr = array_unique($arr);
                if (count($arr) > 10) {
                    exit;
                }
                $sqlin = implode(",", $arr);
                if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                    $wheresql .= " AND category IN  ({$sqlin}) ";
                }
            } else {
                $wheresql .= " AND category = " . intval($aset['subclass']);
            }
        }
    }
    if (isset($aset['key']) && !empty($aset['key'])) {
        if ($_CFG['jobsearch_purview'] == '2') {
            if ($_SESSION['username'] == '') {
                header("Location: " . url_rewrite('QS_login') . "?url=" . urlencode($_SERVER["REQUEST_URI"]));
            }
        }
        $key = help::addslashes_deep(trim($aset['key']));
        if ($_CFG['jobsearch_type'] == '1') {
            $akey = explode(' ', $key);
            if (count($akey) > 1) {
                $akey = array_filter($akey);
                $akey = array_slice($akey, 0, 2);
                $akey = array_map("fulltextpad", $akey);
                $key = '+' . implode(' +', $akey);
                $mode = ' IN BOOLEAN MODE';
            } else {
                $key = fulltextpad($key);
                $mode = ' ';
            }
            $wheresql .= " AND  MATCH (`key`) AGAINST ('{$key}'{$mode}) ";
        } else {
            $wheresql .= " AND likekey LIKE '%{$key}%' ";
        }
        $orderbysql = " ORDER BY refreshtime DESC,id desc ";
        $jobstable = table('jobs_search_key');
    }
    /* 搜索 时间范围 */
    $moth = intval($_CFG['search_time']);
    if ($moth > 0) {
        $moth_time = $moth * 3600 * 24 * 30;
        $time = time() - $moth_time;
        $wheresql .= " AND refreshtime>{$time} ";
    }
    if (!empty($aset['tag'])) {
        $jobstable = $jobstable . ' as r ';
        if (strpos($aset['tag'], ",")) {
            $or = $orsql = "";
            $arr = explode(",", $aset['tag']);
            $sqlin = implode(",", $arr);
            if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                $joinwheresql_tag .= " AND tag IN  ({$sqlin}) ";
            }
        } else {
            $joinwheresql_tag .= " AND tag=" . intval($aset['tag']);
        }
        if (!empty($joinwheresql_tag)) {
            $joinwheresql_tag = " WHERE " . ltrim(ltrim($joinwheresql_tag), 'AND');
        }
        $joinsql = $joinsql == "" ? "  INNER  JOIN  ( SELECT DISTINCT pid FROM " . table('jobs_tag') . " {$joinwheresql_tag} ) AS g ON  r.id=g.pid " : $joinsql . "  INNER  JOIN  ( SELECT DISTINCT pid FROM " . table('jobs_tag') . " {$joinwheresql_tag} )AS g ON  r.id=g.pid ";
    }
    if (!empty($wheresql)) {
        $wheresql = " WHERE " . ltrim(ltrim($wheresql), 'AND');
    }
    if (isset($aset['page'])) {
        require_once QISHI_ROOT_PATH . 'include/page.class.php';
        $total_sql = "SELECT COUNT(*) AS num FROM {$jobstable} {$joinsql} {$wheresql}";
        //echo $total_sql;
        $total_count = $db->get_total($total_sql);
        if ($_CFG['jobs_list_max'] > 0) {
            $total_count > intval($_CFG['jobs_list_max']) && ($total_count = intval($_CFG['jobs_list_max']));
        }
        //如果是浏览过的职位 总数应该算cookie中的
        if ($aset['view_jobs']) {
            $total_count = count($_COOKIE['QS']['view_jobs_log']);
        }
        $page = new page(array('total' => $total_count, 'perpage' => $aset['row'], 'alias' => $aset['listpage'], 'getarray' => $_GET));
        $currenpage = $page->nowindex;
        $aset['start'] = abs($currenpage - 1) * $aset['row'];
        if ($total_count > $aset['row']) {
            $smarty->assign('page', $page->show(8));
            $smarty->assign('pagemin', $page->show(7));
            $smarty->assign('pagenow', $page->show(6));
        }
        $smarty->assign('total', $total_count);
    }
    $limit = " LIMIT {$aset['start']} , {$aset['row']}";
    $list = $id = $com_list = array();
    $idresult = $db->query("SELECT id FROM {$jobstable} " . $joinsql . $wheresql . $orderbysql . $limit);
    //echo "SELECT id FROM {$jobstable} ".$wheresql.$orderbysql.$limit;
    // 如果是浏览过的职位,从cookie中获取职位的id
    if ($aset['view_jobs']) {
        foreach ($_COOKIE['QS']['view_jobs_log'] as $value) {
            $id[] = $value;
        }
    } else {
        while ($row = $db->fetch_array($idresult)) {
            $id[] = $row['id'];
        }
    }
    if (!empty($id)) {
        $wheresql = " WHERE id IN (" . implode(',', $id) . ") ";
        $result = $db->query("SELECT id,jobs_name,recommend,emergency,stick,highlight,companyname,company_id,company_audit,nature_cn,sex_cn,age,amount,category_cn,graduate,trade_cn,scale,scale_cn,district_cn,street_cn,tag_cn,education_cn,experience_cn,wage,wage_cn,contents,setmeal_id,setmeal_name,refreshtime,click FROM " . table('jobs') . " AS r " . $joinsql . $wheresql . $orderbysql);
        while ($row = $db->fetch_array($result)) {
            $row['jobs_name_'] = $row['jobs_name'];
            $row['refreshtime_cn'] = daterange(time(), $row['refreshtime'], 'Y-m-d', "#FF3300");
            $row['jobs_name'] = cut_str($row['jobs_name'], $aset['jobslen'], 0, $aset['dot']);
            if (!empty($row['highlight'])) {
                $row['jobs_name'] = "<span style=\"color:{$row['highlight']}\">{$row['jobs_name']}</span>";
            }
            if ($aset['brieflylen'] > 0) {
                $row['briefly'] = cut_str(strip_tags($row['contents']), $aset['brieflylen'], 0, $aset['dot']);
            } else {
                $row['briefly'] = strip_tags($row['contents']);
            }
            $row['amount'] = $row['amount'] == "0" ? '若干' : $row['amount'];
            $row['briefly_'] = strip_tags($row['contents']);
            $row['companyname_'] = $row['companyname'];
            $row['companyname'] = cut_str($row['companyname'], $aset['companynamelen'], 0, $aset['dot']);
            $row['jobs_url'] = url_rewrite($aset['jobsshow'], array('id' => $row['id'], 'style' => $aset['tpl_compnay']));
            $row['company_url'] = url_rewrite($aset['companyshow'], array('id' => $row['company_id']));
            $row['wage_newcn'] = str_replace("元/月", "", $row['wage_cn']);
            if (isset($aset['reward']) && $aset['reward'] != '') {
                $rs = $db->getone("SELECT  cp_json from " . table("promotion") . " where cp_promotionid=5 and cp_jobid={$row['id']} ");
                $json = str_replace('&quot;', '"', trim($rs["cp_json"]));
                $row['block_balance'] = json_decode($json)->block_balance;
            }
            if ($row['tag_cn']) {
                $tag_cn = explode(',', $row['tag_cn']);
                $row['tag_cn'] = $tag_cn;
            } else {
                $row['tag_cn'] = array();
            }
            //合并公司 显示模式
            if ($aset['mode'] == 1) {
                //统计单个公司符合条件职位数
                $count_com = $db->get_total("SELECT COUNT(*) AS num FROM " . table('jobs') . "  WHERE  company_id=" . $row['company_id']);
                $row['count'] = $count_com;
                $row['count_url'] = $row['company_url'];
                $list[$row['company_id']][] = $row;
            } else {
                $list[] = $row;
            }
        }
    } else {
        $list = array();
    }
    $smarty->assign($aset['listname'], $list);
}
function tpl_function_qishi_company_list($params, &$smarty)
{
    global $db, $_CFG;
    $arrset = explode(',', $params['set']);
    foreach ($arrset as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "列表名":
                $aset['listname'] = $a[1];
                break;
            case "显示数目":
                $aset['row'] = $a[1];
                break;
            case "开始位置":
                $aset['start'] = $a[1];
                break;
            case "企业名长度":
                $aset['companynamelen'] = $a[1];
                break;
            case "描述长度":
                $aset['brieflylen'] = $a[1];
                break;
            case "填补字符":
                $aset['dot'] = $a[1];
                break;
            case "行业":
                $aset['trade'] = $a[1];
                break;
            case "地区分类":
                $aset['citycategory'] = $a[1];
                break;
            case "地区大类":
                $aset['district'] = $a[1];
                break;
            case "地区小类":
                $aset['sdistrict'] = $a[1];
                break;
            case "企业性质":
                $aset['nature'] = $a[1];
                break;
            case "黄页":
                $aset['yellowpages'] = $a[1];
                break;
            case "关键字":
                $aset['key'] = $a[1];
                break;
            case "排序":
                $aset['displayorder'] = $a[1];
                break;
            case "分页显示":
                $aset['paged'] = $a[1];
                break;
            case "公司页面":
                $aset['companyshow'] = $a[1];
                break;
            case "列表页":
                $aset['listpage'] = $a[1];
                break;
            case "规模":
                $aset['scale'] = $a[1];
                break;
        }
    }
    if (is_array($aset)) {
        $aset = array_map("get_smarty_request", $aset);
    }
    $aset['listname'] = isset($aset['listname']) ? $aset['listname'] : "list";
    $aset['row'] = !empty($aset['row']) ? intval($aset['row']) : 10;
    $aset['start'] = isset($aset['start']) ? intval($aset['start']) : 0;
    $aset['companynamelen'] = isset($aset['companynamelen']) ? intval($aset['companynamelen']) : 16;
    $aset['dot'] = isset($aset['dot']) ? $aset['dot'] : '';
    $aset['companyshow'] = isset($aset['companyshow']) ? $aset['companyshow'] : 'QS_companyshow';
    $aset['listpage'] = !empty($aset['listpage']) ? $aset['listpage'] : 'QS_companylist';
    if ($aset['displayorder']) {
        if (strpos($aset['displayorder'], '>')) {
            $arr = explode('>', $aset['displayorder']);
            // 排序字段
            if ($arr[0] == 'click') {
                $arr[0] = "click";
            } elseif ($arr[0] == "id") {
                $arr[0] = "id";
            } else {
                $arr[0] = "";
            }
            // 排序方式
            if ($arr[1] == 'desc') {
                $arr[1] = "desc";
            } elseif ($arr[1] == "asc") {
                $arr[1] = "asc";
            } else {
                $arr[1] = "";
            }
            if ($arr[0] && $arr[1]) {
                $orderbysql = " ORDER BY `" . $arr[0] . "` " . $arr[1];
            }
        }
    }
    if (isset($aset['trade']) && intval($aset['trade']) > 0) {
        $wheresql .= " AND trade=" . intval($aset['trade']);
    }
    if (isset($aset['nature']) && intval($aset['nature']) > 0) {
        $wheresql .= " AND nature=" . intval($aset['nature']);
    }
    if (isset($aset['scale']) && intval($aset['scale']) > 0) {
        $wheresql .= " AND scale=" . intval($aset['scale']);
    }
    if (!empty($aset['citycategory'])) {
        $dsql = $xsql = "";
        $arr = explode(",", $aset['citycategory']);
        $arr = array_unique($arr);
        if (count($arr) > 10) {
            exit;
        }
        foreach ($arr as $sid) {
            $cat = explode(".", $sid);
            if (intval($cat[1]) === 0) {
                $dsql .= " OR district =" . intval($cat[0]);
            } else {
                $xsql .= " OR sdistrict =" . intval($cat[1]);
            }
        }
        $wheresql .= " AND  (" . ltrim(ltrim($dsql . $xsql), 'OR') . ") ";
    } else {
        if (isset($aset['district']) && $aset['district'] != '') {
            if (strpos($aset['district'], "-")) {
                $or = $orsql = "";
                $arr = explode("-", $aset['district']);
                $arr = array_unique($arr);
                if (count($arr) > 20) {
                    exit;
                }
                $sqlin = implode(",", $arr);
                if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                    $wheresql .= " AND district IN  ({$sqlin}) ";
                }
            } else {
                $wheresql .= " AND district =" . intval($aset['district']);
            }
        }
        if (isset($aset['sdistrict']) && $aset['sdistrict'] != '') {
            if (strpos($aset['sdistrict'], "-")) {
                $or = $orsql = "";
                $arr = explode("-", $aset['sdistrict']);
                $arr = array_unique($arr);
                if (count($arr) > 10) {
                    exit;
                }
                $sqlin = implode(",", $arr);
                if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                    $wheresql .= " AND sdistrict IN  ({$sqlin}) ";
                }
            } else {
                $wheresql .= " AND sdistrict =" . intval($aset['sdistrict']);
            }
        }
    }
    if (!empty($aset['key'])) {
        $key = help::addslashes_deep(trim($aset['key']));
        $wheresql .= " AND companyname like '%{$key}%'";
    }
    if (!empty($wheresql)) {
        $wheresql = " WHERE " . ltrim(ltrim($wheresql), 'AND');
    }
    if (isset($aset['paged'])) {
        require_once QISHI_ROOT_PATH . 'include/page.class.php';
        $total_sql = "SELECT COUNT(*) AS num FROM " . table('company_profile') . $wheresql;
        $total_count = $db->get_total($total_sql);
        $pagelist = new page(array('total' => $total_count, 'perpage' => $aset['row'], 'alias' => $aset['listpage'], 'getarray' => $_GET));
        $currenpage = $pagelist->nowindex;
        $aset['start'] = ($currenpage - 1) * $aset['row'];
        if ($total_count > $aset['row']) {
            $smarty->assign('page', $pagelist->show(3));
        }
        $smarty->assign('total', $total_count);
    }
    $limit = " LIMIT " . abs($aset['start']) . ',' . $aset['row'];
    $result = $db->query("SELECT id,companyname,contents,logo,audit,trade_cn,district_cn,nature_cn FROM " . table('company_profile') . " " . $wheresql . $orderbysql . $limit);
    $list = array();
    if (intval($_CFG['subsite_id']) > 0) {
        $countwheresql = ' and subsite_id=' . intval($_CFG['subsite_id']);
    } else {
        $countwheresql = '';
    }
    while ($row = $db->fetch_array($result)) {
        $row['companyname_'] = $row['companyname'];
        $row['companyname'] = cut_str($row['companyname'], $aset['companynamelen'], 0, $aset['dot']);
        $row['url'] = url_rewrite($aset['companyshow'], array('id' => $row['id']));
        $row['contents'] = str_replace('&nbsp;', '', $row['contents']);
        $row['briefly_'] = strip_tags($row['contents']);
        $row['briefly'] = strip_tags($row['briefly_']);
        if ($aset['brieflylen'] > 0) {
            $row['briefly'] = cut_str(strip_tags($row['contents']), $aset['brieflylen'], 0, $aset['dot']);
        }
        if ($row['logo']) {
            $row['logo'] = $_CFG['site_dir'] . "data/logo/" . $row['logo'];
        } else {
            $row['logo'] = $_CFG['site_dir'] . "data/logo/no_logo.gif";
        }
        $row['jobs_num'] = $db->get_total("select count(*) as num from " . table('jobs') . " where company_id=" . $row['id'] . $countwheresql);
        $row['comment_num'] = $db->get_total("select count(*) as num from " . table('comment') . " where company_id=" . $row['id'] . " and audit=1");
        $list[] = $row;
    }
    $smarty->assign($aset['listname'], $list);
}
function tpl_function_qishi_hunter_jobs_list($params, &$smarty)
{
    global $db, $_CFG;
    $arrset = explode(',', $params['set']);
    foreach ($arrset as $str) {
        $a = explode(':', $str);
        switch ($a[0]) {
            case "列表名":
                $aset['listname'] = $a[1];
                break;
            case "显示数目":
                $aset['row'] = $a[1];
                break;
            case "开始位置":
                $aset['start'] = $a[1];
                break;
            case "职位名长度":
                $aset['jobslen'] = $a[1];
                break;
            case "企业名长度":
                $aset['companynamelen'] = $a[1];
                break;
            case "描述长度":
                $aset['brieflylen'] = $a[1];
                break;
            case "填补字符":
                $aset['dot'] = $a[1];
                break;
            case "职位分类":
                $aset['jobcategory'] = $a[1];
                break;
            case "职位大类":
                $aset['category'] = $a[1];
                break;
            case "职位小类":
                $aset['subclass'] = $a[1];
                break;
            case "地区分类":
                $aset['citycategory'] = $a[1];
                break;
            case "地区大类":
                $aset['district'] = $a[1];
                break;
            case "地区小类":
                $aset['sdistrict'] = $a[1];
                break;
            case "学历":
                $aset['education'] = $a[1];
                break;
            case "工作经验":
                $aset['experience'] = $a[1];
                break;
            case "年龄":
                $aset['age'] = $a[1];
                break;
            case "工资":
                $aset['wage'] = $a[1];
                break;
            case "行业":
                $aset['trade'] = $a[1];
                break;
            case "公司规模":
                $aset['scale'] = $a[1];
                break;
            case "关键字":
                $aset['key'] = $a[1];
                break;
            case "推荐":
                $aset['recommend'] = $a[1];
                break;
            case "关键字类型":
                $aset['keytype'] = $a[1];
                break;
            case "日期范围":
                $aset['settr'] = $a[1];
                break;
            case "排序":
                $aset['displayorder'] = $a[1];
                break;
            case "分页显示":
                $aset['page'] = $a[1];
                break;
            case "会员UID":
                $aset['uid'] = $a[1];
                break;
            case "公司页面":
                $aset['companyshow'] = $a[1];
                break;
            case "职位页面":
                $aset['jobsshow'] = $a[1];
                break;
            case "列表页":
                $aset['listpage'] = $a[1];
                break;
        }
    }
    $timenow = time();
    $aset = array_map("get_smarty_request", $aset);
    $aset['listname'] = isset($aset['listname']) ? $aset['listname'] : "list";
    $aset['listpage'] = isset($aset['listpage']) ? $aset['listpage'] : "QS_hunter_jobslist";
    $aset['row'] = intval($aset['row']) > 0 ? intval($aset['row']) : 10;
    if ($aset['row'] > 30) {
        $aset['row'] = 30;
    }
    $aset['start'] = isset($aset['start']) ? intval($aset['start']) : 0;
    $aset['jobslen'] = isset($aset['jobslen']) ? intval($aset['jobslen']) : 8;
    $aset['companynamelen'] = isset($aset['companynamelen']) ? intval($aset['companynamelen']) : 15;
    $aset['recommend'] = isset($aset['recommend']) ? intval($aset['recommend']) : '';
    $aset['brieflylen'] = isset($aset['brieflylen']) ? intval($aset['brieflylen']) : 0;
    $aset['companyshow'] = isset($aset['companyshow']) ? $aset['companyshow'] : 'QS_companyshow';
    $aset['jobsshow'] = isset($aset['jobsshow']) ? $aset['jobsshow'] : 'QS_hunter_jobsshow';
    if (isset($aset['displayorder'])) {
        $arr = explode('>', $aset['displayorder']);
        // 排序方式
        if ($arr[1] == 'desc') {
            $arr[1] = "desc";
        } elseif ($arr[1] == "asc") {
            $arr[1] = "asc";
        } else {
            $arr[1] = "desc";
        }
        if ($arr[0] == "rtime") {
            $orderbysql = " ORDER BY refreshtime {$arr[1]}";
        } elseif ($arr[0] == "atime") {
            $orderbysql = " ORDER BY addtime {$arr[1]}";
        } elseif ($arr[0] == "hot") {
            $orderbysql = " ORDER BY click {$arr[1]}";
        } elseif ($arr[0] == "scale") {
            $orderbysql = " ORDER BY scale {$arr[1]},refreshtime {$arr[1]}";
        } elseif ($arr[0] == "wage") {
            $orderbysql = " ORDER BY wage {$arr[1]},refreshtime {$arr[1]}";
        } else {
            $orderbysql = " ORDER BY refreshtime {$arr[1]}";
        }
    }
    if (intval($_CFG['subsite_id']) > 0) {
        $wheresql .= " AND subsite_id=" . intval($_CFG['subsite_id']) . " ";
    }
    if (isset($aset['settr']) && $aset['settr'] != '') {
        $settr = intval($aset['settr']);
        if ($settr > 0) {
            $settr_val = intval(strtotime("-" . $aset['settr'] . " day"));
            $wheresql .= " AND refreshtime>" . $settr_val;
        }
    }
    if (isset($aset['uid']) && $aset['uid'] != '') {
        $wheresql .= " AND uid=" . intval($aset['uid']);
    }
    if (isset($aset['recommend']) && $aset['recommend'] != '') {
        $wheresql .= " AND recommend=" . intval($aset['recommend']);
    }
    if (isset($aset['education']) && $aset['education'] != '') {
        $wheresql .= " AND education=" . intval($aset['education']);
    }
    if (isset($aset['scale']) && $aset['scale'] != '') {
        $wheresql .= " AND scale=" . intval($aset['scale']);
    }
    if (isset($aset['wage']) && $aset['wage'] != '') {
        $wheresql .= " AND wage=" . intval($aset['wage']);
    }
    if (isset($aset['experience']) && $aset['experience'] != '') {
        $wheresql .= " AND experience=" . intval($aset['experience']);
    }
    if (isset($aset['age']) && $aset['age'] != '') {
        $wheresql .= " AND age=" . intval($aset['age']);
    }
    if (isset($aset['trade']) && $aset['trade'] != '') {
        if (strpos($aset['trade'], "_")) {
            $or = $orsql = "";
            $arr = explode("_", $aset['trade']);
            $arr = array_unique($arr);
            if (count($arr) > 10) {
                exit;
            }
            $sqlin = implode(",", $arr);
            if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                $wheresql .= " AND trade IN  ({$sqlin}) ";
            }
        } else {
            $wheresql .= " AND trade=" . intval($aset['trade']) . " ";
        }
    }
    if (!empty($aset['jobcategory'])) {
        $dsql = $xsql = "";
        $arr = explode("_", $aset['jobcategory']);
        $arr = array_unique($arr);
        if (count($arr) > 10) {
            exit;
        }
        foreach ($arr as $sid) {
            $cat = explode(".", $sid);
            if (intval($cat[1]) === 0) {
                $dsql .= " OR category =" . intval($cat[0]);
            } else {
                $xsql .= " OR subclass =" . intval($cat[1]);
            }
        }
        $wheresql .= " AND  (" . ltrim(ltrim($dsql . $xsql), 'OR') . ") ";
    } else {
        if (isset($aset['category']) && $aset['category'] != '') {
            if (strpos($aset['category'], "-")) {
                $or = $orsql = "";
                $arr = explode("-", $aset['category']);
                $arr = array_unique($arr);
                if (count($arr) > 10) {
                    exit;
                }
                $sqlin = implode(",", $arr);
                if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                    $wheresql .= " AND category IN  ({$sqlin}) ";
                }
            } else {
                $wheresql .= " AND category = " . intval($aset['category']);
            }
        }
        if (isset($aset['subclass']) && $aset['subclass'] != '') {
            if (strpos($aset['subclass'], "-")) {
                $or = $orsql = "";
                $arr = explode("-", $aset['subclass']);
                $arr = array_unique($arr);
                if (count($arr) > 10) {
                    exit;
                }
                $sqlin = implode(",", $arr);
                if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                    $wheresql .= " AND subclass IN  ({$sqlin}) ";
                }
            } else {
                $wheresql .= " AND subclass = " . intval($aset['subclass']);
            }
        }
    }
    if (!empty($aset['citycategory'])) {
        $dsql = $xsql = "";
        $arr = explode("_", $aset['citycategory']);
        $arr = array_unique($arr);
        if (count($arr) > 10) {
            exit;
        }
        foreach ($arr as $sid) {
            $cat = explode(".", $sid);
            if (intval($cat[1]) === 0) {
                $dsql .= " OR district =" . intval($cat[0]);
            } else {
                $xsql .= " OR sdistrict =" . intval($cat[1]);
            }
        }
        $wheresql .= " AND  (" . ltrim(ltrim($dsql . $xsql), 'OR') . ") ";
    } else {
        if (isset($aset['district']) && $aset['district'] != '') {
            if (strpos($aset['district'], "-")) {
                $or = $orsql = "";
                $arr = explode("-", $aset['district']);
                $arr = array_unique($arr);
                if (count($arr) > 20) {
                    exit;
                }
                $sqlin = implode(",", $arr);
                if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                    $wheresql .= " AND district IN  ({$sqlin}) ";
                }
            } else {
                $wheresql .= " AND district =" . intval($aset['district']);
            }
        }
        if (isset($aset['sdistrict']) && $aset['sdistrict'] != '') {
            if (strpos($aset['sdistrict'], "-")) {
                $or = $orsql = "";
                $arr = explode("-", $aset['sdistrict']);
                $arr = array_unique($arr);
                if (count($arr) > 10) {
                    exit;
                }
                $sqlin = implode(",", $arr);
                if (preg_match("/^(\\d{1,10},)*(\\d{1,10})\$/", $sqlin)) {
                    $wheresql .= " AND sdistrict IN  ({$sqlin}) ";
                }
            } else {
                $wheresql .= " AND sdistrict =" . intval($aset['sdistrict']);
            }
        }
    }
    if (isset($aset['key']) && !empty($aset['key'])) {
        if ($_CFG['hunterjobsearch_purview'] == '2') {
            if ($_SESSION['username'] == '') {
                header("Location: " . url_rewrite('QS_login') . "?url=" . urlencode($_SERVER["REQUEST_URI"]));
            }
        }
        $key = help::addslashes_deep(trim($aset['key']));
        if ($_CFG['hunterjobsearch_type'] == '1') {
            $akey = explode(' ', $key);
            if (count($akey) > 1) {
                $akey = array_filter($akey);
                $akey = array_slice($akey, 0, 2);
                $akey = array_map("fulltextpad", $akey);
                $key = '+' . implode(' +', $akey);
                $mode = ' IN BOOLEAN MODE';
            } else {
                $key = fulltextpad($key);
                $mode = ' ';
            }
            $wheresql .= " AND  MATCH (`key`) AGAINST ('{$key}'{$mode}) ";
        } else {
            $wheresql .= " AND likekey LIKE '%{$key}%' ";
        }
        $jobstable = table('jobs_search_key');
    }
    if ($_CFG['operation_hunter_mode'] == '1') {
        $wheresql .= "  AND audit=1  AND display=1 ";
    } elseif ($_CFG['operation_hunter_mode'] == '2') {
        $wheresql .= "  AND audit=1 AND display=1 AND setmeal_id>0 AND (setmeal_deadline>{$timenow} OR setmeal_deadline=0)";
    }
    if (!empty($wheresql)) {
        $wheresql = " WHERE " . ltrim(ltrim($wheresql), 'AND');
    }
    //echo "SELECT * FROM ".table('hunter_jobs')." ".$wheresql.$orderbysql.$limit;
    if (isset($aset['page'])) {
        require_once QISHI_ROOT_PATH . 'include/page.class.php';
        $total_sql = "SELECT COUNT(*) AS num FROM " . table('hunter_jobs') . " {$wheresql}";
        //echo $total_sql;
        //echo "<br>";
        $total_count = $db->get_total($total_sql);
        if ($_CFG['hunter_list_max'] > 0) {
            $total_count > intval($_CFG['hunter_list_max']) && ($total_count = intval($_CFG['hunter_list_max']));
        }
        $page = new page(array('total' => $total_count, 'perpage' => $aset['row'], 'alias' => $aset['listpage'], 'getarray' => $_GET));
        $currenpage = $page->nowindex;
        $aset['start'] = abs($currenpage - 1) * $aset['row'];
        if ($total_count > $aset['row']) {
            $smarty->assign('page', $page->show(8));
            $smarty->assign('pagemin', $page->show(7));
        }
        $smarty->assign('total', $total_count);
    }
    $limit = " LIMIT {$aset['start']} , {$aset['row']}";
    $list = $id = array();
    $result = $db->query("SELECT id,subsite_id,jobs_name,contents,jobs_qualified,companyname,refreshtime,district_cn,wage_cn FROM " . table('hunter_jobs') . $wheresql . $orderbysql . $limit);
    while ($row = $db->fetch_array($result)) {
        $row['jobs_name_'] = $row['jobs_name'];
        $row['jobs_name'] = cut_str($row['jobs_name'], $aset['jobslen'], 0, $aset['dot']);
        if ($aset['brieflylen'] > 0) {
            $row['briefly'] = cut_str(strip_tags($row['contents']), $aset['brieflylen'], 0, $aset['dot']);
            $row['jobs_qualified'] = cut_str(strip_tags($row['jobs_qualified']), $aset['brieflylen'], 0, $aset['dot']);
        } else {
            $row['briefly'] = strip_tags($row['contents']);
            $row['jobs_qualified'] = strip_tags($row['jobs_qualified']);
        }
        $row['amount'] = $row['amount'] == "0" ? '若干' : $row['amount'];
        $row['briefly_'] = strip_tags($row['contents']);
        $row['companyname_'] = $row['companyname'];
        $row['companyname'] = cut_str($row['companyname'], $aset['companynamelen'], 0, $aset['dot']);
        $row['jobs_url'] = url_rewrite($aset['jobsshow'], array('id' => $row['id']), 1, $row['subsite_id']);
        $row['company_url'] = url_rewrite($aset['companyshow'], array('id' => $row['company_id']));
        $row['refreshtime_cn'] = daterange(time(), $row['refreshtime'], 'Y-m-d', "#FF3300");
        $list[] = $row;
    }
    $smarty->assign($aset['listname'], $list);
}