wtf git
This commit is contained in:
parent
6a75857b72
commit
05150706cc
@ -49,6 +49,10 @@ class Image {
|
||||
$this->$name = $value; // hax
|
||||
}
|
||||
$this->posted_timestamp = strtotime($this->posted); // pray
|
||||
|
||||
assert(is_numeric($this->id));
|
||||
assert(is_numeric($this->height));
|
||||
assert(is_numeric($this->width));
|
||||
}
|
||||
}
|
||||
|
||||
@ -128,7 +132,13 @@ class Image {
|
||||
assert(is_array($tags));
|
||||
global $database;
|
||||
if(count($tags) == 0) {
|
||||
return $database->db->GetOne("SELECT COUNT(*) FROM images");
|
||||
#return $database->db->GetOne("SELECT COUNT(*) FROM images");
|
||||
$total = $database->cache->get("image-count");
|
||||
if(!$total) {
|
||||
$total = $database->db->GetOne("SELECT COUNT(*) FROM images");
|
||||
$database->cache->set("image-count", $total, 600);
|
||||
}
|
||||
return $total;
|
||||
}
|
||||
else {
|
||||
$querylet = Image::build_search_querylet($tags);
|
||||
@ -297,10 +307,7 @@ class Image {
|
||||
* @retval string
|
||||
*/
|
||||
public function get_image_filename() {
|
||||
$hash = $this->hash;
|
||||
$ab = substr($hash, 0, 2);
|
||||
$ext = $this->ext;
|
||||
return "images/$ab/$hash";
|
||||
return warehouse_path("images", $this->hash);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -309,9 +316,7 @@ class Image {
|
||||
* @retval string
|
||||
*/
|
||||
public function get_thumb_filename() {
|
||||
$hash = $this->hash;
|
||||
$ab = substr($hash, 0, 2);
|
||||
return "thumbs/$ab/$hash";
|
||||
return warehouse_path("thumbs", $this->hash);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -390,7 +395,7 @@ class Image {
|
||||
// insert each new tags
|
||||
foreach($tags as $tag) {
|
||||
$id = $database->db->GetOne(
|
||||
"SELECT id FROM tags WHERE tag = ?",
|
||||
"SELECT id FROM tags WHERE lower(tag) = lower(?)",
|
||||
array($tag));
|
||||
if(empty($id)) {
|
||||
// a new tag
|
||||
@ -897,10 +902,9 @@ class Tag {
|
||||
* heirachy, or throw an exception trying
|
||||
*/
|
||||
function move_upload_to_archive($event) {
|
||||
$hash = $event->hash;
|
||||
$ha = substr($hash, 0, 2);
|
||||
if(!@copy($event->tmpname, "images/$ha/$hash")) {
|
||||
throw new UploadException("Failed to copy file from uploads ({$event->tmpname}) to archive (images/$ha/$hash)");
|
||||
$target = warehouse_path("images", $event->hash);
|
||||
if(!@copy($event->tmpname, $target)) {
|
||||
throw new UploadException("Failed to copy file from uploads ({$event->tmpname}) to archive ($target)");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -465,6 +465,10 @@ function format_text($string) {
|
||||
return $tfe->formatted;
|
||||
}
|
||||
|
||||
function warehouse_path($base, $hash) {
|
||||
$ab = substr($hash, 0, 2);
|
||||
return "$base/$ab/$hash";
|
||||
}
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
|
||||
* Logging convenience *
|
||||
|
Loading…
x
Reference in New Issue
Block a user