log("log","list_logs_directory"); $c=array(); foreach( glob("${dir}/*log*") as $absfile) { $c[]=array("name"=>basename($absfile), "creation_date"=>date("F d Y H:i:s", filectime($absfile)), "mtime" => filemtime($absfile), "filesize"=>filesize($absfile), "downlink"=>urlencode(basename($absfile)), ); } usort($c,"m_log::compare_logtime"); return $c; }//list_logs // Used by list_logs_directory to sort private function compare_logname($a, $b) { return strcmp($a['name'],$b['name']); } // Used by list_logs_directory to sort private function compare_logtime($a, $b) { return $b['mtime']-$a['mtime']; } function hook_menu() { $obj = array( 'title' => _("Logs"), 'ico' => 'images/logs.png', 'link' => 'logs_list.php', 'pos' => 130, ) ; return $obj; } function list_logs_directory_all($dirs){ global $err; $err->log("log","get_logs_directory_all"); $c=array(); foreach($dirs as $dir=>$val){ $c[$dir]=$this->list_logs_directory($val); } return $c; } function get_logs_directory(){ global $cuid,$mem,$err; $err->log("log","get_logs_directory"); // Return an array to allow multiple directory in the future if(defined('ALTERNC_LOGS_ARCHIVE')){ $c=array("dir"=>ALTERNC_LOGS_ARCHIVE."/".$cuid."-".$mem->user["login"]); }else{ $c=array("dir"=>ALTERNC_LOGS."/".$cuid."-".$mem->user["login"]); } return $c; } function download_link($file){ global $err,$mem; $err->log("log","download_link"); header("Content-Disposition: attachment; filename=".$file.""); header("Content-Type: application/force-download"); header("Content-Transfer-Encoding: binary"); $f=$this->get_logs_directory(); $ff=$f['dir']."/".basename($file); set_time_limit(0); readfile($ff); } function tail($file,$lines=20) { global $err,$mem; $err->log("log","tail"); $lines=intval($lines); if ($lines<=0) $lines=20; $f=$this->get_logs_directory(); $ff=$f['dir']."/".basename($file); unset($out); exec("tail -".$lines." ".escapeshellarg($ff),$out); return implode("\n",$out); } } // end class