Пример #1
0
 /**
  * 获取地区列表
  *
  * @author Linmaogan <*****@*****.**>
  * @CreateDate: 2013-2-5 下午6:19:22
  * @param array $urls 广告地址数组
  * @param array $provinceIds 指定省份ID数组
  * @return array:
  */
 public function getRegion($urls = array(), $provinceIds = array())
 {
     // 获取省份列表
     $regionList = D("Region")->where('parent_id = 0')->field('id,parent_id,name')->select();
     // 合并默认广告地址
     $regionList = array_merge($this->provinceInfo, $regionList);
     $regionList = array_unique_fb($regionList);
     // 过滤掉重复的数组
     // 重组数组下标,用id值做下标
     foreach ($regionList as $value) {
         $regionList2[$value['id']] = $value;
     }
     unset($regionList);
     tdSort($regionList2, 'id');
     // 对省份进行排序
     // 因为排序后数组下标发生了重置,所以再次重组数组下标,用id值做下标
     foreach ($regionList2 as $value) {
         $newRegionList[$value['id']] = $value;
     }
     unset($regionList2);
     // 添加广告时,获取默认显示的省份
     if ($provinceIds && is_array($provinceIds)) {
         foreach ($newRegionList as &$val) {
             if (in_array($val['id'], $provinceIds)) {
                 $regionDefaultList[] = $val;
                 // 默认显示的省份
                 $val['isSelect'] = '1';
                 // 增加默认显示标记
             }
         }
     }
     // 修改广告时,获取默认显示的省份
     if ($urls && is_array($urls)) {
         foreach ($urls as $key => $value) {
             $newRegionList[$key]['url'] = $value;
             // 数据追加广告地址
             $newRegionList[$key]['isSelect'] = 1;
             // 增加默认显示标记
             $expandRegionList[] = $newRegionList[$key];
         }
         $regionDefaultList = $expandRegionList;
         //var_dump($urls,$expandRegionList);
     }
     return array('default' => $regionDefaultList, 'all' => $newRegionList);
 }
Пример #2
0
function pushlastuse($uid, $name, $myid)
{
    global $tankdb;
    global $database_tankdb;
    $last_use_json = '[{"uid":"' . $uid . '", "uname":' . json_encode($name) . ' }]';
    if ($_SESSION['MM_last'] == null) {
        $last_use_arr = $last_use_json;
    } else {
        $last_use_new = json_decode($last_use_json, true);
        $last_use_old = json_decode($_SESSION['MM_last'], true);
        $last_use_merge = array_merge($last_use_new, $last_use_old);
        $last_use_unique = array_unique_fb($last_use_merge);
        if (count($last_use_unique) > 5) {
            array_pop($last_use_unique);
        }
        $last_use_arr = json_encode($last_use_unique);
    }
    mysql_select_db($database_tankdb, $tankdb);
    $update_lastuse = sprintf("UPDATE tk_user SET tk_user_lastuse=%s WHERE uid = {$myid}", GetSQLValueString($last_use_arr, "text"));
    $rs_update_lastuse = mysql_query($update_lastuse, $tankdb) or die(mysql_error());
    $_SESSION['MM_last'] = $last_use_arr;
    return $last_use_arr;
}
Пример #3
0
/**
 * 首页调用品牌车系
 *
 * @access  private
 * @return  array
 */
function mh_index_get_brand_carSys()
{
    //$sql = "SELECT * FROM ".$GLOBALS['ecs']->table('brand')." ORDER BY brand_id ASC";
    $sql2 = "SELECT site_carCountry FROM " . $GLOBALS['ecs']->table('brand') . " ORDER BY brand_id ASC";
    //$all = $GLOBALS['db']->getAll($sql);
    $carSys = $GLOBALS['db']->getAll($sql2);
    $carSys = array_unique_fb($carSys);
    $arr = array();
    foreach ($carSys as $idx => $row) {
        $arr[$idx]['site_carCountry'] = $row['site_carCountry'];
        $sql = "SELECT * FROM " . $GLOBALS['ecs']->table('brand') . "WHERE site_carCountry='" . $arr[$idx]['site_carCountry'] . "' ORDER BY brand_id ASC";
        $all = $GLOBALS['db']->getAll($sql);
        foreach ($all as $key => $result) {
            $arr[$idx]['carSys'][$key]['id'] = $result['brand_id'];
            $arr[$idx]['carSys'][$key]['name'] = $result['brand_name'];
        }
    }
    return $arr;
}