summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Pritz <bluewind@xssn.at>2010-02-07 17:57:47 +0100
committerFlorian Pritz <bluewind@xssn.at>2010-02-07 17:57:47 +0100
commit5cb8dbec56fae74dd9d5ae30ed06464135b600f3 (patch)
tree84857b24f2d7c77187b0623d032962b9a6c797dc
parented37021577c01f14f3f4d6f3b5da18f6b56d5be4 (diff)
fix indenting
Signed-off-by: Florian Pritz <bluewind@xssn.at>
-rw-r--r--system/application/controllers/file.php10
-rw-r--r--system/application/models/file_mod.php280
2 files changed, 145 insertions, 145 deletions
diff --git a/system/application/controllers/file.php b/system/application/controllers/file.php
index fb114ee7b..6be3cf1c9 100644
--- a/system/application/controllers/file.php
+++ b/system/application/controllers/file.php
@@ -164,19 +164,19 @@ class File extends Controller {
header('Etag: "'.$etag.'"');
} else {
if ($mode
- && $this->file_mod->mime2extension($type)
- && filesize($file) <= $this->config->item('upload_max_text_size')
- ) {
+ && $this->file_mod->mime2extension($type)
+ && filesize($file) <= $this->config->item('upload_max_text_size')
+ ) {
header("Content-Type: text/html\n");
// TODO: move to own file
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'
.'<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"'
.' <head><title>'.$filedata['filename'].'</title>'
- .' <link rel="stylesheet" type="text/css" href="'.base_url().'data/paste.css" />'
+ .' <link rel="stylesheet" type="text/css" href="'.base_url().'data/paste.css" />'
.' </head>'
.'<body>'
.' <div class="top_bar">'
- .' <a class="raw_link no" href="'.site_url($this->config->item('paste_download_url').$id).'">Raw</a>'
+ .' <a class="raw_link no" href="'.site_url($this->config->item('paste_download_url').$id).'">Raw</a>'
.' </div'
.' <table class="content">'
.' <tr><td class="numbers"><pre>';
diff --git a/system/application/models/file_mod.php b/system/application/models/file_mod.php
index 445ccdce4..5e31784b2 100644
--- a/system/application/models/file_mod.php
+++ b/system/application/models/file_mod.php
@@ -9,159 +9,159 @@
class File_mod extends Model {
- function __construct()
- {
- parent::Model();
+ function __construct()
+ {
+ parent::Model();
+ }
+
+ function new_id()
+ {
+ $id = $this->random_id(3,6);
+
+ if ($this->id_exists($id)) {
+ return $this->new_id();
+ } else {
+ return $id;
}
-
- function new_id()
- {
- $id = $this->random_id(3,6);
-
- if ($this->id_exists($id)) {
- return $this->new_id();
- } else {
- return $id;
- }
+ }
+
+ function id_exists($id)
+ {
+ $sql = '
+ SELECT id
+ FROM `files`
+ WHERE `id` = ?';
+ $query = $this->db->query($sql, array($id));
+
+ if ($query->num_rows() == 1) {
+ return true;
+ } else {
+ return false;
}
-
- function id_exists($id)
- {
- $sql = '
- SELECT id
- FROM `files`
- WHERE `id` = ?';
- $query = $this->db->query($sql, array($id));
-
- if ($query->num_rows() == 1) {
- return true;
- } else {
- return false;
- }
+ }
+
+ function get_filedata($id)
+ {
+ $sql = '
+ SELECT hash,filename
+ FROM `files`
+ WHERE `id` = ?';
+ $query = $this->db->query($sql, array($id));
+
+ if ($query->num_rows() == 1) {
+ $return = $query->result_array();
+ return $return[0];
+ } else {
+ return false;
}
+ }
- function get_filedata($id)
- {
- $sql = '
- SELECT hash,filename
- FROM `files`
- WHERE `id` = ?';
- $query = $this->db->query($sql, array($id));
-
- if ($query->num_rows() == 1) {
- $return = $query->result_array();
- return $return[0];
- } else {
- return false;
- }
- }
+ function folder($hash) {
+ return $this->config->item('upload_path').'/'.substr($hash, 0, 3);
+ }
- function folder($hash) {
- return $this->config->item('upload_path').'/'.substr($hash, 0, 3);
- }
+ function file($hash) {
+ return $this->folder($hash).'/'.$hash;
+ }
- function file($hash) {
- return $this->folder($hash).'/'.$hash;
- }
-
- function hash_password($password)
- {
+ function hash_password($password)
+ {
// TODO: move salt to config
- return sha1('w9yFMeU6ITrkrPBlRJfA'.$password);
- }
-
- private function unused_file($hash)
- {
- $sql = '
- SELECT id
- FROM `files`
- WHERE `hash` = ?';
- $query = $this->db->query($sql, array($hash));
-
- if ($query->num_rows() == 0) {
- return true;
- } else {
- return false;
- }
+ return sha1('w9yFMeU6ITrkrPBlRJfA'.$password);
+ }
+
+ private function unused_file($hash)
+ {
+ $sql = '
+ SELECT id
+ FROM `files`
+ WHERE `hash` = ?';
+ $query = $this->db->query($sql, array($hash));
+
+ if ($query->num_rows() == 0) {
+ return true;
+ } else {
+ return false;
}
-
- function delete_id($id, $password)
- {
- $filedata = $this->get_filedata($id);
- $password = $this->hash_password($password);
-
- $sql = '
- DELETE
- FROM `files`
- WHERE `id` = ?
- AND password = ?
- LIMIT 1';
- $query = $this->db->query($sql, array($id, $password));
-
- if($this->unused_file($filedata['hash'])) {
- unlink($this->file(substr($filedata['hash'])));
- // TODO: remove empty folders
- }
+ }
+
+ function delete_id($id, $password)
+ {
+ $filedata = $this->get_filedata($id);
+ $password = $this->hash_password($password);
+
+ $sql = '
+ DELETE
+ FROM `files`
+ WHERE `id` = ?
+ AND password = ?
+ LIMIT 1';
+ $query = $this->db->query($sql, array($id, $password));
+
+ if($this->unused_file($filedata['hash'])) {
+ unlink($this->file(substr($filedata['hash'])));
+ // TODO: remove empty folders
}
-
- private function random_id($min_length, $max_length)
- {
- $random = '';
- $char_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
- $char_list .= "abcdefghijklmnopqrstuvwxyz";
- $char_list .= "1234567890";
-
- for($i = 0; $i < $max_length; $i++) {
- if (strlen($random) >= $min_length) {
- if (rand()%2 == 1) {
- break;
- }
+ }
+
+ private function random_id($min_length, $max_length)
+ {
+ $random = '';
+ $char_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
+ $char_list .= "abcdefghijklmnopqrstuvwxyz";
+ $char_list .= "1234567890";
+
+ for($i = 0; $i < $max_length; $i++) {
+ if (strlen($random) >= $min_length) {
+ if (rand()%2 == 1) {
+ break;
}
- $random .= substr($char_list,(rand()%(strlen($char_list))), 1);
}
- return $random;
+ $random .= substr($char_list,(rand()%(strlen($char_list))), 1);
}
+ return $random;
+ }
+
+ function mime2extension($type)
+ {
+ $typearray = array(
+ 'text/plain' => 'txt',
+ 'text/x-python' => 'py',
+ 'text/x-csrc' => 'c',
+ 'text/x-chdr' => 'h',
+ 'text/x-c++hdr' => 'h',
+ 'text/x-c++src' => 'cpp',
+ 'text/x-patch' => 'diff',
+ 'text/x-lua' => 'lua',
+ 'text/x-haskell' => 'hs',
+ 'text/x-literate-haskell' => 'hs',
+ 'text/x-subviewer' => 'sh',
+ #'text/x-makefile' => 'make',
+ #'text/x-log' => 'log',
+ 'text/html' => 'html',
+ 'text/css' => 'css',
+ #'image/svg+xml' => 'xml',
+ 'application/x-perl' => 'pl',
+ 'application/xml' => 'xml',
+ 'application/javascript' => 'js',
+ 'application/x-desktop' => 'txt',
+ 'application/x-m4' => 'txt',
+ 'application/x-awk' => 'awk',
+ 'application/x-java' => 'java',
+ 'application/x-php' => 'php',
+ 'application/x-ruby' => 'rb',
+ 'application/x-shellscript' => 'sh',
+ 'application/x-x509-ca-cert' => 'txt',
+ 'application/mbox' => 'txt'
+ );
+ if (array_key_exists($type, $typearray)) return $typearray[$type];
+
+ if (strpos($type, 'text/') === 0) return 'txt';
+
+ # default
+ return false;
+ }
- function mime2extension($type)
- {
- $typearray = array(
- 'text/plain' => 'txt',
- 'text/x-python' => 'py',
- 'text/x-csrc' => 'c',
- 'text/x-chdr' => 'h',
- 'text/x-c++hdr' => 'h',
- 'text/x-c++src' => 'cpp',
- 'text/x-patch' => 'diff',
- 'text/x-lua' => 'lua',
- 'text/x-haskell' => 'hs',
- 'text/x-literate-haskell' => 'hs',
- 'text/x-subviewer' => 'sh',
- #'text/x-makefile' => 'make',
- #'text/x-log' => 'log',
- 'text/html' => 'html',
- 'text/css' => 'css',
- #'image/svg+xml' => 'xml',
- 'application/x-perl' => 'pl',
- 'application/xml' => 'xml',
- 'application/javascript' => 'js',
- 'application/x-desktop' => 'txt',
- 'application/x-m4' => 'txt',
- 'application/x-awk' => 'awk',
- 'application/x-java' => 'java',
- 'application/x-php' => 'php',
- 'application/x-ruby' => 'rb',
- 'application/x-shellscript' => 'sh',
- 'application/x-x509-ca-cert' => 'txt',
- 'application/mbox' => 'txt'
- );
- if (array_key_exists($type, $typearray)) return $typearray[$type];
-
- if (strpos($type, 'text/') === 0) return 'txt';
-
- # default
- return false;
- }
-
}
/* End of file file_mod.php */