Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

PHP self-test script   --  need suggestions

Posted on 2014-04-16
6
Medium Priority
?
531 Views
Last Modified: 2014-04-21
A client has an account on a vendor's server.  We have no control over system updates/parameters.
About once a week something will happen that breaks some facet of PHP.
the most common is suhosin either gets protected or uninstalled.
example error:

[16-Apr-2014 09:15:01] PHP Warning:  PHP Startup: Unable to load dynamic library '/usr/local/lib/php/extensions/no-debug-non-zts-20060613/suhosin.so' - /usr/local/lib/php/extensions/no-debug-non-zts-20060613/suhosin.so: cannot open shared object file: No such file or directory in Unknown on line 0

Please offer experience/advice/suggestions for a script  that can be run in an (hourly) cron job that checks basic PHP health (including suhosin)  and if there's a problem
emails the error to us.

thanks
0
Comment
Question by:willsherwood
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 111

Accepted Solution

by:
Ray Paseur earned 1900 total points
ID: 40004130
Good grief!  Get a new hosting company!  That's a technically incompetent installation, and if the hosting company cannot fix it, they don't know what they are doing and that is dangerous for your work.  You probably do not want Suhosin in any case.

If you want to look for the error_log file, this script will do the job.  You may want to modify it to send an email, text or tweet.  It will scan all of the directories in the tree and show you the error_log contents.  Install it in the web root and run it from the browser to see what it creates.

<?php // find_error_log.php
error_reporting(E_ALL);
ob_start();

// PUT THIS SCRIPT IN THE WEB ROOT DIRECTORY
$path = realpath(getcwd());
$plen = strlen($path);

// THE ERROR LOG FILE NAME
$signal = strrev('error_log');


// IF THERE IS A POST-METHOD REQUEST TO DELETE THE ERROR LOG
if (!empty($_POST['log']))
{
    // MAKE SURE WE ONLY UNLINK THE ERROR LOG FILE
    $test = strrev($_POST['log']);
    if (strpos($test, $signal) === 0)
    {
        unlink($path . $_POST['log']);
        echo '<h3>' . $_POST['log'] . ' Discarded</h3>';
    }
}


// SEE http://php.net/manual/en/class.recursivedirectoryiterator.php#85805
$objs = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($path), RecursiveIteratorIterator::SELF_FIRST);

// UNFORTUNATELY THIS DOES NOT WORK AT PHP 5.4
// var_dump($objs);

// ITERATE OVER THE OBJECTS
foreach($objs as $name => $obj)
{
    // PROCESS THE ERROR LOG ONLY
    $test = strrev($name);
    if (strpos($test, $signal) === 0)
    {
        $name = substr($name, $plen);
        $form = <<<EOD
<form method="post" style="margin:0; padding:0; display:inline;!important">
<b>$name</b>
<input type="submit" value="Discard?" />
<input type="hidden" name="log" value="$name" />
</form>
EOD;
        echo $form;

        // SHOW THE CONTENTS OF THE ERROR LOG
        echo '<pre>';
        print_r(file_get_contents($path . $name));
        echo "</pre>" . PHP_EOL;
    }
}

$out = ob_get_contents();
if (empty($out)) echo '<h3>Good News! No error_log found.</h3>';

Open in new window

HTH, ~Ray
0
 
LVL 59

Expert Comment

by:Julian Hansen
ID: 40004274
Move to another hosting company.
0
 
LVL 84

Assisted Solution

by:Dave Baldwin
Dave Baldwin earned 100 total points
ID: 40004640
I was getting that on Penguin / Chihost for a long time because suhosin doesn't run with PHP 5.4 but apparently they weren't changing the 'php.ini' on that server.  I just checked and that error has finally stopped.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
LVL 111

Assisted Solution

by:Ray Paseur
Ray Paseur earned 1900 total points
ID: 40004716
I got those on ChiHost, too.  It didn't seem to affect my scripts - it just filled up the error logs.  When I told them about it, they fixed it and the problem went away.
0
 

Author Closing Comment

by:willsherwood
ID: 40012895
thanks all!
(unfortunately it's not my choice regarding the provider for this client)
0
 
LVL 111

Expert Comment

by:Ray Paseur
ID: 40013020
At least let your client know the consensus from the Experts!

Thanks for the points and thanks for using EE, ~Ray
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …
Suggested Courses

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question