Commit 50187098 authored by Richard Mansfield's avatar Richard Mansfield

Put view log file & stats images into subdirectories under dataroot

Signed-off-by: default avatarRichard Mansfield <richardm@catalyst.net.nz>
parent d460191a
......@@ -42,7 +42,7 @@ switch ($type) {
header('Cache-Control: max-age=' . $maxage);
header('Pragma: public');
readfile(get_config('dataroot') . $type . '.png');
readfile(get_config('dataroot') . 'images/' . $type . '.png');
exit;
}
......
......@@ -160,7 +160,9 @@ function ensure_sanity() {
!check_dir_exists(get_config('dataroot') . 'sessions') ||
!check_dir_exists(get_config('dataroot') . 'temp') ||
!check_dir_exists(get_config('dataroot') . 'langpacks') ||
!check_dir_exists(get_config('dataroot') . 'htmlpurifier')) {
!check_dir_exists(get_config('dataroot') . 'htmlpurifier') ||
!check_dir_exists(get_config('dataroot') . 'log') ||
!check_dir_exists(get_config('dataroot') . 'images')) {
throw new ConfigSanityException(get_string('couldnotmakedatadirectories', 'error'));
}
......@@ -2386,7 +2388,7 @@ function cron_site_data_daily() {
));
// Process log file containing view visits
$viewlog = get_config('dataroot') . 'views.log';
$viewlog = get_config('dataroot') . 'log/views.log';
if (rename($viewlog, $viewlog . '.temp') and $fh = @fopen($viewlog . '.temp', 'r')) {
// Read the new stuff out of the file
......@@ -2485,4 +2487,8 @@ function build_portfolio_search_html(&$data) {
$data->pagination_js = $pagination['javascript'];
}
function mahara_log($logname, $string) {
error_log('[' . date("Y-m-d h:i:s") . "] $string\n", 3, get_config('dataroot') . 'log/' . $logname . '.log');
}
?>
......@@ -200,9 +200,7 @@ function site_statistics($full=false) {
if ($full) {
$data = site_data_current();
if (file_exists(get_config('dataroot') . 'weekly.png')) {
$data['weekly'] = get_config('wwwroot') . 'admin/thumb.php?type=weekly';
}
$data['weekly'] = stats_graph_url('weekly');
if (is_postgres()) {
$weekago = "CURRENT_DATE - INTERVAL '1 week'";
......@@ -352,9 +350,7 @@ function user_statistics($limit, $offset, &$sitedata) {
display_size($maxquotaused->quotaused)
);
if (file_exists(get_config('dataroot') . 'institutions.png')) {
$data['institutions'] = get_config('wwwroot') . 'admin/thumb.php?type=institutions';
}
$data['institutions'] = stats_graph_url('institutions');
$smarty = smarty_core();
$smarty->assign('data', $data);
......@@ -505,7 +501,7 @@ function user_institution_graph() {
}
$AxisX->setFontSize(8);
$Graph->done(array('filename' => get_config('dataroot') . 'institutions.png'));
$Graph->done(array('filename' => stats_graph_path('institutions')));
}
}
......@@ -536,9 +532,7 @@ function group_statistics($limit, $offset) {
GROUP BY jointype
ORDER BY groups DESC", array()
));
if (file_exists(get_config('dataroot') . 'grouptypes.png')) {
$smarty->assign('groupgraph', get_config('wwwroot') . 'admin/thumb.php?type=grouptypes');
}
$smarty->assign('groupgraph', stats_graph_url('grouptypes'));
$data['summary'] = $smarty->fetch('admin/groupstatssummary.tpl');
......@@ -673,7 +667,7 @@ function group_type_graph() {
$PointingMarker =& $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker));
$Plot->setMarker($PointingMarker);
$Graph->done(array('filename' => get_config('dataroot') . 'grouptypes.png'));
$Graph->done(array('filename' => stats_graph_path('grouptypes')));
}
}
......@@ -688,10 +682,6 @@ function view_statistics($limit, $offset) {
);
$data['table'] = view_stats_table($limit, $offset);
if (file_exists(get_config('dataroot') . 'viewtypes.png')) {
$viewtypes = get_config('wwwroot') . 'admin/thumb.php?type=viewtypes';
}
$smarty = smarty_core();
$maxblocktypes = 5;
$smarty->assign('blocktypecounts', get_records_sql_array("
......@@ -707,7 +697,7 @@ function view_statistics($limit, $offset) {
ORDER BY blocks DESC",
array(), 0, $maxblocktypes
));
$smarty->assign('viewtypes', $viewtypes);
$smarty->assign('viewtypes', stats_graph_url('viewtypes'));
$data['summary'] = $smarty->fetch('admin/viewstatssummary.tpl');
return $data;
......@@ -818,7 +808,7 @@ function view_type_graph() {
$PointingMarker =& $Plot->addNew('Image_Graph_Marker_Pointing_Angular', array(20, &$Marker));
$Plot->setMarker($PointingMarker);
$Graph->done(array('filename' => get_config('dataroot') . 'viewtypes.png'));
$Graph->done(array('filename' => stats_graph_path('viewtypes')));
}
}
......@@ -892,7 +882,7 @@ function graph_site_data_weekly() {
// $AxisY->forceMaximum($maxy + $padding);
// $AxisY->forceMinimum($miny - $padding);
$Graph->done(array('filename' => get_config('dataroot') . 'weekly.png'));
$Graph->done(array('filename' => stats_graph_path('weekly')));
}
function graph_site_data_daily() {
......@@ -901,4 +891,15 @@ function graph_site_data_daily() {
view_type_graph();
}
function stats_graph_path($name) {
return get_config('dataroot') . 'images/' . $name . '.png';
}
function stats_graph_url($name) {
if (file_exists(stats_graph_path($name))) {
return get_config('wwwroot') . 'admin/thumb.php?type=' . $name;
}
return '';
}
?>
......@@ -336,8 +336,7 @@ else {
$smarty->assign('viewcontent', $view->build_columns());
$smarty->display('user/view.tpl');
// Log view visits
error_log('[' . date("Y-m-d h:i:s") . "] $viewid\n", 3, get_config('dataroot') . 'views.log');
mahara_log('views', "$viewid"); // Log view visits
// Send an invitation to the user to join a group
function invite_submit(Pieform $form, $values) {
......
......@@ -296,6 +296,5 @@ if ($tutorgroupdata = group_get_user_course_groups()) {
$smarty->display('view/view.tpl');
// Log view visits
error_log('[' . date("Y-m-d h:i:s") . "] $viewid\n", 3, get_config('dataroot') . 'views.log');
mahara_log('views', "$viewid"); // Log view visits
?>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment