Ejemplo n.º 1
0
function download_log($where_, $name_, $server_ = NULL)
{
    if ($where_ == 'sm') {
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename=sessionmanager_' . $name_);
        $filename = SESSIONMANAGER_LOGS . '/main.log';
        $fp = @fopen($filename, 'r');
        if ($fp !== false) {
            while ($str = fgets($fp, 4096)) {
                echo $str;
            }
        }
        @fclose($fp);
    } elseif ($where_ == 'aps') {
        header('Content-Type: application/octet-stream');
        header('Content-Disposition: attachment; filename=slaveserver_' . $server_ . '.log');
        $server = Abstract_Server::load($server_);
        if (!$server) {
            Logger::error('main', '(admin/logs) download_log() - cannot load Server \'' . $server_ . '\'');
            redirect();
        }
        $buf = new Server_Logs($server);
        $buf->process();
        while ($str = $buf->getContent()) {
            echo $str;
        }
    }
    die;
}
Ejemplo n.º 2
0
 public function log_download($log_)
 {
     $this->check_authorized('viewStatus');
     $filename = SESSIONMANAGER_LOGS . '/' . $log_ . '.log';
     if (file_exists($filename)) {
         $fp = @fopen($filename, 'r');
         if ($fp === false) {
             return null;
         }
         $buf = '';
         while ($str = fgets($fp, 4096)) {
             $buf .= $str;
         }
         fclose($fp);
         if (function_exists("iconv")) {
             $buf = iconv("UTF-8", "UTF-8//IGNORE", $buf);
         }
         return $buf;
     }
     $server = Abstract_Server::load($log_);
     if (!$server) {
         return null;
     }
     $l = new Server_Logs($server);
     $l->process();
     $buf = '';
     while ($str = $l->getContent()) {
         $buf .= $str;
     }
     if (function_exists("iconv")) {
         $buf = iconv("UTF-8", "UTF-8//IGNORE", $buf);
     }
     return $buf;
 }