Commit 50187098 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

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