View file script/admin/stats.php

File size: 10.35Kb
<?php
/*-----------------------------------------------------------------------------------------
mcGalleryPRO
All code is © 2003 Marc Cagninacci.
No files may be redistributed in whole or significant part.
----------------- mcgalleryPRO IS NOT FREE SOFTWARE -------------------
You should have receive a file called license.txt in this package
--------------------------------------------------------------------------------------------*/

session_start();
if (empty($_SESSION['private_login']))
{
include "./sess.php";
exit;
}
include './header.php';

if ($stat_type == '' || $stat_type == 'photos')
{
$stat_type = 'photos';
$table = 'mcgallery_photo';
$like = 'photos%';
$like2 = '%jpg';
$type = 'P';
$dir='photos';
}

elseif ($stat_type == 'videos')
{
$table = 'mcgallery_video';
$like = 'videos%';
$like2 = '%mpg';
$type = 'V';
$dir='videos';
}

elseif ($stat_type == 'flash')
{
$table = 'mcgallery_flash';
$like = 'flash%';
$like2 = '%swf';
$type = 'F';
$dir='flash';
}

$connect= mysql_connect($host,$login,$pass);
mysql_select_db($base, $connect);

$query= "SELECT SUM(visite) as nbre_visite FROM $table";
$res= mysql_query($query);
$row1= mysql_fetch_array($res);

$query= "SELECT album FROM $table GROUP BY album";
$res= mysql_query($query);
$row2= mysql_num_rows($res);

$query= "SELECT id FROM $table";
$res= mysql_query($query);
$row3= mysql_num_rows($res);

$query= "SELECT id FROM mcgallery_card WHERE image LIKE '$like'";
$res= mysql_query($query);
$row4= mysql_num_rows($res);

$query= "SELECT id FROM mcgallery_comment WHERE type='$type'";
$res= mysql_query($query);
$row5= mysql_num_rows($res);

$query= "SELECT file FROM mcgallery_select where type='$type' GROUP BY file";
$res= mysql_query($query);
$row6= mysql_num_rows($res);

if ($top =='') { $top = 10; }
if ($tip =='') { $tip = $l_tip_aff; }
?>
   <table border="0" cellspacing="1" cellpadding="1" align="center">
    <tr>
    <td bgcolor="#OOOOOO" colspan="6" align="center">
    <font face="verdana" size="2" color="white">
    <?php 
    echo '&nbsp;';
    echo $l_Albums.': '.$row2.'&nbsp;&nbsp; | &nbsp;&nbsp;';
    echo $dir.': '.$row3.'&nbsp;&nbsp; | &nbsp;&nbsp;';
    echo $l_Visite.': '.$row1['nbre_visite'].'&nbsp;&nbsp; | &nbsp;&nbsp;';
    echo $l_Ecard.': '.$row4.'&nbsp;&nbsp; | &nbsp;&nbsp;';
    echo $l_Comments.': '.$row5.'&nbsp;&nbsp; | &nbsp;&nbsp;';
    echo $l_sel_add.': '.$row6.'&nbsp;';

    ?>
    </font>
    </td>
    </tr>
    <form method="post" action="stats.php">
     <td bgcolor="#OOOOOO" colspan="6">&nbsp;
     <select name="top">
     <option value="10">10</option>
     <option value="20">20</option>
     <option value="30">30</option>
     <option value="40">40</option>
     <option value="50">50</option>
     <option value="">---</option>
     <option value="<?php echo $top; ?>" selected><?php echo $top; ?></option>
    </select>
     <select name="stat_type">
     <option value="photos">photos</option>
     <option value="videos">videos</option>
     <option value="flash">flash</option>
     <option value="">---</option>
     <option value="<?php echo $stat_type; ?>" selected><?php echo $stat_type; ?></option>
    </select>
     <font face="verdana" size="2" color="white">&nbsp;<?php echo $l_top; ?>&nbsp;</font>
     <select name="tip">
     <option value="<?php echo $l_tip_aff; ?>"><?php echo $l_tip_aff; ?></option>
     <option value="<?php echo $l_tip_com; ?>"><?php echo $l_tip_com; ?></option>
     <option value="<?php echo $l_tip_card; ?>"><?php echo $l_tip_card; ?></option>
     <option value="<?php echo $l_tip_sel; ?>"><?php echo $l_tip_sel; ?></option>
     <option value="">---</option>
     <option value="<?php echo $tip; ?>" selected><?php echo $tip; ?></option>
    </select>
    &nbsp;
    <input type="submit" name="submit" value="OK">
     </td>
   </form>
    </tr>
    <tr>
   <td bgcolor="#OOOOOO"><font face="verdana" size="2" color="white">&nbsp;</font></td>
   <td bgcolor="#OOOOOO" align="center"><font face="verdana" size="2" color="white"><?php echo $l_nombre; ?></font></td>
   <td bgcolor="#OOOOOO"><font face="verdana" size="2" color="white"><?php echo $l_Album; ?></font></td>
   <td bgcolor="#OOOOOO"><font face="verdana" size="2" color="white"><?php echo $l_Titre; ?></font></td>
   <td bgcolor="#OOOOOO"><font face="verdana" size="2" color="white"><?php echo $l_Auteur; ?></font></td>
   <td bgcolor="#OOOOOO"><font face="verdana" size="2" color="white"><?php echo $l_Description; ?></font></td>
   </tr>
<?php 


