Fork me on GitHub

Rapport de message :*
 

Re: Base SQL vs MySQL | Impact pour xoops?

Titre du sujet : Re: Base SQL vs MySQL | Impact pour xoops?
par Kris sur 22/06/2012 22:28:41

brut de forme :
function.OnlineByModule.php
<?php
// $Id: function.OnlineByModule.php
//  ------------------------------------------------------------------------ //
//                XOOPS - PHP Content Management System                      //
//                    Copyright (c) 2000 XOOPS.org                           //
//                       <http://www.xoops.org/>   ... nbsp;   //
//  ------------------------------------------------------------------------ //
//  This program is free software; you can redistribute it and/or modify     //
//  it under the terms of the GNU General Public License as published by     //
//  the Free Software Foundation; either version 2 of the License, or        //
//  (at your option) any later version.                                      //
//                                                                           //
//  You may not change or alter any portion of this comment or credits       //
//  of supporting developers from this source code or any supporting         //
//  source code which is considered copyrighted (c) material of the          //
//  original comment or credit authors.                                      //
//                                                                           //
//  This program is distributed in the hope that it will be useful,          //
//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
//  GNU General Public License for more details.                             //
//                                                                           //
//  You should have received a copy of the GNU General Public License        //
//  along with this program; if not, write to the Free Software              //
//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
//  ------------------------------------------------------------------------ //

/*
 * Smarty plugin
 * -------------------------------------------------------------
 * Type        :    function
 * Name        :    OnlineByModule
 * Version    :    1.0
 * Author    :    DuGris <http://www.dugris.info/>
 * Purpose    :    Get the number of visitors per module
 * -------------------------------------------------------------
 *
 * Input    :    modules    =    lists of the modules to display
 *                            if empty all modules
 *
 *             length        =   numbers character for the module name
 *
 *           assign        =    variable to be initialized for the templates
 *
 *
 *            I.e: Get all visitors for all modules
 *                <{OnlineByModule}>
 *
 *            I.e: Get news, mydownload
 *                <{xoMemberInfo modules="news|mydownload"}>
 *
 *            I.e: Get news, mydownload and limit the numbers character for the module name
 *                <{xoMemberInfo modules="news|mydownload" length=15}>
 *
 *            I.e: Get news, mydownload and limit the numbers character for the module name
 *                <{xoMemberInfo modules="news|mydownload" length=15}>
 *
 *            I.e: variable to be initialized for the templates
 *                <{xoMemberInfo assign=onlinebymodule}>
 *
 * -------------------------------------------------------------
 */

function smarty_function_OnlineByModule$params, &$smarty ) {
    global 
$xoopsUser$xoopsConfig;

    
$time time();
    if ( isset( 
$_SESSION['xoops_online_by_module'] ) && @$_SESSION['xoops_online_by_module_expire'] > $time ) {
        
$module_info $_SESSION['xoops_online_by_module'];
    } else {
        include_once(
XOOPS_ROOT_PATH '/modules/system/language/' $xoopsConfig['language'] . '/modinfo.php');
        
$module_info = array();
        
$myts =& MyTextSanitizer::getInstance();
        
$online_handler =& xoops_gethandler('online');
        
$module_handler =& xoops_gethandler('module');
        
$installed_mods =& $module_handler->getObjects();

        
$module_info = array() ;

        if ( @empty( 
$params['modules'] ) ) {
            foreach ( 
$installed_mods as $key => $module ) {
                
$module_list[] = $module->getVar('dirname');
            }
        } else {
            
$module_list explode("|"$params['modules']);
        }

        foreach ( 
$installed_mods as $key => $module ) {
            if ( 
in_array($module->getVar('dirname'), $module_list) ) {
                
$moduleperm_handler =& xoops_gethandler('groupperm');
                
$view_module 0;
                if (
$xoopsUser) {
                    if (
$moduleperm_handler->checkRight('module_read'$module->getVar('mid'), $xoopsUser->getGroups())) {
                        
$view_module 1;
                    }
                } else {
                    if (
$moduleperm_handler->checkRight('module_read'$module->getVar('mid'), XOOPS_GROUP_ANONYMOUS)) {
                        
$view_module 1;
                    }
                }

                
$online_module $online_handler->getCount(new Criteria('online_module'$module->getVar('mid') ));
                
$module_name $myts->makeTboxData4Show($module->getVar('name''E')) ;

                if ( (
$module->getVar('dirname') == 'system' && $view_module) ||  !$view_module) {
                    if (
$online_module != 0) {
                        
$module_info[1]['module'] = _MI_SYSTEM_NAME// system
                        
$module_info[1]['counter'] = $module_info[1]['counter'] + $online_module;
                    }
                } else {
                    if (
$online_module != 0) {
                        if ( 
$params['length'] && strlen$name_module ) > $params['length'] ) {
                            
$module_name substr$name_module $params['length'] );
                        }
                        
$module_info[$key]['module'] = $module_name;
                        
$module_info[$key]['counter'] = $online_module;
                    }
                }

                
$_SESSION['xoops_online_by_module'] = $module_info;
                
$_SESSION['xoops_online_by_module_expire'] = $time 60;
            }
        }
    }

    if ( !@empty( 
$params['assign'] ) ) {
        
$smarty->assign$params['assign'], $module_info );
    } else {
        
$ret "";
        foreach (
$module_info as $info ) {
            
$ret .= $info['module'] . " : " $info['counter'] . '<br />';
        }
        echo 
$ret;
    }
}

?>

Propulsé avec XOOPS | Graphisme adapté par Tatane, Grosdunord, Montuy337513

55 Personne(s) en ligne (42 Personne(s) connectée(s) sur Forum) | Utilisateur(s): 0 | Invité(s): 55 | Plus ...