diff options
Diffstat (limited to 'application')
-rw-r--r-- | application/controllers/file.php | 78 | ||||
-rw-r--r-- | application/controllers/user.php | 34 | ||||
-rwxr-xr-x | application/errors/error_general.php | 4 | ||||
-rw-r--r-- | application/models/mfile.php | 21 | ||||
-rw-r--r-- | application/views/file/footer.php | 3 | ||||
-rw-r--r-- | application/views/file/header.php | 28 | ||||
-rw-r--r-- | application/views/file/html_footer.php | 6 | ||||
-rw-r--r-- | application/views/file/html_header.php | 131 | ||||
-rw-r--r-- | application/views/file/upload_form.php | 131 | ||||
-rw-r--r-- | application/views/file/upload_history.php | 53 | ||||
-rw-r--r-- | application/views/footer.php | 8 | ||||
-rw-r--r-- | application/views/header.php | 51 | ||||
l--------- | application/views/user/footer.php | 1 | ||||
l--------- | application/views/user/header.php | 1 | ||||
-rw-r--r-- | application/views/user/invite.php | 44 | ||||
-rw-r--r-- | application/views/user/login.php | 8 | ||||
-rw-r--r-- | application/views/user/register.php | 4 |
17 files changed, 360 insertions, 246 deletions
diff --git a/application/controllers/file.php b/application/controllers/file.php index 2cf84016b..bd56c92df 100644 --- a/application/controllers/file.php +++ b/application/controllers/file.php @@ -173,49 +173,51 @@ class File extends CI_Controller { $this->data['current_highlight'] = htmlspecialchars($lexer); $this->data['timeout'] = $this->mfile->get_timeout_string($id); - - $this->load->view($this->var->view_dir.'/html_header', $this->data); + $this->data['lexers'] = $this->mfile->get_lexers(); + $this->data['filedata'] = $filedata; // highlight the file and chache the result $this->load->library("MemcacheLibrary"); if (! $cached = $this->memcachelibrary->get($filedata['hash'].'_'.$lexer)) { + $cached = array(); if ($lexer == "rmd") { ob_start(); echo '<table class="content"><tr>'; echo '<td class="markdownrender">'."\n"; - passthru('perl '.FCPATH.'scripts/Markdown.pl '.escapeshellarg($file), $return_value); + passthru('perl '.FCPATH.'scripts/Markdown.pl '.escapeshellarg($file), $cached["return_value"]); - $cached = ob_get_contents(); + $cached["output"] = ob_get_contents(); ob_end_clean(); } elseif ($lexer == "ascii") { ob_start(); echo '<table class="content"><tr>'; echo '<td class="code"><pre class="text">'."\n"; - passthru('perl '.FCPATH.'scripts/ansi2html '.escapeshellarg($file), $return_value); + passthru('perl '.FCPATH.'scripts/ansi2html '.escapeshellarg($file), $cached["return_value"]); echo "</pre>\n"; - $cached = ob_get_contents(); + $cached["output"] = ob_get_contents(); ob_end_clean(); } else { - $ret = $this->_pygmentize($file, $lexer); - $return_value = $ret["return_value"]; - $cached = $ret["output"]; + $cached = $this->_pygmentize($file, $lexer); } - if ($return_value != 0) { - $cached = "<div class=\"error\"><p>Error trying to process the file. - Either the lexer is unknown or something is broken. - Falling back to plain text.</p></div>\n"; + if ($cached["return_value"] != 0) { $ret = $this->_pygmentize($file, "text"); - $cached .= $ret["output"]; + $cached["output"] = $ret["output"]; } $this->memcachelibrary->set($filedata['hash'].'_'.$lexer, $cached, 100); } - $this->output->append_output($cached); + if ($cached["return_value"] != 0) { + $this->data["error_message"] = "<p>Error trying to process the file. + Either the lexer is unknown or something is broken. + Falling back to plain text.</p>"; + } + $this->load->view($this->var->view_dir.'/html_header', $this->data); + $this->output->append_output($cached["output"]); $this->load->view($this->var->view_dir.'/html_footer', $this->data); } @@ -228,7 +230,7 @@ class File extends CI_Controller { echo '<table class="content"><tr>'; echo '<td class="numbers"><pre>'; // generate line numbers (links) - passthru('perl -ne \'print "<a href=\"#n$.\" id=\"n$.\">$.</a>\n"\' '.escapeshellarg($file), $return_value); + passthru('perl -ne \'print "<a href=\"#n$.\" ><span class=\"anchor\" id=\"n$.\"> </span>$.</a>\n"\' '.escapeshellarg($file), $return_value); echo '</pre></td><td class="code">'."\n"; passthru('pygmentize -F codetagify -O encoding=guess,outencoding=utf8 -l '.escapeshellarg($lexer).' -f html '.escapeshellarg($file), $return_value); @@ -248,18 +250,18 @@ class File extends CI_Controller { $this->data["id"] = $id; $this->data['timeout'] = $this->mfile->get_timeout_string($id); - $this->load->view($this->var->view_dir.'/header', $this->data); + $this->load->view('header', $this->data); $this->load->view($this->var->view_dir.'/file_info', $this->data); - $this->load->view($this->var->view_dir.'/footer', $this->data); + $this->load->view('footer', $this->data); } function _non_existent() { $this->data["title"] .= " - Not Found"; $this->output->set_status_header(404); - $this->load->view($this->var->view_dir.'/header', $this->data); + $this->load->view('header', $this->data); $this->load->view($this->var->view_dir.'/non_existent', $this->data); - $this->load->view($this->var->view_dir.'/footer', $this->data); + $this->load->view('footer', $this->data); } function _show_url($id, $lexer) @@ -300,9 +302,9 @@ class File extends CI_Controller { if ($redirect) { redirect($this->data['url'], "location", 303); } else { - $this->load->view($this->var->view_dir.'/header', $this->data); + $this->load->view('header', $this->data); $this->load->view($this->var->view_dir.'/show_url', $this->data); - $this->load->view($this->var->view_dir.'/footer', $this->data); + $this->load->view('footer', $this->data); } } @@ -319,11 +321,11 @@ class File extends CI_Controller { $this->data['client_link_slackware'] = base_url().'data/client/slackware/'; if (!is_cli_client()) { - $this->load->view($this->var->view_dir.'/header', $this->data); + $this->load->view('header', $this->data); } $this->load->view($this->var->view_dir.'/client', $this->data); if (!is_cli_client()) { - $this->load->view($this->var->view_dir.'/footer', $this->data); + $this->load->view('footer', $this->data); } } @@ -337,12 +339,12 @@ class File extends CI_Controller { $this->data['username'] = $this->muser->get_username(); - $this->load->view($this->var->view_dir.'/header', $this->data); + $this->load->view('header', $this->data); $this->load->view($this->var->view_dir.'/upload_form', $this->data); if (is_cli_client()) { $this->client(); } - $this->load->view($this->var->view_dir.'/footer', $this->data); + $this->load->view('footer', $this->data); } // Allow CLI clients to query the server for the maxium filesize so they can @@ -415,9 +417,9 @@ class File extends CI_Controller { $this->data["total_size"] = format_bytes($total_size["sum"]); $cached = ""; - $cached .= $this->load->view($this->var->view_dir.'/header', $this->data, true); + $cached .= $this->load->view('header', $this->data, true); $cached .= $this->load->view($this->var->view_dir.'/upload_history', $this->data, true); - $cached .= $this->load->view($this->var->view_dir.'/footer', $this->data, true); + $cached .= $this->load->view('footer', $this->data, true); // disable for now. reenable if it causes too much load //$this->memcachelibrary->set('history_'.$this->var->view_dir."_".$user, $cached, 42); @@ -461,9 +463,9 @@ class File extends CI_Controller { $this->data["deleted_count"] = $deleted_count; $this->data["total_count"] = $total_count; - $this->load->view($this->var->view_dir.'/header', $this->data); + $this->load->view('header', $this->data); $this->load->view($this->var->view_dir.'/deleted', $this->data); - $this->load->view($this->var->view_dir.'/footer', $this->data); + $this->load->view('footer', $this->data); } function delete() @@ -501,17 +503,17 @@ class File extends CI_Controller { if(!$content) { $this->output->set_status_header(400); $this->data["msg"] = "Nothing was pasted, content is empty."; - $this->load->view($this->var->view_dir.'/header', $this->data); + $this->load->view('header', $this->data); $this->load->view($this->var->view_dir.'/upload_error', $this->data); - $this->load->view($this->var->view_dir.'/footer'); + $this->load->view('footer'); return; } if ($filesize > $this->config->item('upload_max_size')) { $this->output->set_status_header(413); - $this->load->view($this->var->view_dir.'/header', $this->data); + $this->load->view('header', $this->data); $this->load->view($this->var->view_dir.'/too_big'); - $this->load->view($this->var->view_dir.'/footer'); + $this->load->view('footer'); return; } @@ -548,18 +550,18 @@ class File extends CI_Controller { if (isset($_FILES["file"])) { $this->data["msg"] = $errors[$_FILES['file']['error']]; } - $this->load->view($this->var->view_dir.'/header', $this->data); + $this->load->view('header', $this->data); $this->load->view($this->var->view_dir.'/upload_error', $this->data); - $this->load->view($this->var->view_dir.'/footer'); + $this->load->view('footer'); return; } $filesize = filesize($_FILES['file']['tmp_name']); if ($filesize > $this->config->item('upload_max_size')) { $this->output->set_status_header(413); - $this->load->view($this->var->view_dir.'/header', $this->data); + $this->load->view('header', $this->data); $this->load->view($this->var->view_dir.'/too_big'); - $this->load->view($this->var->view_dir.'/footer'); + $this->load->view('footer'); return; } diff --git a/application/controllers/user.php b/application/controllers/user.php index ef79baa78..aa1ea235b 100644 --- a/application/controllers/user.php +++ b/application/controllers/user.php @@ -29,9 +29,9 @@ class User extends CI_Controller { { $this->data["username"] = $this->muser->get_username(); - $this->load->view($this->var->view_dir.'header', $this->data); + $this->load->view('header', $this->data); $this->load->view($this->var->view_dir.'index', $this->data); - $this->load->view($this->var->view_dir.'footer', $this->data); + $this->load->view('footer', $this->data); } function login() @@ -39,17 +39,17 @@ class User extends CI_Controller { $this->muser->require_session(); $this->session->keep_flashdata("uri"); - if ($this->input->post('process')) { + if ($this->input->post('process') !== false) { $username = $this->input->post('username'); $password = $this->input->post('password'); $result = $this->muser->login($username, $password); if ($result !== true) { - $data['login_error'] = true; - $this->load->view($this->var->view_dir.'header', $this->data); + $this->data['login_error'] = true; + $this->load->view('header', $this->data); $this->load->view($this->var->view_dir.'login', $this->data); - $this->load->view($this->var->view_dir.'footer', $this->data); + $this->load->view('footer', $this->data); } else { $uri = $this->session->flashdata("uri"); if ($uri) { @@ -59,9 +59,9 @@ class User extends CI_Controller { } } } else { - $this->load->view($this->var->view_dir.'header', $this->data); + $this->load->view('header', $this->data); $this->load->view($this->var->view_dir.'login', $this->data); - $this->load->view($this->var->view_dir.'footer', $this->data); + $this->load->view('footer', $this->data); } } @@ -100,16 +100,16 @@ class User extends CI_Controller { $userid = $this->muser->get_userid(); $query = $this->db->query(" - SELECT `key` + SELECT `key`, `date` FROM invitations WHERE user = ? ", array($userid))->result_array(); $this->data["query"] = $query; - $this->load->view($this->var->view_dir.'header', $this->data); + $this->load->view('header', $this->data); $this->load->view($this->var->view_dir.'invite', $this->data); - $this->load->view($this->var->view_dir.'footer', $this->data); + $this->load->view('footer', $this->data); } function register() @@ -172,9 +172,9 @@ class User extends CI_Controller { DELETE FROM invitations WHERE `key` = ? ", array($key)); - $this->load->view($this->var->view_dir.'header', $this->data); + $this->load->view('header', $this->data); $this->load->view($this->var->view_dir.'registered', $this->data); - $this->load->view($this->var->view_dir.'footer', $this->data); + $this->load->view('footer', $this->data); return; } else { $values["username"] = $username; @@ -186,9 +186,9 @@ class User extends CI_Controller { $this->data["values"] = $values; $this->data["error"] = $error; - $this->load->view($this->var->view_dir.'header', $this->data); + $this->load->view('header', $this->data); $this->load->view($this->var->view_dir.'register', $this->data); - $this->load->view($this->var->view_dir.'footer', $this->data); + $this->load->view('footer', $this->data); } function logout() @@ -213,9 +213,9 @@ class User extends CI_Controller { } } - $this->load->view($this->var->view_dir.'header', $this->data); + $this->load->view('header', $this->data); $this->load->view($this->var->view_dir.'hash_password', $this->data); - $this->load->view($this->var->view_dir.'footer', $this->data); + $this->load->view('footer', $this->data); } function cron() diff --git a/application/errors/error_general.php b/application/errors/error_general.php index ae2bac76d..1d33e8652 100755 --- a/application/errors/error_general.php +++ b/application/errors/error_general.php @@ -15,7 +15,7 @@ if (class_exists("CI_Controller") && !isset($GLOBALS["is_error_page"])) { exit(); } - include 'application/views/file/header.php'; + include 'application/views/header.php'; ?> <div class="error"> @@ -24,7 +24,7 @@ if (class_exists("CI_Controller") && !isset($GLOBALS["is_error_page"])) { </div> <?php - include 'application/views/file/footer.php'; + include 'application/views/footer.php'; } else { // default CI error page ?> diff --git a/application/models/mfile.php b/application/models/mfile.php index e298850a5..10daba3af 100644 --- a/application/models/mfile.php +++ b/application/models/mfile.php @@ -199,6 +199,27 @@ class Mfile extends CI_Model { return true; } + public function get_lexers() { + $this->load->library("MemcacheLibrary"); + if (! $lexers = $this->memcachelibrary->get('lexers')) { + $lexers = array(); + $last_desc = ""; + exec("python ".escapeshellarg(FCPATH."scripts/get_lexer_list.py"), $output); + + foreach ($output as $line) { + list($name, $desc) = explode("|", $line); + if ($desc == $last_desc) { + continue; + } + $last_desc = $desc; + $lexers[$name] = $desc; + } + $this->memcachelibrary->set('lexers', $lexers, 1800); + } + + return $lexers; + } + function should_highlight($type) { if ($this->mime2lexer($type)) return true; diff --git a/application/views/file/footer.php b/application/views/file/footer.php deleted file mode 100644 index eda863585..000000000 --- a/application/views/file/footer.php +++ /dev/null @@ -1,3 +0,0 @@ - </div> -</body> -</html> diff --git a/application/views/file/header.php b/application/views/file/header.php deleted file mode 100644 index 3029e4579..000000000 --- a/application/views/file/header.php +++ /dev/null @@ -1,28 +0,0 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> - -<head> - <title><?php echo isset($title) ? $title : ''; ?></title> - <link rel="stylesheet" type="text/css" href="<?php echo link_with_mtime("/data/default.css"); ?>" media="screen" /> - <meta http-equiv="Content-type" content="text/html; charset=utf-8" /> - <meta name="robots" content="noindex,nofollow" /> -</head> - -<body> - <div class="top"> - <?php echo anchor('file/index', 'New'); ?> | - <?php echo anchor('file/upload_history', 'History'); ?> | - <?php echo anchor('user/invite', 'Invite'); ?> - - <?php if(!isset($is_error_page)) { ?> - <div class="right"> - <?php if(isset($username) && $username) { ?> - <?=anchor("user/logout", "Logout"); ?> - <?php } else { ?> - <?=anchor("user/login", "Login"); ?> - <?php } ?> - </div> - <?php } ?> - </div> - - <div class="content"> diff --git a/application/views/file/html_footer.php b/application/views/file/html_footer.php index ddc460a39..a2a1cfec2 100644 --- a/application/views/file/html_footer.php +++ b/application/views/file/html_footer.php @@ -1,5 +1,7 @@ </td> </tr> </table> - </body> -</html> + </div> + </div> + +<?php include(FCPATH."application/views/footer.php"); diff --git a/application/views/file/html_header.php b/application/views/file/html_header.php index 60db38238..67e9d0cca 100644 --- a/application/views/file/html_header.php +++ b/application/views/file/html_header.php @@ -1,52 +1,85 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml"> - <head> - <title><?php echo $title; ?></title> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> - <link rel="stylesheet" type="text/css" href="<?php echo link_with_mtime("/data/paste.css"); ?>" /> -<?php if (file_exists(FCPATH."/data/paste-$current_highlight.css")) {?> - <link rel="stylesheet" type="text/css" href="<?php echo link_with_mtime("/data/paste-$current_highlight.css"); ?>" /> -<?php } ?> - </head> - <body> - <div class="top_bar"> - <a class="raw_link no" href="<?php echo site_url(); ?>">New</a> | - <a class="raw_link no" href="<?php echo site_url($id); ?>">Raw</a> | - <a class="raw_link no" href="<?php echo site_url($id."/plain"); ?>">Plain</a> | - <a class="raw_link no" href="<?php echo site_url($id."/info"); ?>">Info</a> | - Currently: <?php echo $current_highlight; ?> | - Timeout: <?php echo $timeout; ?> - <div style="float:right;"> - <a class="raw_link no" href="<?php echo site_url($id)."/"; ?>">Code</a> | - <a class="raw_link no" href="<?php echo site_url($id."/rmd"); ?>">Render Markdown</a> - </div> +<?php include(FCPATH."application/views/header.php"); ?> + </div> -<script type="text/javascript"> -/* <![CDATA[ */ -function update_anchor_highlight() { - var anchor = window.location.hash.substr(1); - var element = document.getElementById("highlight_line"); - if (element) { - element.parentNode.removeChild(element); - } - anchor = document.getElementById(anchor); - if (!anchor) { - return; - } - var newElement = document.createElement("div"); - newElement.setAttribute("id", "highlight_line"); - newElement.textContent=" "; - anchor.parentNode.insertBefore(newElement, anchor.nextSibling); -} + <script type="text/javascript"> + /* <![CDATA[ */ + window.lexers = <?php echo json_encode($lexers); ?>; + window.paste_base = '<?php echo site_url($id) ?>'; + /* ]]> */ + </script> + + <?php if (isset($error_message)) { ?> + <div class="alert alert-block alert-error" style="text-align: center"> + <?php echo $error_message; ?> + </div> + <?php } ?> -if ("onhashchange" in window) { - window.onload = function () { - update_anchor_highlight(); - } - window.onhashchange = function () { - update_anchor_highlight(); - } -} -/* ]]> */ -</script> + <div class="container" style="padding-top:40px;background:#eee;padding:3px;"> + <div style="border:1px solid #ccc;"> + <div class="navbar navbar-static-top"> + <div class="navbar-inner" style="box-shadow: none;"> + <ul class="nav"> + <li><a href="#file-info" class="brand" data-toggle="modal"><?php echo $title ?></a></li> + <li class="divider-vertical"></li> + <li class="dropdown"> + <a href="#" class="dropdown-toggle" data-toggle="dropdown" id="language-toggle"> + Language: <?php echo $current_highlight; ?> + <b class="caret"></b> + </a> + <div class="dropdown-menu" style="padding: 15px; padding-bottom: 0px;"> + <form> + <input type="text" id="language" placeholder="Language" class="input-medium"> + </form> + </div> + </li> + <li class="divider-vertical"></li> + <li> + <a href="#file-info" role="button" data-toggle="modal">Info</a> + <div id="file-info" class="modal hide fade"> + <div class="modal-header"> + <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button> + <h3>Paste Information</h3> + </div> + <div class="modal-body"> + <table class="table"> + <tr> + <td style="border:0;">Filename:</td> + <td style="border:0;"><?php echo htmlspecialchars($filedata["filename"]) ?></td> + </tr> + <tr> + <td>Size:</td> + <td><?php echo format_bytes($filedata["filesize"]) ?></td> + </tr> + <tr> + <td>Mimetype:</td> + <td><?php echo $filedata["mimetype"] ?></td> + </tr> + <tr> + <td>Uploaded:</td> + <td><?php echo date("r", $filedata["date"]) ?></td> + </tr> + <tr> + <td>Removal:</td> + <td><?php echo $timeout ?></td> + </tr> + </table> + </div> + <div class="modal-footer"> + <button class="btn" data-dismiss="modal" aria-hidden="true">Close</button> + </div> + </div> + </li> + </ul> + <div class="btn-group pull-right" style="margin-top: 7px; margin-right:-10px;"> + <a href="<?php echo site_url($id."/plain") ?>" class="btn btn-small" rel="tooltip" title="View as plain text">Plain</a> + <a href="<?php echo site_url($id) ?>" class="btn btn-small" rel="tooltip" title="View as raw file (org. mime type)">Raw</a> + <?php if ($current_highlight === 'rmd') { ?> + <a href="<?php echo site_url($id)."/" ?>" class="btn btn-small" rel="tooltip" title="Render as Code">Code</a> + <?php } else { ?> + <a href="<?php echo site_url($id."/rmd") ?>" class="btn btn-small" rel="tooltip" title="Render as Markdown">Markdown</a> + <?php } ?> + </div> + </div> + </div> + <div id="paste-container"> diff --git a/application/views/file/upload_form.php b/application/views/file/upload_form.php index 20fb1a3d8..d92cbfb5c 100644 --- a/application/views/file/upload_form.php +++ b/application/views/file/upload_form.php @@ -1,67 +1,72 @@ -<? if ($username) { ?> -<div class="center"> - <?php echo form_open_multipart('file/do_upload'); ?> - <p> - File: <input type="file" id="file" name="file" size="30" /> - <input type="submit" value="Upload" id="upload_button" name="process" /> - </p> - </form> - <p><b>OR</b></p> - <?php echo form_open_multipart('file/do_paste'); ?> - <p> - <textarea id="textarea" name="content" cols="80" rows="20"></textarea><br /> - <input type="submit" value="Paste" name="process" /> - </p> - </form> - <script type="text/javascript"> - /* <![CDATA[ */ - var max_upload_size = "<?php echo $max_upload_size; ?>"; - /* ]]> */ - </script> - <script type="text/javascript" src="<?php echo link_with_mtime("/data/js/upload_form.js"); ?>"></script> -</div> -<? } else { ?> -You have to <?=anchor("user/login", "log in"); ?> to be able to upload/paste. -<div id="login-form"> - <?=form_open("user/login"); ?> - <input type="text" name="username" /> - <input type="password" name="password" /> - <input type="submit" value="Login" name="process" /> - </form> +<?php if (isset($username) && $username) { ?> +<div class="well"> + <div class="row-fluid"> + <div class="span6"> + <div style="border-right:1px solid #ddd;padding-right:25px;"> + <?php echo form_open_multipart('file/do_paste'); ?> + <h2>Text paste</h2> + <textarea name="content" style="width:98%; height:300px;"></textarea> + <button type="submit" class="btn btn-primary">Paste it!</button> + </form> + </div> + </div> + <div class="span6"> + <?php echo form_open_multipart('file/do_upload'); ?> + <h2>File upload</h2> + <input id="file" type="file" name="file"><br> + <button type="submit" id="upload_button" class="btn btn-primary">Upload it!</button> + </form> + <div class="alert alert-block alert-info"> + <h4 class="alert-heading">Notice!</h4> + <p> + Uploads/pastes are deleted after <?php echo $upload_max_age; ?> days + <?php if($small_upload_size > 0) { + echo "unless they are smaller than ".format_bytes($small_upload_size); + } ?>. Maximum upload size is <?php echo format_bytes($max_upload_size); ?> + </p> + </div> + </div> + </div> </div> -<? } ?> -<br /> -<p>Uploads/pastes are deleted after <?php echo $upload_max_age; ?> days<?php if($small_upload_size > 0): ?> - unless they are smaller than <?php echo format_bytes($small_upload_size); ?> - <?php endif; ?>. Maximum upload size is <?php echo format_bytes($max_upload_size); ?></p> -<h2>Features</h2> -<p>For shell uploading/pasting and download information for the client go to <a href="<?php echo site_url("file/client"); ?>"><?php echo site_url("file/client"); ?></a></p> -<p>You can use the <?php echo anchor("file/upload_history", "history"); ?> to find old uploads.</p> -<p>How to link your pastes:</p> -<ul> - <li><span class="example">/<ID>/</span> automatically highlight the paste</li> - <li><span class="example">/<ID></span> set the detected MIME type and let the browser do the rest</li> - <li><span class="example">/<ID>/plain</span> force the MIME type to be text/plain</li> - <li><span class="example">/<ID>/<file extension></span> override auto detection and use the supplied file extension or language name for highlighting</li> - <li><span class="example">/<ID>/qr</span> display a qr code containing a link to <span class="example">/<ID>/</span></li> - <li><span class="example">/<ID>/rmd</span> convert markdown to HTML</li> - <li><span class="example">/<ID>/ascii</span> convert text with ANSI (shell) escape codes to HTML</li> - <li><span class="example">/<ID>/info</span> display some information about the ID</li> -</ul> -<p>If your upload is not detected as text, only -<span class="example">/<ID>/qr</span>, -<span class="example">/<ID>/plain</span> and -<span class="example">/<ID>/info</span> -will work as above and all others will simply return the file with the detected MIME type.</p> -<h2>Information</h2> -<p>This website's primary goal is aiding developers, power users, students and alike in solving problems, debugging software, sharing their configuration, etc. It is not intended to distribute confidential or harmful information, scripts or software.</p> - -<p>If you believe you deserve an account, ask someone who is already using this service to <?=anchor("user/invite", "invite"); ?> you.</p> +<script type="text/javascript"> + /* <![CDATA[ */ + var max_upload_size = "<?php echo $max_upload_size; ?>"; + /* ]]> */ +</script> +<script type="text/javascript" src="<?php echo link_with_mtime("/data/js/upload_form.js"); ?>"></script> -<?php if($contact_me_url) {?><p>If you experience any problems feel free to <a href="<?php echo $contact_me_url; ?>">contact me</a>.</p> -<br /><?php }; ?> -<div class="small"> - <p>Icons by <a href="http://p.yusukekamiyamane.com/">Yusuke Kamiyamane</a></p> - <p>This service is provided without warranty of any kind and may not be used to distribute copyrighted content.</p> +<?php } else { ?> + <?php echo form_open('user/login'); ?> + <input type="text" name="username" placeholder="Username" /> + <input type="password" name="password" placeholder="Password" /> + <input type="submit" class="btn btn-primary" value="Login" name="process" style="margin-bottom: 9px" /> + </form> +<?php } ?> +<div class="row"> + <div class="span6"> + <div class="page-header"><h1>Features</h1></div> + <p>For shell uploading/pasting and download information for the client go to <a href="<?php echo site_url("file/client"); ?>"><?php echo site_url("file/client"); ?></a></p> + <p>You can use the <?php echo anchor("file/upload_history", "history"); ?> to find old uploads.</p> + <h3>How to link your pastes:</h3> + <dl class="dl-horizontal"> + <dt>/<ID>/</dt><dd>automatically highlight the paste</dd> + <dt>/<ID></dt><dd>set the detected MIME type and let the browser do the rest</dd> + <dt>/<ID>/plain</dt><dd>force the MIME type to be text/plain</dd> + <dt>/<ID>/<file extension></dt><dd>override auto detection and use the supplied file extension or language name for highlighting</dd> + <dt>/<ID>/qr</dt><dd>display a qr code containing a link to <span class="example">/<ID>/</span></dd> + <dt>/<ID>/rmd</dt><dd>convert markdown to HTML</dd> + <dt>/<ID>/ascii</dt><dd>convert text with ANSI (shell) escape codes to HTML</dd> + <dt>/<ID>/info</dt><dd>display some information about the ID</dd> + </dl> + <p>If your upload is not detected as text, only <b>/<ID>/qr</b>, <b>/<ID>/plain</b> and <b>/<ID>/info</b> will work as above and all others will simply return the file with the detected MIME type.</p> + </div> + <div class="span6"> + <div class="page-header"><h1>Information</h1></div> + <p>This website's primary goal is aiding developers, power users, students and alike in solving problems, debugging software, sharing their configuration, etc. It is not intended to distribute confidential or harmful information, scripts or software.</p> + <p>If you believe you deserve an account, ask someone who is already using this service to <a href="http://test.paste.xinu.at/index.php/user/invite">invite</a> you.</p> + <?php if(isset($contact_me_url) && $contact_me_url) { ?> + <p>If you experience any problems feel free to <a href="<?php echo $contact_me_url; ?>">contact me</a>.</p> + <?php } ?> + </div> </div> diff --git a/application/views/file/upload_history.php b/application/views/file/upload_history.php index 41b055792..2f09240a1 100644 --- a/application/views/file/upload_history.php +++ b/application/views/file/upload_history.php @@ -1,28 +1,31 @@ -<?php echo form_open("file/do_delete"); ?> - <table class="results"> - <tr> - <th></th> - <th>ID</th> - <th>Filename</th> - <th>Mimetype - <th>Date</th> - <th>Hash</th> - <th>Size</th> - </tr> - - <?php foreach($query as $key => $item): ?> - <tr class="<?php echo even_odd(); ?>"> - <td><input type="checkbox" name="ids[<?php echo $item["id"]; ?>]" value="<?php echo $item["id"]; ?>" /></td> - <td><a href="<?php echo site_url("/".$item["id"]); ?>/"><?php echo $item["id"]; ?></a></td> - <td><?php echo htmlspecialchars($item["filename"]); ?></td> - <td><?php echo $item["mimetype"]; ?></td> - <td><?php echo $item["date"]; ?></td> - <td><?php echo $item["hash"]; ?></td> - <td><?php echo $item["filesize"]; ?></td> - </tr> - <?php endforeach; ?> - </table> - <input type="submit" value="Delete checked" name="process" /> +<?php echo form_open("file/do_delete") ?> + <table class="table table-striped"> + <thead> + <tr> + <th><input type="checkbox" name="all-ids" id="history-all"></th> + <th>ID</th> + <th>Filename</th> + <th>Mimetype + <th>Date</th> + <th>Hash</th> + <th>Size</th> + </tr> + </thead> + <tbody> + <?php foreach($query as $key => $item): ?> + <tr> + <td><input type="checkbox" name="ids[<?php echo $item["id"] ?>]" value="<?php echo $item["id"] ?>" class="delete-history"></td> + <td><a href="<?php echo site_url("/".$item["id"]) ?>/"><?php echo $item["id"] ?></a></td> + <td><?php echo htmlspecialchars($item["filename"]); ?></td> + <td><?php echo $item["mimetype"] ?></td> + <td><?php echo $item["date"] ?></td> + <td><?php echo $item["hash"] ?></td> + <td><?php echo $item["filesize"] ?></td> + </tr> + <?php endforeach; ?> + </tbody> + </table> + <input class="btn btn-danger" type="submit" value="Delete checked" name="process"> </form> <p>Total sum of your distinct uploads: <?php echo $total_size; ?>.</p> diff --git a/application/views/footer.php b/application/views/footer.php new file mode 100644 index 000000000..92b305999 --- /dev/null +++ b/application/views/footer.php @@ -0,0 +1,8 @@ + </div> + + <script src="<?php echo link_with_mtime("/data/js/jquery-1.8.2.min.js"); ?>"></script> + <script src="<?php echo link_with_mtime("/data/js/jquery-ui-1.8.23.custom.min.js"); ?>"></script> + <script src="<?php echo link_with_mtime("/data/js/bootstrap-2.1.1.min.js"); ?>"></script> + <script src="<?php echo link_with_mtime("/data/js/script.js"); ?>"></script> +</body> +</html> diff --git a/application/views/header.php b/application/views/header.php new file mode 100644 index 000000000..4f2c46e79 --- /dev/null +++ b/application/views/header.php @@ -0,0 +1,51 @@ +<!DOCTYPE html> +<html lang="en"> + +<head> + <meta charset="utf-8"> + <title><?php echo isset($title) ? $title : 'FileBin'; ?></title> + <meta name="robots" content="noindex,nofollow" /> + <meta name="description" content=""> + <meta name="author" content=""> + + <link href="<?php echo link_with_mtime("/data/css/ui-lightness/jquery-ui-1.8.23.custom.css"); ?>" rel="stylesheet"> + <link href="<?php echo link_with_mtime("/data/css/bootstrap-2.1.1.min.css"); ?>" rel="stylesheet"> + <link href="<?php echo link_with_mtime("/data/css/bootstrap-responsive-2.1.1.min.css"); ?>" rel="stylesheet"> + <link href="<?php echo link_with_mtime("/data/css/style.css"); ?>" rel="stylesheet"> +</head> + +<body> + <div class="navbar navbar-fixed-top navbar-inverse"> + <div class="navbar-inner"> + <div class="container"> + <a class="brand" href="<?php echo site_url(); ?>">FileBin</a> + <?php if(!isset($GLOBALS["is_error_page"])) { ?> + <ul class="nav pull-right"> + <?php if(isset($username) && $username) { ?> + <li><a href="<?php echo site_url("/user/logout"); ?>">Logout</a></li> + <?php } else { ?> + <li class="dropdown"> + <a class="dropdown-toggle" href="#" data-toggle="dropdown">Login <b class="caret"></b></a> + <div class="dropdown-menu" style="padding: 15px;"> + <?php echo form_open("user/login"); ?> + <input type="text" name="username" placeholder="Username" class="input-medium"> + <input type="password" name="password" placeholder="Password" class="input-medium"> + <button type="submit" name="process" class="btn btn-primary pull-right">Login</button> + </form> + </div> + </li> + <?php } ?> + </ul> + <?php }; ?> + <ul class="nav"> + <?php if(isset($username) && $username) { ?> + <li><a href="<?php echo site_url("file/index") ?>"><i class="icon-pencil icon-white"></i> New</a></li> + <li><a href="<?php echo site_url("file/upload_history") ?>"><i class="icon-book icon-white"></i> History</a></li> + <li><a href="<?php echo site_url("user/invite") ?>"><i class="icon-plus icon-white"></i> Invite</a></li> + <?php } ?> + </ul> + </div> + </div> + </div> + + <div class="container"> diff --git a/application/views/user/footer.php b/application/views/user/footer.php deleted file mode 120000 index e3a4d3fca..000000000 --- a/application/views/user/footer.php +++ /dev/null @@ -1 +0,0 @@ -../file/footer.php
\ No newline at end of file diff --git a/application/views/user/header.php b/application/views/user/header.php deleted file mode 120000 index 7b5e4d759..000000000 --- a/application/views/user/header.php +++ /dev/null @@ -1 +0,0 @@ -../file/header.php
\ No newline at end of file diff --git a/application/views/user/invite.php b/application/views/user/invite.php index 5be8b48a3..eba77ead0 100644 --- a/application/views/user/invite.php +++ b/application/views/user/invite.php @@ -1,15 +1,37 @@ -<?php echo form_open('user/create_invitation_key'); ?> - <input type="submit" value="Create new key" name="process" /> -</form> +<div class="alert alert-block"> + <p> + <b>Watch out!</b> + </p> + <p> + You are free to invite anyone you want to, but please keep in + mind that if this person violates the rules and is banned, your + account will also be disabled. + </p> +</div> -<p> -You are free to invite anyone you want to, but please keep in -mind that if this person violates the rules and is banned, your account will also be disabled. -</p> +<h2>Unused invitation keys</h2> +<table class="table table-striped"> + <thead> + <tr> + <th>#</th> + <th style="width: 70%;">Key</th> + <th>Created on</th> + </tr> + </thead> + <tbody> + <?php $i = 1; ?> + <?php foreach($query as $key => $item): ?> + <tr> + <td><?php echo $i++; ?></td> + <td><?php echo anchor("user/register/".$item["key"], $item["key"]) ?></td> + <td><?php echo date("Y/m/d H:i", $item["date"]) ?></td> + </tr> + <?php endforeach; ?> + </tbody> +</table> -<p>Unused invitation keys:</p> <p> -<?php foreach($query as $key => $item): ?> - <?php echo anchor("user/register/".$item["key"], $item["key"]); ?><br /> -<?php endforeach; ?> + <?php echo form_open('user/create_invitation_key'); ?> + <input class="btn btn-primary btn-large" type="submit" value="Create a new key" name="process" /> + </form> </p> diff --git a/application/views/user/login.php b/application/views/user/login.php index ca6f01b88..21264a404 100644 --- a/application/views/user/login.php +++ b/application/views/user/login.php @@ -1,7 +1,7 @@ <?php -if (isset($login_error)) { - echo '<font style="color: rgb(238, 51, 51);">The entered credentials are invalid.</font>'; -} ?> +if (isset($login_error)) { ?> + <div class="alert alert-error">The entered credentials are invalid.</div> +<?php } ?> <?php echo form_open('user/login'); ?> <table> @@ -14,5 +14,5 @@ if (isset($login_error)) { <td><input type="password" name="password" /></td> </tr> </table> - <input type="submit" value="Login" name="process" /> + <input type="submit" class="btn btn-primary" value="Login" name="process" /> </form> diff --git a/application/views/user/register.php b/application/views/user/register.php index 78af46e96..2b15175a3 100644 --- a/application/views/user/register.php +++ b/application/views/user/register.php @@ -7,10 +7,10 @@ <table> <tr> <td>Username</td> - <td> <input type="text" name="username" value="<?=$values["username"]; ?>" /></td> + <td> <input type="text" name="username" value="<?php echo $values["username"]; ?>" /></td> </tr><tr> <td>Email</td> - <td> <input type="text" name="email" value="<?=$values["email"]; ?>" /></td> + <td> <input type="text" name="email" value="<?php echo $values["email"]; ?>" /></td> </tr><tr> <td>Password</td> <td> <input type="password" name="password" /></td> |