4images Modifications / Modifikationen > Plugins

[ACP - PLUGIN] - Cat hits all in 1

(1/5) > >>

thunderstrike:
Detail: This show cat hits in one page in ACP - > plugins - v2.0.

[02-28-2008] - Update

- Admin paging add.
- Add this: http://www.4homepages.de/forum/index.php?topic=6926.msg112721#msg112721
- Add define constant (step 3).

[02-28-2008] - End Update

// Step 1

In admin/plugins, create file: cat_visits.php .

Add:


--- Code: ---<?php // PLUGIN_TITLE: Category visits
/**************************************************************************
 *                                                                        *
 *    4images - A Web Based Image Gallery Management System               *
 *    ----------------------------------------------------------------    *
 *                                                                        *
 *             File: cat_visits.php                                     *
 *        Copyright: (C) 2002 Jan Sorgalla                                *
 *            Email: jan@4homepages.de                                    *
 *              Web: http://www.4homepages.de                             *
 *    Scriptversion: 1.7.4                                                *
 *                                                                        *
 *    Never released without support from: Nicky (http://www.nicky.net)   *
 *                                                                        *
 **************************************************************************
 *                                                                        *
 *    Dieses Script ist KEINE Freeware. Bitte lesen Sie die Lizenz-       *
 *    bedingungen (Lizenz.txt) fweitere Informationen.                 *
 *    ---------------------------------------------------------------     *
 *    This script is NOT freeware! Please read the Copyright Notice       *
 *    (Licence.txt) for further information.                              *
 *                                                                        *
 *************************************************************************/

$nozip = 1;
define('IN_CP', 1);
define('ROOT_PATH', "./../../");
require(ROOT_PATH.'admin/admin_global.php');

show_admin_header();

if ($action == "") {
    $action = "show_cat_visits";
}

