data->created_utc, $b->data->created_utc); }
function CicadaSubreddit($isDecipher=true, $isBook=true, $isTimestamp=true) {
$aReddit = json_decode(file_get_contents("a2e7j6ic78h0j.json")); //convert to PHP object
usort($aReddit, 'SortByDateCreated');
$line = 0;
foreach($aReddit as $post) {
if($isTimestamp) echo ''. date('Y-m-d H:i:s', $post->data->created) .': ';
if(!$post->data->is_self) {
//if not a self post, it must be a link
echo "data->url ."\">". $post->data->title ."
\n";
} else {
$text = trim($post->data->title);
if($isDecipher) {
//$aKey = a2e7j6ic78h0j7eiejd0120 = subreddit name converted to Vignere key
$aKey = array(10, 2, 14, 7, 19, 6, 18, 12, 7, 8, 17, 0, 19, 7, 14, 18, 14, 19, 13, 0, 1, 2, 0);
$iKey = 0; //index of current key
for($i = 0; $i < strlen($text); $i++) {
if(ctype_alpha($text[$i])) {
$key = $aKey[$iKey]; //Caesar shift for current letter
$iKey = ($iKey + 1) % count($aKey); //increment key
$base = ctype_lower($text[$i]) ? ord('a') : ord('A'); //convert [a,z] to [0,25]
$text[$i] = chr(((ord($text[$i]) - $base - $key + 26) % 26) + $base);
}
}
}
if($isBook) {
//$aBook = Cicada book code found in duck decoy image
$aBook = array(20, 3, 5, 20, 5, 53, 1, 8, 2, 4, 8, 4, 13, 4, 8, 4, 5, 14, 7, 31, 12, 36, 2, 3, 5, 65, 5, 1, 2, 18, 32, 10, 3, 25, 10, 7, 20, 10, 32, 4, 40, 11, 9, 13, 6, 3, 5, 43, 17, 13, 4, 2, 18, 4, 6, 4, 24, 64, 5, 37, 60, 12, 6, 8, 5, 18, 45, 10, 2, 17, 9, 20, 2, 34, 13, 21);
if($line < count($aBook)) {
$pos = $aBook[$line++] - 1;
$text = substr($text, 0, $pos) .''. $text[$pos] .''. substr($text, $pos+1);
}
}
echo $text ."
\n";
}
}
}
CicadaSubreddit();
?>