|
From: <ir...@us...> - 2013-02-27 08:14:18
|
Revision: 11113
http://sourceforge.net/p/xoops/svn/11113
Author: irmtfan
Date: 2013-02-27 08:14:14 +0000 (Wed, 27 Feb 2013)
Log Message:
-----------
some bug fixes. 1- store stats when nothing to store 2- name of 2 classes was lowercase
add some more help for users and admins
better method for getting setting.php
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/index.php
XoopsModules/userlog/trunk/userlog/admin/setting.php
XoopsModules/userlog/trunk/userlog/class/log.php
XoopsModules/userlog/trunk/userlog/class/setting.php
XoopsModules/userlog/trunk/userlog/class/stats.php
XoopsModules/userlog/trunk/userlog/images/userlog_logo.png
XoopsModules/userlog/trunk/userlog/include/log.php
XoopsModules/userlog/trunk/userlog/include/module.php
XoopsModules/userlog/trunk/userlog/language/english/help/help.html
XoopsModules/userlog/trunk/userlog/language/english/modinfo.php
XoopsModules/userlog/trunk/userlog/xoops_version.php
Added Paths:
-----------
XoopsModules/userlog/trunk/userlog/docs/readme_devs.txt
Modified: XoopsModules/userlog/trunk/userlog/admin/index.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/index.php 2013-02-27 04:31:18 UTC (rev 11112)
+++ XoopsModules/userlog/trunk/userlog/admin/index.php 2013-02-27 08:14:14 UTC (rev 11113)
@@ -56,7 +56,7 @@
$indexAdmin->addInfoBoxLine(_AM_USERLOG_SUMMARY,'<a href="logs.php?options[admin]=1">' . _AM_USERLOG_SUMMARY_ADMIN . '</a>');
$indexAdmin->addInfoBoxLine(_AM_USERLOG_SUMMARY,'<a href="logs.php?options[referer]=google.com">' . _AM_USERLOG_SUMMARY_GOOGLE . '</a>');
}
-$indexAdmin->addConfigBoxLine($Userlog->getConfig('logfilepath') .'/'. USERLOG_DIRNAME , 'folder');
+$indexAdmin->addConfigBoxLine($Userlog->getConfig('logfilepath') , 'folder');
echo $indexAdmin->addNavigation('index.php');
echo $indexAdmin->renderButton();
echo $indexAdmin->renderIndex();
Modified: XoopsModules/userlog/trunk/userlog/admin/setting.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/setting.php 2013-02-27 04:31:18 UTC (rev 11112)
+++ XoopsModules/userlog/trunk/userlog/admin/setting.php 2013-02-27 08:14:14 UTC (rev 11113)
@@ -30,6 +30,7 @@
// Where do we start ?
$set_id = UserlogRequest::getInt('set_id',0);
$logsetObj = $set_id ? $Userlog->getHandler('setting')->get($set_id) : UserlogSetting::getInstance();
+$logsetObj->cleanCache(); // delete all settings caches
if ($set_id && !is_object($logsetObj)) {
redirect_header("setting.php", 1, _AM_USERLOG_SET_ERROR);
}
@@ -98,7 +99,6 @@
$options_arr = $logsetObj->getOptions($option,"key");// empty means all. sanitize options
$logsetObj->setVar("options",implode(",",$options_arr));
$logsetObj->setVar("scope",implode(",",$scope));
- $logsetObj->cleanCache(); // delete all settings caches
$logsetObj->set(true);
redirect_header("setting.php", 1, sprintf($message, $logsetObj->name()));
break;
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-02-27 04:31:18 UTC (rev 11112)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-02-27 08:14:14 UTC (rev 11113)
@@ -143,7 +143,7 @@
// force to create file if not exist
if ($fileHandler->XoopsFileHandler($log_file, false) == false) {
if(!$fileHandler->exists()) {
- $fileHandler->XoopsFileHandler($log_file, true); // create file
+ $fileHandler->XoopsFileHandler($log_file, true); // create file and folder
$this->setErrors('File was not exist create file ({$log_file_name})');
// update the new file in database
$statsObj = UserlogStats::getInstance();
Modified: XoopsModules/userlog/trunk/userlog/class/setting.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/setting.php 2013-02-27 04:31:18 UTC (rev 11112)
+++ XoopsModules/userlog/trunk/userlog/class/setting.php 2013-02-27 08:14:14 UTC (rev 11113)
@@ -104,50 +104,35 @@
return $options;
}
///////////////////////////////////////////////////////////
- // if uid setting exist in db
- $criteria = new CriteriaCompo();
- $criteria->add(new Criteria('logby', 'uid'));
- $criteria->add(new Criteria('unique_id', $unique_uid));
- $logsetObj = $this->userlog->getHandler('setting')->getObjects($criteria);
- if ($logsetObj) {
- $logsetObj = $logsetObj[0];
- $this->setFile('uid', $unique_uid, array($logsetObj->options(), $logsetObj->scope()) );
- return array($logsetObj->options(), $logsetObj->scope());
+ // database get All is better for performance???
+ $logsetsObj = $this->userlog->getHandler('setting')->getAll();
+ if (empty($logsetsObj)) return false; // if not set in db return false
+ $uid_unique_uid = "uid" . $unique_uid;
+ foreach($unique_gid as $key=>$gid) {
+ $gid_unique_gid[$key] = "gid" . $gid;
}
- // if gid setting exist in db
- foreach ($unique_gid as $gid) {
- $criteria = new CriteriaCompo();
- $criteria->add(new Criteria('logby', 'gid'));
- $criteria->add(new Criteria('unique_id', $gid));
- $logsetObj = $this->userlog->getHandler('setting')->getObjects($criteria);
- if ($logsetObj) {
- $logsetObj = $logsetObj[0];
- $this->setFile('gid', $gid, array($logsetObj->options(), $logsetObj->scope()));
- return array($logsetObj->options(), $logsetObj->scope());
+ $ip_unique_ip = "ip" . $unique_ip;
+ foreach($logsetsObj as $setObj) {
+ $sLobgy = $setObj->logby();
+ $sUnique_id = $setObj->unique_id();
+ $sLogbyId = $sLobgy . $sUnique_id;
+ // if uid setting exist in db return it
+ if($sLogbyId == $uid_unique_uid ||
+ // if gid setting exist in db return it
+ in_array($sLogbyId, $gid_unique_gid) ||
+ // if ip setting exist in db return it
+ $sLogbyId == $ip_unique_ip) {
+ $sets = array($setObj->options(), $setObj->scope());
+ $this->setFile($sLobgy, $sUnique_id, $sets); // build cache
+ return $sets;
}
+ // if all exist in db
+ if($sUnique_id == 0) {
+ $sets = array($setObj->options(), $setObj->scope());
+ $this->setFile('all', 0, $sets); // build cache
+ return $sets;
+ }
}
-
- // if ip setting exist in db
- $criteria = new CriteriaCompo();
- $criteria->add(new Criteria('logby', 'ip'));
- $criteria->add(new Criteria('unique_id', $unique_ip));
- $logsetObj = $this->userlog->getHandler('setting')->getObjects($criteria);
- if ($logsetObj) {
- $logsetObj = $logsetObj[0];
- $this->setFile('ip', $unique_ip, array($logsetObj->options(), $logsetObj->scope()));
- return array($logsetObj->options(), $logsetObj->scope());
- }
- // if all exist in db
- $criteria = new CriteriaCompo();
- //$criteria->add(new Criteria('logby', 'ip')); // logby can be anything uid, gid, ip, ...
- $criteria->add(new Criteria('unique_id', 0));
- $logsetObj = $this->userlog->getHandler('setting')->getObjects($criteria);
- if ($logsetObj) {
- $logsetObj = $logsetObj[0];
- $this->setFile('all', 0, array($logsetObj->options(), $logsetObj->scope()));
- return array($logsetObj->options(), $logsetObj->scope());
- }
-
return false;
}
Modified: XoopsModules/userlog/trunk/userlog/class/stats.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/stats.php 2013-02-27 04:31:18 UTC (rev 11112)
+++ XoopsModules/userlog/trunk/userlog/class/stats.php 2013-02-27 08:14:14 UTC (rev 11113)
@@ -22,6 +22,7 @@
defined("XOOPS_ROOT_PATH") or die("XOOPS root path not defined");
include_once dirname(dirname(__FILE__)) . '/include/common.php';
+xoops_loadLanguage("admin",USERLOG_DIRNAME);
class UserlogStats extends XoopsObject
{
@@ -74,6 +75,7 @@
public function getAll()
{
$statsObj = $this->userlog->getHandler('stats')->getAll();
+ if (empty($statsObj)) return false; // if no result nothing in database
foreach ($statsObj as $sObj) {
$index1 = $sObj->stats_type().$sObj->stats_link();
$index2 = $sObj->stats_period();
@@ -100,15 +102,16 @@
case "file":
$logext = "log";
$log_file_paths = array(XOOPS_VAR_PATH .'/'. USERLOG_DIRNAME,XOOPS_UPLOAD_PATH .'/'. USERLOG_DIRNAME);
+
$allFiles = 0;
foreach($log_file_paths as $log_file_path) {
$log_file = $log_file_path . '/' . $this->userlog->getConfig('logfilename').".".$logext;
$files = glob($log_file_path);
$allFiles += count($files);
- $this->update("file" ,0 ,count($files) ,false ,$log_file); // update working file in 2 pathes
+ $this->update("file" ,0 ,count($files) ,false ,$files ? $log_file : ''); // update working file in 2 pathes
}
// update all files in db link='all'
- $this->update("file" ,0 ,$allFiles ,false ,'all');
+ $this->update("file" ,0 ,$allFiles ,false ,$files ? 'all': '');
break;
case "views":
break;
@@ -160,6 +163,8 @@
public function update($type = 'log', $period = 0, $value = null, $increment = false, $link = '')
{
+ // if there is nothing to add to db
+ if (empty($value) && empty($link)) return false;
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('stats_type', $type), "AND");
$criteria->add(new Criteria('stats_period', $period), "AND");
Added: XoopsModules/userlog/trunk/userlog/docs/readme_devs.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/readme_devs.txt (rev 0)
+++ XoopsModules/userlog/trunk/userlog/docs/readme_devs.txt 2013-02-27 08:14:14 UTC (rev 11113)
@@ -0,0 +1,279 @@
+developers help for userlog module.
+
+1- log user activities structure.
+I assume we need to gather below information from user. If you have any idea about them please let me know.
+i dont sanitize them because i want to log them as ther are. what is your idea. Im a very basic programmer. please help me.
+
+in userlog/class/setting.php
+
+[code]
+ public function getOptions($option = null, $V = "value")
+ {
+ $V = strtolower($V);
+
+ if ($this->userlog->getUser()) {
+ $uid = $this->userlog->getUser()->getVar('uid');
+ $uname = $this->userlog->getUser()->getVar('uname');
+ $last_login = $this->userlog->getUser()->getVar('last_login');
+ $admin = $this->userlog->getUser()->isAdmin();
+ $groups = "g" . implode("g",$this->userlog->getUser()->getGroups()); // g1g2
+ } else {
+ $uid = 0;
+ $uname = '';
+ $last_login = 0;
+ $admin = 0;
+ $groups = "g" . XOOPS_GROUP_ANONYMOUS; // g3
+ }
+ $options = array(
+ "log_id" => array( "type" => "int",
+ "title" => _AM_USERLOG_LOG_ID,
+ "value" => null // null for now
+ ),
+ "log_time" => array( "type" => "int",
+ "title" => _AM_USERLOG_LOG_TIME,
+ "value" => time()
+ ),
+ "uid" => array( "type" => "int",
+ "title" => _AM_USERLOG_UID,
+ "value" => $uid
+ ),
+ "uname" => array( "type" => "text",
+ "title" => _AM_USERLOG_UNAME,
+ "value" => $uname
+ ),
+ "admin" => array( "type" => "bool",
+ "title" => _AM_USERLOG_ADMIN,
+ "value" => $admin
+ ),
+ "groups" => array( "type" => "text",
+ "title" => _AM_USERLOG_GROUPS,
+ "value" => $groups
+ ),
+ "last_login" => array( "type" => "int",
+ "title" => _AM_USERLOG_LAST_LOGIN,
+ "value" => $last_login
+ ),
+ "user_ip" => array( "type" => "text",
+ "title" => _AM_USERLOG_USER_IP,
+ "value" => $_SERVER['REMOTE_ADDR']
+ ),
+ "user_agent" => array( "type" => "text",
+ "title" => _AM_USERLOG_USER_AGENT,
+ "value" => $_SERVER['HTTP_USER_AGENT']
+ ),
+ "url" => array( "type" => "text",
+ "title" => _AM_USERLOG_URL,
+ "value" => $_SERVER['REQUEST_URI']
+ ),
+ "script" => array( "type" => "text",
+ "title" => _AM_USERLOG_SCRIPT,
+ "value" => end(explode('/',$_SERVER['PHP_SELF']))
+ ),
+ "referer" => array( "type" => "text",
+ "title" => _AM_USERLOG_REFERER,
+ "value" => !empty($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ""
+ ),
+ "pagetitle" => array( "type" => "text",
+ "title" => _AM_USERLOG_PAGETITLE,
+ "value" => isset($GLOBALS['xoopsTpl']) ? $GLOBALS['xoopsTpl']->get_template_vars("xoops_pagetitle") : ""
+ ),
+ "module" => array( "type" => "text",
+ "title" => _AM_USERLOG_MODULE,
+ "value" => $this->userlog->getLogModule()->getVar("dirname")
+ ),
+ "item_name" => array( "type" => "text",
+ "title" => _AM_USERLOG_ITEM_NAME,
+ "value" => null
+ ),
+ "item_id" => array( "type" => "text",
+ "title" => _AM_USERLOG_ITEM_ID,
+ "value" => null
+ ),
+ // user data input method
+ "request_method" => array( "type" => "text",
+ "title" => _AM_USERLOG_REQUEST_METHOD,
+ "value" => $_SERVER['REQUEST_METHOD']
+ ),
+ "get" => array( "type" => "text",
+ "title" => _AM_USERLOG_GET,
+ "value" => $_GET
+ ),
+ "post" => array( "type" => "text",
+ "title" => _AM_USERLOG_POST,
+ "value" => $_POST
+ ),
+ "request" => array( "type" => "text",
+ "title" => _AM_USERLOG_REQUEST,
+ "value" => $_REQUEST
+ ),
+ "files" => array( "type" => "text",
+ "title" => _AM_USERLOG_FILES,
+ "value" => $_FILES
+ ),
+ "env" => array( "type" => "text",
+ "title" => _AM_USERLOG_ENV,
+ "value" => $_ENV
+ ),
+ "session" => array( "type" => "text",
+ "title" => _AM_USERLOG_SESSION,
+ "value" => $_SESSION
+ ),
+ "cookie" => array( "type" => "text",
+ "title" => _AM_USERLOG_COOKIE,
+ "value" => $_COOKIE
+ ),
+ "header" => array( "type" => "text",
+ "title" => _AM_USERLOG_HEADER,
+ "value" => headers_list()
+ ),
+ "logger" => array( "type" => "text",
+ "title" => _AM_USERLOG_LOGGER,
+ "value" => $GLOBALS['xoopsLogger']->errors
+ ),
+ // settings will not be logged
+ "store_file" => array( "type" => "int",
+ "title" => _AM_USERLOG_STORE_FILE,
+ "value" => 1
+ ),
+ "store_db" => array( "type" => "int",
+ "title" => _AM_USERLOG_STORE_DB,
+ "value" => 1
+ ),
+ "views" => array( "type" => "int",
+ "title" => _AM_USERLOG_VIEWS,
+ "value" => 1 // for item_name and item_id
+ ),
+ );
+ $ret = $this->userlog->getFromKeys($options, $option);
+ if (empty($V)) return $ret;
+ if ($V == "key") return array_keys($ret);
+ $ret2 = null;
+ foreach ($ret as $option=>$val) {
+ $ret2[$option] = $val[$V];
+ }
+ return $ret2;
+ }
+[/code]
+
+2- setting structure.
+i think we just need to log users based on "uid" or "gid" or "ip" and it will cover all possibilities. please let me know your idea.
+
+the table structure is:
+in userlog/sql/mysql.sql
+[code]
+CREATE TABLE mod_userlog_set (
+ set_id mediumint(8) unsigned NOT NULL auto_increment,
+ name varchar(100) NOT NULL default '',
+ logby varchar(10) NOT NULL default '',
+ unique_id int(11) unsigned NOT NULL default 0,
+ options TEXT NOT NULL,
+ scope TEXT NOT NULL,
+ PRIMARY KEY (set_id),
+ UNIQUE logby_id (logby, unique_id)
+) ENGINE=MyISAM;
+[/code]
+
+The above is clear. more information in module help.
+
+3- performance.
+it checks every hit to see if the visitor have a setting or not. for the best performance i wrote a get function like this.
+in userlog/class/setting.php
+[code]
+ public function get()
+ {
+ // if uid setting exist in File
+ $unique_uid = ($this->userlog->getUser()) ? $this->userlog->getUser()->getVar('uid') : 0;
+ if ($options = $this->getFile('uid', $unique_uid)) {
+ return $options;
+ }
+
+ // if gid setting exist in File
+ $unique_gid = ($this->userlog->getUser()) ? $this->userlog->getUser()->getGroups() : array(XOOPS_GROUP_ANONYMOUS);
+ foreach ($unique_gid as $gid) {
+ if ($options = $this->getFile('gid', $gid)) {
+ return $options;
+ }
+ }
+ // if ip setting exist in File
+ $unique_ip = XoopsUserUtility::getIP(); // ip as int
+ if ($options = $this->getFile('ip', $unique_ip)) {
+ return $options;
+ }
+ // if all exist in File
+ if ($options = $this->getFile('all', 0)) {
+ return $options;
+ }
+ ///////////////////////////////////////////////////////////
+ // database get All is better for performance???
+ $logsetsObj = $this->userlog->getHandler('setting')->getAll();
+ if (empty($logsetsObj)) return false; // if not set in db return false
+ $uid_unique_uid = "uid" . $unique_uid;
+ foreach($unique_gid as $key=>$gid) {
+ $gid_unique_gid[$key] = "gid" . $gid;
+ }
+ $ip_unique_ip = "ip" . $unique_ip;
+ foreach($logsetsObj as $setObj) {
+ $sLobgy = $setObj->logby();
+ $sUnique_id = $setObj->unique_id();
+ $sLogbyId = $sLobgy . $sUnique_id;
+ // if uid setting exist in db return it
+ if($sLogbyId == $uid_unique_uid ||
+ // if gid setting exist in db return it
+ in_array($sLogbyId, $gid_unique_gid) ||
+ // if ip setting exist in db return it
+ $sLogbyId == $ip_unique_ip) {
+ $sets = array($setObj->options(), $setObj->scope());
+ $this->setFile($sLobgy, $sUnique_id, $sets); // build cache
+ return $sets;
+ }
+ // if all exist in db
+ if($sUnique_id == 0) {
+ $sets = array($setObj->options(), $setObj->scope());
+ $this->setFile('all', 0, $sets); // build cache
+ return $sets;
+ }
+ }
+ return false;
+ }
+[/code]
+
+as you can see it create cache files for each settings. IMO it will help to reduce queries for users have a setting.
+
+for getting settings from db i firstly used criteria but then i decide to get all settings at once and then find if the user have setting or not. IMO it has the better performance. please let me know your opinion. what is the best performance? this function is important for your review.
+
+4- views
+now every module have a counter for its item views. eg: news, publisher, page in xoops 2.6
+but this counter is useless. we dont need forever views. we need views in a specific time period.
+in every news agency the first and top block is "today hot news" and it means news that had been most viewed today.
+
+for a long time that was an unsolved issue for me and i think in the whole xoops we have this problem in all modules.
+after starting userlog for a different purpose I suddenly reach to an innovative idea for gathering all views in all modules.
+i used module "notification" because every module item that should have views have a notification too.
+there we have all needed information about items. so i wrote this nice and tricky function:
+[code]
+ public function setItem()
+ {
+ $not_config =& $this->userlog->getLogModule()->getInfo('notification');
+ if (!empty($not_config)) {
+ foreach ($not_config['category'] as $category) {
+ // if $item_id != 0 ---> return true
+ if (!empty($category['item_name']) && $item_id = UserlogRequest::getInt($category['item_name'], 0)){
+ $this->setVar('item_name', $category['item_name']);
+ $this->setVar('item_id', $item_id);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+[/code]
+
+so for example in news we only have these typical URLs:
+
+news/article.php?storyid=ITEM_ID
+news/index.php|article.php?storytopic=ITEM_ID
+
+as you can see i just need to store item_name and item_id because i have the module dirname and script name!!!
+
+IMO we should stick to this idea to have a overall item views in the XOOPS and drop all counters in all modules.
+i need your idea about this.
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/images/userlog_logo.png
===================================================================
(Binary files differ)
Modified: XoopsModules/userlog/trunk/userlog/include/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/include/log.php 2013-02-27 04:31:18 UTC (rev 11112)
+++ XoopsModules/userlog/trunk/userlog/include/log.php 2013-02-27 08:14:14 UTC (rev 11113)
@@ -27,7 +27,7 @@
include_once 'common.php';
$Userlog = Userlog::getInstance(false);
-$logsetObj = Userlogsetting::getInstance();
+$logsetObj = UserlogSetting::getInstance();
$statsObj = UserlogStats::getInstance();
list($setting, $scope) = $logsetObj->get();
Modified: XoopsModules/userlog/trunk/userlog/include/module.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/include/module.php 2013-02-27 04:31:18 UTC (rev 11112)
+++ XoopsModules/userlog/trunk/userlog/include/module.php 2013-02-27 08:14:14 UTC (rev 11113)
@@ -23,6 +23,6 @@
include_once 'common.php';
function xoops_module_uninstall_userlog(&$module)
{
- $logsetObj = Userlogsetting::getInstance();
+ $logsetObj = UserlogSetting::getInstance();
$logsetObj->cleanCache(); // delete all settings caches
}
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/language/english/help/help.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-02-27 04:31:18 UTC (rev 11112)
+++ XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-02-27 08:14:14 UTC (rev 11113)
@@ -1,22 +1,37 @@
<div id="help-template" class="outer">
-<h1 class="head">Help: userlog</h1>
-
+<h1 class="head">Help: <a class="ui-corner-all tooltip" href="<{$xoops_url}>/modules/userlog/admin/index.php" title="Back to the administration of Userlog"> Userlog <img src="<{xoAdminIcons home.png}>" alt="Back to the administration of Userlog"/></a></h1>
<h4 class="odd">Description</h4>
<p class="even">
Userlog is a node logger which can log your user/visitor activities in your site.
This is a very useful tool for webmasters in busy sites. for example you can log your other admins navigation.
current nodes for logging are: user id, user group and visitor ip.
+You can store logs in database, in file or both.
</p>
-
+<h4 class="odd">Userlog preferences</h4>
+After installtion we strongly recommend you to go to preferences.<br /><br />
+Here you can set your desired values for important configurations.<br /><br />
+important configs are:<br /><br />
+<b>Log file configs</b>:
+If you need to store logs in file, set the working path, working file size, working file name, ... here<br /><br />
+<b>Log database configs</b>:
+If you need to store logs in database, set the maximum logs thersholds here.<br /><br />
<h4 class="odd">Setting</h4>
<p class="even">
"Setting" provides a wide range of options that you can use to set for specific users to be logged.<br />
<br />
<b>Setting name</b>: here you can input any name you like. It is not important for the module activities. It is just for you.<br />
<br />
-<b>Setting logby</b>: here you will choose the 'node' you want to log users by that. currently you can log users by "user id", "user group" and "visitor ip".<br />
-by selecting user group all activities of users belong to that specific group will be logged.<br />
-visitor ip is very usefull to log robots, malicious visitors and ...<br />
+<b>Setting logby</b>: here you will choose the 'node' you want to log users by that and in the next part you should input the Unique id for this node. currently you can log users by "user id", "user group" and "visitor ip".<br />
+- by selecting uid only that specific user will be logged. eg uid=1<br />
+- by selecting user group all activities of users belong to that specific group will be logged. eg: gid=3<br />
+- visitor ip is very usefull to log robots, malicious visitors and ... eg: ip=66.249.66.1<br />
+- if you set Unique id = 0 (read the next part) Userlog module will log all users/visitors regardless of logby.
+the priority for getting settings is as below.<br /><br />
+IF EXIST uid get it<br />
+ELSE IF EXIST gid get it<br />
+ELSE IF EXIST ip get it<br />
+ELSE IF Unique id = 0 log all users<br />
+
<br />
<b>Setting Unique id</b>: here you must choose one unique id (node id) to be logged.<br />
(eg: uid=1, gid=3 (anonymous), ip=66.249.66.1) enter 0 means all users.<br />
@@ -25,13 +40,18 @@
select log user views means store uid, groups, script name, pagetitle, module, item name, item id in Database.<br />
<br />
<b>Setting scope:</b> if you want to log users activities in some specific module here you can do it.<br />
-select nothing means all website.
+select nothing means all website.<br />
+<br />
+attention: we assume you will not have many settings in your site (eg: less than 100 settings) so we dont provide many navigation facilities like order and sort in set list table. you just have a pagenav.<br />
+advise: more settings will confuse you more. choose logby and Unique id wisely to avoid any overlap.<br />
+for example for a specific user use "uid" but for a group use "gid".<br />
</p>
<h4 class="odd">Logs</h4>
<p class="even">
You can see users logs through this section of the userlog Module.<br /><br />
To search for logs based on a criteria you have an advance form.<br /><br />
+To do: browsing logs from log file<br /><br />
</p>
<h4 class="odd">Views block</h4>
<p class="even">
Modified: XoopsModules/userlog/trunk/userlog/language/english/modinfo.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/modinfo.php 2013-02-27 04:31:18 UTC (rev 11112)
+++ XoopsModules/userlog/trunk/userlog/language/english/modinfo.php 2013-02-27 08:14:14 UTC (rev 11113)
@@ -27,28 +27,28 @@
// configs
// config logfile
-define("_MI_USERLOG_CONFCAT_LOGFILE","Log file");
+define("_MI_USERLOG_CONFCAT_LOGFILE","Log file (Set if you need to store logs in file otherwise foget it)");
define("_MI_USERLOG_CONFCAT_LOGFILE_DSC","Preferences for log file");
define("_MI_USERLOG_CONFCAT_FORMAT","Format");
define("_MI_USERLOG_CONFCAT_FORMAT_DSC","Preferences for format");
define("_MI_USERLOG_CONFCAT_PAGENAV","Page navigation");
define("_MI_USERLOG_CONFCAT_PAGENAV_DSC","Preferences for page navigation");
-define("_MI_USERLOG_CONFCAT_LOGDB","Log database");
+define("_MI_USERLOG_CONFCAT_LOGDB","Log database (Set if you need to store logs in database otherwise foget it)");
define("_MI_USERLOG_CONFCAT_LOGDB_DSC","Preferences for Log database");
-define("_MI_USERLOG_MAXLOGFILESIZE","Maximum file size for log file (bytes)");
-define("_MI_USERLOG_MAXLOGFILESIZE_DSC","Advise: Set it below 1MB because some servers have limitations for view large file in Cpanel.");
+define("_MI_USERLOG_MAXLOGFILESIZE","Maximum file size for current working log file (in bytes)");
+define("_MI_USERLOG_MAXLOGFILESIZE_DSC","Advise: Set it below 1MB because some servers set limitations for viewing large files in Cpanel.");
define("_MI_USERLOG_LOGFILEPATH","Log file full path");
define("_MI_USERLOG_LOGFILEPATH_DSC","Advise: a path outside wwwroot is safe from browsing by everybody");
-define("_MI_USERLOG_LOGFILENAME","Log file name");
-define("_MI_USERLOG_LOGFILENAME_DSC","the initial log file name");
+define("_MI_USERLOG_LOGFILENAME","Current working Log file name");
+define("_MI_USERLOG_LOGFILENAME_DSC","Older log files will be stored with this prefix. Log_file_name_date('Y-m-d_H-i-s').log");
// config format
define("_MI_USERLOG_DATEFORMAT","Date format");
-define("_MI_USERLOG_DATEFORMAT_DSC","If leave empty will use Core default");
+define("_MI_USERLOG_DATEFORMAT_DSC","If you leave it empty, this module will use Core default");
// config pagenav
define("_MI_USERLOG_SETS_PERPAGE","Number of settings per page");
-define("_MI_USERLOG_SETS_PERPAGE_DSC","The default value");
+define("_MI_USERLOG_SETS_PERPAGE_DSC","The default value for viewing settings");
define("_MI_USERLOG_LOGS_PERPAGE","Number of logs per page");
-define("_MI_USERLOG_LOGS_PERPAGE_DSC","The default value");
+define("_MI_USERLOG_LOGS_PERPAGE_DSC","The default value for viewing logs");
// config logdb
define("_MI_USERLOG_MAXLOGS","Maximum logs stored in db");
define("_MI_USERLOG_MAXLOGS_DSC","logs will be deleted from db after this number");
Modified: XoopsModules/userlog/trunk/userlog/xoops_version.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-02-27 04:31:18 UTC (rev 11112)
+++ XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-02-27 08:14:14 UTC (rev 11113)
@@ -19,6 +19,7 @@
* @author The XOOPS Project <www.xoops.org> <www.xoops.ir>
* @version $Id: xoops_version.php 1 2013-02-26 16:25:04Z irmtfan $
*/
+defined("XOOPS_ROOT_PATH") or die("XOOPS root path not defined");
$modversion = array();
$modversion['name'] = _MI_USERLOG_NAME;
$modversion['dirname'] = 'userlog';
|
|
From: <ir...@us...> - 2013-02-28 02:20:31
|
Revision: 11120
http://sourceforge.net/p/xoops/svn/11120
Author: irmtfan
Date: 2013-02-28 02:20:26 +0000 (Thu, 28 Feb 2013)
Log Message:
-----------
add pagination, sort, order form and up/down arrow to admin/logs.php
bug fix: stats update when file type have a link
fix some definitions
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/index.php
XoopsModules/userlog/trunk/userlog/admin/logs.php
XoopsModules/userlog/trunk/userlog/class/stats.php
XoopsModules/userlog/trunk/userlog/language/english/admin.php
XoopsModules/userlog/trunk/userlog/language/english/help/help.html
XoopsModules/userlog/trunk/userlog/language/english/modinfo.php
XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
XoopsModules/userlog/trunk/userlog/xoops_version.php
Added Paths:
-----------
XoopsModules/userlog/trunk/userlog/class/form/
XoopsModules/userlog/trunk/userlog/class/form/index.html
XoopsModules/userlog/trunk/userlog/class/form/simpleform.php
Modified: XoopsModules/userlog/trunk/userlog/admin/index.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/index.php 2013-02-27 21:09:27 UTC (rev 11119)
+++ XoopsModules/userlog/trunk/userlog/admin/index.php 2013-02-28 02:20:26 UTC (rev 11120)
@@ -35,8 +35,8 @@
$statsObj->updateAll("file", 100); // prob = 100
$stats = $statsObj->getAll();
-// if nothing in database - start with a setting!
-if (empty($stats)) {
+// if no set in database - start with a setting!
+if ($stats["set"][0]["value"] == 0) {
$indexAdmin->addItemButton(_AM_USERLOG_SET_ADD,"setting.php");
} else {
$indexAdmin->addInfoBox(_AM_USERLOG_STATS_ABSTRACT);
@@ -48,7 +48,8 @@
// use sprintf in moduleadmin: sprintf($text, "<span style='color : " . $color . "; font-weight : bold;'>" . $value . "</span>")
$indexAdmin->addInfoBoxLine(_AM_USERLOG_STATS_ABSTRACT,
sprintf(_AM_USERLOG_STATS_TYPE_PERIOD, "%s\1", $types[$type], constant("_AM_USERLOG_" . strtoupper($periods[$period]))),
- $arr2["value"] );
+ $arr2["value"],
+ $arr2["value"] ? 'GREEN' : 'RED');
}
}
$indexAdmin->addInfoBox(_AM_USERLOG_SUMMARY);
Modified: XoopsModules/userlog/trunk/userlog/admin/logs.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-02-27 21:09:27 UTC (rev 11119)
+++ XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-02-28 02:20:26 UTC (rev 11120)
@@ -38,6 +38,9 @@
//$query_types = array("="=>"",">"=>"GT", "<"=>"LT");
$criteria = new CriteriaCompo();
//$criteria->add(new Criteria(1, 1));
+// formnav in the upper section
+include_once USERLOG_ROOT_PATH . '/class/form/simpleform.php';
+$formNav = new UserlogSimpleForm('','logsnav','logs.php', 'get');
foreach($options as $key=>$val) {
// if user input an empty variable unset it
if (empty($val)) {
@@ -89,12 +92,20 @@
$vars[$key] = $val;
// add criteria
$criteria->add($criteria_q[$key]);
+ // add hiddens to formnav
+ $hidOptionsEl = new XoopsFormHidden("options[{$key}]", $val);
+ $formNav->addElement($hidOptionsEl);
+ unset($hidOptionsEl);
}
$logs = $Userlog->getHandler('log')->getLogs($limitentry,$startentry,$criteria,$sortentry,$orderentry ,null, false);
$totalLogs = $Userlog->getHandler('log')->getLogsCount($criteria);
+if ( !empty($query_array) ) {
+ $query_page = implode("&", array_values($query_array));
+}
+$query_entry = "&limitentry=" . $limitentry . "&sortentry=" . $sortentry . "&orderentry=" . $orderentry;
// pagenav
-$pagenav = new XoopsPageNav($totalLogs, $limitentry, $startentry, 'startentry');
+$pagenav = new XoopsPageNav($totalLogs, $limitentry, $startentry, 'startentry', $query_entry . (!empty($query_page) ? "&" . $query_page : ''));
if ( !empty($pagenav) ) {
$GLOBALS['xoopsTpl']->assign("pagenav",$pagenav->renderNav());
}
@@ -124,8 +135,8 @@
}
// assign logs
$GLOBALS['xoopsTpl']->assign('logs', $logs);
-if ( !empty($query_array) ) {
- $GLOBALS['xoopsTpl']->assign('query_page', implode("&", array_values($query_array)));
+if ( !empty($query_page) ) {
+ $GLOBALS['xoopsTpl']->assign('query_page', $query_page);
}
$GLOBALS['xoopsTpl']->assign('types', $type_vars);
@@ -150,6 +161,20 @@
$form->addElement($submitEl);
$GLOBALS['xoopsTpl']->assign('form', $form->render());
+// add formnav after adding form
+$limitEl->setClass("floatleft left");
+$formNav->addElement($limitEl);
+$sortEl->setExtra("onchange=\"document.forms.logsnav.submit()\"");
+$sortEl->setClass("floatleft left");
+$formNav->addElement($sortEl);
+$orderEl->setExtra("onchange=\"document.forms.logsnav.submit()\"");
+$orderEl->setClass("floatleft left");
+$formNav->addElement($orderEl);
+$submitEl = new XoopsFormButton('', 'submit()', _GO, 'submit');
+$submitEl->setClass("floatleft left");
+$formNav->addElement($submitEl);
+$GLOBALS['xoopsTpl']->assign('formNav', $formNav->render());
+
//headers
foreach($skips as $option) {
unset($headers[$option]);
Added: XoopsModules/userlog/trunk/userlog/class/form/index.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/form/index.html (rev 0)
+++ XoopsModules/userlog/trunk/userlog/class/form/index.html 2013-02-28 02:20:26 UTC (rev 11120)
@@ -0,0 +1 @@
+ <script>history.go(-1);</script>
\ No newline at end of file
Added: XoopsModules/userlog/trunk/userlog/class/form/simpleform.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/form/simpleform.php (rev 0)
+++ XoopsModules/userlog/trunk/userlog/class/form/simpleform.php 2013-02-28 02:20:26 UTC (rev 11120)
@@ -0,0 +1,51 @@
+<?php
+/**
+ * XOOPS simple form
+ *
+ * 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.
+ *
+ * @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 kernel
+ * @subpackage form
+ * @since 2.0.0
+ * @author Kazumi Ono (AKA onokazu) http://www.myweb.ne.jp/, http://jp.xoops.org/
+ * @version $Id: simpleform.php 8066 2011-11-06 05:09:33Z beckmi $
+ */
+
+defined('XOOPS_ROOT_PATH') or die('Restricted access');
+
+/**
+ * base class
+ */
+xoops_load('XoopsForm');
+
+/**
+ * Form that will output as a simple HTML form with minimum formatting
+ */
+class UserlogSimpleForm extends XoopsForm
+{
+ /**
+ * create HTML to output the form with minimal formatting
+ *
+ * @return string
+ */
+ function render()
+ {
+ $ret = $this->getTitle() . "\n<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n";
+ foreach ($this->getElements() as $ele) {
+ if (!$ele->isHidden()) {
+ $ret .= "<div class=\"" . $ele->getClass() . "\"><strong>" . $ele->getCaption() . "</strong>" . $ele->render() . "\n</div>";
+ } else {
+ $ret .= $ele->render() . "\n";
+ }
+ }
+ $ret .= "</form>\n";
+ return $ret;
+ }
+}
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/class/stats.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/stats.php 2013-02-27 21:09:27 UTC (rev 11119)
+++ XoopsModules/userlog/trunk/userlog/class/stats.php 2013-02-28 02:20:26 UTC (rev 11120)
@@ -96,13 +96,11 @@
case "set":
// total
$sets = $this->userlog->getHandler('setting')->getCount();
- if (empty($sets)) return false;
$this->update("set", 0, $sets);
break;
case "file":
$logext = "log";
$log_file_paths = array(XOOPS_VAR_PATH .'/'. USERLOG_DIRNAME,XOOPS_UPLOAD_PATH .'/'. USERLOG_DIRNAME);
-
$allFiles = 0;
$dirnum = 2; // assume 2 pathes are exist
foreach($log_file_paths as $log_file_path) {
@@ -169,7 +167,9 @@
public function update($type = 'log', $period = 0, $value = null, $increment = false, $link = '')
{
// if there is nothing to add to db
- if (empty($value) && empty($link)) return false;
+ if (empty($value) && !empty($increment)) return false;
+ // for file we should have a link
+ if ($type == "file" && empty($link)) return false;
$criteria = new CriteriaCompo();
$criteria->add(new Criteria('stats_type', $type), "AND");
$criteria->add(new Criteria('stats_period', $period), "AND");
Modified: XoopsModules/userlog/trunk/userlog/language/english/admin.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-02-27 21:09:27 UTC (rev 11119)
+++ XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-02-28 02:20:26 UTC (rev 11120)
@@ -33,8 +33,8 @@
define("_AM_USERLOG_LOG_TIME_DSC","Time of log record");
define("_AM_USERLOG_UID","User id");
define("_AM_USERLOG_UID_DSC","User id number");
-define("_AM_USERLOG_ADMIN","isAdmin?(y/n)");
-define("_AM_USERLOG_ADMIN_DSC","true if user is admin in this area");
+define("_AM_USERLOG_ADMIN","is Admin?(y/n)");
+define("_AM_USERLOG_ADMIN_DSC","true if user is admin in all or any section of your website that have been logged. eg: webmasters, moderator in forums");
define("_AM_USERLOG_GROUPS","Groups");
define("_AM_USERLOG_GROUPS_DSC","All Groups");
define("_AM_USERLOG_UNAME","Username");
@@ -71,15 +71,15 @@
define("_AM_USERLOG_SET_NAME","Setting name");
define("_AM_USERLOG_SET_NAME_DSC","Type a name for this setting in your own language");
define("_AM_USERLOG_SET_LOGBY","Log by");
-define("_AM_USERLOG_SET_LOGBY_DSC","Log user activities by fetching? priority: IF exist uid log it ELSEIF exist gid log it ELSEIf exist ip log it");
+define("_AM_USERLOG_SET_LOGBY_DSC","Log user activities by fetching this value from users table in database? priority: IF exist uid log it ELSEIF exist gid log it ELSEIf exist ip log it ELSE if Unique id = 0 log all users ELSE dont log");
define("_AM_USERLOG_SET_UNIQUE_ID","Unique id");
define("_AM_USERLOG_SET_UNIQUE_ID_DSC","Unique id (eg: uid=1, gid=3 (anonymous), ip=66.249.66.1) 0=all users");
define("_AM_USERLOG_SET_GID","Group id");
define("_AM_USERLOG_SET_IP","Visitor ip");
define("_AM_USERLOG_SET_OPTIONS","options");
-define("_AM_USERLOG_SET_OPTIONS_DSC","Log which user/page data? Note: no option means all options. no store option (File and/or Database) means Database. select views means store uid, groups, script name, pagetitle, module, item name, item id in Database");
+define("_AM_USERLOG_SET_OPTIONS_DSC","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, module, item name, item id in Database");
define("_AM_USERLOG_SET_SCOPE","Log scope");
-define("_AM_USERLOG_SET_SCOPE_DSC","Log users activities in which modules? select nothing means whole website");
+define("_AM_USERLOG_SET_SCOPE_DSC","Log users activities in which modules? Select nothing means whole website");
// setting.php add/edit
define("_AM_USERLOG_SET_ERROR","Error. You input a wrong data!");
@@ -157,7 +157,7 @@
// END DO NOT TOUCH
// logs.php error
-define("_AM_USERLOG_LOG_ERROR","No Log is found in database.");
+define("_AM_USERLOG_LOG_ERROR","No Log is found in database with this criteria.");
define("_AM_USERLOG_LOG_STATUS","%s\1 logs are found.");
define("_AM_USERLOG_LOG_PAGE","Pages");
Modified: XoopsModules/userlog/trunk/userlog/language/english/help/help.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-02-27 21:09:27 UTC (rev 11119)
+++ XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-02-28 02:20:26 UTC (rev 11120)
@@ -2,10 +2,11 @@
<h1 class="head">Help: <a class="ui-corner-all tooltip" href="<{$xoops_url}>/modules/userlog/admin/index.php" title="Back to the administration of Userlog"> Userlog <img src="<{xoAdminIcons home.png}>" alt="Back to the administration of Userlog"/></a></h1>
<h4 class="odd">Description</h4>
<p class="even">
-Userlog is a node logger which can log your user/visitor activities in your site.
-This is a very useful tool for webmasters in busy sites. for example you can log your other admins navigation.
-current nodes for logging are: user id, user group and visitor ip.
-You can store logs in database, in file or both.
+Userlog is a node logger which can log your user/visitor activities in your site.<br />
+This is a very useful tool for webmasters in busy sites. for example you can log your other admins navigation.<br />
+Current nodes for logging are: user id, user group and visitor ip.<br />
+You can store logs in database, in file or both.<br /><br />
+<b>Attention: userlog module will only work in admin part of modules use the moduleadmin class.</b><br /><br />
</p>
<h4 class="odd">Userlog preferences</h4>
After installtion we strongly recommend you to go to preferences.<br /><br />
@@ -36,7 +37,7 @@
<b>Setting Unique id</b>: here you must choose one unique id (node id) to be logged.<br />
(eg: uid=1, gid=3 (anonymous), ip=66.249.66.1) enter 0 means all users.<br />
<br />
-<b>Setting options:</b> you can select which user or page data you want to be logged. Also here you can choose 3 settings. store in file? store in db? and log user views?<br />
+<b>Setting options:</b> you can select which user or page data you want to be logged. Also here you can choose 3 settings. store in file? store in database? and log user views?<br />
select log user views means store uid, groups, script name, pagetitle, module, item name, item id in Database.<br />
<br />
<b>Setting scope:</b> if you want to log users activities in some specific module here you can do it.<br />
Modified: XoopsModules/userlog/trunk/userlog/language/english/modinfo.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/modinfo.php 2013-02-27 21:09:27 UTC (rev 11119)
+++ XoopsModules/userlog/trunk/userlog/language/english/modinfo.php 2013-02-28 02:20:26 UTC (rev 11120)
@@ -27,20 +27,20 @@
// configs
// config logfile
-define("_MI_USERLOG_CONFCAT_LOGFILE","Log file (Set if you need to store logs in file otherwise foget it)");
+define("_MI_USERLOG_CONFCAT_LOGFILE","Log file (Set if you need to store logs in file otherwise forget it)");
define("_MI_USERLOG_CONFCAT_LOGFILE_DSC","Preferences for log file");
define("_MI_USERLOG_CONFCAT_FORMAT","Format");
define("_MI_USERLOG_CONFCAT_FORMAT_DSC","Preferences for format");
define("_MI_USERLOG_CONFCAT_PAGENAV","Page navigation");
define("_MI_USERLOG_CONFCAT_PAGENAV_DSC","Preferences for page navigation");
-define("_MI_USERLOG_CONFCAT_LOGDB","Log database (Set if you need to store logs in database otherwise foget it)");
+define("_MI_USERLOG_CONFCAT_LOGDB","Log database (Set if you need to store logs in database otherwise forget it)");
define("_MI_USERLOG_CONFCAT_LOGDB_DSC","Preferences for Log database");
define("_MI_USERLOG_MAXLOGFILESIZE","Maximum file size for current working log file (in bytes)");
define("_MI_USERLOG_MAXLOGFILESIZE_DSC","Advise: Set it below 1MB because some servers set limitations for viewing large files in Cpanel.");
define("_MI_USERLOG_LOGFILEPATH","Log file full path");
define("_MI_USERLOG_LOGFILEPATH_DSC","Advise: a path outside wwwroot is safe from browsing by everybody");
define("_MI_USERLOG_LOGFILENAME","Current working Log file name");
-define("_MI_USERLOG_LOGFILENAME_DSC","Older log files will be stored with this prefix. Log_file_name_date('Y-m-d_H-i-s').log");
+define("_MI_USERLOG_LOGFILENAME_DSC","Older log files will be stored with this prefix: Log_file_name_date('Y-m-d_H-i-s').log");
// config format
define("_MI_USERLOG_DATEFORMAT","Date format");
define("_MI_USERLOG_DATEFORMAT_DSC","If you leave it empty, this module will use Core default");
@@ -50,10 +50,10 @@
define("_MI_USERLOG_LOGS_PERPAGE","Number of logs per page");
define("_MI_USERLOG_LOGS_PERPAGE_DSC","The default value for viewing logs");
// config logdb
-define("_MI_USERLOG_MAXLOGS","Maximum logs stored in db");
-define("_MI_USERLOG_MAXLOGS_DSC","logs will be deleted from db after this number");
-define("_MI_USERLOG_MAXLOGSPERIOD","Maximum period that logs stored in db. 0 = store forever");
-define("_MI_USERLOG_MAXLOGSPERIOD_DSC","logs older than this period will be deleted from database. Positive for days and negative for hours. advise: use a high number");
+define("_MI_USERLOG_MAXLOGS","Maximum logs stored in database");
+define("_MI_USERLOG_MAXLOGS_DSC","logs will be deleted from database after this number");
+define("_MI_USERLOG_MAXLOGSPERIOD","Maximum period that logs stored in database. 0 = store forever");
+define("_MI_USERLOG_MAXLOGSPERIOD_DSC","logs older than this period will be deleted from database. Positive for days and negative for hours. Advise: use a high number");
// blocks
define("_MI_USERLOG_BLOCK_VIEWS","All views in site");
Modified: XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-02-27 21:09:27 UTC (rev 11119)
+++ XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-02-28 02:20:26 UTC (rev 11120)
@@ -1,8 +1,15 @@
-<{if $logs}>
<div class="odd border x-small">
-<{$status}> <{$pages}> <{$smarty.const._AM_USERLOG_LOG_PAGE}>.
-<{$smarty.const._AM_USERLOG_SORT}>:<{$sortentry}> <{$smarty.const._AM_USERLOG_ORDER}>:<{$orderentry}>
+<div class="floatleft left">
+ <{if $logs}>
+ <{$status}> <{$pages}> <{$smarty.const._AM_USERLOG_LOG_PAGE}>
+ <{else}>
+ <{$smarty.const._AM_USERLOG_LOG_ERROR}>
+ <{/if}>
</div>
+<div class="floatright left"><{$formNav}></div>
+<div class="clear"></div>
+</div>
+<{if $options}>
<div class="even border x-small">
<{foreach item=val key=op from=$options}>
<{assign var=header value=$op|replace:'GT':''|replace:'LT':''}>
@@ -10,12 +17,14 @@
<{$headers.$header}><{$tt}>=<b><{$val}></b><br/>
<{/foreach}>
</div>
+<{/if}>
+<{if $logs}>
<{assign var=widthC value=5}>
<div class="outer">
- <div class="head border xx-small">
+ <div class="head boxshadow1 border xx-small">
<{foreach item=title key=header from=$headers}>
<div title="<{$title}>" class="width<{if $header == "admin" || $header == "log_id" || $header == "uid"}>1<{else}><{$widthC}><{/if}> floatleft center" style="height: 15px; overflow: hidden;">
- <a title="<{$title}>" href="logs.php?sortentry=<{$header}>&<{$query_page}>" alt="<{$title}>"><{$title}></a>
+ <a class="ui-corner-all tooltip" title="<{$title}>" href="logs.php?limitentry=<{$limitentry}>&sortentry=<{$header}><{if $query_page}>&<{$query_page}><{/if}><{if $sortentry eq $header}>&orderentry=<{if $orderentry eq 'DESC'}>ASC<{else}>DESC<{/if}><{/if}> " alt="<{$title}>"><{if $sortentry eq $header}><img src="<{if $orderentry eq 'DESC'}><{xoModuleIcons16 DESC.png}><{else}><{xoModuleIcons16 ASC.png}><{/if}>"/><{/if}><{$title}></a>
</div>
<{/foreach}>
<div class="clear"></div>
@@ -29,8 +38,6 @@
</div>
<{/foreach}>
</div>
-<{else}>
- <{$smarty.const._AM_USERLOG_LOG_ERROR}>
<{/if}>
<{$pagenav}>
<{$form}>
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/xoops_version.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-02-27 21:09:27 UTC (rev 11119)
+++ XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-02-28 02:20:26 UTC (rev 11120)
@@ -27,7 +27,7 @@
$modversion['version'] = '1';
$modversion['author'] = 'xoops.org (irmtfan)';
$modversion['nickname'] = 'irmtfan';
-$modversion['credits'] = 'The XOOPS Project Team, trabis, irmtfan';
+$modversion['credits'] = 'The XOOPS Project Team, trabis, irmtfan, mamba, tatane, Cesag';
$modversion['license'] = 'GNU GPL 2.0';
$modversion['license_url'] = 'www.gnu.org/licenses/gpl-2.0.html/';
$modversion['official'] = 0;
|
|
From: <ir...@us...> - 2013-03-02 12:45:49
|
Revision: 11142
http://sourceforge.net/p/xoops/svn/11142
Author: irmtfan
Date: 2013-03-02 12:45:45 +0000 (Sat, 02 Mar 2013)
Log Message:
-----------
add webmaster permission from file to avoid all webmasters to access
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/index.php
XoopsModules/userlog/trunk/userlog/admin/logs.php
XoopsModules/userlog/trunk/userlog/admin/setting.php
XoopsModules/userlog/trunk/userlog/class/form/simpleform.php
XoopsModules/userlog/trunk/userlog/class/log.php
XoopsModules/userlog/trunk/userlog/class/setting.php
XoopsModules/userlog/trunk/userlog/class/stats.php
XoopsModules/userlog/trunk/userlog/class/userlog.php
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/include/log.php
XoopsModules/userlog/trunk/userlog/language/english/admin.php
XoopsModules/userlog/trunk/userlog/language/english/blocks.php
XoopsModules/userlog/trunk/userlog/language/english/modinfo.php
XoopsModules/userlog/trunk/userlog/sql/mysql.sql
XoopsModules/userlog/trunk/userlog/xoops_version.php
Added Paths:
-----------
XoopsModules/userlog/trunk/userlog/admin/addon/
XoopsModules/userlog/trunk/userlog/admin/addon/index.html
XoopsModules/userlog/trunk/userlog/admin/addon/perm.php
Added: XoopsModules/userlog/trunk/userlog/admin/addon/index.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/addon/index.html (rev 0)
+++ XoopsModules/userlog/trunk/userlog/admin/addon/index.html 2013-03-02 12:45:45 UTC (rev 11142)
@@ -0,0 +1 @@
+ <script>history.go(-1);</script>
\ No newline at end of file
Added: XoopsModules/userlog/trunk/userlog/admin/addon/perm.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/addon/perm.php (rev 0)
+++ XoopsModules/userlog/trunk/userlog/admin/addon/perm.php 2013-03-02 12:45:45 UTC (rev 11142)
@@ -0,0 +1,40 @@
+<?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 (ir...@ya...)
+ * @author The XOOPS Project <www.xoops.org> <www.xoops.ir>
+ * @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;
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/admin/index.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/index.php 2013-03-02 10:37:52 UTC (rev 11141)
+++ XoopsModules/userlog/trunk/userlog/admin/index.php 2013-03-02 12:45:45 UTC (rev 11142)
@@ -39,24 +39,24 @@
if ($stats["set"][0]["value"] == 0) {
$indexAdmin->addItemButton(_AM_USERLOG_SET_ADD,"setting.php");
} else {
- $indexAdmin->addInfoBox(_AM_USERLOG_STATS_ABSTRACT);
- $periods = array_flip($statsObj->_period);
- $types = $statsObj->_type;
- foreach($stats as $type=>$arr) {
- if(strlen($type) > 10) continue;
- foreach($arr as $period=>$arr2) {
- // use sprintf in moduleadmin: sprintf($text, "<span style='color : " . $color . "; font-weight : bold;'>" . $value . "</span>")
- $indexAdmin->addInfoBoxLine(_AM_USERLOG_STATS_ABSTRACT,
- sprintf(_AM_USERLOG_STATS_TYPE_PERIOD, "%s\1", $types[$type], constant("_AM_USERLOG_" . strtoupper($periods[$period]))),
- $arr2["value"],
- $arr2["value"] ? 'GREEN' : 'RED');
- }
- }
$indexAdmin->addInfoBox(_AM_USERLOG_SUMMARY);
$indexAdmin->addInfoBoxLine(_AM_USERLOG_SUMMARY,'<a href="logs.php?options[referer]=del&options[request_method]=POST">' . _AM_USERLOG_SUMMARY_DELETED . '</a>');
$indexAdmin->addInfoBoxLine(_AM_USERLOG_SUMMARY,'<a href="logs.php?options[admin]=1">' . _AM_USERLOG_SUMMARY_ADMIN . '</a>');
$indexAdmin->addInfoBoxLine(_AM_USERLOG_SUMMARY,'<a href="logs.php?options[referer]=google.com">' . _AM_USERLOG_SUMMARY_GOOGLE . '</a>');
}
+$indexAdmin->addInfoBox(_AM_USERLOG_STATS_ABSTRACT);
+$periods = array_flip($statsObj->_period);
+$types = $statsObj->_type;
+foreach($stats as $type=>$arr) {
+ if(strlen($type) > 10) continue;
+ foreach($arr as $period=>$arr2) {
+ // use sprintf in moduleadmin: sprintf($text, "<span style='color : " . $color . "; font-weight : bold;'>" . $value . "</span>")
+ $indexAdmin->addInfoBoxLine(_AM_USERLOG_STATS_ABSTRACT,
+ sprintf(_AM_USERLOG_STATS_TYPE_PERIOD, "%s\1", $types[$type], constant("_AM_USERLOG_" . strtoupper($periods[$period]))),
+ $arr2["value"],
+ $arr2["value"] ? 'GREEN' : 'RED');
+ }
+}
$indexAdmin->addConfigBoxLine($Userlog->getConfig('logfilepath') , 'folder');
echo $indexAdmin->addNavigation('index.php');
echo $indexAdmin->renderButton();
Modified: XoopsModules/userlog/trunk/userlog/admin/logs.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-03-02 10:37:52 UTC (rev 11141)
+++ XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-03-02 12:45:45 UTC (rev 11142)
@@ -141,7 +141,7 @@
$GLOBALS['xoopsTpl']->assign('types', $type_vars);
// form
-list($form, $headers) =$logsetObj->logForm($options);
+list($form, $els, $headers) =$logsetObj->logForm($options);
$limitEl = new XoopsFormText(_AM_USERLOG_LOGS_PERPAGE, "limitentry", 10, 255, $limitentry);
$limitEl->setDescription(sprintf(_AM_USERLOG_LOGS_PERPAGE_DSC, $Userlog->getConfig("logs_perpage")));
Modified: XoopsModules/userlog/trunk/userlog/admin/setting.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/setting.php 2013-03-02 10:37:52 UTC (rev 11141)
+++ XoopsModules/userlog/trunk/userlog/admin/setting.php 2013-03-02 12:45:45 UTC (rev 11142)
@@ -30,7 +30,6 @@
// Where do we start ?
$set_id = UserlogRequest::getInt('set_id',0);
$logsetObj = $set_id ? $Userlog->getHandler('setting')->get($set_id) : UserlogSetting::getInstance();
-$logsetObj->cleanCache(); // delete all settings caches
if ($set_id && !is_object($logsetObj)) {
redirect_header("setting.php", 1, _AM_USERLOG_SET_ERROR);
}
@@ -55,11 +54,15 @@
}
$confirm = UserlogRequest::getString('confirm',0,"post");
if ($confirm) {
+ if ($logsetObj->deleteFile($logsetObj->logby(),$logsetObj->getVar('unique_id'))) { //use getVar to get IP long
+ $msgDel = _AM_USERLOG_SET_CLEANCACHE_SUCCESS;
+ }
if (!$Userlog->getHandler('setting')->delete($logsetObj)) {
redirect_header("setting.php", 1, sprintf(_AM_USERLOG_SET_DELETE_ERROR, $logsetObj->name()));
exit();
}
- redirect_header("setting.php", 1, sprintf(_AM_USERLOG_SET_DELETE_SUCCESS, $logsetObj->name()));
+ $msgDel .= "<br/>" . sprintf(_AM_USERLOG_SET_DELETE_SUCCESS, $logsetObj->name());
+ redirect_header("setting.php", 1, $msgDel);
exit();
} else {
xoops_confirm(array('op' => 'del', 'set_id' => $logsetObj->set_id(), 'confirm' => 1), 'setting.php', sprintf(_AM_USERLOG_SET_DELETE_CONFIRM, $logsetObj->name()), _DELETE);
@@ -99,13 +102,22 @@
$options_arr = $logsetObj->getOptions($option,"key");// empty means all. sanitize options
$logsetObj->setVar("options",implode(",",$options_arr));
$logsetObj->setVar("scope",implode(",",$scope));
- $logsetObj->set(true);
+ if ($logsetObj->storeSet(true)) {
+ $message .= "<br/>" . _AM_USERLOG_SET_CACHE;
+ }
redirect_header("setting.php", 1, sprintf($message, $logsetObj->name()));
break;
case "cancel":
redirect_header("setting.php", 1, _AM_USERLOG_SET_CANCEL);
exit();
-
+ case "cleanCash":
+ // delete all settings caches
+ if ($numfiles = $logsetObj->cleanCache()) {
+ redirect_header("setting.php", 1, sprintf(_AM_USERLOG_SET_CLEANCACHE_SUCCESS, $numfiles));
+ } else {
+ redirect_header("setting.php", 1,_AM_USERLOG_SET_CLEANCACHE_NOFILE);
+ }
+ break;
case "default":
default:
// get all dirnames for scope
@@ -147,13 +159,18 @@
}
$sets[$id]["scope"] = $dir_str;
}
+ // buttons
+ $indexAdmin = new ModuleAdmin();
+ if ($totalSets > 0) {
+ $indexAdmin->addItemButton(_AM_USERLOG_SET_CLEANCACHE_ALL, "setting.php?op=cleanCash", "delete");
+ }
+ if ($set_id) { // if in edit mode add a button
+ $indexAdmin->addItemButton(_AM_USERLOG_SET_ADD,"setting.php");
+ }
+ // template
$template_main = "userlog_admin_sets.html";
// form
$form = new XoopsThemeForm($set_id ? _EDIT . " " . $logsetObj->name() : _AM_USERLOG_SET_ADD,'setting','setting.php?op=addsetting', 'post');
- if ($set_id) { // if in edit mode add a button
- $indexAdmin = new ModuleAdmin();
- $indexAdmin->addItemButton(_AM_USERLOG_SET_ADD,"setting.php");
- }
$nameEle = new XoopsFormText(_AM_USERLOG_SET_NAME,"name",10,20, $logsetObj->name());
$nameEle->setDescription(_AM_USERLOG_SET_NAME_DSC);
Modified: XoopsModules/userlog/trunk/userlog/class/form/simpleform.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/form/simpleform.php 2013-03-02 10:37:52 UTC (rev 11141)
+++ XoopsModules/userlog/trunk/userlog/class/form/simpleform.php 2013-03-02 12:45:45 UTC (rev 11142)
@@ -37,10 +37,10 @@
*/
function render()
{
- $ret = $this->getTitle() . "\n<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n";
+ $ret = $this->getTitle() . "<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n";
foreach ($this->getElements() as $ele) {
if (!$ele->isHidden()) {
- $ret .= "<div class=\"" . $ele->getClass() . "\"><strong>" . $ele->getCaption() . "</strong>" . $ele->render() . "\n</div>";
+ $ret .= "<div class=\"" . $ele->getClass() . "\"><strong>" . $ele->getCaption() . "</strong>" . $ele->render() . "</div>";
} else {
$ret .= $ele->render() . "\n";
}
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-02 10:37:52 UTC (rev 11141)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-02 12:45:45 UTC (rev 11142)
@@ -30,7 +30,7 @@
*/
public $userlog = null;
- var $_store = 0; // store: 0,1->db 2->file 3->both
+ public $_store = 0; // store: 0,1->db 2->file 3->both
/**
* constructor
Modified: XoopsModules/userlog/trunk/userlog/class/setting.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/setting.php 2013-03-02 10:37:52 UTC (rev 11141)
+++ XoopsModules/userlog/trunk/userlog/class/setting.php 2013-03-02 12:45:45 UTC (rev 11142)
@@ -31,7 +31,7 @@
/**
* @var string
*/
- var $all_logby = array("uid"=>_AM_USERLOG_UID,"gid"=>_AM_USERLOG_SET_GID,"ip"=>_AM_USERLOG_SET_IP);
+ public $all_logby = array("uid"=>_AM_USERLOG_UID,"gid"=>_AM_USERLOG_SET_GID,"ip"=>_AM_USERLOG_SET_IP);
public $userlog = null;
@@ -73,13 +73,15 @@
if ($this->getVar("logby") == "ip") return long2ip($this->getVar('unique_id'));
return $this->getVar('unique_id');
}
- public function set($force = true)
+ public function storeSet($force = true)
{
- $this->setDb(true);
- // use $this->getVar('unique_id') (int ip) instead of $this->unique_id() (string ip)
- $this->setFile($this->logby(), $this->getVar('unique_id'), array($this->options(), $this->scope()));
+ if($this->setDb(true)) {
+ // use $this->getVar('unique_id') (int ip) instead of $this->unique_id() (string ip)
+ if($this->setFile($this->logby(), $this->getVar('unique_id'), array($this->options(), $this->scope()))) return true;
+ }
+ return false;
}
- public function get()
+ public function getSet()
{
// if uid setting exist in File
$unique_uid = ($this->userlog->getUser()) ? $this->userlog->getUser()->getVar('uid') : 0;
@@ -104,6 +106,8 @@
return $options;
}
///////////////////////////////////////////////////////////
+ // check probability
+ if(!$this->userlog->probCheck($this->userlog->getConfig("probset"))) return false;
// database get All is better for performance???
$logsetsObj = $this->userlog->getHandler('setting')->getAll();
if (empty($logsetsObj)) return false; // if not set in db return false
@@ -148,14 +152,16 @@
public function setFile($logby = "uid", $unique_id, $options)
{
- if(!is_array($options)) $options = explode(",",$options);
return $this->_createCacheFile($options, "setting_{$logby}_{$unique_id}");
}
public function getFile($logby = "uid", $unique_id)
{
return $this->_loadCacheFile("setting_{$logby}_{$unique_id}");
}
-
+ public function deleteFile($logby = "uid", $unique_id)
+ {
+ return $this->_deleteCacheFile("setting_{$logby}_{$unique_id}");
+ }
private function _createCacheFile($data, $name = null, $root_path = XOOPS_CACHE_PATH)
{
$name = ($name) ? $name : strval(time());
@@ -169,6 +175,12 @@
$key = USERLOG_DIRNAME ."_{$name}";
return XoopsCache::read($key);
}
+ private function _deleteCacheFile($name = null, $root_path = XOOPS_CACHE_PATH)
+ {
+ if (empty($name)) return false;
+ $key = USERLOG_DIRNAME ."_{$name}";
+ return XoopsCache::delete($key);
+ }
public function getOptions($option = null, $V = "value")
{
$V = strtolower($V);
@@ -334,14 +346,14 @@
}
}
}
- return array($form,$headers);
+ return array($form,$el,$headers);
}
function cleanCache() {
$files = glob(XOOPS_VAR_PATH.'/caches/xoops_cache/*' . USERLOG_DIRNAME . '*.*');
foreach ($files as $filename) {
unlink($filename);
}
- return true;
+ return count($files);
}
}
Modified: XoopsModules/userlog/trunk/userlog/class/stats.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/stats.php 2013-03-02 10:37:52 UTC (rev 11141)
+++ XoopsModules/userlog/trunk/userlog/class/stats.php 2013-03-02 12:45:45 UTC (rev 11142)
@@ -31,8 +31,8 @@
* @var string
*/
public $userlog = null;
- var $_period = array("all" => 0, "today" => 1, "week" => 7, "month" => 30);
- var $_type = array("log" => _AM_USERLOG_STATS_LOG,
+ public $_period = array("all" => 0, "today" => 1, "week" => 7, "month" => 30);
+ public $_type = array("log" => _AM_USERLOG_STATS_LOG,
"logdel" => _AM_USERLOG_STATS_LOGDEL,
"set" => _AM_USERLOG_STATS_SET,
"file" => _AM_USERLOG_STATS_FILE,
@@ -89,9 +89,7 @@
public function updateAll($type="log", $prob = 11)
{
- mt_srand((double)microtime()*1000000);
- // check probabillity 11 means 10%, 100 means 100%
- if (mt_rand(1, 100) > $prob) return false;
+ if(!$this->userlog->probCheck($prob)) return false;
switch ($type) {
case "set":
// total
@@ -102,11 +100,9 @@
$logext = "log";
$log_file_paths = array(XOOPS_VAR_PATH .'/'. USERLOG_DIRNAME,XOOPS_UPLOAD_PATH .'/'. USERLOG_DIRNAME);
$allFiles = 0;
- $dirnum = 2; // assume 2 pathes are exist
foreach($log_file_paths as $log_file_path) {
$log_file = $log_file_path . '/' . $this->userlog->getConfig('logfilename').".".$logext;
if (!is_dir($log_file_path)) {
- $dirnum -= 1;
continue;
}
$files = glob($log_file_path . '/*.' . $logext);
@@ -114,7 +110,7 @@
$this->update("file" ,0 ,count($files) ,false ,$log_file); // update working file in 2 pathes
}
// update all files in db link='all'
- $this->update("file" ,0 ,$allFiles ,false ,$dirnum ? 'all' : '');
+ $this->update("file" ,0 ,$allFiles ,false ,'all');
break;
case "views":
break;
Modified: XoopsModules/userlog/trunk/userlog/class/userlog.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-03-02 10:37:52 UTC (rev 11141)
+++ XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-03-02 12:45:45 UTC (rev 11142)
@@ -23,14 +23,14 @@
class Userlog
{
- var $dirname;
- var $module;
- var $logmodule;
- var $user;
- var $handler;
- var $config;
- var $debug;
- var $debugArray = array();
+ public $dirname;
+ public $module;
+ public $logmodule;
+ public $user;
+ public $handler;
+ public $config;
+ public $debug;
+ public $debugArray = array();
protected function __construct($debug)
{
@@ -134,6 +134,14 @@
xoops_load('XoopsLocal');
return XoopsLocal::formatTimestamp($intTime, $dateFormat, $timeoffset);
}
+ public function probCheck($prob = 11)
+ {
+ mt_srand((double)microtime()*1000000);
+ // check probabillity 11 means 10%, 100 means 100%
+ if (mt_rand(1, 100) > $prob) return false;
+ return true;
+ }
+
private function initModule()
{
global $xoopsModule;
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-02 10:37:52 UTC (rev 11141)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-02 12:45:45 UTC (rev 11142)
@@ -1,2 +1,6 @@
Userlog
Changelog:
+- add webmaster permission from file to avoid other webmasters to access.(2013/03/02)
+- add probabilities to preferences for sets and stats.(previously hardcoded)(2013/03/02)
+- add delete/create cache setting files messages.(previously hardcoded)(2013/03/02)
+
Modified: XoopsModules/userlog/trunk/userlog/include/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/include/log.php 2013-03-02 10:37:52 UTC (rev 11141)
+++ XoopsModules/userlog/trunk/userlog/include/log.php 2013-03-02 12:45:45 UTC (rev 11142)
@@ -29,7 +29,7 @@
$Userlog = Userlog::getInstance(false);
$logsetObj = UserlogSetting::getInstance();
$statsObj = UserlogStats::getInstance();
-list($setting, $scope) = $logsetObj->get();
+list($setting, $scope) = $logsetObj->getSet();
// if there is a setting
if (!empty($setting) ) {
@@ -70,7 +70,7 @@
// store log
$logObj->store($tolog, true);
// update all time stats
- $statsObj->updateAll("log", 10); // prob = 10
+ $statsObj->updateAll("log", $Userlog->getConfig("probstats")); // prob = 10
}
// update all time stats
-$statsObj->updateAll("log", 1); // prob = 1
\ No newline at end of file
+$statsObj->updateAll("log", $Userlog->getConfig("probstatsallhit")); // prob = 10
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/language/english/admin.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-02 10:37:52 UTC (rev 11141)
+++ XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-02 12:45:45 UTC (rev 11142)
@@ -48,7 +48,7 @@
define("_AM_USERLOG_SCRIPT_DSC","Script name e.g.:(in your homepage it is index.php)");
define("_AM_USERLOG_REFERER","Referer URI");
define("_AM_USERLOG_PAGETITLE","Page title");
-define("_AM_USERLOG_MODULE","Module dir name");
+define("_AM_USERLOG_MODULE","Module dirname");
define("_AM_USERLOG_ITEM_NAME","Item name");
define("_AM_USERLOG_ITEM_ID","Item ID");
define("_AM_USERLOG_REQUEST_METHOD","Request method (GET, POST, ...)");
@@ -83,43 +83,49 @@
// setting.php add/edit
define("_AM_USERLOG_SET_ERROR","Error. You've entered wrong data!");
-define("_AM_USERLOG_SET_CREATE","Setting %s\1 created successfully.");
-define("_AM_USERLOG_SET_EDIT","Setting %s\1 edited successfully.");
-define("_AM_USERLOG_SET_UPDATE","Setting %s\1 is in database and was updated successfully.");
+define("_AM_USERLOG_SET_CREATE","Setting %1\$s created successfully.");
+define("_AM_USERLOG_SET_EDIT","Setting %1\$s edited successfully.");
+define("_AM_USERLOG_SET_UPDATE","Caution! your new submitted setting is not created because setting %1\$s has been in database with the same Log by and Unique ID. But it updated with your new options successfully.");
define("_AM_USERLOG_SET_CANCEL","Cancel");
// setting.php delete
-define("_AM_USERLOG_SET_DELETE_CONFIRM","Are you sure to delete setting %s\1?");
-define("_AM_USERLOG_SET_DELETE_ERROR","Cannot delete setting %s\1");
-define("_AM_USERLOG_SET_DELETE_SUCCESS","Setting %s\1 deleted successfully.");
+define("_AM_USERLOG_SET_DELETE_CONFIRM","Are you sure to delete setting %1\$s?");
+define("_AM_USERLOG_SET_DELETE_ERROR","Cannot delete setting %1\$s");
+define("_AM_USERLOG_SET_DELETE_SUCCESS","Setting %1\$s deleted successfully.");
+// setting.php create/clean cache
+define("_AM_USERLOG_SET_CACHE","Appropriate cached setting file created/edited successfully.");
+define("_AM_USERLOG_SET_CLEANCACHE","Appropriate cached setting file deleted successfully.");
+define("_AM_USERLOG_SET_CLEANCACHE_ALL","Delete all cached setting files?");
+define("_AM_USERLOG_SET_CLEANCACHE_SUCCESS","%1\$d cached setting files deleted successfully.");
+define("_AM_USERLOG_SET_CLEANCACHE_NOFILE","No cached setting file is exist to delete.");
// logs.php form
define("_AM_USERLOG_LOGFORM","Enter data and push enter or click on submit button to show logs");
define("_AM_USERLOG_LOGS_PERPAGE","Number of logs per page");
-define("_AM_USERLOG_LOGS_PERPAGE_DSC","The default value is %s\1 defined in Preferences");
+define("_AM_USERLOG_LOGS_PERPAGE_DSC","The default value is %1\$s defined in Preferences");
define("_AM_USERLOG_SORT","Sort by");
define("_AM_USERLOG_SORT_DSC","Select one field to sort logs based on that field");
define("_AM_USERLOG_ORDER","Order by");
define("_AM_USERLOG_ORDER_DSC","Ascending or Descending order");
-define("_AM_USERLOG_LOG_ID_FORM","Enter one '%s\1' or several '%s\2's separated with comma to show logs based on that. eg: 23,32,12");
+define("_AM_USERLOG_LOG_ID_FORM","Enter one '%1\$s' or several '%2\$s's separated with comma to show logs based on that. eg: 23,32,12");
define("_AM_USERLOG_LOG_IDGT","Log id greater than");
-define("_AM_USERLOG_LOG_IDGT_FORM","Enter one '%s\1' to show all '%s\2's greater than it");
+define("_AM_USERLOG_LOG_IDGT_FORM","Enter one '%1\$s' to show all '%2\$s's greater than it");
define("_AM_USERLOG_LOG_IDLT","Log id lower than");
-define("_AM_USERLOG_LOG_IDLT_FORM","Enter one '%s\1' to show all '%s\2's lower than it");
+define("_AM_USERLOG_LOG_IDLT_FORM","Enter one '%1\$s' to show all '%2\$s's lower than it");
define("_AM_USERLOG_LOG_TIMEGT","Log time since");
define("_AM_USERLOG_LOG_TIMEGT_FORM","Enter Time of log record to show all logs since that time. Positive for days and negative for hours. eg: 1 means since one day ago");
define("_AM_USERLOG_LOG_TIMELT","Log time until");
define("_AM_USERLOG_LOG_TIMELT_FORM","Enter Time of log record to show all logs until that time. Positive for days and negative for hours. eg: 1 means until one day ago");
-define("_AM_USERLOG_UID_FORM","Enter one '%s\1' or several '%s\2's separated with comma to show logs based on that. eg: 23,32,12");
+define("_AM_USERLOG_UID_FORM","Enter one '%1\$s' or several '%2\$s's separated with comma to show logs based on that. eg: 23,32,12");
define("_AM_USERLOG_UIDGT","User id greater than");
-define("_AM_USERLOG_UIDGT_FORM","Enter one '%s\1' number to show all logs for all users with a '%s\2' greater than that");
+define("_AM_USERLOG_UIDGT_FORM","Enter one '%1\$s' number to show all logs for all users with a '%2\$s' greater than that");
define("_AM_USERLOG_UIDLT","User id lower than");
-define("_AM_USERLOG_UIDLT_FORM","Enter one '%s\1' number to show all logs for all users with a '%s\2' lower than that");
+define("_AM_USERLOG_UIDLT_FORM","Enter one '%1\$s' number to show all logs for all users with a '%2\$s' lower than that");
define("_AM_USERLOG_ADMIN_FORM","Enter 1 to show all logs from Admins");
define("_AM_USERLOG_GROUPS_FORM","Enter one group with 'g' prefix (or several groups separated with comma) to show logs for all users belonging to those groups. eg: g1,g2 means all users belonging to group 1 OR group 2");
@@ -131,7 +137,7 @@
define("_AM_USERLOG_LAST_LOGINLT_FORM","Enter Time of User Last Visit to show all logs until that time. Positive for days and negative for hours. eg: 1 means until one day ago");
// for all other text logs use just one definition
-define("_AM_USERLOG_TEXT_FORM","Enter one exact '%s\1' or part of '%s\2' to show all logs for users have that. you can enter several separated with comma. eg: TERM1, TERM2, TERM3");
+define("_AM_USERLOG_TEXT_FORM","Enter one exact '%1\$s' or part of '%2\$s' to show all logs for users have that. you can enter several separated with comma. eg: TERM1, TERM2, TERM3");
// Translators: do not touch below for now
// START DO NOT TOUCH
define("_AM_USERLOG_UNAME_FORM",_AM_USERLOG_TEXT_FORM);
@@ -158,7 +164,7 @@
// logs.php error
define("_AM_USERLOG_LOG_ERROR","No Log is found in database with this criteria.");
-define("_AM_USERLOG_LOG_STATUS","%s\1 logs are found.");
+define("_AM_USERLOG_LOG_STATUS","%1\$s logs are found.");
define("_AM_USERLOG_LOG_PAGE","Pages");
// views block
@@ -170,15 +176,15 @@
// index.php stats.php
define("_AM_USERLOG_STATS_ABSTRACT","Statistics Overview");
-define("_AM_USERLOG_STATS_TYPE_PERIOD","There are %s\1 %s\2 exist in %s\3");
-// %s\2 for above
+define("_AM_USERLOG_STATS_TYPE_PERIOD","There are %1\$s %2\$s exist in %3\$s");
+// %2\$s for above
define("_AM_USERLOG_STATS_LOG","Logs");
define("_AM_USERLOG_STATS_LOGDEL","Deleted logs");
define("_AM_USERLOG_STATS_SET","Sets");
define("_AM_USERLOG_STATS_FILE","Files");
define("_AM_USERLOG_STATS_FILEALL","Files in all paths");
define("_AM_USERLOG_STATS_VIEWS","Views");
-// %s\3 for above
+// %3\$s for above
define("_AM_USERLOG_ALL","All Times");
define("_AM_USERLOG_TODAY","Today");
define("_AM_USERLOG_WEEK","This week");
Modified: XoopsModules/userlog/trunk/userlog/language/english/blocks.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/blocks.php 2013-03-02 10:37:52 UTC (rev 11141)
+++ XoopsModules/userlog/trunk/userlog/language/english/blocks.php 2013-03-02 12:45:45 UTC (rev 11142)
@@ -24,4 +24,4 @@
define("_MB_USERLOG_BLOCK_ITEMS","Select items");
define("_MB_USERLOG_BLOCK_ITEMS_DSC","These are typical links of your active modules. Select at least one item.");
define("_MB_USERLOG_BLOCK_TIME","Time period");
-define("_MB_USERLOG_BLOCK_TIME_DSC","Time of Log record to count all logs since that time. Positive for days and negatives for hours");
\ No newline at end of file
+define("_MB_USERLOG_BLOCK_TIME_DSC","Time of Log record to count all logs since that time. Positive for days and negative for hours");
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/language/english/modinfo.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/modinfo.php 2013-03-02 10:37:52 UTC (rev 11141)
+++ XoopsModules/userlog/trunk/userlog/language/english/modinfo.php 2013-03-02 12:45:45 UTC (rev 11142)
@@ -35,6 +35,9 @@
define("_MI_USERLOG_CONFCAT_PAGENAV_DSC","Preferences for page navigation");
define("_MI_USERLOG_CONFCAT_LOGDB","Log database (Set it if you need to store logs in database, otherwise ignore it)");
define("_MI_USERLOG_CONFCAT_LOGDB_DSC","Preferences for Log database");
+define("_MI_USERLOG_CONFCAT_PROB","Probability to work on database.(These default numbers are recommended for a high traffic website. e.g.: more than 30,000 hits per day)");
+define("_MI_USERLOG_CONFCAT_PROB_DSC","Preferences for Probability");
+// config logfile
define("_MI_USERLOG_MAXLOGFILESIZE","Maximum file size for current working Log file (in bytes)");
define("_MI_USERLOG_MAXLOGFILESIZE_DSC","Advise: Set it below 1MB because some servers set limitations for viewing large files in CPanel.");
define("_MI_USERLOG_LOGFILEPATH","Log file full path");
@@ -54,7 +57,17 @@
define("_MI_USERLOG_MAXLOGS_DSC","Logs will be deleted from database after reaching this number");
define("_MI_USERLOG_MAXLOGSPERIOD","Maximum time that logs are stored in the database. 0 = store forever");
define("_MI_USERLOG_MAXLOGSPERIOD_DSC","Logs older than this period will be deleted from database. Positive for days and negative for hours. Advise: use a high number")...
[truncated message content] |
|
From: <ir...@us...> - 2013-03-04 05:36:34
|
Revision: 11149
http://sourceforge.net/p/xoops/svn/11149
Author: irmtfan
Date: 2013-03-04 05:36:27 +0000 (Mon, 04 Mar 2013)
Log Message:
-----------
add a complete file browsing engine can accept any file, criteria, pagination, sort,order
use json_encode for better performance
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/logs.php
XoopsModules/userlog/trunk/userlog/class/log.php
XoopsModules/userlog/trunk/userlog/class/stats.php
XoopsModules/userlog/trunk/userlog/class/userlog.php
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/include/log.php
XoopsModules/userlog/trunk/userlog/include/module.php
XoopsModules/userlog/trunk/userlog/language/english/admin.php
XoopsModules/userlog/trunk/userlog/language/english/help/help.html
XoopsModules/userlog/trunk/userlog/language/english/modinfo.php
XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
XoopsModules/userlog/trunk/userlog/xoops_version.php
Modified: XoopsModules/userlog/trunk/userlog/admin/logs.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-03-04 00:18:02 UTC (rev 11148)
+++ XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-03-04 05:36:27 UTC (rev 11149)
@@ -32,12 +32,14 @@
$orderentry = UserlogRequest::getString('orderentry','DESC');
$options = UserlogRequest::getArray("options");
+$engine = UserlogRequest::getString('engine',$Userlog->getConfig("engine"));
+$file = UserlogRequest::getArray('file', "all");
+
$logsetObj = UserlogSetting::getInstance();
// get var types int, text, bool , ...
$type_vars = $logsetObj->getOptions("", "type");
//$query_types = array("="=>"",">"=>"GT", "<"=>"LT");
$criteria = new CriteriaCompo();
-//$criteria->add(new Criteria(1, 1));
// formnav in the upper section
include_once USERLOG_ROOT_PATH . '/class/form/simpleform.php';
$formNav = new UserlogSimpleForm('','logsnav','logs.php', 'get');
@@ -97,9 +99,16 @@
$formNav->addElement($hidOptionsEl);
unset($hidOptionsEl);
}
-$logs = $Userlog->getHandler('log')->getLogs($limitentry,$startentry,$criteria,$sortentry,$orderentry ,null, false);
-$totalLogs = $Userlog->getHandler('log')->getLogsCount($criteria);
+// get logs from engine: 1- db 2- file
+$loglogObj = UserlogLog::getInstance();
+if( $engine == 'db' ) {
+ $logs = $Userlog->getHandler('log')->getLogs($limitentry,$startentry,$criteria,$sortentry,$orderentry ,null, false);
+ $totalLogs = $Userlog->getHandler('log')->getLogsCount($criteria);
+} else {
+ list($logs, $totalLogs) = $loglogObj->getLogsFromFiles($file, $limitentry, $startentry, $options, $sortentry,$orderentry);
+}
+// parse query page
if ( !empty($query_array) ) {
$query_page = implode("&", array_values($query_array));
}
@@ -121,18 +130,9 @@
$GLOBALS['xoopsTpl']->assign('orderentry', $orderentry);
$skips = array("get", "post", "request", "files", "env");
-// only times should be changed before assign to template
-foreach($logs as $log_id=>$log) {
- $logs[$log_id]["log_time"] = $Userlog->formatTime($logs[$log_id]["log_time"]);
- $logs[$log_id]["last_login"] = $Userlog->formatTime($logs[$log_id]["last_login"]);
- // merge all request_method to one column
- if (!empty($logs[$log_id]["request_method"])) {
- $logs[$log_id]["request_method"] = $logs[$log_id]["request_method"] . $logs[$log_id][strtolower($logs[$log_id]["request_method"])];
- }
- foreach($skips as $option) {
- unset($logs[$log_id][$option]);
- }
-}
+// prepared for display
+$logs = $loglogObj->ArrayToDisplay($logs, $skips);
+
// assign logs
$GLOBALS['xoopsTpl']->assign('logs', $logs);
if ( !empty($query_page) ) {
@@ -143,6 +143,12 @@
// form
list($form, $els, $headers) =$logsetObj->logForm($options);
+$engineEl = new XoopsFormSelect(_AM_USERLOG_ENGINE,"engine", $engine);
+$engineEl->addOption("db", _AM_USERLOG_ENGINE_DB);
+$engineEl->addOption("file", _AM_USERLOG_ENGINE_FILE);
+if ($engine == "file") {
+ $fileEl = $loglogObj->buildFileSelectEle($file);
+}
$limitEl = new XoopsFormText(_AM_USERLOG_LOGS_PERPAGE, "limitentry", 10, 255, $limitentry);
$limitEl->setDescription(sprintf(_AM_USERLOG_LOGS_PERPAGE_DSC, $Userlog->getConfig("logs_perpage")));
$sortEl = new XoopsFormSelect(_AM_USERLOG_SORT,"sortentry", $sortentry);
@@ -154,7 +160,11 @@
$orderEl->setDescription(_AM_USERLOG_ORDER_DSC);
$submitEl = new XoopsFormButton(_SUBMIT, 'submit', _SUBMIT, 'submit');
-
+
+$form->addElement($engineEl);
+if ($engine == "file") {
+ $form->addElement($fileEl);
+}
$form->addElement($limitEl);
$form->addElement($sortEl);
$form->addElement($orderEl);
@@ -162,6 +172,14 @@
$GLOBALS['xoopsTpl']->assign('form', $form->render());
// add formnav after adding form
+if ($engine == "file") {
+ $fileEl->setClass("floatleft left");
+ $fileEl->setExtra("onchange=\"document.forms.logsnav.submit()\"");
+ $formNav->addElement($fileEl);
+}
+$engineEl->setClass("floatleft left");
+$engineEl->setExtra("onchange=\"document.forms.logsnav.submit()\"");
+$formNav->addElement($engineEl);
$limitEl->setClass("floatleft left");
$formNav->addElement($limitEl);
$sortEl->setExtra("onchange=\"document.forms.logsnav.submit()\"");
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-04 00:18:02 UTC (rev 11148)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-04 05:36:27 UTC (rev 11149)
@@ -55,15 +55,15 @@
$this->initVar("item_name", XOBJ_DTYPE_TXTBOX, null, false, 10);
$this->initVar("item_id", XOBJ_DTYPE_INT, null, false);
$this->initVar("request_method", XOBJ_DTYPE_TXTBOX, null, false, 20);
- $this->initVar("get", XOBJ_DTYPE_TXTAREA, '', false);
- $this->initVar("post", XOBJ_DTYPE_TXTAREA, '', false);
- $this->initVar("request", XOBJ_DTYPE_TXTAREA, '', false);
- $this->initVar("files", XOBJ_DTYPE_TXTAREA, '', false);
- $this->initVar("env", XOBJ_DTYPE_TXTAREA, '', false);
- $this->initVar("session", XOBJ_DTYPE_TXTAREA, '', false);
- $this->initVar("cookie", XOBJ_DTYPE_TXTAREA, '', false);
- $this->initVar("header", XOBJ_DTYPE_TXTAREA, '', false);
- $this->initVar("logger", XOBJ_DTYPE_TXTAREA, '', false);
+ $this->initVar("get", XOBJ_DTYPE_SOURCE);
+ $this->initVar("post", XOBJ_DTYPE_SOURCE);
+ $this->initVar("request", XOBJ_DTYPE_SOURCE);
+ $this->initVar("files", XOBJ_DTYPE_SOURCE);
+ $this->initVar("env", XOBJ_DTYPE_SOURCE);
+ $this->initVar("session", XOBJ_DTYPE_SOURCE);
+ $this->initVar("cookie", XOBJ_DTYPE_SOURCE);
+ $this->initVar("header", XOBJ_DTYPE_SOURCE);
+ $this->initVar("logger", XOBJ_DTYPE_SOURCE);
}
/**
* @param string $method
@@ -110,9 +110,9 @@
{
// set vars
foreach ($tolog as $option=>$logvalue) {
- // value array to string
- if (is_array($logvalue)) $logvalue = $this->logString($logvalue);
if(!empty($logvalue)) {
+ // value array to string. use json_encode
+ if (is_array($logvalue) && count($logvalue) > 0) $logvalue = json_encode($logvalue);
$this->setVar($option, $logvalue);
}
}
@@ -121,6 +121,31 @@
return $ret;
}
+ public function ArrayToDisplay($logs, $skips)
+ {
+ foreach($logs as $log_id=>$log) {
+ $logs[$log_id]["log_time"] = $this->userlog->formatTime($logs[$log_id]["log_time"]);
+ $logs[$log_id]["last_login"] = $this->userlog->formatTime($logs[$log_id]["last_login"]);
+ foreach (array("session","cookie","header","logger") as $option){
+ // if value is not string it was decoded in file
+ if (!is_string($logs[$log_id][$option])) continue;
+ $logArr = json_decode($logs[$log_id][$option], true);
+ if($logArr) {
+ $logs[$log_id][$option] = var_export($logArr, true);
+ }
+ }
+ // merge all request_method to one column
+ if (!empty($logs[$log_id]["request_method"]) &&
+ !empty($logs[$log_id][strtolower($logs[$log_id]["request_method"])])) {
+ $logs[$log_id]["request_method"] = $logs[$log_id]["request_method"] . ' ' .$logs[$log_id][strtolower($logs[$log_id]["request_method"])];
+ }
+ foreach($skips as $option) {
+ unset($logs[$log_id][$option]);
+ }
+ }
+ return $logs;
+ }
+
public function storeFile($tolog)
{
$logext = "log";
@@ -134,26 +159,24 @@
return false;
}
}
- $data = "\nlog_id|" . /*$this->log_id()*/ "0" .$this->logString($tolog);
- if ($this->item_name() !== null ) {
- $data .= "\$item_name|" . $this->item_name() . "\$item_id|". $this->item_id(); // views save to file;
- }
// file create/open/write
$fileHandler = XoopsFile::getHandler();
+ $fileHandler->XoopsFileHandler($log_file, false);
// force to create file if not exist
- if ($fileHandler->XoopsFileHandler($log_file, false) == false) {
- if(!$fileHandler->exists()) {
- $fileHandler->XoopsFileHandler($log_file, true); // create file and folder
- $this->setErrors('File was not exist create file ({$log_file_name})');
- // update the new file in database
- $statsObj = UserlogStats::getInstance();
- $statsObj->update("file", 0, 0, false, $log_file); // value = 0 to not auto increment
- // update old file if exist
- if(!empty($old_file)) {
- $statsObj->update("file", 0, 0, false, $old_file); // value = 0 to not auto increment
- }
- $statsObj->updateAll("file", 100); // prob = 100
+ if(!$fileHandler->exists()) {
+ $fileHandler->XoopsFileHandler($log_file, true); // create file and folder
+ $this->setErrors('File was not exist create file ({$log_file_name})');
+ // update the new file in database
+ $statsObj = UserlogStats::getInstance();
+ $statsObj->update("file", 0, 0, false, $log_file); // value = 0 to not auto increment
+ // update old file if exist
+ if(!empty($old_file)) {
+ $statsObj->update("file", 0, 0, false, $old_file); // value = 0 to not auto increment
}
+ $statsObj->updateAll("file", 100); // prob = 100
+ $data = json_encode($tolog);
+ } else {
+ $data = "\n" . json_encode($tolog);
}
if ($fileHandler->open("a") == false) {
$this->setErrors('Cannot open file ({$log_file_name})');
@@ -166,55 +189,173 @@
$fileHandler->close();
return true;
}
- public function getFromFile($log_file = null)
+ public function getLogsFromFiles($log_file = null, $limit = 0, $start = 0, $options = null, $sort = "log_time", $order = "DESC")
{
+ $logs = array();
+ $logsStr = $this->readFiles($log_file);
+ foreach ($logsStr as $id=>$log) {
+ $logArr = json_decode($log, true);
+ // check if data is correct in file before do anything more
+ if (!is_array($logArr) || !array_key_exists("log_id", $logArr)) continue;
+ foreach ($logArr as $option=>$logvalue) {
+ // value array to string
+ $logs[$id][$option] = (is_array($logvalue) && count($logvalue) > 0) ? var_export($logvalue, true) : $logvalue;
+ }
+ }
+ // START Criteria in array
+ foreach($options as $key=>$val) {
+ // if user input an empty variable unset it
+ if (empty($val)) continue;
+ // deal with greater than and lower than
+ $tt = substr($key, -2);
+ switch ($tt) {
+ case "GT":
+ $op = substr($key,0, -2);
+ break;
+ case "LT":
+ $op = substr($key,0, -2);
+ break;
+ default:
+ $op = $key;
+ break;
+ }
+ $val_arr = explode(",", $val);
+ // if type is text
+ if (!empty($val_arr[0]) && intval($val_arr[0]) == 0) {
+ foreach ($logs as $id => $log) {
+ $flagStr = false;
+ foreach($val_arr as $qry) {
+ // if !QUERY eg: !logs.php,views.php
+ if (substr($qry,0,1) == "!") {
+ if(strpos($log[$op], substr($qry,1)) !== false) $flagStr = true;
+ } else {
+ if(strpos($log[$op], $qry) !== false) $flagStr = true;
+ }
+ }
+ if (!$flagStr) unset($logs[$id]);
+ }
+ } else {
+ // if there is one value - deal with =, > ,<
+ if (count($val_arr) == 1) {
+ $val_int = $val_arr[0];
+ if($op == "log_time" || $op == "last_login") $val_int = time() - $Userlog->getSinceTime($val_int);
+ // query is one int $t (=, < , >)
+ foreach ($logs as $id => $log) {
+ switch ($tt) {
+ case "GT":
+ if($log[$op] <= $val_int) unset($logs[$id]);
+ break;
+ case "LT":
+ if($log[$op] >= $val_int) unset($logs[$id]);
+ break;
+ default:
+ if($log[$op] != $val_int) unset($logs[$id]);
+ break;
+ }
+ }
+ } else {
+ // query is an array of int separate with comma. use OR ???
+ foreach ($logs as $id => $log) {
+ if(!in_array($log[$op], $val_arr)) unset($logs[$id]);
+ }
+ }
+ }
+ }
+ // END Criteria in array
+ // if no logs return empty array and total = 0
+ if(empty($logs)) return array(array(), 0);
+
+ // sort order array. multisort is possible :D
+ if (!empty($sort)) {
+ // log_id is just the same as log_time
+ if ($sort == "log_id") $sort = "log_time";
+ // $typeFlag = is_numeric($logs[0][$sort]) ? SORT_NUMERIC : SORT_STRING;
+ // Obtain a list of columns
+ foreach ($logs as $key => $log) {
+ $col[$key] = $log[$sort];
+ //$col2[$key] = $log[$sort2];
+ }
+ // Add $logs as the last parameter, to sort by the common key
+ array_multisort($col, ($order == "ASC") ? SORT_ASC : SORT_DESC, $logs);
+ }
+ // get count
+ $total = count($logs);
+ // now slice the array with desired start and limit
+ if (!empty($limit)) {
+ $logs = array_slice($logs,$start, $limit);
+ }
+ return array($logs, $total);
+ }
+ public function readFiles($log_files = array())
+ {
+ if(empty($log_files) || count($log_files) == 0) {
+ return $this->readFile();
+ }
+ $logs = array();
+ $pathParts = pathinfo($log_files[0]);
+ // if "all" or no extension => $path
+ if ($log_files[0] == "all" || empty($pathParts[extension])) {
+ list($allFiles,$totalFiles) = $this->userlog->getAllLogFiles();
+ if (empty($totalFiles)) return array();
+ foreach($allFiles as $path=>$files) {
+ foreach($files as $file) {
+ $logs = array_merge($logs,$this->readFile($path . "/" . $file));
+ }
+ // if it is $path
+ if ($log_files[0] != "all") {
+ if ($log_files[0] == $path) break; // exit for loop and return logs
+ $logs = array(); // reset logs for next path
+ }
+ }
+ return $logs;
+ }
+ foreach($log_files as $file) {
+ $logs = array_merge($logs,$this->readFile($file));
+ }
+ return $logs;
+ }
+
+ public function readFile($log_file = null)
+ {
if (!$log_file) {
$logext = "log";
$log_file_name = $this->userlog->getConfig('logfilepath') .'/'. USERLOG_DIRNAME . '/' . $this->userlog->getConfig('logfilename');
$log_file = $log_file_name.".".$logext;
}
- // file create/open/write
+ // file open/read
$fileHandler = XoopsFile::getHandler();
// not create file if not exist
- if ($fileHandler->XoopsFileHandler($log_file, false) == false) {
- $this->setErrors('Cannot create file ({$log_file_name})');
+ $fileHandler->XoopsFileHandler($log_file, false);
+ if (!$fileHandler->exists()) {
+ $this->setErrors('Cannot open file ({$log_file_name})');
return false;
}
+
if (($data = $fileHandler->read()) == false) {
$this->setErrors('Cannot read file ({$log_file_name})');
return false;
}
- return $data;
+ $logs = explode("\n",$data);
+ return $logs;
}
-
- // use ; because it will never used in other methods
- public function logString($data, $startDelimiter="\$" , $endDelimiter="" )
+ public function buildFileSelectEle($currentFile = null, $multi = false)
{
- static $depth = 0;
- $delimiters = array("<", ">","{","}","[[","]]");
- $ret = "";
- foreach ($data as $method=>$value)
- {
- if(!empty($value)) {
- $ret .= $startDelimiter . "{$method}";
- if (!$depth) { // if it is the first level
- $ret .= "|";
- } else {
- $ret .= ":";
- }
- if (is_array($value)) {
- $depth = $depth+2;
- $ret .= self::logString($value,$delimiters[$depth],$delimiters[$depth+1]);
- } else {
- $depth = 0;
- $ret .="{$value}";
- }
- $ret .= $endDelimiter;
+ $logext = "log";
+ list($allFiles,$totalFiles) = $this->userlog->getAllLogFiles();
+ if (empty($totalFiles)) return false;
+ $log_file_name = $this->userlog->getConfig('logfilename');
+ $working_file = $log_file_name.".".$logext;
+ $fileEl = new XoopsFormSelect(_AM_USERLOG_FILE,"file", $currentFile);
+ $fileEl->addOption("all", _AM_USERLOG_STATS_FILEALL);
+ foreach($allFiles as $path=>$files) {
+ $fileEl->addOption($path, ">" . $path);
+ foreach($files as $file) {
+ $fileEl->addOption($path . "/" . $file, "-----" . $file . (($file == $working_file) ? "(" ._AM_USERLOG_FILE_WORKING . ")" : ""));
}
}
- return $ret;
+ return $fileEl;
}
-
+
public function setItem()
{
$not_config =& $this->userlog->getLogModule()->getInfo('notification');
Modified: XoopsModules/userlog/trunk/userlog/class/stats.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/stats.php 2013-03-04 00:18:02 UTC (rev 11148)
+++ XoopsModules/userlog/trunk/userlog/class/stats.php 2013-03-04 05:36:27 UTC (rev 11149)
@@ -98,19 +98,13 @@
break;
case "file":
$logext = "log";
- $log_file_paths = array(XOOPS_VAR_PATH .'/'. USERLOG_DIRNAME,XOOPS_UPLOAD_PATH .'/'. USERLOG_DIRNAME);
- $allFiles = 0;
- foreach($log_file_paths as $log_file_path) {
- $log_file = $log_file_path . '/' . $this->userlog->getConfig('logfilename').".".$logext;
- if (!is_dir($log_file_path)) {
- continue;
- }
- $files = glob($log_file_path . '/*.' . $logext);
- $allFiles += count($files);
- $this->update("file" ,0 ,count($files) ,false ,$log_file); // update working file in 2 pathes
+ list($allFiles,$totalFiles) = $this->userlog->getAllLogFiles();
+ foreach($allFiles as $path=>$files) {
+ $log_file = $path . '/' . $this->userlog->getConfig('logfilename').".".$logext;
+ $this->update("file" ,0 ,count($files) ,false ,$log_file); // update working file in all paths (now 2)
}
// update all files in db link='all'
- $this->update("file" ,0 ,$allFiles ,false ,'all');
+ $this->update("file" ,0 ,$totalFiles ,false ,'all');
break;
case "views":
break;
Modified: XoopsModules/userlog/trunk/userlog/class/userlog.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-03-04 00:18:02 UTC (rev 11148)
+++ XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-03-04 05:36:27 UTC (rev 11149)
@@ -105,6 +105,22 @@
$this->addLog("Getting handler '{$name}'");
return $this->handler[$name . '_handler'];
}
+ public function getAllLogFiles()
+ {
+ $allConfigs = $this->module->getInfo('config');
+ $currentPath = $this->getConfig("logfilepath");
+ $logPaths = array_keys($allConfigs[2]["options"]);
+ $logext = "log";
+ $allFiles = array();
+ $totalFiles = 0;
+ foreach($logPaths as $path) {
+ $folderHandler = XoopsFile::getHandler("folder",$path . "/" . USERLOG_DIRNAME);
+ $allFiles[$path . "/" . USERLOG_DIRNAME] = $folderHandler->find(".*" . $logext);
+ $totalFiles += count($allFiles[$path . "/" . USERLOG_DIRNAME]);
+ }
+ if(empty($totalFiles)) return array(array(), 0);
+ return array($allFiles, $totalFiles);
+ }
public function getFromKeys($array, $keys = null)
{
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-04 00:18:02 UTC (rev 11148)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-04 05:36:27 UTC (rev 11149)
@@ -1,5 +1,7 @@
Userlog
Changelog:
+- add acomplete file browsing engine can accept any file, criteria, pagination, sort,order (2013/03/04)
+- use json_encode instead of serialize for better performance. (2013/03/04)
- add webmaster permission from file to avoid other webmasters to access.(2013/03/02)
- add probabilities to preferences for sets and stats.(previously hardcoded)(2013/03/02)
- add delete/create cache setting files messages.(previously hardcoded)(2013/03/02)
Modified: XoopsModules/userlog/trunk/userlog/include/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/include/log.php 2013-03-04 00:18:02 UTC (rev 11148)
+++ XoopsModules/userlog/trunk/userlog/include/log.php 2013-03-04 05:36:27 UTC (rev 11149)
@@ -62,6 +62,9 @@
// set item in db for views
if (!empty($tolog["views"])) {
$logObj->setItem();
+ // add to save for file
+ $tolog["item_name"] = $logObj->item_name();
+ $tolog["item_id"] = $logObj->item_id();
}
// remove used settings that should not be logged
@@ -70,7 +73,7 @@
// store log
$logObj->store($tolog, true);
// update all time stats
- $statsObj->updateAll("log", $Userlog->getConfig("probstats")); // prob = 10
+ $statsObj->updateAll("log", $Userlog->getConfig("probstats")); // default prob = 10
}
// update all time stats
-$statsObj->updateAll("log", $Userlog->getConfig("probstatsallhit")); // prob = 10
\ No newline at end of file
+$statsObj->updateAll("log", $Userlog->getConfig("probstatsallhit")); // default prob = 1
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/include/module.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/include/module.php 2013-03-04 00:18:02 UTC (rev 11148)
+++ XoopsModules/userlog/trunk/userlog/include/module.php 2013-03-04 05:36:27 UTC (rev 11149)
@@ -24,5 +24,5 @@
function xoops_module_uninstall_userlog(&$module)
{
$logsetObj = UserlogSetting::getInstance();
- $logsetObj->cleanCache(); // delete all settings caches
+ return $logsetObj->cleanCache(); // delete all settings caches
}
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/language/english/admin.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-04 00:18:02 UTC (rev 11148)
+++ XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-04 05:36:27 UTC (rev 11149)
@@ -161,6 +161,12 @@
define("_AM_USERLOG_HEADER_FORM",_AM_USERLOG_TEXT_FORM);
define("_AM_USERLOG_LOGGER_FORM",_AM_USERLOG_TEXT_FORM);
// END DO NOT TOUCH
+// logs.php engine
+define("_AM_USERLOG_ENGINE","Select the engine you want to get logs from:");
+define("_AM_USERLOG_ENGINE_FILE","FILE");
+define("_AM_USERLOG_ENGINE_DB","Database");
+define("_AM_USERLOG_FILE","Select files you want to get logs from:");
+define("_AM_USERLOG_FILE_WORKING","Working file");
// logs.php error
define("_AM_USERLOG_LOG_ERROR","No Log is found in database with this criteria.");
Modified: XoopsModules/userlog/trunk/userlog/language/english/help/help.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-03-04 00:18:02 UTC (rev 11148)
+++ XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-03-04 05:36:27 UTC (rev 11149)
@@ -2,9 +2,9 @@
<h1 class="head">Help: <a class="ui-corner-all tooltip" href="<{$xoops_url}>/modules/userlog/admin/index.php" title="Back to the administration of Userlog"> Userlog <img src="<{xoAdminIcons home.png}>" alt="Back to the administration of Userlog"/></a></h1>
<h4 class="odd">Description</h4>
<p class="even">
-Userlog is a node logger which can log your user/visitor activities in your site.<br />
+Userlog is a node logger which can log your user/visitor activities in your site from a preferred node.<br />
This is a very useful tool for webmasters in busy sites. For example, you can log your other Admins navigation.<br />
-Current nodes for logging are: user id, user group and visitor IP.<br />
+Current nodes for logging are: user ID, user group and visitor IP.<br />
You can store logs in a database, in a file or both.<br /><br />
<b>Attention: userlog module will only work in Admin part of modules that use the ModuleAdmin class.</b><br /><br />
</p>
Modified: XoopsModules/userlog/trunk/userlog/language/english/modinfo.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/modinfo.php 2013-03-04 00:18:02 UTC (rev 11148)
+++ XoopsModules/userlog/trunk/userlog/language/english/modinfo.php 2013-03-04 05:36:27 UTC (rev 11149)
@@ -52,6 +52,8 @@
define("_MI_USERLOG_SETS_PERPAGE_DSC","The default value for viewing settings");
define("_MI_USERLOG_LOGS_PERPAGE","Number of logs per page");
define("_MI_USERLOG_LOGS_PERPAGE_DSC","The default value for viewing logs");
+define("_MI_USERLOG_ENGINE","Select the default engine for browsing logs");
+define("_MI_USERLOG_ENGINE_DSC","This will be the default engine in logs browing.");
// config logdb
define("_MI_USERLOG_MAXLOGS","Maximum logs stored in database");
define("_MI_USERLOG_MAXLOGS_DSC","Logs will be deleted from database after reaching this number");
Modified: XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-03-04 00:18:02 UTC (rev 11148)
+++ XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-03-04 05:36:27 UTC (rev 11149)
@@ -31,8 +31,8 @@
</div>
<{foreach item=log key=log_id from=$logs}>
<div class="<{cycle values='even,odd'}> border x-small">
- <{foreach item=data key=header from=$log}>
- <div title="<{$data}>" class="width<{if $header == "admin" || $header == "log_id" || $header == "uid"}>1<{else}><{$widthC}><{/if}> floatleft center" style="height: 15px; overflow: hidden;"> <{$data}></div>
+ <{foreach item=title key=header from=$headers}>
+ <div title="<{$log.$header}>" class="width<{if $header == "admin" || $header == "log_id" || $header == "uid"}>1<{else}><{$widthC}><{/if}> floatleft center" style="height: 15px; overflow: hidden;"> <{$log.$header}></div>
<{/foreach}>
<div class="clear"></div>
</div>
Modified: XoopsModules/userlog/trunk/userlog/xoops_version.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-03-04 00:18:02 UTC (rev 11148)
+++ XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-03-04 05:36:27 UTC (rev 11149)
@@ -23,6 +23,7 @@
$modversion = array();
$modversion['name'] = _MI_USERLOG_NAME;
$modversion['dirname'] = 'userlog';
+xoops_loadLanguage('admin', $modversion['dirname']);
$modversion['description'] = _MI_USERLOG_DSC;
$modversion['version'] = '1';
$modversion['author'] = 'xoops.org (irmtfan)';
@@ -189,6 +190,16 @@
$modversion['config'][$i]['category'] = 'pagenav';
$i++;
+$modversion['config'][$i]['name'] = 'engine';
+$modversion['config'][$i]['title'] = '_MI_USERLOG_ENGINE';
+$modversion['config'][$i]['description'] = '_MI_USERLOG_ENGINE_DSC';
+$modversion['config'][$i]['formtype'] = 'select';
+$modversion['config'][$i]['valuetype'] = 'text';
+$modversion['config'][$i]['default'] = 'db';
+$modversion['config'][$i]['options'] = array(_AM_USERLOG_ENGINE_DB=>'db',_AM_USERLOG_ENGINE_FILE=>'file');
+$modversion['config'][$i]['category'] = 'pagenav';
+
+$i++;
$modversion['config'][$i]['name'] = 'logdb';
$modversion['config'][$i]['title'] = '_MI_USERLOG_CONFCAT_LOGDB';
$modversion['config'][$i]['description'] = '_MI_USERLOG_CONFCAT_LOGDB_DSC';
@@ -255,7 +266,7 @@
// 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)) {
+if (isset($xoopsOption['pagetype']) && $xoopsOption['pagetype'] == "admin" && is_object($xoopsModule)) {
// get dirname
$dirname = $xoopsModule->getVar('dirname');
// START if dirname is system
|
|
From: <ir...@us...> - 2013-03-04 14:02:32
|
Revision: 11151
http://sourceforge.net/p/xoops/svn/11151
Author: irmtfan
Date: 2013-03-04 14:02:25 +0000 (Mon, 04 Mar 2013)
Log Message:
-----------
- add manual delete/purge for engine=db
- add log status. active/idle
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/index.php
XoopsModules/userlog/trunk/userlog/admin/logs.php
XoopsModules/userlog/trunk/userlog/class/log.php
XoopsModules/userlog/trunk/userlog/class/stats.php
XoopsModules/userlog/trunk/userlog/class/userlog.php
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/include/log.php
XoopsModules/userlog/trunk/userlog/language/english/admin.php
XoopsModules/userlog/trunk/userlog/language/english/help/help.html
XoopsModules/userlog/trunk/userlog/language/english/modinfo.php
XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
XoopsModules/userlog/trunk/userlog/xoops_version.php
Modified: XoopsModules/userlog/trunk/userlog/admin/index.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/index.php 2013-03-04 06:39:39 UTC (rev 11150)
+++ XoopsModules/userlog/trunk/userlog/admin/index.php 2013-03-04 14:02:25 UTC (rev 11151)
@@ -58,6 +58,7 @@
}
}
$indexAdmin->addConfigBoxLine($Userlog->getConfig('logfilepath') , 'folder');
+$indexAdmin->addConfigBoxLine("<span class='bold " . ($Userlog->getConfig('status') ? "green" : "red") . "'>" . _MI_USERLOG_STATUS . " " . ($Userlog->getConfig('status') ? _MI_USERLOG_ACTIVE : _MI_USERLOG_IDLE) . "</span>", 'default');
echo $indexAdmin->addNavigation('index.php');
echo $indexAdmin->renderButton();
echo $indexAdmin->renderIndex();
Modified: XoopsModules/userlog/trunk/userlog/admin/logs.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-03-04 06:39:39 UTC (rev 11150)
+++ XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-03-04 14:02:25 UTC (rev 11151)
@@ -34,7 +34,8 @@
$options = UserlogRequest::getArray("options");
$engine = UserlogRequest::getString('engine',$Userlog->getConfig("engine"));
$file = UserlogRequest::getArray('file', "all");
-
+$opentry = UserlogRequest::getString('op');
+
$logsetObj = UserlogSetting::getInstance();
// get var types int, text, bool , ...
$type_vars = $logsetObj->getOptions("", "type");
@@ -73,7 +74,7 @@
foreach($val_arr as $qry) {
// if !QUERY eg: !logs.php,views.php
if (substr($qry,0,1) == "!") {
- $criteria_q[$key]->add(new Criteria($op, "%" . substr($qry,1) . "%", "NOT LIKE"), "OR");
+ $criteria_q[$key]->add(new Criteria($op, "%" . substr($qry,1) . "%", "NOT LIKE"), "AND");
} else {
$criteria_q[$key]->add(new Criteria($op, "%" . $qry . "%", "LIKE"), "OR");
}
@@ -99,20 +100,48 @@
$formNav->addElement($hidOptionsEl);
unset($hidOptionsEl);
}
-
+// parse query page
+if ( !empty($query_array) ) {
+ $query_page = implode("&", array_values($query_array));
+}
+$query_entry = "&engine=" . $engine . "&limitentry=" . $limitentry . "&sortentry=" . $sortentry . "&orderentry=" . $orderentry;
+if ($engine == "file") {
+ foreach($file as $oneFile) {
+ $query_entry .= "&file[]=" . $oneFile;
+ }
+}
// get logs from engine: 1- db 2- file
$loglogObj = UserlogLog::getInstance();
+
+// delete/purge
+$confirm = UserlogRequest::getString('confirm',0);
+if ($opentry == "del" && !empty($confirm)) {
+ $log_id = UserlogRequest::getArray('log_id');
+ if( $engine == 'db' ) {
+ // delete logs in database
+ $statsObj = UserlogStats::getInstance();
+ if(is_numeric($log_id[0])) {
+ $criteriaLogId = new CriteriaCompo();
+ $criteriaLogId->add(new Criteria("log_id", "(" . implode(",",$log_id) . ")", "IN"));
+ $numDel = $statsObj->delete($type = 'log', 0, 0, $criteriaLogId);
+ redirect_header("logs.php?op=" . $query_entry . (!empty($query_page) ? "&" . $query_page : ''), 1, sprintf(_AM_USERLOG_LOG_DELETE_SUCCESS, $numDel));
+ } elseif($log_id[0] == "bulk") {
+ $numDel = $statsObj->delete($type = 'log', 0, 0, $criteria);
+ redirect_header("logs.php?op=" . $query_entry , 10, sprintf(_AM_USERLOG_LOG_DELETE_SUCCESS_QUERY, $numDel, $query_page) );
+ }
+ redirect_header("logs.php?op=" . $query_entry . (!empty($query_page) ? "&" . $query_page : ''), 1, _AM_USERLOG_LOG_DELETE_ERROR);
+ // for file
+ } else {
+ redirect_header("logs.php?op=" . $query_entry . (!empty($query_page) ? "&" . $query_page : ''), 1, _AM_USERLOG_LOG_DELETE_ERROR);
+ }
+}
if( $engine == 'db' ) {
$logs = $Userlog->getHandler('log')->getLogs($limitentry,$startentry,$criteria,$sortentry,$orderentry ,null, false);
$totalLogs = $Userlog->getHandler('log')->getLogsCount($criteria);
} else {
list($logs, $totalLogs) = $loglogObj->getLogsFromFiles($file, $limitentry, $startentry, $options, $sortentry,$orderentry);
}
-// parse query page
-if ( !empty($query_array) ) {
- $query_page = implode("&", array_values($query_array));
-}
-$query_entry = "&limitentry=" . $limitentry . "&sortentry=" . $sortentry . "&orderentry=" . $orderentry;
+
// pagenav
$pagenav = new XoopsPageNav($totalLogs, $limitentry, $startentry, 'startentry', $query_entry . (!empty($query_page) ? "&" . $query_page : ''));
if ( !empty($pagenav) ) {
@@ -138,6 +167,9 @@
if ( !empty($query_page) ) {
$GLOBALS['xoopsTpl']->assign('query_page', $query_page);
}
+if ( !empty($query_entry) ) {
+ $GLOBALS['xoopsTpl']->assign('query_entry', $query_entry);
+}
$GLOBALS['xoopsTpl']->assign('types', $type_vars);
// form
@@ -147,7 +179,7 @@
$engineEl->addOption("db", _AM_USERLOG_ENGINE_DB);
$engineEl->addOption("file", _AM_USERLOG_ENGINE_FILE);
if ($engine == "file") {
- $fileEl = $loglogObj->buildFileSelectEle($file);
+ $fileEl = $loglogObj->buildFileSelectEle($file, true);
}
$limitEl = new XoopsFormText(_AM_USERLOG_LOGS_PERPAGE, "limitentry", 10, 255, $limitentry);
$limitEl->setDescription(sprintf(_AM_USERLOG_LOGS_PERPAGE_DSC, $Userlog->getConfig("logs_perpage")));
@@ -193,6 +225,7 @@
$formNav->addElement($submitEl);
$GLOBALS['xoopsTpl']->assign('formNav', $formNav->render());
+$indexAdmin = new ModuleAdmin();
//headers
foreach($skips as $option) {
unset($headers[$option]);
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-04 06:39:39 UTC (rev 11150)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-04 14:02:25 UTC (rev 11151)
@@ -32,6 +32,7 @@
public $_store = 0; // store: 0,1->db 2->file 3->both
+ public $_sourceJSON = array("get","post","request","files","env","session","cookie","header","logger");// json_encoded fields
/**
* constructor
*/
@@ -126,7 +127,7 @@
foreach($logs as $log_id=>$log) {
$logs[$log_id]["log_time"] = $this->userlog->formatTime($logs[$log_id]["log_time"]);
$logs[$log_id]["last_login"] = $this->userlog->formatTime($logs[$log_id]["last_login"]);
- foreach (array("session","cookie","header","logger") as $option){
+ foreach ($this->_sourceJSON as $option){
// if value is not string it was decoded in file
if (!is_string($logs[$log_id][$option])) continue;
$logArr = json_decode($logs[$log_id][$option], true);
@@ -223,13 +224,20 @@
// if type is text
if (!empty($val_arr[0]) && intval($val_arr[0]) == 0) {
foreach ($logs as $id => $log) {
- $flagStr = false;
foreach($val_arr as $qry) {
// if !QUERY eg: !logs.php,views.php
if (substr($qry,0,1) == "!") {
- if(strpos($log[$op], substr($qry,1)) !== false) $flagStr = true;
+ $flagStr = true;
+ if(strpos($log[$op], substr($qry,1)) !== false) {
+ $flagStr = false; // have that delete
+ break; // means AND
+ }
} else {
- if(strpos($log[$op], $qry) !== false) $flagStr = true;
+ $flagStr = false;
+ if(strpos($log[$op], $qry) !== false) {
+ $flagStr = true; // have that dont delete
+ break; // means OR
+ }
}
}
if (!$flagStr) unset($logs[$id]);
@@ -292,9 +300,9 @@
return $this->readFile();
}
$logs = array();
- $pathParts = pathinfo($log_files[0]);
+ $ext = pathinfo($log_files[0], PATHINFO_EXTENSION);
// if "all" or no extension => $path
- if ($log_files[0] == "all" || empty($pathParts[extension])) {
+ if ($log_files[0] == "all" || empty($ext)) {
list($allFiles,$totalFiles) = $this->userlog->getAllLogFiles();
if (empty($totalFiles)) return array();
foreach($allFiles as $path=>$files) {
@@ -310,6 +318,8 @@
return $logs;
}
foreach($log_files as $file) {
+ $ext = pathinfo($file, PATHINFO_EXTENSION);
+ if (empty($ext)) return $logs;
$logs = array_merge($logs,$this->readFile($file));
}
return $logs;
@@ -345,7 +355,7 @@
if (empty($totalFiles)) return false;
$log_file_name = $this->userlog->getConfig('logfilename');
$working_file = $log_file_name.".".$logext;
- $fileEl = new XoopsFormSelect(_AM_USERLOG_FILE,"file", $currentFile);
+ $fileEl = new XoopsFormSelect(_AM_USERLOG_FILE,"file", $currentFile, 3, $multi);
$fileEl->addOption("all", _AM_USERLOG_STATS_FILEALL);
foreach($allFiles as $path=>$files) {
$fileEl->addOption($path, ">" . $path);
Modified: XoopsModules/userlog/trunk/userlog/class/stats.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/stats.php 2013-03-04 06:39:39 UTC (rev 11150)
+++ XoopsModules/userlog/trunk/userlog/class/stats.php 2013-03-04 14:02:25 UTC (rev 11151)
@@ -127,7 +127,7 @@
$exceed = $logs - $this->userlog->getConfig('maxlogs');
// if logs exceed the maxlogs delete them
if ($exceed > 0) {
- $numDel = $this->delete("log",$per, $exceed);
+ $numDel = $this->delete("log",$per, $exceed, null, true);
$logs -= $numDel;
}
$this->update("log", $per, $logs);
@@ -136,19 +136,26 @@
}
return true;
}
- public function delete($type = 'log',$period = 0, $limitDel = 0, $criteria = null)
+ public function delete($type = 'log',$period = 0, $limitDel = 0, $criteria = null, $asObject = false)
{
switch ($type) {
case "log":
- $logsObj = $this->userlog->getHandler('log')->getLogs($limitDel,0,$criteria,"log_id","ASC");
- $numDel = 0;
- foreach (array_keys($logsObj) as $key) {
- $numDel += $this->userlog->getHandler('log')->delete($logsObj[$key], true) ? 1 : 0;
+ if ($asObject) {
+ $logsObj = $this->userlog->getHandler('log')->getLogs($limitDel,0,$criteria,"log_id","ASC");
+ $numDel = 0;
+ foreach (array_keys($logsObj) as $key) {
+ $numDel += $this->userlog->getHandler('log')->delete($logsObj[$key], true) ? 1 : 0;
+ }
+ if ($numDel > 0) {
+ $this->update("logdel", $period, $numDel, true); // increment
+ }
+ unset($logsObj);
+ return $numDel;
}
+ $numDel = $this->userlog->getHandler('log')->deleteAll($criteria, true, $asObject);
if ($numDel > 0) {
$this->update("logdel", $period, $numDel, true); // increment
}
- unset($logsObj);
return $numDel;
break;
}
Modified: XoopsModules/userlog/trunk/userlog/class/userlog.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-03-04 06:39:39 UTC (rev 11150)
+++ XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-03-04 14:02:25 UTC (rev 11151)
@@ -109,7 +109,7 @@
{
$allConfigs = $this->module->getInfo('config');
$currentPath = $this->getConfig("logfilepath");
- $logPaths = array_keys($allConfigs[2]["options"]);
+ $logPaths = array_keys($allConfigs[3]["options"]);
$logext = "log";
$allFiles = array();
$totalFiles = 0;
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-04 06:39:39 UTC (rev 11150)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-04 14:02:25 UTC (rev 11151)
@@ -1,6 +1,8 @@
Userlog
Changelog:
-- add acomplete file browsing engine can accept any file, criteria, pagination, sort,order (2013/03/04)
+- add delete/purge for engine=db(2013/03/04)
+- add log status. active/idle(2013/03/04)
+- add a complete file browsing engine can accept any file, criteria, pagination, sort,order (2013/03/04)
- use json_encode instead of serialize for better performance. (2013/03/04)
- add webmaster permission from file to avoid other webmasters to access.(2013/03/02)
- add probabilities to preferences for sets and stats.(previously hardcoded)(2013/03/02)
Modified: XoopsModules/userlog/trunk/userlog/include/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/include/log.php 2013-03-04 06:39:39 UTC (rev 11150)
+++ XoopsModules/userlog/trunk/userlog/include/log.php 2013-03-04 14:02:25 UTC (rev 11151)
@@ -27,6 +27,7 @@
include_once 'common.php';
$Userlog = Userlog::getInstance(false);
+if (!$Userlog->getConfig("status")) return;
$logsetObj = UserlogSetting::getInstance();
$statsObj = UserlogStats::getInstance();
list($setting, $scope) = $logsetObj->getSet();
Modified: XoopsModules/userlog/trunk/userlog/language/english/admin.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-04 06:39:39 UTC (rev 11150)
+++ XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-04 14:02:25 UTC (rev 11151)
@@ -128,16 +128,15 @@
define("_AM_USERLOG_UIDLT_FORM","Enter one '%1\$s' number to show all logs for all users with a '%2\$s' lower than that");
define("_AM_USERLOG_ADMIN_FORM","Enter 1 to show all logs from Admins");
-define("_AM_USERLOG_GROUPS_FORM","Enter one group with 'g' prefix (or several groups separated with comma) to show logs for all users belonging to those groups. eg: g1,g2 means all users belonging to group 1 OR group 2");
+define("_AM_USERLOG_GROUPS_FORM","Enter one group with 'g' prefix (or several groups separated with comma) to show logs for all users belonging to those groups. Enter '!g' prefix to show logs for users not in those groups. eg: g1,g2,!g4 means all users belonging to group 1 OR group 2 AND not belong to group 4");
-
define("_AM_USERLOG_LAST_LOGINGT","User Last Visit since");
define("_AM_USERLOG_LAST_LOGINGT_FORM","Enter Time of User Last Visit to show all logs since that time. Positive for days and negative for hours. eg: 1 means since one day ago");
define("_AM_USERLOG_LAST_LOGINLT","User Last Visit until");
define("_AM_USERLOG_LAST_LOGINLT_FORM","Enter Time of User Last Visit to show all logs until that time. Positive for days and negative for hours. eg: 1 means until one day ago");
// for all other text logs use just one definition
-define("_AM_USERLOG_TEXT_FORM","Enter one exact '%1\$s' or part of '%2\$s' to show all logs for users have that. you can enter several separated with comma. eg: TERM1, TERM2, TERM3");
+define("_AM_USERLOG_TEXT_FORM","Enter one exact '%1\$s' or part of '%2\$s' to show all logs for users have that (with prefix '!' have not that). you can enter several separated with comma. eg: TERM1, !TERM2, TERM3 means all logs have TERM1 and TERM3 but have not TERM2");
// Translators: do not touch below for now
// START DO NOT TOUCH
define("_AM_USERLOG_UNAME_FORM",_AM_USERLOG_TEXT_FORM);
@@ -169,10 +168,18 @@
define("_AM_USERLOG_FILE_WORKING","Working file");
// logs.php error
-define("_AM_USERLOG_LOG_ERROR","No Log is found in database with this criteria.");
+define("_AM_USERLOG_LOG_ERROR","No Log is found with this criteria.");
define("_AM_USERLOG_LOG_STATUS","%1\$s logs are found.");
define("_AM_USERLOG_LOG_PAGE","Pages");
+// logs.php delete
+define("_AM_USERLOG_LOG_DELETE_SELECT","Delete selected logs in the current page.");
+define("_AM_USERLOG_LOG_PURGE_ALL","Purge all rendered logs in all pages?");
+define("_AM_USERLOG_LOG_DELETE_CONFIRM","Are you sure you want to delete logs? logs will permanently be deleted from database.");
+define("_AM_USERLOG_LOG_DELETE_SUCCESS","%1\$d logs deleted successfully.");
+define("_AM_USERLOG_LOG_DELETE_SUCCESS_QUERY","%1\$d logs deleted successfully with '%2\$s' query.");
+define("_AM_USERLOG_LOG_DELETE_ERROR","Error. you input an invalid criteria for delete.");
+
// views block
define("_AM_USERLOG_VIEW_ALL","All views");
define("_AM_USERLOG_VIEW_MODULE","Module views");
Modified: XoopsModules/userlog/trunk/userlog/language/english/help/help.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-03-04 06:39:39 UTC (rev 11150)
+++ XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-03-04 14:02:25 UTC (rev 11151)
@@ -50,9 +50,9 @@
<h4 class="odd">Logs</h4>
<p class="even">
-You can see users logs through the Admin section of the userlog Module.<br /><br />
+You can see/delete/purge users logs through the Admin section of the userlog Module.<br /><br />
+You can get logs from database or file source engine.<br /><br />
To search for logs based on a criteria you have an advance form.<br /><br />
-To do: browsing logs from log file<br /><br />
</p>
<h4 class="odd">Views block</h4>
<p class="even">
Modified: XoopsModules/userlog/trunk/userlog/language/english/modinfo.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/modinfo.php 2013-03-04 06:39:39 UTC (rev 11150)
+++ XoopsModules/userlog/trunk/userlog/language/english/modinfo.php 2013-03-04 14:02:25 UTC (rev 11151)
@@ -26,7 +26,13 @@
define("_MI_USERLOG_DSC","Log user/visitor activities and navigations");
// configs
-// config logfile
+// config status
+define("_MI_USERLOG_STATUS","Log status:");
+define("_MI_USERLOG_STATUS_DSC","Active: Module will do its job. Idle:The module will not log anything");
+define("_MI_USERLOG_ACTIVE","Active");
+define("_MI_USERLOG_IDLE","Idle");
+
+// config categories
define("_MI_USERLOG_CONFCAT_LOGFILE","Log file (Set it if you need to store logs in a file, otherwise ignore it)");
define("_MI_USERLOG_CONFCAT_LOGFILE_DSC","Preferences for Log file");
define("_MI_USERLOG_CONFCAT_FORMAT","Format");
@@ -53,7 +59,7 @@
define("_MI_USERLOG_LOGS_PERPAGE","Number of logs per page");
define("_MI_USERLOG_LOGS_PERPAGE_DSC","The default value for viewing logs");
define("_MI_USERLOG_ENGINE","Select the default engine for browsing logs");
-define("_MI_USERLOG_ENGINE_DSC","This will be the default engine in logs browing.");
+define("_MI_USERLOG_ENGINE_DSC","This will be the default engine in logs browsing.");
// config logdb
define("_MI_USERLOG_MAXLOGS","Maximum logs stored in database");
define("_MI_USERLOG_MAXLOGS_DSC","Logs will be deleted from database after reaching this number");
Modified: XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-03-04 06:39:39 UTC (rev 11150)
+++ XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-03-04 14:02:25 UTC (rev 11151)
@@ -21,23 +21,43 @@
<{if $logs}>
<{assign var=widthC value=5}>
<div class="outer">
+ <form name="delete" action="logs.php?op=del&confirm=1<{if $query_page}>&<{$query_page}><{/if}><{if $query_entry}><{$query_entry}><{/if}>" method="POST" onsubmit="javascript: if(window.document.delete.log_id[].value < 1){return false;}">
<div class="head boxshadow1 border xx-small">
+ <div class="width1 floatleft center">
+ <{$smarty.const._ALL}>: <input type="checkbox" name="id_check" id="id_check" value="1" onclick="xoopsCheckAll('delete', 'id_check');" />
+ </div>
<{foreach item=title key=header from=$headers}>
<div title="<{$title}>" class="width<{if $header == "admin" || $header == "log_id" || $header == "uid"}>1<{else}><{$widthC}><{/if}> floatleft center" style="height: 15px; overflow: hidden;">
- <a class="ui-corner-all tooltip" title="<{$title}>" href="logs.php?limitentry=<{$limitentry}>&sortentry=<{$header}><{if $query_page}>&<{$query_page}><{/if}><{if $sortentry eq $header}>&orderentry=<{if $orderentry eq 'DESC'}>ASC<{else}>DESC<{/if}><{/if}> " alt="<{$title}>"><{if $sortentry eq $header}><img src="<{if $orderentry eq 'DESC'}><{xoModuleIcons16 DESC.png}><{else}><{xoModuleIcons16 ASC.png}><{/if}>"/><{/if}><{$title}></a>
+ <a class="ui-corner-all tooltip" title="<{$title}>" href="logs.php?limitentry=<{$limitentry}>&sortentry=<{$header}><{if $query_page}>&<{$query_page}><{/if}><{if $sortentry eq $header}>&orderentry=<{if $orderentry eq 'DESC'}>ASC<{else}>DESC<{/if}><{/if}> " alt="<{$title}>"><{if $sortentry eq $header}><img src="<{if $orderentry eq 'DESC'}><{xoModuleIcons16 DESC.png}><{else}><{xoModuleIcons16 ASC.png}><{/if}>"/><{/if}><{$title}></a>
</div>
<{/foreach}>
<div class="clear"></div>
</div>
<{foreach item=log key=log_id from=$logs}>
<div class="<{cycle values='even,odd'}> border x-small">
+ <div class="width1 floatleft center">
+ <a href="logs.php?op=del&confirm=1<{if $query_page}>&<{$query_page}><{/if}><{if $query_entry}><{$query_entry}><{/if}>&log_id=<{$log_id}>" title="<{$smarty.const._DELETE}>" onclick="return confirm('<{$smarty.const._AM_USERLOG_LOG_DELETE_CONFIRM}>');"><img src="<{xoModuleIcons16 delete.png}>" alt="<{$smarty.const._DELETE}>" title="<{$smarty.const._DELETE}>" /></a>
+ <input type="checkbox" name="log_id[]" id="log_id[<{$log_id}>]" value="<{$log_id}>" />
+ </div>
<{foreach item=title key=header from=$headers}>
<div title="<{$log.$header}>" class="width<{if $header == "admin" || $header == "log_id" || $header == "uid"}>1<{else}><{$widthC}><{/if}> floatleft center" style="height: 15px; overflow: hidden;"> <{$log.$header}></div>
<{/foreach}>
<div class="clear"></div>
</div>
<{/foreach}>
+ <div class="floatleft">
+ <input onclick="return confirm('<{$smarty.const._AM_USERLOG_LOG_DELETE_CONFIRM}>');" id="submit" class="formButton" type="submit" name="submit" value="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" title="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" />
+ </div>
+ <{if $pages gt 1}>
+ <div class="floatright xo-buttons">
+ <a class="ui-corner-all tooltip" title="<{$smarty.const._AM_USERLOG_LOG_PURGE_ALL}>" href="logs.php?op=del&confirm=1&log_id=bulk<{if $query_page}>&<{$query_page}><{/if}><{if $query_entry}><{$query_entry}><{/if}>" onclick="return confirm('<{$smarty.const._AM_USERLOG_LOG_DELETE_CONFIRM}>');">
+ <img src="<{xoModuleIcons16 delete.png}>" alt="<{$smarty.const._DELETE}>" title="<{$smarty.const._DELETE}>" /><{$smarty.const._AM_USERLOG_LOG_PURGE_ALL}>
+ </a>
+ </div>
+ <{/if}>
+ <{$pagenav}>
+ <div class="clear"></div>
+ </form>
</div>
<{/if}>
-<{$pagenav}>
<{$form}>
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/xoops_version.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-03-04 06:39:39 UTC (rev 11150)
+++ XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-03-04 14:02:25 UTC (rev 11151)
@@ -111,6 +111,15 @@
// Config Settings (only for modules that need config settings generated automatically)
################### Log file ####################
$i = 0;
+$modversion['config'][$i]['name'] = 'status';
+$modversion['config'][$i]['title'] = '_MI_USERLOG_STATUS';
+$modversion['config'][$i]['description'] = '_MI_USERLOG_STATUS_DSC';
+$modversion['config'][$i]['formtype'] = 'select';
+$modversion['config'][$i]['valuetype'] = 'int';
+$modversion['config'][$i]['default'] = 1;
+$modversion['config'][$i]['options'] = array(_MI_USERLOG_ACTIVE => 1, _MI_USERLOG_IDLE => 0);
+
+$i++;
$modversion['config'][$i]['name'] = 'logfile';
$modversion['config'][$i]['title'] = '_MI_USERLOG_CONFCAT_LOGFILE';
$modversion['config'][$i]['description'] = '_MI_USERLOG_CONFCAT_LOGFILE_DSC';
|
|
From: <ir...@us...> - 2013-03-05 02:40:52
|
Revision: 11154
http://sourceforge.net/p/xoops/svn/11154
Author: irmtfan
Date: 2013-03-05 02:40:49 +0000 (Tue, 05 Mar 2013)
Log Message:
-----------
add a default to preferences for viewing files in logs.php
fix some js issues
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/logs.php
XoopsModules/userlog/trunk/userlog/class/log.php
XoopsModules/userlog/trunk/userlog/language/english/admin.php
XoopsModules/userlog/trunk/userlog/language/english/modinfo.php
XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
XoopsModules/userlog/trunk/userlog/xoops_version.php
Modified: XoopsModules/userlog/trunk/userlog/admin/logs.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-03-04 22:36:47 UTC (rev 11153)
+++ XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-03-05 02:40:49 UTC (rev 11154)
@@ -33,7 +33,7 @@
$options = UserlogRequest::getArray("options");
$engine = UserlogRequest::getString('engine',$Userlog->getConfig("engine"));
-$file = UserlogRequest::getArray('file', "all");
+$file = UserlogRequest::getArray('file', '');
$opentry = UserlogRequest::getString('op');
$logsetObj = UserlogSetting::getInstance();
@@ -178,8 +178,10 @@
$engineEl = new XoopsFormSelect(_AM_USERLOG_ENGINE,"engine", $engine);
$engineEl->addOption("db", _AM_USERLOG_ENGINE_DB);
$engineEl->addOption("file", _AM_USERLOG_ENGINE_FILE);
+$engineEl->setDescription(_AM_USERLOG_ENGINE_DSC);
if ($engine == "file") {
$fileEl = $loglogObj->buildFileSelectEle($file, true);
+ $fileEl->setDescription(_AM_USERLOG_FILE_DSC);
}
$limitEl = new XoopsFormText(_AM_USERLOG_LOGS_PERPAGE, "limitentry", 10, 255, $limitentry);
$limitEl->setDescription(sprintf(_AM_USERLOG_LOGS_PERPAGE_DSC, $Userlog->getConfig("logs_perpage")));
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-04 22:36:47 UTC (rev 11153)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-05 02:40:49 UTC (rev 11154)
@@ -296,7 +296,7 @@
}
public function readFiles($log_files = array())
{
- if(empty($log_files) || count($log_files) == 0) {
+ if(empty($log_files[0]) || count($log_files) == 0) {
return $this->readFile();
}
$logs = array();
@@ -351,6 +351,10 @@
public function buildFileSelectEle($currentFile = null, $multi = false)
{
$logext = "log";
+ if (empty($currentFile[0])) {
+ $log_file_name = $this->userlog->getConfig('logfilepath') .'/'. USERLOG_DIRNAME . '/' . $this->userlog->getConfig('logfilename');
+ $currentFile = $log_file_name.".".$logext;
+ }
list($allFiles,$totalFiles) = $this->userlog->getAllLogFiles();
if (empty($totalFiles)) return false;
$log_file_name = $this->userlog->getConfig('logfilename');
Modified: XoopsModules/userlog/trunk/userlog/language/english/admin.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-04 22:36:47 UTC (rev 11153)
+++ XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-05 02:40:49 UTC (rev 11154)
@@ -161,10 +161,12 @@
define("_AM_USERLOG_LOGGER_FORM",_AM_USERLOG_TEXT_FORM);
// END DO NOT TOUCH
// logs.php engine
-define("_AM_USERLOG_ENGINE","Select the engine you want to get logs from:");
+define("_AM_USERLOG_ENGINE","Engine");
+define("_AM_USERLOG_ENGINE_DSC","Select the engine you want to get logs from.");
define("_AM_USERLOG_ENGINE_FILE","FILE");
define("_AM_USERLOG_ENGINE_DB","Database");
-define("_AM_USERLOG_FILE","Select files you want to get logs from:");
+define("_AM_USERLOG_FILE","Files");
+define("_AM_USERLOG_FILE_DSC","Select files you want to get logs from.");
define("_AM_USERLOG_FILE_WORKING","Working file");
// logs.php error
Modified: XoopsModules/userlog/trunk/userlog/language/english/modinfo.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/modinfo.php 2013-03-04 22:36:47 UTC (rev 11153)
+++ XoopsModules/userlog/trunk/userlog/language/english/modinfo.php 2013-03-05 02:40:49 UTC (rev 11154)
@@ -60,6 +60,9 @@
define("_MI_USERLOG_LOGS_PERPAGE_DSC","The default value for viewing logs");
define("_MI_USERLOG_ENGINE","Select the default engine for browsing logs");
define("_MI_USERLOG_ENGINE_DSC","This will be the default engine in logs browsing.");
+define("_MI_USERLOG_FILE","Select the default files for browsing logs");
+define("_MI_USERLOG_FILE_DSC","This will be the default files in logs browsing.");
+
// config logdb
define("_MI_USERLOG_MAXLOGS","Maximum logs stored in database");
define("_MI_USERLOG_MAXLOGS_DSC","Logs will be deleted from database after reaching this number");
Modified: XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-03-04 22:36:47 UTC (rev 11153)
+++ XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-03-05 02:40:49 UTC (rev 11154)
@@ -21,7 +21,7 @@
<{if $logs}>
<{assign var=widthC value=5}>
<div class="outer">
- <form name="delete" action="logs.php?op=del&confirm=1<{if $query_page}>&<{$query_page}><{/if}><{if $query_entry}><{$query_entry}><{/if}>" method="POST" onsubmit="javascript: if(window.document.delete.log_id[].value < 1){return false;}">
+ <form name="delete" action="logs.php?op=del&confirm=1<{if $query_page}>&<{$query_page}><{/if}><{if $query_entry}><{$query_entry}><{/if}>" method="POST" onsubmit="javascript: if(isOneChecked('log_id[]')) {return confirm('<{$smarty.const._AM_USERLOG_LOG_DELETE_CONFIRM}>');} else {return false;}">
<div class="head boxshadow1 border xx-small">
<div class="width1 floatleft center">
<{$smarty.const._ALL}>: <input type="checkbox" name="id_check" id="id_check" value="1" onclick="xoopsCheckAll('delete', 'id_check');" />
@@ -46,7 +46,7 @@
</div>
<{/foreach}>
<div class="floatleft">
- <input onclick="return confirm('<{$smarty.const._AM_USERLOG_LOG_DELETE_CONFIRM}>');" id="submit" class="formButton" type="submit" name="submit" value="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" title="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" />
+ <input id="submit" class="formButton" type="submit" name="submit" value="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" title="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" />
</div>
<{if $pages gt 1}>
<div class="floatright xo-buttons">
@@ -60,4 +60,20 @@
</form>
</div>
<{/if}>
-<{$form}>
\ No newline at end of file
+<{$form}>
+<script type="text/javascript">
+function isOneChecked($name) {
+ // All <input> tags...
+ var chx = document.getElementsByName($name);
+ for (var i=0; i<chx.length; i++) {
+ // If you have more than one checkbox group, also check the name attribute
+ // for the one you want as in && chx[i].name == 'choose'
+ // Return true from the function on first match of a checked item
+ if (chx[i].type == 'checkbox' && chx[i].checked) {
+ return true;
+ }
+ }
+ // End of the loop, return false
+ return false;
+}
+</script>
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/xoops_version.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-03-04 22:36:47 UTC (rev 11153)
+++ XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-03-05 02:40:49 UTC (rev 11154)
@@ -209,6 +209,16 @@
$modversion['config'][$i]['category'] = 'pagenav';
$i++;
+$modversion['config'][$i]['name'] = 'file';
+$modversion['config'][$i]['title'] = '_MI_USERLOG_FILE';
+$modversion['config'][$i]['description'] = '_MI_USERLOG_FILE_DSC';
+$modversion['config'][$i]['formtype'] = 'select';
+$modversion['config'][$i]['valuetype'] = 'text';
+$modversion['config'][$i]['default'] = '0';
+$modversion['config'][$i]['options'] = array(_AM_USERLOG_FILE_WORKING=>'0',_AM_USERLOG_STATS_FILEALL=>'all');
+$modversion['config'][$i]['category'] = 'pagenav';
+
+$i++;
$modversion['config'][$i]['name'] = 'logdb';
$modversion['config'][$i]['title'] = '_MI_USERLOG_CONFCAT_LOGDB';
$modversion['config'][$i]['description'] = '_MI_USERLOG_CONFCAT_LOGDB_DSC';
|
|
From: <ir...@us...> - 2013-03-05 10:32:39
|
Revision: 11156
http://sourceforge.net/p/xoops/svn/11156
Author: irmtfan
Date: 2013-03-05 10:32:36 +0000 (Tue, 05 Mar 2013)
Log Message:
-----------
add number of items to display and fix script_name bug in views block
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/setting.php
XoopsModules/userlog/trunk/userlog/blocks/views.php
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/docs/readme.txt
XoopsModules/userlog/trunk/userlog/docs/readme_devs.txt
XoopsModules/userlog/trunk/userlog/language/english/admin.php
XoopsModules/userlog/trunk/userlog/language/english/blocks.php
XoopsModules/userlog/trunk/userlog/language/english/help/help.html
XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
XoopsModules/userlog/trunk/userlog/xoops_version.php
Modified: XoopsModules/userlog/trunk/userlog/admin/setting.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/setting.php 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/admin/setting.php 2013-03-05 10:32:36 UTC (rev 11156)
@@ -62,7 +62,7 @@
exit();
}
$msgDel .= "<br/>" . sprintf(_AM_USERLOG_SET_DELETE_SUCCESS, $logsetObj->name());
- redirect_header("setting.php", 1, $msgDel);
+ redirect_header("setting.php", 1, sprintf($msgDel, 1)); // one cache file deleted
exit();
} else {
xoops_confirm(array('op' => 'del', 'set_id' => $logsetObj->set_id(), 'confirm' => 1), 'setting.php', sprintf(_AM_USERLOG_SET_DELETE_CONFIRM, $logsetObj->name()), _DELETE);
Modified: XoopsModules/userlog/trunk/userlog/blocks/views.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/blocks/views.php 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/blocks/views.php 2013-03-05 10:32:36 UTC (rev 11156)
@@ -28,25 +28,28 @@
xoops_loadLanguage("admin",USERLOG_DIRNAME);
// options[0] - number of logs to proceed. use a high number. 0 = no limit and get all. default 2000
-// options[1] - items to select in Where claus
-// options[2] - Time period - default 1 day
-// options[3] - Uid in WHERE claus: select some users to only count views by them 0-all (by default)
-// options[4] - Gid in WHERE claus: select some groups to only count views by them 0-all (by default)
-// options[5] - Sort - module, views
+// options[1] - number of items to show in block. the default is 10
+// options[2] - items to select in Where claus
+// options[3] - Time period - default 1 day
+// options[4] - Uid in WHERE claus: select some users to only count views by them 0-all (by default)
+// options[5] - Gid in WHERE claus: select some groups to only count views by them 0-all (by default)
+// options[6] - Sort - module, views
function userlog_views_show($options)
{
$Userlog = Userlog::getInstance();
- if (!empty($options[1])) {
- $options_views = explode(',', $options[1]); // item views in where claus eg: news-storyid, newbb-topic_id, news-storytopic
+ if (!empty($options[2])) {
+ $options_views = explode(',', $options[2]); // item views in where claus eg: news-storyid, newbb-topic_id, news-storytopic
$module=array();
foreach ($options_views as $key=>$item) {
- $module_item = explode('-', $item); // news-storyid news-storytopic => $module["news"]=array("storyid","storytopic");
- if (!isset($module[$module_item[0]])) {
- $module[$module_item[0]] = array();
+ $module_script_item = explode('-', $item); // news:article.php-storyid news:index.php-storytopic => $module["news"]=array("storyid","storytopic");
+ $module_script = explode(':', $module_script_item[0]); // news:article.php => $module_script = array(news,article.php);
+ if (!isset($module[$module_script[0]])) {
+ $module[$module_script[0]] = array();
+ $scripts[$module_script[0]] = array_slice($module_script,1); // use later to check if the script is correct.
}
- $module[$module_item[0]][] = $module_item[1];
+ $module[$module_script[0]][] = $module_script_item[1];
}
$criteriaModule = new CriteriaCompo();
foreach ($module as $module_dir=>$items) {
@@ -63,19 +66,19 @@
}
}
- if (!empty($options[2])) {
- $starttime = time() - $Userlog->getSinceTime($options[2]);
+ if (!empty($options[3])) {
+ $starttime = time() - $Userlog->getSinceTime($options[3]);
$criteriaSince = new CriteriaCompo();
$criteriaSince->add(new Criteria('log_time', $starttime ,'>'));
}
- if (!empty($options[3])) {
+ if (!empty($options[4])) {
$criteriaUser = new CriteriaCompo();
- $criteriaUser->add(new Criteria('uid', '(' . $options[3] . ')', 'IN'));
+ $criteriaUser->add(new Criteria('uid', '(' . $options[4] . ')', 'IN'));
}
- if (!empty($options[4])) {
+ if (!empty($options[5])) {
$criteriaGroup = new CriteriaCompo();
- $options_groups = explode(',', $options[4]); // groups to select
+ $options_groups = explode(',', $options[5]); // groups to select
foreach($options_groups as $group) {
$criteriaGroup->add(new Criteria("groups", "%g" . $group . "%", "LIKE"), "OR");
}
@@ -105,6 +108,7 @@
// assign needed vars
$module_dirname = $loglogObj->module();
$script_name = $loglogObj->script();
+ if (!in_array($script_name, $scripts[$module_dirname])) continue; // check if the script is correct
$item_name = $loglogObj->item_name();
$item_id = $loglogObj->item_id();
// increment total, module, script, item_name, item views
@@ -174,13 +178,14 @@
if (empty($items[$module_dirname][$script_name][$item_name][$item_id]["title"]) && $loglogObj->pagetitle() != '') {
$items[$module_dirname][$script_name][$item_name][$item_id]["title"] = $loglogObj->pagetitle();
$sort_views[$link]["title"] = $loglogObj->pagetitle();
+ if(count($sort_views) == $options[1]) break; // exit the for loop
}
}
$block = array();
arsort($sort_views);
$block["items"]= $items;
$block["sort_views"] = $sort_views;
- $block["sort_type"] = $options[5];
+ $block["sort_type"] = $options[6];
return $block;
}
@@ -201,16 +206,21 @@
$not_config = $module->getInfo('notification');
foreach ($not_config['category'] as $category) {
if (!empty($category['item_name'])) {
- $script = is_array($category["subscribe_from"]) ? implode("|", $category["subscribe_from"]) : $category["subscribe_from"];
- $hasviews[$module->dirname()."-".$category['item_name']] = $module->dirname()."/" . $script ."?".$category['item_name']."=ITEM_ID";
+ $script = is_array($category["subscribe_from"]) ? implode(":", $category["subscribe_from"]) : $category["subscribe_from"];
+ $hasviews[$module->dirname(). ":" . $script . "-" . $category['item_name']] = $module->dirname()."/" . $script ."?".$category['item_name']."=ITEM_ID";
}
}
}
+
$i=0;
- // number of logs to display element
- $numdispEle = new XoopsFormText(_MB_USERLOG_BLOCK_LOG_LIMIT, "options[{$i}]", 10, 255, intval($options[$i]));
+ // number of logs to proceed element
+ $numlogsEle = new XoopsFormText(_MB_USERLOG_BLOCK_LOG_LIMIT, "options[{$i}]", 10, 255, intval($options[$i]));
$i++;
+ // number of items to display element
+ $numitemsEle = new XoopsFormText(_MB_USERLOG_BLOCK_ITEMS_NUM, "options[{$i}]", 10, 255, intval($options[$i]));
+
+ $i++;
// views element
$options_views = explode(',', $options[$i]);
$viewsEle = new XoopsFormCheckBox(_MB_USERLOG_BLOCK_ITEMS, "options[{$i}][]", $options_views);
@@ -246,7 +256,8 @@
$sortEle->setDescription(_AM_USERLOG_SORT_DSC);
// add all elements to form
- $form->addElement($numdispEle);
+ $form->addElement($numlogsEle);
+ $form->addElement($numitemsEle);
$form->addElement($viewsEle);
$form->addElement($timeEle);
$form->addElement($userEle);
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-05 10:32:36 UTC (rev 11156)
@@ -1,5 +1,6 @@
Userlog
Changelog:
+- add number of items to display and fix script_name bug in views block.(2013/03/05)
- add delete/purge for engine=db(2013/03/04)
- add log status. active/idle(2013/03/04)
- add a complete file browsing engine can accept any file, criteria, pagination, sort,order (2013/03/04)
Modified: XoopsModules/userlog/trunk/userlog/docs/readme.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/readme.txt 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/docs/readme.txt 2013-03-05 10:32:36 UTC (rev 11156)
@@ -8,4 +8,39 @@
=========================
1- upload the userlog to /modules/userlog (upload the compressed file and decompressed via Cpanel is the best way to insure all files are correctly uploaded)
2- go to your admin -> system -> modules -> install
-3- change the default settings to your desired in the module preferences
+3- change the default settings to your desired in the module preferences.
+
+Important notice: There is a new "ADDITIONAL permission in file for webmasters" addon introduced in userlog module.
+if you want other webmasters dont have access to userlog module this addon is for you.
+for more information go to userlog/admin/addon/perm.php
+
+known bugs/malfunctioning in userlog module:
+1- userlog will not work in XOOPS255/index.php (homepage) when no module is set for start page.
+ there is a bug in XOOPS255/header.php
+ solution:
+in XOOPS255/header.php exit() should be commented.
+[code]
+$xoopsPreload->triggerEvent('core.header.checkcache');
+ if ($xoTheme->checkCache()) {
+ $xoopsPreload->triggerEvent('core.header.cacheend');
+ //exit(); // irmtfan comment this
+ }
+[/code]
+ more information here: http://sourceforge.net/p/xoops/bugs/1261/
+
+2- You cannot select many items in userlog > blocks > views block.
+It is because of a length limitation in options field in newblocks table in xoops 255 and xoops 26.
+solution:
+in XOOPS255/kernel/block.php and XOOPS26/kernel/block.php
+line 40:
+[code]
+ $this->initVar('options', XOBJ_DTYPE_TXTBOX, null, false, 255);
+[/code]
+
+with this:
+[code]
+[code]
+ $this->initVar('options', XOBJ_DTYPE_TXTBOX, null, false, 600);
+[/code]
+Then go to your database and change the field options length in newblocks table to higher number than 255.
+
Modified: XoopsModules/userlog/trunk/userlog/docs/readme_devs.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/readme_devs.txt 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/docs/readme_devs.txt 2013-03-05 10:32:36 UTC (rev 11156)
@@ -176,10 +176,10 @@
The above is clear. more information in module help.
3- performance.
-it checks every hit to see if the visitor have a setting or not. for the best performance i wrote a get function like this.
+it checks every hit to see if the visitor have a setting or not. for the best performance i wrote a getSet function like this.
in userlog/class/setting.php
[code]
- public function get()
+ public function getSet()
{
// if uid setting exist in File
$unique_uid = ($this->userlog->getUser()) ? $this->userlog->getUser()->getVar('uid') : 0;
@@ -204,6 +204,8 @@
return $options;
}
///////////////////////////////////////////////////////////
+ // check probability
+ if(!$this->userlog->probCheck($this->userlog->getConfig("probset"))) return false;
// database get All is better for performance???
$logsetsObj = $this->userlog->getHandler('setting')->getAll();
if (empty($logsetsObj)) return false; // if not set in db return false
@@ -236,10 +238,9 @@
return false;
}
[/code]
-
as you can see it create cache files for each settings. IMO it will help to reduce queries for users have a setting.
-
for getting settings from db i firstly used criteria but then i decide to get all settings at once and then find if the user have setting or not. IMO it has the better performance. please let me know your opinion. what is the best performance? this function is important for your review.
+Also i add a probability check to access to database in random.
4- views
now every module have a counter for its item views. eg: news, publisher, page in xoops 2.6
@@ -271,7 +272,7 @@
so for example in news we only have these typical URLs:
news/article.php?storyid=ITEM_ID
-news/index.php|article.php?storytopic=ITEM_ID
+news/index.php:article.php?storytopic=ITEM_ID
as you can see i just need to store item_name and item_id because i have the module dirname and script name!!!
Modified: XoopsModules/userlog/trunk/userlog/language/english/admin.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-05 10:32:36 UTC (rev 11156)
@@ -160,7 +160,7 @@
define("_AM_USERLOG_HEADER_FORM",_AM_USERLOG_TEXT_FORM);
define("_AM_USERLOG_LOGGER_FORM",_AM_USERLOG_TEXT_FORM);
// END DO NOT TOUCH
-// logs.php engine
+// logs.php engine/file
define("_AM_USERLOG_ENGINE","Engine");
define("_AM_USERLOG_ENGINE_DSC","Select the engine you want to get logs from.");
define("_AM_USERLOG_ENGINE_FILE","FILE");
@@ -181,6 +181,7 @@
define("_AM_USERLOG_LOG_DELETE_SUCCESS","%1\$d logs deleted successfully.");
define("_AM_USERLOG_LOG_DELETE_SUCCESS_QUERY","%1\$d logs deleted successfully with '%2\$s' query.");
define("_AM_USERLOG_LOG_DELETE_ERROR","Error. you input an invalid criteria for delete.");
+define("_AM_USERLOG_LOG_DELETE_ERRORSELECT","You select nothing to delete.");
// views block
define("_AM_USERLOG_VIEW_ALL","All views");
Modified: XoopsModules/userlog/trunk/userlog/language/english/blocks.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/blocks.php 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/language/english/blocks.php 2013-03-05 10:32:36 UTC (rev 11156)
@@ -22,6 +22,7 @@
define("_MB_USERLOG_BLOCK_LOG_LIMIT","Number of Logs to proceed");
define("_MB_USERLOG_BLOCK_ITEMS","Select items");
+define("_MB_USERLOG_BLOCK_ITEMS_NUM","Number of items to display in block.");
define("_MB_USERLOG_BLOCK_ITEMS_DSC","These are typical links of your active modules. Select at least one item.");
define("_MB_USERLOG_BLOCK_TIME","Time period");
define("_MB_USERLOG_BLOCK_TIME_DSC","Time of Log record to count all logs since that time. Positive for days and negative for hours");
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/language/english/help/help.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-03-05 10:32:36 UTC (rev 11156)
@@ -22,7 +22,7 @@
<br />
<b>Setting name</b>: here you can input any name you like. It is not important for the module activities. It is just for you.<br />
<br />
-<b>Setting logby</b>: here you will choose the 'node' you want to log users by, and in the next part you should input the Unique ID for this node. Currently you can log users by "user id", "user group" and "visitor IP".<br />
+<b>logby</b>: here you will choose the 'node' you want to log users by, and in the next part you should input the Unique ID for this node. Currently you can log users by "user id", "user group" and "visitor IP".<br />
- by selecting uid only that specific user will be logged. eg uid=1<br />
- by selecting user group all activities of users belong to that specific group will be logged. eg: gid=3<br />
- visitor IP is very useful to log robots, malicious visitors and ... eg: ip=66.249.66.1<br />
@@ -34,13 +34,13 @@
ELSE IF Unique id = 0 log all users<br />
<br />
-<b>Setting Unique ID</b>: here you must choose one unique ID (node id) to be logged.<br />
+<b>Unique ID</b>: here you must choose one unique ID (node id) to be logged.<br />
(eg: uid=1, gid=3 (anonymous), ip=66.249.66.1) enter 0 means all users.<br />
<br />
-<b>Setting options:</b> you can select which user or page data you want to be logged. Also here you can choose 3 settings. Store in file? Store in database? And log user views?<br />
+<b>options:</b> you can select which user or page data you want to be logged. Also here you can choose 3 settings. Store in file? Store in database? And log user views?<br />
select log user views means store uid, groups, script name, pagetitle, module, item name, item ID in Database.<br />
<br />
-<b>Setting scope:</b> if you want to log users activities in some specific module, you can do it here.<br />
+<b>Log scope:</b> if you want to log users activities in some specific module, you can do it here.<br />
select nothing means all website.<br />
<br />
Attention: we assume you will not have many settings in your site (eg: less than 100 settings) so we don't provide many navigation facilities like order and sort in set list table. You just have a page navigation.<br />
Modified: XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-03-05 10:32:36 UTC (rev 11156)
@@ -21,7 +21,7 @@
<{if $logs}>
<{assign var=widthC value=5}>
<div class="outer">
- <form name="delete" action="logs.php?op=del&confirm=1<{if $query_page}>&<{$query_page}><{/if}><{if $query_entry}><{$query_entry}><{/if}>" method="POST" onsubmit="javascript: if(isOneChecked('log_id[]')) {return confirm('<{$smarty.const._AM_USERLOG_LOG_DELETE_CONFIRM}>');} else {return false;}">
+ <form name="delete" action="logs.php?op=del&confirm=1<{if $query_page}>&<{$query_page}><{/if}><{if $query_entry}><{$query_entry}><{/if}>" method="POST" onsubmit="javascript: return deleteSubmitValid('log_id[]');">
<div class="floatleft">
<input id="submit" class="formButton" type="submit" name="submit" value="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" title="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" />
</div>
@@ -88,4 +88,13 @@
// End of the loop, return false
return false;
}
+function deleteSubmitValid($name) {
+ if (isOneChecked($name)) {
+ return confirm('<{$smarty.const._AM_USERLOG_LOG_DELETE_CONFIRM}>');
+ } else {
+ alert('<{$smarty.const._AM_USERLOG_LOG_DELETE_ERRORSELECT}>');
+ return false;
+ }
+ return false;
+}
</script>
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/xoops_version.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-03-05 03:14:38 UTC (rev 11155)
+++ XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-03-05 10:32:36 UTC (rev 11156)
@@ -91,17 +91,18 @@
// blocks
$i = 0;
// options[0] - number of logs to proceed. use a high number. 0 = no limit and get all. default 2000
-// options[1] - items to select in Where claus
-// options[2] - Time period - default 1 day
-// options[3] - Uid in WHERE claus: select some users to only count views by them 0-all (by default)
-// options[4] - Gid in WHERE claus: select some groups to only count views by them 0-all (by default)
-// options[5] - Sort - module, views
+// options[1] - number of items to show in block. the default is 10
+// options[2] - items to select in Where claus
+// options[3] - Time period - default 1 day
+// options[4] - Uid in WHERE claus: select some users to only count views by them 0-all (by default)
+// options[5] - Gid in WHERE claus: select some groups to only count views by them 0-all (by default)
+// options[6] - Sort - module, views
$modversion['blocks'][$i]['file'] = "views.php";
$modversion['blocks'][$i]['name'] = _MI_USERLOG_BLOCK_VIEWS;
$modversion['blocks'][$i]['description'] = _MI_USERLOG_BLOCK_VIEWS_DSC;
$modversion['blocks'][$i]['show_func'] = "userlog_views_show";
$modversion['blocks'][$i]['edit_func'] = "userlog_views_edit";
-$modversion['blocks'][$i]['options'] = "2000||1|0|0|views";
+$modversion['blocks'][$i]['options'] = "2000|10||1|0|0|views";
$modversion['blocks'][$i]['template'] = "userlog_views.html";
// Config categories
@@ -325,7 +326,7 @@
$modversion['hasAdmin'] = 0;
$modversion['system_menu'] = 0;
$modversion['tables'] = null;
- redirect_header(XOOPS_URL . "/admin.php", 1, sprintf(_MI_USERLOG_WEBMASTER_NOPERM,implode(",", $perm["super"]["uid"]), implode(",", $perm["super"]["group"])) );
+ redirect_header(XOOPS_URL . "/modules/system/help.php?mid=" . (!empty($mod) ? $mod : $xoopsModule->getVar("mid", "s")) . "&page=help", 1, sprintf(_MI_USERLOG_WEBMASTER_NOPERM,implode(",", $perm["super"]["uid"]), implode(",", $perm["super"]["group"])) );
}
}
}
|
|
From: <ir...@us...> - 2013-03-06 03:32:58
|
Revision: 11165
http://sourceforge.net/p/xoops/svn/11165
Author: irmtfan
Date: 2013-03-06 03:32:56 +0000 (Wed, 06 Mar 2013)
Log Message:
-----------
some cleanup and comments. add logo in admin navigation
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/addon/perm.php
XoopsModules/userlog/trunk/userlog/admin/logs.php
XoopsModules/userlog/trunk/userlog/admin/setting.php
XoopsModules/userlog/trunk/userlog/class/log.php
XoopsModules/userlog/trunk/userlog/class/stats.php
XoopsModules/userlog/trunk/userlog/class/userlog.php
XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
XoopsModules/userlog/trunk/userlog/templates/userlog_admin_sets.html
Modified: XoopsModules/userlog/trunk/userlog/admin/addon/perm.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/addon/perm.php 2013-03-06 00:09:27 UTC (rev 11164)
+++ XoopsModules/userlog/trunk/userlog/admin/addon/perm.php 2013-03-06 03:32:56 UTC (rev 11165)
@@ -24,16 +24,19 @@
// 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
+// 1- go to the userlog > admin
+// 2- go to the userlog > preferences
+// 3- install, uninstall or update userlog
// 4- dump any table in system -> maintenance -> dump
// empty array means nothing.
+// Note: you can delete this file if you dont need it.
+
// 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();
-// 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
+
+// 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();
Modified: XoopsModules/userlog/trunk/userlog/admin/logs.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-03-06 00:09:27 UTC (rev 11164)
+++ XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-03-06 03:32:56 UTC (rev 11165)
@@ -35,15 +35,17 @@
$engine = UserlogRequest::getString('engine',$Userlog->getConfig("engine"));
$file = UserlogRequest::getArray('file', '');
$opentry = UserlogRequest::getString('op');
-
+
+// formnav in the upper section
+include_once USERLOG_ROOT_PATH . '/class/form/simpleform.php';
+$formNav = new UserlogSimpleForm('','logsnav','logs.php', 'get');
+
$logsetObj = UserlogSetting::getInstance();
+// START build Criteria for database
// get var types int, text, bool , ...
$type_vars = $logsetObj->getOptions("", "type");
//$query_types = array("="=>"",">"=>"GT", "<"=>"LT");
$criteria = new CriteriaCompo();
-// formnav in the upper section
-include_once USERLOG_ROOT_PATH . '/class/form/simpleform.php';
-$formNav = new UserlogSimpleForm('','logsnav','logs.php', 'get');
foreach($options as $key=>$val) {
// if user input an empty variable unset it
if (empty($val)) {
@@ -68,7 +70,7 @@
}
$criteria_q[$key] = new CriteriaCompo();
$val_arr = explode(",", $val);
- $query_array[$key] = "options[{$key}]={$val}";
+ $query_array[$key] = "options[{$key}]={$val}"; // to keep options in url. very important
// if type is text
if ($type_vars[$op] == "text") {
foreach($val_arr as $qry) {
@@ -91,8 +93,6 @@
$criteria_q[$key]->add(new Criteria($op, "(" . $val . ")", "IN"));
}
}
- // save vars
- $vars[$key] = $val;
// add criteria
$criteria->add($criteria_q[$key]);
// add hiddens to formnav
@@ -100,20 +100,21 @@
$formNav->addElement($hidOptionsEl);
unset($hidOptionsEl);
}
+// END build Criteria for database
+
// parse query page
if ( !empty($query_array) ) {
$query_page = implode("&", array_values($query_array));
}
+// create query entry
$query_entry = "&engine=" . $engine . "&limitentry=" . $limitentry . "&sortentry=" . $sortentry . "&orderentry=" . $orderentry;
if ($engine == "file") {
foreach($file as $oneFile) {
$query_entry .= "&file[]=" . $oneFile;
}
}
-// get logs from engine: 1- db 2- file
-$loglogObj = UserlogLog::getInstance();
-// delete/purge
+// START delete/purge
$confirm = UserlogRequest::getString('confirm',0);
if ($opentry == "del" && !empty($confirm)) {
$log_id = UserlogRequest::getArray('log_id');
@@ -135,6 +136,10 @@
redirect_header("logs.php?op=" . $query_entry . (!empty($query_page) ? "&" . $query_page : ''), 1, _AM_USERLOG_LOG_DELETE_ERROR);
}
}
+// END delete/purge
+
+// get logs from engine: 1- db 2- file
+$loglogObj = UserlogLog::getInstance();
if( $engine == 'db' ) {
$logs = $Userlog->getHandler('log')->getLogs($limitentry,$startentry,$criteria,$sortentry,$orderentry ,null, false);
$totalLogs = $Userlog->getHandler('log')->getLogsCount($criteria);
@@ -142,12 +147,13 @@
list($logs, $totalLogs) = $loglogObj->getLogsFromFiles($file, $limitentry, $startentry, $options, $sortentry,$orderentry);
}
-// pagenav
+// pagenav to template
$pagenav = new XoopsPageNav($totalLogs, $limitentry, $startentry, 'startentry', $query_entry . (!empty($query_page) ? "&" . $query_page : ''));
if ( !empty($pagenav) ) {
$GLOBALS['xoopsTpl']->assign("pagenav",$pagenav->renderNav());
}
+// options/entries to template
$GLOBALS['xoopsTpl']->assign('options', $options);
$GLOBALS['xoopsTpl']->assign('totalLogs', $totalLogs);
$GLOBALS['xoopsTpl']->assign('pages', ceil($totalLogs/$limitentry));
@@ -158,29 +164,37 @@
$GLOBALS['xoopsTpl']->assign('sortentry', $sortentry);
$GLOBALS['xoopsTpl']->assign('orderentry', $orderentry);
+// skip these headers because we can merge it to request method column
$skips = array("get", "post", "request", "files", "env");
-// prepared for display
-$logs = $loglogObj->ArrayToDisplay($logs, $skips);
+// prepared for display. timestamps and var_export
+$logs = $loglogObj->arrayToDisplay($logs, $skips);
-// assign logs
+// logs to template
$GLOBALS['xoopsTpl']->assign('logs', $logs);
+
+// query page
if ( !empty($query_page) ) {
$GLOBALS['xoopsTpl']->assign('query_page', $query_page);
}
+// query entry
if ( !empty($query_entry) ) {
$GLOBALS['xoopsTpl']->assign('query_entry', $query_entry);
}
+// var types to template
$GLOBALS['xoopsTpl']->assign('types', $type_vars);
-// form
-list($form, $els, $headers) =$logsetObj->logForm($options);
+// START main form
+// form, elements, headers
+list($form, $elements, $headers) = $logsetObj->logForm($options);
+// engine element
$engineEl = new XoopsFormSelect(_AM_USERLOG_ENGINE,"engine", $engine);
$engineEl->addOption("db", _AM_USERLOG_ENGINE_DB);
$engineEl->addOption("file", _AM_USERLOG_ENGINE_FILE);
$engineEl->setDescription(_AM_USERLOG_ENGINE_DSC);
+// file element
if ($engine == "file") {
- $fileEl = $loglogObj->buildFileSelectEle($file, true);
+ $fileEl = $loglogObj->buildFileSelectEle($file, true);// multiselect = true
$fileEl->setDescription(_AM_USERLOG_FILE_DSC);
}
$limitEl = new XoopsFormText(_AM_USERLOG_LOGS_PERPAGE, "limitentry", 10, 255, $limitentry);
@@ -204,8 +218,9 @@
$form->addElement($orderEl);
$form->addElement($submitEl);
$GLOBALS['xoopsTpl']->assign('form', $form->render());
-
-// add formnav after adding form
+// END main form
+// START form navigation
+// add formnav after adding main form
if ($engine == "file") {
$fileEl->setClass("floatleft left");
$fileEl->setExtra("onchange=\"document.forms.logsnav.submit()\"");
@@ -226,16 +241,19 @@
$submitEl->setClass("floatleft left");
$formNav->addElement($submitEl);
$GLOBALS['xoopsTpl']->assign('formNav', $formNav->render());
+// END form navigation
-$indexAdmin = new ModuleAdmin();
-//headers
+$indexAdmin = new ModuleAdmin(); // add this just to include the css file to template
+$GLOBALS['xoopsTpl']->assign('logo',$indexAdmin->addNavigation('logs.php'));
+
+//headers skip then to template
foreach($skips as $option) {
unset($headers[$option]);
}
$GLOBALS['xoopsTpl']->assign('headers', $headers);
+
$template_main = "userlog_admin_logs.html";
if ( !empty($template_main) ) {
$GLOBALS['xoopsTpl']->display("db:{$template_main}");
}
-
xoops_cp_footer();
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/admin/setting.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/setting.php 2013-03-06 00:09:27 UTC (rev 11164)
+++ XoopsModules/userlog/trunk/userlog/admin/setting.php 2013-03-06 03:32:56 UTC (rev 11165)
@@ -228,6 +228,7 @@
}
if ( !empty($indexAdmin) ) {
$GLOBALS['xoopsTpl']->assign("addset",$indexAdmin->renderButton("left"));
+ $GLOBALS['xoopsTpl']->assign('logo',$indexAdmin->addNavigation('setting.php'));
}
if ( !empty($template_main) ) {
$GLOBALS['xoopsTpl']->display("db:{$template_main}");
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-06 00:09:27 UTC (rev 11164)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-06 03:32:56 UTC (rev 11165)
@@ -122,7 +122,7 @@
return $ret;
}
- public function ArrayToDisplay($logs, $skips)
+ public function arrayToDisplay($logs, $skips)
{
foreach($logs as $log_id=>$log) {
$logs[$log_id]["log_time"] = $this->userlog->formatTime($logs[$log_id]["log_time"]);
@@ -149,12 +149,10 @@
public function storeFile($tolog)
{
- $logext = "log";
+ $log_file = $this->userlog->getWorkingFile();
$log_file_name = $this->userlog->getConfig('logfilepath') .'/'. USERLOG_DIRNAME . '/' . $this->userlog->getConfig('logfilename');
- $log_file = $log_file_name.".".$logext;
-
if (filesize($log_file) > $this->userlog->getConfig('maxlogfilesize')) {
- $old_file = $log_file_name."_".date('Y-m-d_H-i-s').".".$logext;
+ $old_file = $log_file_name ."_".date('Y-m-d_H-i-s') . "." . $this->userlog->logext;
if(!$result=rename($log_file, $old_file)) {
$this->setErrors('ERROR renaming ({$log_file_name})');
return false;
@@ -194,6 +192,8 @@
{
$logs = array();
$logsStr = $this->readFiles($log_file);
+ // if no logs return empty array and total = 0
+ if(empty($logsStr)) return array(array(), 0);
foreach ($logsStr as $id=>$log) {
$logArr = json_decode($log, true);
// check if data is correct in file before do anything more
@@ -328,9 +328,7 @@
public function readFile($log_file = null)
{
if (!$log_file) {
- $logext = "log";
- $log_file_name = $this->userlog->getConfig('logfilepath') .'/'. USERLOG_DIRNAME . '/' . $this->userlog->getConfig('logfilename');
- $log_file = $log_file_name.".".$logext;
+ $log_file = $this->userlog->getWorkingFile();
}
// file open/read
$fileHandler = XoopsFile::getHandler();
@@ -350,16 +348,14 @@
}
public function buildFileSelectEle($currentFile = null, $multi = false)
{
- $logext = "log";
+ $fileEl = new XoopsFormSelect(_AM_USERLOG_FILE,"file", $currentFile, 3, $multi);
if (empty($currentFile[0])) {
- $log_file_name = $this->userlog->getConfig('logfilepath') .'/'. USERLOG_DIRNAME . '/' . $this->userlog->getConfig('logfilename');
- $currentFile = $log_file_name.".".$logext;
+ $currentFile = $this->userlog->getWorkingFile();
}
list($allFiles,$totalFiles) = $this->userlog->getAllLogFiles();
- if (empty($totalFiles)) return false;
+ if (empty($totalFiles)) return $fileEl;
$log_file_name = $this->userlog->getConfig('logfilename');
- $working_file = $log_file_name.".".$logext;
- $fileEl = new XoopsFormSelect(_AM_USERLOG_FILE,"file", $currentFile, 3, $multi);
+ $working_file = $log_file_name . "." . $this->userlog->logext;
$fileEl->addOption("all", _AM_USERLOG_STATS_FILEALL);
foreach($allFiles as $path=>$files) {
$fileEl->addOption($path, ">" . $path);
Modified: XoopsModules/userlog/trunk/userlog/class/stats.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/stats.php 2013-03-06 00:09:27 UTC (rev 11164)
+++ XoopsModules/userlog/trunk/userlog/class/stats.php 2013-03-06 03:32:56 UTC (rev 11165)
@@ -97,10 +97,9 @@
$this->update("set", 0, $sets);
break;
case "file":
- $logext = "log";
list($allFiles,$totalFiles) = $this->userlog->getAllLogFiles();
foreach($allFiles as $path=>$files) {
- $log_file = $path . '/' . $this->userlog->getConfig('logfilename').".".$logext;
+ $log_file = $path . '/' . $this->userlog->getConfig('logfilename') . "." . $this->userlog->logext;
$this->update("file" ,0 ,count($files) ,false ,$log_file); // update working file in all paths (now 2)
}
// update all files in db link='all'
Modified: XoopsModules/userlog/trunk/userlog/class/userlog.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-03-06 00:09:27 UTC (rev 11164)
+++ XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-03-06 03:32:56 UTC (rev 11165)
@@ -31,7 +31,8 @@
public $config;
public $debug;
public $debugArray = array();
-
+ public $logext = "log";
+
protected function __construct($debug)
{
$this->debug = $debug;
@@ -110,18 +111,23 @@
$allConfigs = $this->module->getInfo('config');
$currentPath = $this->getConfig("logfilepath");
$logPaths = array_keys($allConfigs[3]["options"]);
- $logext = "log";
$allFiles = array();
$totalFiles = 0;
foreach($logPaths as $path) {
$folderHandler = XoopsFile::getHandler("folder",$path . "/" . USERLOG_DIRNAME);
- $allFiles[$path . "/" . USERLOG_DIRNAME] = $folderHandler->find(".*" . $logext);
+ $allFiles[$path . "/" . USERLOG_DIRNAME] = $folderHandler->find(".*" . $this->logext);
$totalFiles += count($allFiles[$path . "/" . USERLOG_DIRNAME]);
}
if(empty($totalFiles)) return array(array(), 0);
return array($allFiles, $totalFiles);
}
+ public function getWorkingFile()
+ {
+ $logFileName = $this->getConfig('logfilepath') .'/'. USERLOG_DIRNAME . '/' . $this->getConfig('logfilename');
+ return $logFileName . "." . $this->logext;
+ }
+
public function getFromKeys($array, $keys = null)
{
if (empty($keys)) return $array; // all keys
Modified: XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-03-06 00:09:27 UTC (rev 11164)
+++ XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-03-06 03:32:56 UTC (rev 11165)
@@ -1,3 +1,4 @@
+<{$logo}>
<div class="odd border x-small">
<div class="floatleft left">
<{if $logs}>
Modified: XoopsModules/userlog/trunk/userlog/templates/userlog_admin_sets.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/templates/userlog_admin_sets.html 2013-03-06 00:09:27 UTC (rev 11164)
+++ XoopsModules/userlog/trunk/userlog/templates/userlog_admin_sets.html 2013-03-06 03:32:56 UTC (rev 11165)
@@ -1,3 +1,4 @@
+<{$logo}>
<{if $sets}>
<div class="outer">
<div class="head border x-small">
|
|
From: <ir...@us...> - 2013-03-07 02:37:36
|
Revision: 11173
http://sourceforge.net/p/xoops/svn/11173
Author: irmtfan
Date: 2013-03-07 02:37:32 +0000 (Thu, 07 Mar 2013)
Log Message:
-----------
- add more GUI facilities to admin/logs.php. a complete toggle formhead can remember the last status for each admin, reset button, up/down.
- fix small bug in saving logs in file
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/logs.php
XoopsModules/userlog/trunk/userlog/admin/menu.php
XoopsModules/userlog/trunk/userlog/class/form/simpleform.php
XoopsModules/userlog/trunk/userlog/class/log.php
XoopsModules/userlog/trunk/userlog/class/setting.php
XoopsModules/userlog/trunk/userlog/class/userlog.php
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/docs/readme.txt
XoopsModules/userlog/trunk/userlog/language/english/admin.php
XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
Added Paths:
-----------
XoopsModules/userlog/trunk/userlog/templates/css/
XoopsModules/userlog/trunk/userlog/templates/css/index.html
XoopsModules/userlog/trunk/userlog/templates/css/style.css
XoopsModules/userlog/trunk/userlog/templates/js/
XoopsModules/userlog/trunk/userlog/templates/js/index.html
XoopsModules/userlog/trunk/userlog/templates/js/userlog.js
Modified: XoopsModules/userlog/trunk/userlog/admin/logs.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-03-06 23:15:46 UTC (rev 11172)
+++ XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-03-07 02:37:32 UTC (rev 11173)
@@ -197,6 +197,7 @@
$fileEl = $loglogObj->buildFileSelectEle($file, true);// multiselect = true
$fileEl->setDescription(_AM_USERLOG_FILE_DSC);
}
+// limit, sort, order
$limitEl = new XoopsFormText(_AM_USERLOG_LOGS_PERPAGE, "limitentry", 10, 255, $limitentry);
$limitEl->setDescription(sprintf(_AM_USERLOG_LOGS_PERPAGE_DSC, $Userlog->getConfig("logs_perpage")));
$sortEl = new XoopsFormSelect(_AM_USERLOG_SORT,"sortentry", $sortentry);
@@ -206,9 +207,9 @@
$orderEl->addOption("DESC", _DESCENDING);
$orderEl->addOption("ASC", _ASCENDING);
$orderEl->setDescription(_AM_USERLOG_ORDER_DSC);
-
-$submitEl = new XoopsFormButton(_SUBMIT, 'submit', _SUBMIT, 'submit');
-
+// submit logs
+$submitEl = new XoopsFormButton(_SUBMIT, 'submitlogs', _SUBMIT, 'submit');
+// add elements
$form->addElement($engineEl);
if ($engine == "file") {
$form->addElement($fileEl);
@@ -237,11 +238,34 @@
$orderEl->setExtra("onchange=\"document.forms.logsnav.submit()\"");
$orderEl->setClass("floatleft left");
$formNav->addElement($orderEl);
-$submitEl = new XoopsFormButton('', 'submit()', _GO, 'submit');
+$submitEl = new XoopsFormButton('', 'submitlogsnav', _GO, 'submit');
$submitEl->setClass("floatleft left");
$formNav->addElement($submitEl);
$GLOBALS['xoopsTpl']->assign('formNav', $formNav->render());
// END form navigation
+$formHead = new UserlogSimpleForm(_AM_USERLOG_LOGFORM,'logshead','logs.php', 'get');
+foreach($elements as $key=>$ele) {
+ $ele->setClass("floatleft left");
+ $formHead->addElement($elements[$key]);
+}
+// add class hidden to formHead
+if ($engine == "file") {
+ $fileEl->setClass("hidden");
+ $formHead->addElement($fileEl);
+}
+$engineEl->setClass("hidden");
+$formHead->addElement($engineEl);
+$limitEl->setClass("hidden");
+$formHead->addElement($limitEl);
+$sortEl->setClass("hidden");
+$formHead->addElement($sortEl);
+$orderEl->setClass("hidden");
+$formHead->addElement($orderEl);
+// add submit to formHead
+$submitEl = new XoopsFormButton('', 'submitlogshead', _SUBMIT, 'submit');
+$formHead->addElement($submitEl);
+$formHead->setExtra("onsubmit=\"preventSubmitEmptyInput('options[');\"");
+$GLOBALS['xoopsTpl']->assign('formHead', $formHead->render());
$indexAdmin = new ModuleAdmin(); // add this just to include the css file to template
$GLOBALS['xoopsTpl']->assign('logo',$indexAdmin->addNavigation('logs.php'));
@@ -251,7 +275,20 @@
unset($headers[$option]);
}
$GLOBALS['xoopsTpl']->assign('headers', $headers);
-
+// get TOGGLE cookie
+$toggles = $Userlog->getCookie("TOGGLE");
+$expand = (count($toggles) > 0) ? ( (in_array('formhead', $toggles)) ? false : true ) : true;
+if ($expand) {
+ $formHeadToggle["toggle"] = "toggle_block";
+ $formHeadToggle["icon"] = "green";
+ $formHeadToggle["alt"] = _AM_USERLOG_HIDE_FORM;
+} else {
+ $formHeadToggle["toggle"] = "toggle_none";
+ $formHeadToggle["icon"] = "green_off";
+ $formHeadToggle["alt"] = _AM_USERLOG_SHOW_FORM;
+}
+$xoopsTpl->assign('formHeadToggle', $formHeadToggle);
+// template
$template_main = "userlog_admin_logs.html";
if ( !empty($template_main) ) {
$GLOBALS['xoopsTpl']->display("db:{$template_main}");
Modified: XoopsModules/userlog/trunk/userlog/admin/menu.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/menu.php 2013-03-06 23:15:46 UTC (rev 11172)
+++ XoopsModules/userlog/trunk/userlog/admin/menu.php 2013-03-07 02:37:32 UTC (rev 11173)
@@ -49,4 +49,11 @@
$i++;
$adminmenu[$i]['title'] = _AM_USERLOG_ABOUT;
$adminmenu[$i]['link'] = "admin/about.php";
-$adminmenu[$i]["icon"] = '../../' . $pathIcon32 . '/about.png';
\ No newline at end of file
+$adminmenu[$i]["icon"] = '../../' . $pathIcon32 . '/about.png';
+// add js, css, toggle_cookie to admin pages
+global $xoTheme;
+$Userlog = Userlog::getInstance(false);
+$xoTheme->addScript("modules/" . USERLOG_DIRNAME . "/templates/js/" . USERLOG_DIRNAME . ".js");
+$xoTheme->addStylesheet("modules/" . USERLOG_DIRNAME . "/templates/css/style.css");
+$toggle_script="var toggle_cookie=\"" . $Userlog->cookiePrefix . "TOGGLE" . "\";";
+$xoTheme->addScript( null, array ('type' => 'text/javascript'), $toggle_script);
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/class/form/simpleform.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/form/simpleform.php 2013-03-06 23:15:46 UTC (rev 11172)
+++ XoopsModules/userlog/trunk/userlog/class/form/simpleform.php 2013-03-07 02:37:32 UTC (rev 11173)
@@ -37,7 +37,8 @@
*/
function render()
{
- $ret = $this->getTitle() . "<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n";
+ $ret = ($this->getTitle() ? "<div class=\" center head \">" . $this->getTitle() . "</div>" : "");
+ $ret.= "<form name='" . $this->getName() . "' id='" . $this->getName() . "' action='" . $this->getAction() . "' method='" . $this->getMethod() . "'" . $this->getExtra() . ">\n";
foreach ($this->getElements() as $ele) {
if (!$ele->isHidden()) {
$ret .= "<div class=\"" . $ele->getClass() . "\"><strong>" . $ele->getCaption() . "</strong>" . $ele->render() . "</div>";
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-06 23:15:46 UTC (rev 11172)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-07 02:37:32 UTC (rev 11173)
@@ -224,6 +224,7 @@
// if type is text
if (!empty($val_arr[0]) && intval($val_arr[0]) == 0) {
foreach ($logs as $id => $log) {
+ if (is_array($log[$op])) $log[$op] = json_encode($log[$op]);
foreach($val_arr as $qry) {
// if !QUERY eg: !logs.php,views.php
if (substr($qry,0,1) == "!") {
@@ -348,10 +349,10 @@
}
public function buildFileSelectEle($currentFile = null, $multi = false)
{
- $fileEl = new XoopsFormSelect(_AM_USERLOG_FILE,"file", $currentFile, 3, $multi);
if (empty($currentFile[0])) {
$currentFile = $this->userlog->getWorkingFile();
}
+ $fileEl = new XoopsFormSelect(_AM_USERLOG_FILE,"file", $currentFile, 3, $multi);
list($allFiles,$totalFiles) = $this->userlog->getAllLogFiles();
if (empty($totalFiles)) return $fileEl;
$log_file_name = $this->userlog->getConfig('logfilename');
Modified: XoopsModules/userlog/trunk/userlog/class/setting.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/setting.php 2013-03-06 23:15:46 UTC (rev 11172)
+++ XoopsModules/userlog/trunk/userlog/class/setting.php 2013-03-07 02:37:32 UTC (rev 11173)
@@ -340,13 +340,14 @@
if (defined($defEl . "_FORM")) {
$el[$ele.$type] = new XoopsFormText(constant($defEl), "options[{$ele}{$type}]", 10, 255, !empty($options[$ele.$type]) ? $options[$ele.$type] : null);
$el[$ele.$type]->setDescription(sprintf(constant($defEl . "_FORM"), $ele, $ele));
- // http://stackoverflow.com/questions/8029532/how-to-prevent-submitting-the-html-forms-input-field-value-if-it-empty
- $el[$ele.$type]->customValidationCode[]= "if (document.getElementById('options[{$ele}{$type}]').value == \"\") { document.getElementById('options[{$ele}{$type}]').setAttribute('name', ''); }\n";
$form->addElement($el[$ele.$type]);
}
}
}
- return array($form,$el,$headers);
+ // http://stackoverflow.com/questions/8029532/how-to-prevent-submitting-the-html-forms-input-field-value-if-it-empty
+ // http://stackoverflow.com/questions/2617480/how-to-get-all-elements-which-name-starts-with-some-string
+ $el["log_id"]->customValidationCode[]="preventSubmitEmptyInput('options[');"; // check all input tags
+ return array($form ,$el ,$headers);
}
function cleanCache() {
$files = glob(XOOPS_VAR_PATH.'/caches/xoops_cache/*' . USERLOG_DIRNAME . '*.*');
Modified: XoopsModules/userlog/trunk/userlog/class/userlog.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-03-06 23:15:46 UTC (rev 11172)
+++ XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-03-07 02:37:32 UTC (rev 11173)
@@ -32,11 +32,13 @@
public $debug;
public $debugArray = array();
public $logext = "log";
+ public $cookiePrefix = "";
protected function __construct($debug)
{
$this->debug = $debug;
$this->dirname = USERLOG_DIRNAME;
+ $this->cookiePrefix = USERLOG_DIRNAME . '_'. (($this->getUser()) ? $this->getUser()->getVar('uid') : '');
}
static function &getInstance($debug = false)
@@ -156,6 +158,12 @@
xoops_load('XoopsLocal');
return XoopsLocal::formatTimestamp($intTime, $dateFormat, $timeoffset);
}
+ public function getCookie($name = "TOGGLE")
+ {
+ $toggles = UserlogRequest::getString($this->cookiePrefix . $name,null, 'cookie');
+ return explode(",",$toggles);
+ }
+
public function probCheck($prob = 11)
{
mt_srand((double)microtime()*1000000);
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-06 23:15:46 UTC (rev 11172)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-07 02:37:32 UTC (rev 11173)
@@ -1,5 +1,6 @@
Userlog
Changelog:
+- add more GUI facilities to admin/logs.php. a complete toggle formhead can remember the last status for each admin, reset button, up/down. (2013/03/07)
- add number of items to display and fix script_name bug in views block.(2013/03/05)
- add delete/purge for engine=db(2013/03/04)
- add log status. active/idle(2013/03/04)
Modified: XoopsModules/userlog/trunk/userlog/docs/readme.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/readme.txt 2013-03-06 23:15:46 UTC (rev 11172)
+++ XoopsModules/userlog/trunk/userlog/docs/readme.txt 2013-03-07 02:37:32 UTC (rev 11173)
@@ -44,3 +44,18 @@
[/code]
Then go to your database and change the field options length in newblocks table to higher number than 255.
+3- When the URL or The REFERER is longer than 255 characters you have a warning and log will not be stored in database but it will be stored in file.
+You can see this warning:
+[code]
+Warning: Insert failed in method 'cleanVars' of object 'UserlogLog' in file /class/model/write.php line 280
+[/code]
+It is because I decide to limit URL/Referer to 255 characters because of better performance.
+solution:
+If you really need to save URLs with more characters than 255. do the following.
+a) go to userlog/class/log.php and change the below indicate lines to your desired values.
+[code]
+ $this->initVar("url", XOBJ_DTYPE_TXTBOX, null, true, 500); // change this
+ $this->initVar("script", XOBJ_DTYPE_TXTBOX, null, true, 50);
+ $this->initVar("referer", XOBJ_DTYPE_TXTBOX, null, true, 500);// change this
+[/code]
+b) go to your database and change 'url' and 'referer' fields in table mod_userlog_log to your desired values.
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/language/english/admin.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-06 23:15:46 UTC (rev 11172)
+++ XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-07 02:37:32 UTC (rev 11173)
@@ -182,6 +182,11 @@
define("_AM_USERLOG_LOG_DELETE_SUCCESS_QUERY","%1\$d logs deleted successfully with '%2\$s' query.");
define("_AM_USERLOG_LOG_DELETE_ERROR","Error. you input an invalid criteria for delete.");
define("_AM_USERLOG_LOG_DELETE_ERRORSELECT","You select nothing to delete.");
+// logs.php template
+define("_AM_USERLOG_SHOW_FORM","Show head form");
+define("_AM_USERLOG_HIDE_FORM","Hide head form");
+define("_AM_USERLOG_UP","Go up");
+define("_AM_USERLOG_DOWN","Go down");
// views block
define("_AM_USERLOG_VIEW_ALL","All views");
Added: XoopsModules/userlog/trunk/userlog/templates/css/index.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/templates/css/index.html (rev 0)
+++ XoopsModules/userlog/trunk/userlog/templates/css/index.html 2013-03-07 02:37:32 UTC (rev 11173)
@@ -0,0 +1 @@
+ <script>history.go(-1);</script>
\ No newline at end of file
Added: XoopsModules/userlog/trunk/userlog/templates/css/style.css
===================================================================
--- XoopsModules/userlog/trunk/userlog/templates/css/style.css (rev 0)
+++ XoopsModules/userlog/trunk/userlog/templates/css/style.css 2013-03-07 02:37:32 UTC (rev 11173)
@@ -0,0 +1,33 @@
+.toggle_block, .toggle_none {
+ -moz-transition-property: all;
+ -moz-transition-duration: 1s;
+ -moz-transition-timing-function: ease-in-out;
+ -moz-transition-delay: 0s;
+ -webkit-transition-property: all;
+ -webkit-transition-duration: 1s;
+ -webkit-transition-timing-function: ease-in-out;
+ -webkit-transition-delay: 0s;
+ -ms-transition-property: all;
+ -ms-transition-duration: 1s;
+ -ms-transition-timing-function: ease-in-out;
+ -ms-transition-delay: 0s;
+ -o-transition-property: all;
+ -o-transition-duration: 1s;
+ -o-transition-timing-function: ease-in-out;
+ -o-transition-delay: 0s;
+ transition: all 1s ease-in-out 0s;
+}
+
+.toggle_block{
+ visibility:visible;
+ opacity: 1;
+ top: auto;
+}
+.toggle_none, .toggle_none div, .toggle_none div div {
+ opacity: 0;
+ top: 0;
+ height:0;
+ visibility:hidden;
+}
+/* .hidden is defined in xoops.css but i add it in rare cases that user dont have that in his/her xoops.css */
+.hidden{ visibility:hidden; position:absolute; top:0; left:0; }
Added: XoopsModules/userlog/trunk/userlog/templates/js/index.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/templates/js/index.html (rev 0)
+++ XoopsModules/userlog/trunk/userlog/templates/js/index.html 2013-03-07 02:37:32 UTC (rev 11173)
@@ -0,0 +1 @@
+ <script>history.go(-1);</script>
\ No newline at end of file
Added: XoopsModules/userlog/trunk/userlog/templates/js/userlog.js
===================================================================
--- XoopsModules/userlog/trunk/userlog/templates/js/userlog.js (rev 0)
+++ XoopsModules/userlog/trunk/userlog/templates/js/userlog.js 2013-03-07 02:37:32 UTC (rev 11173)
@@ -0,0 +1,129 @@
+function isOneChecked($name) {
+ // All <input> tags...
+ var chx = document.getElementsByName($name);
+ for (var i=0; i<chx.length; i++) {
+ // If you have more than one checkbox group, also check the name attribute
+ // for the one you want as in && chx[i].name == 'choose'
+ // Return true from the function on first match of a checked item
+ if (chx[i].type == 'checkbox' && chx[i].checked) {
+ return true;
+ }
+ }
+ // End of the loop, return false
+ return false;
+}
+// http://stackoverflow.com/questions/2617480/how-to-get-all-elements-which-name-starts-with-some-string
+function preventSubmitEmptyInput($prefix) {
+ var eles = [];
+ var inputs = document.getElementsByTagName("input");
+ for(var i = 0; i < inputs.length; i++) {
+ if(inputs[i].name.indexOf($prefix) == 0) {
+ eles.push(inputs[i]);
+ }
+ }
+ for(var i = 0; i < eles.length; i++) {
+ if (eles[i].value =='') {
+ eles[i].setAttribute('name', '');
+ }
+ }
+ return true;
+}
+// START irmtfan - improve: add alt, title, id and innerHTML - recognize a IMG tag for src
+function ToggleBlock(blockid, icon, src_expand, src_collapse, alt_expand, alt_collapse, class_expand, class_collapse)
+{
+ var Img_tag='IMG';
+ var el=document.getElementById(blockid);
+ if (el.className == class_expand)
+ {
+ el.className = class_collapse;
+ if (icon.nodeName == Img_tag) {
+ icon.src = src_collapse;
+ }
+ icon.alt= alt_collapse;
+ icon.id = findBaseName(src_collapse);
+ SaveCollapsed(blockid, true);
+ }
+ else
+ {
+ el.className = class_expand;
+ if (icon.nodeName == Img_tag) {
+ icon.src = src_expand;
+ }
+ icon.alt= alt_expand;
+ icon.id = findBaseName(src_expand);
+ SaveCollapsed(blockid, false);
+ }
+ icon.title = icon.alt;
+ if (icon.nodeName != Img_tag){
+ icon.innerHTML=icon.alt; // to support IE7&8 use innerHTML istead of textContent
+ }
+ document.getElementById(blockid + "text").innerHTML=icon.alt;
+}
+// source: http://stackoverflow.com/questions/1991608/find-base-name-in-url-in-javascript
+function findBaseName(url) {
+ var fileName = url.substring(url.lastIndexOf('/') + 1);
+ var dot = fileName.lastIndexOf('.');
+ return dot == -1 ? fileName : fileName.substring(0, dot);
+}
+// END irmtfan - improve: add alt, title and innerHTML - recognize a IMG tag for src
+function SaveCollapsed(objid, addcollapsed)
+{
+ var collapsed = GetCookie(toggle_cookie);
+ var tmp = "";
+ if (collapsed != null)
+ {
+ collapsed = collapsed.split(",");
+ for (i in collapsed)
+ {
+ if (collapsed[i] != objid && collapsed[i] != "")
+ {
+ tmp = tmp + collapsed[i];
+ tmp = tmp + ",";
+ }
+ }
+ }
+
+ if (addcollapsed)
+ {
+ tmp = tmp + objid;
+ }
+
+ expires = new Date();
+ expires.setTime(expires.getTime() + (1000 * 86400 * 365));
+ SetCookie(toggle_cookie, tmp, expires);
+}
+
+function SetCookie(name, value, expires)
+{
+ if (!expires)
+ {
+ expires = new Date();
+ }
+ document.cookie = name + "=" + escape(value) + "; expires=" + expires.toGMTString() + "; path=/";
+}
+
+function GetCookie(name)
+{
+ cookie_name = name + "=";
+ cookie_length = document.cookie.length;
+ cookie_begin = 0;
+ while (cookie_begin < cookie_length)
+ {
+ value_begin = cookie_begin + cookie_name.length;
+ if (document.cookie.substring(cookie_begin, value_begin) == cookie_name)
+ {
+ var value_end = document.cookie.indexOf (";", value_begin);
+ if (value_end == -1)
+ {
+ value_end = cookie_length;
+ }
+ return unescape(document.cookie.substring(value_begin, value_end));
+ }
+ cookie_begin = document.cookie.indexOf(" ", cookie_begin) + 1;
+ if (cookie_begin == 0)
+ {
+ break;
+ }
+ }
+ return null;
+}
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-03-06 23:15:46 UTC (rev 11172)
+++ XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-03-07 02:37:32 UTC (rev 11173)
@@ -6,16 +6,33 @@
<{else}>
<{$smarty.const._AM_USERLOG_LOG_ERROR}>
<{/if}>
+ <{if $options}>
+ <span class="xo-buttons">
+ <a class="ui-corner-all tooltip" title="<{$smarty.const._RESET}>" href="logs.php?op=<{if $query_entry}><{$query_entry}><{/if}>">
+ <img src="<{xoModuleIcons16 on.png}>" alt="<{$smarty.const._RESET}>" title="<{$smarty.const._RESET}>" /><{$smarty.const._RESET}>
+ </a>
+ </span>
+ <{/if}>
+ <div class="cursorpointer bold" onclick="ToggleBlock('formhead',(this.firstElementChild || this.children[0]) , '<{xoModuleIcons16 green.gif}>', '<{xoModuleIcons16 green_off.gif}>','<{$smarty.const._AM_USERLOG_HIDE_FORM}>','<{$smarty.const._AM_USERLOG_SHOW_FORM}>','toggle_block','toggle_none')">
+ <img id="<{$formHeadToggle.icon}>" src="<{if $formHeadToggle.icon == 'green'}><{xoModuleIcons16 green.gif}><{else}><{xoModuleIcons16 green_off.gif}><{/if}>" alt="<{$formHeadToggle.alt}>" title="<{$formHeadToggle.alt}>" /><span id="formheadtext"><{$formHeadToggle.alt}></span>
+ </div>
</div>
<div class="floatright left"><{$formNav}></div>
<div class="clear"></div>
</div>
+<div class="even border x-small">
+ <div id="formhead" class="<{$formHeadToggle.toggle}>">
+ <{$formHead}>
+ <div class="clear"></div>
+ </div>
+ <div class="clear"></div>
+</div>
<{if $options}>
<div class="even border x-small">
<{foreach item=val key=op from=$options}>
<{assign var=header value=$op|replace:'GT':''|replace:'LT':''}>
<{assign var=tt value=$op|replace:$header:''|replace:'GT':'>'|replace:'LT':'<'}>
- <{$headers.$header}><{$tt}>=<b><{$val}></b><br/>
+ <{if $headers.$header}><{$headers.$header}><{$tt}><{else}><{$headers.request_method}>[<{$op}>]<{/if}>=<b><{$val}></b><br/>
<{/foreach}>
</div>
<{/if}>
@@ -24,7 +41,8 @@
<div class="outer">
<form name="delete" action="logs.php?op=del&confirm=1<{if $query_page}>&<{$query_page}><{/if}><{if $query_entry}><{$query_entry}><{/if}>" method="POST" onsubmit="javascript: return deleteSubmitValid('log_id[]');">
<div class="floatleft">
- <input id="submit" class="formButton" type="submit" name="submit" value="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" title="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" />
+ <a href="#submitdeleteDown"><img src="<{xoModuleIcons16 down.png}>" alt="<{$smarty.const._AM_USERLOG_DOWN}>" title="<{$smarty.const._AM_USERLOG_DOWN}>" /></a>
+ <input id="submitdeleteUp" class="formButton" type="submit" name="submitdelete" value="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" title="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" />
</div>
<{if $pages gt 1}>
<div class="floatright xo-buttons">
@@ -37,7 +55,7 @@
<div class="clear"></div>
<div class="head boxshadow1 border xx-small">
<div class="width1 floatleft center">
- <{$smarty.const._ALL}>: <input type="checkbox" name="id_check" id="id_check" value="1" onclick="xoopsCheckAll('delete', 'id_check');" />
+ <input title="<{$smarty.const._ALL}>" type="checkbox" name="id_check" id="id_check" value="1" onclick="xoopsCheckAll('delete', 'id_check');" />
</div>
<{foreach item=title key=header from=$headers}>
<div title="<{$title}>" class="width<{if $header == "admin" || $header == "log_id" || $header == "uid"}>1<{else}><{$widthC}><{/if}> floatleft center" style="height: 15px; overflow: hidden;">
@@ -59,7 +77,8 @@
</div>
<{/foreach}>
<div class="floatleft">
- <input id="submit" class="formButton" type="submit" name="submit" value="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" title="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" />
+ <a href="#submitdeleteUp"><img src="<{xoModuleIcons16 up.png}>" alt="<{$smarty.const._AM_USERLOG_UP}>" title="<{$smarty.const._AM_USERLOG_UP}>" /></a>
+ <input id="submitdeleteDown" class="formButton" type="submit" name="submitdelete" value="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" title="<{$smarty.const._AM_USERLOG_LOG_DELETE_SELECT}>" />
</div>
<{if $pages gt 1}>
<div class="floatright xo-buttons">
@@ -75,20 +94,6 @@
<{/if}>
<{$form}>
<script type="text/javascript">
-function isOneChecked($name) {
- // All <input> tags...
- var chx = document.getElementsByName($name);
- for (var i=0; i<chx.length; i++) {
- // If you have more than one checkbox group, also check the name attribute
- // for the one you want as in && chx[i].name == 'choose'
- // Return true from the function on first match of a checked item
- if (chx[i].type == 'checkbox' && chx[i].checked) {
- return true;
- }
- }
- // End of the loop, return false
- return false;
-}
function deleteSubmitValid($name) {
if (isOneChecked($name)) {
return confirm('<{$smarty.const._AM_USERLOG_LOG_DELETE_CONFIRM}>');
|
|
From: <ir...@us...> - 2013-03-11 07:34:19
|
Revision: 11197
http://sourceforge.net/p/xoops/svn/11197
Author: irmtfan
Date: 2013-03-11 07:34:12 +0000 (Mon, 11 Mar 2013)
Log Message:
-----------
add export to csv. add statistics page. rewrite views functions
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/logs.php
XoopsModules/userlog/trunk/userlog/admin/menu.php
XoopsModules/userlog/trunk/userlog/blocks/views.php
XoopsModules/userlog/trunk/userlog/class/log.php
XoopsModules/userlog/trunk/userlog/class/setting.php
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/language/english/admin.php
XoopsModules/userlog/trunk/userlog/templates/blocks/userlog_views.html
XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
XoopsModules/userlog/trunk/userlog/xoops_version.php
Added Paths:
-----------
XoopsModules/userlog/trunk/userlog/admin/stats.php
XoopsModules/userlog/trunk/userlog/templates/userlog_admin_stats.html
Modified: XoopsModules/userlog/trunk/userlog/admin/logs.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-03-11 05:35:55 UTC (rev 11196)
+++ XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-03-11 07:34:12 UTC (rev 11197)
@@ -34,12 +34,8 @@
$options = UserlogRequest::getArray("options");
$engine = UserlogRequest::getString('engine',$Userlog->getConfig("engine"));
$file = UserlogRequest::getArray('file', '');
-$opentry = UserlogRequest::getString('op');
-
-// formnav in the upper section
-include_once USERLOG_ROOT_PATH . '/class/form/simpleform.php';
-$formNav = new UserlogSimpleForm('','logsnav','logs.php', 'get');
-
+$opentry = UserlogRequest::getString('op', '', 'post');
+$log_id = UserlogRequest::getArray('log_id', 0 , 'post');
$logsetObj = UserlogSetting::getInstance();
// START build Criteria for database
// get var types int, text, bool , ...
@@ -47,11 +43,6 @@
//$query_types = array("="=>"",">"=>"GT", "<"=>"LT");
$criteria = new CriteriaCompo();
foreach($options as $key=>$val) {
- // if user input an empty variable unset it
- if (empty($val)) {
- unset($options[$key]);
- continue;
- }
// deal with greater than and lower than
$tt = substr($key, -2);
switch ($tt) {
@@ -95,10 +86,6 @@
}
// add criteria
$criteria->add($criteria_q[$key]);
- // add hiddens to formnav
- $hidOptionsEl = new XoopsFormHidden("options[{$key}]", $val);
- $formNav->addElement($hidOptionsEl);
- unset($hidOptionsEl);
}
// END build Criteria for database
@@ -115,9 +102,8 @@
}
// START delete/purge
-$confirm = UserlogRequest::getString('confirm',0);
+$confirm = UserlogRequest::getString('confirm',0, 'post');
if ($opentry == "del" && !empty($confirm)) {
- $log_id = UserlogRequest::getArray('log_id');
if( $engine == 'db' ) {
// delete logs in database
$statsObj = UserlogStats::getInstance();
@@ -186,6 +172,30 @@
// START main form
// form, elements, headers
list($form, $elements, $headers) = $logsetObj->logForm($options);
+// START export
+if (substr($opentry,0,6) == "export") {
+ list($opentry,$export) = explode("-",$opentry);
+ // if it is not bulk export get the actual logs in the page
+ if(is_numeric($log_id[0])) {
+ $logs = $Userlog->getFromKeys($logs,$log_id);
+ }
+ $totalLogsExport = count($logs);
+ switch ($export) {
+ case 'csv':
+ if( $csvFile = $loglogObj->exportLogsToCsv($logs, $headers, "engine_" . $engine . "_total_" . $totalLogsExport,";")) {
+ redirect_header("logs.php?op=" . $query_entry . (!empty($query_page) ? "&" . $query_page : '') . "&limitentry=" . (empty($limitentry) ? $Userlog->getConfig("logs_perpage") : $limitentry),
+ 7,
+ sprintf(_AM_USERLOG_LOG_EXPORT_SUCCESS,$totalLogsExport, $csvFile) );
+ }
+ redirect_header("logs.php?op=" . $query_entry . (!empty($query_page) ? "&" . $query_page : '') . "&limitentry=" . (empty($limitentry) ? $Userlog->getConfig("logs_perpage") : $limitentry),
+ 1,
+ _AM_USERLOG_LOG_EXPORT_ERROR);
+ break;
+ default :
+ break;
+ }
+}
+// END export
// engine element
$engineEl = new XoopsFormSelect(_AM_USERLOG_ENGINE,"engine", $engine);
@@ -221,45 +231,54 @@
$GLOBALS['xoopsTpl']->assign('form', $form->render());
// END main form
// START form navigation
-// add formnav after adding main form
+// formNav in the upper section
+include_once USERLOG_ROOT_PATH . '/class/form/simpleform.php';
+$formNav = new UserlogSimpleForm('','logsnav','logs.php', 'get');
+foreach($elements as $key=>$ele) {
+ $ele->setClass("hidden");
+ $formNav->addElement($elements[$key]);
+}
if ($engine == "file") {
$fileEl->setClass("floatleft left");
- $fileEl->setExtra("onchange=\"document.forms.logsnav.submit()\"");
+ $fileEl->setExtra("onchange=\"document.forms.logsnav.submitlogsnav.click()\"");
$formNav->addElement($fileEl);
}
$engineEl->setClass("floatleft left");
-$engineEl->setExtra("onchange=\"document.forms.logsnav.submit()\"");
+$engineEl->setExtra("onchange=\"document.forms.logsnav.submitlogsnav.click()\"");
$formNav->addElement($engineEl);
$limitEl->setClass("floatleft left");
$formNav->addElement($limitEl);
-$sortEl->setExtra("onchange=\"document.forms.logsnav.submit()\"");
+$sortEl->setExtra("onchange=\"document.forms.logsnav.submitlogsnav.click()\"");
$sortEl->setClass("floatleft left");
$formNav->addElement($sortEl);
-$orderEl->setExtra("onchange=\"document.forms.logsnav.submit()\"");
+$orderEl->setExtra("onchange=\"document.forms.logsnav.submitlogsnav.click()\"");
$orderEl->setClass("floatleft left");
$formNav->addElement($orderEl);
$submitEl = new XoopsFormButton('', 'submitlogsnav', _GO, 'submit');
$submitEl->setClass("floatleft left");
$formNav->addElement($submitEl);
+$formNav->setExtra("onsubmit=\"preventSubmitEmptyInput('options[');\"");
$GLOBALS['xoopsTpl']->assign('formNav', $formNav->render());
// END form navigation
+// START form head
+// use _class = array("hidden") to reset element class
$formHead = new UserlogSimpleForm(_AM_USERLOG_LOGFORM,'logshead','logs.php', 'get');
foreach($elements as $key=>$ele) {
- $ele->setClass("floatleft left");
+ $ele->_class = array("floatleft", "left");
$formHead->addElement($elements[$key]);
}
// add class hidden to formHead
if ($engine == "file") {
- $fileEl->setClass("hidden");
+ $fileEl->_class = array("hidden");
$formHead->addElement($fileEl);
}
-$engineEl->setClass("hidden");
+$engineEl->_class = array("hidden");
$formHead->addElement($engineEl);
-$limitEl->setClass("hidden");
+$limitEl->_class = array("hidden");
$formHead->addElement($limitEl);
-$sortEl->setClass("hidden");
+$sortEl->_class = array("hidden");
$formHead->addElement($sortEl);
-$orderEl->setClass("hidden");
+$orderEl->_class = array("hidden");
$formHead->addElement($orderEl);
// add submit to formHead
$submitEl = new XoopsFormButton('', 'submitlogshead', _SUBMIT, 'submit');
@@ -267,6 +286,7 @@
$formHead->addElement($submitEl);
$formHead->setExtra("onsubmit=\"preventSubmitEmptyInput('options[');\"");
$GLOBALS['xoopsTpl']->assign('formHead', $formHead->render());
+// END form head
$indexAdmin = new ModuleAdmin(); // add this just to include the css file to template
$GLOBALS['xoopsTpl']->assign('logo',$indexAdmin->addNavigation('logs.php'));
Modified: XoopsModules/userlog/trunk/userlog/admin/menu.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/menu.php 2013-03-11 05:35:55 UTC (rev 11196)
+++ XoopsModules/userlog/trunk/userlog/admin/menu.php 2013-03-11 07:34:12 UTC (rev 11197)
@@ -47,6 +47,11 @@
$adminmenu[$i]["icon"] = '../../' . $pathIcon32 . '/content.png';
$i++;
+$adminmenu[$i]['title'] = _AM_USERLOG_ADMENU_STATS;
+$adminmenu[$i]['link'] = "admin/stats.php";
+$adminmenu[$i]["icon"] = '../../' . $pathIcon32 . '/stats.png';
+
+$i++;
$adminmenu[$i]['title'] = _AM_USERLOG_ABOUT;
$adminmenu[$i]['link'] = "admin/about.php";
$adminmenu[$i]["icon"] = '../../' . $pathIcon32 . '/about.png';
Added: XoopsModules/userlog/trunk/userlog/admin/stats.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/stats.php (rev 0)
+++ XoopsModules/userlog/trunk/userlog/admin/stats.php 2013-03-11 07:34:12 UTC (rev 11197)
@@ -0,0 +1,74 @@
+<?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
+ * @since 1
+ * @author irmtfan (ir...@ya...)
+ * @author The XOOPS Project <www.xoops.org> <www.xoops.ir>
+ * @version $Id: stats.php 1 2013-02-26 16:25:04Z irmtfan $
+ */
+
+include_once dirname(__FILE__) . '/admin_header.php';
+include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
+xoops_cp_header();
+
+$Userlog = Userlog::getInstance(false);
+// Where do we start ?
+// update all time stats
+$statsObj = UserlogStats::getInstance();
+$statsObj->updateAll("log", 100); // prob = 100
+$statsObj->updateAll("set", 100); // prob = 100
+$statsObj->updateAll("file", 100); // prob = 100
+
+$stats = $statsObj->getAll();
+$indexAdmin = new ModuleAdmin();
+$indexAdmin->addInfoBox(_AM_USERLOG_STATS_ABSTRACT);
+$periods = array_flip($statsObj->_period);
+$types = $statsObj->_type;
+foreach($stats as $type=>$arr) {
+ if(strlen($type) > 10) continue;
+ foreach($arr as $period=>$arr2) {
+ // use sprintf in moduleadmin: sprintf($text, "<span style='color : " . $color . "; font-weight : bold;'>" . $value . "</span>")
+ $indexAdmin->addInfoBoxLine(_AM_USERLOG_STATS_ABSTRACT,
+ sprintf(_AM_USERLOG_STATS_TYPE_PERIOD, "%s\1", $types[$type], constant("_AM_USERLOG_" . strtoupper($periods[$period]))),
+ $arr2["value"],
+ $arr2["value"] ? 'GREEN' : 'RED');
+ }
+}
+$indexAdmin->addInfoBox(_AM_USERLOG_VIEW_MODULE);
+$criteria = new CriteriaCompo();
+$criteria->setGroupby("module");
+$moduleViews = $Userlog->getHandler('log')->getCounts($criteria);
+$module_handler =& xoops_gethandler('module');
+$criteria = new CriteriaCompo();
+foreach(array_keys($moduleViews) as $mDir) {
+ $criteria->add(new Criteria('dirname', $mDir), "OR");
+}
+$modulesObj = $module_handler->getObjects($criteria, true); // id_as_key = true, asobject = false
+foreach($modulesObj as $mObj) {
+ $mDir = $mObj->dirname();
+ $indexAdmin->addInfoBoxLine(_AM_USERLOG_VIEW_MODULE,
+ $mObj->name() . ": %s",
+ $moduleViews[$mDir],
+ $moduleViews[$mDir]? 'GREEN' : 'RED');
+}
+$GLOBALS['xoopsTpl']->assign('stats_abstract',$indexAdmin->renderInfoBox());
+$GLOBALS['xoopsTpl']->assign('logo',$indexAdmin->addNavigation('stats.php'));
+// template
+$template_main = "userlog_admin_stats.html";
+if ( !empty($template_main) ) {
+ $GLOBALS['xoopsTpl']->display("db:{$template_main}");
+}
+xoops_cp_footer();
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/blocks/views.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/blocks/views.php 2013-03-11 05:35:55 UTC (rev 11196)
+++ XoopsModules/userlog/trunk/userlog/blocks/views.php 2013-03-11 07:34:12 UTC (rev 11197)
@@ -27,28 +27,29 @@
define('USERLOG_BLOCK_VIEWS_DEFINED',true);
xoops_loadLanguage("admin",USERLOG_DIRNAME);
-// options[0] - number of logs to proceed. use a high number. 0 = no limit and get all. default 2000
-// options[1] - number of items to show in block. the default is 10
-// options[2] - items to select in Where claus
-// options[3] - Time period - default 1 day
-// options[4] - Uid in WHERE claus: select some users to only count views by them 0-all (by default)
-// options[5] - Gid in WHERE claus: select some groups to only count views by them 0-all (by default)
-// options[6] - Sort - module, views
+// options[0] - number of items to show in block. the default is 10
+// options[1] - items to select in Where claus
+// options[2] - Time period - default 1 day
+// options[3] - Uid in WHERE claus: select some users to only count views by them 0-all (by default)
+// options[4] - Gid in WHERE claus: select some groups to only count views by them 0-all (by default)
+// options[5] - Sort - module, views
+// options[6] - Order - DESC, ASC
function userlog_views_show($options)
{
$Userlog = Userlog::getInstance();
- if (!empty($options[2])) {
- $options_views = explode(',', $options[2]); // item views in where claus eg: news-storyid, newbb-topic_id, news-storytopic
+ if (!empty($options[1])) {
+ $options_views = explode(',', $options[1]); // item views in where claus eg: news-storyid, newbb-topic_id, news-storytopic
$module=array();
foreach ($options_views as $key=>$item) {
$module_script_item = explode('-', $item); // news:article.php-storyid news:index.php-storytopic => $module["news"]=array("storyid","storytopic");
$module_script = explode(':', $module_script_item[0]); // news:article.php => $module_script = array(news,article.php);
if (!isset($module[$module_script[0]])) {
$module[$module_script[0]] = array();
- $scripts[$module_script[0]] = array_slice($module_script,1); // use later to check if the script is correct.
+ $scripts[$module_script[0]] = array_slice($module_script,1);
}
+ $scripts[$module_script[0]] = array_unique(array_merge($scripts[$module_script[0]], array_slice($module_script,1)));
$module[$module_script[0]][] = $module_script_item[1];
}
$criteriaModule = new CriteriaCompo();
@@ -61,24 +62,29 @@
$criteriaItemName->add(new Criteria('item_name', $item_name), "OR");
}
$criteriaItem->add($criteriaItemName);
+ $criteriaScript = new CriteriaCompo();
+ foreach($scripts[$module_dir] as $script_name) {
+ $criteriaScript->add(new Criteria('script', $script_name), "OR");
+ }
+ $criteriaItem->add($criteriaScript);
$criteriaModule->add($criteriaItem, "OR");
- unset($criteriaItem,$criteriaItemName);
+ unset($criteriaItem,$criteriaItemName,$criteriaScript);
}
}
- if (!empty($options[3])) {
- $starttime = time() - $Userlog->getSinceTime($options[3]);
+ if (!empty($options[2])) {
+ $starttime = time() - $Userlog->getSinceTime($options[2]);
$criteriaSince = new CriteriaCompo();
$criteriaSince->add(new Criteria('log_time', $starttime ,'>'));
}
- if (!empty($options[4])) {
+ if (!empty($options[3])) {
$criteriaUser = new CriteriaCompo();
- $criteriaUser->add(new Criteria('uid', '(' . $options[4] . ')', 'IN'));
+ $criteriaUser->add(new Criteria('uid', '(' . $options[3] . ')', 'IN'));
}
- if (!empty($options[5])) {
+ if (!empty($options[4])) {
$criteriaGroup = new CriteriaCompo();
- $options_groups = explode(',', $options[5]); // groups to select
+ $options_groups = explode(',', $options[4]); // groups to select
foreach($options_groups as $group) {
$criteriaGroup->add(new Criteria("groups", "%g" . $group . "%", "LIKE"), "OR");
}
@@ -98,95 +104,44 @@
if ( !empty($criteriaGroup) ) {
$criteria->add($criteriaGroup);
}
+ $criteria->setLimit($options[0]);
+ $fields = array("uid","groups","pagetitle","module","script","item_name","item_id");
+ $criteria->setGroupby("module,script,item_name,item_id");
- $loglogsObj = $Userlog->getHandler('log')->getLogs($options[0], 0, $criteria);
+ list($loglogsObj, $itemViews) = $Userlog->getHandler('log')->getLogsCounts($criteria,$fields);
+ $criteria->setGroupby("module");
+ $moduleViews = $Userlog->getHandler('log')->getCounts($criteria);
+ $module_handler =& xoops_gethandler('module');
+ $criteria = new CriteriaCompo();
+ foreach(array_keys($moduleViews) as $module) {
+ $criteria->add(new Criteria('dirname', $module), "OR");
+ }
+ $modules = $module_handler->getObjects($criteria, true); // id_as_key = true, asobject = false
+ foreach($modules as $module) {
+ $moduleNames[$module->dirname()] = $module->name();
+ }
+ unset($criteria);
// initializing
- $items = array(); // very important!!!
- $items["views"] = 0;
- $sort_views = array();
- foreach($loglogsObj as $loglogObj) {
- // assign needed vars
+ $items = array();; // very important!!!
+ foreach($loglogsObj as $key=>$loglogObj) {
$module_dirname = $loglogObj->module();
- $script_name = $loglogObj->script();
- if (!in_array($script_name, $scripts[$module_dirname])) continue; // check if the script is correct
- $item_name = $loglogObj->item_name();
- $item_id = $loglogObj->item_id();
- // increment total, module, script, item_name, item views
- // $items = array("newbb"=> array("viewtopic.php"=>array("topic_id"=>array([1]=>array("views"=> 23,
- // "title"=>"topic title"
- // ),
- // [23]=>array("views"=> 234,
- // "title"=>"my test topic"
- // ),
- // "views"=> 51, // topic_id views
- // ),// end of topic_id
- // "post_id"=>array([234512]=>array("views"=> 4,
- // "title"=>"Re: topic title"
- // ),
- // [123] =>array("views"=> 121,
- // "title"=>"post title"
- // ),
- // "views"=> 23, // post_id views
- // ),// end of post_id
- // "views"=> 124, // viewtopic.php views
- // ), // end of viewtopic.php
- // "index.php" =>array("forum"=>array([3]=>array("views"=> 5,
- // "title"=>"Forum test"
- // ),
- // ), //end of forum
- // "views"=> 14, // index.php views
- // ), // end of index.php
- // "views"=> 123, // newbb views
- // ), // end of newbb
- // "news"=>array("article.php"=>array("storyid"=>array([234]=>array("views"=> 12,
- // "title"=>"news title"
- // ),
- // ),// end of storyid
- // ), // end of article.php
- // "views"=> 43, // news views
- // ), // end of news
- // "views"=>2424, // total views
- // ); // end of array
- $items["views"]++;
- if (!isset($items[$module_dirname])) {
- $items[$module_dirname] = array();
- $items[$module_dirname]["views"] = 0;
- }
- $items[$module_dirname]["views"]++;
- if (!isset($items[$module_dirname][$script_name])) {
- $items[$module_dirname][$script_name] = array();
- $items[$module_dirname][$script_name]["views"] = 0;
- }
- $items[$module_dirname][$script_name]["views"]++;
- if (!isset($items[$module_dirname][$script_name][$item_name])) {
- $items[$module_dirname][$script_name][$item_name] = array();
- $items[$module_dirname][$script_name][$item_name]["views"] = 0;
- }
- $items[$module_dirname][$script_name][$item_name]["views"]++;
- if (!isset($items[$module_dirname][$script_name][$item_name][$item_id])) {
- $items[$module_dirname][$script_name][$item_name][$item_id] = array();
- $items[$module_dirname][$script_name][$item_name][$item_id]["views"] = 0;
- }
- $items[$module_dirname][$script_name][$item_name][$item_id]["views"]++;
- $link = $module_dirname."/".$script_name."?".$item_name."=".$item_id;
- if (!isset($sort_views[$link])) {
- $sort_views[$link] = array();
- $sort_views[$link]["views"] = 0;
- }
- $sort_views[$link]["views"]++;
- // get the title of the item only once if the pagetitle is not empty.
- if (empty($items[$module_dirname][$script_name][$item_name][$item_id]["title"]) && $loglogObj->pagetitle() != '') {
- $items[$module_dirname][$script_name][$item_name][$item_id]["title"] = $loglogObj->pagetitle();
- $sort_views[$link]["title"] = $loglogObj->pagetitle();
- if(count($sort_views) == $options[1]) break; // exit the for loop
- }
+ $link = $module_dirname."/".$loglogObj->script()."?".$loglogObj->item_name()."=".$loglogObj->item_id();
+ $items[$link] = array();
+ $items[$link]["views"] = $itemViews[$key];
+ $items[$link]["title"] = $loglogObj->pagetitle();
+ $items[$link]["module"] = $module_dirname;
+ $items[$link]["module_name"] = $moduleNames[$module_dirname];
+ $items[$link]["module_views"] = $moduleViews[$module_dirname];
}
$block = array();
- arsort($sort_views);
- $block["items"]= $items;
- $block["sort_views"] = $sort_views;
- $block["sort_type"] = $options[6];
-
+ foreach($items as $link=>$item) {
+ $col1[$link] = $item[$options[5]];
+ $col2[$link] = $item["views"];//second sort by
+ }
+ array_multisort($col1, ($options[6] == "ASC") ? SORT_ASC : SORT_DESC ,$col2 ,SORT_DESC, $items);
+ $block["items"] = $items;
+ $block["sort"] = $options[5];
+ unset($loglogsObj,$items);
return $block;
}
@@ -213,10 +168,6 @@
}
$i=0;
- // number of logs to proceed element
- $numlogsEle = new XoopsFormText(_MB_USERLOG_BLOCK_LOG_LIMIT, "options[{$i}]", 10, 255, intval($options[$i]));
-
- $i++;
// number of items to display element
$numitemsEle = new XoopsFormText(_MB_USERLOG_BLOCK_ITEMS_NUM, "options[{$i}]", 10, 255, intval($options[$i]));
@@ -252,17 +203,28 @@
$i++;
$sortEle = new XoopsFormSelect(_AM_USERLOG_SORT, "options[{$i}]", $options[$i]);
- $sortEle->addOptionArray(array("module"=>_AM_USERLOG_MODULE,"views"=>_AM_USERLOG_VIEW));
+ $sortEle->addOptionArray(array(
+ "views"=>_AM_USERLOG_VIEW,
+ "module"=>_AM_USERLOG_MODULE,
+ "module_name"=>_AM_USERLOG_MODULE_NAME,
+ "module_views"=>_AM_USERLOG_VIEW_MODULE
+ ));
$sortEle->setDescription(_AM_USERLOG_SORT_DSC);
+ $i++;
+ $orderEle = new XoopsFormSelect(_AM_USERLOG_ORDER,"options[{$i}]", $options[$i]);
+ $orderEle->addOption("DESC", _DESCENDING);
+ $orderEle->addOption("ASC", _ASCENDING);
+ $orderEle->setDescription(_AM_USERLOG_ORDER_DSC);
+
// add all elements to form
- $form->addElement($numlogsEle);
$form->addElement($numitemsEle);
$form->addElement($viewsEle);
$form->addElement($timeEle);
$form->addElement($userEle);
$form->addElement($groupEle);
$form->addElement($sortEle);
+ $form->addElement($orderEle);
return $form->render();
}
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-11 05:35:55 UTC (rev 11196)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-11 07:34:12 UTC (rev 11197)
@@ -113,7 +113,7 @@
foreach ($tolog as $option=>$logvalue) {
if(!empty($logvalue)) {
// value array to string. use json_encode
- if (is_array($logvalue) && count($logvalue) > 0) $logvalue = json_encode($logvalue);
+ if (is_array($logvalue) && count($logvalue) > 0) $logvalue = json_encode($logvalue, (phpversion() > "5.4.0") ? JSON_UNESCAPED_UNICODE : 0);
$this->setVar($option, $logvalue);
}
}
@@ -173,10 +173,11 @@
$statsObj->update("file", 0, 0, false, $old_file); // value = 0 to not auto increment
}
$statsObj->updateAll("file", 100); // prob = 100
- $data = json_encode($tolog);
+ $data = "";
} else {
- $data = "\n" . json_encode($tolog);
+ $data = "\n";
}
+ $data .= json_encode($tolog, (phpversion() > "5.4.0") ? JSON_UNESCAPED_UNICODE : 0);
if ($fileHandler->open("a") == false) {
$this->setErrors('Cannot open file ({$log_file_name})');
return false;
@@ -188,6 +189,28 @@
$fileHandler->close();
return true;
}
+ public function exportLogsToCsv($logs, $headers, $csvNamePrefix="list_", $delimiter=";")
+ {
+ $csvFile = $this->userlog->getConfig("logfilepath") . "/" . USERLOG_DIRNAME . "/export/csv/" . $csvNamePrefix . "_" . date('Y-m-d_H-i-s') . ".csv";
+ // file create/open/write
+ $fileHandler = XoopsFile::getHandler();
+ $fileHandler->XoopsFileHandler($csvFile, false);
+ // force to create file if not exist
+ if(!$fileHandler->exists()) {
+ $fileHandler->XoopsFileHandler($csvFile, true); // create file and folder
+ $this->setErrors('File was not exist create file ({$csvFile})');
+ }
+ if ($fileHandler->open("a") == false) {
+ $this->setErrors('Cannot open file ({$csvFile})');
+ return false;
+ }
+ if(!fputcsv($fileHandler->handle, $headers, $delimiter)) return false;
+ foreach($logs as $thisRow) {
+ if(!fputcsv($fileHandler->handle, $thisRow, $delimiter)) return false;
+ }
+ $fileHandler->close();
+ return $csvFile;
+ }
public function getLogsFromFiles($log_file = null, $limit = 0, $start = 0, $options = null, $sort = "log_time", $order = "DESC")
{
$logs = array();
@@ -224,7 +247,7 @@
// if type is text
if (!empty($val_arr[0]) && intval($val_arr[0]) == 0) {
foreach ($logs as $id => $log) {
- if (is_array($log[$op])) $log[$op] = json_encode($log[$op]);
+ if (is_array($log[$op])) $log[$op] = json_encode($log[$op], (phpversion() > "5.4.0") ? JSON_UNESCAPED_UNICODE : 0);
foreach($val_arr as $qry) {
// if !QUERY eg: !logs.php,views.php
if (substr($qry,0,1) == "!") {
@@ -411,7 +434,65 @@
$ret = $this->getAll($criteria, $fields, $asObject, $id_as_key);
return $ret;
}
-
+ public function getLogsCounts($criteria = null, $fields = null, $asObject = true, $id_as_key = true)
+ {
+ if (is_array($fields) && count($fields) > 0) {
+ if (!in_array($this->keyName, $fields)) {
+ $fields[] = $this->keyName;
+ }
+ $select = implode(",", $fields);
+ } else {
+ $select = "*";
+ }
+ $limit = null;
+ $start = null;
+ $sql = "SELECT {$select}, COUNT(*) AS count FROM {$this->table}";
+ if (isset($criteria) && is_subclass_of($criteria, "criteriaelement")) {
+ $sql .= " " . $criteria->renderWhere();
+ if ($groupby = $criteria->getGroupby()) {
+ $sql .= $groupby;
+ }
+ $limit = $criteria->getLimit();
+ $start = $criteria->getStart();
+ }
+ $result = $this->db->query($sql, $limit, $start);
+ $ret = array();
+ $retCount = array();
+ if ($asObject) {
+ while ($myrow= $this->db->fetchArray($result)) {
+ if ($id_as_key) {
+ $retCount[$myrow[$this->keyName]] = array_pop($myrow);
+ } else {
+ $retCount[] = array_pop($myrow);
+ }
+ $object =& $this->create(false);
+ $object->assignVars($myrow);
+ if ($id_as_key) {
+ $ret[$myrow[$this->keyName]] = $object;
+ } else {
+ $ret[] = $object;
+ }
+ unset($object);
+ }
+ } else {
+ $object =& $this->create(false);
+ while ($myrow = $this->db->fetchArray($result)) {
+ if ($id_as_key) {
+ $retCount[$myrow[$this->keyName]] = array_pop($myrow);
+ } else {
+ $retCount[] = array_pop($myrow);
+ }
+ $object->assignVars($myrow);
+ if ($id_as_key) {
+ $ret[$myrow[$this->keyName]] = $object->getValues(array_keys($myrow));
+ } else {
+ $ret[] = $object->getValues(array_keys($myrow));
+ }
+ }
+ unset($object);
+ }
+ return array($ret,$retCount);
+ }
public function getLogsCount($otherCriteria = null,$notNullFields = '')
{
$criteria = new CriteriaCompo();
Modified: XoopsModules/userlog/trunk/userlog/class/setting.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/setting.php 2013-03-11 05:35:55 UTC (rev 11196)
+++ XoopsModules/userlog/trunk/userlog/class/setting.php 2013-03-11 07:34:12 UTC (rev 11197)
@@ -335,13 +335,25 @@
$el= array();
$query_types = array("="=>"",">"=>"GT", "<"=>"LT");
foreach($headers as $ele=>$def) {
- foreach($query_types as $type) {
- $defEl = "_AM_USERLOG_". strtoupper($ele.$type); // if constant is defined in translation - it is good for now
- if (defined($defEl . "_FORM")) {
- $el[$ele.$type] = new XoopsFormText(constant($defEl), "options[{$ele}{$type}]", 10, 255, !empty($options[$ele.$type]) ? $options[$ele.$type] : null);
- $el[$ele.$type]->setDescription(sprintf(constant($defEl . "_FORM"), $ele, $ele));
- $form->addElement($el[$ele.$type]);
- }
+ switch ($ele) {
+ case "admin":
+ $el[$ele] = new XoopsFormRadio(_AM_USERLOG_ADMIN, "options[{$ele}]",isset($options[$ele]) ? $options[$ele] : '');
+ $el[$ele]->addOption(1,_YES);
+ $el[$ele]->addOption(0,_NO);
+ $el[$ele]->addOption('',_ALL);
+ $el[$ele]->setDescription(_AM_USERLOG_ADMIN_FORM);
+ $form->addElement($el[$ele]);
+ break;
+ default:
+ foreach($query_types as $type) {
+ $defEl = "_AM_USERLOG_". strtoupper($ele.$type); // if constant is defined in translation - it is good for now
+ if (defined($defEl . "_FORM")) {
+ $el[$ele.$type] = new XoopsFormText(constant($defEl), "options[{$ele}{$type}]", 10, 255, !empty($options[$ele.$type]) ? $options[$ele.$type] : null);
+ $el[$ele.$type]->setDescription(sprintf(constant($defEl . "_FORM"), $ele, $ele));
+ $form->addElement($el[$ele.$type]);
+ }
+ }
+ break;
}
}
// http://stackoverflow.com/questions/8029532/how-to-prevent-submitting-the-html-forms-input-field-value-if-it-empty
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-11 05:35:55 UTC (rev 11196)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-11 07:34:12 UTC (rev 11197)
@@ -1,5 +1,6 @@
Userlog
Changelog:
+- add export to csv. add statistics page. rewrit...
[truncated message content] |
|
From: <ir...@us...> - 2013-03-12 10:40:02
|
Revision: 11213
http://sourceforge.net/p/xoops/svn/11213
Author: irmtfan
Date: 2013-03-12 10:39:59 +0000 (Tue, 12 Mar 2013)
Log Message:
-----------
add file manager to delete/rename/copy/merge/zip/export-csv log files
add getModules function, add check all items in views block
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/logs.php
XoopsModules/userlog/trunk/userlog/admin/menu.php
XoopsModules/userlog/trunk/userlog/admin/setting.php
XoopsModules/userlog/trunk/userlog/admin/stats.php
XoopsModules/userlog/trunk/userlog/blocks/views.php
XoopsModules/userlog/trunk/userlog/class/log.php
XoopsModules/userlog/trunk/userlog/class/userlog.php
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/language/english/admin.php
XoopsModules/userlog/trunk/userlog/language/english/help/help.html
XoopsModules/userlog/trunk/userlog/xoops_version.php
Added Paths:
-----------
XoopsModules/userlog/trunk/userlog/admin/file.php
XoopsModules/userlog/trunk/userlog/templates/userlog_admin_file.html
Added: XoopsModules/userlog/trunk/userlog/admin/file.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/file.php (rev 0)
+++ XoopsModules/userlog/trunk/userlog/admin/file.php 2013-03-12 10:39:59 UTC (rev 11213)
@@ -0,0 +1,125 @@
+<?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
+ * @since 1
+ * @author irmtfan (ir...@ya...)
+ * @author The XOOPS Project <www.xoops.org> <www.xoops.ir>
+ * @version $Id: file.php 1 2013-02-26 16:25:04Z irmtfan $
+ */
+
+include_once dirname(__FILE__) . '/admin_header.php';
+include_once XOOPS_ROOT_PATH . '/class/pagenav.php';
+xoops_cp_header();
+$Userlog = Userlog::getInstance(false);
+$loglogObj = UserlogLog::getInstance();
+
+$indexAdmin = new ModuleAdmin();
+
+// Where do we start ?
+$file = UserlogRequest::getArray('file', $Userlog->getConfig("file"));
+$opentry = UserlogRequest::getString('op', '');
+$filename = UserlogRequest::getString('filename', '');
+$confirm = UserlogRequest::getString('confirm',0);
+$totalFiles = count($file);
+if(!empty($opentry) && ($confirm == 0 || $totalFiles == 0)) {
+ redirect_header("file.php", 5, sprintf(_AM_USERLOG_ERROR,""));
+}
+switch ($opentry) {
+ case "del":
+ if ($deleteFiles = $loglogObj->deleteFiles($file)) {
+ $msgDel = sprintf(_AM_USERLOG_FILE_DELETE_SUCCESS, $deleteFiles) . "<br\>" . implode("<br\>",$loglogObj->getErrors());
+ redirect_header("file.php", 5, $msgDel);
+ }
+ redirect_header("file.php", 5, sprintf(_AM_USERLOG_ERROR,implode("<br\>",$loglogObj->getErrors())));
+ break;
+ case "rename":
+ // only one file. 0 file or more than one file => error
+ if ($totalFiles != 1) {
+ redirect_header("file.php", 5, sprintf(_AM_USERLOG_ERROR,_AM_USERLOG_FILE_SELECT_ONE));
+ }
+ if ($newFile = $loglogObj->renameFile($file[0], $filename)) {
+ redirect_header("file.php", 700, sprintf(_AM_USERLOG_FILE_RENAME_SUCCESS,$file[0], $newFile));
+ }
+ redirect_header("file.php", 5, sprintf(_AM_USERLOG_ERROR,implode("<br\>",$loglogObj->getErrors())));
+ break;
+ case "copy":
+ // only one file. 0 file or more than one file => error
+ if ($totalFiles != 1) {
+ redirect_header("file.php", 5, sprintf(_AM_USERLOG_ERROR,_AM_USERLOG_FILE_SELECT_ONE));
+ }
+ if ($newFile = $loglogObj->copyFile($file[0], $filename)) {
+ redirect_header("file.php", 700, sprintf(_AM_USERLOG_FILE_COPY_SUCCESS,$file[0], $newFile));
+ }
+ redirect_header("file.php", 5, sprintf(_AM_USERLOG_ERROR,implode("<br\>",$loglogObj->getErrors())));
+ break;
+ case "merge":
+ // if "all"
+ if ($file[0] == "all") {
+ list($allFiles,$totalFiles) = $Userlog->getAllLogFiles();
+ }
+ if ($mergeFile = $loglogObj->mergeFiles($file, $filename)) {
+ redirect_header("file.php", 5, sprintf(_AM_USERLOG_FILE_MERGE_SUCCESS, $totalFiles,$mergeFile));
+ }
+ redirect_header("file.php", 5, sprintf(_AM_USERLOG_ERROR,implode("<br\>",$loglogObj->getErrors())));
+ break;
+ case "zip":
+ if ($zipFile = $loglogObj->zipFiles($file, $filename)) {
+ $msgZip = sprintf(_AM_USERLOG_FILE_ZIP_SUCCESS,$totalFiles, $zipFile ) . "<br\>" . implode("<br\>",$loglogObj->getErrors());
+ redirect_header("file.php", 5, $msgZip);
+ }
+ redirect_header("file.php", 5, sprintf(_AM_USERLOG_ERROR, implode("<br\>",$loglogObj->getErrors())));
+ break;
+ case "export-csv":
+ $logsetObj = UserlogSetting::getInstance();
+ $headers = $logsetObj->getOptions("","title");
+ unset($headers["store_db"], $headers["store_file"], $headers["views"]);
+ if($csvFile = $loglogObj->exportFilesToCsv($file, $headers, $filename,";")) {
+ $msgCsv = sprintf(_AM_USERLOG_FILE_EXOPORT_SUCCESS,$totalFiles, $csvFile );
+ redirect_header("file.php", 5, $msgCsv);
+ }
+ redirect_header("file.php", 5, sprintf(_AM_USERLOG_ERROR, implode("<br\>",$loglogObj->getErrors())));
+ break;
+}
+$form = new XoopsThemeForm(_AM_USERLOG_ADMENU_FILE,'filemanager','file.php', 'post');
+$fileEl = $loglogObj->buildFileSelectEle($file, true, 10);// multiselect = true, size=10
+$form->addElement($fileEl);
+$actionEl = new XoopsFormSelect(_AM_USERLOG_FILE_ACTION,"op", $opentry);
+$actionEl->addOptionArray(array("del"=>_DELETE,
+ "rename"=>_AM_USERLOG_FILE_RENAME,
+ "copy"=>_AM_USERLOG_FILE_COPY,
+ "merge"=>_AM_USERLOG_FILE_MERGE,
+ "zip" =>_AM_USERLOG_FILE_ZIP,
+ "export-csv"=>_AM_USERLOG_FILE_EXPORT_CSV
+ ));
+$actionEl->setExtra("onchange=\"document.forms.filemanager.filename.className = ''; if(this.value == 'del') { document.forms.filemanager.filename.className = 'hidden';}\"");
+$form->addElement($actionEl);
+$filenameEl = new XoopsFormText(_AM_USERLOG_FILE_FILENAME, "filename", 50, 255, '');
+$filenameEl->setExtra("Class='hidden'");
+$filenameEl->setDescription(_AM_USERLOG_FILE_FILENAME_DSC);
+$form->addElement($filenameEl);
+$submitEl = new XoopsFormButton(_SUBMIT, 'submitfilemanager', _SUBMIT, 'submit');
+$form->addElement($submitEl);
+$confirmEl = new XoopsFormHidden("confirm",0);
+$confirmEl->customValidationCode[]="if(confirm('" . _AM_USERLOG_FILE_CONFIRM . "' + ' action=' + myform.op.value)) {myform.confirm.value = 1;} else {return false;};";
+$form->addElement($confirmEl);
+$GLOBALS['xoopsTpl']->assign('form', $form->render());
+$GLOBALS['xoopsTpl']->assign('logo',$indexAdmin->addNavigation('file.php'));
+// template
+$template_main = "userlog_admin_file.html";
+if ( !empty($template_main) ) {
+ $GLOBALS['xoopsTpl']->display("db:{$template_main}");
+}
+xoops_cp_footer();
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/admin/logs.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-03-12 02:58:29 UTC (rev 11212)
+++ XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-03-12 10:39:59 UTC (rev 11213)
@@ -33,7 +33,7 @@
$options = UserlogRequest::getArray("options");
$engine = UserlogRequest::getString('engine',$Userlog->getConfig("engine"));
-$file = UserlogRequest::getArray('file', '');
+$file = UserlogRequest::getArray('file', $Userlog->getConfig("file"));
$opentry = UserlogRequest::getString('op', '', 'post');
$log_id = UserlogRequest::getArray('log_id', 0 , 'post');
$logsetObj = UserlogSetting::getInstance();
Modified: XoopsModules/userlog/trunk/userlog/admin/menu.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/menu.php 2013-03-12 02:58:29 UTC (rev 11212)
+++ XoopsModules/userlog/trunk/userlog/admin/menu.php 2013-03-12 10:39:59 UTC (rev 11213)
@@ -47,6 +47,11 @@
$adminmenu[$i]["icon"] = '../../' . $pathIcon32 . '/content.png';
$i++;
+$adminmenu[$i]['title'] = _AM_USERLOG_ADMENU_FILE;
+$adminmenu[$i]['link'] = "admin/file.php";
+$adminmenu[$i]["icon"] = '../../' . $pathIcon32 . '/compfile.png';
+
+$i++;
$adminmenu[$i]['title'] = _AM_USERLOG_ADMENU_STATS;
$adminmenu[$i]['link'] = "admin/stats.php";
$adminmenu[$i]["icon"] = '../../' . $pathIcon32 . '/stats.png';
Modified: XoopsModules/userlog/trunk/userlog/admin/setting.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/setting.php 2013-03-12 02:58:29 UTC (rev 11212)
+++ XoopsModules/userlog/trunk/userlog/admin/setting.php 2013-03-12 10:39:59 UTC (rev 11213)
@@ -121,10 +121,7 @@
case "default":
default:
// get all dirnames for scope
- $module_handler =& xoops_gethandler('module');
- $criteria = new CriteriaCompo();
- $criteria->add(new Criteria('isactive', 1));
- $modules = $module_handler->getObjects($criteria, true); // id_as_key = true, asobject = false
+ $modules = $Userlog->getModules();
foreach($modules as $module) {
$dirNames[$module->dirname()] = $module->name();
}
Modified: XoopsModules/userlog/trunk/userlog/admin/stats.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/stats.php 2013-03-12 02:58:29 UTC (rev 11212)
+++ XoopsModules/userlog/trunk/userlog/admin/stats.php 2013-03-12 10:39:59 UTC (rev 11213)
@@ -51,12 +51,7 @@
$criteria = new CriteriaCompo();
$criteria->setGroupby("module");
$moduleViews = $Userlog->getHandler('log')->getCounts($criteria);
-$module_handler =& xoops_gethandler('module');
-$criteria = new CriteriaCompo();
-foreach(array_keys($moduleViews) as $mDir) {
- $criteria->add(new Criteria('dirname', $mDir), "OR");
-}
-$modulesObj = $module_handler->getObjects($criteria, true); // id_as_key = true, asobject = false
+$modulesObj = $Userlog->getModules(array_keys($moduleViews));
foreach($modulesObj as $mObj) {
$mDir = $mObj->dirname();
$indexAdmin->addInfoBoxLine(_AM_USERLOG_VIEW_MODULE,
Modified: XoopsModules/userlog/trunk/userlog/blocks/views.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/blocks/views.php 2013-03-12 02:58:29 UTC (rev 11212)
+++ XoopsModules/userlog/trunk/userlog/blocks/views.php 2013-03-12 10:39:59 UTC (rev 11213)
@@ -111,12 +111,7 @@
list($loglogsObj, $itemViews) = $Userlog->getHandler('log')->getLogsCounts($criteria,$fields);
$criteria->setGroupby("module");
$moduleViews = $Userlog->getHandler('log')->getCounts($criteria);
- $module_handler =& xoops_gethandler('module');
- $criteria = new CriteriaCompo();
- foreach(array_keys($moduleViews) as $module) {
- $criteria->add(new Criteria('dirname', $module), "OR");
- }
- $modules = $module_handler->getObjects($criteria, true); // id_as_key = true, asobject = false
+ $modules = $Userlog->getModules(array_keys($moduleViews));
foreach($modules as $module) {
$moduleNames[$module->dirname()] = $module->name();
}
@@ -177,6 +172,8 @@
$viewsEle = new XoopsFormCheckBox(_MB_USERLOG_BLOCK_ITEMS, "options[{$i}][]", $options_views);
$viewsEle->columns = 3;
$viewsEle->addOptionArray($hasviews);
+ $check_all = _ALL . ": <input type=\"checkbox\" name=\"item_check\" id=\"item_check\" value=\"1\" onclick=\"xoopsCheckGroup('blockform', 'item_check','options[{$i}][]');\" />"; // blockform is the main form
+ $viewsEle = new XoopsFormLabel(_MB_USERLOG_BLOCK_ITEMS, $check_all ."<br\>". $viewsEle->render());
$viewsEle->setDescription(_MB_USERLOG_BLOCK_ITEMS_DSC);
$i++;
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-12 02:58:29 UTC (rev 11212)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-12 10:39:59 UTC (rev 11213)
@@ -154,7 +154,7 @@
if (filesize($log_file) > $this->userlog->getConfig('maxlogfilesize')) {
$old_file = $log_file_name ."_".date('Y-m-d_H-i-s') . "." . $this->userlog->logext;
if(!$result=rename($log_file, $old_file)) {
- $this->setErrors('ERROR renaming ({$log_file_name})');
+ $this->setErrors("ERROR renaming ({$log_file})");
return false;
}
}
@@ -164,7 +164,7 @@
// force to create file if not exist
if(!$fileHandler->exists()) {
$fileHandler->XoopsFileHandler($log_file, true); // create file and folder
- $this->setErrors('File was not exist create file ({$log_file_name})');
+ $this->setErrors("File was not exist create file ({$log_file})");
// update the new file in database
$statsObj = UserlogStats::getInstance();
$statsObj->update("file", 0, 0, false, $log_file); // value = 0 to not auto increment
@@ -179,16 +179,26 @@
}
$data .= json_encode($tolog, (phpversion() > "5.4.0") ? JSON_UNESCAPED_UNICODE : 0);
if ($fileHandler->open("a") == false) {
- $this->setErrors('Cannot open file ({$log_file_name})');
+ $this->setErrors("Cannot open file ({$log_file})");
return false;
}
if ($fileHandler->write($data) == false) {
- $this->setErrors('Cannot write to file ({$log_file_name})');
+ $this->setErrors("Cannot write to file ({$log_file})");
return false;
}
$fileHandler->close();
return true;
}
+ public function exportFilesToCsv($log_file, $headers, $csvNamePrefix="list_", $delimiter=";")
+ {
+ list($logs, $totalLogs) = $this->getLogsFromFiles($log_file);
+ $logs = $this->arrayToDisplay($logs);
+ $csvNamePrefix = basename($csvNamePrefix);
+ if($csvFile = $this->exportLogsToCsv($logs, $headers, $csvNamePrefix . "from_file_total_" . $totalLogs ,$delimiter)) {
+ return $csvFile;
+ }
+ return false;
+ }
public function exportLogsToCsv($logs, $headers, $csvNamePrefix="list_", $delimiter=";")
{
$csvFile = $this->userlog->getConfig("logfilepath") . "/" . USERLOG_DIRNAME . "/export/csv/" . $csvNamePrefix . "_" . date('Y-m-d_H-i-s') . ".csv";
@@ -198,10 +208,10 @@
// force to create file if not exist
if(!$fileHandler->exists()) {
$fileHandler->XoopsFileHandler($csvFile, true); // create file and folder
- $this->setErrors('File was not exist create file ({$csvFile})');
+ $this->setErrors("File was not exist create file ({$csvFile})");
}
if ($fileHandler->open("a") == false) {
- $this->setErrors('Cannot open file ({$csvFile})');
+ $this->setErrors("Cannot open file ({$csvFile})");
return false;
}
if(!fputcsv($fileHandler->handle, $headers, $delimiter)) return false;
@@ -223,7 +233,7 @@
if (!is_array($logArr) || !array_key_exists("log_id", $logArr)) continue;
foreach ($logArr as $option=>$logvalue) {
// value array to string
- $logs[$id][$option] = (is_array($logvalue) && count($logvalue) > 0) ? var_export($logvalue, true) : $logvalue;
+ $logs[$id][$option] = (is_array($logvalue)) ? ( (count($logvalue) > 0) ? var_export($logvalue, true) : '' ) : $logvalue;
}
}
// START Criteria in array
@@ -348,7 +358,39 @@
}
return $logs;
}
-
+ public function mergeFiles($log_files = array(), $mergeFileName = null)
+ {
+ $logs = array();
+ $logsStr = $this->readFiles($log_files);
+ $data = implode("\n",$logsStr);
+ $mergeFile = $this->userlog->getConfig('logfilepath') .'/'. USERLOG_DIRNAME . '/';
+ $mergeFileName = basename($mergeFileName, "." . $this->userlog->logext);
+ if (empty($mergeFileName)) {
+ $mergeFile .= $this->userlog->getConfig('logfilename') . "_merge_" . count($log_files) . "_files_" . date('Y-m-d_H-i-s');
+ } else {
+ $mergeFile .= $mergeFileName;
+ }
+ $mergeFile .= "." . $this->userlog->logext;
+
+ // file create/open/write
+ $fileHandler = XoopsFile::getHandler();
+ $fileHandler->XoopsFileHandler($mergeFile, false); //to see if file exist
+ if($fileHandler->exists()) {
+ $this->setErrors("file ({$mergeFile}) is exist");
+ return false;
+ }
+ $fileHandler->XoopsFileHandler($mergeFile, true); // create file and folder
+ if ($fileHandler->open("a") == false) {
+ $this->setErrors("Cannot open file ({$mergeFile})");
+ return false;
+ }
+ if ($fileHandler->write($data) == false) {
+ $this->setErrors("Cannot write to file ({$mergeFile})");
+ return false;
+ }
+ $fileHandler->close();
+ return $mergeFile;
+ }
public function readFile($log_file = null)
{
if (!$log_file) {
@@ -359,23 +401,152 @@
// not create file if not exist
$fileHandler->XoopsFileHandler($log_file, false);
if (!$fileHandler->exists()) {
- $this->setErrors('Cannot open file ({$log_file_name})');
+ $this->setErrors("Cannot open file ({$log_file})");
return false;
}
if (($data = $fileHandler->read()) == false) {
- $this->setErrors('Cannot read file ({$log_file_name})');
+ $this->setErrors("Cannot read file ({$log_file})");
return false;
}
$logs = explode("\n",$data);
return $logs;
}
- public function buildFileSelectEle($currentFile = null, $multi = false)
+ public function deleteFiles($log_files = array())
{
+ $deletedFiles = 0;
+ if (count($log_files) == 0) {
+ $this->setErrors("No file to delete");
+ return false;
+ }
+ // file open/read
+ $fileHandler = XoopsFile::getHandler();
+ foreach($log_files as $file) {
+ $fileHandler->XoopsFileHandler($file, false);
+ if (!$fileHandler->exists()) {
+ $this->setErrors("({$file}) is a folder or is not exist");
+ continue;
+ }
+ if (($ret = $fileHandler->delete()) == false) {
+ $this->setErrors("Cannot delete ({$file})");
+ continue;
+ }
+ $deletedFiles++;
+ }
+ return $deletedFiles;
+ }
+ public function renameFile($log_file = null, $newFileName = null)
+ {
+ if (!is_string($log_file)) {
+ $this->setErrors(_AM_USERLOG_FILE_SELECT_ONE);
+ return false;
+ }
+ // check if file exist
+ $fileHandler = XoopsFile::getHandler();
+ $fileHandler->XoopsFileHandler($log_file, false);
+ if (!$fileHandler->exists()) {
+ $this->setErrors("({$log_file}) is a folder or is not exist");
+ return false;
+ }
+
+ $newFileName = basename($newFileName, "." . $this->userlog->logext);
+ if (empty($newFileName)) {
+ $newFileName = $fileHandler->name() . "_rename_" . date('Y-m-d_H-i-s');
+ }
+ $newFile = dirname($log_file) . "/" . $newFileName . "." . $this->userlog->logext;
+ // check if new file exist => return false
+ $fileHandler->XoopsFileHandler($newFile, false);
+ if ($fileHandler->exists()) {
+ $this->setErrors("({$newFile}) is exist");
+ return false;
+ }
+ if (!@rename($log_file, $newFile)) {
+ $this->setErrors("Cannot rename ({$file})");
+ return false;
+ }
+ return $newFile;
+ }
+ public function copyFile($log_file = null, $newFileName = null)
+ {
+ if (!is_string($log_file)) {
+ $this->setErrors(_AM_USERLOG_FILE_SELECT_ONE);
+ return false;
+ }
+ // check if file exist
+ $fileHandler = XoopsFile::getHandler();
+ $fileHandler->XoopsFileHandler($log_file, false);
+ if (!$fileHandler->exists()) {
+ $this->setErrors("({$log_file}) is a folder or is not exist");
+ return false;
+ }
+
+ $newFileName = basename($newFileName, "." . $this->userlog->logext);
+ if (empty($newFileName)) {
+ $newFileName = $fileHandler->name() . "_copy_" . date('Y-m-d_H-i-s');
+ }
+ $newFile = dirname($log_file) . "/" . $newFileName . "." . $this->userlog->logext;
+ // check if new file exist => return false
+ $fileHandler->XoopsFileHandler($newFile, false);
+ if ($fileHandler->exists()) {
+ $this->setErrors("({$newFile}) is exist");
+ return false;
+ }
+ if (!@copy($log_file, $newFile)) {
+ $this->setErrors("Cannot rename ({$file})");
+ return false;
+ }
+ return $newFile;
+ }
+ public function zipFiles($log_files = array(), $zipFileName = null)
+ {
+ // file open/read
+ $fileHandler = XoopsFile::getHandler();
+ foreach($log_files as $key=>$file) {
+ $fileHandler->XoopsFileHandler($file, false);
+ if (!$fileHandler->exists()) {
+ $this->setErrors("({$file}) is a folder or is not exist");
+ unset($log_files[$key]);
+ continue;
+ }
+ }
+ if( ($totalFiles = count($log_files)) == 0) {
+ $this->setErrors("No file to zip");
+ return false;
+ }
+ //this folder must be writeable by the server
+ $zipFolder = $this->userlog->getConfig('logfilepath') .'/'. USERLOG_DIRNAME . '/zip';
+ $folderHandler = XoopsFile::getHandler("folder",$zipFolder, true);// create if not exist
+ $zipFileName = basename($zipFileName, ".zip");
+ if (empty($zipFileName)) {
+ $zipFileName = $this->userlog->getConfig('logfilename') . "_zip_" . $totalFiles . "_files_" . date('Y-m-d_H-i-s') . ".zip";
+ } else {
+ $zipFileName = $zipFileName . ".zip";
+ }
+ $zipFile = $zipFolder . "/" . $zipFileName;
+
+ $zip = new ZipArchive();
+
+ if ($zip->open($zipFile, ZIPARCHIVE::CREATE)!==TRUE)
+ {
+ $this->setErrors("Cannot open ({$zipFile})");
+ return false;
+ }
+ foreach($log_files as $file) {
+ if(!$zip->addFile($file, basename($file))) {
+ $this->setErrors("Cannot zip ({$file})");
+ }
+ }
+ $this->setErrors("Number of files operated in zipped file: ({$zip->numFiles})");
+ //$this->setErrors("Zip file name: ({$zip->filename})");
+ $zip->close();
+ return $zipFile;
+ }
+ public function buildFileSelectEle($currentFile = null, $multi = false, $size = 3)
+ {
if (empty($currentFile[0])) {
$currentFile = $this->userlog->getWorkingFile();
}
- $fileEl = new XoopsFormSelect(_AM_USERLOG_FILE,"file", $currentFile, 3, $multi);
+ $fileEl = new XoopsFormSelect(_AM_USERLOG_FILE,"file", $currentFile, $size, $multi);
list($allFiles,$totalFiles) = $this->userlog->getAllLogFiles();
if (empty($totalFiles)) return $fileEl;
$log_file_name = $this->userlog->getConfig('logfilename');
Modified: XoopsModules/userlog/trunk/userlog/class/userlog.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-03-12 02:58:29 UTC (rev 11212)
+++ XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-03-12 10:39:59 UTC (rev 11213)
@@ -64,7 +64,23 @@
}
return $this->logmodule;
}
-
+ public function &getModules($dirnames = array(), $otherCriteria = null)
+ {
+ // get all dirnames
+ $module_handler =& xoops_gethandler('module');
+ $criteria = new CriteriaCompo();
+ if(count($dirnames) > 0) {
+ foreach($dirnames as $mDir) {
+ $criteria->add(new Criteria('dirname', $mDir), "OR");
+ }
+ }
+ if (!empty($otherCriteria)) {
+ $criteria->add($otherCriteria);
+ }
+ $criteria->add(new Criteria('isactive', 1), "AND");
+ $modules = $module_handler->getObjects($criteria, true);
+ return $modules;
+ }
public function &getUser()
{
if ($this->user == null) {
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-12 02:58:29 UTC (rev 11212)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-12 10:39:59 UTC (rev 11213)
@@ -1,5 +1,7 @@
Userlog
Changelog:
+- add filemanager to delete/rename/copy/merge/zip/export-csv log files(2013/03/12)
+- add getModules function, add check all items in views block (2013/03/12)
- add export to csv. add statistics page. rewrite views functions (2013/03/11)
- add more GUI facilities to admin/logs.php. a complete toggle formhead can remember the last status for each admin, reset button, up/down. (2013/03/07)
- add number of items to display and fix script_name bug in views block.(2013/03/05)
Modified: XoopsModules/userlog/trunk/userlog/language/english/admin.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-12 02:58:29 UTC (rev 11212)
+++ XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-12 10:39:59 UTC (rev 11213)
@@ -24,8 +24,11 @@
define("_AM_USERLOG_ADMENU_INDEX","Home");
define("_AM_USERLOG_ADMENU_SETTING","Setting");
define("_AM_USERLOG_ADMENU_LOGS","Logs");
+define("_AM_USERLOG_ADMENU_FILE","File manager");
define("_AM_USERLOG_ADMENU_STATS","Statistics");
define("_AM_USERLOG_ABOUT","About");
+// general error
+define("_AM_USERLOG_ERROR","An error occured during the operation. %1\$s");
// setting.php loglog object options
define("_AM_USERLOG_LOG_ID","Log ID");
@@ -229,4 +232,22 @@
define("_AM_USERLOG_SUMMARY","Some examples of criteria you can use to get logs");
define("_AM_USERLOG_SUMMARY_DELETED","Deleted items from your database");
define("_AM_USERLOG_SUMMARY_ADMIN","Admin user activities");
-define("_AM_USERLOG_SUMMARY_GOOGLE","Users who come to your site from Google.");
\ No newline at end of file
+define("_AM_USERLOG_SUMMARY_GOOGLE","Users who come to your site from Google.");
+
+// file.php
+define("_AM_USERLOG_FILE_ACTION","Select one action");
+define("_AM_USERLOG_FILE_SELECT_ONE","You must select one file.");
+define("_AM_USERLOG_FILE_RENAME","Rename");
+define("_AM_USERLOG_FILE_COPY","Copy");
+define("_AM_USERLOG_FILE_ZIP","Compress(Zip)");
+define("_AM_USERLOG_FILE_MERGE","Merge");
+define("_AM_USERLOG_FILE_EXPORT_CSV","Export to CSV");
+define("_AM_USERLOG_FILE_FILENAME","Enter the result file name. e.g.: myfile");
+define("_AM_USERLOG_FILE_FILENAME_DSC","Advise: Leave it empty to auto generate by using the current criteria and date. If you enter an already existed file name for zip file, new files will be added/overwritten in old archive file.");
+define("_AM_USERLOG_FILE_MERGE_SUCCESS","%1\$d files merged successfully into %2\$s");
+define("_AM_USERLOG_FILE_DELETE_SUCCESS","%1\$d files deleted successfully.");
+define("_AM_USERLOG_FILE_RENAME_SUCCESS","file %1\$s renamed successfully into %2\$s");
+define("_AM_USERLOG_FILE_COPY_SUCCESS","file %1\$s copied successfully into %2\$s");
+define("_AM_USERLOG_FILE_ZIP_SUCCESS","%1\$d files zipped successfully into %2\$s");
+define("_AM_USERLOG_FILE_EXOPORT_SUCCESS","%1\$d files exported successfully into %2\$s");
+define("_AM_USERLOG_FILE_CONFIRM","Are you sure you want to do this action?");
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/language/english/help/help.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-03-12 02:58:29 UTC (rev 11212)
+++ XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-03-12 10:39:59 UTC (rev 11213)
@@ -50,10 +50,22 @@
<h4 class="odd">Logs</h4>
<p class="even">
-You can see/delete/purge users logs through the Admin section of the userlog Module.<br /><br />
+You can see/delete/purge/export users logs through the Admin section of the userlog Module.<br /><br />
You can get logs from database or file source engine.<br /><br />
To search for logs based on a criteria you have an advance form.<br /><br />
+Export files will be stored in "the working path"/export folder.<br /><br />
</p>
+<h4 class="odd">File manager</h4>
+<p class="even">
+You can see/delete/rename/copy/merge/compress(zip)/export users log files through the file manager of the userlog Module.<br /><br />
+Zip files will be stored in "the working path"/zip folder.<br /><br />
+Export files will be stored in "the working path"/export folder. <br /><br />
+You can select a name for your result (e.g.: copied file) but if you leave that empty, userlog will generate an automatic name by using the current criteria and date.<br /><br />
+The difference between The file manager section and logs section when you select file engine is, in logs section you dynamically work with files data and can see them rows by rows in detail but in file manager you just can work on the whole data in files.<br /><br />
+For example in logs section you can select some rows to export but in file manager you just can export whole data from some selected files.<br /><br />
+<b>Attention: If you work on too many files at once you may end up a white screen. It is because the server runs out of memory and/or cpu.</b>
+</p>
+
<h4 class="odd">Views block</h4>
<p class="even">
Many XOOPS users have a wish for a block to see most viewed items in a module or in the whole website in a specific period of time.<br /><br />
@@ -62,4 +74,4 @@
<br /><br />
</p>
-</div>
+</div>
\ No newline at end of file
Added: XoopsModules/userlog/trunk/userlog/templates/userlog_admin_file.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/templates/userlog_admin_file.html (rev 0)
+++ XoopsModules/userlog/trunk/userlog/templates/userlog_admin_file.html 2013-03-12 10:39:59 UTC (rev 11213)
@@ -0,0 +1,2 @@
+<{$logo}>
+<{$form}>
Modified: XoopsModules/userlog/trunk/userlog/xoops_version.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-03-12 02:58:29 UTC (rev 11212)
+++ XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-03-12 10:39:59 UTC (rev 11213)
@@ -84,6 +84,10 @@
$modversion['templates'][$i]['description'] = 'list of userlog logs';
$i++;
+$modversion['templates'][$i]['file'] = 'userlog_admin_file.html';
+$modversion['templates'][$i]['description'] = 'File manager';
+
+$i++;
$modversion['templates'][$i]['file'] = 'userlog_admin_stats.html';
$modversion['templates'][$i]['description'] = 'Logs Statistics';
|
|
From: <ir...@us...> - 2013-03-12 11:32:53
|
Revision: 11214
http://sourceforge.net/p/xoops/svn/11214
Author: irmtfan
Date: 2013-03-12 11:32:50 +0000 (Tue, 12 Mar 2013)
Log Message:
-----------
fix bugs:
1- post method for confirm request var
2- sort/order for views
3- filesize to $fileHandler->size()
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/file.php
XoopsModules/userlog/trunk/userlog/blocks/views.php
XoopsModules/userlog/trunk/userlog/class/log.php
Modified: XoopsModules/userlog/trunk/userlog/admin/file.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/file.php 2013-03-12 10:39:59 UTC (rev 11213)
+++ XoopsModules/userlog/trunk/userlog/admin/file.php 2013-03-12 11:32:50 UTC (rev 11214)
@@ -32,7 +32,7 @@
$file = UserlogRequest::getArray('file', $Userlog->getConfig("file"));
$opentry = UserlogRequest::getString('op', '');
$filename = UserlogRequest::getString('filename', '');
-$confirm = UserlogRequest::getString('confirm',0);
+$confirm = UserlogRequest::getString('confirm',0, 'post');
$totalFiles = count($file);
if(!empty($opentry) && ($confirm == 0 || $totalFiles == 0)) {
redirect_header("file.php", 5, sprintf(_AM_USERLOG_ERROR,""));
Modified: XoopsModules/userlog/trunk/userlog/blocks/views.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/blocks/views.php 2013-03-12 10:39:59 UTC (rev 11213)
+++ XoopsModules/userlog/trunk/userlog/blocks/views.php 2013-03-12 11:32:50 UTC (rev 11214)
@@ -105,11 +105,14 @@
$criteria->add($criteriaGroup);
}
$criteria->setLimit($options[0]);
+ $criteria->setSort(($options[5] == "views") ? "count" : "module");
+ $criteria->setOrder($options[6]);
$fields = array("uid","groups","pagetitle","module","script","item_name","item_id");
$criteria->setGroupby("module,script,item_name,item_id");
list($loglogsObj, $itemViews) = $Userlog->getHandler('log')->getLogsCounts($criteria,$fields);
$criteria->setGroupby("module");
+ $criteria->setSort(($options[5] == "module_views") ? "count" : "module");
$moduleViews = $Userlog->getHandler('log')->getCounts($criteria);
$modules = $Userlog->getModules(array_keys($moduleViews));
foreach($modules as $module) {
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-12 10:39:59 UTC (rev 11213)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-12 11:32:50 UTC (rev 11214)
@@ -150,17 +150,17 @@
public function storeFile($tolog)
{
$log_file = $this->userlog->getWorkingFile();
- $log_file_name = $this->userlog->getConfig('logfilepath') .'/'. USERLOG_DIRNAME . '/' . $this->userlog->getConfig('logfilename');
- if (filesize($log_file) > $this->userlog->getConfig('maxlogfilesize')) {
+ // file create/open/write
+ $fileHandler = XoopsFile::getHandler();
+ $fileHandler->XoopsFileHandler($log_file, false);
+ if ($fileHandler->size() > $this->userlog->getConfig('maxlogfilesize')) {
+ $log_file_name = $this->userlog->getConfig('logfilepath') .'/'. USERLOG_DIRNAME . '/' . $this->userlog->getConfig('logfilename');
$old_file = $log_file_name ."_".date('Y-m-d_H-i-s') . "." . $this->userlog->logext;
if(!$result=rename($log_file, $old_file)) {
$this->setErrors("ERROR renaming ({$log_file})");
return false;
}
}
- // file create/open/write
- $fileHandler = XoopsFile::getHandler();
- $fileHandler->XoopsFileHandler($log_file, false);
// force to create file if not exist
if(!$fileHandler->exists()) {
$fileHandler->XoopsFileHandler($log_file, true); // create file and folder
@@ -623,6 +623,9 @@
if ($groupby = $criteria->getGroupby()) {
$sql .= $groupby;
}
+ if ($sort = $criteria->getSort()) {
+ $sql .= " ORDER BY {$sort} " . $criteria->getOrder();
+ }
$limit = $criteria->getLimit();
$start = $criteria->getStart();
}
|
|
From: <ir...@us...> - 2013-03-12 12:02:20
|
Revision: 11215
http://sourceforge.net/p/xoops/svn/11215
Author: irmtfan
Date: 2013-03-12 12:02:17 +0000 (Tue, 12 Mar 2013)
Log Message:
-----------
fix bug: $Userlog should be $this->userlog
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/file.php
XoopsModules/userlog/trunk/userlog/class/log.php
Modified: XoopsModules/userlog/trunk/userlog/admin/file.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/file.php 2013-03-12 11:32:50 UTC (rev 11214)
+++ XoopsModules/userlog/trunk/userlog/admin/file.php 2013-03-12 12:02:17 UTC (rev 11215)
@@ -51,7 +51,7 @@
redirect_header("file.php", 5, sprintf(_AM_USERLOG_ERROR,_AM_USERLOG_FILE_SELECT_ONE));
}
if ($newFile = $loglogObj->renameFile($file[0], $filename)) {
- redirect_header("file.php", 700, sprintf(_AM_USERLOG_FILE_RENAME_SUCCESS,$file[0], $newFile));
+ redirect_header("file.php", 5, sprintf(_AM_USERLOG_FILE_RENAME_SUCCESS,$file[0], $newFile));
}
redirect_header("file.php", 5, sprintf(_AM_USERLOG_ERROR,implode("<br\>",$loglogObj->getErrors())));
break;
@@ -61,7 +61,7 @@
redirect_header("file.php", 5, sprintf(_AM_USERLOG_ERROR,_AM_USERLOG_FILE_SELECT_ONE));
}
if ($newFile = $loglogObj->copyFile($file[0], $filename)) {
- redirect_header("file.php", 700, sprintf(_AM_USERLOG_FILE_COPY_SUCCESS,$file[0], $newFile));
+ redirect_header("file.php", 5, sprintf(_AM_USERLOG_FILE_COPY_SUCCESS,$file[0], $newFile));
}
redirect_header("file.php", 5, sprintf(_AM_USERLOG_ERROR,implode("<br\>",$loglogObj->getErrors())));
break;
@@ -113,7 +113,7 @@
$submitEl = new XoopsFormButton(_SUBMIT, 'submitfilemanager', _SUBMIT, 'submit');
$form->addElement($submitEl);
$confirmEl = new XoopsFormHidden("confirm",0);
-$confirmEl->customValidationCode[]="if(confirm('" . _AM_USERLOG_FILE_CONFIRM . "' + ' action=' + myform.op.value)) {myform.confirm.value = 1;} else {return false;};";
+$confirmEl->customValidationCode[]="if(confirm('" . _AM_USERLOG_FILE_CONFIRM . "' + ' action=' + myform.op.value + ' ' + myform.file.value)) {myform.confirm.value = 1;} else {return false;};";
$form->addElement($confirmEl);
$GLOBALS['xoopsTpl']->assign('form', $form->render());
$GLOBALS['xoopsTpl']->assign('logo',$indexAdmin->addNavigation('file.php'));
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-12 11:32:50 UTC (rev 11214)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-12 12:02:17 UTC (rev 11215)
@@ -280,7 +280,7 @@
// if there is one value - deal with =, > ,<
if (count($val_arr) == 1) {
$val_int = $val_arr[0];
- if($op == "log_time" || $op == "last_login") $val_int = time() - $Userlog->getSinceTime($val_int);
+ if($op == "log_time" || $op == "last_login") $val_int = time() - $this->userlog->getSinceTime($val_int);
// query is one int $t (=, < , >)
foreach ($logs as $id => $log) {
switch ($tt) {
|
|
From: <ir...@us...> - 2013-03-14 02:11:10
|
Revision: 11225
http://sourceforge.net/p/xoops/svn/11225
Author: irmtfan
Date: 2013-03-14 02:11:06 +0000 (Thu, 14 Mar 2013)
Log Message:
-----------
fix bugs:
1- notices when moduleViews is empty (no logs is exist) in admin/stats.php (Cesag)
2- Fatal error after installation in admin/menu.php (Cesag)
3- Warning: array_multisort() [function.array-multisort]: Argument #1 is expected to be an array or a sort flag in file. It is when no logs is exist (Cesag)
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/menu.php
XoopsModules/userlog/trunk/userlog/admin/stats.php
XoopsModules/userlog/trunk/userlog/blocks/views.php
XoopsModules/userlog/trunk/userlog/class/log.php
Modified: XoopsModules/userlog/trunk/userlog/admin/menu.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/menu.php 2013-03-13 22:02:36 UTC (rev 11224)
+++ XoopsModules/userlog/trunk/userlog/admin/menu.php 2013-03-14 02:11:06 UTC (rev 11225)
@@ -61,6 +61,7 @@
$adminmenu[$i]['link'] = "admin/about.php";
$adminmenu[$i]["icon"] = '../../' . $pathIcon32 . '/about.png';
// add js, css, toggle_cookie to admin pages
+include_once dirname(dirname(__FILE__)) . '/include/common.php'; // after installtion it will included before admin_header.php
global $xoTheme;
$Userlog = Userlog::getInstance(false);
$xoTheme->addScript("modules/" . USERLOG_DIRNAME . "/templates/js/" . USERLOG_DIRNAME . ".js");
Modified: XoopsModules/userlog/trunk/userlog/admin/stats.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/stats.php 2013-03-13 22:02:36 UTC (rev 11224)
+++ XoopsModules/userlog/trunk/userlog/admin/stats.php 2013-03-14 02:11:06 UTC (rev 11225)
@@ -47,17 +47,19 @@
$arr2["value"] ? 'GREEN' : 'RED');
}
}
-$indexAdmin->addInfoBox(_AM_USERLOG_VIEW_MODULE);
$criteria = new CriteriaCompo();
$criteria->setGroupby("module");
$moduleViews = $Userlog->getHandler('log')->getCounts($criteria);
-$modulesObj = $Userlog->getModules(array_keys($moduleViews));
-foreach($modulesObj as $mObj) {
- $mDir = $mObj->dirname();
- $indexAdmin->addInfoBoxLine(_AM_USERLOG_VIEW_MODULE,
- $mObj->name() . ": %s",
- $moduleViews[$mDir],
- $moduleViews[$mDir]? 'GREEN' : 'RED');
+if (!empty($moduleViews)) {
+ $indexAdmin->addInfoBox(_AM_USERLOG_VIEW_MODULE);
+ $modulesObj = $Userlog->getModules(array_keys($moduleViews));
+ foreach($modulesObj as $mObj) {
+ $mDir = $mObj->dirname();
+ $indexAdmin->addInfoBoxLine(_AM_USERLOG_VIEW_MODULE,
+ $mObj->name() . ": %s",
+ $moduleViews[$mDir],
+ $moduleViews[$mDir]? 'GREEN' : 'RED');
+ }
}
$GLOBALS['xoopsTpl']->assign('stats_abstract',$indexAdmin->renderInfoBox());
$GLOBALS['xoopsTpl']->assign('logo',$indexAdmin->addNavigation('stats.php'));
Modified: XoopsModules/userlog/trunk/userlog/blocks/views.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/blocks/views.php 2013-03-13 22:02:36 UTC (rev 11224)
+++ XoopsModules/userlog/trunk/userlog/blocks/views.php 2013-03-14 02:11:06 UTC (rev 11225)
@@ -136,7 +136,9 @@
$col1[$link] = $item[$options[5]];
$col2[$link] = $item["views"];//second sort by
}
- array_multisort($col1, ($options[6] == "ASC") ? SORT_ASC : SORT_DESC ,$col2 ,SORT_DESC, $items);
+ if ( !empty($items) ) {
+ array_multisort($col1, ($options[6] == "ASC") ? SORT_ASC : SORT_DESC ,$col2 ,SORT_DESC, $items);
+ }
$block["items"] = $items;
$block["sort"] = $options[5];
unset($loglogsObj,$items);
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-13 22:02:36 UTC (rev 11224)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-14 02:11:06 UTC (rev 11225)
@@ -409,6 +409,7 @@
$this->setErrors("Cannot read file ({$log_file})");
return false;
}
+ $fileHandler->close();
$logs = explode("\n",$data);
return $logs;
}
@@ -433,6 +434,7 @@
}
$deletedFiles++;
}
+ $fileHandler->close();
return $deletedFiles;
}
public function renameFile($log_file = null, $newFileName = null)
@@ -464,6 +466,7 @@
$this->setErrors("Cannot rename ({$file})");
return false;
}
+ $fileHandler->close();
return $newFile;
}
public function copyFile($log_file = null, $newFileName = null)
@@ -492,9 +495,10 @@
return false;
}
if (!@copy($log_file, $newFile)) {
- $this->setErrors("Cannot rename ({$file})");
+ $this->setErrors("Cannot copy ({$log_file})");
return false;
}
+ $fileHandler->close();
return $newFile;
}
public function zipFiles($log_files = array(), $zipFileName = null)
@@ -509,6 +513,7 @@
continue;
}
}
+ $fileHandler->close();
if( ($totalFiles = count($log_files)) == 0) {
$this->setErrors("No file to zip");
return false;
@@ -536,7 +541,10 @@
$this->setErrors("Cannot zip ({$file})");
}
}
- $this->setErrors("Number of files operated in zipped file: ({$zip->numFiles})");
+ // if there are some files existed in zip file and/or some files overwritten
+ if($totalFiles != $zip->numFiles) {
+ $this->setErrors("Number of files operated in zipped file: ({$zip->numFiles})");
+ }
//$this->setErrors("Zip file name: ({$zip->filename})");
$zip->close();
return $zipFile;
|
|
From: <ir...@us...> - 2013-03-19 02:41:49
|
Revision: 11248
http://sourceforge.net/p/xoops/svn/11248
Author: irmtfan
Date: 2013-03-19 02:41:45 +0000 (Tue, 19 Mar 2013)
Log Message:
-----------
- change version to ALPHA 2(2013/03/19)
- enhance admin/logs.php template to show admin(y/n), group names, user link, user ip link to whois, ...(2013/03/19)
- add HomePage to module scope. It will be for all root scripts like ROOT/admin.php(2013/03/19)
- add module name to table logs in database for better performance(2013/03/19)
- add user views, group views, item views form to statistics page(2013/03/19)
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/index.php
XoopsModules/userlog/trunk/userlog/admin/setting.php
XoopsModules/userlog/trunk/userlog/admin/stats.php
XoopsModules/userlog/trunk/userlog/blocks/views.php
XoopsModules/userlog/trunk/userlog/class/log.php
XoopsModules/userlog/trunk/userlog/class/setting.php
XoopsModules/userlog/trunk/userlog/class/userlog.php
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/language/english/admin.php
XoopsModules/userlog/trunk/userlog/language/english/blocks.php
XoopsModules/userlog/trunk/userlog/language/english/help/help.html
XoopsModules/userlog/trunk/userlog/sql/mysql.sql
XoopsModules/userlog/trunk/userlog/templates/blocks/userlog_views.html
XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
XoopsModules/userlog/trunk/userlog/templates/userlog_admin_stats.html
XoopsModules/userlog/trunk/userlog/xoops_version.php
Modified: XoopsModules/userlog/trunk/userlog/admin/index.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/index.php 2013-03-18 23:11:49 UTC (rev 11247)
+++ XoopsModules/userlog/trunk/userlog/admin/index.php 2013-03-19 02:41:45 UTC (rev 11248)
@@ -57,7 +57,7 @@
$arr2["value"] ? 'GREEN' : 'RED');
}
}
-$indexAdmin->addConfigBoxLine($Userlog->getConfig('logfilepath') , 'folder');
+$indexAdmin->addConfigBoxLine(array($Userlog->getConfig('logfilepath'), 755) , 'chmod');
$indexAdmin->addConfigBoxLine("<span class='bold " . ($Userlog->getConfig('status') ? "green" : "red") . "'>" . _MI_USERLOG_STATUS . " " . ($Userlog->getConfig('status') ? _MI_USERLOG_ACTIVE : _MI_USERLOG_IDLE) . "</span>", 'default');
echo $indexAdmin->addNavigation('index.php');
echo $indexAdmin->renderButton();
Modified: XoopsModules/userlog/trunk/userlog/admin/setting.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/setting.php 2013-03-18 23:11:49 UTC (rev 11247)
+++ XoopsModules/userlog/trunk/userlog/admin/setting.php 2013-03-19 02:41:45 UTC (rev 11248)
@@ -91,9 +91,9 @@
$logsetObj->setVar("name",$name);
$logsetObj->setVar("logby",$logby);
$logsetObj->setVar("unique_id",$unique_id);
- // select views means store uid, groups, script name, pagetitle, module, item name, item id in Database
+ // select views means store uid, groups, script name, pagetitle, module, module_name, item name, item id in Database
if (in_array("views",$option)) {
- $option = array_merge(array("uid", "groups", "script","pagetitle","module","item_name","item_id"),$option);
+ $option = array_merge(array("uid", "groups", "script","pagetitle","module","module_name","item_name","item_id"),$option);
}
// always log id and time
if(!empty($option[0])) {
@@ -121,10 +121,7 @@
case "default":
default:
// get all dirnames for scope
- $modules = $Userlog->getModules();
- foreach($modules as $module) {
- $dirNames[$module->dirname()] = $module->name();
- }
+ $dirNames = $Userlog->getModules();
// unset userlog
//unset($dirNames[USERLOG_DIRNAME]);
// get all settings as array
Modified: XoopsModules/userlog/trunk/userlog/admin/stats.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/stats.php 2013-03-18 23:11:49 UTC (rev 11247)
+++ XoopsModules/userlog/trunk/userlog/admin/stats.php 2013-03-19 02:41:45 UTC (rev 11248)
@@ -26,6 +26,16 @@
$Userlog = Userlog::getInstance(false);
// Where do we start ?
+$startentry = UserlogRequest::getInt('startentry',0);
+$limitentry = UserlogRequest::getInt('limitentry',10);
+$sortentry = UserlogRequest::getString('sortentry','count');
+$orderentry = UserlogRequest::getString('orderentry','DESC');
+$modules = UserlogRequest::getArray("modules");
+$moduleScriptItem = UserlogRequest::getArray("moduleScriptItem");
+$log_timeGT = UserlogRequest::getInt('log_timeGT',1);
+$users = UserlogRequest::getArray("users", -1);
+$groups = UserlogRequest::getArray("groups", 0);
+
// update all time stats
$statsObj = UserlogStats::getInstance();
$statsObj->updateAll("log", 100); // prob = 100
@@ -50,17 +60,143 @@
$criteria = new CriteriaCompo();
$criteria->setGroupby("module");
$moduleViews = $Userlog->getHandler('log')->getCounts($criteria);
+$dirNames = $Userlog->getModules();
if (!empty($moduleViews)) {
$indexAdmin->addInfoBox(_AM_USERLOG_VIEW_MODULE);
- $modulesObj = $Userlog->getModules(array_keys($moduleViews));
- foreach($modulesObj as $mObj) {
- $mDir = $mObj->dirname();
+ foreach($moduleViews as $mDir=>$views) {
$indexAdmin->addInfoBoxLine(_AM_USERLOG_VIEW_MODULE,
- $mObj->name() . ": %s",
- $moduleViews[$mDir],
- $moduleViews[$mDir]? 'GREEN' : 'RED');
+ $dirNames[$mDir] . ": %s",
+ $views,
+ $views? 'GREEN' : 'RED');
}
}
+$criteria = new CriteriaCompo();
+$criteria->setGroupby("uid");
+$criteria->setLimit(10);
+$userViews = $Userlog->getHandler('log')->getCounts($criteria);
+if (!empty($userViews)) {
+ $indexAdmin->addInfoBox(_AM_USERLOG_VIEW_USER);
+ foreach($userViews as $uid=>$views) {
+ $indexAdmin->addInfoBoxLine(_AM_USERLOG_VIEW_USER,
+ (($uid) ? "<a href=\"" . XOOPS_URL . "/userinfo.php?uid=" . $uid . "\">" . XoopsUserUtility::getUnameFromId($uid) . "</a>" : XoopsUserUtility::getUnameFromId(0)) . ": %s",
+ $views,
+ $views? 'GREEN' : 'RED');
+ }
+}
+$criteria = new CriteriaCompo();
+$criteria->setGroupby("groups");
+$criteria->setLimit(10);
+$groupViews = $Userlog->getHandler('log')->getCounts($criteria);
+if (!empty($groupViews)) {
+ $indexAdmin->addInfoBox(_AM_USERLOG_VIEW_GROUP);
+ foreach($groupViews as $gids=>$views) {
+ $groupArr = explode("g", substr($gids, 1)); // remove the first "g" from string
+ foreach($groupArr as $group) {
+ if(isset($gidViews[$group])) {
+ $gidViews[$group] += $views;
+ } else {
+ $gidViews[$group] = $views;
+ }
+ }
+ }
+ $groupNames = $Userlog->getGroupList();
+ foreach($gidViews as $gid=>$views) {
+ $indexAdmin->addInfoBoxLine(_AM_USERLOG_VIEW_GROUP,
+ $groupNames[$gid] . ": %s",
+ $views,
+ $views? 'GREEN' : 'RED');
+ }
+}
+
+// START module - script - item
+$module=array();
+// items
+foreach ($moduleScriptItem as $key=>$item) {
+ $module_script_item = explode('-', $item); // news:article.php-storyid news:index.php-storytopic => $module["news"]=array("storyid","storytopic");
+ $module_script = explode(':', $module_script_item[0]); // news:article.php => $module_script = array(news,article.php);
+ if (!isset($module[$module_script[0]])) {
+ $module[$module_script[0]]["item_name"] = array();
+ $module[$module_script[0]]["script"] = array_slice($module_script,1);
+ }
+ $module[$module_script[0]]["script"] = array_unique(array_merge($module[$module_script[0]]["script"], array_slice($module_script,1)));
+ $module[$module_script[0]]["item_name"][] = $module_script_item[1];
+}
+// add modules dont have item_name
+foreach($modules as $dir) {
+ if(!isset($module[$dir])) $module[$dir] = null;
+}
+// END module - script - item
+$loglogObj = UserlogLog::getInstance();
+
+// get items views
+$items = $loglogObj->getViews($limitentry , $startentry, $sortentry, $orderentry, $module, $log_timeGT, ($users[0] != -1) ? $users : array(), ($groups[0] != 0) ? $groups : array());
+$GLOBALS['xoopsTpl']->assign('sortentry',$sortentry);
+$GLOBALS['xoopsTpl']->assign('items',$items);
+// SRART form
+$form = new XoopsThemeForm(_AM_USERLOG_VIEW,'views','stats.php', 'post');
+// number of items to display element
+$limitEl = new XoopsFormText(_MB_USERLOG_ITEMS_NUM, "limitentry", 10, 255, $limitentry);
+$sortEl = new XoopsFormSelect(_AM_USERLOG_SORT,"sortentry", $sortentry);
+$sortEl->addOptionArray(array(
+ "count"=>_AM_USERLOG_VIEW,
+ "module"=>_AM_USERLOG_MODULE,
+ "module_name"=>_AM_USERLOG_MODULE_NAME,
+ "module_count"=>_AM_USERLOG_VIEW_MODULE
+ ));
+$sortEl->setDescription(_AM_USERLOG_SORT_DSC);
+$orderEl = new XoopsFormSelect(_AM_USERLOG_ORDER,"orderentry", $orderentry);
+$orderEl->addOption("DESC", _DESCENDING);
+$orderEl->addOption("ASC", _ASCENDING);
+$orderEl->setDescription(_AM_USERLOG_ORDER_DSC);
+// modules, items elements
+$moduleObjs = $Userlog->getModules(array(), null, true);
+foreach ($moduleObjs as $mObj) {
+ $dirNames[$mObj->dirname()] = $mObj->name();
+ $not_config = $mObj->getInfo('notification');
+ if (!empty($not_config['category'])) {
+ foreach ($not_config['category'] as $category) {
+ if (!empty($category['item_name'])) {
+ $script = is_array($category["subscribe_from"]) ? implode(":", $category["subscribe_from"]) : $category["subscribe_from"];
+ $itemLinks[$mObj->dirname(). ":" . $script . "-" . $category['item_name']] = $mObj->dirname()."/" . $script ."?".$category['item_name']."=ITEM_ID";
+ }
+ }
+ }
+}
+$moduleEl = new XoopsFormSelect(_AM_USERLOG_MODULES,"modules",$modules,5, true);
+$moduleEl->addOptionArray($dirNames);
+$itemsEl = new XoopsFormSelect(_AM_USERLOG_ITEMS,"moduleScriptItem",$moduleScriptItem,5, true);
+$itemsEl->addOptionArray($itemLinks);
+$itemsEl->setDescription(_AM_USERLOG_ITEMS_DSC);
+
+$timeEl = new XoopsFormText(_AM_USERLOG_LOG_TIMEGT, "log_timeGT", 10, 255, $log_timeGT);
+$timeEl->setDescription(_AM_USERLOG_LOG_TIMEGT_FORM);
+
+$userRadioEl = new XoopsFormRadio(_AM_USERLOG_UID, "users", $users[0]);
+$userRadioEl->addOption(-1,_ALL);
+$userRadioEl->addOption(($users[0] != -1) ? $users[0] : 0,_SELECT); // if no user in selection box it select uid=0 anon users
+$userRadioEl->setExtra("onchange=\"var el=document.getElementById('users'); el.disabled=(this.id == 'users1'); if (!el.value) {el.value= this.value}\""); // if user dont select any option it select "all"
+$userSelectEl = new XoopsFormSelectUser(_AM_USERLOG_UID, "users", true, $users, 3, true);
+$userEl = new XoopsFormLabel(_AM_USERLOG_UID, $userRadioEl->render().$userSelectEl->render());
+
+$groupRadioEl = new XoopsFormRadio(_AM_USERLOG_GROUPS, "groups", $groups[0]);
+$groupRadioEl->addOption(0,_ALL);
+$groupRadioEl->addOption(($groups[0] != 0) ? $groups[0] : 2,_SELECT); // if no group in selection box it select gid=2 registered users
+$groupRadioEl->setExtra("onchange=\"var el=document.getElementById('groups'); el.disabled=(this.id == 'groups1'); if (!el.value) {el.value= this.value}\""); // if group dont select any option it select "all"
+$groupSelectEl = new XoopsFormSelectGroup(_AM_USERLOG_GROUPS, "groups", true, $groups, 3, true);
+$groupEl = new XoopsFormLabel(_AM_USERLOG_GROUPS, $groupRadioEl->render().$groupSelectEl->render());
+
+$submitEl = new XoopsFormButton(_SUBMIT, 'submitlogs', _SUBMIT, 'submit');
+// add all elements to form
+$form->addElement($limitEl);
+$form->addElement($moduleEl);
+$form->addElement($itemsEl);
+$form->addElement($timeEl);
+$form->addElement($userEl);
+$form->addElement($groupEl);
+$form->addElement($sortEl);
+$form->addElement($orderEl);
+$form->addElement($submitEl);
+$GLOBALS['xoopsTpl']->assign('form',$form->render());
$GLOBALS['xoopsTpl']->assign('stats_abstract',$indexAdmin->renderInfoBox());
$GLOBALS['xoopsTpl']->assign('logo',$indexAdmin->addNavigation('stats.php'));
// template
Modified: XoopsModules/userlog/trunk/userlog/blocks/views.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/blocks/views.php 2013-03-18 23:11:49 UTC (rev 11247)
+++ XoopsModules/userlog/trunk/userlog/blocks/views.php 2013-03-19 02:41:45 UTC (rev 11248)
@@ -37,111 +37,28 @@
function userlog_views_show($options)
{
- $Userlog = Userlog::getInstance();
-
+ $loglogObj = UserlogLog::getInstance();
+ $module=array();
if (!empty($options[1])) {
$options_views = explode(',', $options[1]); // item views in where claus eg: news-storyid, newbb-topic_id, news-storytopic
- $module=array();
foreach ($options_views as $key=>$item) {
$module_script_item = explode('-', $item); // news:article.php-storyid news:index.php-storytopic => $module["news"]=array("storyid","storytopic");
$module_script = explode(':', $module_script_item[0]); // news:article.php => $module_script = array(news,article.php);
if (!isset($module[$module_script[0]])) {
- $module[$module_script[0]] = array();
- $scripts[$module_script[0]] = array_slice($module_script,1);
+ $module[$module_script[0]]["item_name"] = array();
+ $module[$module_script[0]]["script"] = array_slice($module_script,1);
}
- $scripts[$module_script[0]] = array_unique(array_merge($scripts[$module_script[0]], array_slice($module_script,1)));
- $module[$module_script[0]][] = $module_script_item[1];
+ $module[$module_script[0]]["script"] = array_unique(array_merge($module[$module_script[0]]["script"], array_slice($module_script,1)));
+ $module[$module_script[0]]["item_name"][] = $module_script_item[1];
}
- $criteriaModule = new CriteriaCompo();
- foreach ($module as $module_dir=>$items) {
- $criteriaItem = new CriteriaCompo();
- $criteriaItem->add(new Criteria('module', $module_dir));
- $criteriaItemName = new CriteriaCompo();
- foreach($items as $item_name) {
- // why we cannot use this $criteriaItemName->add(new Criteria('item_name', $items, "IN"));
- $criteriaItemName->add(new Criteria('item_name', $item_name), "OR");
- }
- $criteriaItem->add($criteriaItemName);
- $criteriaScript = new CriteriaCompo();
- foreach($scripts[$module_dir] as $script_name) {
- $criteriaScript->add(new Criteria('script', $script_name), "OR");
- }
- $criteriaItem->add($criteriaScript);
- $criteriaModule->add($criteriaItem, "OR");
- unset($criteriaItem,$criteriaItemName,$criteriaScript);
- }
}
+ $users = ($options[3] != -1) ? explode(",",$options[3]) : array();
+ $groups = !empty($options[4]) ? explode(",",$options[4]) : array();
- if (!empty($options[2])) {
- $starttime = time() - $Userlog->getSinceTime($options[2]);
- $criteriaSince = new CriteriaCompo();
- $criteriaSince->add(new Criteria('log_time', $starttime ,'>'));
- }
-
- if (!empty($options[3])) {
- $criteriaUser = new CriteriaCompo();
- $criteriaUser->add(new Criteria('uid', '(' . $options[3] . ')', 'IN'));
- }
- if (!empty($options[4])) {
- $criteriaGroup = new CriteriaCompo();
- $options_groups = explode(',', $options[4]); // groups to select
- foreach($options_groups as $group) {
- $criteriaGroup->add(new Criteria("groups", "%g" . $group . "%", "LIKE"), "OR");
- }
- }
-
- // add all criterias
- $criteria = new CriteriaCompo();
- if ( !empty($criteriaModule) ) {
- $criteria->add($criteriaModule);
- }
- if ( !empty($criteriaSince) ) {
- $criteria->add($criteriaSince);
- }
- if ( !empty($criteriaUser) ) {
- $criteria->add($criteriaUser);
- }
- if ( !empty($criteriaGroup) ) {
- $criteria->add($criteriaGroup);
- }
- $criteria->setLimit($options[0]);
- $criteria->setSort(($options[5] == "views") ? "count" : "module");
- $criteria->setOrder($options[6]);
- $fields = array("uid","groups","pagetitle","module","script","item_name","item_id");
- $criteria->setGroupby("module,script,item_name,item_id");
-
- list($loglogsObj, $itemViews) = $Userlog->getHandler('log')->getLogsCounts($criteria,$fields);
- $criteria->setGroupby("module");
- $criteria->setSort(($options[5] == "module_views") ? "count" : "module");
- $moduleViews = $Userlog->getHandler('log')->getCounts($criteria);
- $modules = $Userlog->getModules(array_keys($moduleViews));
- foreach($modules as $module) {
- $moduleNames[$module->dirname()] = $module->name();
- }
- unset($criteria);
- // initializing
- $items = array();; // very important!!!
- foreach($loglogsObj as $key=>$loglogObj) {
- $module_dirname = $loglogObj->module();
- $link = $module_dirname."/".$loglogObj->script()."?".$loglogObj->item_name()."=".$loglogObj->item_id();
- $items[$link] = array();
- $items[$link]["views"] = $itemViews[$key];
- $items[$link]["title"] = $loglogObj->pagetitle();
- $items[$link]["module"] = $module_dirname;
- $items[$link]["module_name"] = $moduleNames[$module_dirname];
- $items[$link]["module_views"] = $moduleViews[$module_dirname];
- }
- $block = array();
- foreach($items as $link=>$item) {
- $col1[$link] = $item[$options[5]];
- $col2[$link] = $item["views"];//second sort by
- }
- if ( !empty($items) ) {
- array_multisort($col1, ($options[6] == "ASC") ? SORT_ASC : SORT_DESC ,$col2 ,SORT_DESC, $items);
- }
+ $items = $loglogObj->getViews($options[0] , 0, $options[5], $options[6], $module, $options[2], $users, $groups);
+ $block = array();
$block["items"] = $items;
$block["sort"] = $options[5];
- unset($loglogsObj,$items);
return $block;
}
@@ -169,36 +86,34 @@
$i=0;
// number of items to display element
- $numitemsEle = new XoopsFormText(_MB_USERLOG_BLOCK_ITEMS_NUM, "options[{$i}]", 10, 255, intval($options[$i]));
+ $numitemsEle = new XoopsFormText(_MB_USERLOG_ITEMS_NUM, "options[{$i}]", 10, 255, intval($options[$i]));
$i++;
// views element
$options_views = explode(',', $options[$i]);
- $viewsEle = new XoopsFormCheckBox(_MB_USERLOG_BLOCK_ITEMS, "options[{$i}][]", $options_views);
+ $viewsEle = new XoopsFormCheckBox(_AM_USERLOG_ITEMS, "options[{$i}][]", $options_views);
$viewsEle->columns = 3;
$viewsEle->addOptionArray($hasviews);
$check_all = _ALL . ": <input type=\"checkbox\" name=\"item_check\" id=\"item_check\" value=\"1\" onclick=\"xoopsCheckGroup('blockform', 'item_check','options[{$i}][]');\" />"; // blockform is the main form
- $viewsEle = new XoopsFormLabel(_MB_USERLOG_BLOCK_ITEMS, $check_all ."<br\>". $viewsEle->render());
- $viewsEle->setDescription(_MB_USERLOG_BLOCK_ITEMS_DSC);
+ $viewsEle = new XoopsFormLabel(_AM_USERLOG_ITEMS, $check_all ."<br\>". $viewsEle->render());
+ $viewsEle->setDescription(_AM_USERLOG_ITEMS_DSC);
$i++;
- $timeEle = new XoopsFormText(_MB_USERLOG_BLOCK_TIME, "options[{$i}]", 10, 255, $options[$i]);
- $timeEle->setDescription(_MB_USERLOG_BLOCK_TIME_DSC);
+ $timeEle = new XoopsFormText(_AM_USERLOG_LOG_TIMEGT, "options[{$i}]", 10, 255, $options[$i]);
+ $timeEle->setDescription(_AM_USERLOG_LOG_TIMEGT_FORM);
$i++;
- // topic_poster element
- $userRadioEle = new XoopsFormRadio(_AM_USERLOG_UID, "options[{$i}]", !empty($options[$i]));
- $userRadioEle->addOption(0,_ALL);
- $userRadioEle->addOption(!empty($options[$i]) ? $options[$i] : 1,_SELECT); // if no user in selection box it select uid=1
+ $userRadioEle = new XoopsFormRadio(_AM_USERLOG_UID, "options[{$i}]", $options[$i]);
+ $userRadioEle->addOption(-1,_ALL);
+ $userRadioEle->addOption(($options[$i] != -1) ? $options[$i] : 0,_SELECT); // if no user in selection box it select uid=0 anon users
$userRadioEle->setExtra("onchange=\"var el=document.getElementById('options[{$i}]'); el.disabled=(this.id == 'options[{$i}]1'); if (!el.value) {el.value= this.value}\""); // if user dont select any option it select "all"
- $userSelectEle = new XoopsFormSelectUser(_AM_USERLOG_UID, "options[{$i}]", false, explode(',', $options[$i]), 3, true);
+ $userSelectEle = new XoopsFormSelectUser(_AM_USERLOG_UID, "options[{$i}]", true, explode(',', $options[$i]), 3, true);
$userEle = new XoopsFormLabel(_AM_USERLOG_UID, $userRadioEle->render().$userSelectEle->render());
$i++;
- // topic_poster element
$groupRadioEle = new XoopsFormRadio(_AM_USERLOG_GROUPS, "options[{$i}]", !empty($options[$i]));
$groupRadioEle->addOption(0,_ALL);
- $groupRadioEle->addOption(!empty($options[$i]) ? $options[$i] : 1,_SELECT); // if no group in selection box it select uid=1
+ $groupRadioEle->addOption(!empty($options[$i]) ? $options[$i] : 2,_SELECT); // if no group in selection box it select gid=2 registered users
$groupRadioEle->setExtra("onchange=\"var el=document.getElementById('options[{$i}]'); el.disabled=(this.id == 'options[{$i}]1'); if (!el.value) {el.value= this.value}\""); // if group dont select any option it select "all"
$groupSelectEle = new XoopsFormSelectGroup(_AM_USERLOG_GROUPS, "options[{$i}]", true, explode(',', $options[$i]), 3, true);
$groupEle = new XoopsFormLabel(_AM_USERLOG_GROUPS, $groupRadioEle->render().$groupSelectEle->render());
@@ -206,10 +121,10 @@
$i++;
$sortEle = new XoopsFormSelect(_AM_USERLOG_SORT, "options[{$i}]", $options[$i]);
$sortEle->addOptionArray(array(
- "views"=>_AM_USERLOG_VIEW,
+ "count"=>_AM_USERLOG_VIEW,
"module"=>_AM_USERLOG_MODULE,
"module_name"=>_AM_USERLOG_MODULE_NAME,
- "module_views"=>_AM_USERLOG_VIEW_MODULE
+ "module_count"=>_AM_USERLOG_VIEW_MODULE
));
$sortEle->setDescription(_AM_USERLOG_SORT_DSC);
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-18 23:11:49 UTC (rev 11247)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-19 02:41:45 UTC (rev 11248)
@@ -52,7 +52,8 @@
$this->initVar("script", XOBJ_DTYPE_TXTBOX, null, true, 50);
$this->initVar("referer", XOBJ_DTYPE_TXTBOX, null, true, 255);
$this->initVar("pagetitle", XOBJ_DTYPE_TXTBOX, null, false, 255);
- $this->initVar("module", XOBJ_DTYPE_TXTBOX, null, true, 10);
+ $this->initVar("module", XOBJ_DTYPE_TXTBOX, null, true, 25);
+ $this->initVar("module_name", XOBJ_DTYPE_TXTBOX, null, true, 25);
$this->initVar("item_name", XOBJ_DTYPE_TXTBOX, null, false, 10);
$this->initVar("item_id", XOBJ_DTYPE_INT, null, false);
$this->initVar("request_method", XOBJ_DTYPE_TXTBOX, null, false, 20);
@@ -96,10 +97,106 @@
return $this->userlog->formatTime($this->getVar('last_login'));
}
- public function getViews($criteria = null)
+ public function getViews($limit = 10, $start = 0, $sort = 'count', $order = 'DESC' ,$modules = array(), $since = 0, $users = array(), $groups = array())
{
+ if (!empty($modules)) {
+ $criteriaModule = new CriteriaCompo();
+ foreach ($modules as $module_dir=>$items) {
+ $criteriaItem = new CriteriaCompo();
+ $criteriaItem->add(new Criteria('module', $module_dir));
+ $criteriaItemName = new CriteriaCompo();
+ if (!empty($items["item_name"])) {
+ foreach($items["item_name"] as $item_name) {
+ // why we cannot use this $criteriaItemName->add(new Criteria('item_name', $items, "IN"));
+ $criteriaItemName->add(new Criteria('item_name', $item_name), "OR");
+ }
+ }
+ $criteriaItem->add($criteriaItemName);
+ $criteriaScript = new CriteriaCompo();
+ if (!empty($items["script"])) {
+ foreach($items["script"] as $script_name) {
+ $criteriaScript->add(new Criteria('script', $script_name), "OR");
+ }
+ }
+ $criteriaItem->add($criteriaScript);
+ $criteriaModule->add($criteriaItem, "OR");
+ unset($criteriaItem,$criteriaItemName,$criteriaScript);
+ }
}
+ if (!empty($since)) {
+ $starttime = time() - $this->userlog->getSinceTime($since);
+ $criteriaSince = new CriteriaCompo();
+ $criteriaSince->add(new Criteria('log_time', $starttime ,'>'));
+ }
+
+ if (!empty($users)) {
+ $criteriaUser = new CriteriaCompo();
+ $criteriaUser->add(new Criteria('uid', '(' . implode(",",$users) . ')', 'IN'));
+ }
+ if (!empty($groups)) {
+ $criteriaGroup = new CriteriaCompo();
+ foreach($groups as $group) {
+ $criteriaGroup->add(new Criteria("groups", "%g" . $group . "%", "LIKE"), "OR");
+ }
+ }
+
+ // add all criterias
+ $criteria = new CriteriaCompo();
+ if ( !empty($criteriaModule) ) {
+ $criteria->add($criteriaModule);
+ }
+ if ( !empty($criteriaSince) ) {
+ $criteria->add($criteriaSince);
+ }
+ if ( !empty($criteriaUser) ) {
+ $criteria->add($criteriaUser);
+ }
+ if ( !empty($criteriaGroup) ) {
+ $criteria->add($criteriaGroup);
+ }
+ $criteria->setLimit($limit);
+ $criteria->setStart($start);
+ $sortItem = ($sort == "module_count") ? "module_name" : $sort;
+ $criteria->setSort($sortItem);
+ $criteria->setOrder($order);
+ $fields = array("uid","groups","pagetitle","module","module_name","script","item_name","item_id");
+ $criteria->setGroupby("uid, groups, module, script, item_name, item_id");
+
+ list($loglogsObj, $itemViews) = $this->userlog->getHandler('log')->getLogsCounts($criteria,$fields);
+ $criteria->setGroupby("module");
+ $criteria->setSort(($sort == "module_count") ? "count" : "module");
+ $moduleViews = $this->userlog->getHandler('log')->getCounts($criteria);
+ unset($criteria);
+ // initializing
+ $items = array(); // very important!!!
+ foreach($loglogsObj as $key=>$loglogObj) {
+ $module_dirname = $loglogObj->module();
+ $item_id = $loglogObj->item_id();
+ if(!empty($item_id)) {
+ $link = "modules/" . $module_dirname."/".$loglogObj->script() . "?".$loglogObj->item_name()."=".$item_id;
+ } elseif($module_dirname != "system-root") {
+ $link = "modules/" . $module_dirname."/".$loglogObj->script();
+ } else {
+ $link = $loglogObj->script();
+ }
+ $items[$link] = array();
+ $items[$link]["count"] = $itemViews[$key];
+ $items[$link]["pagetitle"] = $loglogObj->pagetitle();
+ $items[$link]["module"] = $module_dirname;
+ $items[$link]["module_name"] = $loglogObj->module_name();
+ $items[$link]["module_count"] = $moduleViews[$module_dirname];
+ }
+ foreach($items as $link=>$item) {
+ $col1[$link] = $item[$sort];
+ $col2[$link] = $item["count"];//second sort by
+ }
+ if ( !empty($items) ) {
+ array_multisort($col1, ($order == "ASC") ? SORT_ASC : SORT_DESC ,$col2 ,SORT_DESC, $items);
+ }
+ return $items;
+ }
+
public function store($tolog, $force = true)
{
if ($this->_store > 1) $this->storeFile($tolog); // store file
@@ -127,6 +224,10 @@
foreach($logs as $log_id=>$log) {
$logs[$log_id]["log_time"] = $this->userlog->formatTime($logs[$log_id]["log_time"]);
$logs[$log_id]["last_login"] = $this->userlog->formatTime($logs[$log_id]["last_login"]);
+ // change g1g2 to Webmasters, Registered Users
+ $groups = explode("g", substr($logs[$log_id]["groups"], 1)); // remove the first "g" from string
+ $userGroupNames = $this->userlog->getFromKeys($this->userlog->getGroupList(), $groups);
+ $logs[$log_id]["groups"] = implode(",", $userGroupNames);
foreach ($this->_sourceJSON as $option){
// if value is not string it was decoded in file
if (!is_string($logs[$log_id][$option])) continue;
Modified: XoopsModules/userlog/trunk/userlog/class/setting.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/setting.php 2013-03-18 23:11:49 UTC (rev 11247)
+++ XoopsModules/userlog/trunk/userlog/class/setting.php 2013-03-19 02:41:45 UTC (rev 11248)
@@ -255,6 +255,10 @@
"title" => _AM_USERLOG_MODULE,
"value" => $this->userlog->getLogModule()->getVar("dirname")
),
+ "module_name" => array( "type" => "text",
+ "title" => _AM_USERLOG_MODULE_NAME,
+ "value" => $this->userlog->getLogModule()->getVar("name")
+ ),
"item_name" => array( "type" => "text",
"title" => _AM_USERLOG_ITEM_NAME,
"value" => null
Modified: XoopsModules/userlog/trunk/userlog/class/userlog.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-03-18 23:11:49 UTC (rev 11247)
+++ XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-03-19 02:41:45 UTC (rev 11248)
@@ -33,6 +33,7 @@
public $debugArray = array();
public $logext = "log";
public $cookiePrefix = "";
+ public $groupList;
protected function __construct($debug)
{
@@ -64,7 +65,7 @@
}
return $this->logmodule;
}
- public function &getModules($dirnames = array(), $otherCriteria = null)
+ public function &getModules($dirnames = array(), $otherCriteria = null, $asObj = false)
{
// get all dirnames
$module_handler =& xoops_gethandler('module');
@@ -79,7 +80,12 @@
}
$criteria->add(new Criteria('isactive', 1), "AND");
$modules = $module_handler->getObjects($criteria, true);
- return $modules;
+ if($asObj) return $modules;
+ $dirNames["system-root"] = _YOURHOME;
+ foreach($modules as $module) {
+ $dirNames[$module->dirname()] = $module->name();
+ }
+ return $dirNames;
}
public function &getUser()
{
@@ -88,7 +94,14 @@
}
return $this->user;
}
-
+ public function &getGroupList()
+ {
+ if ($this->groupList == null) {
+ $this->initGroupList();
+ }
+ return $this->groupList;
+ }
+
public function getConfig($name = null)
{
if ($this->config == null) {
@@ -206,7 +219,8 @@
$this->logmodule = $xoopsModule;
} else {
$hModule = xoops_gethandler('module');
- $this->logmodule = $hModule->getByDirname($this->dirname);
+ $this->logmodule = $hModule->getByDirname("system");
+ $this->logmodule->setVar("dirname","system-root");
}
$this->addLog('INIT LOGMODULE');
}
@@ -221,6 +235,12 @@
}
$this->addLog('INIT USER');
}
+ private function initGroupList()
+ {
+ $groupHandler =& xoops_gethandler('member');
+ $this->groupList = $groupHandler->getGroupList();
+ $this->addLog('INIT GROUP LIST');
+ }
private function initConfig()
{
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-18 23:11:49 UTC (rev 11247)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-19 02:41:45 UTC (rev...
[truncated message content] |
|
From: <ir...@us...> - 2013-03-19 03:44:48
|
Revision: 11249
http://sourceforge.net/p/xoops/svn/11249
Author: irmtfan
Date: 2013-03-19 03:44:45 +0000 (Tue, 19 Mar 2013)
Log Message:
-----------
bug fix: Paths were incorrect in xoops_version.php
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/class/userlog.php
XoopsModules/userlog/trunk/userlog/xoops_version.php
Modified: XoopsModules/userlog/trunk/userlog/class/userlog.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-03-19 02:41:45 UTC (rev 11248)
+++ XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-03-19 03:44:45 UTC (rev 11249)
@@ -141,7 +141,7 @@
{
$allConfigs = $this->module->getInfo('config');
$currentPath = $this->getConfig("logfilepath");
- $logPaths = array_keys($allConfigs[3]["options"]);
+ $logPaths = $allConfigs[3]["options"];
$allFiles = array();
$totalFiles = 0;
foreach($logPaths as $path) {
Modified: XoopsModules/userlog/trunk/userlog/xoops_version.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-03-19 02:41:45 UTC (rev 11248)
+++ XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-03-19 03:44:45 UTC (rev 11249)
@@ -152,7 +152,7 @@
$modversion['config'][$i]['formtype'] = 'select';
$modversion['config'][$i]['valuetype'] = 'text';
$modversion['config'][$i]['default'] = XOOPS_VAR_PATH;
-$modversion['config'][$i]['options'] = array(XOOPS_VAR_PATH => "XOOPS_VAR_PATH", XOOPS_UPLOAD_PATH => "XOOPS_UPLOAD_PATH");
+$modversion['config'][$i]['options'] = array("XOOPS_VAR_PATH" => XOOPS_VAR_PATH, "XOOPS_UPLOAD_PATH" => XOOPS_UPLOAD_PATH);
$modversion['config'][$i]['category'] = 'logfile';
$i++;
|
|
From: <ir...@us...> - 2013-03-20 22:24:07
|
Revision: 11270
http://sourceforge.net/p/xoops/svn/11270
Author: irmtfan
Date: 2013-03-20 22:24:04 +0000 (Wed, 20 Mar 2013)
Log Message:
-----------
add page admin (yes/no) to table logs in database for recognizing admin pages
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/setting.php
XoopsModules/userlog/trunk/userlog/class/log.php
XoopsModules/userlog/trunk/userlog/class/setting.php
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/language/english/admin.php
XoopsModules/userlog/trunk/userlog/language/english/help/help.html
XoopsModules/userlog/trunk/userlog/sql/mysql.sql
XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
Modified: XoopsModules/userlog/trunk/userlog/admin/setting.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/setting.php 2013-03-20 19:35:42 UTC (rev 11269)
+++ XoopsModules/userlog/trunk/userlog/admin/setting.php 2013-03-20 22:24:04 UTC (rev 11270)
@@ -91,9 +91,9 @@
$logsetObj->setVar("name",$name);
$logsetObj->setVar("logby",$logby);
$logsetObj->setVar("unique_id",$unique_id);
- // select views means store uid, groups, script name, pagetitle, module, module_name, item name, item id in Database
+ // select views means store uid, groups, script name, pagetitle, pageadmin, module, module_name, item name, item id in Database
if (in_array("views",$option)) {
- $option = array_merge(array("uid", "groups", "script","pagetitle","module","module_name","item_name","item_id"),$option);
+ $option = array_merge(array("uid", "groups", "script","pagetitle","pageadmin","module","module_name","item_name","item_id"),$option);
}
// always log id and time
if(!empty($option[0])) {
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-20 19:35:42 UTC (rev 11269)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-03-20 22:24:04 UTC (rev 11270)
@@ -52,6 +52,7 @@
$this->initVar("script", XOBJ_DTYPE_TXTBOX, null, true, 50);
$this->initVar("referer", XOBJ_DTYPE_TXTBOX, null, true, 255);
$this->initVar("pagetitle", XOBJ_DTYPE_TXTBOX, null, false, 255);
+ $this->initVar("pageadmin", XOBJ_DTYPE_INT, null, false);
$this->initVar("module", XOBJ_DTYPE_TXTBOX, null, true, 25);
$this->initVar("module_name", XOBJ_DTYPE_TXTBOX, null, true, 25);
$this->initVar("item_name", XOBJ_DTYPE_TXTBOX, null, false, 10);
@@ -160,8 +161,8 @@
$sortItem = ($sort == "module_count") ? "module_name" : $sort;
$criteria->setSort($sortItem);
$criteria->setOrder($order);
- $fields = array("uid","groups","pagetitle","module","module_name","script","item_name","item_id");
- $criteria->setGroupby("uid, groups, module, script, item_name, item_id");
+ $fields = array("uid","groups","pagetitle","pageadmin","module","module_name","script","item_name","item_id");
+ $criteria->setGroupby("uid, groups, pageadmin, module, script, item_name, item_id");
list($loglogsObj, $itemViews) = $this->userlog->getHandler('log')->getLogsCounts($criteria,$fields);
$criteria->setGroupby("module");
@@ -176,7 +177,7 @@
if(!empty($item_id)) {
$link = "modules/" . $module_dirname."/".$loglogObj->script() . "?".$loglogObj->item_name()."=".$item_id;
} elseif($module_dirname != "system-root") {
- $link = "modules/" . $module_dirname."/".$loglogObj->script();
+ $link = "modules/" . $module_dirname . ($loglogObj->pageadmin() ? "/admin/" : "/") .$loglogObj->script();
} else {
$link = $loglogObj->script();
}
Modified: XoopsModules/userlog/trunk/userlog/class/setting.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/setting.php 2013-03-20 19:35:42 UTC (rev 11269)
+++ XoopsModules/userlog/trunk/userlog/class/setting.php 2013-03-20 22:24:04 UTC (rev 11270)
@@ -251,6 +251,10 @@
"title" => _AM_USERLOG_PAGETITLE,
"value" => isset($GLOBALS['xoopsTpl']) ? $GLOBALS['xoopsTpl']->get_template_vars("xoops_pagetitle") : ""
),
+ "pageadmin" => array( "type" => "bool",
+ "title" => _AM_USERLOG_PAGEADMIN,
+ "value" => (isset($GLOBALS['xoopsOption']['pagetype']) && $GLOBALS['xoopsOption']['pagetype'] == "admin") ? 1 : 0
+ ),
"module" => array( "type" => "text",
"title" => _AM_USERLOG_MODULE,
"value" => $this->userlog->getLogModule()->getVar("dirname")
@@ -340,12 +344,14 @@
$query_types = array("="=>"",">"=>"GT", "<"=>"LT");
foreach($headers as $ele=>$def) {
switch ($ele) {
+ case "pageadmin":
case "admin":
- $el[$ele] = new XoopsFormRadio(_AM_USERLOG_ADMIN, "options[{$ele}]",isset($options[$ele]) ? $options[$ele] : '');
+ $defEl = "_AM_USERLOG_". strtoupper($ele); // if constant is defined in translation - it is good for now
+ $el[$ele] = new XoopsFormRadio(constant($defEl), "options[{$ele}]",isset($options[$ele]) ? $options[$ele] : '');
$el[$ele]->addOption(1,_YES);
$el[$ele]->addOption(0,_NO);
$el[$ele]->addOption('',_ALL);
- $el[$ele]->setDescription(_AM_USERLOG_ADMIN_FORM);
+ $el[$ele]->setDescription(constant($defEl . "_FORM"));
$form->addElement($el[$ele]);
break;
default:
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-20 19:35:42 UTC (rev 11269)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-20 22:24:04 UTC (rev 11270)
@@ -1,5 +1,6 @@
Userlog
Changelog:
+- add page admin (yes/no) to table logs in database for recognizing admin pages(2013/03/21)
- change version to ALPHA 2(2013/03/19)
- enhance admin/logs.php template to show admin(y/n), group names, user link, user ip link to whois, ...(2013/03/19)
- add HomePage to module scope. It will be for all root scripts like ROOT/admin.php(2013/03/19)
Modified: XoopsModules/userlog/trunk/userlog/language/english/admin.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-20 19:35:42 UTC (rev 11269)
+++ XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-20 22:24:04 UTC (rev 11270)
@@ -39,6 +39,8 @@
define("_AM_USERLOG_UID_DSC","User ID number");
define("_AM_USERLOG_ADMIN","Is Admin?(y/n)");
define("_AM_USERLOG_ADMIN_DSC","True if user is Admin in all or any section of your website that have been logged. e.g.: webmasters, moderator in forums");
+define("_AM_USERLOG_PAGEADMIN","Is Page admin?(y/n)");
+define("_AM_USERLOG_PAGEADMIN_DSC","True if page is in admin side.");
define("_AM_USERLOG_GROUPS","Groups");
define("_AM_USERLOG_GROUPS_DSC","All Groups");
define("_AM_USERLOG_UNAME","Username");
@@ -82,7 +84,7 @@
define("_AM_USERLOG_SET_GID","Group ID");
define("_AM_USERLOG_SET_IP","Visitor IP");
define("_AM_USERLOG_SET_OPTIONS","Options");
-define("_AM_USERLOG_SET_OPTIONS_DSC","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, module dirname, module name, item name, item id in Database");
+define("_AM_USERLOG_SET_OPTIONS_DSC","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");
define("_AM_USERLOG_SET_SCOPE","Log scope");
define("_AM_USERLOG_SET_SCOPE_DSC","Log users activities in which modules? Selecting nothing means whole website");
Modified: XoopsModules/userlog/trunk/userlog/language/english/help/help.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-03-20 19:35:42 UTC (rev 11269)
+++ XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-03-20 22:24:04 UTC (rev 11270)
@@ -38,7 +38,7 @@
(eg: uid=1, gid=3 (anonymous), ip=66.249.66.1) enter 0 means all users.<br />
<br />
<b>options:</b> you can select which user or page data you want to be logged. Also here you can choose 3 settings. Store in file? Store in database? And log user views?<br />
-select log user views means store uid, groups, script name, pagetitle, module dirname, module name, item name, item ID in Database.<br />
+select log user views means store uid, groups, script name, pagetitle, pageadmin, module dirname, module name, item name, item ID in Database.<br />
<br />
<b>Log scope:</b> if you want to log users activities in some specific module, you can do it here.<br />
select nothing means all website.<br />
Modified: XoopsModules/userlog/trunk/userlog/sql/mysql.sql
===================================================================
--- XoopsModules/userlog/trunk/userlog/sql/mysql.sql 2013-03-20 19:35:42 UTC (rev 11269)
+++ XoopsModules/userlog/trunk/userlog/sql/mysql.sql 2013-03-20 22:24:04 UTC (rev 11270)
@@ -16,6 +16,7 @@
script varchar(20) NOT NULL default '',
referer varchar(255) NOT NULL default '',
pagetitle varchar(255) NOT NULL default '',
+ pageadmin smallint(1) unsigned NOT NULL default 0,
module varchar(25) NOT NULL default '',
module_name varchar(25) NOT NULL default '',
item_name varchar(10) NOT NULL default '',
@@ -33,7 +34,7 @@
PRIMARY KEY (log_id),
KEY log_id_uid (log_id, uid),
KEY uid (uid, uname, user_ip),
- KEY views (uid, groups, script, pagetitle(20), module, item_name, item_id)
+ KEY views (uid, groups, script, pagetitle(20),pageadmin, module, item_name, item_id)
) ENGINE=MyISAM;
# --------------------------------------------------------
Modified: XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-03-20 19:35:42 UTC (rev 11269)
+++ XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html 2013-03-20 22:24:04 UTC (rev 11270)
@@ -74,7 +74,7 @@
<input title="<{$smarty.const._ALL}>" type="checkbox" name="id_check" id="id_check" value="1" onclick="xoopsCheckAll('select', 'id_check');" />
</div>
<{foreach item=title key=header from=$headers}>
- <div title="<{$title}>" class="width<{if $header == "admin" || $header == "log_id" || $header == "uid" || $header == "item_name" || $header == "item_id"}>1<{else}><{$widthC}><{/if}> floatleft center" style="height: 15px; overflow: hidden;">
+ <div title="<{$title}>" class="width<{if $header == "admin" || $header == "pageadmin" || $header == "log_id" || $header == "uid" || $header == "item_name" || $header == "item_id"}>1<{else}><{$widthC}><{/if}> floatleft center" style="height: 15px; overflow: hidden;">
<a class="ui-corner-all tooltip" title="<{$title}>" href="logs.php?limitentry=<{$limitentry}>&sortentry=<{$header}><{if $query_page}>&<{$query_page}><{/if}><{if $sortentry eq $header}>&orderentry=<{if $orderentry eq 'DESC'}>ASC<{else}>DESC<{/if}><{/if}> " alt="<{$title}>"><{if $sortentry eq $header}><img src="<{if $orderentry eq 'DESC'}><{xoModuleIcons16 DESC.png}><{else}><{xoModuleIcons16 ASC.png}><{/if}>"/><{/if}><{$title}></a>
</div>
<{/foreach}>
@@ -87,14 +87,14 @@
<input type="checkbox" name="log_id[]" id="log_id[<{$log_id}>]" value="<{$log_id}>" />
</div>
<{foreach item=title key=header from=$headers}>
- <div title="<{$log.$header}>" class="width<{if $header == "admin" || $header == "log_id" || $header == "uid" || $header == "item_name" || $header == "item_id"}>1<{else}><{$widthC}><{/if}> floatleft center" style="height: 15px; overflow: hidden;">
+ <div title="<{$log.$header}>" class="width<{if $header == "admin" || $header == "pageadmin" || $header == "log_id" || $header == "uid" || $header == "item_name" || $header == "item_id"}>1<{else}><{$widthC}><{/if}> floatleft center" style="height: 15px; overflow: hidden;">
<{if $header == "uname"}>
<a href="<{$xoops_url}>/userinfo.php?uid=<{$log.uid}>"><{$log.uname}></a>
<{elseif $header == "user_ip"}>
<a href="http://www.whois.sc/<{$log.user_ip}>"><{$log.user_ip}></a>
- <{elseif $header == "admin"}>
- <{if $log.admin == 1}><{$smarty.const._YES}><{else}><{$smarty.const._NO}><{/if}>
+ <{elseif $header == "admin" || $header == "pageadmin"}>
+ <{if $log.$header == 1}><{$smarty.const._YES}><{else}><{$smarty.const._NO}><{/if}>
<{elseif $header == "item_id"}>
<{if $log.item_id gt 0}><{$log.item_id}><{/if}>
<{else}>
|
|
From: <ir...@us...> - 2013-04-01 04:09:44
|
Revision: 11336
http://sourceforge.net/p/xoops/svn/11336
Author: irmtfan
Date: 2013-04-01 04:09:41 +0000 (Mon, 01 Apr 2013)
Log Message:
-----------
- change version to BETA 1(2013/04/01)
- fix some parts in templates, definitions, help.html(2013/04/01)
- bug fix: item_id is int not text. add greater than and lower than for item_id in logs form(2013/04/01)
- add persian language(2013/04/01)
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/class/setting.php
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/language/english/admin.php
XoopsModules/userlog/trunk/userlog/language/english/help/help.html
XoopsModules/userlog/trunk/userlog/language/english/modinfo.php
XoopsModules/userlog/trunk/userlog/templates/userlog_admin_logs.html
XoopsModules/userlog/trunk/userlog/xoops_version.php
Added Paths:
-----------
XoopsModules/userlog/trunk/userlog/language/persian/
XoopsModules/userlog/trunk/userlog/language/persian/admin.php
XoopsModules/userlog/trunk/userlog/language/persian/blocks.php
XoopsModules/userlog/trunk/userlog/language/persian/help/
XoopsModules/userlog/trunk/userlog/language/persian/help/help.html
XoopsModules/userlog/trunk/userlog/language/persian/help/index.html
XoopsModules/userlog/trunk/userlog/language/persian/index.html
XoopsModules/userlog/trunk/userlog/language/persian/modinfo.php
Modified: XoopsModules/userlog/trunk/userlog/class/setting.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/setting.php 2013-03-31 23:56:08 UTC (rev 11335)
+++ XoopsModules/userlog/trunk/userlog/class/setting.php 2013-04-01 04:09:41 UTC (rev 11336)
@@ -267,7 +267,7 @@
"title" => _AM_USERLOG_ITEM_NAME,
"value" => null
),
- "item_id" => array( "type" => "text",
+ "item_id" => array( "type" => "int",
"title" => _AM_USERLOG_ITEM_ID,
"value" => null
),
@@ -359,7 +359,8 @@
$defEl = "_AM_USERLOG_". strtoupper($ele.$type); // if constant is defined in translation - it is good for now
if (defined($defEl . "_FORM")) {
$el[$ele.$type] = new XoopsFormText(constant($defEl), "options[{$ele}{$type}]", 10, 255, !empty($options[$ele.$type]) ? $options[$ele.$type] : null);
- $el[$ele.$type]->setDescription(sprintf(constant($defEl . "_FORM"), $ele, $ele));
+ $defEle = "_AM_USERLOG_". strtoupper($ele);
+ $el[$ele.$type]->setDescription(sprintf(constant($defEl . "_FORM"), constant($defEle), constant($defEle)));
$form->addElement($el[$ele.$type]);
}
}
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-03-31 23:56:08 UTC (rev 11335)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-04-01 04:09:41 UTC (rev 11336)
@@ -1,5 +1,9 @@
Userlog
Changelog:
+- change version to BETA 1(2013/04/01)
+- fix some parts in templates, definitions, help.html(2013/04/01)
+- bug fix: item_id is int not text. add greater than and lower than for item_id in logs form(2013/04/01)
+- add persian language(2013/04/01)
- add page admin (yes/no) to table logs in database for recognizing admin pages(2013/03/21)
- change version to ALPHA 2(2013/03/19)
- enhance admin/logs.php template to show admin(y/n), group names, user link, user ip link to whois, ...(2013/03/19)
Modified: XoopsModules/userlog/trunk/userlog/language/english/admin.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-03-31 23:56:08 UTC (rev 11335)
+++ XoopsModules/userlog/trunk/userlog/language/english/admin.php 2013-04-01 04:09:41 UTC (rev 11336)
@@ -117,32 +117,51 @@
define("_AM_USERLOG_ORDER","Order by");
define("_AM_USERLOG_ORDER_DSC","Ascending or Descending order");
-define("_AM_USERLOG_LOG_ID_FORM","Enter one '%1\$s' or several '%2\$s's separated with comma to show logs based on that. eg: 23,32,12");
-define("_AM_USERLOG_LOG_IDGT","Log id greater than");
-define("_AM_USERLOG_LOG_IDGT_FORM","Enter one '%1\$s' to show all '%2\$s's greater than it");
-define("_AM_USERLOG_LOG_IDLT","Log id lower than");
-define("_AM_USERLOG_LOG_IDLT_FORM","Enter one '%1\$s' to show all '%2\$s's lower than it");
+// for all INT logs use these definition
+define("_AM_USERLOG_INTGT","%1\$s greater than");
+define("_AM_USERLOG_INTLT","%1\$s lower than");
+define("_AM_USERLOG_TIMEGT","%1\$s since");
+define("_AM_USERLOG_TIMELT","%1\$s until");
+define("_AM_USERLOG_INT_FORM","Enter one '%1\$s' or several '%2\$s's separated with comma to show logs based on that. eg: 23,32,12");
+define("_AM_USERLOG_INTGT_FORM","Enter one '%1\$s' to show all '%2\$s's greater than it.");
+define("_AM_USERLOG_INTLT_FORM","Enter one '%1\$s' to show all '%2\$s's lower than it.");
+define("_AM_USERLOG_TIMEGT_FORM","Enter Time of '%1\$s' to show all logs since that time. Positive for days and negative for hours. eg: 1 means since one day ago.");
+define("_AM_USERLOG_TIMELT_FORM","Enter Time of '%1\$s' to show all logs until that time. Positive for days and negative for hours. eg: 1 means since one day ago.");
+// Translators: do not touch below for now
+// START DO NOT TOUCH
+define("_AM_USERLOG_LOG_ID_FORM",_AM_USERLOG_INT_FORM);
+define("_AM_USERLOG_LOG_IDGT",sprintf(_AM_USERLOG_INTGT,_AM_USERLOG_LOG_ID));
+define("_AM_USERLOG_LOG_IDGT_FORM",_AM_USERLOG_INTGT_FORM);
+define("_AM_USERLOG_LOG_IDLT",sprintf(_AM_USERLOG_INTLT,_AM_USERLOG_LOG_ID));
+define("_AM_USERLOG_LOG_IDLT_FORM",_AM_USERLOG_INTLT_FORM);
-define("_AM_USERLOG_LOG_TIMEGT","Log time since");
-define("_AM_USERLOG_LOG_TIMEGT_FORM","Enter Time of log record to show all logs since that time. Positive for days and negative for hours. eg: 1 means since one day ago");
-define("_AM_USERLOG_LOG_TIMELT","Log time until");
-define("_AM_USERLOG_LOG_TIMELT_FORM","Enter Time of log record to show all logs until that time. Positive for days and negative for hours. eg: 1 means until one day ago");
+define("_AM_USERLOG_LOG_TIMEGT",sprintf(_AM_USERLOG_TIMEGT,_AM_USERLOG_LOG_TIME));
+define("_AM_USERLOG_LOG_TIMEGT_FORM",sprintf(_AM_USERLOG_TIMEGT_FORM,_AM_USERLOG_LOG_TIME));
+define("_AM_USERLOG_LOG_TIMELT",sprintf(_AM_USERLOG_TIMELT,_AM_USERLOG_LOG_TIME));
+define("_AM_USERLOG_LOG_TIMELT_FORM",sprintf(_AM_USERLOG_TIMELT_FORM,_AM_USERLOG_LOG_TIME));
-define("_AM_USERLOG_UID_FORM","Enter one '%1\$s' or several '%2\$s's separated with comma to show logs based on that. eg: 23,32,12");
-define("_AM_USERLOG_UIDGT","User id greater than");
-define("_AM_USERLOG_UIDGT_FORM","Enter one '%1\$s' number to show all logs for all users with a '%2\$s' greater than that");
-define("_AM_USERLOG_UIDLT","User id lower than");
-define("_AM_USERLOG_UIDLT_FORM","Enter one '%1\$s' number to show all logs for all users with a '%2\$s' lower than that");
+define("_AM_USERLOG_UID_FORM",_AM_USERLOG_INT_FORM);
+define("_AM_USERLOG_UIDGT",sprintf(_AM_USERLOG_INTGT,_AM_USERLOG_UID));
+define("_AM_USERLOG_UIDGT_FORM",_AM_USERLOG_INTGT_FORM);
+define("_AM_USERLOG_UIDLT",sprintf(_AM_USERLOG_INTLT,_AM_USERLOG_UID));
+define("_AM_USERLOG_UIDLT_FORM",_AM_USERLOG_INTLT_FORM);
+define("_AM_USERLOG_LAST_LOGINGT",sprintf(_AM_USERLOG_TIMEGT,_AM_USERLOG_LAST_LOGIN));
+define("_AM_USERLOG_LAST_LOGINGT_FORM",sprintf(_AM_USERLOG_TIMEGT_FORM,_AM_USERLOG_LAST_LOGIN));
+define("_AM_USERLOG_LAST_LOGINLT",sprintf(_AM_USERLOG_TIMELT,_AM_USERLOG_LAST_LOGIN));
+define("_AM_USERLOG_LAST_LOGINLT_FORM",sprintf(_AM_USERLOG_TIMELT_FORM,_AM_USERLOG_LAST_LOGIN));
+
+define("_AM_USERLOG_ITEM_ID_FORM",_AM_USERLOG_INT_FORM);
+define("_AM_USERLOG_ITEM_IDGT",sprintf(_AM_USERLOG_INTGT,_AM_USERLOG_ITEM_ID));
+define("_AM_USERLOG_ITEM_IDGT_FORM",_AM_USERLOG_INTGT_FORM);
+define("_AM_USERLOG_ITEM_IDLT",sprintf(_AM_USERLOG_INTLT,_AM_USERLOG_ITEM_ID));
+define("_AM_USERLOG_ITEM_IDLT_FORM",_AM_USERLOG_INTLT_FORM);
+// END DO NOT TOUCH
+
define("_AM_USERLOG_ADMIN_FORM","Select Yes to show all logs from Admins");
define("_AM_USERLOG_PAGEADMIN_FORM","Select Yes to show all pages in admin side of modules");
define("_AM_USERLOG_GROUPS_FORM","Enter one group with 'g' prefix (or several groups separated with comma) to show logs for all users belonging to those groups. Enter '!g' prefix to show logs for users not in those groups. eg: g1,g2,!g4 means all users belonging to group 1 OR group 2 AND not belong to group 4");
-define("_AM_USERLOG_LAST_LOGINGT","User Last Visit since");
-define("_AM_USERLOG_LAST_LOGINGT_FORM","Enter Time of User Last Visit to show all logs since that time. Positive for days and negative for hours. eg: 1 means since one day ago");
-define("_AM_USERLOG_LAST_LOGINLT","User Last Visit until");
-define("_AM_USERLOG_LAST_LOGINLT_FORM","Enter Time of User Last Visit to show all logs until that time. Positive for days and negative for hours. eg: 1 means until one day ago");
-
// for all other text logs use just one definition
define("_AM_USERLOG_TEXT_FORM","Enter one exact '%1\$s' or part of '%2\$s' to show all logs for users have that (with prefix '!' have not that). you can enter several separated with comma. eg: TERM1, !TERM2, TERM3 means all logs have TERM1 and TERM3 but have not TERM2");
// Translators: do not touch below for now
@@ -157,7 +176,6 @@
define("_AM_USERLOG_MODULE_FORM",_AM_USERLOG_TEXT_FORM);
define("_AM_USERLOG_MODULE_NAME_FORM",_AM_USERLOG_TEXT_FORM);
define("_AM_USERLOG_ITEM_NAME_FORM",_AM_USERLOG_TEXT_FORM);
-define("_AM_USERLOG_ITEM_ID_FORM",_AM_USERLOG_TEXT_FORM);
define("_AM_USERLOG_REQUEST_METHOD_FORM",_AM_USERLOG_TEXT_FORM);
define("_AM_USERLOG_GET_FORM",_AM_USERLOG_TEXT_FORM);
define("_AM_USERLOG_POST_FORM",_AM_USERLOG_TEXT_FORM);
Modified: XoopsModules/userlog/trunk/userlog/language/english/help/help.html
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-03-31 23:56:08 UTC (rev 11335)
+++ XoopsModules/userlog/trunk/userlog/language/english/help/help.html 2013-04-01 04:09:41 UTC (rev 11336)
@@ -68,7 +68,7 @@
<h4 class="odd">Statistics</h4>
<p class="even">
You can see total module views, total user views, total group views through the Statistics of the userlog Module.<br /><br />
-Also you have an advance form to see any item views using some criteria like what is the module/link/log time/poster/group poster of the item<br /><br />
+Also you have an advance form to see any item views using some criteria like what is the module/link/log time/viewer uid/viewer group id of the item<br /><br />
Statistics is under develop. please let us know what do you like to see here.<br /><br />
</p>
Modified: XoopsModules/userlog/trunk/userlog/language/english/modinfo.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/modinfo.php 2013-03-31 23:56:08 UTC (rev 11335)
+++ XoopsModules/userlog/trunk/userlog/language/english/modinfo.php 2013-04-01 04:09:41 UTC (rev 11336)
@@ -67,12 +67,12 @@
define("_MI_USERLOG_MAXLOGS","Maximum logs stored in database");
define("_MI_USERLOG_MAXLOGS_DSC","Logs will be deleted from database after reaching this number");
define("_MI_USERLOG_MAXLOGSPERIOD","Maximum time that logs are stored in the database. 0 = store forever");
-define("_MI_USERLOG_MAXLOGSPERIOD_DSC","Logs older than this period will be deleted from database. Positive for days and negative for hours. Advise: use a high number");
+define("_MI_USERLOG_MAXLOGSPERIOD_DSC","Logs older than this period will be deleted from database. Positive for days and negative for hours. Advise: use a large number");
// config probability
define("_MI_USERLOG_PROBSET","Probability to check database for a match setting");
define("_MI_USERLOG_PROBSET_DSC","Probability percentage to check database ONLY if it didnt find any setting in cache files for the current visitor/user. 20 means in one of each 5 hits it will check.");
define("_MI_USERLOG_PROBSTATS","Probability to update statistics in database when the visitor is logged.");
-define("_MI_USERLOG_PROBSTATS_DSC","Probability percentage to update database logs. 10 means in 1 of 10 visits of a visitor who have a match setting, it will update database. 0 means no update so you should manually update by visiting userlog > admin > home.");
+define("_MI_USERLOG_PROBSTATS_DSC","Probability percentage to update database logs. 10 means in 1 of each 10 visits of a visitor who have a match setting, it will update statistics. 0 means no update so you should manually update by visiting userlog > admin > home.");
define("_MI_USERLOG_PROBSTATSALLHIT","Probability to update statistics in database in each hit.");
define("_MI_USERLOG_PROBSTATSALLHIT_DSC","Probability percentage to update database logs. 1 means in 1 of each 100 hits it will update statistics.0 means no update so you should manually update by visiting userlog > admin > home. Advise: set a low percentage based on your website traffic.");
Added: XoopsModules/userlog/trunk/userlog/language/persian/admin.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/persian/admin.php (rev 0)
+++ XoopsModules/userlog/trunk/userlog/language/persian/admin.php 2013-04-01 04:09:41 UTC (rev 11336)
@@ -0,0 +1,281 @@
+<?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 language
+ * @since 1
+ * @author irmtfan (ir...@ya...)
+ * @author The XOOPS Project <www.xoops.org> <www.xoops.ir>
+ * @version $Id: admin.php 1 2013-02-26 16:25:04Z irmtfan $
+ */
+
+// admin menus
+define("_AM_USERLOG_ADMENU_INDEX","صفحه اصلی");
+define("_AM_USERLOG_ADMENU_SETTING","تنظیم برای ثبت");
+define("_AM_USERLOG_ADMENU_LOGS","ثبت شده ها");
+define("_AM_USERLOG_ADMENU_FILE","مدیر فایل");
+define("_AM_USERLOG_ADMENU_STATS","آمار بازدید");
+define("_AM_USERLOG_ABOUT","درباره ماژول ثبت فعالیت های کاربران");
+// general error
+define("_AM_USERLOG_ERROR","یک خطا در حین انجام عملیات اتفاق افتاد .%1\$s");
+
+// setting.php loglog object options
+define("_AM_USERLOG_LOG_ID","شماره ثبت");
+define("_AM_USERLOG_LOG_ID_DSC","شماره مورد ثبت شده در پایگاه داده.");
+define("_AM_USERLOG_LOG_TIME","زمان ثبت");
+define("_AM_USERLOG_LOG_TIME_DSC","زمان مورد ثبت شده");
+define("_AM_USERLOG_UID","شماره کاربر");
+define("_AM_USERLOG_UID_DSC","شماره کاربر ثبت شده");
+define("_AM_USERLOG_ADMIN","آیا کاربر دارای دسترسی مدیریت است؟");
+define("_AM_USERLOG_ADMIN_DSC","اگر کاربر در قسمتی یا کل سایت دارای دسترسی مدیریت باشد هنگام ثبت شدن آن قسمت گزینه بله ثبت خواهد شد. مثلا وب مستر ها یا ناظران انجمن ها");
+define("_AM_USERLOG_PAGEADMIN","آیا صفحه در قسمت مدیریت است؟");
+define("_AM_USERLOG_PAGEADMIN_DSC","اگر صفحه ای که دارد ثبت میشود در قسمت مدیریت ماژول باشد بله ثبت خواهد شد.");
+define("_AM_USERLOG_GROUPS","گروه ها");
+define("_AM_USERLOG_GROUPS_DSC","تمام گروه ها در سایت");
+define("_AM_USERLOG_UNAME","نام کاربری");
+define("_AM_USERLOG_UNAME_DSC","نام کاربری در پایگاه داده");
+define("_AM_USERLOG_LAST_LOGIN","آخرین بازدید");
+define("_AM_USERLOG_LAST_LOGIN_DSC","آخرین بازدید کاربر از وب سایت");
+define("_AM_USERLOG_USER_IP","IP کاربر");
+define("_AM_USERLOG_USER_AGENT","مرورگر کاربر");
+define("_AM_USERLOG_URL","لینک");
+define("_AM_USERLOG_SCRIPT","نام اسکریپت");
+define("_AM_USERLOG_SCRIPT_DSC","نام اسکریپت مثلا در صفحه اصلی سایت index.php خواهد بود.");
+define("_AM_USERLOG_REFERER","لینک ارجاع شده (referer)");
+define("_AM_USERLOG_PAGETITLE","عنوان صفحه");
+define("_AM_USERLOG_MODULE","نام شاخه ماژول");
+define("_AM_USERLOG_MODULE_NAME","نام ماژول");
+define("_AM_USERLOG_ITEM_NAME","نام آیتم");
+define("_AM_USERLOG_ITEM_ID","شماره آیتم");
+define("_AM_USERLOG_REQUEST_METHOD","متد دریافت (GET, POST, ...)");
+define("_AM_USERLOG_GET","\$_GET");
+define("_AM_USERLOG_POST","\$_POST");
+define("_AM_USERLOG_REQUEST","\$_REQUEST");
+define("_AM_USERLOG_FILES","\$_FILES");
+define("_AM_USERLOG_ENV","\$_ENV");
+define("_AM_USERLOG_SESSION","نشست ها (SESSIONS)");
+define("_AM_USERLOG_COOKIE","کوکی ها");
+define("_AM_USERLOG_HEADER","فهرست هدر");
+define("_AM_USERLOG_LOGGER","خطاهای زوپس");
+define("_AM_USERLOG_STORE_FILE","در فایل ذخیره شوند؟");
+define("_AM_USERLOG_STORE_DB","در پایگاه داده ذخیره شوند؟");
+define("_AM_USERLOG_VIEWS","بازدید های کاربر ثبت شوند؟");
+
+// setting.php logset object
+define("_AM_USERLOG_SET_ADD","اضافه کردن یک تنظیم برای ثبت");
+define("_AM_USERLOG_SET_ID","شماره");
+define("_AM_USERLOG_SET_NAME","نام تنظیم");
+define("_AM_USERLOG_SET_NAME_DSC","یک نام فارسی یا انگلیسی به دلخواه خود بنویسید");
+define("_AM_USERLOG_SET_LOGBY","ثبت از طریق");
+define("_AM_USERLOG_SET_LOGBY_DSC","فعالیت کاربران را از طریق گرفتن این مقدار از جدول کاربران ثبت خواهد کرد. اولویت: اگر شماره کاربری وجود دارد ثبت کن وگرنه اگر شماره گروه وجود دارد ثبت کن وگرنه نه اگر شماره ip وجود دارد ثبت کن وگرنه اگر شماره یکتا صفر است همه کاربران را ثبت کن وگرنه چیزی ثبت نکن.");
+define("_AM_USERLOG_SET_UNIQUE_ID","شماره یکتا");
+define("_AM_USERLOG_SET_UNIQUE_ID_DSC"," شماره یکتا (مثلا: شماره کاربر=1, شماره گروه=3 (گروه مهمان), ip=66.249.66.1) 0=همه کاربران");
+define("_AM_USERLOG_SET_GID","شماره گروه");
+define("_AM_USERLOG_SET_IP","IP بازدید کننده");
+define("_AM_USERLOG_SET_OPTIONS","گزینه ها");
+define("_AM_USERLOG_SET_OPTIONS_DSC","چه اطلاعاتی از کاربر و صفحات بازدید شده را میخواهید ثبت کنید؟ توجه: انتخاب هیچ یعنی همه گزینه ها. انتخاب نکردن روش ذخیره سازی (فایل یا پایگاه داده) یعنی ذخیره سازی در پایگاه داده. انتخاب ثبت شدن بازدید های کاربر یعنی ثبت شماره کاربری، گروه، نام اسکریپت، نام صفحه، آیا صفحه مدیریت است؟، نام شاخه ماژول، نام ماژول، نام آیتم، شماره آیتم در پایگاه داده.");
+define("_AM_USERLOG_SET_SCOPE","حوزه عملکرد برای ثبت");
+define("_AM_USERLOG_SET_SCOPE_DSC","فعالیت کاربران در چه ماژول هایی ثبت شود؟ اگر چیزی انتخاب نکنید یعنی در همه سایت ثبت شود.");
+
+// setting.php add/edit
+define("_AM_USERLOG_SET_ERROR","خطا. اطلاعات غلطی وارد کردید!");
+define("_AM_USERLOG_SET_CREATE","تنظیم %1\$s با موفقیت ثبت شد.");
+define("_AM_USERLOG_SET_EDIT","تنظیم %1\$s با موفقیت ویرایش شد.");
+define("_AM_USERLOG_SET_UPDATE","هشدار! تنظیم ارسالی شما ساخته نشد چون تنظیم دیگری با نام %1\$s در پایگاه داده با اطلاعات مشابه ثبت از طریق و شماره یکتا وجود داشت. در هر حال این تنظیم با گزینه های وارد شده توسط شما با موفقیت به روز شد.");
+define("_AM_USERLOG_SET_CANCEL","لغو");
+
+// setting.php delete
+define("_AM_USERLOG_SET_DELETE_CONFIRM","آیا مطمان هستید که میخواهید تنظیم %1\$s را حذف کنید؟");
+define("_AM_USERLOG_SET_DELETE_ERROR","نا توانی در حذف تنظیم %1\$s");
+define("_AM_USERLOG_SET_DELETE_SUCCESS","تنظیم %1\$s با موفقیت حذف شد.");
+
+// setting.php create/clean cache
+define("_AM_USERLOG_SET_CACHE","فایل کش تنظیم مربوطه با موفقیت ساخته یا ویرایش شد.");
+define("_AM_USERLOG_SET_CLEANCACHE","فایل کش تنظیم مربوطه با موفقیت حذف شد.");
+define("_AM_USERLOG_SET_CLEANCACHE_ALL","آیا میخواهید همه فایل های کش مربوط به تنظیمات را حذف کنید؟");
+define("_AM_USERLOG_SET_CLEANCACHE_SUCCESS","%1\$d عدد فایل کش مربوط به تنظیمات با موفقیت حذف شد.");
+define("_AM_USERLOG_SET_CLEANCACHE_NOFILE","هیچ فایل کش مربوط به تنظیم وجود ندارد تا حذف شود.");
+
+// logs.php form
+define("_AM_USERLOG_LOGFORM","اطلاعات را در فرم وارد کرده و اینتر کنید یا دکمه ارسال را در زیر صفحه بزنید");
+
+define("_AM_USERLOG_LOGS_PERPAGE","تعداد ثبت شده در هر صفحه");
+define("_AM_USERLOG_LOGS_PERPAGE_DSC","عدد پیش فرض %1\$s در قسمت ویژگی های ماژول قابل تغییر است.");
+define("_AM_USERLOG_SORT","مرتب سازی بر اساس");
+define("_AM_USERLOG_SORT_DSC","یک مقدار را انتخاب کنید تا همه ثبت شده ها بر اساس آن مرنب شوند.");
+define("_AM_USERLOG_ORDER","صعودی/نزولی");
+define("_AM_USERLOG_ORDER_DSC","صعودی یا نزولی مرتب شوند");
+
+// for all INT logs use these definition
+define("_AM_USERLOG_INTGT","%1\$s بزرگتر از");
+define("_AM_USERLOG_INTLT","%1\$s کوچکتر از");
+define("_AM_USERLOG_TIMEGT","%1\$s از");
+define("_AM_USERLOG_TIMELT","%1\$s تا");
+define("_AM_USERLOG_INT_FORM","یک '%1\$s' یا چند '%2\$s's با جداسازی توسط کاما بنویسید تا ثبت شده ها بر اساس آن نمایش داده شوند. مثلا: 23,32,12");
+define("_AM_USERLOG_INTGT_FORM","یک '%1\$s' .وارد کنید تا تمام '%2\$s' های بزرگتر از آن نمایش داده شوند.");
+define("_AM_USERLOG_INTLT_FORM","یک '%1\$s' وارد کنید تا تمام '%2\$s' های کوچکتر از آن نمایش داده شوند.");
+define("_AM_USERLOG_TIMEGT_FORM","یک زمان وارد کنید تا %1\$s را از آن زمان به بعد نمایش دهد. اعداد مثبت برای روز ها و اعداد منفی را برای ساعت ها وارد کنید. مثلا: 1 یعنی از یک روز قبل.");
+define("_AM_USERLOG_TIMELT_FORM","یک زمان وارد کنید تا %1\$s را تا آن زمان نمایش دهد. اعداد مثبت برای روز ها و اعداد منفی را برای ساعت ها وارد کنید. مثلا: 1 یعنی تا یک روز قبل.");
+// Translators: do not touch below for now
+// START DO NOT TOUCH
+define("_AM_USERLOG_LOG_ID_FORM",_AM_USERLOG_INT_FORM);
+define("_AM_USERLOG_LOG_IDGT",sprintf(_AM_USERLOG_INTGT,_AM_USERLOG_LOG_ID));
+define("_AM_USERLOG_LOG_IDGT_FORM",_AM_USERLOG_INTGT_FORM);
+define("_AM_USERLOG_LOG_IDLT",sprintf(_AM_USERLOG_INTLT,_AM_USERLOG_LOG_ID));
+define("_AM_USERLOG_LOG_IDLT_FORM",_AM_USERLOG_INTLT_FORM);
+
+define("_AM_USERLOG_LOG_TIMEGT",sprintf(_AM_USERLOG_TIMEGT,_AM_USERLOG_LOG_TIME));
+define("_AM_USERLOG_LOG_TIMEGT_FORM",sprintf(_AM_USERLOG_TIMEGT_FORM,_AM_USERLOG_LOG_TIME));
+define("_AM_USERLOG_LOG_TIMELT",sprintf(_AM_USERLOG_TIMELT,_AM_USERLOG_LOG_TIME));
+define("_AM_USERLOG_LOG_TIMELT_FORM",sprintf(_AM_USERLOG_TIMELT_FORM,_AM_USERLOG_LOG_TIME));
+
+define("_AM_USERLOG_UID_FORM",_AM_USERLOG_INT_FORM);
+define("_AM_USERLOG_UIDGT",sprintf(_AM_USERLOG_INTGT,_AM_USERLOG_UID));
+define("_AM_USERLOG_UIDGT_FORM",_AM_USERLOG_INTGT_FORM);
+define("_AM_USERLOG_UIDLT",sprintf(_AM_USERLOG_INTLT,_AM_USERLOG_UID));
+define("_AM_USERLOG_UIDLT_FORM",_AM_USERLOG_INTLT_FORM);
+
+define("_AM_USERLOG_LAST_LOGINGT",sprintf(_AM_USERLOG_TIMEGT,_AM_USERLOG_LAST_LOGIN));
+define("_AM_USERLOG_LAST_LOGINGT_FORM",sprintf(_AM_USERLOG_TIMEGT_FORM,_AM_USERLOG_LAST_LOGIN));
+define("_AM_USERLOG_LAST_LOGINLT",sprintf(_AM_USERLOG_TIMELT,_AM_USERLOG_LAST_LOGIN));
+define("_AM_USERLOG_LAST_LOGINLT_FORM",sprintf(_AM_USERLOG_TIMELT_FORM,_AM_USERLOG_LAST_LOGIN));
+
+define("_AM_USERLOG_ITEM_ID_FORM",_AM_USERLOG_INT_FORM);
+define("_AM_USERLOG_ITEM_IDGT",sprintf(_AM_USERLOG_INTGT,_AM_USERLOG_ITEM_ID));
+define("_AM_USERLOG_ITEM_IDGT_FORM",_AM_USERLOG_INTGT_FORM);
+define("_AM_USERLOG_ITEM_IDLT",sprintf(_AM_USERLOG_INTLT,_AM_USERLOG_ITEM_ID));
+define("_AM_USERLOG_ITEM_IDLT_FORM",_AM_USERLOG_INTLT_FORM);
+// END DO NOT TOUCH
+
+define("_AM_USERLOG_ADMIN_FORM","بله را انتخاب کنید تا تمام ثبت شده های کاربران دارای دسترسی مدیریت را نمایش دهد.");
+define("_AM_USERLOG_PAGEADMIN_FORM","بله را انتخاب کنید تا تمام صفحات مدیریت ماژول ها را نمایش دهد.");
+define("_AM_USERLOG_GROUPS_FORM","یک گروه را با پیشوند 'g' وارد کنید (و یا چندین گروه با جداسازی توسط کاما) تا تمام ثبت شده های مربوط به اعضای متعلق به آن گروه ها را نمایش دهد. اگر با پیشوند '!g' وارد کنید اعضایی را که متعلق به آن گروه ها نیستند را نمایش میدهد. مثلا: g1,g2,!g4 یعنی همه کاربران متعلق به گروه های یک یا دو ولی آنهایی که متعلق به گروه چهار نیستند.4");
+
+// for all other text logs use just one definition
+define("_AM_USERLOG_TEXT_FORM","یک '%1\$s' کامل یا قسمتی از '%2\$s' را بنویسید تا ثبت شده های تمام کاربران دارای آن را نمایش دهد (با پیشوند '!' تمام کاربرانی که دارای آن نیستند). شما میتوانید چندین مورد را با جداسازی توسط کاما وارد کنید. مثلا: TERM1, !TERM2, TERM3 یعنی تمام آنهایی که دارای TERM1 و TERM3 هستند ولی TERM2 را ندارند.");
+// Translators: do not touch below for now
+// START DO NOT TOUCH
+define("_AM_USERLOG_UNAME_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_USER_IP_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_USER_AGENT_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_URL_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_SCRIPT_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_REFERER_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_PAGETITLE_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_MODULE_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_MODULE_NAME_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_ITEM_NAME_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_REQUEST_METHOD_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_GET_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_POST_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_REQUEST_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_FILES_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_ENV_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_SESSION_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_COOKIE_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_HEADER_FORM",_AM_USERLOG_TEXT_FORM);
+define("_AM_USERLOG_LOGGER_FORM",_AM_USERLOG_TEXT_FORM);
+// END DO NOT TOUCH
+// logs.php engine/file
+define("_AM_USERLOG_ENGINE","محل ذخیره");
+define("_AM_USERLOG_ENGINE_DSC","مکان ذخیره را وارد کنید تا ثبت شده ها از آنجا خوانده شوند.");
+define("_AM_USERLOG_ENGINE_FILE","فایل");
+define("_AM_USERLOG_ENGINE_DB","پایگاه داده");
+define("_AM_USERLOG_FILE","فایل ها");
+define("_AM_USERLOG_FILE_DSC","فایل هایی را که میخواهید بخوانید انتخاب کنید.");
+define("_AM_USERLOG_FILE_WORKING","فایل در حال کار");
+
+// logs.php error
+define("_AM_USERLOG_LOG_ERROR","هیچ موردی با این شرایط پیدا نشد.");
+define("_AM_USERLOG_LOG_STATUS","%1\$s مورد پیدا شد.");
+define("_AM_USERLOG_LOG_PAGE","صفحه");
+
+// logs.php delete
+define("_AM_USERLOG_LOG_DELETE_SELECT","حذف موارد انتخابی در این صفحه.");
+define("_AM_USERLOG_LOG_PURGE_ALL","حذف تمام موارد پیدا شده در تمام صفحات");
+define("_AM_USERLOG_LOG_DELETE_CONFIRM","آیا مطمانید که میخواهید حذف کنید؟ موارد کاملا از پایگاه داده حذف خواهند شد.");
+define("_AM_USERLOG_LOG_DELETE_SUCCESS","%1\$d مورد با موفقیت حذف شد.");
+define("_AM_USERLOG_LOG_DELETE_SUCCESS_QUERY","%1\$d مورد با موفقیت با شرایط '%2\$s' حذف شد.");
+define("_AM_USERLOG_LOG_DELETE_ERROR","خطا. شرایط حذف اشتباه است.");
+define("_AM_USERLOG_LOG_DELETE_ERRORSELECT","هیچ موردی برای حذف انتخاب نکرده اید.");
+
+// logs.php select
+define("_AM_USERLOG_LOG_SELECT","یک گزینه را برای انجام عملیات در این صفحه انتخاب کنید.");
+define("_AM_USERLOG_LOG_SELECT_BULK","یک گزینه را برای انجام عملیات در تمام صفحات انتخاب کنید.");
+define("_AM_USERLOG_LOG_ERRORSELECT","هیچ موردی را انتخاب نکرده اید.");
+
+// logs.php export
+define("_AM_USERLOG_LOG_EXPORT_CSV_SELECT","تبدیل تمام موارد انتخاب شده به فایل اکسل با فرمت csv.");
+define("_AM_USERLOG_LOG_EXPORT_CSV_ALL","تبدیل تمام موارد پیدا شده در تمام صفحات به فایل اکسل با فرمت csv");
+define("_AM_USERLOG_LOG_EXPORT_SUCCESS","%1\$d مورد با موفقیت به فایل اکسل با فرمت csv تبدیل و ذخیره شد. فایل csv: %2\$s");
+define("_AM_USERLOG_LOG_EXPORT_ERROR","خطا. شرایط تبدیل اشتباه است.");
+
+// logs.php template
+define("_AM_USERLOG_SHOW_FORM","نمایش فرم بالای صفحه");
+define("_AM_USERLOG_HIDE_FORM","مخفی کردن فرم بالای صفحه");
+define("_AM_USERLOG_UP","برو بالا");
+define("_AM_USERLOG_DOWN","برو پایین");
+
+// views block
+define("_AM_USERLOG_VIEW_ALL","تمام بازدید ها");
+define("_AM_USERLOG_VIEW_MODULE","بازدید های ماژول");
+define("_AM_USERLOG_VIEW_USER","بازدید های کاربران");
+define("_AM_USERLOG_VIEW_GROUP","بازدید های گروه ها");
+define("_AM_USERLOG_VIEW","بازدید ها");
+
+// index.php stats.php
+define("_AM_USERLOG_STATS_ABSTRACT","خلاصه آمار");
+define("_AM_USERLOG_STATS_TYPE_PERIOD","تعداد %1\$s %2\$s در %3\$s وجود دارد.");
+// %2\$s for above
+define("_AM_USERLOG_STATS_LOG","ثبت شده");
+define("_AM_USERLOG_STATS_LOGDEL","ثبت شده حذف شده");
+define("_AM_USERLOG_STATS_SET","تنظیم");
+define("_AM_USERLOG_STATS_FILE","فایل");
+define("_AM_USERLOG_STATS_FILEALL","فایل ها در تمام شاخه ها");
+define("_AM_USERLOG_STATS_VIEWS","بازدید");
+// %3\$s for above
+define("_AM_USERLOG_ALL","کل");
+define("_AM_USERLOG_TODAY","امروز");
+define("_AM_USERLOG_WEEK","این هفته");
+define("_AM_USERLOG_MONTH","این ماه");
+
+// index.php summary
+define("_AM_USERLOG_SUMMARY","چند مثال از نوشتن شرط هایی که میتوانید ثبت شده ها را نمایش دهید");
+define("_AM_USERLOG_SUMMARY_DELETED","موارد حذف شده از پایگاه داده");
+define("_AM_USERLOG_SUMMARY_ADMIN","فعالیت کاربران دارای دسترسی مدیریت");
+define("_AM_USERLOG_SUMMARY_GOOGLE","پیدا کردن کاربرانی که از سایت گوگل وارد سایت شما شده اند.");
+
+// file.php
+define("_AM_USERLOG_FILE_ACTION","یک عمل را انتخاب کنید.");
+define("_AM_USERLOG_FILE_SELECT_ONE","باید فقط یک فایل را انتخاب کنید.");
+define("_AM_USERLOG_FILE_RENAME","تغییر نام");
+define("_AM_USERLOG_FILE_COPY","کپی کردن فایل");
+define("_AM_USERLOG_FILE_ZIP","فشرده کردن(Zip)");
+define("_AM_USERLOG_FILE_MERGE","ادغام کردن چند فایل در یک فایل");
+define("_AM_USERLOG_FILE_EXPORT_CSV","تبدیل به CSV");
+define("_AM_USERLOG_FILE_FILENAME","نام فایل را بنویسید. مثلا: myfile");
+define("_AM_USERLOG_FILE_FILENAME_DSC","توصیه: اگر نام فایل را خالی بگذارید این ماژول یک نام اوتوماتیک با توجه به شرایط و تاریخ و زمان تولید خواهد کرد. اگر در هنگام فشرده سازی یک نام که در حال حاضر وجود دارد وارد کنید, فایل های جدید به فایل فشرده قبلی اضافه میشوند و فایل های موجود در فایل فشرده قبلی به روز میشوند.");
+define("_AM_USERLOG_FILE_MERGE_SUCCESS","%1\$d فایل با موفقیت در %2\$s ادغام شد.");
+define("_AM_USERLOG_FILE_DELETE_SUCCESS","%1\$d فایل با موفقیت حذف شد.");
+define("_AM_USERLOG_FILE_RENAME_SUCCESS","فایل %1\$s با موفقیت به %2\$s تغییر نام داده شد.");
+define("_AM_USERLOG_FILE_COPY_SUCCESS","فایل %1\$s با موفقیت به %2\$s کپی شد.");
+define("_AM_USERLOG_FILE_ZIP_SUCCESS","%1\$d فایل با موفقیت فشرده شد و با نام %2\$s ذخیره شد.");
+define("_AM_USERLOG_FILE_EXOPORT_SUCCESS","%1\$d فایل با موفقیت تبدیل شد و با نام %2\$s ذخیره شد.");
+define("_...
[truncated message content] |
|
From: <ir...@us...> - 2013-04-03 02:56:50
|
Revision: 11339
http://sourceforge.net/p/xoops/svn/11339
Author: irmtfan
Date: 2013-04-03 02:56:45 +0000 (Wed, 03 Apr 2013)
Log Message:
-----------
fix: need to have all log options in export.
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/logs.php
XoopsModules/userlog/trunk/userlog/class/log.php
XoopsModules/userlog/trunk/userlog/language/persian/admin.php
Modified: XoopsModules/userlog/trunk/userlog/admin/logs.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-04-02 21:18:36 UTC (rev 11338)
+++ XoopsModules/userlog/trunk/userlog/admin/logs.php 2013-04-03 02:56:45 UTC (rev 11339)
@@ -153,7 +153,7 @@
// skip these headers because we can merge it to request method column
$skips = array("get", "post", "request", "files", "env");
// prepared for display. timestamps and var_export
-$logs = $loglogObj->arrayToDisplay($logs, $skips);
+$logs = $loglogObj->arrayToDisplay($logs);
// logs to template
$GLOBALS['xoopsTpl']->assign('logs', $logs);
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-04-02 21:18:36 UTC (rev 11338)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-04-03 02:56:45 UTC (rev 11339)
@@ -220,7 +220,7 @@
return $ret;
}
- public function arrayToDisplay($logs, $skips)
+ public function arrayToDisplay($logs, $skips = array())
{
foreach($logs as $log_id=>$log) {
$logs[$log_id]["log_time"] = $this->userlog->formatTime($logs[$log_id]["log_time"]);
Modified: XoopsModules/userlog/trunk/userlog/language/persian/admin.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/persian/admin.php 2013-04-02 21:18:36 UTC (rev 11338)
+++ XoopsModules/userlog/trunk/userlog/language/persian/admin.php 2013-04-03 02:56:45 UTC (rev 11339)
@@ -122,7 +122,7 @@
define("_AM_USERLOG_INTLT","%1\$s کوچکتر از");
define("_AM_USERLOG_TIMEGT","%1\$s از");
define("_AM_USERLOG_TIMELT","%1\$s تا");
-define("_AM_USERLOG_INT_FORM","یک '%1\$s' یا چند '%2\$s's با جداسازی توسط کاما بنویسید تا ثبت شده ها بر اساس آن نمایش داده شوند. مثلا: 23,32,12");
+define("_AM_USERLOG_INT_FORM","یک '%1\$s' یا چند '%2\$s' با جداسازی توسط کاما بنویسید تا ثبت شده ها بر اساس آن نمایش داده شوند. مثلا: 23,32,12");
define("_AM_USERLOG_INTGT_FORM","یک '%1\$s' .وارد کنید تا تمام '%2\$s' های بزرگتر از آن نمایش داده شوند.");
define("_AM_USERLOG_INTLT_FORM","یک '%1\$s' وارد کنید تا تمام '%2\$s' های کوچکتر از آن نمایش داده شوند.");
define("_AM_USERLOG_TIMEGT_FORM","یک زمان وارد کنید تا %1\$s را از آن زمان به بعد نمایش دهد. اعداد مثبت برای روز ها و اعداد منفی را برای ساعت ها وارد کنید. مثلا: 1 یعنی از یک روز قبل.");
|
|
From: <ir...@us...> - 2013-04-06 06:50:28
|
Revision: 11350
http://sourceforge.net/p/xoops/svn/11350
Author: irmtfan
Date: 2013-04-06 06:50:24 +0000 (Sat, 06 Apr 2013)
Log Message:
-----------
- fix: hide filename element when delete is selected in admin/file.php(2013/04/06)
- improve: show the name of action in confirm box in admin/file.php(2013/04/06)
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/addon/perm.php
XoopsModules/userlog/trunk/userlog/admin/file.php
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/docs/readme.txt
XoopsModules/userlog/trunk/userlog/docs/readme_devs.txt
Modified: XoopsModules/userlog/trunk/userlog/admin/addon/perm.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/addon/perm.php 2013-04-06 00:06:06 UTC (rev 11349)
+++ XoopsModules/userlog/trunk/userlog/admin/addon/perm.php 2013-04-06 06:50:24 UTC (rev 11350)
@@ -21,7 +21,7 @@
* @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.
+// Here you can set ADDITIONAL permission in file for webmasters in your website, ONLY if you want to limit the access to userlog module for some of them.
// Webmasters that dont have access cannot:
// 1- go to the userlog > admin
Modified: XoopsModules/userlog/trunk/userlog/admin/file.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/file.php 2013-04-06 00:06:06 UTC (rev 11349)
+++ XoopsModules/userlog/trunk/userlog/admin/file.php 2013-04-06 06:50:24 UTC (rev 11350)
@@ -97,23 +97,23 @@
$fileEl = $loglogObj->buildFileSelectEle($file, true, 10);// multiselect = true, size=10
$form->addElement($fileEl);
$actionEl = new XoopsFormSelect(_AM_USERLOG_FILE_ACTION,"op", $opentry);
-$actionEl->addOptionArray(array("del"=>_DELETE,
- "rename"=>_AM_USERLOG_FILE_RENAME,
- "copy"=>_AM_USERLOG_FILE_COPY,
- "merge"=>_AM_USERLOG_FILE_MERGE,
- "zip" =>_AM_USERLOG_FILE_ZIP,
- "export-csv"=>_AM_USERLOG_FILE_EXPORT_CSV
- ));
-$actionEl->setExtra("onchange=\"document.forms.filemanager.filename.className = ''; if(this.value == 'del') { document.forms.filemanager.filename.className = 'hidden';}\"");
+$actions = array( "zip" =>_AM_USERLOG_FILE_ZIP,
+ "del"=>_DELETE,
+ "rename"=>_AM_USERLOG_FILE_RENAME,
+ "copy"=>_AM_USERLOG_FILE_COPY,
+ "merge"=>_AM_USERLOG_FILE_MERGE,
+ "export-csv"=>_AM_USERLOG_FILE_EXPORT_CSV
+ );
+$actionEl->addOptionArray($actions);
+$actionEl->setExtra("onchange=\"var el = document.forms.filemanager.filename.parentElement.parentElement; el.className = ''; if(this.value == 'del') { el.className = 'hidden'}\"");
$form->addElement($actionEl);
$filenameEl = new XoopsFormText(_AM_USERLOG_FILE_FILENAME, "filename", 50, 255, '');
-$filenameEl->setExtra("Class='hidden'");
$filenameEl->setDescription(_AM_USERLOG_FILE_FILENAME_DSC);
$form->addElement($filenameEl);
$submitEl = new XoopsFormButton(_SUBMIT, 'submitfilemanager', _SUBMIT, 'submit');
$form->addElement($submitEl);
$confirmEl = new XoopsFormHidden("confirm",0);
-$confirmEl->customValidationCode[]="if(confirm('" . _AM_USERLOG_FILE_CONFIRM . "' + ' action=' + myform.op.value + ' ' + myform.file.value)) {myform.confirm.value = 1;} else {return false;};";
+$confirmEl->customValidationCode[]="if(confirm('" . _AM_USERLOG_FILE_CONFIRM . " ' + myform.op.options[myform.op.selectedIndex].innerHTML + '\\n " . _AM_USERLOG_FILE . ": ' + myform.file.value)) {myform.confirm.value = 1;} else {return false;};";
$form->addElement($confirmEl);
$GLOBALS['xoopsTpl']->assign('form', $form->render());
$GLOBALS['xoopsTpl']->assign('logo',$indexAdmin->addNavigation('file.php'));
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-04-06 00:06:06 UTC (rev 11349)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-04-06 06:50:24 UTC (rev 11350)
@@ -1,5 +1,7 @@
Userlog
Changelog:
+- fix: hide filename element when delete is selected in admin/file.php(2013/04/06)
+- improve: show the name of action in confirm box in admin/file.php(2013/04/06)
- change version to BETA 1(2013/04/01)
- fix some parts in templates, definitions, help.html(2013/04/01)
- bug fix: item_id is int not text. add greater than and lower than for item_id in logs form(2013/04/01)
Modified: XoopsModules/userlog/trunk/userlog/docs/readme.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/readme.txt 2013-04-06 00:06:06 UTC (rev 11349)
+++ XoopsModules/userlog/trunk/userlog/docs/readme.txt 2013-04-06 06:50:24 UTC (rev 11350)
@@ -13,6 +13,7 @@
Important notice: There is a new "ADDITIONAL permission in file for webmasters" addon introduced in userlog module.
if you want other webmasters dont have access to userlog module this addon is for you.
for more information go to userlog/admin/addon/perm.php
+If you dont need this addon you just need to remove addon/perm.php
known bugs/malfunctioning in userlog module:
1- userlog will not work in XOOPS255/index.php (homepage) when no module is set for start page.
Modified: XoopsModules/userlog/trunk/userlog/docs/readme_devs.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/readme_devs.txt 2013-04-06 00:06:06 UTC (rev 11349)
+++ XoopsModules/userlog/trunk/userlog/docs/readme_devs.txt 2013-04-06 06:50:24 UTC (rev 11350)
@@ -2,7 +2,7 @@
1- log user activities structure.
I assume we need to gather below information from user. If you have any idea about them please let me know.
-i dont sanitize them because i want to log them as ther are. what is your idea. Im a very basic programmer. please help me.
+i dont sanitize them because i want to log them as they are. what is your idea. Im a very basic programmer. please help me.
in userlog/class/setting.php
@@ -77,15 +77,23 @@
"title" => _AM_USERLOG_PAGETITLE,
"value" => isset($GLOBALS['xoopsTpl']) ? $GLOBALS['xoopsTpl']->get_template_vars("xoops_pagetitle") : ""
),
+ "pageadmin" => array( "type" => "bool",
+ "title" => _AM_USERLOG_PAGEADMIN,
+ "value" => (isset($GLOBALS['xoopsOption']['pagetype']) && $GLOBALS['xoopsOption']['pagetype'] == "admin") ? 1 : 0
+ ),
"module" => array( "type" => "text",
"title" => _AM_USERLOG_MODULE,
"value" => $this->userlog->getLogModule()->getVar("dirname")
),
+ "module_name" => array( "type" => "text",
+ "title" => _AM_USERLOG_MODULE_NAME,
+ "value" => $this->userlog->getLogModule()->getVar("name")
+ ),
"item_name" => array( "type" => "text",
"title" => _AM_USERLOG_ITEM_NAME,
"value" => null
),
- "item_id" => array( "type" => "text",
+ "item_id" => array( "type" => "int",
"title" => _AM_USERLOG_ITEM_ID,
"value" => null
),
@@ -156,7 +164,7 @@
[/code]
2- setting structure.
-i think we just need to log users based on "uid" or "gid" or "ip" and it will cover all possibilities. please let me know your idea.
+I think we just need to log users by getting "uid" or "gid" or "ip" and it will cover all possibilities. please let me know your idea.
the table structure is:
in userlog/sql/mysql.sql
@@ -173,7 +181,7 @@
) ENGINE=MyISAM;
[/code]
-The above is clear. more information in module help.
+The above is clear. more information in userlog > help.
3- performance.
it checks every hit to see if the visitor have a setting or not. for the best performance i wrote a getSet function like this.
@@ -238,8 +246,8 @@
return false;
}
[/code]
-as you can see it create cache files for each settings. IMO it will help to reduce queries for users have a setting.
-for getting settings from db i firstly used criteria but then i decide to get all settings at once and then find if the user have setting or not. IMO it has the better performance. please let me know your opinion. what is the best performance? this function is important for your review.
+as you can see it create cache files for each setting. IMO it will help to reduce queries for users have a setting.
+for getting settings from db at first I used criteria but then i decide to get all settings at once and then find if the user have setting or not. IMO it has the better performance. please let me know your opinion. what is the best performance? this function is important for your review.
Also i add a probability check to access to database in random.
4- views
@@ -247,10 +255,10 @@
but this counter is useless. we dont need forever views. we need views in a specific time period.
in every news agency the first and top block is "today hot news" and it means news that had been most viewed today.
-for a long time that was an unsolved issue for me and i think in the whole xoops we have this problem in all modules.
+for a long time that was an unsolved issue for me and I think in the whole xoops we have this problem in all modules.
after starting userlog for a different purpose I suddenly reach to an innovative idea for gathering all views in all modules.
-i used module "notification" because every module item that should have views have a notification too.
-there we have all needed information about items. so i wrote this nice and tricky function:
+I used "notification" functionality because every module item that should have views have a notification too.
+There we have all needed information about items. so i wrote this nice and tricky function:
[code]
public function setItem()
{
@@ -276,5 +284,5 @@
as you can see i just need to store item_name and item_id because i have the module dirname and script name!!!
-IMO we should stick to this idea to have a overall item views in the XOOPS and drop all counters in all modules.
-i need your idea about this.
\ No newline at end of file
+IMO we should stick to this idea to have an "overall item views" in the XOOPS and drop all counters in all modules.
+I need your idea about this.
\ No newline at end of file
|
|
From: <ir...@us...> - 2013-04-06 13:03:58
|
Revision: 11351
http://sourceforge.net/p/xoops/svn/11351
Author: irmtfan
Date: 2013-04-06 13:03:55 +0000 (Sat, 06 Apr 2013)
Log Message:
-----------
- fix and improve: parse all files in all paths before any action in class/log.php and admin/file.php(2013/04/06)
- fix: return false when no file is selected in class/log.php(2013/04/06)
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/admin/file.php
XoopsModules/userlog/trunk/userlog/blocks/views.php
XoopsModules/userlog/trunk/userlog/class/log.php
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/xoops_version.php
Modified: XoopsModules/userlog/trunk/userlog/admin/file.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/admin/file.php 2013-04-06 06:50:24 UTC (rev 11350)
+++ XoopsModules/userlog/trunk/userlog/admin/file.php 2013-04-06 13:03:55 UTC (rev 11351)
@@ -33,6 +33,7 @@
$opentry = UserlogRequest::getString('op', '');
$filename = UserlogRequest::getString('filename', '');
$confirm = UserlogRequest::getString('confirm',0, 'post');
+$file = $loglogObj->parseFiles($file);
$totalFiles = count($file);
if(!empty($opentry) && ($confirm == 0 || $totalFiles == 0)) {
redirect_header("file.php", 5, sprintf(_AM_USERLOG_ERROR,""));
@@ -66,10 +67,6 @@
redirect_header("file.php", 5, sprintf(_AM_USERLOG_ERROR,implode("<br\>",$loglogObj->getErrors())));
break;
case "merge":
- // if "all"
- if ($file[0] == "all") {
- list($allFiles,$totalFiles) = $Userlog->getAllLogFiles();
- }
if ($mergeFile = $loglogObj->mergeFiles($file, $filename)) {
redirect_header("file.php", 5, sprintf(_AM_USERLOG_FILE_MERGE_SUCCESS, $totalFiles,$mergeFile));
}
Modified: XoopsModules/userlog/trunk/userlog/blocks/views.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/blocks/views.php 2013-04-06 06:50:24 UTC (rev 11350)
+++ XoopsModules/userlog/trunk/userlog/blocks/views.php 2013-04-06 13:03:55 UTC (rev 11351)
@@ -29,11 +29,11 @@
// options[0] - number of items to show in block. the default is 10
// options[1] - items to select in Where claus
-// options[2] - Time period - default 1 day
-// options[3] - Uid in WHERE claus: select some users to only count views by them 0-all (by default)
-// options[4] - Gid in WHERE claus: select some groups to only count views by them 0-all (by default)
-// options[5] - Sort - module, views
-// options[6] - Order - DESC, ASC
+// options[2] - Time period - default: 1 day
+// options[3] - Uid in WHERE claus: select some users to only count views by them -1 -> all (by default)
+// options[4] - Gid in WHERE claus: select some groups to only count views by them 0 -> all (by default)
+// options[5] - Sort - views, module dirname, module name, module views default: views
+// options[6] - Order - DESC, ASC default: DESC
function userlog_views_show($options)
{
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-04-06 06:50:24 UTC (rev 11350)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-04-06 13:03:55 UTC (rev 11351)
@@ -291,9 +291,14 @@
$fileHandler->close();
return true;
}
- public function exportFilesToCsv($log_file, $headers, $csvNamePrefix="list_", $delimiter=";")
+ public function exportFilesToCsv($log_files = array(), $headers, $csvNamePrefix="list_", $delimiter=";")
{
- list($logs, $totalLogs) = $this->getLogsFromFiles($log_file);
+ $log_files = $this->parseFiles($log_files);
+ if( ($totalFiles = count($log_files)) == 0) {
+ $this->setErrors(_AM_USERLOG_FILE_SELECT_ONE);
+ return false;
+ }
+ list($logs, $totalLogs) = $this->getLogsFromFiles($log_files);
$logs = $this->arrayToDisplay($logs);
$csvNamePrefix = basename($csvNamePrefix);
if($csvFile = $this->exportLogsToCsv($logs, $headers, $csvNamePrefix . "from_file_total_" . $totalLogs ,$delimiter)) {
@@ -323,10 +328,10 @@
$fileHandler->close();
return $csvFile;
}
- public function getLogsFromFiles($log_file = null, $limit = 0, $start = 0, $options = null, $sort = "log_time", $order = "DESC")
+ public function getLogsFromFiles($log_files = array(), $limit = 0, $start = 0, $options = null, $sort = "log_time", $order = "DESC")
{
$logs = array();
- $logsStr = $this->readFiles($log_file);
+ $logsStr = $this->readFiles($log_files);
// if no logs return empty array and total = 0
if(empty($logsStr)) return array(array(), 0);
foreach ($logsStr as $id=>$log) {
@@ -432,36 +437,23 @@
}
public function readFiles($log_files = array())
{
- if(empty($log_files[0]) || count($log_files) == 0) {
+ $log_files = $this->parseFiles($log_files);
+ if( ($totalFiles = count($log_files)) == 0) {
return $this->readFile();
}
$logs = array();
- $ext = pathinfo($log_files[0], PATHINFO_EXTENSION);
- // if "all" or no extension => $path
- if ($log_files[0] == "all" || empty($ext)) {
- list($allFiles,$totalFiles) = $this->userlog->getAllLogFiles();
- if (empty($totalFiles)) return array();
- foreach($allFiles as $path=>$files) {
- foreach($files as $file) {
- $logs = array_merge($logs,$this->readFile($path . "/" . $file));
- }
- // if it is $path
- if ($log_files[0] != "all") {
- if ($log_files[0] == $path) break; // exit for loop and return logs
- $logs = array(); // reset logs for next path
- }
- }
- return $logs;
- }
foreach($log_files as $file) {
- $ext = pathinfo($file, PATHINFO_EXTENSION);
- if (empty($ext)) return $logs;
$logs = array_merge($logs,$this->readFile($file));
}
return $logs;
}
public function mergeFiles($log_files = array(), $mergeFileName = null)
{
+ $log_files = $this->parseFiles($log_files);
+ if( ($totalFiles = count($log_files)) == 0) {
+ $this->setErrors(_AM_USERLOG_FILE_SELECT_ONE);
+ return false;
+ }
$logs = array();
$logsStr = $this->readFiles($log_files);
$data = implode("\n",$logsStr);
@@ -504,12 +496,12 @@
$fileHandler->XoopsFileHandler($log_file, false);
if (!$fileHandler->exists()) {
$this->setErrors("Cannot open file ({$log_file})");
- return false;
+ return array();
}
if (($data = $fileHandler->read()) == false) {
$this->setErrors("Cannot read file ({$log_file})");
- return false;
+ return array();
}
$fileHandler->close();
$logs = explode("\n",$data);
@@ -517,11 +509,12 @@
}
public function deleteFiles($log_files = array())
{
- $deletedFiles = 0;
- if (count($log_files) == 0) {
- $this->setErrors("No file to delete");
+ $log_files = $this->parseFiles($log_files);
+ if( ($totalFiles = count($log_files)) == 0) {
+ $this->setErrors(_AM_USERLOG_FILE_SELECT_ONE);
return false;
}
+ $deletedFiles = 0;
// file open/read
$fileHandler = XoopsFile::getHandler();
foreach($log_files as $file) {
@@ -603,8 +596,26 @@
$fileHandler->close();
return $newFile;
}
- public function zipFiles($log_files = array(), $zipFileName = null)
+ public function getFilesFromFolders($folders = array())
{
+ list($allFiles,$totalFiles) = $this->userlog->getAllLogFiles();
+ if (empty($totalFiles)) return array();
+ $pathFiles = array();
+ $getAll = false;
+ if(in_array("all",$folders)) $getAll = true;
+ foreach($allFiles as $path=>$files) {
+ if($getAll || in_array($path, $folders)) {
+ foreach($files as $file) {
+ $pathFiles[] = $path . "/" . $file;
+ }
+ }
+ }
+ return $pathFiles;
+ }
+ public function parseFiles($log_files = array())
+ {
+ $pathFiles = $this->getFilesFromFolders($log_files);
+ $log_files = array_unique(array_merge($log_files,$pathFiles));
// file open/read
$fileHandler = XoopsFile::getHandler();
foreach($log_files as $key=>$file) {
@@ -616,6 +627,11 @@
}
}
$fileHandler->close();
+ return $log_files;
+ }
+ public function zipFiles($log_files = array(), $zipFileName = null)
+ {
+ $log_files = $this->parseFiles($log_files);
if( ($totalFiles = count($log_files)) == 0) {
$this->setErrors("No file to zip");
return false;
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-04-06 06:50:24 UTC (rev 11350)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-04-06 13:03:55 UTC (rev 11351)
@@ -1,5 +1,7 @@
Userlog
Changelog:
+- fix and improve: parse all files in all paths before any action in class/log.php and admin/file.php(2013/04/06)
+- fix: return false when no file is selected in class/log.php(2013/04/06)
- fix: hide filename element when delete is selected in admin/file.php(2013/04/06)
- improve: show the name of action in confirm box in admin/file.php(2013/04/06)
- change version to BETA 1(2013/04/01)
Modified: XoopsModules/userlog/trunk/userlog/xoops_version.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-04-06 06:50:24 UTC (rev 11350)
+++ XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-04-06 13:03:55 UTC (rev 11351)
@@ -100,11 +100,11 @@
$i = 0;
// options[0] - number of items to show in block. the default is 10
// options[1] - items to select in Where claus
-// options[2] - Time period - default 1 day
-// options[3] - Uid in WHERE claus: select some users to only count views by them 0-all (by default)
-// options[4] - Gid in WHERE claus: select some groups to only count views by them 0-all (by default)
-// options[5] - Sort - module, views
-// options[6] - Order - DESC, ASC
+// options[2] - Time period - default: 1 day
+// options[3] - Uid in WHERE claus: select some users to only count views by them -1 -> all (by default)
+// options[4] - Gid in WHERE claus: select some groups to only count views by them 0 -> all (by default)
+// options[5] - Sort - views, module dirname, module name, module views default: views
+// options[6] - Order - DESC, ASC default: DESC
$modversion['blocks'][$i]['file'] = "views.php";
$modversion['blocks'][$i]['name'] = _MI_USERLOG_BLOCK_VIEWS;
$modversion['blocks'][$i]['description'] = _MI_USERLOG_BLOCK_VIEWS_DSC;
|
|
From: <ir...@us...> - 2013-04-07 08:54:48
|
Revision: 11356
http://sourceforge.net/p/xoops/svn/11356
Author: irmtfan
Date: 2013-04-07 08:54:45 +0000 (Sun, 07 Apr 2013)
Log Message:
-----------
- change version to 1.01 RC 1 (2013/04/07)
- add update functionality - e.g.: update is possible from v1 beta1 to v1.01 rc1(2013/04/07)
- fix: change module_name field in mod_userlog_log table size from VARCHAR(25) to VARCHAR(50) (2013/04/07)
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/class/log.php
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/include/module.php
XoopsModules/userlog/trunk/userlog/sql/mysql.sql
XoopsModules/userlog/trunk/userlog/xoops_version.php
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-04-07 03:14:28 UTC (rev 11355)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-04-07 08:54:45 UTC (rev 11356)
@@ -54,7 +54,7 @@
$this->initVar("pagetitle", XOBJ_DTYPE_TXTBOX, null, false, 255);
$this->initVar("pageadmin", XOBJ_DTYPE_INT, null, false);
$this->initVar("module", XOBJ_DTYPE_TXTBOX, null, true, 25);
- $this->initVar("module_name", XOBJ_DTYPE_TXTBOX, null, true, 25);
+ $this->initVar("module_name", XOBJ_DTYPE_TXTBOX, null, true, 50);
$this->initVar("item_name", XOBJ_DTYPE_TXTBOX, null, false, 10);
$this->initVar("item_id", XOBJ_DTYPE_INT, null, false);
$this->initVar("request_method", XOBJ_DTYPE_TXTBOX, null, false, 20);
@@ -801,7 +801,31 @@
}
return $this->getCount($criteria, $notNullFields);
}
-
+ public function changeField($field = null, $structure = null)
+ {
+ $sql = "ALTER TABLE {$this->table} CHANGE {$field} {$field} {$structure}";
+ if (!$result = $this->db->queryF($sql)) {
+ xoops_error($this->db->error().'<br />'.$sql);
+ return false;
+ }
+ return true;
+ }
+ public function showFields($field = null)
+ {
+ $sql = "SHOW FIELDS FROM {$this->table}";
+ if (isset($field)) {
+ $sql .= " LIKE '{$field}'";
+ }
+ if (!$result = $this->db->queryF($sql)) {
+ xoops_error($this->db->error().'<br />'.$sql);
+ return false;
+ }
+ $ret = array();
+ while ($myrow = $this->db->fetchArray($result)) {
+ $ret[$myrow["Field"]] = $myrow;
+ }
+ return $ret;
+ }
public function &get($id)
{
static $logs;
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-04-07 03:14:28 UTC (rev 11355)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-04-07 08:54:45 UTC (rev 11356)
@@ -1,5 +1,12 @@
Userlog
Changelog:
+
+VERSION 1.01:
+- change version to 1.01 RC 1 (2013/04/07)
+- add update functionality - e.g.: update is possible from v1 beta1 to v1.01 rc1(2013/04/07)
+- fix: change module_name field in mod_userlog_log table size from VARCHAR(25) to VARCHAR(50) (2013/04/07)
+
+VERSION 1:
- fix and improve: parse all files in all paths before any action in class/log.php and admin/file.php(2013/04/06)
- fix: return false when no file is selected in class/log.php(2013/04/06)
- fix: hide filename element when delete is selected in admin/file.php(2013/04/06)
Modified: XoopsModules/userlog/trunk/userlog/include/module.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/include/module.php 2013-04-07 03:14:28 UTC (rev 11355)
+++ XoopsModules/userlog/trunk/userlog/include/module.php 2013-04-07 08:54:45 UTC (rev 11356)
@@ -25,4 +25,37 @@
{
$logsetObj = UserlogSetting::getInstance();
return $logsetObj->cleanCache(); // delete all settings caches
+}
+function xoops_module_update_userlog(&$module, $prev_version = null)
+{
+ if ($prev_version == round( $module->getInfo("version") * 100, 2 )) {
+ $module->setErrors("You have the latest " . $module->getInfo("name") . " module (". $module->getInfo("dirname") . " version " . $module->getInfo("version") . ") and update is not necessary");
+ print_r($module->getErrors());
+ return true;
+ }
+ $ret = false;
+ // first db update
+ if ($prev_version == 100) {
+ $ret = update_userlog_v100($module);
+ }
+ print_r($module->getErrors());
+ return $ret;
+}
+
+// update database from v1 to 1.01 (Beta1 to RC1)
+// module_name VARCHAR(25) change to VARCHAR(50)
+function update_userlog_v100(&$module)
+{
+ $field = "module_name";
+ $Userlog = Userlog::getInstance();
+ $ret = $Userlog->getHandler('log')->showFields($field);
+ preg_match_all('!\d+!', $ret[$field]["Type"], $nums);
+ // only change if module_name Type was VARCHAR(25)
+ if($nums[0][0] == 25) {
+ $ret2 = $Userlog->getHandler('log')->changeField($field, "VARCHAR(50)");
+ } else {
+ $ret2 = true;
+ $module->setErrors("Your table field ({$field}) with size {$ret[$field]['Type']} dont need change.");
+ }
+ return $ret2;
}
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/sql/mysql.sql
===================================================================
--- XoopsModules/userlog/trunk/userlog/sql/mysql.sql 2013-04-07 03:14:28 UTC (rev 11355)
+++ XoopsModules/userlog/trunk/userlog/sql/mysql.sql 2013-04-07 08:54:45 UTC (rev 11356)
@@ -18,7 +18,7 @@
pagetitle varchar(255) NOT NULL default '',
pageadmin smallint(1) unsigned NOT NULL default 0,
module varchar(25) NOT NULL default '',
- module_name varchar(25) NOT NULL default '',
+ module_name varchar(50) NOT NULL default '',
item_name varchar(10) NOT NULL default '',
item_id int(11) unsigned NOT NULL default 0,
request_method varchar(20) NOT NULL default '',
Modified: XoopsModules/userlog/trunk/userlog/xoops_version.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-04-07 03:14:28 UTC (rev 11355)
+++ XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-04-07 08:54:45 UTC (rev 11356)
@@ -25,7 +25,7 @@
$modversion['dirname'] = 'userlog';
xoops_loadLanguage('admin', $modversion['dirname']);
$modversion['description'] = _MI_USERLOG_DSC;
-$modversion['version'] = '1';
+$modversion['version'] = '1.01';
$modversion['author'] = 'xoops.org (irmtfan)';
$modversion['nickname'] = 'irmtfan';
$modversion['credits'] = 'The XOOPS Project Team, trabis, irmtfan, mamba, tatane, Cesag, zyspec';
@@ -34,13 +34,14 @@
$modversion['official'] = 0;
$modversion['help'] = 'page=help';
$modversion['image'] = 'images/userlog_logo.png';
+$modversion['onUpdate'] = 'include/module.php';
$modversion['onUninstall'] = 'include/module.php';
//about
-$modversion['release_date'] = '2013/04/01';
+$modversion['release_date'] = '2013/04/07';
$modversion['module_website_url'] = 'http://www.xoops.org/';
$modversion['module_website_name'] = 'XOOPS';
-$modversion['module_status'] = 'BETA 1';
+$modversion['module_status'] = 'RC 1';
$modversion['min_php'] = '5.3';
$modversion['min_xoops'] = '2.5.5';
$modversion['min_db'] = array('mysql' => '5.0.7', 'mysqli' => '5.0.7');
|
|
From: <ir...@us...> - 2013-04-17 05:06:02
|
Revision: 11390
http://sourceforge.net/p/xoops/svn/11390
Author: irmtfan
Date: 2013-04-17 05:05:57 +0000 (Wed, 17 Apr 2013)
Log Message:
-----------
- change version to 1.01 Final (2013/04/17)
- fix and improve: add eventCoreIncludeFunctionsRedirectheader to log redirects because usually prorammers use exit() after redirect_header function. in include/log.php and preloads/core.php(2013/04/17)
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/docs/readme.txt
XoopsModules/userlog/trunk/userlog/include/log.php
XoopsModules/userlog/trunk/userlog/preloads/core.php
XoopsModules/userlog/trunk/userlog/xoops_version.php
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-04-17 01:49:19 UTC (rev 11389)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-04-17 05:05:57 UTC (rev 11390)
@@ -2,6 +2,8 @@
Changelog:
VERSION 1.01:
+- change version to 1.01 Final (2013/04/17)
+- fix and improve: add eventCoreIncludeFunctionsRedirectheader to log redirects because usually prorammers use exit() after redirect_header function. in include/log.php and preloads/core.php(2013/04/17)
- fix: empty smarty variables cause some errors in templates. in admin/logs.php (2013/04/16)
- add: search logs by using a setting (logby-unique_id) in templates/userlog_admin_sets.html (2013/04/13)
- fix: sometimes xoops core getGroups() funxtion return duplicate groups in class/setting.php and admin/stats.php (2013/04/13)
Modified: XoopsModules/userlog/trunk/userlog/docs/readme.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/readme.txt 2013-04-17 01:49:19 UTC (rev 11389)
+++ XoopsModules/userlog/trunk/userlog/docs/readme.txt 2013-04-17 05:05:57 UTC (rev 11390)
@@ -4,6 +4,36 @@
=========================
XOOPS 2.5.5 php 5.3 mysql 5.0
+Features:
+=========================
+- Log user activities and navigations.
+ Examples:
+ 1- The possibility to list all the IPs used from a certain user, and conversely to list all the users logged from a defined IP to find duplicate users.
+ 2- Find deleted items from your database.
+ 3- Find admin user activities(webmasters, moderators, ...)
+ 4- Find users who come to your site from Google.
+
+- Can log users by getting User ID, User group or visitor IP.
+- Logs can be stored in file, database or both.
+- Any below user information and/or page data can be selected to be logged.
+[quote]
+User ID,Username,Is Admin?(y/n),Groups,User Last Visit,User IP,User agent,URL (Request URI),Script name,Referer URI,Page title,Is Page admin?(y/n),Module dirname,Module name,Item name,Item ID,Request method (GET, POST, ...),$_GET,$_POST,$_REQUEST,$_FILES,$_ENV,$_SESSION,$_COOKIE,Headers list,Logger
+[/quote]
+- Any active module in your installation can be selected and userlog will log users activities only in those modules.
+- You can navigate/delete/purge/export to CSV user logs in admin/logs.
+- You can render logs from database or file source engine in admin/logs.php.
+- To search for logs based on a criteria you have an advance form in admin/logs.php
+- You can see/delete/rename/copy/merge/compress(zip)/export to CSV log files in admin/file.php.
+- You can see total module views, total user views, total group views in admin/stats.php
+- you have an advance form to see any item views using some criteria like what is the module/link/log time/viewer uid/viewer group id of the item in admin/stats.php
+- by activating the views block you can set a most viewed items in a module or in the whole website in a specific period of time. e.g.: today most viewed (hot) news
+- You can set the module as Active or Idle in preferences.
+- If you need to store logs in a file, you can set the working path, working file size, working file name, ... in preferences.
+- If you need to store logs in database, you can set the maximum logs thresholds (maximum number of logs and maximum time that logs are stored in the database) in preferences.
+- Can be used as a backup/restore tool.
+- Used JSON format to store arrays to database for better performance (instead of xoops core serialize).
+
+
To Install
=========================
1- upload the userlog to /modules/userlog (upload the compressed file and decompressed via Cpanel is the best way to insure all files are correctly uploaded)
Modified: XoopsModules/userlog/trunk/userlog/include/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/include/log.php 2013-04-17 01:49:19 UTC (rev 11389)
+++ XoopsModules/userlog/trunk/userlog/include/log.php 2013-04-17 05:05:57 UTC (rev 11390)
@@ -80,4 +80,27 @@
$statsObj->updateAll("log", $Userlog->getConfig("probstats")); // default prob = 10
}
// update all time stats
-$statsObj->updateAll("log", $Userlog->getConfig("probstatsallhit")); // default prob = 1
\ No newline at end of file
+$statsObj->updateAll("log", $Userlog->getConfig("probstatsallhit")); // default prob = 1
+
+// START to log redirects when $xoopsConfig['redirect_message_ajax'] = true
+// We need to shift the position of userlog to the top of 'system_modules_active' cache file list.
+// because to log redirect pages when $xoopsConfig['redirect_message_ajax'] = true IF eventCoreIncludeFunctionsRedirectheader in system module runs first it will exit()
+// IMO It is a bug in XOOPS255/modules/system/preloads/core.php
+// IMO exit() should be commented or we should find some way to make sure all eventCoreIncludeFunctionsRedirectheader events will run before any exit();
+/*
+if (!headers_sent() && isset($xoopsConfig['redirect_message_ajax']) && $xoopsConfig['redirect_message_ajax']) {
+ $_SESSION['redirect_message'] = $args[2];
+ header("Location: " . preg_replace("/[&]amp;/i", '&', $url));
+ exit(); // IMO exit() should be commented
+}
+*/
+if ($modules_list = XoopsCache::read('system_modules_active')) {
+ $key = array_search(USERLOG_DIRNAME, $modules_list);
+ // if userlog is not in the top
+ if ($key != 0) {
+ unset($modules_list[$key]);
+ array_unshift($modules_list, USERLOG_DIRNAME);
+ XoopsCache::write('system_modules_active', $modules_list);
+ }
+}
+// END to log redirects when $xoopsConfig['redirect_message_ajax'] = true
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/preloads/core.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/preloads/core.php 2013-04-17 01:49:19 UTC (rev 11389)
+++ XoopsModules/userlog/trunk/userlog/preloads/core.php 2013-04-17 05:05:57 UTC (rev 11390)
@@ -29,6 +29,12 @@
include dirname(dirname(__FILE__)) . '/include/log.php';
}
+ // to log redirects because usually prorammers use exit() after redirect_header function.
+ function eventCoreIncludeFunctionsRedirectheader($args)
+ {
+ include dirname(dirname(__FILE__)) . '/include/log.php';
+ }
+
// in XOOPS255/index.php (homepage) when no module is set for start page there is a bug in XOOPS255/header.php exit() should be commented
/*$xoopsPreload->triggerEvent('core.header.checkcache');
if ($xoTheme->checkCache()) {
Modified: XoopsModules/userlog/trunk/userlog/xoops_version.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-04-17 01:49:19 UTC (rev 11389)
+++ XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-04-17 05:05:57 UTC (rev 11390)
@@ -28,7 +28,7 @@
$modversion['version'] = '1.01';
$modversion['author'] = 'xoops.org (irmtfan)';
$modversion['nickname'] = 'irmtfan';
-$modversion['credits'] = 'The XOOPS Project Team, trabis, irmtfan, mamba, tatane, Cesag, zyspec';
+$modversion['credits'] = 'The XOOPS Project Team, trabis, irmtfan, mamba, tatane, Cesag, zyspec, blackrx';
$modversion['license'] = 'GNU GPL 2.0';
$modversion['license_url'] = 'www.gnu.org/licenses/gpl-2.0.html/';
$modversion['official'] = 0;
@@ -38,10 +38,10 @@
$modversion['onUninstall'] = 'include/module.php';
//about
-$modversion['release_date'] = '2013/04/07';
+$modversion['release_date'] = '2013/04/20';
$modversion['module_website_url'] = 'http://www.xoops.org/';
$modversion['module_website_name'] = 'XOOPS';
-$modversion['module_status'] = 'RC 1';
+$modversion['module_status'] = 'Final';
$modversion['min_php'] = '5.3';
$modversion['min_xoops'] = '2.5.5';
$modversion['min_db'] = array('mysql' => '5.0.7', 'mysqli' => '5.0.7');
|
|
From: <ir...@us...> - 2013-04-17 09:26:19
|
Revision: 11393
http://sourceforge.net/p/xoops/svn/11393
Author: irmtfan
Date: 2013-04-17 09:26:16 +0000 (Wed, 17 Apr 2013)
Log Message:
-----------
- improve: add missing configcat in xoops_version.php to be more compatible with xoops26 in xoops_version.php and language/LANG/modinfo.php (2013/04/17)
- improve: replace all '->XoopsFileHandler' with '->__construct' to be more compatible with xoops26 in class/log.php(2013/04/17)
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/class/log.php
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/docs/lang_diff.txt
XoopsModules/userlog/trunk/userlog/docs/readme.txt
XoopsModules/userlog/trunk/userlog/language/english/modinfo.php
XoopsModules/userlog/trunk/userlog/language/persian/modinfo.php
XoopsModules/userlog/trunk/userlog/xoops_version.php
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-04-17 07:11:29 UTC (rev 11392)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-04-17 09:26:16 UTC (rev 11393)
@@ -256,7 +256,7 @@
$log_file = $this->userlog->getWorkingFile();
// file create/open/write
$fileHandler = XoopsFile::getHandler();
- $fileHandler->XoopsFileHandler($log_file, false);
+ $fileHandler->__construct($log_file, false);
if ($fileHandler->size() > $this->userlog->getConfig('maxlogfilesize')) {
$log_file_name = $this->userlog->getConfig('logfilepath') .'/'. USERLOG_DIRNAME . '/' . $this->userlog->getConfig('logfilename');
$old_file = $log_file_name ."_".date('Y-m-d_H-i-s') . "." . $this->userlog->logext;
@@ -267,7 +267,7 @@
}
// force to create file if not exist
if(!$fileHandler->exists()) {
- if(!$fileHandler->XoopsFileHandler($log_file, true)) { // create file and folder
+ if(!$fileHandler->__construct($log_file, true)) { // create file and folder
// Errors Warning: mkdir() [function.mkdir]: Permission denied in file /class/file/folder.php line 529
$this->setErrors("Cannot create folder/file ({$log_file})");
return false;
@@ -317,10 +317,10 @@
$csvFile = $this->userlog->getConfig("logfilepath") . "/" . USERLOG_DIRNAME . "/export/csv/" . $csvNamePrefix . "_" . date('Y-m-d_H-i-s') . ".csv";
// file create/open/write
$fileHandler = XoopsFile::getHandler();
- $fileHandler->XoopsFileHandler($csvFile, false);
+ $fileHandler->__construct($csvFile, false);
// force to create file if not exist
if(!$fileHandler->exists()) {
- $fileHandler->XoopsFileHandler($csvFile, true); // create file and folder
+ $fileHandler->__construct($csvFile, true); // create file and folder
$this->setErrors("File was not exist create file ({$csvFile})");
}
if ($fileHandler->open("a") == false) {
@@ -474,12 +474,12 @@
// file create/open/write
$fileHandler = XoopsFile::getHandler();
- $fileHandler->XoopsFileHandler($mergeFile, false); //to see if file exist
+ $fileHandler->__construct($mergeFile, false); //to see if file exist
if($fileHandler->exists()) {
$this->setErrors("file ({$mergeFile}) is exist");
return false;
}
- $fileHandler->XoopsFileHandler($mergeFile, true); // create file and folder
+ $fileHandler->__construct($mergeFile, true); // create file and folder
if ($fileHandler->open("a") == false) {
$this->setErrors("Cannot open file ({$mergeFile})");
return false;
@@ -499,7 +499,7 @@
// file open/read
$fileHandler = XoopsFile::getHandler();
// not create file if not exist
- $fileHandler->XoopsFileHandler($log_file, false);
+ $fileHandler->__construct($log_file, false);
if (!$fileHandler->exists()) {
$this->setErrors("Cannot open file ({$log_file})");
return array();
@@ -524,7 +524,7 @@
// file open/read
$fileHandler = XoopsFile::getHandler();
foreach($log_files as $file) {
- $fileHandler->XoopsFileHandler($file, false);
+ $fileHandler->__construct($file, false);
if (!$fileHandler->exists()) {
$this->setErrors("({$file}) is a folder or is not exist");
continue;
@@ -546,7 +546,7 @@
}
// check if file exist
$fileHandler = XoopsFile::getHandler();
- $fileHandler->XoopsFileHandler($log_file, false);
+ $fileHandler->__construct($log_file, false);
if (!$fileHandler->exists()) {
$this->setErrors("({$log_file}) is a folder or is not exist");
return false;
@@ -558,7 +558,7 @@
}
$newFile = dirname($log_file) . "/" . $newFileName . "." . $this->userlog->logext;
// check if new file exist => return false
- $fileHandler->XoopsFileHandler($newFile, false);
+ $fileHandler->__construct($newFile, false);
if ($fileHandler->exists()) {
$this->setErrors("({$newFile}) is exist");
return false;
@@ -578,7 +578,7 @@
}
// check if file exist
$fileHandler = XoopsFile::getHandler();
- $fileHandler->XoopsFileHandler($log_file, false);
+ $fileHandler->__construct($log_file, false);
if (!$fileHandler->exists()) {
$this->setErrors("({$log_file}) is a folder or is not exist");
return false;
@@ -590,7 +590,7 @@
}
$newFile = dirname($log_file) . "/" . $newFileName . "." . $this->userlog->logext;
// check if new file exist => return false
- $fileHandler->XoopsFileHandler($newFile, false);
+ $fileHandler->__construct($newFile, false);
if ($fileHandler->exists()) {
$this->setErrors("({$newFile}) is exist");
return false;
@@ -625,7 +625,7 @@
// file open/read
$fileHandler = XoopsFile::getHandler();
foreach($log_files as $key=>$file) {
- $fileHandler->XoopsFileHandler($file, false);
+ $fileHandler->__construct($file, false);
if (!$fileHandler->exists()) {
$this->setErrors("({$file}) is a folder or is not exist");
unset($log_files[$key]);
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-04-17 07:11:29 UTC (rev 11392)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-04-17 09:26:16 UTC (rev 11393)
@@ -2,6 +2,8 @@
Changelog:
VERSION 1.01:
+- improve: add missing configcat in xoops_version.php to be more compatible with xoops26 in xoops_version.php and language/LANG/modinfo.php (2013/04/17)
+- improve: replace all '->XoopsFileHandler' with '->__construct' to be more compatible with xoops26 in class/log.php(2013/04/17)
- change version to 1.01 Final (2013/04/17)
- fix and improve: add eventCoreIncludeFunctionsRedirectheader to log redirects because usually prorammers use exit() after redirect_header function. in include/log.php and preloads/core.php(2013/04/17)
- fix: empty smarty variables cause some errors in templates. in admin/logs.php (2013/04/16)
Modified: XoopsModules/userlog/trunk/userlog/docs/lang_diff.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/lang_diff.txt 2013-04-17 07:11:29 UTC (rev 11392)
+++ XoopsModules/userlog/trunk/userlog/docs/lang_diff.txt 2013-04-17 09:26:16 UTC (rev 11393)
@@ -11,4 +11,20 @@
add:
define("_AM_USERLOG_CONFIG_CHMOD_ERROR","Could not create any folder inside '%1\$s' because its chmod is under %2\$d.");
-define("_AM_USERLOG_CONFIG_CREATE_FOLDER","If you need to store logs in file, you should create folder '%1\$s' and set chmod = %2\$d manually using Cpanel.");
\ No newline at end of file
+define("_AM_USERLOG_CONFIG_CREATE_FOLDER","If you need to store logs in file, you should create folder '%1\$s' and set chmod = %2\$d manually using Cpanel.");
+
+modinfo.php
+----------
+edit:
+// config categories
+define("_MI_USERLOG_CONFCAT_LOGFILE","Log file settings");
+define("_MI_USERLOG_CONFCAT_LOGFILE_DSC","Log file (Set it if you need to store logs in a file, otherwise ignore it)");
+define("_MI_USERLOG_CONFCAT_FORMAT","Format");
+define("_MI_USERLOG_CONFCAT_FORMAT_DSC","Format settings");
+define("_MI_USERLOG_CONFCAT_PAGENAV","Page navigation");
+define("_MI_USERLOG_CONFCAT_PAGENAV_DSC","Page navigation settings");
+define("_MI_USERLOG_CONFCAT_LOGDB","Log database settings");
+define("_MI_USERLOG_CONFCAT_LOGDB_DSC","Log database (Set it if you need to store logs in database, otherwise ignore it)");
+define("_MI_USERLOG_CONFCAT_PROB","Probability settings");
+define("_MI_USERLOG_CONFCAT_PROB_DSC","Probability to work on database.(These default numbers are recommended for a high traffic website. e.g.: more than 30,000 hits per day)");
+
Modified: XoopsModules/userlog/trunk/userlog/docs/readme.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/readme.txt 2013-04-17 07:11:29 UTC (rev 11392)
+++ XoopsModules/userlog/trunk/userlog/docs/readme.txt 2013-04-17 09:26:16 UTC (rev 11393)
@@ -4,15 +4,33 @@
=========================
XOOPS 2.5.5 php 5.3 mysql 5.0
+To Install
+=========================
+1- upload the userlog to /modules/userlog (upload the compressed file and decompressed via Cpanel is the best way to insure all files are correctly uploaded)
+2- go to your admin -> system -> modules -> install
+3- change the default settings to your desired in the module preferences.
+
+Important notice: There is a new "ADDITIONAL permission in file for webmasters" addon introduced in userlog module.
+if you want other webmasters dont have access to userlog module this addon is for you.
+for more information go to userlog/admin/addon/perm.php
+If you dont need this addon you just need to remove addon/perm.php
+
Features:
=========================
- Log user activities and navigations.
Examples:
1- The possibility to list all the IPs used from a certain user, and conversely to list all the users logged from a defined IP to find duplicate users.
2- Find deleted items from your database.
+ modules/userlog/admin/logs.php?options[referer]=del&options[request_method]=POST
3- Find admin user activities(webmasters, moderators, ...)
+ modules/userlog/admin/logs.php?options[admin]=1
4- Find users who come to your site from Google.
-
+ modules/userlog/admin/logs.php?options[referer]=google.com
+ 5- Find all updated modules: (change op=update to op=install or op=uninstall to see install and uninstall activities)
+ modules/userlog/admin/logs.php?options[referer]=op=update&options[module]=system&options[request_method]=POST
+ 6- Find all errors/notices/warnings.
+ modules/userlog/admin/logs.php?options[logger]=errno
+
- Can log users by getting User ID, User group or visitor IP.
- Logs can be stored in file, database or both.
- Any below user information and/or page data can be selected to be logged.
@@ -33,19 +51,8 @@
- Can be used as a backup/restore tool.
- Used JSON format to store arrays to database for better performance (instead of xoops core serialize).
-
-To Install
+Known bugs/malfunctioning:
=========================
-1- upload the userlog to /modules/userlog (upload the compressed file and decompressed via Cpanel is the best way to insure all files are correctly uploaded)
-2- go to your admin -> system -> modules -> install
-3- change the default settings to your desired in the module preferences.
-
-Important notice: There is a new "ADDITIONAL permission in file for webmasters" addon introduced in userlog module.
-if you want other webmasters dont have access to userlog module this addon is for you.
-for more information go to userlog/admin/addon/perm.php
-If you dont need this addon you just need to remove addon/perm.php
-
-known bugs/malfunctioning in userlog module:
1- userlog will not work in XOOPS255/index.php (homepage) when no module is set for start page.
there is a bug in XOOPS255/header.php
solution:
Modified: XoopsModules/userlog/trunk/userlog/language/english/modinfo.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/english/modinfo.php 2013-04-17 07:11:29 UTC (rev 11392)
+++ XoopsModules/userlog/trunk/userlog/language/english/modinfo.php 2013-04-17 09:26:16 UTC (rev 11393)
@@ -33,16 +33,17 @@
define("_MI_USERLOG_IDLE","Idle");
// config categories
-define("_MI_USERLOG_CONFCAT_LOGFILE","Log file (Set it if you need to store logs in a file, otherwise ignore it)");
-define("_MI_USERLOG_CONFCAT_LOGFILE_DSC","Preferences for Log file");
+define("_MI_USERLOG_CONFCAT_LOGFILE","Log file settings");
+define("_MI_USERLOG_CONFCAT_LOGFILE_DSC","Log file (Set it if you need to store logs in a file, otherwise ignore it)");
define("_MI_USERLOG_CONFCAT_FORMAT","Format");
-define("_MI_USERLOG_CONFCAT_FORMAT_DSC","Preferences for format");
+define("_MI_USERLOG_CONFCAT_FORMAT_DSC","Format settings");
define("_MI_USERLOG_CONFCAT_PAGENAV","Page navigation");
-define("_MI_USERLOG_CONFCAT_PAGENAV_DSC","Preferences for page navigation");
-define("_MI_USERLOG_CONFCAT_LOGDB","Log database (Set it if you need to store logs in database, otherwise ignore it)");
-define("_MI_USERLOG_CONFCAT_LOGDB_DSC","Preferences for Log database");
-define("_MI_USERLOG_CONFCAT_PROB","Probability to work on database.(These default numbers are recommended for a high traffic website. e.g.: more than 30,000 hits per day)");
-define("_MI_USERLOG_CONFCAT_PROB_DSC","Preferences for Probability");
+define("_MI_USERLOG_CONFCAT_PAGENAV_DSC","Page navigation settings");
+define("_MI_USERLOG_CONFCAT_LOGDB","Log database settings");
+define("_MI_USERLOG_CONFCAT_LOGDB_DSC","Log database (Set it if you need to store logs in database, otherwise ignore it)");
+define("_MI_USERLOG_CONFCAT_PROB","Probability settings");
+define("_MI_USERLOG_CONFCAT_PROB_DSC","Probability to work on database.(These default numbers are recommended for a high traffic website. e.g.: more than 30,000 hits per day)");
+
// config logfile
define("_MI_USERLOG_MAXLOGFILESIZE","Maximum file size for current working Log file (in bytes)");
define("_MI_USERLOG_MAXLOGFILESIZE_DSC","Advise: Set it below 1MB because some servers set limitations for viewing large files in CPanel.");
Modified: XoopsModules/userlog/trunk/userlog/language/persian/modinfo.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/language/persian/modinfo.php 2013-04-17 07:11:29 UTC (rev 11392)
+++ XoopsModules/userlog/trunk/userlog/language/persian/modinfo.php 2013-04-17 09:26:16 UTC (rev 11393)
@@ -33,16 +33,17 @@
define("_MI_USERLOG_IDLE","توقف");
// config categories
-define("_MI_USERLOG_CONFCAT_LOGFILE","ذخیره در فایل (اگر میخواهید ثبت شده ها را در فایل ذخیره کنید تنظیمات زیر را به دلخواه خود تغییر دهید وگرنه اهمیت ندهید)");
-define("_MI_USERLOG_CONFCAT_LOGFILE_DSC","تنظیمات ذخیره در فایل");
+define("_MI_USERLOG_CONFCAT_LOGFILE","تنظیمات ذخیره در فایل");
+define("_MI_USERLOG_CONFCAT_LOGFILE_DSC","ذخیره در فایل (اگر میخواهید ثبت شده ها را در فایل ذخیره کنید تنظیمات زیر را به دلخواه خود تغییر دهید وگرنه اهمیت ندهید)");
define("_MI_USERLOG_CONFCAT_FORMAT","فرمت");
define("_MI_USERLOG_CONFCAT_FORMAT_DSC","تنظیمات فرمت");
define("_MI_USERLOG_CONFCAT_PAGENAV","مرور صفحه");
define("_MI_USERLOG_CONFCAT_PAGENAV_DSC","تنظیمات مرور صفحه");
-define("_MI_USERLOG_CONFCAT_LOGDB","ذخیره در پایگاه داده (اگر میخواهید ثبت شده ها را در پایگاه داده ذخیره کنید تنظیمات زیر را به دلخواه خود تغییر دهید وگرنه اهمیت ندهید)");
-define("_MI_USERLOG_CONFCAT_LOGDB_DSC","تنظیمات ذخیره در پایگاه داده");
-define("_MI_USERLOG_CONFCAT_PROB","احتمال برای دسترسی به پایگاه داده.(این اعداد برای سایت هایی با ترافیک بالا مناسب هستند. مثلا: بیشتر از سی هزار بازدید در روز)");
-define("_MI_USERLOG_CONFCAT_PROB_DSC","تنظیمات برای احتمالات");
+define("_MI_USERLOG_CONFCAT_LOGDB","تنظیمات ذخیره در پایگاه داده");
+define("_MI_USERLOG_CONFCAT_LOGDB_DSC","ذخیره در پایگاه داده (اگر میخواهید ثبت شده ها را در پایگاه داده ذخیره کنید تنظیمات زیر را به دلخواه خود تغییر دهید وگرنه اهمیت ندهید)");
+define("_MI_USERLOG_CONFCAT_PROB","تنظیمات برای احتمالات");
+define("_MI_USERLOG_CONFCAT_PROB_DSC","احتمال برای دسترسی به پایگاه داده.(این اعداد برای سایت هایی با ترافیک بالا مناسب هستند. مثلا: بیشتر از سی هزار بازدید در روز)");
+
// config logfile
define("_MI_USERLOG_MAXLOGFILESIZE","بیشترین اندازه فایل در حال کار (به بایت)");
define("_MI_USERLOG_MAXLOGFILESIZE_DSC","توصیه: روی کمتر از یک مگابایت بگذارید تا بتوانید از هر جایی مثلا از سی پنل مستقیم فایل ها را بخوانید.");
Modified: XoopsModules/userlog/trunk/userlog/xoops_version.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-04-17 07:11:29 UTC (rev 11392)
+++ XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-04-17 09:26:16 UTC (rev 11393)
@@ -117,6 +117,14 @@
// Config categories
$modversion['configcat']['logfile']['name'] = _MI_USERLOG_CONFCAT_LOGFILE;
$modversion['configcat']['logfile']['description'] = _MI_USERLOG_CONFCAT_LOGFILE_DSC;
+$modversion['configcat']['format']['name'] = _MI_USERLOG_CONFCAT_FORMAT;
+$modversion['configcat']['format']['description'] = _MI_USERLOG_CONFCAT_FORMAT_DSC;
+$modversion['configcat']['pagenav']['name'] = _MI_USERLOG_CONFCAT_PAGENAV;
+$modversion['configcat']['pagenav']['description'] = _MI_USERLOG_CONFCAT_PAGENAV_DSC;
+$modversion['configcat']['logdb']['name'] = _MI_USERLOG_CONFCAT_LOGDB;
+$modversion['configcat']['logdb']['description'] = _MI_USERLOG_CONFCAT_LOGDB_DSC;
+$modversion['configcat']['prob']['name'] = _MI_USERLOG_CONFCAT_PROB;
+$modversion['configcat']['prob']['description'] = _MI_USERLOG_CONFCAT_PROB_DSC;
// Config Settings (only for modules that need config settings generated automatically)
################### Log file ####################
@@ -131,11 +139,12 @@
$i++;
$modversion['config'][$i]['name'] = 'logfile';
-$modversion['config'][$i]['title'] = '_MI_USERLOG_CONFCAT_LOGFILE';
-$modversion['config'][$i]['description'] = '_MI_USERLOG_CONFCAT_LOGFILE_DSC';
+$modversion['config'][$i]['title'] = '_MI_USERLOG_CONFCAT_LOGFILE_DSC';
+$modversion['config'][$i]['description'] = '';
$modversion['config'][$i]['formtype'] = 'line_break';
$modversion['config'][$i]['valuetype'] = 'textbox';
$modversion['config'][$i]['default'] = 'odd';
+$modversion['config'][$i]['category'] = 'logfile';
$i++;
$modversion['config'][$i]['name'] = 'maxlogfilesize';
@@ -167,11 +176,12 @@
$i++;
$modversion['config'][$i]['name'] = 'format';
-$modversion['config'][$i]['title'] = '_MI_USERLOG_CONFCAT_FORMAT';
-$modversion['config'][$i]['description'] = '_MI_USERLOG_CONFCAT_FORMAT_DSC';
+$modversion['config'][$i]['title'] = '_MI_USERLOG_CONFCAT_FORMAT_DSC';
+$modversion['config'][$i]['description'] = '';
$modversion['config'][$i]['formtype'] = 'line_break';
$modversion['config'][$i]['valuetype'] = 'textbox';
$modversion['config'][$i]['default'] = 'even';
+$modversion['config'][$i]['category'] = 'format';
$i++;
$modversion['config'][$i]['name'] = 'format_date';
@@ -184,11 +194,12 @@
$i++;
$modversion['config'][$i]['name'] = 'pagenav';
-$modversion['config'][$i]['title'] = '_MI_USERLOG_CONFCAT_PAGENAV';
-$modversion['config'][$i]['description'] = '_MI_USERLOG_CONFCAT_PAGENAV_DSC';
+$modversion['config'][$i]['title'] = '_MI_USERLOG_CONFCAT_PAGENAV_DSC';
+$modversion['config'][$i]['description'] = '';
$modversion['config'][$i]['formtype'] = 'line_break';
$modversion['config'][$i]['valuetype'] = 'textbox';
$modversion['config'][$i]['default'] = 'odd';
+$modversion['config'][$i]['category'] = 'pagenav';
$i++;
$modversion['config'][$i]['name'] = 'sets_perpage';
@@ -230,11 +241,12 @@
$i++;
$modversion['config'][$i]['name'] = 'logdb';
-$modversion['config'][$i]['title'] = '_MI_USERLOG_CONFCAT_LOGDB';
-$modversion['config'][$i]['description'] = '_MI_USERLOG_CONFCAT_LOGDB_DSC';
+$modversion['config'][$i]['title'] = '_MI_USERLOG_CONFCAT_LOGDB_DSC';
+$modversion['config'][$i]['description'] = '';
$modversion['config'][$i]['formtype'] = 'line_break';
$modversion['config'][$i]['valuetype'] = 'textbox';
$modversion['config'][$i]['default'] = 'even';
+$modversion['config'][$i]['category'] = 'logdb';
$i++;
$modversion['config'][$i]['name'] = 'maxlogs';
@@ -256,11 +268,12 @@
$i++;
$modversion['config'][$i]['name'] = 'prob';
-$modversion['config'][$i]['title'] = '_MI_USERLOG_CONFCAT_PROB';
-$modversion['config'][$i]['description'] = '_MI_USERLOG_CONFCAT_PROB_DSC';
+$modversion['config'][$i]['title'] = '_MI_USERLOG_CONFCAT_PROB_DSC';
+$modversion['config'][$i]['description'] = '';
$modversion['config'][$i]['formtype'] = 'line_break';
$modversion['config'][$i]['valuetype'] = 'textbox';
$modversion['config'][$i]['default'] = 'odd';
+$modversion['config'][$i]['category'] = 'prob';
$i++;
$modversion['config'][$i]['name'] = 'probset';
|
|
From: <ir...@us...> - 2013-04-17 10:55:06
|
Revision: 11394
http://sourceforge.net/p/xoops/svn/11394
Author: irmtfan
Date: 2013-04-17 10:55:03 +0000 (Wed, 17 Apr 2013)
Log Message:
-----------
- improve: remove all get() functions in userlog classes to be more compatible with xoops26 in class/setting.php and class/log.php and class/stats.php (2013/04/17)
- improve: use "XoopsLocale" instead of "XoopsLocal" in xoops26 in class/userlog.php (2013/04/17)
- improve: add "static" to functions to be more compatible with xoops26 in preloads/core.php (2013/04/17)
- improve: make getGroupby() function compatible with xoops26 in class/log.php (2013/04/17)
Modified Paths:
--------------
XoopsModules/userlog/trunk/userlog/class/log.php
XoopsModules/userlog/trunk/userlog/class/setting.php
XoopsModules/userlog/trunk/userlog/class/stats.php
XoopsModules/userlog/trunk/userlog/class/userlog.php
XoopsModules/userlog/trunk/userlog/docs/changelog.txt
XoopsModules/userlog/trunk/userlog/preloads/core.php
Modified: XoopsModules/userlog/trunk/userlog/class/log.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/log.php 2013-04-17 09:26:16 UTC (rev 11393)
+++ XoopsModules/userlog/trunk/userlog/class/log.php 2013-04-17 10:55:03 UTC (rev 11394)
@@ -754,7 +754,7 @@
if (isset($criteria) && is_subclass_of($criteria, "criteriaelement")) {
$sql .= " " . $criteria->renderWhere();
if ($groupby = $criteria->getGroupby()) {
- $sql .= $groupby;
+ $sql .= !strpos($groupby,"GROUP BY") ? " GROUP BY {$groupby}" : $groupby;
}
if ($sort = $criteria->getSort()) {
$sql .= " ORDER BY {$sort} " . $criteria->getOrder();
@@ -833,14 +833,4 @@
}
return $ret;
}
- public function &get($id)
- {
- static $logs;
- if (isset($logs[$id])) {
- return $logs[$id];
- }
- $obj = parent::get($id);
- $logs[$id] = $obj;
- return $obj;
- }
}
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/class/setting.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/setting.php 2013-04-17 09:26:16 UTC (rev 11393)
+++ XoopsModules/userlog/trunk/userlog/class/setting.php 2013-04-17 10:55:03 UTC (rev 11394)
@@ -407,15 +407,4 @@
$ret = $this->getAll($criteria, $fields, $asObject, $id_as_key);
return $ret;
}
-
- public function &get($id)
- {
- static $sets;
- if (isset($sets[$id])) {
- return $sets[$id];
- }
- $obj = parent::get($id);
- $sets[$id] = $obj;
- return $obj;
- }
}
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/class/stats.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/stats.php 2013-04-17 09:26:16 UTC (rev 11393)
+++ XoopsModules/userlog/trunk/userlog/class/stats.php 2013-04-17 10:55:03 UTC (rev 11394)
@@ -202,16 +202,4 @@
$this->userlog = Userlog::getInstance();
parent::__construct($db, "mod_userlog_stats", 'UserlogStats', "stats_id", "stats_type");
}
- public function &get($id)
- {
- static $stats;
- if (isset($stats[$id])) {
- return $stats[$id];
- }
- $obj = parent::get($id);
- $stats[$id] = $obj;
- return $obj;
-
- }
-
}
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/class/userlog.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-04-17 09:26:16 UTC (rev 11393)
+++ XoopsModules/userlog/trunk/userlog/class/userlog.php 2013-04-17 10:55:03 UTC (rev 11394)
@@ -185,7 +185,7 @@
$dateFormat = $this->getConfig('format_date');
}
xoops_load('XoopsLocal');
- return XoopsLocal::formatTimestamp($intTime, $dateFormat, $timeoffset);
+ return class_exists("XoopsLocal") ? XoopsLocal::formatTimestamp($intTime, $dateFormat, $timeoffset) : XoopsLocale::formatTimestamp($intTime, $dateFormat, $timeoffset); // use XoopsLocale in xoops26
}
public function getCookie($name = "TOGGLE")
{
Modified: XoopsModules/userlog/trunk/userlog/docs/changelog.txt
===================================================================
--- XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-04-17 09:26:16 UTC (rev 11393)
+++ XoopsModules/userlog/trunk/userlog/docs/changelog.txt 2013-04-17 10:55:03 UTC (rev 11394)
@@ -2,6 +2,10 @@
Changelog:
VERSION 1.01:
+- improve: remove all get() functions in userlog classes to be more compatible with xoops26 in class/setting.php and class/log.php and class/stats.php (2013/04/17)
+- improve: use "XoopsLocale" instead of "XoopsLocal" in xoops26 in class/userlog.php (2013/04/17)
+- improve: add "static" to functions to be more compatible with xoops26 in preloads/core.php (2013/04/17)
+- improve: make getGroupby() function compatible with xoops26 in class/log.php (2013/04/17)
- improve: add missing configcat in xoops_version.php to be more compatible with xoops26 in xoops_version.php and language/LANG/modinfo.php (2013/04/17)
- improve: replace all '->XoopsFileHandler' with '->__construct' to be more compatible with xoops26 in class/log.php(2013/04/17)
- change version to 1.01 Final (2013/04/17)
Modified: XoopsModules/userlog/trunk/userlog/preloads/core.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/preloads/core.php 2013-04-17 09:26:16 UTC (rev 11393)
+++ XoopsModules/userlog/trunk/userlog/preloads/core.php 2013-04-17 10:55:03 UTC (rev 11394)
@@ -24,13 +24,13 @@
class UserlogCorePreload extends XoopsPreloadItem
{
// to log main part of modules
- function eventCoreFooterStart($args)
+ static function eventCoreFooterStart($args)
{
include dirname(dirname(__FILE__)) . '/include/log.php';
}
// to log redirects because usually prorammers use exit() after redirect_header function.
- function eventCoreIncludeFunctionsRedirectheader($args)
+ static function eventCoreIncludeFunctionsRedirectheader($args)
{
include dirname(dirname(__FILE__)) . '/include/log.php';
}
@@ -43,7 +43,7 @@
} */
// to log admin part of modules (must use moduleadmin class)
- function eventSystemClassGuiHeader($args)
+ static function eventSystemClassGuiHeader($args)
{
include dirname(dirname(__FILE__)) . '/include/log.php';
}
|