if ($action == "show_cat_visits") {
    
    $sql1 = "
    
    SELECT COUNT(cat_id) AS total_hits
    FROM " . CATEGORIES_TABLE . " 
    WHERE (cat_id NOT IN (".get_auth_cat_sql("auth_viewimage", "NOTIN").", ".get_auth_cat_sql("auth_viewcat", "NOTIN")."))
    
    ";
    
    $row = $site_db->query_firstrow($sql1);
    $total_hits = (isset($row['total_hits'])) ? $row['total_hits'] : 0;
    
    $condition = "";
    
    if (defined('CAT_HITS_PERPAGE_ACTIVATION') && CAT_HITS_PERPAGE_ACTIVATION == 1 && defined('CAT_HITS_SET_PERPAGE') && CAT_HITS_SET_PERPAGE > 0) {
    
    include(ROOT_PATH.'admin/includes/admin_paging.php');
    $cat_hits_perpage = (defined('CAT_HITS_PERPAGE_ACTIVATION') && CAT_HITS_PERPAGE_ACTIVATION == 1 && defined('CAT_HITS_SET_PERPAGE') && CAT_HITS_SET_PERPAGE > 0) ? intval(trim(CAT_HITS_SET_PERPAGE)) : 0;
    $link_arg = $site_sess->url("cat_visits.php?action=show_cat_visits");

    $text = str_replace(array("{total_cat_images}"), array($total_hits), $lang['cat_hits_description']);

    $getpaging = new Paging($page, $cat_hits_perpage, $total_hits, $link_arg, $text, '', '', '', '', false);
    $offset = (defined('CAT_HITS_PERPAGE_ACTIVATION') && CAT_HITS_PERPAGE_ACTIVATION == 1 && defined('CAT_HITS_SET_PERPAGE') && CAT_HITS_SET_PERPAGE > 0) ? $getpaging->get_offset() : "";
        
    $paging_split_valid = false;
    $paging_stats_valid = false;    
    if (defined('CAT_HITS_PERPAGE_ACTIVATION') && CAT_HITS_PERPAGE_ACTIVATION == 1 && defined('CAT_HITS_SET_PERPAGE') && CAT_HITS_SET_PERPAGE > 0) {
        $paging_split_valid = true;        
    }
        
    if (defined('CAT_HITS_PERPAGE_ACTIVATION') && CAT_HITS_PERPAGE_ACTIVATION == 1 && defined('CAT_HITS_SET_PERPAGE') && CAT_HITS_SET_PERPAGE > 0) {
        $paging_stats_valid = true;                
    }
    
    $condition = "LIMIT ".$offset.", ".$cat_hits_perpage;
    }
    
    $sql = "
    
    SELECT cat_id, cat_name, cat_hits
    FROM " . CATEGORIES_TABLE . "
    WHERE (cat_id NOT IN (".get_auth_cat_sql("auth_viewimage", "NOTIN").", ".get_auth_cat_sql("auth_viewcat", "NOTIN")."))    
    ORDER BY cat_hits DESC
    " . $condition;
    
    unset ($condition);
    
    $result = $site_db->query($sql);
    $num_rows = $site_db->get_numrows($result);
    ?>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%">
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" align="center" class="tableheader" /><?php echo $lang['cat_hits_stats']; ?></td>
    </tr>
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">   
    </table>   
    <?php    
    if (isset($num_rows) && $num_rows <= 0) {
        ?>
        <table border="0" width="100%" cellpadding="0" cellspacing="0" class="tablebottom" />   
        <tr>   
        <td width="100%" align="center" class="tablerow" /><br /><?php echo $lang['cat_hits_no_content']; ?></td>
        </tr>
        </table>
        <?php          
    } elseif (isset($num_rows) && $num_rows > 0) {
        
        ?>
        <table border="0" width="100%" cellpadding="1" cellspacing="1" class="tablebottom" />   
        <tr>
        <td width="100%" align="center" class="tablerow" /><br /><?php echo (($paging_stats_valid) ? $getpaging->get_paging_stats() : (($total_hits > 0) ? str_replace(array("{total_cat_images}"), array($total_hits), $lang['cat_hits_description']) : $lang['cat_hits_no_content'])); ?><br /><br /></td>
        </tr>
        </table>
        <table border="0" width="100%" cellpadding="1" cellspacing="1" class="tablebottom" />   
        <tr>
        <td width="100%" align="right" class="tablerow" /><br /><?php echo (($paging_split_valid) ? $getpaging->get_paging() : ""); ?><br /></td>
        </tr>
        </table>
        <table border="0" width="100%" cellpadding="1" cellspacing="1" class="tablebottom" />   
        <tr>
        <td width="50%" align="center" class="tableheader" /><?php echo $lang['cat_hits_cat_name']; ?></td>       
        <td width="50%" align="center" class="tableheader" /><?php echo $lang['cat_hits_title']; ?></td>
        </tr>
        <?php
        while ($stats_row = $site_db->fetch_array($result)) {
            $cat_id = $stats_row['cat_id'];
            $cat_name = format_text(trim($stats_row['cat_name']), 2);            
            $cat_hits = $stats_row['cat_hits'];
        ?>
        <tr>
        <td width="50%" align="center" class="tablerow" /><a href="<?php echo $site_sess->url(ROOT_PATH . "categories.php?cat_id=" . $cat_id); ?>" class="link" target="_blank" /><?php echo $cat_name; ?></a>       
        <td width="50%" align="center" class="tablerow" /><?php echo $cat_hits; ?></td>
        </tr>
        <?php
        }                
    }
    ?>   
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" align="center" class="tablerow" />&nbsp;</td>
    </tr>
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" align="center" class="tableheader" />&nbsp;</td>
    </tr>
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" align="center" class="tablerow" /><br /><span class="smalltext">Created by <a href="http://www.4homepages.de/forum/index.php?action=profile;u=20285" class="link" target="_blank" />Thunderstrike</a> . 2007-2008</span><br />
<span class="smalltext"><a href="http://www.4homepages.de/forum/index.php?topic=18686" class="link" target="_blank" />Support topic</a> .</span><br />
<br /></td>
    </tr>
    </table>
    <table border="0" width="100%" cellpadding="0" cellspacing="0">
    <tr>
    <td width="100%" align="center" class="tableheader" />&nbsp;</td>
    </tr>
    </table>
    </td>
    </tr>
    </table>
    <?php              


show_admin_footer(); 
?>

--- End code ---

// Step 2

In lang/english/admin.php file,

find:


--- Quote ---$lang['resizing_image_error'] = "Error converting image file!";

--- End quote ---

add after:


--- Code: ---//-----------------------------------------------------
//--- Categories hits stats ---------------------------
//-----------------------------------------------------
$lang['cat_hits_stats'] = "Category hits stats";
$lang['cat_hits_description'] = "Check for cat hits for each categories: {total_cat_images} cats.";
$lang['cat_hits_no_content'] = "No content";
$lang['cat_hits_cat_name'] = "Category name";
$lang['cat_hits_title'] = "Category hits";

--- End code ---

// Step 3

In includes/constants.php file,

add in top ?>:


--- Code: ---// Cat hits plugin.
define('CAT_HITS_PERPAGE_ACTIVATION', 1); // 1 for active. 0 for disable.
define('CAT_HITS_SET_PERPAGE', 10); // Add result per page.

--- End code ---

mawenzi:
... nice plugin ...
... but please change the file name of this plugin in the code ... ;)
... and the file name : cat_visits.php ...

thunderstrike:

--- Quote ---... and the file name : cat_visits.php ...

--- End quote ---

Done. ;)


--- Quote ---... but please change the file name of this plugin in the code ...

--- End quote ---

Is good like this ... why change ?  :|

Mr_LovaLove:
Nice :D

it works fine with 1.7.4

can see all cats with number of hits

thanks for this Plugin

mawenzi:

--- Quote from: mawenzi on September 10, 2007, 11:09:54 AM ---... but please change the file name of this plugin in the code ...

--- End quote ---
... ok, you change it ...

Navigation

[0] Message Index

[#] Next page

Go to full version