Example #1
0
function displayPostProd($uid, $pid, $pp)
{
    $rinfo = getRoundForPuzzle($pid);
    $urlprefix = POSTPROD_URLPREFIX;
    $beta_urlprefix = POSTPROD_BETA_URLPREFIX;
    $roundname = $rinfo['name'];
    $title = getTitle($pid);
    /*
    $showmeta = FALSE;
    if ($roundname == 'Metas') {
        $m = array();
        $regexp = '/^\s*\(([CS])-META\)\s*(.*)$/';
        if (preg_match($regexp, $title, $m)) {
            $roundname = $m[2];
            $title = ($m[1]=='C') ? "Investigator's Report" : "Meta";
            if ($m[1]=='S') { $showmeta = TRUE; }
        }
    }
    */
    $fileList = getFileListForPuzzle($pid, 'postprod');
    $file = $fileList[0];
    $url = $beta_urlprefix;
    //  $url .= "/" . postprodCanonRound($roundname);
    $url .= "puzzle/" . postprodCanon($title) . "/";
    if ($pp) {
        ?>
        <strong>Final Fact Check Beta Link: </strong>
        <a href="<?php 
        echo $url;
        ?>
">View postprod (as pushed from puzzletron)</a>.  <--  Use this to perform final fact check!  Username/password is jarthur/random17.  If it gives a 404, push the button below (which takes a minute).
        <br>
<?php 
        if ($pp) {
            ?>
        <form action="form-submit.php" method="post">
            <input type="hidden" name="pid" value="<?php 
            echo $pid;
            ?>
" />
            <input type="hidden" name="uid" value="<?php 
            echo $uid;
            ?>
" />
            <input type="submit" name="postprod" value="Push this puzzle to post-production">
        </form><br/>
<?php 
        }
        $url = $urlprefix;
        // $url .= "/" . postprodCanonRound($roundname);
        $url .= "/" . postprodCanon($title) . "/";
        ?>
    <strong>Actually Final Link: </strong>
    <a href="<?php 
        echo $url;
        ?>
">View postprod (version installed as final, doesn't work yet)</a>
    <br>
<?php 
    }
}
Example #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;
}
Example #3
0
function displayFileList($uid, $pid, $type)
{
    $fileList = getFileListForPuzzle($pid, $type);
    $first = TRUE;
    if (!$fileList) {
        $file['filename'] = '(none)';
        $file['date'] = NULL;
        $fileList[] = $file;
    }
    foreach ($fileList as $file) {
        $finfo = pathinfo($file['filename']);
        $filename = $finfo['basename'];
        if (strpos($file['filename'], 'http') !== false || !USING_AWS) {
            $link = $file['filename'];
        } else {
            if (strpos($file['filename'], '_dir', strlen($file['filename']) - 4) !== false) {
                $link = 'https://' . AWS_BUCKET . '.s3.amazonaws.com/list.html?prefix=' . $file['filename'];
            } else {
                $link = 'https://' . AWS_BUCKET . '.s3.amazonaws.com/' . $file['filename'];
            }
        }
        $date = $file['date'];
        if ($first) {
            $class = 'fileInfoLatest';
            ?>
            <tr>
                <td class='<?php 
            echo $class;
            ?>
'>
                <?php 
            echo "<strong>Latest {$type}:</strong>";
            ?>
                </td>
<?php 
        } else {
            $class = 'fileInfoOld';
            ?>
            <tr>
                <td class='<?php 
            echo $class;
            ?>
'>
                <?php 
            echo "Older {$type}:";
            ?>
                </td>
<?php 
        }
        ?>

<?php 
        if ($file['filename'] == '(none)') {
            ?>
                <td class='<?php 
            echo $class;
            ?>
' colspan='2'>
                    (none)
                </td>
<?php 
        } else {
            ?>
                <td class='<?php 
            echo $class;
            ?>
'>
                    <?php 
            echo "<a href='{$link}'/>{$filename}</a>";
            ?>
                </td>
                <td class='<?php 
            echo $class;
            ?>
'>
                    <?php 
            echo "{$date}";
            ?>
                </td>
<?php 
        }
        if ($first && !($type == 'draft' && !canAcceptDrafts($pid))) {
            ?>
                <td class='<?php 
            echo $class;
            ?>
'>
                    <a href="#" id="<?php 
            echo "upload{$type}" . "Link";
            ?>
">[Upload New]</a>
                </td>
            </tr>
            <tr id='<?php 
            echo "upload{$type}";
            ?>
'>
            <form enctype="multipart/form-data" method="post" action="form-submit.php">
                <input type="hidden" name="pid" value="<?php 
            echo $pid;
            ?>
" />
                <input type="hidden" name="filetype" value="<?php 
            echo $type;
            ?>
" />
                <input type="hidden" name="uid" value="<?php 
            echo $uid;
            ?>
" />

                <td class='<?php 
            echo $class;
            ?>
' colspan='3'>
                    <input type="file" name="fileupload" />
                    <input type="submit" name="uploadFile" value="Upload" />
                </td>
            </form>
            </tr>
<?php 
            if (isset($_SESSION['upload_error'])) {
                echo '<span class="error">' . $_SESSION['upload_error'] . '</span>';
                unset($_SESSION['upload_error']);
            }
        } else {
            ?>
            </tr>
<?php 
        }
        if ($first) {
            $first = FALSE;
        }
    }
}