<?php
if($_GET['push_num']=='yes'){
    if($_G['uid']){
       $message_list= DB::fetch_all('SELECT *  FROM '.DB::table('mocuz_push_message')." WHERE status = 0 and uid =". $_G['uid']." and name !='{$_G['username']}'"." ORDER BY time DESC");
       $list_num=count($message_list);
       $resultdata = array(
         'total' => $list_num,
        );
       odz_result($resultdata);
    }
}else if($_GET['push_list']=='yes'){
    require_once libfile('function/forumlist');
    if($_G['uid']){
        $message_list= DB::fetch_all('SELECT *  FROM '.DB::table('mocuz_push_message')." WHERE status = 0 and uid =". $_G['uid']." and name !='{$_G['username']}'"." ORDER BY time DESC");
        foreach($message_list as $key=>$val){
           $message_list[$key]['time'] = dgmdate($val['time'], 'u');
           $message_list[$key]['detailurl'] = $_G['baseurl'].$_G['mocuz_config']['mocuz_type'].'/index.php?mod=biu_detail&tid='.$val['tid'].'&sharehtml=1&version='.$_G['mocuz_config']['version'];
        }
        $resultdata = array(
          'message_list' => $message_list,
        );
        $list_num=count($message_list);
        if($list_num>0){
             DB::query('UPDATE '.DB::table('mocuz_push_message')." SET status = 1 WHERE uid = {$_G['uid']}");
        }
        odz_result($resultdata);
    }
}else if($_GET['image_list']=='yes'){
        $url = isset($_GET['url'])?$_GET['url']:'';
        $image_url= DISCUZ_ROOT.$url;
        $mdid = $_GET['mdid'];
        $image_name = $_GET['image_name'];
        $cachename = md5($mdid).'.jpg';
        $TheFile =$_G['mocuz_config']['mocuz_type'].'/cache/'.$image_name.'/'.$cachename;//本地路径
        $ImageFile =$_G['baseurl'].$_G['mocuz_config']['mocuz_type'].'/cache/'.$image_name.'/'.$cachename;
        $aa=getimagesize($image_url);
        if($aa){
            if (!file_exists($TheFile)&&$aa["0"]>164&&$aa["1"]>164) {
                $TheFile =DISCUZ_ROOT.$_G['mocuz_config']['mocuz_type'].'/cache/'.$image_name.'/'.$cachename;
                $content = file_get_contents($image_url);
                file_put_contents($TheFile, $content);
                $ret = create_thumb($image_url, $TheFile, 164, 164, false, true);
                if ($ret['code'] != 0) {
                        $TheFile = '';
                }
            }else{
                $url= $_G['baseurl'].$url;
                $TheFile=$url;
            }
        }
        header('Content-Type: image/jpeg');
        echo file_get_contents($TheFile);
}else if($_GET['biu_image']=='yes'){
        $url = isset($_GET['url'])?$_GET['url']:'';
        $url= DISCUZ_ROOT.$url;
        $mdid = $_GET['mdid'];
        $image_name = $_GET['image_name'];
        $cachename = md5($mdid).'.dat';
        $TheFile =DISCUZ_ROOT.$_G['mocuz_config']['mocuz_type'].'/cache/'.$image_name.'/'.$cachename;
        $ImageFile =$_G['baseurl'].$_G['mocuz_config']['mocuz_type'].'/cache/'.$image_name.'/'.$cachename;
        $aa=getimagesize($url);
        $aa["width"]=$aa["0"]*0.5;
        $aa["height"]=$aa["1"]*0.5;
        if(!empty($aa)){
            if (!file_exists($TheFile)&&$url) {
                $content = file_get_contents($url);
                file_put_contents($TheFile, $content);
                $ret = create_thumb($url, $TheFile, $aa["width"], $aa["height"], false, true);
                if ($ret['code'] != 0) {
                        $TheFile = '';
                }
            }else{
                $TheFile=$url;
            }
        }
        header('Content-Type: image/jpeg');
        echo file_get_contents($TheFile);
}
?>