Exemplo n.º 1
0
<?php

// vim:set ts=4 sw=4 sts=4 et:
require_once "config.php";
require_once "html.php";
require_once "db-func.php";
require_once "utils.php";
// Redirect to the login page, if not logged in
$uid = isLoggedIn();
header("Content-type: text/json");
$puzzles = getPuzzlesInPostprodAndLater($uid);
$exportdata = array();
foreach ($puzzles as $pid) {
    # pid, status, title, slug, round name, round slug.
    $status = getStatusNameForPuzzle($pid);
    $title = getTitle($pid);
    $titleslug = postprodCanon($title);
    $rinfo = getRoundForPuzzle($pid);
    $answer = getAnswersForPuzzleAsList($pid);
    if ($rinfo) {
        $roundname = $rinfo['name'];
        $roundslug = postprodCanonRound($roundname);
        $exportdata[] = array('url' => "/{$roundslug}/{$titleslug}/", 'pid' => $pid, 'status' => $status, 'title' => $title, 'titleslug' => $titleslug, 'round' => $roundname, 'roundslug' => $roundslug, 'answer' => $answer);
    }
}
print json_encode($exportdata) . "\n";
Exemplo n.º 2
0
function pushToPostProdHelper($uid, $pid, &$output)
{
    $round_rows = getRoundDictForPuzzle($pid);
    $rinfo = $round_rows[0];
    $answer_dict = getAnswersAndDeepForPuzzle($pid);
    $aid = $answer_dict['aid'];
    $deep = $answer_dict['deep'];
    $answer = $answer_dict['answer'];
    #$runscript = "/usr/bin/env | grep ^CATTLEPROD";
    #$runscript = "/srv/veil/venv/bin/cattleprod 2>&1";
    #  $runscript = "/nfs/sages/deploy/mh2013/present/bin/cattleprod 2>&1";
    $runscript = "/home/puzzletron/cattleprod.py 2>&1";
    $roundname = $rinfo['name'];
    $roundslug = postprodCanonRound($roundname);
    $title = getTitle($pid);
    $titleslug = postprodCanon($title);
    $fileList = getFileListForPuzzle($pid, 'postprod');
    $file = $fileList[0];
    $credits = getCreditsWithDefault($pid);
    $filename = $file['filename'];
    if (empty($filename)) {
        return "Nothing in the postproduction slot of this puzzle: Nothing to push!";
    }
    $username = getUserUsername($uid);
    # ???
    putenv("CATTLEPROD_PUZZLE_SLUG=" . $titleslug);
    putenv("CATTLEPROD_ROUND_SLUG=" . $roundslug);
    putenv("CATTLEPROD_ROUND_NAME=" . $roundname);
    putenv("CATTLEPROD_TITLE=" . $title);
    putenv("CATTLEPROD_MEDIA=" . "{$filename}");
    putenv("CATTLEPROD_ANSWER_ID=" . $aid);
    putenv("CATTLEPROD_PUZZLE_ID=" . $pid);
    putenv("CATTLEPROD_ANSWER=" . $answer);
    putenv("CATTLEPROD_DEEP=" . $deep);
    putenv("CATTLEPROD_CREDITS=" . $credits);
    putenv("CATTLEPROD_PUSHER=" . $username);
    #  putenv("CATTLEPROD_ASSET_PATH=/nfs/enigma/mh2013/chazelle/assets");
    exec($runscript, $output, $exit_status);
    $output = implode("\n", $output);
    return $exit_status;
}