• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

QUESTION Transitioning from Insert PHP

Brad

New member
Messages
1
Likes
0
Points
1
#1
Hi,

I inherited a client's site that had used Insert PHP. The old entries work, but any new entries do not appear to execute (they do not display any text on the page).

I duplicated the site to a testing server, and have tried Woody Snippets. Are there any special requirements get snippets to execute? I tried the example snippets as well...

I appreciate the help in getting new pages to work with this code. I feel that I am missing something simple...

Here is the code that scans a directory and displays a list of files:

Code:
$dir="../public/myfiles";
$files = scandir($dir);
if ($files) {
foreach ($files as $i => $value) {
    $filename = $files[$i];
    $totallength = strlen($filename);
    $initials = substr($filename, 0, 3);
    $date = substr($filename, 3, 6);
    $year = substr($date, 0, 2);
    $month = substr($date, 2, 2);
    $day = substr($date, 4, 2);
    $time = substr($filename, 9, 4);
    $hour = substr($time, 0, 2);
    $testhour = substr($hour, 0, 1);
    
if ($testhour == '0') {
$hour = substr($time, 1, 1);
}
switch ($hour)
{
case "13":
$hour="1";
break;
case "14":
$hour="2";
break;
case "15":
$hour="3";
break;
case "16":
$hour="4";
break;
}
    
$min = substr($time, 2, 2);
$restoffilename = substr($filename, 13, $totallength);
$addinfo = substr($restoffilename, 0, -4);

$today =strtotime("now");
$datecompare = $year. "-" . $month . "-" . $day;

//check initials and compare filename date to today's date,if in the future list it
if (($initials == "ABC") && (date('y-m-d', $today) <= $datecompare)) {
$btntext = date("F d, Y", mktime(0, 0, 0, $month, $day, $year)) . " - " . $hour . ":" . $min . " " . $addinfo;
//LIST BUTTONS IN DATE ORDER
echo "<p><a href=\"myfiles/$filename\">$btntext</a><br><br> ";

}

}

}
 

alexkovalev

Program developer
Staff member
Messages
152
Likes
10
Points
18
#2
Hi,
You must use absolute directory path that you want to scan.
Code:
$dir="../public/myfiles";
For example (if the directory myfiles is to the root of your site):
Code:
$dir= ABSPATH . "myfiles";
Best regards, Alex