From cb8b733a6c2333ff90d3af0fc37e8c21c73d9e7a Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 9 Apr 2012 11:22:03 +0200 Subject: Move is_cli_client() and random_id() to helper Signed-off-by: Florian Pritz --- application/models/file_mod.php | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) (limited to 'application/models/file_mod.php') diff --git a/application/models/file_mod.php b/application/models/file_mod.php index f804ede9b..1f1fa5f49 100644 --- a/application/models/file_mod.php +++ b/application/models/file_mod.php @@ -23,7 +23,7 @@ class File_mod extends CI_Model { // TODO: make threadsafe function new_id() { - $id = $this->random_id(3,6); + $id = random_id(3,6); if ($this->id_exists($id) || $id == 'file' || $id == 'user') { return $this->new_id(); @@ -175,18 +175,6 @@ class File_mod extends CI_Model { return true; } - function is_cli_client() - { - // official client uses "fb-client/$version" as useragent - $clients = array("fb-client", "libcurl", "pyfb"); - foreach ($clients as $client) { - if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], $client) !== false) { - return true; - } - } - return false; - } - // download a given ID // TODO: make smaller function download() @@ -367,22 +355,6 @@ class File_mod extends CI_Model { return true; } - // Generate a random ID - private function random_id($min_length, $max_length) - { - $random = ''; - $char_list = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; - $char_list .= "abcdefghijklmnopqrstuvwxyz"; - $char_list .= "1234567890"; - $length = rand()%($max_length-$min_length) + $min_length; - - for($i = 0; $i < $max_length; $i++) { - if (strlen($random) == $length) break; - $random .= substr($char_list,(rand()%(strlen($char_list))), 1); - } - return $random; - } - // Allow certain types to be highlight without doing it automatically function can_highlight($type) { -- cgit v1.2.3-24-g4f1b