if ($tip == $l_tip_aff)
{
$query="SELECT idalbum, file, album, title, author, descr, visite FROM $table ORDER BY visite DESC LIMIT 0, $top";
$result=mysql_query($query);
  while ($row=mysql_fetch_array($result))
  {
    $len= strlen($row['idalbum']);
    $image= substr($row['file'], ($len + 1), -3).'jpg';
     if (!file_exists('../'.$dir.'/'.$row['idalbum'].'/small/'.$image)) { $image= substr($row['file'], ($len + 1), -3).'JPG'; }
    echo '<tr><td bgcolor="#CCCCCC" align="center"><img src="../'.$dir.'/'.$row['idalbum'].'/small/'.$image.'" width="64" height="48"></td>';
    echo '<td bgcolor="#CCCCCC" align="center"><font face="verdana" size="2" color="black"><b>'.$row['visite'].'</b></font></td>';
    echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.stripslashes($row['album']).'</font></td>';
    echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.stripslashes($row['title']).'</font></td>';
    echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.stripslashes($row['author']).'</font></td>';
    echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.stripslashes($row['descr']).'</font></td></tr>';
  }
}

elseif ($tip == $l_tip_com)
{
$query="SELECT COUNT(id_photo) as comment, id_photo  FROM mcgallery_comment WHERE type='$type' GROUP BY id_photo ORDER BY comment DESC LIMIT 0, $top";
  $resultc=mysql_query($query);
  while ($rowc=mysql_fetch_array($resultc))
  {
  $query="SELECT id, idalbum, file, album, title, author, descr, visite FROM $table WHERE id='$rowc[id_photo]'";
  $result=mysql_query($query);
   while ($row=mysql_fetch_array($result))
   {
     $len= strlen($row['idalbum']);
     $image= substr($row['file'], ($len + 1), -3).'jpg';
     if (!file_exists('../'.$dir.'/'.$row['idalbum'].'/small/'.$image)) { $image= substr($row['file'], ($len + 1), -3).'JPG'; }
     echo '<tr><td bgcolor="#CCCCCC" align="center"><img src="../'.$dir.'/'.$row['idalbum'].'/small/'.$image.'" width="64" height="48"></td>';
     echo '<td bgcolor="#CCCCCC" align="center"><font face="verdana" size="2"><a href="comments.php?t='.$type.'&id='.$row['id'].'&image='.urlencode('../'.$dir.'/'.$row['idalbum'].'/small/'.$image).'" class="lien1"><b>'.$rowc['comment'].'</b></a></font></td>';
     echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.stripslashes($row['album']).'</font></td>';
     echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.stripslashes($row['title']).'</font></td>';
     echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.stripslashes($row['author']).'</font></td>';
     echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.stripslashes($row['descr']).'</font></td></tr>';
   }
  }
}

elseif ($tip == $l_tip_card)
{
$query="SELECT COUNT(image) as ecard, image  FROM mcgallery_card WHERE image LIKE '$like2' GROUP BY image ORDER BY ecard DESC LIMIT 0, $top";
  $resultc=mysql_query($query);
  while ($rowc=mysql_fetch_array($resultc))
  {
  $explode = explode('/', $rowc['image']);
  $query="SELECT id, idalbum, file, album, title, author, descr, visite FROM $table WHERE file='$explode[1]_$explode[2]'";
  $result=mysql_query($query);
   while ($row=mysql_fetch_array($result))
   {
     $len= strlen($row['idalbum']);
     $image= substr($row['file'], ($len + 1), -3).'jpg';
     if (!file_exists('../'.$dir.'/'.$row['idalbum'].'/small/'.$image)) { $image= substr($row['file'], ($len + 1), -3).'JPG'; }
     echo '<tr><td bgcolor="#CCCCCC" align="center"><img src="../'.$dir.'/'.$row['idalbum'].'/small/'.$image.'" width="64" height="48"></td>';
     echo '<td bgcolor="#CCCCCC" align="center"><font face="verdana" size="2"><a href="ecard.php?image='.urlencode('../'.$dir.'/'.$row['idalbum'].'/small/'.$image).'" class="lien1"><b>'.$rowc['ecard'].'</b></a></font></td>';
     echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.stripslashes($row['album']).'</font></td>';
     echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.stripslashes($row['title']).'</font></td>';
     echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.stripslashes($row['author']).'</font></td>';
     echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.stripslashes($row['descr']).'</font></td></tr>';
   }
  }
}

elseif ($tip == $l_tip_sel)
{
$query="SELECT COUNT(file) as selection, file  FROM mcgallery_select WHERE type = '$type' GROUP BY file ORDER BY selection DESC LIMIT 0, $top";
  $resultc=mysql_query($query);
  while ($rowc=mysql_fetch_array($resultc))
  {
  $query="SELECT id, idalbum, file, album, title, author, descr, visite FROM $table WHERE file='$rowc[file]'";
  $result=mysql_query($query);
   while ($row=mysql_fetch_array($result))
   {
     $len= strlen($row['idalbum']);
     $image= substr($row['file'], ($len + 1), -3).'jpg';
     if (!file_exists('../'.$dir.'/'.$row['idalbum'].'/small/'.$image)) { $image= substr($row['file'], ($len + 1), -3).'JPG'; }
     echo '<tr><td bgcolor="#CCCCCC" align="center"><img src="../'.$dir.'/'.$row['idalbum'].'/small/'.$image.'" width="64" height="48"></td>';
     echo '<td bgcolor="#CCCCCC" align="center"><font face="verdana" size="2" color="black"><b>'.$rowc['selection'].'</b></font></td>';
     echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.stripslashes($row['album']).'</font></td>';
     echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.stripslashes($row['title']).'</font></td>';
     echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.stripslashes($row['author']).'</font></td>';
     echo '<td bgcolor="#CCCCCC"><font face="verdana" size="1" color="black">'.stripslashes($row['descr']).'</font></td></tr>';
   }
  }
}

echo '</table>';
include './footer.php';
?>