phpinfo returning 2 different build dates

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Shawn Wilson

    phpinfo returning 2 different build dates

    Hi,

    My host keeps messing things up and not telling me. I am trying to write a cron
    job that will test to make sure the "unusual" functions I use work and, if not,
    email me. I want it to send me the build date as well. The weird thing is, my
    cron script (using phpinfo) gives me a different build date than phpinfo() in an
    "admin tool" section of my website.

    The cron script is sitting in the root of my home directory (non web
    accessable). The admin tool is sitting in a password-protected (BASIC AUTH)
    section of the site.

    ----------------------

    CRON SCRIPT SNIPPET:
    ob_start();
    phpinfo();
    $string = ob_get_contents ();
    ob_end_clean();

    echo "\n\n" . $string . "\n\n";

    ----------------------

    ADMIN TOOL SNIPPET:
    phpinfo();

    ----------------------

    CRON SCRIPT RESULT SNIPPET:
    PHP Version => 4.3.3

    System => Linux mydomain.com X.XX.XX-XX.X #1 Mon Aug 18 14:56:30 EDT 2003 i686
    Build Date => Oct 21 2003 02:52:32

    ----------------------

    ADMIN TOOL RESULT SNIPPET (copied from HTML):
    PHP Version 4.3.3

    System
    Linux mydomain.com X.XX.XX-XX.X #1 Mon Aug 18 14:56:30 EDT 2003 i686
    Build Date
    Oct 18 2003 21:23:42

    ----------------------

    I have tried both with phpinfo(INFO_GE NERAL) as well - same result.
    Does anyone have any idea why this is happening and how to fix it? Both scripts
    are owned by the same user, and have the same permissions. Since I'm testing, I
    currently execute the cron script through SSH with: php -q ./filename.php. I
    execute the admin tool by accessing it through a browser.

    Thanks in advance,
    Shawn
    --
    Shawn Wilson
    shawn@glassgian t.com

  • Jon Kraft

    #2
    Re: phpinfo returning 2 different build dates

    Shawn Wilson <shawn@glassgia nt.com> wrote:
    [color=blue]
    > email me. I want it to send me the build date as well. The weird thing
    > is, my cron script (using phpinfo) gives me a different build date than
    > phpinfo() in an "admin tool" section of my website.[/color]

    Hi Shawn,

    The command "php" and the php module for the web server are two different
    things, unless PHP is run as CGI.

    BTW, your php script could be shortened to a call to php:

    /path/to/php -i

    Outputs the same as phpinfo().

    HTH;
    JOn


    Comment

    • Shawn Wilson

      #3
      Re: phpinfo returning 2 different build dates

      Jon Kraft wrote:[color=blue]
      >
      > Shawn Wilson <shawn@glassgia nt.com> wrote:
      >[color=green]
      > > email me. I want it to send me the build date as well. The weird thing
      > > is, my cron script (using phpinfo) gives me a different build date than
      > > phpinfo() in an "admin tool" section of my website.[/color]
      >
      > Hi Shawn,
      >
      > The command "php" and the php module for the web server are two different
      > things, unless PHP is run as CGI.
      >
      > BTW, your php script could be shortened to a call to php:
      >
      > /path/to/php -i
      >
      > Outputs the same as phpinfo().[/color]

      Ah, I should have known that. I guess I'll have to set up a cron script to
      fopen() a webpage that uses phpinfo() to display the build date, as it's the PHP
      module's build date I'm interested in, unless anyone knows of a less "cludgy"
      solution =D

      Thanks for your help,
      Shawn
      --
      Shawn Wilson
      shawn@glassgian t.com

      Comment

      • Shawn Wilson

        #4
        Re: phpinfo returning 2 different build dates

        Shawn Wilson wrote:[color=blue]
        >
        > Jon Kraft wrote:[color=green]
        > >
        > > Shawn Wilson <shawn@glassgia nt.com> wrote:
        > >[color=darkred]
        > > > email me. I want it to send me the build date as well. The weird thing
        > > > is, my cron script (using phpinfo) gives me a different build date than
        > > > phpinfo() in an "admin tool" section of my website.[/color]
        > >
        > > Hi Shawn,
        > >
        > > The command "php" and the php module for the web server are two different
        > > things, unless PHP is run as CGI.
        > >
        > > BTW, your php script could be shortened to a call to php:
        > >
        > > /path/to/php -i
        > >
        > > Outputs the same as phpinfo().[/color]
        >
        > Ah, I should have known that. I guess I'll have to set up a cron script to
        > fopen() a webpage that uses phpinfo() to display the build date, as it's the PHP
        > module's build date I'm interested in, unless anyone knows of a less "cludgy"
        > solution =D[/color]

        In case anyone is looking for the a solution to the same problem, my script
        follows:

        <?PHP

        $email = "Shawn Wilson <shawn@glassgia nt.com>";
        $subject = "Website functions not working.";
        $headers = "From: Server <shawn@glassgia nt.com>\nX-Priority: 1";
        $message = "Some functions are not working. Please check out immediately.\n\ n";

        $functionlist = array(
        "imagecreatefro mjpeg",
        "imagecreatefro mpng",
        "imagecreat e",
        "imagecopyresiz ed",
        "imagecopy" ,
        "imagejpeg" ,
        "imagepng",
        "imagecreatetru ecolor",
        "fopen",
        "mysql_quer y",
        "filesize",
        "mysql_conn ect"
        );

        sort ($functionlist) ;

        $works = "";
        $notworks = "";
        $builddate = "";

        foreach($functi onlist as $var) {
        if (function_exist s($var))
        $works .= "Function \"$var\" works.\n";
        else
        $notworks .= "Function \"$var\" does not work.\n";
        }

        ob_start();
        phpinfo();
        $string = ob_get_contents ();
        ob_end_clean();

        $string = explode("\n", $string);

        foreach($string as $var) {
        $var = strip_tags($var );
        if (preg_match("/^Build Date\s+([A-Za-z]+ [0-9]+ [0-9]+
        [0-9]+:[0-9]+:[0-9]+).+$/", $var)) {
        $var = preg_replace("/^Build Date\s+([A-Za-z]+ [0-9]+ [0-9]+
        [0-9]+:[0-9]+:[0-9]+)[^0-9]?.*$/", "\$1", $
        var);
        $builddate = $var;
        break;
        }
        }

        if (strlen($notwor ks) > 0)
        mail($email, $subject, $message . $notworks . "\n" . $works . "\n\nBuild
        Date: $builddate", $headers);
        echo "DONE";
        ?>

        I've got a cron job that calls this script through http every hour. I'm sure
        there's a more efficient regex, but this was a quickie. I might add my host's
        tech support address to the To: header.

        Shawn
        --
        Shawn Wilson
        shawn@glassgian t.com

        Comment

        Working...