Script to find error log files (specified by php.ini) at and below current directory. With option to view or delete files.
By : opus006
<html><body>
<?php
/*
script: FindErrLog
by: Wayne Nelson
for: codewalkers code forum
scrip to display all error logs at, or below current directory.
Uses log file specified in php.ini: error_log=XXXXXXXXXX
*/
function GetListArray( $fileRoot, $matchFile, $isWin) {
$foundList = array();
$subList = array();
$filePath = ""; //file path relative to current file $ web directories
$path = $fileRoot;
do {
$path = $fileRoot.$filePath;
$Hdir = opendir($path);
if ($Hdir) {
while (false !== ($file = readdir($Hdir))) {
if (($file != '.') && ($file != '..')) {
if ($isWin) {
if ($file === $matchFile)
array_push($foundList, $filePath."\\".$file);
if (is_dir( $fileRoot.$filePath."\\".$file ))
array_push($subList, $filePath."\\".$file);
} // if isWin
else {
if ($file === $matchFile)
array_push($foundList, $filePath.'/'.$file);
if (is_dir( $fileRoot.$filePath.'/'.$file ))
array_push($subList, $filePath.'/'.$file);
} // else isWin
} // if . or ..
} // while file
}// if Hdir
$continue= false;
if (list($key, $val)= each($subList)) {
$continue=true;
$filePath = $val;
array_shift($subList);
} // if subList
} while ($continue);
sort($foundList);
return $foundList;
} // GetListArray function;
//###############################
// main code
//###############################
if (isset($_GET['delete'])) {
$tmp = $_GET['delete'];
// var_dump($tmp);
unlink($tmp);
}
$errFile = ini_get('error_log');
$me = $_SERVER['SCRIPT_NAME'];
$sub = substr( $_SERVER['SCRIPT_NAME'], 0, strrpos($_SERVER['SCRIPT_NAME'], '/'));
$webRoot = 'http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER['SERVER_PORT'].$sub;
$dirRoot = getcwd();
$isWin = (strrpos($dirRoot, '\\')=== FALSE) ? FALSE : TRUE;
$List = GetListArray( $dirRoot, $errFile, $isWin);
?>
<table width="100%" border="1" cellspacing="2" cellpadding="0">
<tr>
<td></td>
<td><p>List of all log files (specified by "error_log" in php.ini file) at or below the current directory.</p>
<?php
print "<p>error_log setting: $errFile</p>\n";
print "<p>current web directory: $webRoot</p>\n";
print "<p>current file direcory: $dirRoot</p>\n";
foreach ($List as $dir){
$tmp = str_replace("\\", '/', $dir);
$ds = $me.'?delete='.$dirRoot.$dir;
print '<tr><td><a href="'.$webRoot.$tmp.'" target="_blank">view</a></td><td>'.$dir.'</td><td><a href="'.$ds.'">delete</a></td></tr>'."\n";
} // foreach list
print '<tr><td></td><td><form action ="'.$me.'" method="get" name="FindErrLog">'."\n";
?>
<p><input type="submit" name="bnStart" value="Search" border="0"></p>
</form></td>
</table>
</body>
</html>
<?php
flush();
exit;
?>
| DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware. |
More File Manipulation Code Articles
More By Codewalkers
developerWorks - FREE Tools! |
Join this webcast, to learn how the Rational Process Library can help with compliance issues, drive process improvement, and assist in service-oriented architecture (SOA) or Agile development. We will take a peek into the Rational Process Library with content around software and systems engineering (including RUP), operations and systems management, program and portfolio management, and asset and SOA governance. FREE! Go There Now!
|
|
|
|
David Barnes, Lead Evangelist for IBM Emerging Internet Technologies will discuss aspects of Web 2.0 that bring value to corporations, academia, and government. He'll also discuss IBM's vision around Web 2.0, including the importance of remixability and consumability. The discussion will culminate with examples of various IBM Software Group solutions you can use to get ahead of the Web 2.0 adoption curve. FREE! Go There Now!
|
|
|
|
This whitepaper presents the benefits of successfully introducing static analysis into your organization using IBM Rational Software Analyzer. Additionally, it identifies some common pitfalls that can hinder the effective use of static analysis tooling as well as presents 10 simple strategies designed to help you quickly realize the value of static analysis using Rational Software Analyzer. FREE! Go There Now!
|
|
|
|
Download a free trial version of IBM Rational Developer for System i V7.1, which provides a complete development environment for traditional i5/OS application development. IBM Rational Developer for System i is a new eclipse-based workstation offering for i5/OS application development that provides a comprehensive Integrated Development Environment for edit/compile/debug of traditional RPG/COBOL/C/C++ i5/OS applications. FREE! Go There Now!
|
|
|
|
Listen to this webcast to get an overview of Info 2.0 and a technical demo of how to quickly build an enterprise mashup. IBM's Info 2.0 technology leverages emerging Web 2.0 technologies such as mashups, feeds, AJAX, and JSON in order to simplify assembly of information using feeds and services. Come learn about the technical elements of Info 2.0 including the Feed Generation framework, Mashup Engine, and mashup assembly components. Learn how to pull information from databases, departmental information, and the Web to create mashups critical to your company’s success. We will also discuss best practices to help you get started. FREE! Go There Now!
|
|
|
|
XML has become a common way of storing business data as flat files and many data server vendors including IBM have provided ways to store this data within relational database systems. Increasingly collections of XML files are accessed like databases using an xQuery and other XML standard mechanisms. Businesses find the need to combine the traditional tabular structured data with XML formatted data. In this webcast, you’ll learn about IBM’s WebSphere Federation Server technology, which provides users with the ability to integrate these two data formats. FREE! Go There Now!
|
|
|
|
This webcast outlines the best practices that must be instituted to gain the maximum benefit from SOA while maintaining high quality of service. Whether you are deploying new applications or managing and monitoring your existing infrastructure, learn how you can ensure high quality of services with SOA based solutions from IBM. All registrants who attend this live Web Seminar will receive complimentary access to a white paper titled “Maintaining QoS in an SOA Environment”. FREE! Go There Now!
|
|
|
|
Join this Rational Talks to You teleconference on December 6 at 1:00 pm ET to participate in an agile application development discussion and get your questions answered on using IBM Rational Method Composer in a distributed environment.Get your questions answered! FREE! Go There Now!
|
|
|
|
As organizations have grown increasingly dependent on online software, the risk of malicious attacks has also become far more serious. Fortunately, well-governed organizations can protect their Web applications by injecting vulnerability assessments and ethical hacks into their software development and delivery processes. This paper describes 12 of the most common hacker attacks and provides basic rules that you can follow to help create more hack-resistant Web applications. FREE! Go There Now!
|
|
|
|
This paper is about the critical role that a discipline called integrated requirements management can play in helping to ensure that your business goals and IT investments are continuously aligned—whether you are sourcing, integrating, building or maintaining software. It also looks at ways that automated IBM Rational® products can work together to help you use requirements in the very best way. FREE! Go There Now!
|
|
|
|
All FREE IBM® developerWorks Tools! |