1<?php 2/** 3 * @package tikiwiki 4 */ 5// (c) Copyright by authors of the Tiki Wiki CMS Groupware Project 6// 7// All Rights Reserved. See copyright.txt for details and a complete list of authors. 8// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details. 9// $Id$ 10 11require_once('tiki-setup.php'); 12 13if (empty($prefs['feature_jpgraph'])) { 14 $prefs['feature_jpgraph'] = 'n'; //optional package does not go througp prefs 15} 16 17$categlib = TikiLib::lib('categ'); 18$contributionlib = TikiLib::lib('contribution'); 19 20$commentslib = TikiLib::lib('comments'); 21$access->check_user($user); 22$access->check_feature('feature_actionlog'); 23$access->check_permission_either(['tiki_p_view_actionlog', 'tiki_p_view_actionlog_owngroups']); 24 25if (isset($_REQUEST['checked'])) { 26 $checked = is_array($_REQUEST['checked']) ? $_REQUEST['checked'] : [$_REQUEST['checked']]; 27 // Ban IP adresses of multiple spammers 28 if (isset($_REQUEST['action']) && $_REQUEST['action'] === 'ban') { 29 $mass_ban_ip = implode('|', $checked); 30 header('Location: tiki-admin_banning.php?mass_ban_ip_actionlog=' . $mass_ban_ip); 31 exit; 32 } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] === 'remove' && $tiki_p_admin == 'y' 33 && $access->checkCsrfForm(tra('Remove selected actions?'))) 34 { 35 $rowsDeleted = 0; 36 foreach ($checked as $action) { 37 $result = $logslib->remove_action($action); 38 $rowsDeleted += $result->numRows(); 39 } 40 if ($rowsDeleted) { 41 $msg = $rowsDeleted === 1 ? tra('The selected action has been deleted from the log') 42 : tr('%0 actions have been deleted from the log', $rowsDeleted); 43 Feedback::success($msg); 44 } else { 45 Feedback::error(tr('No actions were deleted from the log')); 46 } 47 } 48} 49 50$auto_query_args = [ 51 'actionId', 52 'startDate_Day', 53 'startDate_Month', 54 'startDate_Year', 55 'endDate_Day', 56 'endDate_Month', 57 'endDate_Year', 58 'selectedUsers', 59 'selectedGroups', 60 'list', 61 'sort_mode', 62 'categId', 63 'find' 64 ]; 65$categories = $categlib->getCategories(); 66 67if (! empty($_REQUEST["action_log_type"])) { 68 $action_log_type = $_REQUEST["action_log_type"]; 69} else { 70 $action_log_type = '%'; 71} 72 73if (! empty($_REQUEST["action_log_ip"])) { 74 $action_log_ip = $_REQUEST["action_log_ip"]; 75} else { 76 $action_log_ip = '%'; 77} 78 79if (! empty($_REQUEST["action_log_action"])) { 80 $action_log_action = $_REQUEST["action_log_action"]; 81} else { 82 $action_log_action = '%'; 83} 84 85$confs = $logslib->get_all_actionlog_conf(); 86$action_log_conf_selected = $logslib->get_actionlog_conf($action_log_type, $action_log_action); 87$nbViewedConfs = 0; 88 89if (isset($_REQUEST["find"])) { 90 $find = $_REQUEST["find"]; 91} else { 92 $find = ''; 93} 94$smarty->assign('find', $find); 95if (! isset($_REQUEST['offset']) || ! empty($_REQUEST['export'])) { 96 $offset = 0; 97} else { 98 $offset = $_REQUEST["offset"]; 99} 100if (isset($_REQUEST['max'])) { 101 $maxRecords = $_REQUEST['max']; 102} else { 103 $maxRecords = $prefs['maxRecords']; 104} 105 106if ($tiki_p_view_actionlog == 'y') { 107 if (isset($_POST['save']) && $access->checkCsrf()) { 108 foreach ($action_log_conf_selected as $index => $conf) { 109 if (isset($_REQUEST['v_' . $conf['code']]) && $_REQUEST['v_' . $conf['code']] == 'on') { //viewed and reported 110 $logslib->set_actionlog_conf($conf['action'], $conf['objectType'], 'v'); 111 } elseif (isset($_REQUEST[$conf['code']]) && $_REQUEST[$conf['code']] == 'on') { 112 $logslib->set_actionlog_conf($conf['action'], $conf['objectType'], 'y'); 113 } else { 114 $logslib->set_actionlog_conf($conf['action'], $conf['objectType'], 'n'); 115 } 116 } 117 global $actionlogConf; 118 unset($actionlogConf); 119 $confs = $logslib->get_all_actionlog_conf(); 120 $action_log_conf_selected = $logslib->get_actionlog_conf($action_log_type); 121 $cookietab = 1; 122 } 123} else { 124 if (isset($_POST['save']) && $access->checkCsrf()) { 125 $_prefs = 'v'; 126 foreach ($action_log_conf_selected as $index => $conf) { 127 if ($conf['status'] == 'v' || $conf['status'] == 'y') { // can only change what is recorded 128 if (isset($_REQUEST['v_' . $conf['code']]) && $_REQUEST['v_' . $conf['code']] == 'on') { //viewed 129 $_prefs .= $conf['id'] . 'v'; 130 } else { 131 $_prefs .= $conf['id'] . 'y'; 132 } 133 } 134 } 135 global $actionlogConf; 136 unset($actionlogConf); 137 $confs = $logslib->get_all_actionlog_conf(); 138 $action_log_conf_selected = $logslib->get_actionlog_conf($action_log_type); 139 $tikilib->set_user_preference($user, 'actionlog_conf', $_prefs); 140 $cookietab = 1; 141 } else { 142 $_prefs = $tikilib->get_user_preference($user, 'actionlog_conf', ''); 143 if (! empty($_prefs)) { 144 foreach ($confs as $i => $conf) { 145 if ($confs[$i]['status'] == 'v' || $confs[$i]['status'] == 'y') { 146 if (preg_match('/[vy]' . $confs[$i]['id'] . '([vy])/', $_prefs, $matches)) { 147 $confs[$i]['status'] = $matches[1]; 148 } 149 } 150 } 151 } 152 } 153 global $actionlogConf; 154 $actionlogConf = $confs; 155} 156 157foreach ($confs as $conf) { 158 if ($conf['status'] == 'v') { 159 ++$nbViewedConfs; 160 } 161} 162$smarty->assign('nbViewedConfs', $nbViewedConfs); 163if (empty($nbViewedConfs)) { 164 $cookietab = 2; 165} 166 167$smarty->assign_by_ref('actionlogConf', $confs); 168 169if (! empty($_REQUEST['actionId']) && $tiki_p_admin == 'y') { 170 $action = $logslib->get_info_action($_REQUEST['actionId']); 171 if (empty($action)) { 172 Feedback::error( tra('Must specify actionId')); 173 } else { 174 if (isset($_POST['saveAction'])&& $access->checkCsrf()) { 175 if ($prefs['feature_contribution'] == 'y') { 176 if ($contributionlib->update($action, empty($_REQUEST['contributions']) ? '' : $_REQUEST['contributions'])) { 177 $logslib->delete_params($_REQUEST['actionId'], 'contribution'); 178 if (isset($_REQUEST['contributions'])) { 179 $logslib->insert_params($_REQUEST['actionId'], 'contribution', $_REQUEST['contributions']); 180 } 181 if (isset($_REQUEST['contributors'])) { 182 $logslib->insert_params($_REQUEST['actionId'], 'contributor', $_REQUEST['contributors']); 183 } 184 } else { 185 $smarty->assign('error', 'found more than one object that can correspond'); 186 } 187 } 188 if (empty($_REQUEST['cat_categories']) && !empty($action['categId'])) { 189 $logslib->update_category($_REQUEST['actionId'], 0); 190 } elseif (!empty($_REQUEST['cat_categories'])) { 191 $old_categ = $action['categId']; 192 if (!in_array($action['categId'], $_REQUEST['cat_categories'])) { 193 $logslib->update_category($_REQUEST['actionId'], $_REQUEST['cat_categories'][0]); 194 } 195 if (count($_REQUEST['cat_categories']) > 1) { 196 $action['params'] = $logslib->get_action_params($_REQUEST['actionId']); 197 $action['contributions'] = $logslib->get_action_contributions($_REQUEST['actionId']); 198 foreach ($_REQUEST['cat_categories'] as $cat) { 199 if ($cat != $old_categ) { 200 $logslib->add_action($action['action'], $action['object'], $action['objectType'], $action['comment'], $action['user'], $action['ip'], '', $action['lastModif'], '', ''); 201 } 202 } 203 } 204 } 205 } else { 206 $smarty->assign_by_ref('action', $action); 207 if ($action['objectType'] == 'wiki page') { 208 $contributions = $logslib->get_action_contributions($action['actionId']); 209 $info = $tikilib->get_page_info($action['object']); 210 $contributors = $logslib->get_wiki_contributors($info); 211 $tcontributors = []; 212 foreach ($contributors as $c) { 213 $tcontributors[] = $c['userId']; 214 } 215 $smarty->assign_by_ref('contributors', $tcontributors); 216 } elseif ($id = $logslib->get_comment_action($action)) { 217 $contributions = $logslib->get_action_contributions($action['actionId']); 218 } else { 219 $contributions = $contributionlib->get_assigned_contributions($action['object'], $action['objectType']); // todo: do a left join 220 } 221 222 $cont = []; 223 foreach ($contributions as $contribution) { 224 $cont[] = $contribution['contributionId']; 225 } 226 $_REQUEST['contributions'] = $cont; 227 include ('contribution.php'); 228 $contributions['data'][] = [ 229 'contributionId' => 0, 230 'name' => '' 231 ]; 232 if (! empty($_REQUEST['startDate'])) { 233 $smarty->assign('startDate', $_REQUEST['startDate']); 234 } 235 if (! empty($_REQUEST['endDate'])) { 236 $smarty->assign('endDate', $_REQUEST['endDate']); 237 } 238 if (! empty($action['categId'])) { 239 foreach ($categories as $i => $cat) { 240 if ($action['categId'] == $cat['categId']) { 241 $categories[$i]['incat'] = 'y'; 242 } 243 } 244 } 245 } 246 } 247} 248if ($tiki_p_list_users == 'y') { 249 $users = $userlib->list_all_users(); 250 $groups = $userlib->list_all_groups(); 251} else { 252 $users = [$userlib->get_user_id($user) => $user]; 253 $groups = $tikilib->get_user_groups($user); 254 $groups = array_diff( 255 $groups, 256 [ 257 'Anonymous' 258 ] 259 ); 260 $_REQUEST['selectedUsers'] = [$user]; 261} 262$selectedGroups = []; 263foreach ($groups as $g) { 264 $selectedGroups[$g] = 'y'; 265} 266$smarty->assign_by_ref('users', $users); 267$smarty->assign_by_ref('groups', $groups); 268$smarty->assign_by_ref('categories', $categories); 269foreach ($categories as $categ) { 270 $categNames[$categ['categId']] = $categ['name']; 271} 272$smarty->assign_by_ref('categNames', $categNames); 273 274if (isset($_REQUEST['list']) || isset($_REQUEST['export']) || isset($_REQUEST['graph'])) { 275 @ini_set('max_execution_time', 0); 276 $url = ''; 277 $selectedUsers = []; 278 if (isset($_REQUEST['selectedUsers'])) { 279 foreach ($users as $key => $u) { 280 if (in_array($u, $_REQUEST['selectedUsers'])) { 281 $url .= "&selectedUsers[]=$u"; 282 $selectedUsers[$key] = 'y'; 283 } else { 284 $selectedUsers[$key] = 'n'; 285 } 286 } 287 } 288 $smarty->assign('selectedUsers', $selectedUsers); 289 if (isset($_REQUEST['selectedGroups']) && ! (count($_REQUEST['selectedGroups']) == 1 && $_REQUEST['selectedGroups'][0] == '')) { 290 $selectedGroups = []; 291 foreach ($groups as $key => $g) { 292 if (in_array($g, $_REQUEST['selectedGroups'])) { 293 $url .= "&selectedGroups[]=$g"; 294 $selectedGroups[$g] = 'y'; 295 if ($tiki_p_admin == 'y' || $tiki_p_view_actionlog_owngroups == 'y') { 296 $members = $userlib->get_group_users($g); 297 foreach ($members as $m) { 298 $_REQUEST['selectedUsers'][] = $m; 299 $selectedUsers[$m] = 'y'; 300 } 301 } 302 } else { 303 $selectedGroups[$g] = 'n'; 304 } 305 } 306 $smarty->assign_by_ref('selectedGroups', $selectedGroups); 307 } 308 if (! isset($_REQUEST['selectedUsers']) || (count($_REQUEST['selectedUsers']) == 1 && $_REQUEST['selectedUsers'][0] == '')) { 309 $_REQUEST['selectedUsers'] = ''; 310 } 311 if (! isset($_REQUEST['categId']) || $_REQUEST['categId'] == 0) { 312 $_REQUEST['categId'] = ''; 313 } else { 314 $url .= '&categId=' . $_REQUEST['categId']; 315 $smarty->assign('reportCateg', $categNames[$_REQUEST['categId']]); 316 } 317 $showCateg = $logslib->action_is_viewed('*', 'category'); 318 $smarty->assign('showCateg', $showCateg ? 'y' : 'n'); 319 $showLogin = $logslib->action_is_viewed('login', 'system'); 320 $smarty->assign('showLogin', $showLogin ? 'y' : 'n'); 321 $showbigbluebutton = $logslib->action_is_viewed('Joined Room', 'bigbluebutton'); 322 $smarty->assign('showbigbluebutton', $showbigbluebutton ? 'y' : 'n'); 323 if (isset($_REQUEST['startDate_Month'])) { 324 $startDate = $tikilib->make_time($_REQUEST['Time_Hour'], $_REQUEST['Time_Minute'], $_REQUEST['Time_Second'], $_REQUEST['startDate_Month'], $_REQUEST['startDate_Day'], $_REQUEST['startDate_Year']); 325 $url .= "&start=$startDate"; 326 } elseif (isset($_REQUEST['startDate'])) { 327 $startDate = $_REQUEST['startDate']; 328 } else { 329 $startDate = $tikilib->make_time(0, 0, 0, $tikilib->date_format('%m'), $tikilib->date_format('%d'), $tikilib->date_format('%Y')); 330 } 331 $smarty->assign('startDate', $startDate); 332 if (isset($_REQUEST['endDate_Month'])) { 333 $endDate = $tikilib->make_time($_REQUEST['end_Hour'], $_REQUEST['end_Minute'], $_REQUEST['end_Second'], $_REQUEST['endDate_Month'], $_REQUEST['endDate_Day'], $_REQUEST['endDate_Year']); 334 $url .= "&end=$endDate"; 335 } elseif (isset($_REQUEST['endDate'])) { 336 $endDate = $_REQUEST['endDate']; 337 } else { 338 $endDate = $tikilib->make_time(23, 59, 59, $tikilib->date_format('%m'), $tikilib->date_format('%d'), $tikilib->date_format('%Y')); 339 } 340 $smarty->assign('endDate', $endDate); 341 342 if (isset($_REQUEST['export'])) { 343 header('Content-type: application/octet-stream'); 344 header('Content-Disposition: attachment; filename="tiki-actionlogs_stats.csv"'); 345 echo "user,date,time,action,type,object,category,categId,ip, unit,+,-,contribution\r\n"; 346 for (;;) { 347 $results = $logslib->list_actions('', '', $_REQUEST['selectedUsers'], $offset, $maxRecords, 'lastModif_desc', $find, $startDate, $endDate, $_REQUEST['categId']); 348 if (empty($results['data'])) { 349 break; 350 } 351 $csv = $logslib->export($results['data']); 352 echo $csv; 353 $offset += $maxRecords; 354 } 355 die(); 356 } 357 if (isset($_REQUEST['export_bbb'])) { 358 header('Content-type: application/octet-stream'); 359 header('Content-Disposition: attachment; filename="tiki-actionlogs_bbb_stats.csv"'); 360 echo "user,object,Time in bigbluebutton (in minutes)\r\n"; 361 $logins = $logslib->list_actions('', 'bigbluebutton', $_REQUEST['selectedUsers'], 0, -1, 'lastModif_asc', $find, $startDate, $endDate, false); 362 $stay_in_big_Times = $logslib->get_bigblue_login_time($logins['data'], $startDate, $endDate, $actions); 363 if (! empty($logins['data'])) { 364 $csv = $logslib->export_bbb($stay_in_big_Times); 365 echo $csv; 366 $offset += $maxRecords; 367 die(); 368 } 369 } 370 $results = $logslib->list_actions('', '', $_REQUEST['selectedUsers'], $offset, $maxRecords, 'lastModif_desc', $find, $startDate, $endDate, $_REQUEST['categId']); 371 $actions = &$results['data']; 372 $actions_cant = $results['cant']; 373 $actions = $logslib->get_more_info($actions, $categNames); 374 $contributorActions = $logslib->split_actions_per_contributors($actions, $_REQUEST['selectedUsers']); 375 if (! empty($_REQUEST['selectedUsers'])) { 376 $results = $logslib->list_actions('', '', '', $offset, $maxRecords, 'lastModif_desc', $find, $startDate, $endDate, $_REQUEST['categId']); 377 $allActions = &$results['data']; 378 $allContributorsActions = $logslib->split_actions_per_contributors($actions, ''); 379 } else { 380 $allActions = $actions; 381 $allContributorsActions = $contributorActions; 382 } 383 $userActions = $logslib->get_stat_actions_per_user($contributorActions); 384 $smarty->assign_by_ref('userActions', $userActions); 385 $objectActions = $logslib->get_stat_actions_per_field($actions, 'object'); 386 $smarty->assign_by_ref('objectActions', $objectActions); 387 $groupContributions = $logslib->get_stat_contributions_per_group($allContributorsActions, $selectedGroups); 388 $smarty->assign_by_ref('groupContributions', $groupContributions); 389 $userContributions = $logslib->get_stat_contributions_per_user($contributorActions); 390 $smarty->assign_by_ref('userContributions', $userContributions['data']); 391 if ($showCateg) { 392 $statCateg = $logslib->get_action_stat_categ($actions, $categNames); 393 $smarty->assign_by_ref('statCateg', $statCateg); 394 $volCateg = $logslib->get_action_vol_categ($actions, $categNames); 395 if (isset($_REQUEST['unit']) && $_REQUEST['unit'] == 'kb') { 396 $volCateg = $logslib->in_kb($volCateg); 397 } 398 $smarty->assign_by_ref('volCateg', $volCateg); 399 $volUserCateg = $logslib->get_action_vol_user_categ($contributorActions, $categNames); 400 if (isset($_REQUEST['unit']) && $_REQUEST['unit'] == 'kb') { 401 $volUserCateg = $logslib->in_kb($volUserCateg); 402 } 403 $smarty->assign_by_ref('volUserCateg', $volUserCateg); 404 $typeVol = $logslib->get_action_vol_type($volCateg); 405 $smarty->assign_by_ref('typeVol', $typeVol); 406 $statUserCateg = $logslib->get_actions_per_user_categ($contributorActions, $categNames); 407 $smarty->assign_by_ref('statUserCateg', $statUserCateg); 408 } 409 if ($showLogin) { 410 $logins = $logslib->list_logs('login', $_REQUEST['selectedUsers'], 0, -1, 'lastModif_asc', '', $startDate, $endDate, $actions); 411 $logTimes = $logslib->get_login_time($logins['data'], $startDate, $endDate, $actions); 412 $smarty->assign_by_ref('logTimes', $logTimes); 413 } 414 if ($showbigbluebutton) { 415 $logins = $logslib->list_actions('', 'bigbluebutton', $_REQUEST['selectedUsers'], 0, -1, 'lastModif_asc', $find, $startDate, $endDate, false); 416 $stay_in_big_Times = $logslib->get_bigblue_login_time($logins['data'], $startDate, $endDate, $actions); 417 $smarty->assign_by_ref('stay_in_big_Times', $stay_in_big_Times); 418 } 419 if (isset($_REQUEST['unit']) && $_REQUEST['unit'] == 'kb') { 420 for ($i = count($actions) - 1; $i >= 0; --$i) { 421 if (isset($actions[$i]['add'])) { 422 $actions[$i]['add'] = round($actions[$i]['add'] / 1024); 423 } 424 if (isset($actions[$i]['del'])) { 425 $actions[$i]['del'] = round($actions[$i]['del'] / 1024); 426 } 427 } 428 } 429 if (isset($_REQUEST['sort_mode'])) { 430 list($col, $order) = explode('_', $_REQUEST['sort_mode']); 431 $sort = []; 432 foreach ($actions as $a) { 433 $sort[] = isset($a[$col]) ? $a[$col] : ''; 434 } 435 array_multisort($sort, ($order == 'desc') ? SORT_DESC : SORT_ASC, $actions); 436 $smarty->assign('sort_mode', $_REQUEST['sort_mode']); 437 } 438 $smarty->assign_by_ref('actionlogs', $actions); 439 if (isset($_REQUEST['unit'])) { 440 $url .= '&unit=' . $_REQUEST['unit']; 441 } 442 $smarty->assign('url', "&list=y$url#List"); 443 if ($prefs['feature_contribution'] == 'y') { 444 if (empty($_REQUEST['contribTime'])) { 445 $_REQUEST['contribTime'] = 'w'; 446 } 447 $contributionStat = $logslib->get_stat_contribution($actions, $startDate, $endDate, $_REQUEST['contribTime']); 448 $smarty->assign_by_ref('contributionStat', $contributionStat['data']); 449 $smarty->assign_by_ref('contributionNbCols', $contributionStat['nbCols']); 450 $smarty->assign_by_ref('contribTime', $_REQUEST['contribTime']); 451 } 452} 453 454if (isset($_REQUEST['graph'])) { 455 $contributions = $contributionlib->list_contributions(0, -1); 456 $legendWidth = 0; 457 foreach ($contributions['data'] as $contribution) { 458 $legendWidth = max($legendWidth, strlen($contribution['name'])); 459 } 460 $legendWidth = $legendWidth * 7 + 20; 461 $xUserTickWidth = 0; 462 foreach ($userContributions['data'] as $u => $val) { 463 $xUserTickWidth = max($xUserTickWidth, strlen($u)); 464 } 465 $xUserTickWidth = $xUserTickWidth * 7; 466 $xGroupTickWidth = 0; 467 foreach ($groupContributions as $g => $val) { 468 $xGroupTickWidth = max($xGroupTickWidth, strlen($g)); 469 } 470 $xGroupTickWidth = $xGroupTickWidth * 7; 471 $yTickWidth = 0; 472 foreach ($contributionStat['data'] as $contribution) { 473 $yTickWidth = max($yTickWidth, $contribution['add'], $contribution['del']); 474 } 475 $yTickWidth = "($yTickWidth).0"; 476 $yTickWidth = strlen($yTickWidth) * 7; 477 $widthWeek = 70 * $contributionStat['nbCols'] + 100 + $legendWidth; 478 $widthTotal = 70 + 100 + $legendWidth + $yTickWidth; 479 $height = 250; 480 $widthUser = 70 * $userContributions['nbCols'] + 100 + $legendWidth + $yTickWidth; 481 $widthGroup = 70 * count($groupContributions) + 100 + $legendWidth + $yTickWidth; 482 $space = 20; 483 if ($prefs['feature_jpgraph'] == 'y') { 484 require_once('lib/jpgraph/src/jpgraph.php'); 485 require_once('lib/jpgraph/src/jpgraph_bar.php'); 486 require_once('lib/jpgraph/src/jpgraph_mgraph.php'); 487 $imagegallib = TikiLib::lib('imagegal'); 488 $ext = 'jpeg'; 489 $background = new MGraph(); 490 $background->SetImgFormat($ext); 491 $background->SetFrame(true, 'black'); 492 $background->SetMargin(10, 10, 10, 10); 493 } else { 494 require_once('lib/sheet/grid.php'); 495 require_once('lib/graph-engine/gd.php'); 496 require_once('lib/graph-engine/pdflib.php'); 497 require_once('lib/graph-engine/ps.php'); 498 require_once('lib/graph-engine/graph.pie.php'); 499 require_once('lib/graph-engine/graph.bar.php'); 500 require_once('lib/graph-engine/graph.multiline.php'); 501 $graphType = 'BarStackGraphic'; 502 $ext = 'jpg'; 503 $background = new GD_GRenderer(max($widthUser, $widthWeek), 8 * $height, $ext); 504 $legendWidth = 300; 505 } 506 include_once('lib/smarty_tiki/modifier.tiki_short_date.php'); 507 $period = ' (' . smarty_modifier_tiki_short_date($startDate); 508 $s = smarty_modifier_tiki_short_date($startDate); 509 $e = smarty_modifier_tiki_short_date($endDate); 510 $period = ($s != $e) ? " ($s-$e)" : " ($s)"; 511 $accumulated = (isset($_REQUEST['barPlot']) && $_REQUEST['barPlot'] == 'acc') ? true : false; 512 $series = $logslib->draw_contribution_user($userContributions, 'add', $contributions); 513 if ($series['totalVol']) { 514 if ($tiki_p_admin == 'y') { 515 $title = tra('Users Contributions: Addition'); 516 } else { 517 $title = sprintf(tra('%s Contributions: Addition'), $user); 518 } 519 if ($prefs['feature_jpgraph'] == 'y') { 520 $graph = new Graph($widthUser, $height + $xUserTickWidth); 521 $graph->img->SetImgFormat($ext); 522 $logslib->graph_to_jpgraph($graph, $series, $accumulated, $_REQUEST['bgcolor'], $_REQUEST['legendBgcolor']); 523 $graph->img->SetMargin(40 + $yTickWidth, 40 + $legendWidth, 50, 40 + $xUserTickWidth); 524 $graph->title->Set($title); 525 $graph->subtitle->Set($period); 526 if ($tiki_p_admin == 'y') { 527 $graph->xaxis->SetTitle(tra('Users'), 'center'); 528 $graph->xaxis->SetTitleMargin($xUserTickWidth); 529 } 530 $graph->xaxis->SetLabelAngle(90); 531 $graph->yaxis->title->Set(tra($_REQUEST['unit'])); 532 $graph->yaxis->SetTitleMargin($yTickWidth); 533 $graph->setFrame(true, 'darkgreen', 2); 534 $background->Add($graph, 0, 0); 535 if (! empty($_REQUEST['galleryId'])) { 536 $logslib->insert_image($_REQUEST['galleryId'], $graph, $ext, $title, $period); 537 } 538 } else { 539 $renderer = new GD_GRenderer($widthUser, $height, $ext); 540 $graph = new $graphType; 541 $graph->setData($series); 542 $graph->setTitle($title); 543 $graph->draw($renderer); 544 imagecopy($background->gd, $renderer->gd, 0, 0, 0, 0, $renderer->width, $renderer->height); 545 } 546 } 547 $series = $logslib->draw_contribution_user($userContributions, 'del', $contributions); 548 if ($series['totalVol']) { 549 if ($tiki_p_admin == 'y') { 550 $title = tra('Users Contributions: Suppression'); 551 } else { 552 $title = sprintf(tra('%s Contributions: Suppression'), $user); 553 } 554 if ($prefs['feature_jpgraph'] == 'y') { 555 $graph = new Graph($widthUser, $height + $xUserTickWidth); 556 $graph->img->SetImgFormat($ext); 557 $logslib->graph_to_jpgraph($graph, $series, $accumulated, $_REQUEST['bgcolor'], $_REQUEST['legendBgcolor']); 558 $graph->img->SetMargin(40 + $yTickWidth, 40 + $legendWidth, 50, 40 + $xUserTickWidth); 559 $graph->title->Set($title); 560 $graph->subtitle->Set($period); 561 if ($tiki_p_admin == 'y') { 562 $graph->xaxis->SetTitle(tra('Users'), 'center'); 563 $graph->xaxis->SetTitleMargin($xUserTickWidth); 564 } 565 $graph->xaxis->SetLabelAngle(90); 566 $graph->yaxis->title->Set(tra($_REQUEST['unit'])); 567 $graph->yaxis->SetTitleMargin($yTickWidth); 568 $graph->setFrame(true, 'red', 2); 569 $background->Add($graph, 0, ($height + $space + $xUserTickWidth)); 570 if (! empty($_REQUEST['galleryId'])) { 571 $logslib->insert_image($_REQUEST['galleryId'], $graph, $ext, $title, $period); 572 } 573 } else { 574 $renderer = new GD_GRenderer($widthUser, $height, $ext); 575 $graph = new $graphType; 576 $graph->setData($series); 577 $graph->setTitle($title); 578 $graph->draw($renderer); 579 imagecopy($background->gd, $renderer->gd, 0, ($height + $space), 0, 0, $renderer->width, $renderer->height); 580 } 581 } 582 $series = $logslib->draw_week_contribution_vol($contributionStat, 'add', $contributions); 583 if ($series['totalVol']) { 584 if ($_REQUEST['contribTime'] == 'd') { 585 $title = tra('Total Contributions Addition per Day'); 586 $title2 = tra('Days'); 587 } else { 588 $title = tra('Total Contributions Addition per Week'); 589 $title2 = tra('Weeks'); 590 } 591 if ($prefs['feature_jpgraph'] == 'y') { 592 $graph = new Graph($widthWeek, $height); 593 $graph->img->SetImgFormat($ext); 594 $logslib->graph_to_jpgraph($graph, $series, $accumulated, $_REQUEST['bgcolor'], $_REQUEST['legendBgcolor']); 595 $graph->img->SetMargin(40 + $yTickWidth, 40 + $legendWidth, 50, 40); 596 $graph->title->Set($title); 597 $graph->xaxis->SetTitle($title2, 'center'); 598 $graph->yaxis->title->Set(tra($_REQUEST['unit'])); 599 $graph->subtitle->Set($period); 600 $graph->yaxis->SetTitleMargin($yTickWidth); 601 $graph->setFrame(true, 'darkgreen', 2); 602 $background->Add($graph, 0, 2 * ($height + $space) + 2 * $xUserTickWidth); 603 if (! empty($_REQUEST['galleryId'])) { 604 $logslib->insert_image($_REQUEST['galleryId'], $graph, $ext, $title, $period); 605 } 606 } else { 607 $renderer = new GD_GRenderer($widthWeek, $height, $ext); 608 $graph = new $graphType; 609 unset($series['totalVol']); 610 $graph->setData($series); 611 $graph->setTitle($title); 612 $graph->draw($renderer); 613 imagecopy($background->gd, $renderer->gd, 0, 2 * ($height + $space), 0, 0, $renderer->width, $renderer->height); 614 } 615 } 616 $series = $logslib->draw_week_contribution_vol($contributionStat, 'del', $contributions); 617 if ($series['totalVol']) { 618 if ($_REQUEST['contribTime'] == 'd') { 619 $title = tra('Total Contributions Suppression per Day'); 620 $title2 = tra('Days'); 621 } else { 622 $title = tra('Total Contributions Suppression per Week'); 623 $title2 = tra('Weeks'); 624 } 625 if ($prefs['feature_jpgraph'] == 'y') { 626 $graph = new Graph($widthWeek, $height); 627 $graph->img->SetImgFormat($ext); 628 $logslib->graph_to_jpgraph($graph, $series, $accumulated, $_REQUEST['bgcolor'], $_REQUEST['legendBgcolor']); 629 $graph->img->SetMargin(40 + $yTickWidth, 40 + $legendWidth, 50, 40); 630 $graph->title->Set($title); 631 $graph->xaxis->SetTitle($title2, 'center'); 632 $graph->subtitle->Set($period); 633 $graph->yaxis->title->Set(tra($_REQUEST['unit'])); 634 $graph->yaxis->SetTitleMargin($yTickWidth); 635 $graph->setFrame(true, 'red', 2); 636 $background->Add($graph, 0, 3 * ($height + $space) + 2 * $xUserTickWidth); 637 if (! empty($_REQUEST['galleryId'])) { 638 $logslib->insert_image($_REQUEST['galleryId'], $graph, $ext, $title, $period); 639 } 640 } else { 641 $renderer = new GD_GRenderer($widthWeek, $height, $ext); 642 $graph = new $graphType; 643 unset($series['totalVol']); 644 $graph->setData($series); 645 $graph->setTitle($title); 646 $graph->draw($renderer); 647 imagecopy($background->gd, $renderer->gd, 0, 3 * ($height + $space), 0, 0, $renderer->width, $renderer->height); 648 } 649 } 650 $series = $logslib->draw_contribution_vol($contributionStat, 'add', $contributions); 651 if ($series['totalVol']) { 652 $title = tra('Total Contributions: Addition'); 653 if ($prefs['feature_jpgraph'] == 'y') { 654 $graph = new Graph($widthTotal, $height); 655 $graph->img->SetImgFormat($ext); 656 $logslib->graph_to_jpgraph($graph, $series, $accumulated, $_REQUEST['bgcolor'], $_REQUEST['legendBgcolor']); 657 $graph->img->SetMargin(40 + $yTickWidth, 40 + $legendWidth, 50, 40); 658 $graph->title->Set($title); 659 $graph->subtitle->Set($period); 660 $graph->yaxis->title->Set(tra($_REQUEST['unit'])); 661 $graph->yaxis->SetTitleMargin($yTickWidth); 662 $graph->setFrame(true, 'darkgreen', 2); 663 $background->Add($graph, 0, 4 * ($height + $space) + 2 * $xUserTickWidth); 664 if (! empty($_REQUEST['galleryId'])) { 665 $logslib->insert_image($_REQUEST['galleryId'], $graph, $ext, $title, $period); 666 } 667 } else { 668 $renderer = new GD_GRenderer($widthTotal, $height, $ext); 669 $graph = new $graphType; 670 $graph->setData($series); 671 $graph->setTitle($title); 672 $graph->draw($renderer); 673 imagecopy($background->gd, $renderer->gd, 0, 4 * ($height + $space), 0, 0, $renderer->width, $renderer->height); 674 } 675 } 676 $series = $logslib->draw_contribution_vol($contributionStat, 'del', $contributions); 677 if ($series['totalVol']) { 678 $title = tra('Total Contributions: Suppression'); 679 if ($prefs['feature_jpgraph'] == 'y') { 680 $graph = new Graph($widthTotal, $height); 681 $graph->img->SetImgFormat($ext); 682 $logslib->graph_to_jpgraph($graph, $series, $accumulated, $_REQUEST['bgcolor'], $_REQUEST['legendBgcolor']); 683 $graph->img->SetMargin(40 + $yTickWidth, 40 + $legendWidth, 50, 40); 684 $graph->title->Set($title); 685 $graph->subtitle->Set($period); 686 $graph->yaxis->title->Set(tra($_REQUEST['unit'])); 687 $graph->yaxis->SetTitleMargin($yTickWidth); 688 $graph->setFrame(true, 'red', 2); 689 $background->Add($graph, 0, 5 * ($height + $space) + 2 * $xUserTickWidth); 690 if (! empty($_REQUEST['galleryId'])) { 691 $logslib->insert_image($_REQUEST['galleryId'], $graph, $ext, $title, $period); 692 } 693 } else { 694 $renderer = new GD_GRenderer($widthTotal, $height, $ext); 695 $graph = new $graphType; 696 $graph->setData($series); 697 $graph->setTitle($title); 698 $graph->draw($renderer); 699 imagecopy($background->gd, $renderer->gd, 0, 5 * ($height + $space), 0, 0, $renderer->width, $renderer->height); 700 } 701 } 702 $series = $logslib->draw_contribution_group($groupContributions, 'add', $contributions); 703 if ($series['totalVol']) { 704 $title = tra('Groups Contributions: Addition'); 705 if ($prefs['feature_jpgraph'] == 'y') { 706 $graph = new Graph($widthGroup, $height + $xGroupTickWidth); 707 $graph->img->SetImgFormat($ext); 708 $logslib->graph_to_jpgraph($graph, $series, $accumulated, $_REQUEST['bgcolor'], $_REQUEST['legendBgcolor']); 709 $graph->img->SetMargin(40 + $yTickWidth, 40 + $legendWidth, 50, 40 + $xGroupTickWidth); 710 $graph->title->Set($title); 711 $graph->subtitle->Set($period); 712 $graph->xaxis->SetTitle(tra('Groups'), 'center'); 713 $graph->xaxis->SetLabelAngle(90); 714 $graph->xaxis->SetTitleMargin($xGroupTickWidth); 715 $graph->yaxis->title->Set(tra($_REQUEST['unit'])); 716 $graph->yaxis->SetTitleMargin($yTickWidth); 717 $graph->setFrame(true, 'darkgreen', 2); 718 $background->Add($graph, 0, 6 * ($height + $space) + 2 * $xUserTickWidth); 719 if (! empty($_REQUEST['galleryId'])) { 720 $logslib->insert_image($_REQUEST['galleryId'], $graph, $ext, $title, $period); 721 } 722 } else { 723 $renderer = new GD_GRenderer($widthGroup, $height, $ext); 724 $graph = new $graphType; 725 $graph->setData($series); 726 $graph->setTitle($title); 727 $graph->draw($renderer); 728 imagecopy($background->gd, $renderer->gd, 0, 6 * ($height + $space), 0, 0, $renderer->width, $renderer->height); 729 } 730 } 731 $series = $logslib->draw_contribution_group($groupContributions, 'del', $contributions); 732 if ($series['totalVol']) { 733 $title = tra('Groups Contributions: Suppression'); 734 if ($prefs['feature_jpgraph'] == 'y') { 735 $graph = new Graph($widthGroup, $height + $xGroupTickWidth); 736 $graph->img->SetImgFormat($ext); 737 $logslib->graph_to_jpgraph($graph, $series, $accumulated, $_REQUEST['bgcolor'], $_REQUEST['legendBgcolor']); 738 $graph->img->SetMargin(40 + $yTickWidth, 40 + $legendWidth, 50, 40 + $xGroupTickWidth); 739 $graph->title->Set($title); 740 $graph->subtitle->Set($period); 741 $graph->xaxis->SetLabelAngle(90); 742 $graph->xaxis->SetTitle(tra('Groups'), 'center'); 743 $graph->xaxis->SetTitleMargin($xGroupTickWidth); 744 $graph->yaxis->title->Set(tra($_REQUEST['unit'])); 745 $graph->yaxis->SetTitleMargin($yTickWidth); 746 $graph->setFrame(true, 'red', 2); 747 $background->Add($graph, 0, 7 * ($height + $space) + 2 * $xUserTickWidth + $xGroupTickWidth); 748 if (! empty($_REQUEST['galleryId'])) { 749 $logslib->insert_image($_REQUEST['galleryId'], $graph, $ext, $title, $period); 750 } 751 } else { 752 $renderer = new GD_GRenderer($widthGroup, $height, $ext); 753 $graph = new $graphType; 754 $graph->setData($series); 755 $graph->setTitle($title); 756 $graph->draw($renderer); 757 imagecopy($background->gd, $renderer->gd, 0, 7 * ($height + $space), 0, 0, $renderer->width, $renderer->height); 758 } 759 } 760 if ($prefs['feature_jpgraph'] == 'y') { 761 $background->Stroke(); 762 } else { 763 ob_start(); 764 $background->httpOutput("graph.$ext"); 765 $content = ob_get_contents(); 766 ob_end_flush(); 767 } 768 die; 769} elseif ($prefs['feature_jpgraph'] == 'y') { 770 $smarty->assign( 771 'bgcolors', 772 [ 773 'white', 774 'gray', 775 'silver', 776 'ivory', 777 'whitesmoke', 778 'beige', 779 'darkgrey' 780 ] 781 ); 782 //get_strings tra('white'), tra('gray'), tra('silver'), tra('ivory'), tra('whitesmoke'), tra('beige'),tra('darkgrey') 783 $smarty->assign('defaultBgcolor', 'whitesmoke'); 784 $smarty->assign('defaultLegendBgcolor', 'white'); 785 $imagegallib = TikiLib::lib('imagegal'); 786 $galleries = $imagegallib->list_galleries(0, -1, 'name_asc', $user, ''); 787 $smarty->assign('galleries', $galleries['data']); 788} 789 790if (empty($_REQUEST)) { 791 $startDate = $tikilib->make_time(0, 0, 0, $tikilib->date_format('%m'), $tikilib->date_format('%d'), $tikilib->date_format('%Y')); 792 $endDate = $tikilib->make_time(23, 59, 59, $tikilib->date_format('%m'), $tikilib->date_format('%d'), $tikilib->date_format('%Y')); 793 $smarty->assign('startDate', $startDate); 794 $smarty->assign('endDate', $endDate); 795} 796$smarty->assign_by_ref('offset', $offset); 797$smarty->assign_by_ref('cant', $actions_cant); 798$smarty->assign_by_ref('maxRecords', $maxRecords); 799$action_log_types = $logslib->get_actionlog_types(); 800if (! empty($_REQUEST['action_log_type'])) { 801 $smarty->assign('action_log_type', $_REQUEST['action_log_type']); 802} 803if (! empty($_REQUEST['action_log_ip'])) { 804 $smarty->assign('action_log_ip', $_REQUEST['action_log_ip']); 805} 806if (! empty($_REQUEST['action_log_action'])) { 807 $smarty->assign('action_log_action', $_REQUEST['action_log_action']); 808} 809$smarty->assign('action_log_conf_selected', $action_log_conf_selected); 810$smarty->assign('action_log_types', $action_log_types); 811$smarty->assign('action_log_actions', $logslib->get_actionlog_actions()); 812 813if (isset($_REQUEST['time'])) { 814 $smarty->assign('time', $_REQUEST['time']); 815} 816if (isset($_REQUEST['unit'])) { 817 $smarty->assign('unit', $_REQUEST['unit']); 818} 819// Display the template 820$smarty->assign('mid', 'tiki-admin_actionlog.tpl'); 821$smarty->display("tiki.tpl"); 822