|
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");
+// 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_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.");
// blocks
define("_MI_USERLOG_BLOCK_VIEWS","All views in site");
-define("_MI_USERLOG_BLOCK_VIEWS_DSC","Show views in the whole site");
\ No newline at end of file
+define("_MI_USERLOG_BLOCK_VIEWS_DSC","Show views in the whole site");
+
+// webmaster permission
+define("_MI_USERLOG_WEBMASTER_NOPERM","You are one of the webmasters but dont have permission to access this area. please contact to webmasters with %1\$s uids or webmasters belong to %2\$s admin groups for more information.");
\ No newline at end of file
Modified: XoopsModules/userlog/trunk/userlog/sql/mysql.sql
===================================================================
--- XoopsModules/userlog/trunk/userlog/sql/mysql.sql 2013-03-02 10:37:52 UTC (rev 11141)
+++ XoopsModules/userlog/trunk/userlog/sql/mysql.sql 2013-03-02 12:45:45 UTC (rev 11142)
@@ -13,7 +13,7 @@
user_ip varchar(15) NOT NULL default '',
user_agent varchar(255) NOT NULL default '',
url varchar(255) NOT NULL default '',
- script varchar(50) NOT NULL default '',
+ script varchar(20) NOT NULL default '',
referer varchar(255) NOT NULL default '',
pagetitle varchar(255) NOT NULL default '',
module varchar(10) NOT NULL default '',
@@ -21,7 +21,7 @@
item_id int(11) unsigned NOT NULL default 0,
request_method varchar(20) NOT NULL default '',
get TEXT NOT NULL,
- post TEXT NOT NULL,
+ post LONGTEXT NOT NULL,
request TEXT NOT NULL,
files TEXT NOT NULL,
env TEXT NOT NULL,
@@ -31,7 +31,8 @@
logger TEXT NOT NULL,
PRIMARY KEY (log_id),
KEY log_id_uid (log_id, uid),
- KEY uid (uid, uname, user_ip)
+ KEY uid (uid, uname, user_ip),
+ KEY views (uid, groups, script, pagetitle(20), module, item_name, item_id)
) ENGINE=MyISAM;
# --------------------------------------------------------
Modified: XoopsModules/userlog/trunk/userlog/xoops_version.php
===================================================================
--- XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-03-02 10:37:52 UTC (rev 11141)
+++ XoopsModules/userlog/trunk/userlog/xoops_version.php 2013-03-02 12:45:45 UTC (rev 11142)
@@ -86,7 +86,6 @@
$modversion['hasAdmin'] = 1;
$modversion['adminindex'] = "admin/index.php";
$modversion['adminmenu'] = "admin/menu.php";
-$modversion['system_menu'] = 1;
// blocks
$i = 0;
@@ -135,7 +134,6 @@
$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]['category'] = 'logfile';
$i++;
@@ -214,4 +212,93 @@
$modversion['config'][$i]['formtype'] = 'textbox';
$modversion['config'][$i]['valuetype'] = 'int';
$modversion['config'][$i]['default'] = 0;
-$modversion['config'][$i]['category'] = 'logdb';
\ No newline at end of file
+$modversion['config'][$i]['category'] = 'logdb';
+
+$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]['formtype'] = 'line_break';
+$modversion['config'][$i]['valuetype'] = 'textbox';
+$modversion['config'][$i]['default'] = 'odd';
+
+$i++;
+$modversion['config'][$i]['name'] = 'probset';
+$modversion['config'][$i]['title'] = '_MI_USERLOG_PROBSET';
+$modversion['config'][$i]['description'] = '_MI_USERLOG_PROBSET_DSC';
+$modversion['config'][$i]['formtype'] = 'select';
+$modversion['config'][$i]['valuetype'] = 'text';
+$modversion['config'][$i]['default'] = 20;
+$modversion['config'][$i]['options'] = array_combine(range(1,100),range(1,100));
+$modversion['config'][$i]['category'] = 'prob';
+
+$i++;
+$modversion['config'][$i]['name'] = 'probstats';
+$modversion['config'][$i]['title'] = '_MI_USERLOG_PROBSTATS';
+$modversion['config'][$i]['description'] = '_MI_USERLOG_PROBSTATS_DSC';
+$modversion['config'][$i]['formtype'] = 'select';
+$modversion['config'][$i]['valuetype'] = 'text';
+$modversion['config'][$i]['default'] = 10;
+$modversion['config'][$i]['options'] = range(0, 100);
+$modversion['config'][$i]['category'] = 'prob';
+
+$i++;
+$modversion['config'][$i]['name'] = 'probstatsallhit';
+$modversion['config'][$i]['title'] = '_MI_USERLOG_PROBSTATSALLHIT';
+$modversion['config'][$i]['description'] = '_MI_USERLOG_PROBSTATSALLHIT_DSC';
+$modversion['config'][$i]['formtype'] = 'select';
+$modversion['config'][$i]['valuetype'] = 'text';
+$modversion['config'][$i]['default'] = 1;
+$modversion['config'][$i]['options'] = range(0, 100);
+$modversion['config'][$i]['category'] = 'prob';
+
+// START add webmaster permission from file to add additional permission check for all webmasters
+global $xoopsOption, $xoopsModule;
+// effective only in admin side
+if ($xoopsOption['pagetype'] == "admin" && is_object($xoopsModule)) {
+ // get dirname
+ $dirname = $xoopsModule->getVar('dirname');
+ // START if dirname is system
+ if($dirname == "system" && isset($_REQUEST['fct'])) {
+ $hModule =& xoops_gethandler('module');
+ // if we are in preferences of modules
+ if($_REQUEST['fct'] == "preferences" && isset($_REQUEST['mod'])) {
+ $mod = intval($_REQUEST['mod']);
+ $module =& $hModule->get($mod);
+ $dirname = $module->getVar('dirname');
+ }
+ // if we are in modules admin - can be done with onuninstall and onupdate???
+ if($_REQUEST['fct'] == "modulesadmin" && isset($_REQUEST['module'])) {
+ $dirname = $_REQUEST['module'];
+ }
+ // if we are in maintenance - now all modules - how to do it for only one module?
+ if($_REQUEST['fct'] == "maintenance") {
+ $dump_modules = isset($_REQUEST['dump_modules']) ? $_REQUEST['dump_modules'] : false;
+ $dump_tables = isset($_REQUEST['dump_tables']) ? $_REQUEST['dump_tables'] : false;
+ if ($dump_tables == true || $dump_modules == true) {
+ $dirname = $modversion['dirname'];
+ }
+ }
+ }
+ // END if dirname is system
+
+ // now check permission from file
+ if($dirname == $modversion['dirname']) {
+ if (file_exists($permFile = XOOPS_ROOT_PATH . "/modules/" . $modversion['dirname'] . "/admin/addon/perm.php")) {
+ $perm = include $permFile;
+ if (count($perm["super"]["uid"]) > 0 || count($perm["super"]["group"]) > 0) {
+ global $xoopsUser;
+ if (is_object($xoopsUser) &&
+ !in_array($xoopsUser->getVar("uid"), $perm["super"]["uid"]) &&
+ count(array_intersect($xoopsUser->getGroups(),$perm["super"]["group"])) == 0
+ ) {
+ $modversion['hasAdmin'] = 0;
+ $modversion['system_menu'] = 0;
+ $modversion['tables'] = null;
+ redirect_header(XOOPS_URL . "/admin.php", 1, sprintf(_MI_USERLOG_WEBMASTER_NOPERM,implode(",", $perm["super"]["uid"]), implode(",", $perm["super"]["group"])) );
+ }
+ }
+ }
+ }
+}
+// END add webmaster permission from file to add additional permission check for all webmasters
\ No newline at end of file
|