-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy pathlotd.php
More file actions
21 lines (21 loc) · 814 Bytes
/
lotd.php
File metadata and controls
21 lines (21 loc) · 814 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<?php
// this file picks a random line of code to show in the top of Messaging, for fun.
$datestr = date("d");
if(file_exists("lotd.txt")){
$oldLine = json_decode(file_get_contents("lotd.txt"));
}else{
$oldLine = json_decode('["00", 0, "test line"]');
}
if($oldLine[0] == $datestr){
echo json_encode(array($oldLine[1], $oldLine[2]));
}else{
$jsLines = file('scriptBeta.js');
$selectedLine = array_rand($jsLines);
while(strlen(trim($jsLines[$selectedLine])) < 5){
$selectedLine = array_rand($jsLines);
}
$newLine = array($datestr, $selectedLine + 1, trim($jsLines[$selectedLine]));
file_put_contents("lotd.txt", json_encode($newLine));
echo json_encode(array($newLine[1], $newLine[2]));
}
?>