From de02b8cb514a95c100d0ec11ab469acfc687ca00 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 22 Oct 2012 15:42:07 +0200 Subject: switch design to bootstrap; minor fixes along the way Initial-work-by: Oliver Mader Additional-work-by: Markus Cisler Signed-off-by: Florian Pritz --- application/controllers/file.php | 78 +++++++++--------- application/controllers/user.php | 34 ++++---- application/errors/error_general.php | 4 +- application/models/mfile.php | 21 +++++ application/views/file/footer.php | 3 - application/views/file/header.php | 28 ------- application/views/file/html_footer.php | 6 +- application/views/file/html_header.php | 131 +++++++++++++++++++----------- application/views/file/upload_form.php | 131 ++++++++++++++++-------------- application/views/file/upload_history.php | 53 ++++++------ application/views/footer.php | 8 ++ application/views/header.php | 51 ++++++++++++ application/views/user/footer.php | 1 - application/views/user/header.php | 1 - application/views/user/invite.php | 44 +++++++--- application/views/user/login.php | 8 +- application/views/user/register.php | 4 +- 17 files changed, 360 insertions(+), 246 deletions(-) delete mode 100644 application/views/file/footer.php delete mode 100644 application/views/file/header.php create mode 100644 application/views/footer.php create mode 100644 application/views/header.php delete mode 120000 application/views/user/footer.php delete mode 120000 application/views/user/header.php (limited to 'application') 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 ''; echo '
'."\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 ''; echo '
'."\n";
-				passthru('perl '.FCPATH.'scripts/ansi2html '.escapeshellarg($file), $return_value);
+				passthru('perl '.FCPATH.'scripts/ansi2html '.escapeshellarg($file), $cached["return_value"]);
 				echo "
\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 = "

Error trying to process the file. - Either the lexer is unknown or something is broken. - Falling back to plain text.

\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"] = "

Error trying to process the file. + Either the lexer is unknown or something is broken. + Falling back to plain text.

"; + } + $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 ''; echo '
';
 		// generate line numbers (links)
-		passthru('perl -ne \'print "$.\n"\' '.escapeshellarg($file), $return_value);
+		passthru('perl -ne \'print " $.\n"\' '.escapeshellarg($file), $return_value);
 		echo '
'."\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'; ?>
@@ -24,7 +24,7 @@ if (class_exists("CI_Controller") && !isset($GLOBALS["is_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 @@ - - - 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 @@ - - - - - <?php echo isset($title) ? $title : ''; ?> - " media="screen" /> - - - - - -
- | - | - - - -
- - - - - -
- -
- -
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 @@
- - + + + + - - - <?php echo $title; ?> - - " /> - - " /> - - - -
- New | - Raw | - ">Plain | - ">Info | - Currently: | - Timeout: - + +
- + + +
+ +
+ -if ("onhashchange" in window) { - window.onload = function () { - update_anchor_highlight(); - } - window.onhashchange = function () { - update_anchor_highlight(); - } -} -/* ]]> */ - +
+
+ +
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 @@ - -
- -

- File: - -

- -

OR

- -

-
- -

- - - -
- -You have to to be able to upload/paste. -
- - - - - + +
+
+
+
+ +

Text paste

+ + + +
+
+
+ +

File upload

+
+ + +
+

Notice!

+

+ Uploads/pastes are deleted after days + 0) { + echo "unless they are smaller than ".format_bytes($small_upload_size); + } ?>. Maximum upload size is +

+
+
+
- -
-

Uploads/pastes are deleted after days 0): ?> - unless they are smaller than - . Maximum upload size is

-

Features

-

For shell uploading/pasting and download information for the client go to ">

-

You can use the to find old uploads.

-

How to link your pastes:

-
    -
  • /<ID>/ automatically highlight the paste
  • -
  • /<ID> set the detected MIME type and let the browser do the rest
  • -
  • /<ID>/plain force the MIME type to be text/plain
  • -
  • /<ID>/<file extension> override auto detection and use the supplied file extension or language name for highlighting
  • -
  • /<ID>/qr display a qr code containing a link to /<ID>/
  • -
  • /<ID>/rmd convert markdown to HTML
  • -
  • /<ID>/ascii convert text with ANSI (shell) escape codes to HTML
  • -
  • /<ID>/info display some information about the ID
  • -
-

If your upload is not detected as text, only -/<ID>/qr, -/<ID>/plain and -/<ID>/info -will work as above and all others will simply return the file with the detected MIME type.

-

Information

-

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.

- -

If you believe you deserve an account, ask someone who is already using this service to you.

+ + -

If you experience any problems feel free to contact me.

-
-
-

Icons by Yusuke Kamiyamane

-

This service is provided without warranty of any kind and may not be used to distribute copyrighted content.

+ + + + + + + +
+
+ +

For shell uploading/pasting and download information for the client go to ">

+

You can use the to find old uploads.

+

How to link your pastes:

+
+
/<ID>/
automatically highlight the paste
+
/<ID>
set the detected MIME type and let the browser do the rest
+
/<ID>/plain
force the MIME type to be text/plain
+
/<ID>/<file extension>
override auto detection and use the supplied file extension or language name for highlighting
+
/<ID>/qr
display a qr code containing a link to /<ID>/
+
/<ID>/rmd
convert markdown to HTML
+
/<ID>/ascii
convert text with ANSI (shell) escape codes to HTML
+
/<ID>/info
display some information about the ID
+
+

If your upload is not detected as text, only /<ID>/qr, /<ID>/plain and /<ID>/info will work as above and all others will simply return the file with the detected MIME type.

+
+
+ +

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.

+

If you believe you deserve an account, ask someone who is already using this service to invite you.

+ +

If you experience any problems feel free to contact me.

+ +
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 @@ - - - - - - - - - - - - $item): ?> - - - - - - - - - - -
IDFilenameMimetype - DateHashSize
]" value="" />/">
- + + + + + + + + + + + + + + $item): ?> + + + + + + + + + + + +
IDFilenameMimetype + DateHashSize
]" value="" class="delete-history">/">
+

Total sum of your distinct uploads: .

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 @@ +
+ + + + + + + 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 @@ + + + + + + <?php echo isset($title) ? $title : 'FileBin'; ?> + + + + + " rel="stylesheet"> + " rel="stylesheet"> + " rel="stylesheet"> + " rel="stylesheet"> + + + + + +
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 @@ - - - +
+

+ Watch out! +

+

+ 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. +

+
-

-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. -

+

Unused invitation keys

+ + + + + + + + + + + $item): ?> + + + + + + + +
#KeyCreated on
-

Unused invitation keys:

- $item): ?> -
- + + +

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 @@ The entered credentials are invalid.'; -} ?> +if (isset($login_error)) { ?> +
The entered credentials are invalid.
+ @@ -14,5 +14,5 @@ if (isset($login_error)) {
- + 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 @@ - + - + -- cgit v1.2.3-24-g4f1b
Username " /> " />
Email " /> " />
Password