Alright, I give up. My current script seems so inconvenient. Does anybody know how to make a nice, SIMPLE quote of the week script that could be put on a site. NOT a random quote generator or anything. And one that DOESN'T use a database.
I just want a simple, flatfile QOTW script. I have trouble making one, and I most certainly can't find one, so here's my last resort.
I realize this is more of a request than just a question. I'm just frustrated. If you want to edit my code to see if you can fix the existing stuff, that's fine, but I don't care. And I recently realized that even if it was fixed, quote.txt would only display the file location rather than its contents.
As of now (but changeable to whatever besides a D😎, quotes are stored as the following:
[+] 1.txt - <i>"Special quote"</i> ~Famous Guy
[+] 2.txt - SAME AS ABOVE^
etc. etc.
Here's my qotw.php code:
<?php
// ########################
// Quote of the Week script
// ########################
$currentdate = date("m.d.Y"); // Find today's date
$day = date("w"); // Find the day of the week
$read = fopen("date.txt","r"); // Open date.txt to read
$contents = fread($read,filesize("date.txt")); // Read date.txt
if($contents == $currentdate) { // If date.txt's date = today...
$rewrite == "1"; } // don't make a new quote
else { $rewrite == "1"; } // Else do make a new quote
fclose($read); // Close date.txt
if($rewrite == "1" && $day == "0") { // If today is Sunday and the quote hasn't yet been changed...
$range = count(scandir('quotes/'))-2; // Find the number of quotes
$rand = rand(0,$range); // Choose random number
$randqotw = "quotes/".$rand.".txt"; // Generate txt name
$file = fopen("quote.txt","w"); // Open quote.txt to write to
fwrite($file,$randqotw); // Write the random quote chosen to quote.txt
fclose($file); // Close quote.txt
$file2 = fopen("date.txt","w"); // Open date.txt
fwrite($file2,$currentdate); // Write today's date to date.txt
fclose($file2); // Close date.txt
include("quote.txt"); // Display quote
exit; } // Exit
else { // If today isn't Sunday and/or it's already been written...
include("quote.txt"); // Display quote
}
?>
It doesn't matter, come up with an entirely different script if you want, I just need a QOTW script. That's all. Without DB. Flatfile.
😃