예제 #1
0
파일: app.php 프로젝트: pkdevbox/jsbin
             $edit_mode = false;
             if ($revision == 1) {
                 header('Location: ' . ROOT . $code_id . '/edit');
             } else {
                 header('Location: ' . ROOT . $code_id . '/' . $revision . '/edit');
             }
         }
     }
 } else {
     if ($action) {
         // this should be an id
         $subaction = array_pop($request);
         if ($action == 'latest') {
             // find the latest revision and redirect to that.
             $code_id = $subaction;
             $latest_revision = getMaxRevision($code_id);
             // header('Location: /' . $code_id . '/' . $latest_revision);
             $edit_mode = false;
         } else {
             if ($subaction != 'gist') {
                 if ($subaction && is_numeric($action)) {
                     $code_id = $subaction;
                     $revision = $action;
                 } else {
                     $code_id = $action;
                     $revision = 1;
                 }
                 list($latest_revision, $html, $javascript) = getCode($code_id, $revision);
                 list($html, $javascript) = formatCompletedCode($html, $javascript, $code_id, $revision);
                 global $quiet;
                 // using new str_lreplace to ensure only the *last* </body> is replaced.
예제 #2
0
파일: app.php 프로젝트: nbprithv/jsbin
     header('Location: /' . $code_id . '/' . $latest_revision);
     $edit_mode = false;
 } else {
     if ($subaction != 'gist') {
         $download = false;
         if ($action === 'download') {
             $download = true;
             $action = $subaction;
             $subaction = array_pop($request);
         }
         if ($subaction && is_numeric($action)) {
             $code_id = $subaction;
             $revision = $action;
         } else {
             $code_id = $action;
             $revision = getMaxRevision($code_id);
         }
         list($latest_revision, $html, $javascript, $css) = getCode($code_id, $revision);
         list($html, $javascript, $css) = formatCompletedCode($html, $javascript, $css, $code_id, $revision);
         global $quiet;
         if ($download) {
             $ext = $html ? 'html' : 'js';
             $filename = implode(array('jsbin', $code_id, $revision, $ext), '.');
             header('Content-Disposition: attachment; filename="' . $filename . '"');
         }
         // using new str_lreplace to ensure only the *last* </body> is replaced.
         // FIXME there's still a bug here if </body> appears in the script and not in the
         // markup - but I'll fix that later
         if (!$quiet && !$download) {
             $html = str_lreplace('</body>', '<script src="' . ROOT . '/js/render/edit.js"></script>' . "\n</body>", $html);
         }