/gamecrawler/wp/youxisoso/search_back.php
PHP | 435 lines | 353 code | 37 blank | 45 comment | 78 complexity | 61056cf613b963ac1abb97e7e7a7853e MD5 | raw file
- <?php
-
- //????()?
- $pageSize = 10 ;
- $pageModel= 10 ; //???????
- $selfPageLink = "/" ; //?????
- $autoLink = "" ;
- $siteurl = get_bloginfo('template_url');
-
- //???id
- $cat = $_POST['cat'] ;
- if($cat == null || "" == $cat){
- $cat = $_GET['cat'] ;
- }
- $categories = "" ;
- $catStr = "" ;
- if($cat != null && "" != $cat){
- $category_id = get_cat_ID($cat);
- $categories = get_categories ('child_of='.$category_id) ;
- // $categories = $wpdb->get_results("select p.name,p.term_id as pterm_id ,t.name,t.term_id as term_id ".
- // " from wp_terms t ,wp_term_taxonomy m , wp_terms p ".
- // " where t.term_id = m.term_id and p.term_id = m.parent and p.term_id ='".$category_id."'") ;
- foreach ($categories as $category) {
- $catStr =$catStr."'".$category->term_id."'," ;
- }
- }
-
- //?????
- $startSapnChar = "_%%" ;
- $endSpanChar = "_%" ;
- //$keyword = $_POST('keyword') ;
- $oldKeyword = "" ;
- $keyword = $_POST['s'] ;
- if($keyword == null || "" == $keyword ){
- $keyword = $_GET["s"];
- }
- if($keyword!= null){
- $keyword =str_replace('\\\'',"'",$keyword) ;
- $keyword =str_replace('\\\"',""",$keyword) ;
- $oldKeyword = $keyword ;
- $oldKeyword = str_replace(""",'"',$keyword );
- $oldKeyword = str_replace("'","'",$oldKeyword );
- $keyword = str_replace($endSpanChar,"",$keyword) ;
- $keyword= trim($keyword) ;
- }
- $oldKeywordArray = explode(" ",$keyword);
- $keywordArray = array() ;
- //??
- $paged = $_POST["paged"];
- if($paged == null || "" == $paged ){
- $paged = $_GET["paged"];
- if($paged == null || "" == $paged ){
- $paged = 0 ;
- }
- }
- //???????????
- $queryStr = "select distinct terp.term_id as term_id, terp.name as name from wp_term_taxonomy tax ,wp_terms terp where tax.parent = terp.term_id" ;
- $cats = $wpdb->get_results($queryStr );
-
- $statNum = $pageSize * $paged ;
-
-
- function csubstr($str, $start=0, $length, $charset="utf-8", $suffix=true) {
- if(function_exists("mb_substr")){
- if(mb_strlen($str, $charset) <= $length) return $str;
- $slice = mb_substr($str, $start, $length, $charset);
- }else{
-
- $re['utf-8'] = "/[\x01-\x7f]|[\xc2-\xdf][\x80-\xbf]|[\xe0-\xef][\x80-\xbf]{2}|[\xf0-\xff][\x80-\xbf]{3}/";
-
- $re['gb2312'] = "/[\x01-\x7f]|[\xb0-\xf7][\xa0-\xfe]/";
-
- $re['gbk'] = "/[\x01-\x7f]|[\x81-\xfe][\x40-\xfe]/";
-
- $re['big5'] = "/[\x01-\x7f]|[\x81-\xfe]([\x40-\x7e]|\xa1-\xfe])/";
-
- preg_match_all($re[$charset], $str, $match);
-
- if(count($match[0]) <= $length) return $str;
- $slice = join("",array_slice($match[0], $start, $length));
- }
- if($suffix) return $slice."
";
- return $slice;
-
- }
-
-
- get_header();
- ?>
- <div id="list_left">
- <ul>
- <li id="xuanzhong">>????</li>
- <?php
-
- if($category_id != null && "" != $category_id){
- ?>
- <li class="fenleileftfloat NOxuanzhong" ><a href="<?php echo $selfPageLink."?s=".$oldKeyword ;?>">????</a></li>
- <?php
- }else{
- ?>
- <li id="xuanzhong" class="fenleileftfloat"><a href="<?php echo $selfPageLink ;?>">????</a></li>
- <?php
- }
- ?>
- <?php
- foreach($cats as $v){
- if($v->term_id == $category_id){
- ?>
- <li id="xuanzhong" class="fenleileftfloat"><a href="<?php echo $selfPageLink."?s=".$oldKeyword."&cat=".$v->name;?>" ><?php echo $v->name; ?></a></li>
- <?php
- }else{
- ?>
- <li class="fenleileftfloat NOxuanzhong"><a href="<?php echo $selfPageLink."?s=".$oldKeyword."&cat=".$v->name;?>"><?php echo $v->name; ?></a></li>
- <?php
- }
- }
- ?>
- <!--
- <li class="NOxuanzhong"><a href="#">????</a></li>
- <li class="NOxuanzhong"><a href="#">flash??</a></li>
- <li class="NOxuanzhong"><a href="#">????</a></li> -->
- </ul>
- </div>
- <div id="list_center">
- <!-- ???????? -->
- <?php
- $postTable = "(select p.* ,m.meta_value meta_value from wp_posts p left join wp_postmeta m on m.post_id = p.ID and m.meta_key='GamePI' and p.post_status = 'publish' AND p.post_type = 'post' )" ;
- $condition = " where post.ID = ships.object_id and ships.term_taxonomy_id = tax.term_taxonomy_id and tax.taxonomy ='category' " ;
- foreach ($oldKeywordArray as $value){
- if($value!= null && $value!=""){
- $keywordArray[$value] = $value ;
- $condition=$condition." and post.post_title like '%".$value."%' ";
- }
- }
-
- // foreach ($oldKeywordArray as $value){
- // if($value!= null && $value!=""){
- // $keywordArray[$value] = $value ;
- // $condition=$condition." or post_content like '%".$value."%' ";
- // }
- // }
- // if($keyword != null && "" != $keyword){
- // $condition=$condition." and post_title like '%".$keyword."%' ";
- // }
- if($category_id != null && "" != $category_id){
- if($catStr !=null && "" != $catStr){
- $catStr = substr($catStr,0,strlen($catStr)-1) ;
- $condition=$condition." and tax.term_id in (".$catStr.") " ;
- }else{
- $condition=$condition." and tax.term_id = '' " ;
- }
- }
- $postCountQue = "select count(distinct post.post_title) as counts from wp_term_taxonomy tax ,wp_term_relationships ships, ".$postTable." post ".$condition ;
- $mycounts = $wpdb->get_results($postCountQue) ;
- $mycount= 0 ;
- if($mycounts != null){
- $mycount = $mycounts[0]->counts ;
- }
-
- ?>
- <span id="mianbaoxie" class="list_centtopspan">?????<a href="?">??</a>=><a href="<?php echo $selfPageLink ;?>">????</a></span>
- <span id="soso_result" class="list_centtopspan">??<?php echo $mycount; ?></>?????</span>
- <?php
- //$args = array ('paged'=>$paged,"orderby"=>"date");
- //query_posts($args);
- //while (have_posts()) : the_post();
-
- $postQue = "select count(distinct post.post_title) ,post.ID as ID ,post.post_title as post_title ,tax.term_id as term_id ,post.post_content as post_content ".
- "from wp_term_taxonomy tax ,wp_term_relationships ships, ".$postTable." post ".$condition." group by post.post_title ORDER BY post.meta_value DESC LIMIT ".$statNum.",".$pageSize ;
- $myposts = $wpdb->get_results($postQue);
- $startSapn = "<span style='color:red;'>";
- $endSpan = "</span>" ;
- foreach($myposts as $mypost) {
- // get game image by user defined
- //$gameSize = get_post_meta($mypost->ID, 'GameSize', true);
- $gamePic = get_post_meta($mypost->ID, 'GamePic', true);
- $gameLink = get_post_meta($mypost->ID, 'GameLink', true);
- $postLink = get_permalink($mypost->ID);
-
- $postTitle = $mypost->post_title ;
- $postTitle = str_replace("%","",$postTitle) ;
- $postTitle = str_replace(""","'",$postTitle) ;
- $titleHtml = $postTitle ;
- foreach($keywordArray as $value) {
- if($value !=null && $value != ""){
- $startFindPos = 0 ;
- $titleHtml = "" ;
- $indexPos = stripos($postTitle,$value,$startFindPos) ;
- if($indexPos >-1){
- do{
- $titleHtml = $titleHtml.substr($postTitle,$startFindPos,$indexPos-$startFindPos).$startSapnChar.
- substr($postTitle,$indexPos,strlen($value)).$endSpanChar.substr($postTitle,$indexPos+strlen($value)) ;
- $startFindPos = $indexPos + strlen($value);
-
- } while(($indexPos = stripos($postTitle,$value,$startFindPos)) >-1) ;
- }else{
- $titleHtml = $postTitle ;
- }
-
- // $titleArray = explode($value,$postTitle) ;
- // $titleHtml = "" ;
- // if(count($titleArray)>0){
- // $arrayCount = count($titleArray) ;
- // for($i= 0 ;$i<$arrayCount -1;$i++){
- // $titleHtml = $titleHtml.$titleArray[$i].$startSapnChar.$value.$endSpanChar ;
- // }
- // $titleHtml = $titleHtml.$titleArray[$arrayCount -1] ;
- // } else {
- // $titleHtml = $postTitle ;
- // }
- $postTitle = $titleHtml ;
- }
-
- }
- $titleHtml = str_replace($startSapnChar,$startSapn,$titleHtml) ;
- $titleHtml = str_replace($endSpanChar,$endSpan,$titleHtml) ;
-
- //mb_strimwidth(strip_tags(apply_filters('the_content', $mypost->post_content)), 0, 300,"
");
- $desHtml = csubstr($mypost->post_content, 0, 300, "utf-8", true) ;
-
-
- ?>
- <div class="list">
- <span class="list_img"><a href="<?php echo $postLink; ?>"><img src="<?php echo $gamePic ?>" width="104" height="79" alt="<?php echo $titleHtml; ?>" title="<?php echo $titleHtml; ?>" /></a></span>
- <h3 class="list_title"><a href="<?php echo $postLink; ?>"><?php echo $titleHtml;//$mypost->post_title; ?></a></h3>
- <span class="list_cat">
- <?php
- $cat_name = get_cat_name($mypost->term_id);
- if($cat_name == 'andriod' ||$cat_name == 'iphone' || $cat_name == 'windows phone' ){
- echo "????:";
- }else {
- echo "??:";
- }
- ?>
- <samp><?php echo $cat_name?></samp></span>
- <p class="list_neirong"><?php echo $desHtml; ?></p>
- <span class="list_add">??????<!-- <a href="<?php //echo $gameLink; ?>"> --><samp><?php echo $gameLink; ?></samp><!-- </a> --></span>
- </div>
- <?php
- }
- //endwhile;
- ?>
- <!-- ???????? -->
-
- <!-- ???? -->
-
- <div id="scroll">
- <?php
- $totalPage = ceil($mycount/$pageSize) ;
- if($totalPage >0){
- $i = 0 ;
- $pagedLink = $selfPageLink."?s=".$oldKeyword."&cat=".$cat;
- if(intval($paged) > 0 ){
- ?>
- <a href="<?php echo $pagedLink."&paged=".(intval($paged)-1); ?>" ><img src="<?php echo $siteurl ?>/images/next-top.gif" alt="???" title="???" class="f_l"/></a>
- <?php
- }
- ?>
- <?php
- if($totalPage<=$pageModel){
- for(;$i<$totalPage;$i++){
- if($i == intval($paged)){
- ?>
- <font class="linknone"><?php echo ($i +1);?></font>
- <?php
- }else{
- ?>
- <a href="<?php echo $pagedLink."&paged=".(intval($i)); ?>" class="linkstyle03"><?php echo ($i +1);?></a>
- <?php
- }
- }
-
- }elseif($totalPage < $pageModel + 3){
- $halfPageModel = intval($pageModel /3) ;
- if(intval($paged) < $halfPageModel*2){
-
- for($i=0;$i < $halfPageModel*2+1;$i++){
- if($i == intval($paged)){
- ?>
- <font class="linknone"><?php echo ($i +1);?></font>
- <?php
- }else{
- ?>
- <a href="<?php echo $pagedLink."&paged=".(intval($i)); ?>" class="linkstyle03"><?php echo ($i +1);?></a>
- <?php
- }
- }
- ?>
- <a class="linkstyle03"><?php echo "...";?></a>
- <?php
- for($i = $totalPage-($pageModel-$halfPageModel*2 -2);$i<$totalPage;$i++){
- ?>
- <a href="<?php echo $pagedLink."&paged=".(intval($i)); ?>" class="linkstyle03"><?php echo ($i +1);?></a>
- <?php
- }
- ?>
- <?php
- }elseif(intval($paged) > $halfPageModel - 1) {
- for($i =0 ;$i< $halfPageModel-1;$i++){
- ?>
- <a href="<?php echo $pagedLink."&paged=".(intval($i)); ?>" class="linkstyle03"><?php echo ($i +1);?></a>
- <?php
- }
- ?>
- <a class="linkstyle03"><?php echo "...";?></a>
- <?php
- for($i=$totalPage-($pageModel-$halfPageModel);$i < $totalPage;$i++){
- if($i == intval($paged)){
- ?>
- <font class="linknone"><?php echo ($i +1);?></font>
- <?php
- }else{
- ?>
- <a href="<?php echo $pagedLink."&paged=".(intval($i)); ?>" class="linkstyle03"><?php echo ($i +1);?></a>
- <?php
- }
- }
- }
- }else{
- $halfPageModel = intval($pageModel /2) ;
- if(intval($paged) < $halfPageModel-1){
- for($i =0 ;$i< $halfPageModel;$i++){
- if($i == intval($paged)){
- ?>
- <font class="linknone"><?php echo ($i +1);?></font>
- <?php
- }else{
- ?>
- <a href="<?php echo $pagedLink."&paged=".(intval($i)); ?>" class="linkstyle03"><?php echo ($i +1);?></a>
- <?php
- }
- }
- ?>
- <a class="linkstyle03"><?php echo "...";?></a>
- <?php
- for($i =$totalPage - ($pageModel - $halfPageModel - 1) ;$i< $totalPage ;$i++){
- ?>
- <a href="<?php echo $pagedLink."&paged=".(intval($i)); ?>" class="linkstyle03"><?php echo ($i +1);?></a>
- <?php
- }
- }elseif(intval($paged) > $totalPage - ($halfPageModel) ) {
- for($i = 0 ;$i< $halfPageModel-1 ;$i++){
- ?>
- <a href="<?php echo $pagedLink."&paged=".(intval($i)); ?>" class="linkstyle03"><?php echo ($i +1);?></a>
- <?php
- }
- ?>
- <a class="linkstyle03"><?php echo "...";?></a>
- <?php
- for($i = $totalPage - ($pageModel - $halfPageModel) ;$i< $totalPage;$i++){
- if($i == intval($paged)){
- ?>
- <font class="linknone"><?php echo ($i +1);?></font>
- <?php
- }else{
- ?>
- <a href="<?php echo $pagedLink."&paged=".(intval($i)); ?>" class="linkstyle03"><?php echo ($i +1);?></a>
- <?php
- }
- }
-
- }else {
- ?>
- <a href="<?php echo $pagedLink."&paged=0"; ?>" class="linkstyle03"><?php echo 1;?></a>
- <a href="<?php echo $pagedLink."&paged=1"; ?>" class="linkstyle03"><?php echo 2;?></a>
- <?php
- $uses = 3 ;
- if($paged > $totalPage/2){
- $uses = 2 ;
- ?>
- <a href="<?php echo $pagedLink."&paged=1"; ?>" class="linkstyle03"><?php echo 3;?></a>
- <?php
- }
- ?>
- <a class="linkstyle03"><?php echo "...";?></a>
- <a href="<?php echo $pagedLink."&paged=".(intval($paged)-1); ?>" class="linkstyle03"><?php echo intval($paged);?></a>
- <font class="linknone"><?php echo (intval($paged) +1);?></font>
- <a href="<?php echo $pagedLink."&paged=".(intval($paged)+1); ?>" class="linkstyle03"><?php echo (intval($paged) +2);?></a>
- <a class="linkstyle03"><?php echo "...";?></a>
- <?php
- for($i = $totalPage - $uses ;$i< $totalPage;$i++){
- ?>
- <a href="<?php echo $pagedLink."&paged=".(intval($i)); ?>" class="linkstyle03"><?php echo ($i +1);?></a>
- <?php
- }
- }
- }
- if(intval($paged)<$totalPage-1){
- ?>
- <a href="<?php echo $pagedLink."&paged=".(intval($paged)+1); ?>" ><img src="<?php echo $siteurl ?>/images/next-bottom.gif" alt="???" title="???" class="f_l" /></a>
- <?php
- }
- }
- ?>
- </div>
-
- <!-- ???? -->
-
-
- </div>
-
- <!-- ?????? -->
- <div id="list_right">
- <h2>??????</h2>
- <?php
- // $hotPostQue = "select count(post.post_title) ,post.ID as ID ,post.post_title as post_title ,tax.term_id as term_id ".
- // " from wp_term_taxonomy tax ,wp_term_relationships ships, wp_posts post where ".
- // " post.ID = ships.object_id and ships.term_taxonomy_id = tax.term_taxonomy_id and post_status = 'publish' AND post_type = 'post' and tax.taxonomy ='category' ".
- // " group by post.post_title order by post.comment_count desc limit 0,10 ";
- //query_posts('orderby=comment_count&showposts=4');//????ID?7?2???
- //while (have_posts()) : the_post();
- $i =1 ;
- $hotposts = getHotPost(10); // $wpdb->get_results($hotPostQue);
- foreach($hotposts as $hotpost) {
- //$gameSize = get_post_meta($hotpost->ID, 'GameSize', true);
- $gamePic = get_post_meta($hotpost->ID, 'GamePic', true);
- //$gameLink = get_post_meta($hotpost->ID, 'GameLink', true);
- $postLink = get_permalink($hotpost->ID);
- ?>
- <div class="list_tuijian">
- <span class="list_img"><a href="<?php echo $postLink; ?>"><img src="<?php echo $gamePic; ?>" width="104" height="79" alt="<?php echo $hotpost->post_title; ?>" title="<?php echo $hotpost->post_title;?>" /></a></span>
- <!-- <span class="listriht listriht_tuijian"><img src="<?php echo $siteurl ?>/images/tuijian/<?php echo $i++ ;?>.jpg" /></span> -->
- <h5 class="listriht listriht_tit"><a href="<?php echo $postLink; ?>"><?php echo $hotpost->post_title; ?></a></h5>
- <span class="listriht listriht_cat "><?php echo get_cat_name($hotpost->term_id);?></span>
- </div>
- <?php
- }
- //endwhile;
- ?>
- </div>
- <!-- ?????? -->
- </div>
-
-
- <?php get_footer();?>