Example #1
0
function getCode($code_id, $revision, $testonly = false)
{
    $sql = sprintf('select * from sandbox where url="%s" and revision="%s"', mysql_real_escape_string($code_id), mysql_real_escape_string($revision));
    $result = mysql_query($sql);
    if (!mysql_num_rows($result) && $testonly == false) {
        header("HTTP/1.0 404 Not Found");
        return defaultCode(true);
    } else {
        if (!mysql_num_rows($result)) {
            return array($revision);
        } else {
            $row = mysql_fetch_object($result);
            // TODO required anymore? used for auto deletion
            $sql = 'update sandbox set last_viewed=now() where id=' . $row->id;
            mysql_query($sql);
            $javascript = preg_replace('/\\r/', '', $row->javascript);
            $html = preg_replace('/\\r/', '', $row->html);
            $revision = $row->revision;
            // return array(preg_replace('/\r/', '', $html), preg_replace('/\r/', '', $javascript), $row->streaming, $row->active_tab, $row->active_cursor);
            return array($revision, get_magic_quotes_gpc() ? stripslashes($html) : $html, get_magic_quotes_gpc() ? stripslashes($javascript) : $javascript, $row->streaming, $row->active_tab, $row->active_cursor);
        }
    }
}
Example #2
0
<?php

include 'app.php';
list($code, $revision) = getCodeIdParams($request);
$edit_mode = false;
if ($code_id) {
    list($latest_revision, $html, $javascript, $css) = getCode($code_id, $revision, true);
} else {
    list($latest_revision, $html, $javascript, $css) = defaultCode();
}
$code_id = $code;
// always include revision *if* we have a code_id
if ($code_id && $revision) {
    $code_id .= '/' . $revision;
}
$code_id_path = ROOT;
if ($code_id) {
    $code_id_path = ROOT . '/' . $code_id;
}
// Include and capture the results of the show saved function.
ob_start();
showSaved($home);
$list_history = ob_get_clean();
$code_id_domain = preg_replace('/https?:\\/\\//', '', $code_id_path);
$gravatar = '';
if ($email) {
    $gravatar = 'http://www.gravatar.com/avatar/' . md5(strtolower(trim($email))) . '?s=26';
}
$scripts = array();
if (!IS_PRODUCTION) {
    $scripts = json_decode(file_get_contents('../scripts.json'));
Example #3
0
    }
    $diff = round($diff / 24);
    if ($diff < 7) {
        return $diff . " day" . plural($diff) . " ago";
    }
    $diff = round($diff / 7);
    if ($diff < 4) {
        return $diff . " week" . plural($diff) . " ago";
    }
    if (date('Y', $time) != date('Y', time())) {
        return date("j-M Y", $time);
    }
    return date("j-M", $time);
}
$last = null;
list($dummy, $defhtml, $defjs, $defcss) = defaultCode();
$formatted = array();
arsort($order);
foreach ($order as $key => $value) {
    $template_bin = array();
    foreach ($bins[$key] as $bin) {
        $url = formatURL($bin['url'], $bin['revision']);
        $title = getTitleFromCode($bin);
        $firstTime = $bin['url'] != $last;
        // attempt to get the modified panels - note that this won't detect
        // if they're using their own template
        $args = array('?live');
        $js = trim($bin['javascript']);
        $html = trim($bin['html']);
        $css = trim($bin['css']);
        if ($js && $js !== $defjs) {