4images Forum & Community

4images Modifications / Modifikationen => Mods & Plugins (Releases & Support) => Topic started by: Rembrandt on June 27, 2012, 07:24:29 PM

Title: [Mod] Graphic statistic
Post by: Rembrandt on June 27, 2012, 07:24:29 PM
Hi!

With this Mod you can view your stats graphically.

The wish come from here: http://www.4homepages.de/forum/index.php?topic=30806.msg162033#new

The Demo is here. (http://4images.vienna-pictures.com/index.php)

The code ist here: :)

1.) search in lang/your lang/main.php:

//--- Top Images --------------------------------------
//-----------------------------------------------------

insert below:
(deutsch)

$lang['t_image_hits'] = "Die {num_hits} Bilder mit den meisten Hits";
$lang['t_image_downloads'] = "Die {num_downloads} Bilder mit den meisten Downloads";
$lang['t_image_rating'] = "Die {num_rating} Bilder mit der höchsten Bewertung";
$lang['t_image_votes'] = "Die {num_votes} Bilder mit den meisten Bewertungen";

(english)

$lang['t_image_hits'] = "Top {num_hits} images by hits";
$lang['t_image_downloads'] = "Top {num_downloads} images by downloads";
$lang['t_image_rating'] = "Top {num_rating} images by rating";
$lang['t_image_votes'] = "Top {num_votes} images by votes";


2.) search in index.php:

//-----------------------------------------------------
//--- Print Out ---------------------------------------

insert above:

//######################### Start Graphic statistic ###################################
 $sql = "SELECT SUM(image_hits) AS sum
          FROM ".IMAGES_TABLE;
  $row = $site_db->query_firstrow($sql);
  $sum = (isset($row['sum'])) ? $row['sum'] : 0;
 
function grafic_stats($num_hits,$what_stats,$sort){
global $site_db,$site_sess,$lang;

  $sql = "SELECT image_id, cat_id, image_name, image_active, image_hits, image_downloads, image_votes, image_rating
          FROM ".IMAGES_TABLE."
          WHERE image_active = 1 AND cat_id NOT IN (".get_auth_cat_sql("auth_viewcat", "NOTIN").")
          ORDER BY $what_stats DESC
          LIMIT $num_hits";
  $result = $site_db->query($sql);

  $num = 1;
  $hits = "";
  while ($row = $site_db->fetch_array($result)) {
    if ($num == 1) {
      $max = $row[$what_stats];
      if ($max == 0) {
        $max = 1;
      }
    }
    $row_bg_number = ($num % 2 == 0) ? 2 : 1;
    $hits .= "<tr class=\"row".$row_bg_number."\">\n";
    $hits .=  "<td>&nbsp;".$num.".</td>\n";
    if($row[$what_stats] >= 1){
      $hits .=  "<td nowrap=\"nowrap\"><b><a href=\"".$site_sess->url(ROOT_PATH."details.php?".URL_IMAGE_ID."=".$row['image_id'])."\" target=\"_blank\">".format_text($row['image_name'], 2)."</a></b></td>\n\n";
      }else{
        $hits .=  "<td> - </td>\n";
    }
    $per = intval($row[$what_stats] / $max * 100);
    $hits .=  "<td width=\"100%\">\n";
    $hits .=  "<table border=\"0\" cellspacing=\"0\" cellpadding=\"1\" width=\"100%\"><tr><td bgcolor=\"#FFFFFF\">\n";
    $hits .=  "<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\" width=\"".$per."%\"><tr>\n";
    $hits .=  "<td bgcolor=\"#FCDC43\"><img src=\"images/spacer.gif\" height=\"10\" width=\"2\"></td>\n";
    $hits .=  "</tr></table></td></tr></table>\n</td>";
    $hits .=  "<td align=\"center\">".$row[$what_stats]."</td></tr>\n";
    $num++;
  }
  if ($num == 1) {
    $hits .=  "<tr class=\"".$row_bg_number."\">\n<td colspan=\"4\">".$lang['no_search_results']."</td></tr>";
  }
  return $hits;
}//function

$num_hits = 10;
$site_template->register_vars(array(
"num_hits" => $num_hits,
"lang_t_image_hits" => preg_replace("/{num_hits}/" ,$num_hits, $lang['t_image_hits']),
"hits" => grafic_stats($num_hits,"image_hits","DESC")
));

$num_downloads = 10;
$site_template->register_vars(array(
"num_downloads" => $num_downloads,
"lang_t_image_downloads" => preg_replace("/{num_downloads}/" ,$num_downloads, $lang['t_image_downloads']),
"downloads" => grafic_stats($num_downloads,"image_downloads","DESC")
));

$num_rating = 10;
$site_template->register_vars(array(
"num_rating" => $num_rating,
"lang_t_image_rating" => preg_replace("/{num_rating}/" ,$num_rating, $lang['t_image_rating']),
"rating" => grafic_stats($num_rating,"image_rating","DESC")
));

$num_votes = 10;
$site_template->register_vars(array(
"num_votes" => $num_votes,
"lang_t_image_votes" => preg_replace("/{num_votes}/" ,$num_votes, $lang['t_image_votes']),
"votes" => grafic_stats($num_votes,"image_votes","DESC")
));
//######################### End Graphic statistic ###################################


3.) search in your templates/home.html:
Code: [Select]
{whos_online}
insert above, or where ever you want:
Code: [Select]
                  <table width="100%" border="0" cellspacing="0" cellpadding="1">
                    <tr>
                      <td class="bordercolor">
                        <table width="100%" border="0" cellpadding="3" cellspacing="0">
                          <tr>
                            <td class="head1" valign="top" colspan="5">{lang_t_image_hits}</td>
                          </tr>
                          {hits}
                          <tr>
                            <td class="head1" valign="top" colspan="5">{lang_t_image_downloads}</td>
                          </tr>
                          {downloads}
                          <tr>
                            <td class="head1" valign="top" colspan="5">{lang_t_image_rating}</td>
                          </tr>
                          {rating}
                          <tr>
                            <td class="head1" valign="top" colspan="5">{lang_t_image_votes}</td>
                          </tr>
                          {votes}
                        </table>
                      </td>
                    </tr>
                  </table>
                  <br>

mfg Andi
Title: Re: [Mod] Graphic statistic
Post by: Pawel_el on April 13, 2013, 09:10:55 PM
+1
Title: Re: [Mod] Graphic statistic
Post by: Pawel_el on April 22, 2013, 10:11:52 PM
hello
if you can make graphical statistics for each
profile?
This is the Annex(http://phototrans.pl/images/charts/au94.png)