A few more small changes for speed.

This commit is contained in:
green-ponies (jgen) 2012-01-12 14:46:58 -05:00
parent 26d383198a
commit 2e0e8475a1
2 changed files with 12 additions and 12 deletions

View File

@ -342,8 +342,8 @@ class Image {
*/ */
public function get_mime_type() { public function get_mime_type() {
$type = strtolower($this->ext); $type = strtolower($this->ext);
if($type == "jpg") $type = "jpeg"; if($type === "jpg") $type = "jpeg";
return "image/$type"; return 'image/'.$type;
} }
/** /**
@ -380,7 +380,7 @@ class Image {
public function set_locked($tf) { public function set_locked($tf) {
global $database; global $database;
$ln = $tf ? "Y" : "N"; $ln = $tf ? "Y" : "N";
$sln = $database->engine->scoreql_to_sql("SCORE_BOOL_$ln"); $sln = $database->engine->scoreql_to_sql('SCORE_BOOL_'.$ln);
$sln = str_replace("'", "", $sln); $sln = str_replace("'", "", $sln);
$sln = str_replace('"', "", $sln); $sln = str_replace('"', "", $sln);
$database->execute("UPDATE images SET locked=:yn WHERE id=:id", array("yn"=>$sln, "id"=>$this->id)); $database->execute("UPDATE images SET locked=:yn WHERE id=:id", array("yn"=>$sln, "id"=>$this->id));
@ -442,8 +442,8 @@ class Image {
array("tag"=>$tag)); array("tag"=>$tag));
} }
log_info("core-image", "Tags for Image #{$this->id} set to: ".implode(" ", $tags)); log_info("core-image", 'Tags for Image #'.$this->id.' set to: '.implode(" ", $tags));
$database->cache->delete("image-{$this->id}-tags"); $database->cache->delete('image-'.$this->id.'-tags');
} }
/** /**
@ -453,7 +453,7 @@ class Image {
global $database; global $database;
$this->delete_tags_from_image(); $this->delete_tags_from_image();
$database->execute("DELETE FROM images WHERE id=:id", array("id"=>$this->id)); $database->execute("DELETE FROM images WHERE id=:id", array("id"=>$this->id));
log_info("core-image", "Deleted Image #{$this->id} ({$this->hash})"); log_info("core-image", 'Deleted Image #'.$this->id.' ('.$this->hash.')');
unlink($this->get_image_filename()); unlink($this->get_image_filename());
unlink($this->get_thumb_filename()); unlink($this->get_thumb_filename());
@ -464,7 +464,7 @@ class Image {
* It DOES NOT remove anything from the database. * It DOES NOT remove anything from the database.
*/ */
public function remove_image_only() { public function remove_image_only() {
log_info("core-image", "Removed Image File ({$this->hash})"); log_info("core-image", 'Removed Image File ('.$this->hash.')');
@unlink($this->get_image_filename()); @unlink($this->get_image_filename());
@unlink($this->get_thumb_filename()); @unlink($this->get_thumb_filename());
} }

View File

@ -98,7 +98,7 @@ class User {
*/ */
public function is_anonymous() { public function is_anonymous() {
global $config; global $config;
return ($this->id == $config->get_int('anon_id')); return ($this->id === $config->get_int('anon_id'));
} }
/** /**
@ -108,7 +108,7 @@ class User {
*/ */
public function is_logged_in() { public function is_logged_in() {
global $config; global $config;
return ($this->id != $config->get_int('anon_id')); return ($this->id !== $config->get_int('anon_id'));
} }
/** /**
@ -125,20 +125,20 @@ class User {
global $database; global $database;
$yn = $admin ? 'Y' : 'N'; $yn = $admin ? 'Y' : 'N';
$database->Execute("UPDATE users SET admin=:yn WHERE id=:id", array("yn"=>$yn, "id"=>$this->id)); $database->Execute("UPDATE users SET admin=:yn WHERE id=:id", array("yn"=>$yn, "id"=>$this->id));
log_info("core-user", "Made {$this->name} admin=$yn"); log_info("core-user", 'Made '.$this->name.' admin='.$yn);
} }
public function set_password($password) { public function set_password($password) {
global $database; global $database;
$hash = md5(strtolower($this->name) . $password); $hash = md5(strtolower($this->name) . $password);
$database->Execute("UPDATE users SET pass=:hash WHERE id=:id", array("hash"=>$hash, "id"=>$this->id)); $database->Execute("UPDATE users SET pass=:hash WHERE id=:id", array("hash"=>$hash, "id"=>$this->id));
log_info("core-user", "Set password for {$this->name}"); log_info("core-user", 'Set password for '.$this->name);
} }
public function set_email($address) { public function set_email($address) {
global $database; global $database;
$database->Execute("UPDATE users SET email=:email WHERE id=:id", array("email"=>$address, "id"=>$this->id)); $database->Execute("UPDATE users SET email=:email WHERE id=:id", array("email"=>$address, "id"=>$this->id));
log_info("core-user", "Set email for {$this->name}"); log_info("core-user", 'Set email for '.$this->name);
} }
/** /**