コード例 #1
0
ファイル: crontest.php プロジェクト: rw251/crossword
 } else {
     if ($last > $id) {
         //ERROR
         //email last > today
         mg_send($email, 'Cron Job Running', 'LAST: ' . $last . ' is greater than TODAY:' . $id);
         return;
     } else {
         if ($last == $id) {
             return;
         }
     }
 }
 echo $last . "</br>";
 echo $id . "</br>";
 for ($i = $last + 1; $i <= $id; $i++) {
     $output = getCrossword($type, $i, false);
     ///- If fewer than 10 clues then something is amiss
     if (sizeof($output['clues']) < 10) {
         mg_send($email, 'Cron Job Running', 'Crossword has ' . sizeof($output['clues']) . ' clues - something is wrong');
         return;
     } else {
         //Save file
         file_put_contents('../../public_html/cword/data/' . $i . '.json', json_encode($output));
         if ($i == $id) {
             file_put_contents('../../public_html/cword/today.json', json_encode($output));
             chmod('../../public_html/cword/today.json', 0755);
         }
         //update last
         file_put_contents('../../public_html/cword/last', $i);
         echo $i . "</br>";
         chmod('../../public_html/cword/data/' . $i . '.json', 0755);
コード例 #2
0
ファイル: get-cword-test.php プロジェクト: rw251/crossword
include '../../cron/cword/get-cword.php';
try {
    $type = "cryptic";
    if (isset($_GET['type'])) {
        if ($_GET['type'] == "prize") {
            $type = "prize";
        }
    }
    $id = getLatest($type);
    echo "Call this page with ?id=xxx&type=prize/cryptic&debug=true<br><br>";
    echo "Type: {$type}<br>";
    echo "Latest {$type} crossword: {$id}<br>";
    echo "Last loaded:" . file_get_contents("../../public_html/cword/last") . "<br>";
    if (isset($_GET['id'])) {
        $id = $_GET['id'];
    }
    $debug = true;
    if (isset($_GET['debug'])) {
        $debug = $_GET['debug'] == "true";
    }
    echo "Crossword number: {$id}<br>";
    echo "Debug: " . ($debug ? "true" : "false") . "<br>";
    $clues = getCrossword($type, $id, $debug);
    echo '<pre>';
    print_r($clues);
    echo '</pre>';
} catch (Exception $e) {
    echo 'Caught exception: ' . $e->getMessage();
}
?>