I have built this piece of code using my Windows test rig and works fine but moving it onto my ubuntu web server i just get a white screen and nothing else.
My Code:
<?php
// full path to text file
define("TEXT_FILE", "/var/www/html/SupportDesk/testfile.txt");
///home/webserver/Desktop/testfile.txt");
//define("TEXT_FILE", "afp://[email protected]/Logs/Test/testfile.txt");
// number of lines to read from the end of file
define("LINES_COUNT", 5);
function read_file($file, $lines) {
echo $file;
$handle = fopen($file, "r");
$linecounter = $lines;
$pos = -2;
$beginning = false;
$text = array();
while ($linecounter > 0) {
$t = " ";
while ($t != "\n") {
if(fseek($handle, $pos, SEEK_END) == -1) {
$beginning = true;
break;
}
$t = fgetc($handle);
$pos --;
}
$linecounter --;
if ($beginning) {
rewind($handle);
}
$text[$lines-$linecounter-1] = fgets($handle);
if ($beginning) break;
}
fclose ($handle);
return array_reverse($text);
}
$lines = read_file(TEXT_FILE, LINES_COUNT);
foreach ($lines as $line) {
$my_array3 = preg_split("/[ \s,]/",$line);
print_r($my_array3);
$result = preg_grep("/Total-Updates:/i", $my_array3);
foreach ($result as $element) {
echo $element . "<br>";
}
$result1 = preg_grep("/Important:/i", $my_array3);
foreach ($result1 as $element1) {
echo $element1 . "<br>";
}
$result2 = preg_grep("/Optional:/i", $my_array3);
foreach ($result2 as $element2) {
echo $element2 . "<br>";
}
}
?>
I believe its a permission error possibly but any help would be appreciated on this.