aboutsummaryrefslogtreecommitdiff
path: root/classes/File.php
diff options
context:
space:
mode:
Diffstat (limited to 'classes/File.php')
-rw-r--r--classes/File.php14
1 files changed, 12 insertions, 2 deletions
diff --git a/classes/File.php b/classes/File.php
index 2545dc9..4a28f80 100644
--- a/classes/File.php
+++ b/classes/File.php
@@ -27,7 +27,17 @@
class File extends Model {
public
$table = 'file',
- $fillable_columns = ['filename'];
+ $fillable_columns = ['filename', 'secret_key'];
+
+ /**
+ * A random max-63-char string that can be used as secret_key
+ *
+ * @return string The random string
+ */
+ public static function getRandomSecretKey() {
+ return preg_replace('/[^\w]+/', '',
+ base64_encode(openssl_random_pseudo_bytes(45)));
+ }
/**
* Get the full internal path to the file
@@ -48,7 +58,7 @@ class File extends Model {
* @return string The URI
*/
public function getFilenameURI() {
- return Constants::files_folder_external . $this->filename;
+ return Constants::url_external . 'file/get?name=' . $this->filename . '&key=' . $this->secret_key;
}
//------------------------------------------------------------------------------