diff --git a/core/database.class.php b/core/database.class.php
index 6e8a0213..bd97af19 100644
--- a/core/database.class.php
+++ b/core/database.class.php
@@ -56,7 +56,7 @@ class DBEngine {
}
public function create_table_sql($name, $data) {
- return "CREATE TABLE $name ($data)";
+ return 'CREATE TABLE '.$name.' ('.$data.')';
}
}
class MySQL extends DBEngine {
@@ -82,7 +82,7 @@ class MySQL extends DBEngine {
public function create_table_sql($name, $data) {
$data = $this->scoreql_to_sql($data);
$ctes = "ENGINE=InnoDB DEFAULT CHARSET='utf8'";
- return "CREATE TABLE $name ($data) $ctes";
+ return 'CREATE TABLE '.$name.' ('.$data.') '.$ctes;
}
}
class PostgreSQL extends DBEngine {
@@ -103,7 +103,7 @@ class PostgreSQL extends DBEngine {
public function create_table_sql($name, $data) {
$data = $this->scoreql_to_sql($data);
- return "CREATE TABLE $name ($data)";
+ return 'CREATE TABLE '.$name.' ('.$data.')';
}
}
@@ -151,14 +151,14 @@ class SQLite extends DBEngine {
$matches = array();
if(preg_match("/INDEX\s*\((.*)\)/", $bit, $matches)) {
$col = $matches[1];
- $extras .= "CREATE INDEX {$name}_{$col} on $name($col);";
+ $extras .= 'CREATE INDEX '.$name.'_'.$col.' on '.$name($col).';';
}
else {
$cols[] = $bit;
}
}
$cols_redone = implode(", ", $cols);
- return "CREATE TABLE $name ($cols_redone); $extras";
+ return 'CREATE TABLE '.$name.' ('.$cols_redone.'); '.$extras;
}
}
// }}}
@@ -331,10 +331,10 @@ class Database {
if (!array_key_exists(0, $args)) {
foreach($args as $name=>$value) {
if(is_numeric($value)) {
- $stmt->bindValue(":$name", $value, PDO::PARAM_INT);
+ $stmt->bindValue(':'.$name, $value, PDO::PARAM_INT);
}
else {
- $stmt->bindValue(":$name", $value, PDO::PARAM_STR);
+ $stmt->bindValue(':'.$name, $value, PDO::PARAM_STR);
}
}
$stmt->execute();
diff --git a/core/event.class.php b/core/event.class.php
index 14043de4..69a93175 100644
--- a/core/event.class.php
+++ b/core/event.class.php
@@ -68,7 +68,7 @@ class PageRequestEvent extends Event {
}
public function count_args() {
- return $this->arg_count - $this->part_count;
+ return (int)($this->arg_count - $this->part_count);
}
/*
@@ -76,20 +76,20 @@ class PageRequestEvent extends Event {
*/
public function get_search_terms() {
$search_terms = array();
- if($this->count_args() == 2) {
+ if($this->count_args() === 2) {
$search_terms = explode(' ', $this->get_arg(0));
}
return $search_terms;
}
public function get_page_number() {
$page_number = 1;
- if($this->count_args() == 1) {
+ if($this->count_args() === 1) {
$page_number = int_escape($this->get_arg(0));
}
- else if($this->count_args() == 2) {
+ else if($this->count_args() === 2) {
$page_number = int_escape($this->get_arg(1));
}
- if($page_number == 0) $page_number = 1; // invalid -> 0
+ if($page_number === 0) $page_number = 1; // invalid -> 0
return $page_number;
}
public function get_page_size() {
diff --git a/core/imageboard.pack.php b/core/imageboard.pack.php
index d07a571b..81ac9674 100644
--- a/core/imageboard.pack.php
+++ b/core/imageboard.pack.php
@@ -514,7 +514,7 @@ class Image {
private static function build_search_querylet($terms) {
assert(is_array($terms));
global $database;
- if($database->engine->name == "mysql")
+ if($database->engine->name === "mysql")
return Image::build_ugly_search_querylet($terms);
else
return Image::build_accurate_search_querylet($terms);
@@ -750,11 +750,13 @@ class Image {
foreach($tag_querylets as $tq) {
global $tag_n;
$sign = $tq->positive ? "+" : "-";
- $sql .= " $sign (tag LIKE :tag$tag_n)";
- $terms["tag$tag_n"] = $tq->tag;
+ //$sql .= " $sign (tag LIKE :tag$tag_n)";
+ $sql .= ' '.$sign.' (tag LIKE :tag'.$tag_n.')';
+ //$terms["tag$tag_n"] = $tq->tag;
+ $terms['tag'.$tag_n] = $tq->tag;
$tag_n++;
- if($sign == "+") $positive_tag_count++;
+ if($sign === "+") $positive_tag_count++;
else $negative_tag_count++;
}
$tag_search = new Querylet($sql, $terms);
@@ -783,7 +785,7 @@ class Image {
}
// one positive tag (a common case), do an optimised search
- else if($positive_tag_count == 1 && $negative_tag_count == 0) {
+ else if($positive_tag_count === 1 && $negative_tag_count === 0) {
$query = new Querylet(
// MySQL is braindead, and does a full table scan on images, running the subquery once for each row -_-
// "{$this->get_images} WHERE images.id IN (SELECT image_id FROM tags WHERE tag LIKE ?) ",
@@ -819,22 +821,22 @@ class Image {
if($tags_ok) {
$tag_id_list = join(', ', $tag_id_array);
- $subquery = new Querylet("
- SELECT images.*, SUM({$tag_search->sql}) AS score
+ $subquery = new Querylet('
+ SELECT images.*, SUM('.$tag_search->sql.') AS score
FROM images
LEFT JOIN image_tags ON image_tags.image_id = images.id
JOIN tags ON image_tags.tag_id = tags.id
- WHERE tags.id IN ({$tag_id_list})
+ WHERE tags.id IN ('.$tag_id_list.')
GROUP BY images.id
- HAVING score = :score",
+ HAVING score = :score',
array_merge(
$tag_search->variables,
array("score"=>$positive_tag_count)
)
);
- $query = new Querylet("
+ $query = new Querylet('
SELECT *, UNIX_TIMESTAMP(posted) AS posted_timestamp
- FROM ({$subquery->sql}) AS images ", $subquery->variables);
+ FROM ('.$subquery->sql.') AS images ', $subquery->variables);
if(strlen($img_search->sql) > 0) {
$query->append_sql(" WHERE ");
@@ -882,9 +884,9 @@ class Tag {
if(is_string($tags)) {
$tags = explode(' ', $tags);
}
- else if(is_array($tags)) {
+ //else if(is_array($tags)) {
// do nothing
- }
+ //}
$tags = array_map("trim", $tags);
@@ -907,13 +909,13 @@ class Tag {
public static function implode($tags) {
assert(is_string($tags) || is_array($tags));
- if(is_string($tags)) {
- // do nothing
- }
- else if(is_array($tags)) {
+ if(is_array($tags)) {
sort($tags);
$tags = implode(' ', $tags);
}
+ //else if(is_string($tags)) {
+ // do nothing
+ //}
return $tags;
}
diff --git a/core/page.class.php b/core/page.class.php
index d382caf2..398fb10d 100644
--- a/core/page.class.php
+++ b/core/page.class.php
@@ -242,22 +242,22 @@ class Page {
// caching failed, add all files to html_headers.
foreach(glob("lib/*.css") as $css) {
- $this->add_html_header("");
+ $this->add_html_header('');
}
$css_files = glob("ext/*/style.css");
if($css_files) {
foreach($css_files as $css_file) {
- $this->add_html_header("");
+ $this->add_html_header('');
}
}
foreach(glob("lib/*.js") as $js) {
- $this->add_html_header("");
+ $this->add_html_header('');
}
$js_files = glob("ext/*/script.js");
if($js_files) {
foreach($js_files as $js_file) {
- $this->add_html_header("");
+ $this->add_html_header('');
}
}
}
@@ -362,12 +362,12 @@ class Page {
} else {
// Caching of CSS disabled.
foreach(glob("lib/*.css") as $css) {
- $this->add_html_header("");
+ $this->add_html_header('');
}
$css_files = glob("ext/*/style.css");
if($css_files) {
foreach($css_files as $css_file) {
- $this->add_html_header("");
+ $this->add_html_header('');
}
}
}
@@ -412,12 +412,12 @@ class Page {
} else {
// Caching of Javascript disabled.
foreach(glob("lib/*.js") as $js) {
- $this->add_html_header("");
+ $this->add_html_header('');
}
$js_files = glob("ext/*/script.js");
if($js_files) {
foreach($js_files as $js_file) {
- $this->add_html_header("");
+ $this->add_html_header('');
}
}
}
diff --git a/core/user.class.php b/core/user.class.php
index 7352122b..b5779020 100644
--- a/core/user.class.php
+++ b/core/user.class.php
@@ -40,7 +40,7 @@ class User {
public static function by_session($name, $session) {
global $config, $database;
- if($database->engine->name == "mysql") {
+ if($database->engine->name === "mysql") {
$query = "SELECT * FROM users WHERE name = :name AND md5(concat(pass, :ip)) = :sess";
}
else {
@@ -53,12 +53,12 @@ class User {
public static function by_id($id) {
assert(is_numeric($id));
global $database;
- if($id == 1) {
- $cached = $database->cache->get("user-id:$id");
+ if($id === 1) {
+ $cached = $database->cache->get('user-id:'.$id);
if($cached) return new User($cached);
}
$row = $database->get_row("SELECT * FROM users WHERE id = :id", array("id"=>$id));
- if($id == 1) $database->cache->set("user-id:$id", $row, 300);
+ if($id === 1) $database->cache->set('user-id:'.$id, $row, 300);
return is_null($row) ? null : new User($row);
}
@@ -148,7 +148,7 @@ class User {
public function get_avatar_html() {
// FIXME: configurable
global $config;
- if($config->get_string("avatar_host") == "gravatar") {
+ if($config->get_string("avatar_host") === "gravatar") {
if(!empty($this->email)) {
$hash = md5(strtolower($this->email));
$s = $config->get_string("avatar_gravatar_size");
@@ -180,7 +180,7 @@ class User {
public function get_auth_html() {
$at = $this->get_auth_token();
- return "";
+ return '';
}
public function check_auth_token() {