51
irmtfan
Re: Userlog: a new module to log user activities
  • 2013/4/10 4:45

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


@blackrx:
Thank you for your test. specially I missed this one:
Module File for system-root Not Found!

I add system-root to userlog when there is no module ($xoopsModule == NULL) defined to distinct pages in YOURSITE/modules/MODULE_DIRNAME/script.php from root pages like YOURSITE/admin.php, YOURSITE/search.php, YOURSITE/index.php, ...
It is nothing more than an echo (so it not important because there is no error, warning,mal functioning, ...)
It is because after my definition XOOPS CORE think system-root is a module with "YOURSITE/modules/system-root" folder.
IMO XOOPS CORE should think about implement something in those root pages that no module defined because XOOPS is a completely modular CMS and always there is a module in action ( here: in YOURSITE/admin.php it is system module)
Anyway I will add a fix for this one.

Quote:

2. I cant have more than 1 setting... is this normal ?

maybe i didnt understand you well but i think you tried to have more than one setting for one (logby,unique id) eg: uid=1, gid=3, ...
It is useless and not allowed by the userlog module to have more than one setting for one (logby,unique id). you should have one setting for one (logby,unique id)
see in sql file i wrote:
CREATE TABLE mod_userlog_set (
  
set_id mediumint(8unsigned NOT NULL auto_increment,
  
name varchar(100NOT NULL default '',
  
logby varchar(10NOT NULL default '',
  
unique_id int(11unsigned NOT NULL default 0,
  
options TEXT NOT NULL,
  
scope TEXT NOT NULL,
  
PRIMARY KEY  (set_id),
  
UNIQUE logby_id (logbyunique_id)
ENGINE=MyISAM;

I defined a UNIQUE logby_id index so i am sure you cannot add more than one setting for one (logby, unique_id)
but now I find that userlog will not check when user try to edit a setting (logby,unique id) and change it to an exist one in admin/setting.php

I will add an error checking.
Anyway if i missed some error checkings the great XOOPS CORE will not allow you to add bad configs!!!. It will be the beauty of using XOOPS API!!!

Quote:

3. column option not removed after updating setting

huum. If i understand you it seems you want to remove all options in a setting. it is impossible. I described it:
Quote:

Options
Log which user/page data? Notice: selecting no option means all options. Selecting no store option (File and/or Database) means Database. Selecting views means store uid, groups, script name, pagetitle,pageadmin, module dirname, module name, item name, item id in Database

so selecting no option means selecting all options and you should select at least one option. if you dont need a setting (you dont need to log somebody) you should delete that setting

Quote:

1. how to make referer url clickable ?


I intended to not add any new feature until the module got stable.
but this is a user side feature and it is very very easy to add because i used templates.
in templates/userlog_admin_logs.html you can customize anything for yourself:
e.g. to make referer url clickable:
<{elseif $header == "admin" || $header == "pageadmin"}>
                    <{if 
$log.$header == 1}><{$smarty.const._YES}><{else}><{$smarty.const._NO}><{/if}>
                <{elseif 
$header == "referer"}>
                    <
a href="<{$log.referer}>"><{$log.referer}>a>
                <{elseif 
$header == "item_id"}>
                    <{if 
$log.item_id gt 0}><{$log.item_id}><{/if}>

you can find all $header values by turn smart debug on.

I will add this feature too.
It would be very good If some theme designers could show us better template for userlog.

EDIT:
I commit to svn:
revision 11368
http://svn.code.sf.net/p/xoops/svn/XoopsModules/userlog/trunk/

52
blackrx
Re: Userlog: a new module to log user activities
  • 2013/4/10 10:44

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


Thank you for the detail explanation..imrtfan...great module...keep up the good work

another question/suggestion.....

in the Logs tab.....how to know which setting is the log from

it will be nice if we can custom name the setting and select it from log tab
etc so i will see only log from setting i want to monitor


53
irmtfan
Re: Userlog: a new module to log user activities
  • 2013/4/10 11:53

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


Quote:

in the Logs tab.....how to know which setting is the log from

it will be nice if we can custom name the setting and select it from log tab
etc so i will see only log from setting i want to monitor


IMO it is confusing and is not good feature because:
1- settings are editable and webmaster can change logby,unique_id, options, scope or delete the setting. so if you see set_id=1 (uid=1) for user=1 in logs tab maybe you change setting to (gid=2) and then see it with other user

2- while uid=1 will log only one person other settings will log many visitors. e.g.: gid=3 means log all anon users

3- Now you can find all logs by searching (User ID=1 or visitor ip=IP) in logs tab and monitor that account and you are sure this user/visitor has a setting in settings tab (because it has logged) so why you want to show the related setting for him in logs tab?

54
blackrx
Re: Userlog: a new module to log user activities
  • 2013/4/10 12:01

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


ok i got it tq..still exploring with the module

thanks again...

55
blackrx
Re: Userlog: a new module to log user activities
  • 2013/4/10 12:38

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


Quote:

irmtfan wrote:


Today i have a challenge with the special permission needed for this kind of modules.
As you may guess one of the most important purposes for userlog module is logging webmasters activities.
But I need to limit all webmasters access to userlog module because i want to control it just myself(the webmaster with full access to root)

So i end up with a file permission.

I add something like this as an addon to userlog:
modules/userlog/admin/addon/perm.php

/*
 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.
*/
/**
 *  userlog module
 *
 * @copyright       The XOOPS Project http://sourceforge.net/projects/xoops/
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
 * @package         userlog admin
 * @subpackage      addon
 * @since           1
 * @author          irmtfan (irmtfan@yahoo.com)
 * @author          The XOOPS Project  
 * @version         $Id: perm.php 1 2013-02-26 16:25:04Z irmtfan $
 */
defined("XOOPS_ROOT_PATH") or die("XOOPS root path not defined");
// Here you can set ADDITIONAL permission in file for webmasters in your website, ONLY if you want to limit the access to userlog module to some of them.

// Webmasters that dont have access cannot:
// 1- go to the userllog/admin
// 2- go to the userlog preferences
// 3- installl, uninstall or update userlog
// 4- dump any table in system -> maintenance -> dump

// empty array means nothing.
// if you add uid of webmasters or those users who have admin permissions in userlog module, other admins will not have permission anymore.
$perm["super"]["uid"] = array();
// e.g.: $perm["super"]["user"] = array(1,234,23451); // it means only users with uid=1,234,23451 have access and other webmasters dont have access.
// if you add groups with admin permission in  whole site (webmasters) or admin permission in userlog module, other admin groups dont have permission
// e.g.: $perm["super"]["group"] = array(1,7,9); // it means only groups 1,7,9 have access and other groups dont have access.
$perm["super"]["group"] = array();

return 
$perm;


it is addon so it means you can just add it to the module if you need a webmaster permission from file.

then i add these codes to xoops_version.php

// START add webmaster permission from file to add additional permission check for all webmasters 
global $xoopsOption$xoopsModule;
// effective only in admin side
if ($xoopsOption['pagetype'] == "admin" && is_object($xoopsModule)) {
    
// get dirname
    
$dirname $xoopsModule->getVar('dirname');
    
// START if dirname is system
    
if($dirname == "system" && isset($_REQUEST['fct'])) {
        
$hModule =& xoops_gethandler('module');
        
// if we are in preferences of modules
        
if($_REQUEST['fct'] == "preferences" && isset($_REQUEST['mod'])) {
            
$mod intval($_REQUEST['mod']);
            
$module =& $hModule->get($mod);
            
$dirname $module->getVar('dirname');
        }
        
// if we are in modules admin - can be done with onuninstall and onupdate???
        
if($_REQUEST['fct'] == "modulesadmin" && isset($_REQUEST['module'])) {
            
$dirname $_REQUEST['module'];
        }
        
// if we are in maintenance - now all modules - how to do it for only one module?
        
if($_REQUEST['fct'] == "maintenance") {
            
$dump_modules = isset($_REQUEST['dump_modules']) ? $_REQUEST['dump_modules'] : false;
            
$dump_tables = isset($_REQUEST['dump_tables']) ? $_REQUEST['dump_tables'] : false;
            if (
$dump_tables == true || $dump_modules == true) {
                
$dirname $modversion['dirname'];
            }
        }
    }
    
// END if dirname is system
    
    // now check permission from file
    
if($dirname == $modversion['dirname']) {
        if (
file_exists($permFile XOOPS_ROOT_PATH "/modules/" $modversion['dirname'] . "/admin/addon/perm.php")) {
            
$perm = include $permFile;
            if (
count($perm["super"]["uid"]) > || count($perm["super"]["group"]) > 0) {
                global 
$xoopsUser;
                if (
is_object($xoopsUser) && 
                        !
in_array($xoopsUser->getVar("uid"), $perm["super"]["uid"]) &&
                        
count(array_intersect($xoopsUser->getGroups(),$perm["super"]["group"])) == 0
                    
) {
                    
$modversion['hasAdmin'] = 0;
                    
$modversion['system_menu'] = 0;
                    
$modversion['tables'] = null;
                    
redirect_header(XOOPS_URL "/admin.php"1sprintf(_MI_USERLOG_WEBMASTER_NOPERM,implode(","$perm["super"]["uid"]), implode(","$perm["super"]["group"])) );
                }
            }
        }
    }
}
// END add webmaster permission from file to add additional permission check for all webmasters


It is correctly do its job.

if you add some uids in the "super" permission other uids in webmasters group cannot do anything in the module.

IMO it should be in core too. because sometimes we need a super user/webmaster


is this working?

when i go here ...modules/userlog/admin/addon/perm.php

XOOPS root path not defined

56
irmtfan
Re: Userlog: a new module to log user activities
  • 2013/4/11 2:09

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


modules/userlog/admin/addon/perm.php is not for your browsing.
you can edit this file and add super permissions as i described in the file.
Quote:

// if you add uid of webmasters or those users who have admin permissions in userlog module, other admins will not have permission anymore.
// e.g.: $perm["super"]["user"] = array(1,234,23451); // it means only users with uid=1,234,23451 have access and other webmasters dont have access.
$perm["super"]["uid"] = array();

// if you add groups with admin permission in whole site (webmasters) or admin permission in userlog module, other admin groups dont have access.
// e.g.: $perm["super"]["group"] = array(1,7,9); // it means only groups 1,7,9 have access and other groups dont have access.
$perm["super"]["group"] = array();

see:
$perm["super"]["user"] = array(1,234,23451);

it means only users with uid=1,234,23451 have access and other webmasters dont have access.
I think the above is clear.

Also i more think about your requested feature.
Quote:

in the Logs tab.....how to know which setting is the log from

it will be nice if we can custom name the setting and select it from log tab
etc so i will see only log from setting i want to monitor

It seems to me you need to "find logs by a setting" in setting tab.

so please change the templates/userlog_admin_sets.html with below and let me know if it is what you want. (It just search logs tab with logby/uniqu_id)
<{$logo}>
<{if 
$sets}>
<
div class="outer">
    <
div class="head border x-small">
        <
div class="width5 floatleft center"><{$smarty.const._AM_USERLOG_SET_ID}>div>
        <
div class="width10 floatleft center"><{$smarty.const._AM_USERLOG_SET_NAME}>div>
        <
div class="width5 floatleft center"><{$smarty.const._AM_USERLOG_SET_LOGBY}>div>
        <
div class="width5 floatleft center"><{$smarty.const._AM_USERLOG_SET_UNIQUE_ID}>div>
        <
div class="width40 floatleft center"><{$smarty.const._AM_USERLOG_SET_OPTIONS}>div>
        <
div class="width20 floatleft center"><{$smarty.const._AM_USERLOG_SET_SCOPE}>div>
        <
div class="truncate center"><{$smarty.const._EDIT}>|<{$smarty.const._DELETE}>|<{$smarty.const._AM_USERLOG_ADMENU_LOGS}>div>
        <
div class="clear">div>
    div>
    <{foreach 
item=set from=$sets}>
    <
div class="<{cycle values='even,odd'}> border">
        <
div class="width5 floatleft center"><{$set.set_id}>div>
        <
div class="width10 floatleft center"><{$set.name}>div>
        <
div class="width5 floatleft center"><{$set.logby}>div>
        <
div class="width5 floatleft center"><{$set.unique_id}>div>
        <
div title="<{$set.options}>" class="width40 floatleft left"><{$set.options}>div>
        <
div title="<{$set.scope}>" class="width20 floatleft left"><{$set.scope}>div>
        <
div class="truncate center">
            <
a href="setting.php?set_id=<{$set.set_id}>" title="<{$smarty.const._EDIT}>"><img src="<{xoModuleIcons16 edit.png}>" alt="<{$smarty.const._EDIT}>" title="<{$smarty.const._EDIT}>" />a>
            |
            <
a href="setting.php?op=del&set_id=<{$set.set_id}>" title="<{$smarty.const._DELETE}>"><img src="<{xoModuleIcons16 delete.png}>" alt="<{$smarty.const._DELETE}>" title="<{$smarty.const._DELETE}>" />a>
            |
            <{if 
$set.unique_id eq 0}>
                <
a href="logs.php"><{$smarty.const._AM_USERLOG_ADMENU_LOGS}>a>
            <{elseif 
$set.logby eq $smarty.const._AM_USERLOG_UID}>
                <
a href="logs.php?options[uid]=<{$set.unique_id}>"><{$smarty.const._AM_USERLOG_ADMENU_LOGS}>a>
            <{elseif 
$set.logby eq $smarty.const._AM_USERLOG_SET_GID}>
                <
a href="logs.php?options[groups]=g<{$set.unique_id}>"><{$smarty.const._AM_USERLOG_ADMENU_LOGS}>a>
            <{elseif 
$set.logby eq $smarty.const._AM_USERLOG_SET_IP}>
                <
a href="logs.php?options[user_ip]=<{$set.unique_id}>"><{$smarty.const._AM_USERLOG_ADMENU_LOGS}>a>
            <{/if}>
        div>
        <
div class="clear">div>
    div>
    <{/foreach}>
    <{
$pagenav}>
div>
<{/if}>
<{
$addset}>
<{
$form}>

57
blackrx
Re: Userlog: a new module to log user activities
  • 2013/4/12 14:28

  • blackrx

  • Quite a regular

  • Posts: 227

  • Since: 2008/2/5 1


thank you again for the explanation imrtfan

the logs by setting works

btw any quick fix for the "Module File for system-root Not Found!"

i just noticed it is also display in all my custom php page since i installed userlog

58
irmtfan
Re: Userlog: a new module to log user activities
  • 2013/4/13 14:58

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


Quote:

btw any quick fix for the "Module File for system-root Not Found!"

i just noticed it is also display in all my custom php page since i installed userlog


I think i fixed it in trunk. did you use the latest revision?
http://svn.code.sf.net/p/xoops/svn/XoopsModules/userlog/trunk/

what php custom pages you meant? are you using a module for creating them or not. are these custom blocks?

59
Cesagonchu
Re: Userlog: a new module to log user activities

I just update the zip file here. Sorry for the delay.

60
irmtfan
Re: Userlog: a new module to log user activities
  • 2013/4/16 9:36

  • irmtfan

  • Module Developer

  • Posts: 3419

  • Since: 2003/12/7


blackrx:
I postponed the Final release because Im waiting for your feedback.
Please let us know if your issue is solved.

Login

Who's Online

249 user(s) are online (147 user(s) are browsing Support Forums)


Members: 0


Guests: 249


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Nov 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits