/wordpress/wp-content/plugins/game/game_total.php
PHP | 248 lines | 204 code | 5 blank | 39 comment | 22 complexity | 22045f3dbe31f8a831cf5d2fda1a6739 MD5 | raw file
Possible License(s): Apache-2.0, AGPL-1.0, GPL-2.0, GPL-3.0, LGPL-2.1
- <?php
- class game_total{
- private $cat;//??,big_type
- private $page;//??
- private $number;//??
- private $pic_address;//????
- private $url_address="/wp-content/themes/zenko/scripts/timthumb.php?src=";
- private $width=120;
- private $height=160;
- private $cat_cn_en_map = array('??'=>'star', '??'=>'trend', '??'=>'sport', '??'=>'event', '??'=>'culture', '??'=>'life', '??'=>'pet');
- private $cat_en_cn_map = array('star'=>'??', 'trend'=>'??', 'sport'=>'??', 'event'=>'??', 'culture'=>'??', 'life'=>'??', 'pet'=>'??');
-
- public function __construct($cat,$page){
- if(!empty($cat)){
- $cat = $this->cat_en_cn_map[$cat];
- }
- $this->cat=$cat;
- $this->page=$page;
- require_once 'pic_address.php';
- $this->pic_address=new pic_address();
- }
-
- //??
- public function game_run(){
- ?>
- <div id="middle">
- <div class="h_game_l">
- <?php
- $this->game_head();
- $this->main_game();
- ?>
- </div>
- </div>
- <?php
- }
- public function game_head(){
- ?>
- <div class="h_g_t">
- <h3>????</h3>
- <div class="h_g_nav">
- <a href="/games/" <?php if(empty($this->cat)){?>class="h_g_sel"<?php }?>>??</a>
- <?php
- foreach($this->cat_cn_en_map as $cat_cn => $cat_en){
- ?>
- <span>-</span>
- <a href="/games/<?php echo $cat_en;?>/" <?php if(strcmp($this->cat, $cat_cn)==0){?>class="h_g_sel"<?php }?>><?php echo $cat_cn;?></a>
- <?php } ?>
- </div>
-
- </div>
- <?php
- }
-
- public function main_game(){
- //???????
- global $wpdb;//????
- if(empty($this->cat)){
- //??
- $this->number=$wpdb->get_var("select count(*) from tb_game_type where is_right=1");
- }else{
- $this->number=$wpdb->get_var("select count(*) from tb_game_type where is_right=1 and big_type='".$wpdb->escape($this->cat)."'");
- }
- //echo $this->number;
- if(intval($this->number)==0){
- echo "?????????";
- return ;
- }
- //$this->number=133;
- $page=$this->page-1;
- $page_number=ceil($this->number/15);
- //echo $page_number;
- if($page>=$page_number){
- //?????????????
- $page=0;
- $this->page=1;
- //echo "????";
- }
- $search_begin=$page*15;//???????
- if(empty($this->cat)){
- $opts = $wpdb->get_results("select mid,type from tb_game_type where is_right=1 order by tid desc limit ".$search_begin.",15");
- //echo "select mid from tb_game_type where is_right=1 order by tid desc limit ".$search_begin.",15";
- }else{
- $opts = $wpdb->get_results("select mid,type from tb_game_type where is_right=1 and big_type='".$wpdb->escape($this->cat)."' order by tid desc limit ".$search_begin.",15");
- }
- foreach ($opts as $my_game){
- $mid=$my_game->mid;//??mid
- $type=$my_game->type;//??type
- $game_opts = $wpdb->get_row("SELECT pid_1,pid_2 FROM tb_game_pic WHERE type = '".$wpdb->escape($type)."' limit 0,1",ARRAY_A);
- $pid_1=$game_opts['pid_1'];
- $pid_2=$game_opts['pid_2'];
- $each_game=array('mid'=>$mid,'pid_1'=>$pid_1,'pid_2'=>$pid_2);
- $this->draw_game($each_game);
- }
- $this->draw_foot();
- }
-
- public function draw_foot(){
- if(intval($this->number)<=15){
- //?????
- return ;
- }
- $url="/games/";
- if(!empty($this->cat)){
- $url .= $this->cat_cn_en_map[$this->cat].'/';
- }
- //???
- ?>
- <div class="page">
- <?php
- //$this->number=1000;
- //$this->page=7;//??????
- if(intval($this->page)==1){
- //???????????????????????
- ?>
- <span class="dis_page">[???]</span>
- <span class="dis_page"><<??? </span>
- <?php
- }else{
- //??????????
- $my_page=$this->page-1;
- ?>
- <a href="<?php echo "{$url}?page=1";?>">[???]</a>
- <a href="<?php echo "{$url}?page={$my_page}";?>"><<??? </a>
- <?php
- }
- $foot_now_page=$this->page;//??????
- $foot_page=ceil($this->number/15); //??????
- if($foot_now_page<5||($foot_page-$foot_now_page)<4){
- //?????4?????????4???$foot_noe_page=5
- if($foot_now_page<=9 && ($foot_page<=9 || $foot_page-$foot_now_page>=4)){
- //???????9?????????9??????????9??? 8?12)
- for($foot_i=1;$foot_i<=$foot_page&&$foot_i<=9;$foot_i++){
- //?????????????9???????
- if($foot_i==$foot_now_page){
- //????
- ?>
- <b><?php echo $foot_now_page;?></b>
- <?php
- }else{
- //????
- ?>
- <a href="<?php echo "{$url}?page={$foot_i}";?>"><?php echo $foot_i;?></a>
- <?php
- }
- }
- }else{
- //???????9????9????????4?
- for($foot_i=9;$foot_i>=1;$foot_i--){
- //?????9?
- $foot_in_i=$foot_i-1;
- if($foot_page-$foot_in_i==$foot_now_page){
- //???
- ?>
- <b><?php echo $foot_now_page;?></b>
- <?php
- }else{
- $foot_in_page=$foot_page-$foot_in_i;
- //????
- ?>
- <a href="<?php echo "{$url}?page={$foot_in_page}";?>"><?php echo $foot_in_page;?></a>
- <?php
- }
- }
- }
- }else{
- //????4????4?
- for($foot_i=4;$foot_i>=1;$foot_i--){
- //???4?
- $here_page=$foot_now_page-$foot_i;
- ?>
- <a href="<?php echo "{$url}?page={$here_page}";?>"><?php echo $here_page;?></a>
- <?php
- }
- //?????
- ?>
- <b><?php echo $foot_now_page;?></b>
- <?php
- //???4?
- for($foot_i=1;$foot_i<=4;$foot_i++){
- //???4?
- $here_page=$foot_now_page+$foot_i;
- ?>
- <a href="<?php echo "{$url}?page={$here_page}";?>"><?php echo $here_page;?></a>
- <?php
- }
- }
- //???????
- if($foot_now_page==$foot_page){
- //?????
- ?>
- <span class="dis_page">???>></span>
- <span class="dis_page">[???]</span>
- <?php
- }else{
- //??????
- $my_page=$this->page+1;
- ?>
- <a href="<?php echo "{$url}?page={$my_page}";?>">??? >></a>
- <a href="<?php echo "{$url}?page={$foot_page}";?>">[???]</a>
- <?php
- }
- ?>
- </div>
- <?php
- }
- function draw_game($game){
- global $wpdb;//????
- $mid=$game['mid'];//??id
- $pid_1=$game['pid_1'];//????1
- $pid_2=$game['pid_2'];//????2
- //$a=get_post($mid);
- $address1=$this->pic_address->get_address($pid_1);//???????
- $address2=$this->pic_address->get_address($pid_2);//???????
- $p1_address="{$this->url_address}{$address1}&w={$this->width}&h={$this->height}&zc=1";
- $p2_address="{$this->url_address}{$address2}&w={$this->width}&h={$this->height}&zc=1";
- //$link=get_permalink($mid);//????
- $link= '/games/'.$mid.'.html';
- //$title=get_the_title($mid);//??
- //echo $title;
- //$nr=get_posts($mid);
- $opts = $wpdb->get_row("SELECT post_content,post_title,post_excerpt FROM wp_posts WHERE id = '".$wpdb->escape($mid)."' and post_type='game' and post_status='publish'",ARRAY_A);
- $number=$wpdb->num_rows;
- //echo $number."xxxsss";
- if(intval($number)!=1){
- $title="??????";
- $page="????????";
- }else{
- $title=$opts['post_title'];
- $my_page=$opts['post_content'];
- $page=$opts['post_excerpt'];
- }
- //echo $title.$page;
- ?>
- <div class="h_game_item">
- <a href="<?php echo $link;?>" class="h_game_itemA">
- <img src="<?php echo $p1_address;?>"/>
- </a>
- <a href="<?php echo $link;?>" class="h_game_itemA">
- <img src="<?php echo $p2_address;?>"/>
- </a>
- <div class="h_g_itemR">
- <a href="<?php echo $link;?>"><?php echo $title;?></a>
- <p><?php echo $page;?></p>
- </div>
- </div>
- <?php
- }
- }