Advertisement
Nenesse

stats.php

Aug 15th, 2011
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 6.32 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Template Name: Page stats
  4.  *
  5.  * A custom page template without sidebar.
  6.  *
  7.  * The "Template Name:" bit above allows this to be selectable
  8.  * from a dropdown menu on the edit page screen.
  9.  *
  10.  * @package WordPress
  11.  * @subpackage Twenty_Ten
  12.  * @since Twenty Ten 1.0
  13.  */
  14.  
  15. get_header(); ?>
  16.  
  17. <!-- main content: primary + sidebar(s) -->
  18.   <div id="main">
  19.    <div id="main-inside" class="clear-block">
  20.     <!-- primary content -->
  21.     <div id="primary-content">
  22.      <div class="blocks" style="margin:auto auto;">
  23.        <?php do_action('mystique_before_primary'); ?>
  24.        
  25.  
  26. <?php
  27. $args=array(
  28.   'orderby' => 'name',
  29.   'order' => 'ASC'
  30.   );
  31.  
  32. $lien_stats_img="https://chart.googleapis.com/chart?";
  33. $type_charts="cht=p3";
  34. $taille_chart="chs=400x400";
  35. $data_chart="chd=t:";
  36. $nom_chart="chdl=";
  37.  
  38. $categories=get_categories($args);
  39.     foreach($categories as $category) {
  40.         //echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> ';
  41.         //echo '<p> Description:'. $category->description . '</p>';
  42.         //echo '<p> Post Count: '. $category->count . '</p>';
  43.  
  44.         $data_chart.=$category->count.',';
  45.         $nom_chart.=$category->name.'|';
  46.     }
  47.  
  48.     $data_chart=substr($data_chart, 0, -1);
  49.     $nom_chart=substr($nom_chart, 0, -1);
  50.  
  51.     $lien_stats=$lien_stats_img.$type_charts."&".$taille_chart."&".$data_chart."&".$nom_chart."&chdlp=b";
  52.     echo '<div align=center><img src="'.$lien_stats.'"></div>';
  53. ?>
  54.     <?php
  55.     //query_posts('showposts=60','&orderby=title&order=asc');
  56.     query_posts( 'posts_per_page=-1'.'&orderby=title&order=asc');
  57.  
  58.     $tableau_pays=array();
  59.     $tableau_pays_cpt=array();
  60.  
  61. $lien_stats_img="https://chart.googleapis.com/chart?";
  62. $type_charts="cht=map:fixed=-60,-170,80,-175";
  63. $taille_chart="chs=600x350";
  64. $nom_chart="chld=";
  65. $data_chart="chd=t:";
  66. $legende_chart="chdl=";
  67. $titre_chart="chtt=Statistiques+par+Pays";
  68. $etiquette_charts='chm=';
  69. $couleur_chart="chco=";
  70.  
  71.     while ( have_posts() ) : the_post(); ?>
  72.  
  73. <?php
  74.     $values = get_post_custom_values("dvd_pays");
  75.     //if (isset($values[0])) {}
  76.     $pays="";
  77.     if(strpos($values[0],"/") || strpos($values[0],",")) {
  78.         if(strpos($values[0],"/")) $pays_tab=explode("/",$values[0]);
  79.         if(strpos($values[0],",")) $pays_tab=explode(",",$values[0]);
  80.            
  81.         for($j=0;$j<count($pays_tab);$j++) {
  82.             //$key=array_search(trim($pays[$j]),$tableau_pays);
  83.             $pays="";
  84.             if(strtolower(trim($pays_tab[$j]))=="france") $pays="FR";
  85.             if(strtolower(trim($pays_tab[$j]))=="usa" || strtolower(trim($pays_tab[$j]))=="us" || strtolower(trim($pays_tab[$j]))=="etats-unis") $pays="US";
  86.             if(strtolower(trim($pays_tab[$j]))=="allemagne") $pays="DE";
  87.             if(strtolower(trim($pays_tab[$j]))=="australie") $pays="AU";
  88.             if(strtolower(trim($pays_tab[$j]))=="irlande") $pays="IE";
  89.             if(strtolower(trim($pays_tab[$j]))=="royaume-uni") $pays="GB";
  90.             if(strtolower(trim($pays_tab[$j]))=="hong-kong") $pays="HK";
  91.             if(strtolower(trim($pays_tab[$j]))=="japon") $pays="JP";
  92.             if(strtolower(trim($pays_tab[$j]))=="italie") $pays="IT";
  93.             if(strtolower(trim($pays_tab[$j]))=="espagne") $pays="ES";
  94.             if(strtolower(trim($pays_tab[$j]))=="canada") $pays="CA";
  95.             if(strtolower(trim($pays_tab[$j]))=="belgique") $pays="BE";
  96.             if(strtolower(trim($pays_tab[$j]))=="nouvelle-zélande") $pays="NZ";
  97.             //if(strlen($pays)<1) echo $pays_tab[$j]."<br>";
  98.             $key=array_search($pays,$tableau_pays);
  99.             if($key==false) {
  100.                 $i++;
  101.                 $tableau_pays[$i]=trim($pays);
  102.                 $tableau_pays_cpt[$i]=1;
  103.                 //echo "i : ".$i;
  104.             } else {
  105.                 //ce genre est deja enregistré dans le tableau a l'index key
  106.                 $tableau_pays_cpt[$key]++;
  107.             }
  108.         }
  109.     }else {
  110.         //$key=array_search(trim($values[0]),$tableau_pays);
  111.         if(strtolower(trim($values[0]))=="france") $pays="FR";
  112.         if(strtolower(trim($values[0]))=="usa" || strtolower(trim($values[0]))=="us" || strtolower(trim($values[0]))=="etats-unis") $pays="US";
  113.         if(strtolower(trim($values[0]))=="allemagne") $pays="DE";
  114.         if(strtolower(trim($values[0]))=="australie") $pays="AU";
  115.         if(strtolower(trim($values[0]))=="irlande") $pays="IE";
  116.         if(strtolower(trim($values[0]))=="royaume-uni") $pays="GB";
  117.         if(strtolower(trim($values[0]))=="hong-kong") $pays="HK";
  118.         if(strtolower(trim($values[0]))=="japon") $pays="JP";
  119.         if(strtolower(trim($values[0]))=="italie") $pays="IT";
  120.         if(strtolower(trim($values[0]))=="espagne") $pays="ES";
  121.         if(strtolower(trim($values[0]))=="canada") $pays="CA";
  122.         if(strtolower(trim($values[0]))=="belgique") $pays="BE";
  123.         if(strtolower(trim($values[0]))=="nouvelle-zélande") $pays="NZ";
  124.         //if(strlen($pays)<1) echo $values[0]."<br>";
  125.         $key=array_search(trim($pays),$tableau_pays);
  126.         //echo $key;
  127.         if($key==false) {
  128.             $i++;
  129.             $tableau_pays[$i]=$pays;
  130.             $tableau_pays_cpt[$i]=1;
  131.             //echo "i : ".$i;
  132.         } else {
  133.             //ce genre est deja enregistré dans le tableau a l'index key
  134.             $tableau_pays_cpt[$key]++;
  135.         }
  136. //echo $values[0].'<br>';
  137.     }
  138.         //$titre=get_the_title(get_the_ID());
  139.  
  140.     endwhile;
  141.     //echo count($tableau_pays);
  142.     for($j=1;$j<=count($tableau_pays);$j++) {
  143.         //echo "<div class='cat '>".$tableau_pays[$j]."(".$tableau_pays_cpt[$j].")</div>";
  144.         $data_chart.=$tableau_pays_cpt[$j].',';
  145.         $nom_chart.=$tableau_pays[$j].'|';
  146.         $index=$j-1;
  147.         $etiquette_charts.="f".$tableau_pays[$j]."(".$tableau_pays_cpt[$j].")".',000000,0,'.$index.',10|';
  148.         $legende_chart.=$tableau_pays[$j].'|';
  149.  
  150.         $a = DecHex(mt_rand(0,15)); $b = DecHex(mt_rand(0,15)); $c = DecHex(mt_rand(0,15)); $d = DecHex(mt_rand(0,15)); $e = DecHex(mt_rand(0,15)); $f = DecHex(mt_rand(0,15)); $hexac = $a . $b . $c . $d . $e . $f;
  151.         $couleur_chart.=$hexac.'|';
  152.     }
  153.     $data_chart=substr($data_chart, 0, -1);
  154.     $nom_chart=substr($nom_chart, 0, -1);
  155.     $legende_chart=substr($legende_chart, 0, -1);
  156.     $couleur_chart=substr($couleur_chart, 0, -1);
  157.     $etiquette_charts=substr($etiquette_charts, 0, -1);
  158.     $lien_stats=$lien_stats_img.$taille_chart."&".$type_charts."&".$nom_chart."&".$etiquette_charts."&".$legende_chart."&".$couleur_chart."&".$titre_chart."&chma=0,110,0,0";
  159.     echo '<div align=center><img src="'.$lien_stats.'"></div>';
  160.  
  161. ?>
  162.    
  163.        <?php do_action('mystique_after_primary'); ?>
  164.      </div>
  165.     </div>
  166.     <!-- /primary content -->
  167.  
  168.     <?php get_sidebar(); ?>
  169.  
  170.    </div>
  171.   </div>
  172.   <!-- /main content -->
  173.  
  174. <?php get_sidebar(); ?>
  175. <?php get_footer(); ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement