Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
NEMS Linux
committed
Feb 25, 2019
1 parent
5f2ab96
commit 4fbc796
Showing
5 changed files
with
33 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
<?php | ||
|
||
$defaultbgcolor = '040111'; | ||
|
||
$key = strtotime('today'); | ||
// caches the response each day | ||
$cachefile = '/tmp/bgcolor-' . $key; | ||
if (file_exists($cachefile)) { | ||
$result = trim(file_get_contents($cachefile)); | ||
} else { | ||
$json_url = 'https://cloud.nemslinux.com/bgcolor/' . $key . '.json'; | ||
$ch = curl_init( $json_url ); | ||
$options = array( | ||
CURLOPT_RETURNTRANSFER => true, | ||
CURLOPT_HTTPHEADER => array('Content-type: application/json') , | ||
); | ||
curl_setopt_array( $ch, $options ); | ||
$result = curl_exec($ch); | ||
file_put_contents($cachefile,$result); | ||
} | ||
$resultobj = json_decode($result); | ||
if (isset($resultobj->$key)) { | ||
$bgcolor = $resultobj->$key; | ||
} else { | ||
$bgcolor = $defaultbgcolor; | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters