Changeset 42 for trunk/services/logs.php


Ignore:
Timestamp:
Dec 18, 2005 12:16:03 AM (18 years ago)
Author:
scdev
Message:

detabbed all files ;P

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/services/logs.php

    r41 r42  
    11<?php
    22/**
    3  * logs.php 
     3 * logs.php
    44 * Code by Strangecode :: www.strangecode.com :: This document contains copyrighted information
    55 */
     
    4848 * MAIN
    4949 *****************************************************************************/
    50  
     50
    5151// Allow realtime file stats.
    52 clearstatcache(); 
     52clearstatcache();
    5353
    5454// What action to take.
     
    6565    App::dieURL($_SERVER['PHP_SELF']);
    6666    break;
    67    
     67
    6868case 'clear' :
    6969//     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
     
    7676    App::dieURL($_SERVER['PHP_SELF']);
    7777    break;
    78    
     78
    7979case 'archive' :
    8080//     $auth->requireAccessClearance(ZONE_ADMIN_APPLOG_FUNC_RESET);
     
    9090    App::dieURL($_SERVER['PHP_SELF']);
    9191    break;
    92    
     92
    9393// case 'ouput' :
    9494//     $main_template = 'ouput';
    9595//     break;
    96    
     96
    9797case 'download' :
    9898    header('Content-Type: application/octet-stream');
     
    101101    die;
    102102    break;
    103    
     103
    104104default :
    105105    $list =& getLog(Prefs::getValue('log_file', 'logs_module'), getFormData('search_query'));
     
    137137
    138138function deleteLog($log_file)
    139 {   
     139{
    140140    if (!file_exists(App::getParam('log_directory') . '/' . $log_file)) {
    141141        App::raiseMsg(sprintf(_("Log file %s does not exist."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     
    143143        return false;
    144144    }
    145    
     145
    146146    if (!is_writable(App::getParam('log_directory') . '/' . $log_file) && !is_writable(App::getParam('log_directory'))) {
    147147        App::raiseMsg(sprintf(_("Log file %s could not be deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     
    149149        return false;
    150150    }
    151    
     151
    152152    if (unlink(App::getParam('log_directory') . '/' . $log_file)) {
    153153        App::raiseMsg(sprintf(_("Log file %s has been deleted."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     
    162162
    163163function clearLog($log_file)
    164 {   
     164{
    165165    if (!$fp = fopen(App::getParam('log_directory') . '/' . $log_file, 'r+')) {
    166166        App::raiseMsg(sprintf(_("Log file %s could not be opened."), $log_file), MSG_NOTICE, __FILE__, __LINE__);
     
    168168        return false;
    169169    }
    170    
     170
    171171    flock($fp, LOCK_EX);
    172172    $ftruncate_return = ftruncate($fp, 0);
     
    185185
    186186function archiveLog($log_file)
    187 {   
     187{
    188188    $old_file_name = $log_file;
    189189    $new_file_name = $log_file . '__' . date('Y-m-d');
     
    198198        return false;
    199199    }
    200    
     200
    201201    App::raiseMsg(sprintf(_("Log file %s has been archived to %s."), $old_file_name, $new_file_name), MSG_NOTICE, __FILE__, __LINE__);
    202202    App::logMsg(sprintf('Log file %s has been archived to %s.', $old_file_name, $new_file_name), LOG_NOTICE, __FILE__, __LINE__);
     
    205205
    206206function printLog($log_file)
    207 {       
     207{
    208208    if (!is_file(App::getParam('log_directory') . '/' . $log_file)) {
    209209        App::raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__);
     
    216216
    217217function &getLog($log_file, $search_query='')
    218 {   
     218{
    219219    if (!is_file(App::getParam('log_directory') . '/' . $log_file)) {
    220220        App::raiseMsg(sprintf(_("Log file %s not found."), $log_file), MSG_WARNING, __FILE__, __LINE__);
     
    223223    }
    224224    $log = file(App::getParam('log_directory') . '/' . $log_file);
    225    
     225
    226226    if ('' != trim($search_query)) {
    227227        if (getFormData('search_grep')) {
     
    237237{
    238238    global $valid_file_extensions;
    239    
     239
    240240    // Get a list of all files in the log directory.
    241241    $dir_handle = opendir(App::getParam('log_directory'));
Note: See TracChangeset for help on using the changeset viewer.