Subject:*
<
Name/Email:*
<
Message Icon:*
<
Select*
<
Message:*
<



Click the Preview to see the content in action.
Options:*
<
Confirmation Code*
<
1 + 5 = ?  
Input the result from the expression
Maximum attempts you can try: 10
*
<
     
getConfig("logfilepath") . "/" . USERLOG_DIRNAME . "/export/" . $export . "/" . "total_ " . $totalLogs . "_" . time() . ".csv", 'w'); fputcsv($fp, $headers, $delimiter); foreach($logs as $thisRow) { fputcsv($fp, $thisRow, $delimiter); } fclose($fp); redirect_header("logs.php?op=" . $query_entry . (!empty($query_page) ? "&" . $query_page : ''), 1, _AM_USERLOG_LOG_EXPORT_SUCCESS); break; default : break; } } // END export [/code] Thank you. I will work on the above to be less hard-code, have more options like export selected lines and whole pages. Do you think export to csv would be enough? Also i used JSON in this module so exporting to JSON will not need anything. I hope You could take a look at this module. I try to write it very understandable. I more need to have ideas from some experts like you about the performance of this module. @ Mamba: You sent me an important email but i missed it. I will try to discuss about them here. [quote] - I have now 306 files, each 1 MB. How would it be possible to "merge" them together, if I would want to do some analytics (e.g. to find out where people go the most, or to retrace steps of a hacker) [/quote] 1- That 1MB is [b]just[/b] a threshold when you want to view files directly using Cpanel. but in general i cannot see any issue to have larger files like 10MB. 2- I can implement a merge tool too. it would be very easy as simple as combining files. I used JSON method and it is more understandable for human reading than serialize so you dont need any special tool. [quote] - how can we have a cron job zipping them together into one file? [/quote] It is very easy too. we can have a separate file browser tab and define merge, zip and ... Also a cron job can be done in the module or outside the module in Cpanel with some guide lines. honestly this module is not for very basic webmasters. so I assume webmaster could do some jobs himself. [quote] - maybe there could be another part of the application that could do some analytics, with charts (e.g. showing which continent/country people coming from, which module is the most popular) [/quote] yes. Honestly right now i only did 20% of what i had in my mind in this module. I did the setting section and storing logs and browsing them. several usages of these logs can be very amazing. And finally those would be just my mind other minds have many other nice things too. Also the form in logs.php is just a very first attempt. you can see all of them are text boxes. i will improve them to more understandable elements: eg: radio YES/No for isAdmin? module checkbox and ... [/quote]" />

Re: Userlog: a new module to log user activities
by irmtfan on 2013/4/24 4:25:49

