<?php

function get_cond_arr() {
    //年月日数组
    GLOBAL $year_arr, $month_arr, $day_arr;
    $year_arr = array();
    $month_arr = array();
    $day_arr = array();
    for ($i = date("Y"); $i >= 2008; $i--)
        $year_arr[$i] = $i;
    for ($i = 1; $i <= 12; $i++)
        $month_arr[$i] = $i;
    for ($i = 1; $i <= date("t"); $i++)
        $day_arr[$i] = $i;

    //查询条件1
    GLOBAL $cond_arr_1;
    $cond_arr_1 = array();
    $cond_arr_1["none"] = "* 请选择 *";
    $cond_arr_1["gb_pubdate"] = "发布日期";

    //查询条件2
    GLOBAL $cond_arr_2;
    $cond_arr_2 = array();
    $cond_arr_2["none"] = "* 请选择 *";
    $cond_arr_2["schoolname"] = "学校";
   // $cond_arr_2["areatype"] = "区属";


    //排序条件
    GLOBAL $orderby_arr;
    $orderby_arr = array();
    $orderby_arr["id"] = "&nbsp;编号&nbsp;";
    $orderby_arr["weight"] = "&nbsp;显示顺序&nbsp;";

    GLOBAL $asc_desc_arr;
    $asc_desc_arr = array();
    $asc_desc_arr["desc"] = "&nbsp;倒序排列&nbsp;";
    $asc_desc_arr["asc"] = "&nbsp;正序排列&nbsp;"; //方向
}

function get_orderby_str($d) {
    GLOBAL $orderby_arr;
    GLOBAL $asc_desc_arr;

    if (isset($orderby_arr[$d["orderby"]]))
        $ss = " order by " . $d["orderby"];

    if (isset($asc_desc_arr[$d["asc_desc"]]))
        $ss.=" " . $d["asc_desc"];

    return $ss;
}

function get_query_str(&$d, $q_ext = "") {//$cond_arr只做检测用
    global $cond_arr_1, $cond_arr_2, $set_arr, $set_flag_arr;
    //字串条件
    if ((isset($cond_arr_2[$d["cond2"]])) and ($d["cond2"] != "none") and ($d["cond2"] != "0")) {
        if ($ss != "")
            $ss.=" and ";
        $ss.=" " . $d["cond2"] . " like '%" . qstr($d["cond2_val"]) . "%' ";
    }

    if ($q_ext != "") {
        if ($ss != "")
            $ss.=" and ";
        $ss.=$q_ext;
    }

    //组合
    if ($ss != "")
        $ss = " where " . $ss;

    return $ss;
}

//删除处理
function msg_del($id) {
    GLOBAL $db, $tbl;

    //删除记录
    $q = "delete from $tbl where id=" . intval($id);
    $db->Execute($q);
}

function doaction($type, $id) {
    GLOBAL $db, $tbl;
    $id2 = explode(",,", $id);
    $aa = explode(",", $id2[0]);
    $bb = explode(",", $id2[1]);

    switch ($type) {
        case 'del':
            msg_del($id);
            break;
        case 'multdel':
            foreach ($aa as $v) {
                msg_del($v);
                //echo "$v<BR>";
            }
            break;
        case 'altorder':
            foreach ($aa as $k => $v) {
                $q = "update $tbl set displayorder=$bb[$k] where id=$v";
                $db->Execute($q);
            }
            break;
        default:
            return "";
    }
}

?>