• need php help

    From August Abolins@2:221/360 to All on Tue Nov 12 03:58:21 2019
    I want to get the date info of a specific file:

    program name = what-time-changed-php.php

    <?php
    $filename = '/wp-content/themes/cat_c21/functions.php';
    if (file_exists($filename)) {
    echo "$filename was last modified: " . date ("F d Y H:i:s.", filemtime($filename));
    }
    ?>

    I type it in at the root site address:

    http:// <sitename>/what-time-changed-php.php

    ..but this is coming up with a blank display. :(

    What am I doing wrong?

    --- Thunderbird 2.0.0.24 (Windows/20100228)
    * Origin: nntp://rbb.fidonet.fi - Lake Ylo - Finland (2:221/360)
  • From mark lewis@1:3634/12.73 to August Abolins on Tue Nov 12 05:07:04 2019

    On 2019 Nov 12 03:58:20, you wrote to All:

    I type it in at the root site address:

    http:// <sitename>/what-time-changed-php.php

    ..but this is coming up with a blank display. :(

    What am I doing wrong?

    invalid or no html? have you looked at the resulting page's source in your browser?

    also, for security reasons, you'd be better off to have $filename contain only the file's name... put the path in another one and do not output it at all... then connect the two when needed...

    )\/(ark

    Once men turned their thinking over to machines in the hope that this would set them free. But that only permitted other men with machines to enslave them.
    ... Real Men Need Poker Night; it's essential to our health.
    ---
    * Origin: (1:3634/12.73)
  • From August Abolins@2:221/360 to mark lewis on Tue Nov 12 19:50:47 2019
    On 2019 Nov 12 03:58:20, you wrote to All:

    AA> I type it in at the root site address:

    AA> http:// <sitename>/what-time-changed-php.php

    AA> ..but this is coming up with a blank display.

    AA> What am I doing wrong?

    invalid or no html? have you looked at the resulting page's
    source in your browser?

    php can be executed directly. I don't need to call it within html.

    Meanwhile, after adjusting the script without the "if.." and thus forcing an output, I would get, the output:

    Last modified: December 31 1969 19:00:00.

    ..which is php-speak for "file not found".

    :(


    also, for security reasons, you'd be better off to have
    $filename contain only the file's name... put the path in
    another one and do not output it at all... then connect the two
    when needed...

    What do you mean "do not output it at all"? How would I see the result otherwise?

    I just want to produce a report of "last modified" dates of files in specific directories. And if that works, have the script email the output on a schedule. But the above is a first step.

    How would this would be a security risk?

    ..AA

    --- Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.1
    * Origin: nntp://rbb.fidonet.fi - Lake Ylo - Finland (2:221/360)
  • From mark lewis@1:3634/12.73 to August Abolins on Fri Nov 22 14:20:58 2019

    On 2019 Nov 12 19:50:46, you wrote to me:

    I type it in at the root site address:

    http:// <sitename>/what-time-changed-php.php

    ..but this is coming up with a blank display.

    What am I doing wrong?

    invalid or no html? have you looked at the resulting page's
    source in your browser?

    php can be executed directly.

    i know :)

    I don't need to call it within html.

    i didn't say you did but if you expect a browser to properly render the output, it should be in proper html format ;)

    also, for security reasons, you'd be better off to have
    $filename contain only the file's name... put the path in
    another one and do not output it at all... then connect the two
    when needed...

    What do you mean "do not output it at all"? How would I see the result otherwise?

    i'm saying that if you want to keep your server's directory layout secret to prevent possible hacking access and fore-knowledge of your setup, do not output the path of the file...

    I just want to produce a report of "last modified" dates of files in specific directories. And if that works, have the script email the output on a schedule. But the above is a first step.

    then why be messing with looking at the output in a browser?

    How would this would be a security risk?

    because it would publish the path to those with possibly nefearious desires...

    )\/(ark

    Once men turned their thinking over to machines in the hope that this would set them free. But that only permitted other men with machines to enslave them.
    ... Kindly observe the mistletoe on my coattails as I depart... D. Drum
    ---
    * Origin: (1:3634/12.73)