good.
As i wrote in the last post the current defined task for last_login field in XOOPS CORE is keeping last visit of the user.(so last login is a confusing name !!!)
I know a couple of modules will provide you such a block for showing last visits.
I simplified your code to this:
le="color: #000000"><?php echo "<div style='clear:both;'></div> "; $now = time(); $hours = 24; $count=0; $time = ( intval( $hours ) > 0 ) ? time() - ( intval( $hours ) * 3600 ) : ( time() - 24*3600 ); global $xoopsDB; $sql = "SELECT distinct uid, uname, user_avatar, last_login FROM ".$xoopsDB->prefix("users")." WHERE level > 0 AND uid NOT IN (1) AND uid NOT IN (76) AND last_login >= '" . $time . "' ORDER BY last_login DESC"; $result = $xoopsDB->query($sql); while (list($uid, $uname,$user_avatar,$last_login) = $xoopsDB->fetchRow($result) ) { //Put this variable in the echo statements where you would like them to show up. $sinceLastLogin = ' ' . class_exists("XoopsLocal") ? XoopsLocal::formatTimestamp($last_login,"elapse") : ''; $count++; if ($user_avatar == 'avatars/blank.gif') { echo "<div style='float: left; padding:2px;'><a href='".XOOPS_URL."/userinfo.php?uid=".$uid."'><img src='".XOOPS_URL."/uploads/avatars/blank.gif' title='$uname | $sinceLastLogin' border='0' alt='".$uname."' height='48' width='48'></a></div>"; } else { echo "<div style='float: left; padding:2px;'><a href='".XOOPS_URL."/userinfo.php?uid=".$uid."'><img src='".XOOPS_URL."/uploads/".$user_avatar."' title='$uname | $sinceLastLogin' border='0' alt='".$uname."' height='48' width='48'></a></div>"; } } echo "<div style='clear:both;'></div> ";

as you can see nowadays XoopsLocal::formatTimestamp($last_login,"elapse") will do the job perfectly
every module developers include me can add a last visit block to his module. because It is not related to any module. it is just some codes to get last_login from users table. (It is better to add to core )
yesterday Mamba told my via email that it would be good to have it in newbb. so i add it to newbb too
http://svn.code.sf.net/p/xoops/svn/XoopsModules/newbb/branches/irmtfan/newbb/
Therefore it is very easy to add it

but login/register history is a different concept. here you can find all real login/register attempts.(and find whether it is failed or successful)
Today i improved the login/register history functionality and for better performance I add a patch to all $_POST which contained "pass".
Now it is ready to make a block from.
download trunk and test:
http://svn.code.sf.net/p/xoops/svn/XoopsModules/userlog/trunk/
Re: Userlog: a new module to log user activities
by blackrx on 2013/4/23 12:59:25

hi imrtfan very nice

btw can you make a special block for the success last login history where we can exclude any user etc

i forgot where i got this but i use this in my site all this while

le="color: #000000"><?php echo "<div style='clear:both;'></div> "; function timeDifference($start,$end,$return='days') { //change times to Unix timestamp. //$start = strtotime($start); //$end = strtotime($end); //subtract dates //echo 'Start Timestamp: ' . $start . '<br/>End Timestamp: ' . $end . '<br/>'; $difference = max($end, $start) - min($end,$start); $time = NULL; //calculate time difference. switch($return) { case 'days': $days = floor($difference/86400); $difference = $difference % 86400; $time['days'] = $days; case 'hours': $hours = floor($difference/3600); $difference = $difference % 3600; $time['hours'] = $hours; case 'minutes': $minutes = floor($difference/60); $difference = $difference % 60; $time['minutes'] = $minutes; case 'seconds': $seconds = $difference; $time['seconds'] = $seconds; } $output = array(); if(is_array($time)) { $showSec = true; if(isset($time['hours']) && $time['hours'] > 0) { $output[] = $time['hours'] . ' Hour'; $showSec = false; } if(isset($time['minutes']) && $time['minutes'] > 0) { $output[] = $time['minutes'] . ' minutes'; $showSec = false; } if(isset($time['seconds']) && $showSec == true) { return $time['seconds'] . ' Second'; } return implode(', ',$output); } } $now = time(); $hours = 24; $count=0; $time = ( intval( $hours ) > 0 ) ? time() - ( intval( $hours ) * 3600 ) : ( time() - 24*3600 ); global $xoopsDB; $sql = "SELECT distinct uid, uname, user_avatar, last_login FROM ".$xoopsDB->prefix("users")." WHERE level > 0 AND uid NOT IN (1) AND uid NOT IN (76) AND last_login >= '" . $time . "' ORDER BY last_login DESC"; $result = $xoopsDB->query($sql); while (list($uid, $uname,$user_avatar,$last_login) = $xoopsDB->fetchRow($result) ) { //Put this variable in the echo statements where you would like them to show up. $sinceLastLogin = ' ' . timeDifference($last_login,$now,'hours') . ' ago'; $count++; if ($user_avatar == 'avatars/blank.gif') { echo "<div style='float: left; padding:2px;'><a href='".XOOPS_URL."/userinfo.php?uid=".$uid."'><img src='".XOOPS_URL."/uploads/avatars/blank.gif' title='$uname | $sinceLastLogin' border='0' alt='".$uname."' height='48' width='48'></a></div>"; } else { echo "<div style='float: left; padding:2px;'><a href='".XOOPS_URL."/userinfo.php?uid=".$uid."'><img src='".XOOPS_URL."/uploads/".$user_avatar."' title='$uname | $sinceLastLogin' border='0' alt='".$uname."' height='48' width='48'></a></div>"; } } echo "<div style='clear:both;'></div> ";
Re: Userlog: a new module to log user activities
by irmtfan on 2013/4/23 11:16:28

Today i finally add one of the wishes for a log module that i had for years.
A login/register history.
Quote:

There is a new login/register history which you can see all attempts by anonymous users (failed and successive) to login or register in your website.
To start a login/register history, you should add a setting for anonymous users (Group id = 3) or all users (Unique ID = 0) which log at least uid and $_POST.

Actually we need a login history because the last login field in users table is just one time not history. Even it is not last login at all!!! It is just the last visit of a logged-in user.
Once all tested passed OK in stats.php page I will implement those functionality to blocks easily.

download trunk and test:
http://svn.code.sf.net/p/xoops/svn/XoopsModules/userlog/trunk/
Re: Userlog: a new module to log user activities
by irmtfan on 2013/4/22 6:39:57

Today i updated userlog to version 1.1

I noticed in some weird situations (eg: custom forms, hacks, ported modules like mediawiki, ...), there is no redirect message after submit. If you want to log any POST method regardless of redirect message you can set a config to yes.
changes:
Quote:

- add: check $_POST before load log module in preloads/core.php and xoops_version.php and include/postlog.php and language/english/modinfo.php and class/userlog.php(2013/04/21)
- add: show time update in admin/index.php and admin/stats.php (2013/04/22)
- add: add referral to stats table to show outside referer websites in class/stats.php and admin/stats.php(2013/04/22)


download trunk:
http://svn.code.sf.net/p/xoops/svn/XoopsModules/userlog/trunk/

version 1.01 is frozen and only will be updated if there are any bugs remained.
If everybody agreed we can release version 1.01 final.
Re: Userlog: a new module to log user activities
by irmtfan on 2013/4/21 10:46:46

Sorry for confusion.
Thank you for your test.
Actually the first question is: Where is the best and most reliable place to save logs?
I chose xoops_data, one can chose xoops_data/caches because he would be sure this folder is writable.
In my wesbite xoops_data is out of wwwroot so i set chmod at 755. but one may have it inside wwwroot and may prefer to make it read only.

Quote:

Then we must explain why irmtfan in his module userlog want to make it read-only in index.php
The folder 'C:/wamp/www/xoops-2.5.5test/htdocs/xoops_data/userlog' must be with a chmod '755' (it's now set on 777).'

I dont make it read-only.
755 is the minimum required chmod to write inside the folder, so any chmod above it is acceptable.

IMHO It is a displaying bug in moduleadmin class. (I forgot to post it )
In xoops255\Frameworks\moduleclasses\moduleadmin\moduleadmin.php Line 213:
le="color: #000000"><?php if (substr(decoct(fileperms($value[0])),2) != $value[1]) {


should be changes to:
le="color: #000000"><?php if (substr(decoct(fileperms($value[0])),2) < $value[1]) {

then it will show OK when the chmod is above 755.

Quote:

can be done from the install folder (include/install.php):


Userlog will not create folders in install because:
1- user may prefer to dont use log in file at all.
2- user can change the log folder location. ( currently xoops_data/userlog and uploads/userlog)
so once user choose to save logs in file the required folders will be created.

even you can add your folder easily in xoops_version.php
the log folder location is not hard-coded in the whole codes. so if you add a full path in xoops_version.php it will read it from there.

Who's Online

868 user(s) are online (775 user(s) are browsing Support Forums)


Members: 0


Guests: 868


more...

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits