Merge pull request #413 from jgen/linting

Lots o' Linting
This commit is contained in:
Shish 2014-04-26 12:00:35 +01:00
commit e9d8ae7f5b
280 changed files with 1533 additions and 1066 deletions

View File

@ -3,4 +3,4 @@ imports:
- php - php
filter: filter:
excluded_paths: [lib/*,ext/chatbox/js/jquery.js] excluded_paths: [lib/*,ext/tagger/script.js]

View File

@ -1,10 +1,18 @@
<?php <?php
/** /**
* Class BaseThemelet
*
* A collection of common functions for theme parts * A collection of common functions for theme parts
*/ */
class BaseThemelet { class BaseThemelet {
/** /**
* Generic error message display * Generic error message display
*
* @param int $code
* @param string $title
* @param string $message
*/ */
public function display_error(/*int*/ $code, /*string*/ $title, /*string*/ $message) { public function display_error(/*int*/ $code, /*string*/ $title, /*string*/ $message) {
global $page; global $page;
@ -24,7 +32,6 @@ class BaseThemelet {
$page->add_block(new Block("Error", $message)); $page->add_block(new Block("Error", $message));
} }
/** /**
* A specific, common error message * A specific, common error message
*/ */
@ -36,6 +43,9 @@ class BaseThemelet {
/** /**
* Generic thumbnail code; returns HTML rather than adding * Generic thumbnail code; returns HTML rather than adding
* a block since thumbs tend to go inside blocks... * a block since thumbs tend to go inside blocks...
*
* @param Image $image
* @return string
*/ */
public function build_thumb_html(Image $image) { public function build_thumb_html(Image $image) {
global $config; global $config;
@ -56,8 +66,8 @@ class BaseThemelet {
$custom_classes = ""; $custom_classes = "";
if(class_exists("Relationships")){ if(class_exists("Relationships")){
if($image->parent_id !== NULL){ $custom_classes .= "shm-thumb-has_parent "; } if(property_exists('Image', 'parent_id') && $image->parent_id !== NULL){ $custom_classes .= "shm-thumb-has_parent "; }
if($image->has_children == TRUE){ $custom_classes .= "shm-thumb-has_child "; } if(property_exists('Image', 'has_children') && $image->has_children == TRUE){ $custom_classes .= "shm-thumb-has_child "; }
} }
return "<a href='$h_view_link' class='thumb shm-thumb shm-thumb-link {$custom_classes}' data-tags='$h_tags' data-post-id='$i_id'>". return "<a href='$h_view_link' class='thumb shm-thumb shm-thumb-link {$custom_classes}' data-tags='$h_tags' data-post-id='$i_id'>".
@ -65,9 +75,14 @@ class BaseThemelet {
"</a>\n"; "</a>\n";
} }
/** /**
* Add a generic paginator * Add a generic paginator.
*
* @param Page $page
* @param string $base
* @param string $query
* @param int $page_number
* @param int $total_pages
*/ */
public function display_paginator(Page $page, $base, $query, $page_number, $total_pages) { public function display_paginator(Page $page, $base, $query, $page_number, $total_pages) {
if($total_pages == 0) $total_pages = 1; if($total_pages == 0) $total_pages = 1;
@ -75,11 +90,28 @@ class BaseThemelet {
$page->add_block(new Block(null, $body, "main", 90, "paginator")); $page->add_block(new Block(null, $body, "main", 90, "paginator"));
} }
/**
* Generate a single HTML link.
*
* @param string $base_url
* @param string $query
* @param int|string $page
* @param string $name
* @return string
*/
private function gen_page_link($base_url, $query, $page, $name) { private function gen_page_link($base_url, $query, $page, $name) {
$link = make_link($base_url.'/'.$page, $query); $link = make_link($base_url.'/'.$page, $query);
return '<a href="'.$link.'">'.$name.'</a>'; return '<a href="'.$link.'">'.$name.'</a>';
} }
/**
* @param string $base_url
* @param string $query
* @param int|string $page
* @param int|string $current_page
* @param string $name
* @return string
*/
private function gen_page_link_block($base_url, $query, $page, $current_page, $name) { private function gen_page_link_block($base_url, $query, $page, $current_page, $name) {
$paginator = ""; $paginator = "";
if($page == $current_page) $paginator .= "<b>"; if($page == $current_page) $paginator .= "<b>";
@ -88,6 +120,15 @@ class BaseThemelet {
return $paginator; return $paginator;
} }
/**
* Build the paginator.
*
* @param int $current_page
* @param int $total_pages
* @param string $base_url
* @param string $query
* @return string
*/
private function build_paginator($current_page, $total_pages, $base_url, $query) { private function build_paginator($current_page, $total_pages, $base_url, $query) {
$next = $current_page + 1; $next = $current_page + 1;
$prev = $current_page - 1; $prev = $current_page - 1;
@ -115,4 +156,4 @@ class BaseThemelet {
.'<br>&lt;&lt; '.$pages_html.' &gt;&gt;'; .'<br>&lt;&lt; '.$pages_html.' &gt;&gt;';
} }
} }
?>

View File

@ -6,39 +6,48 @@ class Block {
/** /**
* The block's title * The block's title
* *
* @retval string * @var string
*/ */
var $header; public $header;
/** /**
* The content * The content
* *
* @retval string * @var string
*/ */
var $body; public $body;
/** /**
* Where the block should be placed. The default theme supports * Where the block should be placed. The default theme supports
* "main" and "left", other themes can add their own areas * "main" and "left", other themes can add their own areas
* *
* @retval string * @var string
*/ */
var $section; public $section;
/** /**
* How far down the section the block should appear, higher * How far down the section the block should appear, higher
* numbers appear lower. The scale is 0-100 by convention, * numbers appear lower. The scale is 0-100 by convention,
* though any number or string will work. * though any number or string will work.
* *
* @retval int * @var int
*/ */
var $position; public $position;
/** /**
* * @var int
*/ */
var $id; public $id;
/**
* Construct a block.
*
* @param string $header
* @param string $body
* @param string $section
* @param int $position
* @param null|int $id
*/
public function __construct($header, $body, /*string*/ $section="main", /*int*/ $position=50, $id=null) { public function __construct($header, $body, /*string*/ $section="main", /*int*/ $position=50, $id=null) {
$this->header = $header; $this->header = $header;
$this->body = $body; $this->body = $body;
@ -47,6 +56,12 @@ class Block {
$this->id = str_replace(' ', '_', is_null($id) ? (is_null($header) ? md5($body) : $header) . $section : $id); $this->id = str_replace(' ', '_', is_null($id) ? (is_null($header) ? md5($body) : $header) . $section : $id);
} }
/**
* Get the HTML for this block.
*
* @param bool $hidable
* @return string
*/
public function get_html($hidable=false) { public function get_html($hidable=false) {
$h = $this->header; $h = $this->header;
$b = $this->body; $b = $this->body;
@ -71,4 +86,4 @@ class NavBlock extends Block {
parent::__construct("Navigation", "<a href='".make_link()."'>Index</a>", "left", 0); parent::__construct("Navigation", "<a href='".make_link()."'>Index</a>", "left", 0);
} }
} }
?>

View File

@ -224,4 +224,4 @@ class MockConfig extends HardcodeConfig {
parent::__construct($config); parent::__construct($config);
} }
} }
?>

View File

@ -45,7 +45,7 @@ class ImgQuerylet {
// }}} // }}}
// {{{ db engines // {{{ db engines
class DBEngine { class DBEngine {
var $name = null; public $name = null;
public function init($db) {} public function init($db) {}
@ -58,7 +58,7 @@ class DBEngine {
} }
} }
class MySQL extends DBEngine { class MySQL extends DBEngine {
var $name = "mysql"; public $name = "mysql";
public function init($db) { public function init($db) {
$db->exec("SET NAMES utf8;"); $db->exec("SET NAMES utf8;");
@ -84,7 +84,7 @@ class MySQL extends DBEngine {
} }
} }
class PostgreSQL extends DBEngine { class PostgreSQL extends DBEngine {
var $name = "pgsql"; public $name = "pgsql";
public function init($db) { public function init($db) {
$db->exec("SET application_name TO 'shimmie [{$_SERVER['REMOTE_ADDR']}]';"); $db->exec("SET application_name TO 'shimmie [{$_SERVER['REMOTE_ADDR']}]';");
@ -123,7 +123,7 @@ function _concat($a, $b) { return $a . $b; }
function _lower($a) { return strtolower($a); } function _lower($a) { return strtolower($a); }
class SQLite extends DBEngine { class SQLite extends DBEngine {
var $name = "sqlite"; public $name = "sqlite";
public function init($db) { public function init($db) {
ini_set('sqlite.assoc_case', 0); ini_set('sqlite.assoc_case', 0);
@ -553,4 +553,4 @@ class MockDatabase extends Database {
public function create_table($name, $def) {} public function create_table($name, $def) {}
public function connect_engine() {} public function connect_engine() {}
} }
?>

View File

@ -4,17 +4,17 @@ class Email {
/** /**
* A generic email. * A generic email.
*/ */
var $to; public $to;
var $subject; public $subject;
var $header; public $header;
var $style; public $style;
var $header_img; public $header_img;
var $sitename; public $sitename;
var $sitedomain; public $sitedomain;
var $siteemail; public $siteemail;
var $date; public $date;
var $body; public $body;
var $footer; public $footer;
public function __construct($to, $subject, $header, $body) { public function __construct($to, $subject, $header, $body) {
global $config; global $config;
@ -116,4 +116,4 @@ Copyright (C) <a href="'.$this->sitedomain.'">'.$this->sitename.'</a><br />
return $sent; return $sent;
} }
} }
?>

View File

@ -26,10 +26,13 @@ class InitExtEvent extends Event {}
* $event->get_arg(0) = "42" * $event->get_arg(0) = "42"
*/ */
class PageRequestEvent extends Event { class PageRequestEvent extends Event {
var $args; public $args;
var $arg_count; public $arg_count;
var $part_count; public $part_count;
/**
* @param string $path
*/
public function __construct($path) { public function __construct($path) {
global $config; global $config;
@ -63,7 +66,8 @@ class PageRequestEvent extends Event {
* *
* If it matches, store the remaining path elements in $args * If it matches, store the remaining path elements in $args
* *
* @retval bool * @param string $name
* @return bool
*/ */
public function page_matches(/*string*/ $name) { public function page_matches(/*string*/ $name) {
$parts = explode("/", $name); $parts = explode("/", $name);
@ -84,8 +88,9 @@ class PageRequestEvent extends Event {
/** /**
* Get the n th argument of the page request (if it exists.) * Get the n th argument of the page request (if it exists.)
* @param $n integer *
* @retval The argmuent (string) or NULL * @param int $n
* @return string|null The argmuent (string) or NULL
*/ */
public function get_arg(/*int*/ $n) { public function get_arg(/*int*/ $n) {
$offset = $this->part_count + $n; $offset = $this->part_count + $n;
@ -99,7 +104,7 @@ class PageRequestEvent extends Event {
/** /**
* Returns the number of arguments the page request has. * Returns the number of arguments the page request has.
* @retval int * @return int
*/ */
public function count_args() { public function count_args() {
return (int)($this->arg_count - $this->part_count); return (int)($this->arg_count - $this->part_count);
@ -108,6 +113,10 @@ class PageRequestEvent extends Event {
/* /*
* Many things use these functions * Many things use these functions
*/ */
/**
* @return array
*/
public function get_search_terms() { public function get_search_terms() {
$search_terms = array(); $search_terms = array();
if($this->count_args() === 2) { if($this->count_args() === 2) {
@ -115,6 +124,10 @@ class PageRequestEvent extends Event {
} }
return $search_terms; return $search_terms;
} }
/**
* @return int
*/
public function get_page_number() { public function get_page_number() {
$page_number = 1; $page_number = 1;
if($this->count_args() === 1) { if($this->count_args() === 1) {
@ -126,6 +139,10 @@ class PageRequestEvent extends Event {
if($page_number === 0) $page_number = 1; // invalid -> 0 if($page_number === 0) $page_number = 1; // invalid -> 0
return $page_number; return $page_number;
} }
/**
* @return int
*/
public function get_page_size() { public function get_page_size() {
global $config; global $config;
return $config->get_int('index_images'); return $config->get_int('index_images');
@ -227,28 +244,28 @@ class LogEvent extends Event {
/** /**
* a category, normally the extension name * a category, normally the extension name
* *
* @retval string * @return string
*/ */
var $section; var $section;
/** /**
* See python... * See python...
* *
* @retval int * @return int
*/ */
var $priority = 0; var $priority = 0;
/** /**
* Free text to be logged * Free text to be logged
* *
* @retval text * @return text
*/ */
var $message; var $message;
/** /**
* The time that the event was created * The time that the event was created
* *
* @retval int * @return int
*/ */
var $time; var $time;
@ -265,4 +282,4 @@ class LogEvent extends Event {
$this->time = time(); $this->time = time();
} }
} }
?>

View File

@ -8,4 +8,12 @@ class SCoreException extends Exception {}
* A fairly common, generic exception * A fairly common, generic exception
*/ */
class PermissionDeniedException extends SCoreException {} class PermissionDeniedException extends SCoreException {}
?>
/**
* Class ImageDoesNotExist
*
* This exception is used when an Image cannot be found by ID.
*
* Example: Image::by_id(-1) returns null
*/
class ImageDoesNotExist extends SCoreException {}

View File

@ -81,7 +81,7 @@
*/ */
abstract class Extension { abstract class Extension {
/** this theme's Themelet object */ /** this theme's Themelet object */
var $theme; public $theme;
/** @private */ /** @private */
var $_child; var $_child;
@ -220,15 +220,18 @@ abstract class DataHandlerExtension extends Extension {
} }
} }
/*
public function onSetupBuilding(SetupBuildingEvent $event) { public function onSetupBuilding(SetupBuildingEvent $event) {
$sb = $this->setup(); $sb = $this->setup();
if($sb) $event->panel->add_block($sb); if($sb) $event->panel->add_block($sb);
} }
protected function setup() {} protected function setup() {}
*/
abstract protected function supported_ext($ext); abstract protected function supported_ext($ext);
abstract protected function check_contents($tmpname); abstract protected function check_contents($tmpname);
abstract protected function create_image_from_data($filename, $metadata); abstract protected function create_image_from_data($filename, $metadata);
abstract protected function create_thumb($hash); abstract protected function create_thumb($hash);
} }
?>

View File

@ -36,14 +36,14 @@ require_once "lib/flexihash.php";
* sound file, or any other supported upload type. * sound file, or any other supported upload type.
*/ */
class Image { class Image {
var $id = null; public $id = null;
var $height, $width; public $height, $width;
var $hash, $filesize; public $hash, $filesize;
var $filename, $ext; public $filename, $ext;
var $owner_ip; public $owner_id, $owner_ip;
var $posted; public $posted, $posted_timestamp;
var $source; public $source;
var $locked; public $locked;
/** /**
* One will very rarely construct an image directly, more common * One will very rarely construct an image directly, more common
@ -54,7 +54,7 @@ class Image {
foreach($row as $name => $value) { foreach($row as $name => $value) {
// some databases use table.name rather than name // some databases use table.name rather than name
$name = str_replace("images.", "", $name); $name = str_replace("images.", "", $name);
$this->$name = $value; // hax $this->$name = $value; // hax, this is likely the cause of much scrutinizer-ci complaints.
} }
$this->posted_timestamp = strtotime($this->posted); // pray $this->posted_timestamp = strtotime($this->posted); // pray
$this->locked = bool_escape($this->locked); $this->locked = bool_escape($this->locked);
@ -68,7 +68,8 @@ class Image {
/** /**
* Find an image by ID * Find an image by ID
* *
* @retval Image * @param int $id
* @return Image
*/ */
public static function by_id(/*int*/ $id) { public static function by_id(/*int*/ $id) {
assert(is_numeric($id)); assert(is_numeric($id));
@ -80,7 +81,8 @@ class Image {
/** /**
* Find an image by hash * Find an image by hash
* *
* @retval Image * @param string $hash
* @return Image
*/ */
public static function by_hash(/*string*/ $hash) { public static function by_hash(/*string*/ $hash) {
assert(is_string($hash)); assert(is_string($hash));
@ -92,7 +94,8 @@ class Image {
/** /**
* Pick a random image out of a set * Pick a random image out of a set
* *
* @retval Image * @param array $tags
* @return Image
*/ */
public static function by_random($tags=array()) { public static function by_random($tags=array()) {
assert(is_array($tags)); assert(is_array($tags));
@ -107,7 +110,11 @@ class Image {
/** /**
* Search for an array of images * Search for an array of images
* *
* @retval Array * @param int $start
* @param int $limit
* @param array $tags
* @throws SCoreException
* @return Array
*/ */
public static function find_images(/*int*/ $start, /*int*/ $limit, $tags=array()) { public static function find_images(/*int*/ $start, /*int*/ $limit, $tags=array()) {
assert(is_numeric($start)); assert(is_numeric($start));
@ -145,6 +152,9 @@ class Image {
/** /**
* Count the number of image results for a given search * Count the number of image results for a given search
*
* @param array $tags
* @return mixed
*/ */
public static function count_images($tags=array()) { public static function count_images($tags=array()) {
assert(is_array($tags)); assert(is_array($tags));
@ -174,6 +184,9 @@ class Image {
/** /**
* Count the number of pages for a given search * Count the number of pages for a given search
*
* @param array $tags
* @return float
*/ */
public static function count_pages($tags=array()) { public static function count_pages($tags=array()) {
assert(is_array($tags)); assert(is_array($tags));
@ -192,7 +205,9 @@ class Image {
* Rather than simply $this_id + 1, one must take into account * Rather than simply $this_id + 1, one must take into account
* deleted images and search queries * deleted images and search queries
* *
* @retval Image * @param array $tags
* @param bool $next
* @return Image
*/ */
public function get_next($tags=array(), $next=true) { public function get_next($tags=array(), $next=true) {
assert(is_array($tags)); assert(is_array($tags));
@ -224,7 +239,8 @@ class Image {
/** /**
* The reverse of get_next * The reverse of get_next
* *
* @retval Image * @param array $tags
* @return Image
*/ */
public function get_prev($tags=array()) { public function get_prev($tags=array()) {
return $this->get_next($tags, false); return $this->get_next($tags, false);
@ -233,14 +249,16 @@ class Image {
/** /**
* Find the User who owns this Image * Find the User who owns this Image
* *
* @retval User * @return User
*/ */
public function get_owner() { public function get_owner() {
return User::by_id($this->owner_id); return User::by_id($this->owner_id);
} }
/** /**
* Set the image's owner * Set the image's owner.
*
* @param User $owner
*/ */
public function set_owner(User $owner) { public function set_owner(User $owner) {
global $database; global $database;
@ -262,7 +280,9 @@ class Image {
} }
/** /**
* Get this image's tags as a string * Get this image's tags as a string.
*
* @return string
*/ */
public function get_tag_list() { public function get_tag_list() {
return Tag::implode($this->get_tag_array()); return Tag::implode($this->get_tag_array());
@ -271,7 +291,7 @@ class Image {
/** /**
* Get the URL for the full size image * Get the URL for the full size image
* *
* @retval string * @return string
*/ */
public function get_image_link() { public function get_image_link() {
global $config; global $config;
@ -296,7 +316,7 @@ class Image {
* Get a short link to the full size image * Get a short link to the full size image
* *
* @deprecated * @deprecated
* @retval string * @return string
*/ */
public function get_short_link() { public function get_short_link() {
global $config; global $config;
@ -306,7 +326,7 @@ class Image {
/** /**
* Get the URL for the thumbnail * Get the URL for the thumbnail
* *
* @retval string * @return string
*/ */
public function get_thumb_link() { public function get_thumb_link() {
global $config; global $config;
@ -331,7 +351,7 @@ class Image {
* Get the tooltip for this image, formatted according to the * Get the tooltip for this image, formatted according to the
* configured template * configured template
* *
* @retval string * @return string
*/ */
public function get_tooltip() { public function get_tooltip() {
global $config; global $config;
@ -360,7 +380,7 @@ class Image {
/** /**
* Figure out where the full size image is on disk * Figure out where the full size image is on disk
* *
* @retval string * @return string
*/ */
public function get_image_filename() { public function get_image_filename() {
return warehouse_path("images", $this->hash); return warehouse_path("images", $this->hash);
@ -369,7 +389,7 @@ class Image {
/** /**
* Figure out where the thumbnail is on disk * Figure out where the thumbnail is on disk
* *
* @retval string * @return string
*/ */
public function get_thumb_filename() { public function get_thumb_filename() {
return warehouse_path("thumbs", $this->hash); return warehouse_path("thumbs", $this->hash);
@ -378,7 +398,7 @@ class Image {
/** /**
* Get the original filename * Get the original filename
* *
* @retval string * @return string
*/ */
public function get_filename() { public function get_filename() {
return $this->filename; return $this->filename;
@ -387,7 +407,7 @@ class Image {
/** /**
* Get the image's mime type * Get the image's mime type
* *
* @retval string * @return string
*/ */
public function get_mime_type() { public function get_mime_type() {
return getMimeType($this->get_image_filename(), $this->get_ext()); return getMimeType($this->get_image_filename(), $this->get_ext());
@ -396,7 +416,7 @@ class Image {
/** /**
* Get the image's filename extension * Get the image's filename extension
* *
* @retval string * @return string
*/ */
public function get_ext() { public function get_ext() {
return $this->ext; return $this->ext;
@ -405,7 +425,7 @@ class Image {
/** /**
* Get the image's source URL * Get the image's source URL
* *
* @retval string * @return string
*/ */
public function get_source() { public function get_source() {
return $this->source; return $this->source;
@ -413,6 +433,8 @@ class Image {
/** /**
* Set the image's source URL * Set the image's source URL
*
* @param string $new_source
*/ */
public function set_source(/*string*/ $new_source) { public function set_source(/*string*/ $new_source) {
global $database; global $database;
@ -426,7 +448,7 @@ class Image {
/** /**
* Check if the image is locked. * Check if the image is locked.
* @retval bool * @return bool
*/ */
public function is_locked() { public function is_locked() {
return $this->locked; return $this->locked;
@ -542,7 +564,9 @@ class Image {
/** /**
* Someone please explain this * Someone please explain this
* *
* @retval string * @param $tmpl
* @param string $_escape
* @return string
*/ */
public function parse_link_template($tmpl, $_escape="url_escape") { public function parse_link_template($tmpl, $_escape="url_escape") {
global $config; global $config;
@ -682,8 +706,8 @@ class Image {
else { else {
$expansions = Tag::resolve_wildcard($term); $expansions = Tag::resolve_wildcard($term);
if($expansions && $positive) $positive_tag_count++; if($expansions && $positive) $positive_tag_count++;
foreach($expansions as $term) { foreach($expansions as $expanded_term) {
$tag_querylets[] = new TagQuerylet($term, $positive); $tag_querylets[] = new TagQuerylet($expanded_term, $positive);
} }
} }
} }
@ -966,6 +990,9 @@ class Image {
class Tag { class Tag {
/** /**
* Remove any excess fluff from a user-input tag * Remove any excess fluff from a user-input tag
*
* @param string $tag
* @return mixed
*/ */
public static function sanitise($tag) { public static function sanitise($tag) {
assert(is_string($tag)); assert(is_string($tag));
@ -1005,6 +1032,10 @@ class Tag {
return $tag_array; return $tag_array;
} }
/**
* @param $tags
* @return string
*/
public static function implode($tags) { public static function implode($tags) {
assert(is_string($tags) || is_array($tags)); assert(is_string($tags) || is_array($tags));
@ -1019,6 +1050,10 @@ class Tag {
return $tags; return $tags;
} }
/**
* @param string $tag
* @return string
*/
public static function resolve_alias($tag) { public static function resolve_alias($tag) {
assert(is_string($tag)); assert(is_string($tag));
@ -1067,8 +1102,8 @@ class Tag {
/** /**
* This function takes a list (array) of tags and changes any tags that have aliases * This function takes a list (array) of tags and changes any tags that have aliases
* *
* @param $tags Array of tags * @param array $tags Array of tags
* @return Array of tags * @return array of tags
*/ */
public static function resolve_aliases($tags) { public static function resolve_aliases($tags) {
assert(is_array($tags)); assert(is_array($tags));
@ -1104,7 +1139,7 @@ class Tag {
/** /**
* Move a file from PHP's temporary area into shimmie's image storage * Move a file from PHP's temporary area into shimmie's image storage
* heirachy, or throw an exception trying * hierarchy, or throw an exception trying
*/ */
function move_upload_to_archive(DataUploadEvent $event) { function move_upload_to_archive(DataUploadEvent $event) {
$target = warehouse_path("images", $event->hash); $target = warehouse_path("images", $event->hash);
@ -1116,8 +1151,12 @@ function move_upload_to_archive(DataUploadEvent $event) {
} }
/** /**
* Given a full size pair of dimentions, return a pair scaled down to fit * Given a full size pair of dimensions, return a pair scaled down to fit
* into the configured thumbnail square, with ratio intact * into the configured thumbnail square, with ratio intact
*
* @param int $orig_width
* @param int $orig_height
* @return array
*/ */
function get_thumbnail_size(/*int*/ $orig_width, /*int*/ $orig_height) { function get_thumbnail_size(/*int*/ $orig_width, /*int*/ $orig_height) {
global $config; global $config;
@ -1143,4 +1182,4 @@ function get_thumbnail_size(/*int*/ $orig_width, /*int*/ $orig_height) {
} }
} }
?>

View File

@ -251,11 +251,11 @@ class Page {
$data_href = get_base_href(); $data_href = get_base_href();
$theme_name = $config->get_string('theme', 'default'); $theme_name = $config->get_string('theme', 'default');
$this->add_html_header("<script type='text/javascript'>base_href = '$data_href';</script>"); $this->add_html_header("<script type='text/javascript'>base_href = '$data_href';</script>", 40);
# 404/static handler will map these to themes/foo/bar.ico or lib/static/bar.ico # 404/static handler will map these to themes/foo/bar.ico or lib/static/bar.ico
$this->add_html_header("<link rel='icon' type='image/x-icon' href='$data_href/favicon.ico'>"); $this->add_html_header("<link rel='icon' type='image/x-icon' href='$data_href/favicon.ico'>", 41);
$this->add_html_header("<link rel='apple-touch-icon' href='$data_href/apple-touch-icon.png'>"); $this->add_html_header("<link rel='apple-touch-icon' href='$data_href/apple-touch-icon.png'>", 42);
$css_files = array(); $css_files = array();
$css_latest = 0; $css_latest = 0;
@ -275,7 +275,7 @@ class Page {
} }
file_put_contents($css_cache_file, $css_data); file_put_contents($css_cache_file, $css_data);
} }
$this->add_html_header("<link rel='stylesheet' href='$data_href/$css_cache_file' type='text/css'>"); $this->add_html_header("<link rel='stylesheet' href='$data_href/$css_cache_file' type='text/css'>", 43);
$js_files = array(); $js_files = array();
$js_latest = 0; $js_latest = 0;
@ -291,10 +291,10 @@ class Page {
} }
file_put_contents($js_cache_file, $js_data); file_put_contents($js_cache_file, $js_data);
} }
$this->add_html_header("<script src='$data_href/$js_cache_file' type='text/javascript'></script>"); $this->add_html_header("<script src='$data_href/$js_cache_file' type='text/javascript'></script>", 44);
} }
} }
class MockPage extends Page { class MockPage extends Page {
} }
?>

View File

@ -46,4 +46,5 @@ _d("EXTRA_EXTS", ""); // optional extra extensions
*/ */
_d("SCORE_VERSION", 's2hack/'.VERSION); // string SCore version _d("SCORE_VERSION", 's2hack/'.VERSION); // string SCore version
_d("ENABLED_EXTS", CORE_EXTS.",".EXTRA_EXTS); _d("ENABLED_EXTS", CORE_EXTS.",".EXTRA_EXTS);
?>

View File

@ -8,16 +8,23 @@ function _new_user($row) {
/** /**
* An object representing a row in the "users" table. * An object representing a row in the "users" table.
* *
* The currently logged in user will always be accessable via the global variable $user * The currently logged in user will always be accessible via the global variable $user
*/ */
class User { class User {
var $id; /** @var int */
var $name; public $id;
var $email;
var $join_date;
var $passhash;
/* @var UserClass */ /** @var string */
public $name;
/** @var string */
public $email;
public $join_date;
public $passhash;
/** @var UserClass */
var $class; var $class;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
@ -44,6 +51,13 @@ class User {
$this->class = $_user_classes[$row["class"]]; $this->class = $_user_classes[$row["class"]];
} }
/**
* Construct a User by session.
*
* @param string $name
* @param string $session
* @return null|User
*/
public static function by_session(/*string*/ $name, /*string*/ $session) { public static function by_session(/*string*/ $name, /*string*/ $session) {
global $config, $database; global $config, $database;
$row = $database->cache->get("user-session-$name-$session"); $row = $database->cache->get("user-session-$name-$session");
@ -60,6 +74,11 @@ class User {
return is_null($row) ? null : new User($row); return is_null($row) ? null : new User($row);
} }
/**
* Construct a User by session.
* @param int $id
* @return null|User
*/
public static function by_id(/*int*/ $id) { public static function by_id(/*int*/ $id) {
assert(is_numeric($id)); assert(is_numeric($id));
global $database; global $database;
@ -72,6 +91,11 @@ class User {
return is_null($row) ? null : new User($row); return is_null($row) ? null : new User($row);
} }
/**
* Construct a User by name.
* @param string $name
* @return null|User
*/
public static function by_name(/*string*/ $name) { public static function by_name(/*string*/ $name) {
assert(is_string($name)); assert(is_string($name));
global $database; global $database;
@ -79,6 +103,12 @@ class User {
return is_null($row) ? null : new User($row); return is_null($row) ? null : new User($row);
} }
/**
* Construct a User by name and hash.
* @param string $name
* @param string $hash
* @return null|User
*/
public static function by_name_and_hash(/*string*/ $name, /*string*/ $hash) { public static function by_name_and_hash(/*string*/ $name, /*string*/ $hash) {
assert(is_string($name)); assert(is_string($name));
assert(is_string($hash)); assert(is_string($hash));
@ -88,6 +118,11 @@ class User {
return is_null($row) ? null : new User($row); return is_null($row) ? null : new User($row);
} }
/**
* @param int $offset
* @param int $limit
* @return array
*/
public static function by_list(/*int*/ $offset, /*int*/ $limit=50) { public static function by_list(/*int*/ $offset, /*int*/ $limit=50) {
assert(is_numeric($offset)); assert(is_numeric($offset));
assert(is_numeric($limit)); assert(is_numeric($limit));
@ -97,8 +132,12 @@ class User {
} }
/* /* useful user object functions start here */
* useful user object functions start here
/**
* @param string $ability
* @return bool
*/ */
public function can($ability) { public function can($ability) {
return $this->class->can($ability); return $this->class->can($ability);
@ -108,7 +147,7 @@ class User {
/** /**
* Test if this user is anonymous (not logged in) * Test if this user is anonymous (not logged in)
* *
* @retval bool * @return bool
*/ */
public function is_anonymous() { public function is_anonymous() {
global $config; global $config;
@ -118,7 +157,7 @@ class User {
/** /**
* Test if this user is logged in * Test if this user is logged in
* *
* @retval bool * @return bool
*/ */
public function is_logged_in() { public function is_logged_in() {
global $config; global $config;
@ -128,12 +167,15 @@ class User {
/** /**
* Test if this user is an administrator * Test if this user is an administrator
* *
* @retval bool * @return bool
*/ */
public function is_admin() { public function is_admin() {
return ($this->class->name === "admin"); return ($this->class->name === "admin");
} }
/**
* @param string $class
*/
public function set_class(/*string*/ $class) { public function set_class(/*string*/ $class) {
assert(is_string($class)); assert(is_string($class));
global $database; global $database;
@ -141,6 +183,9 @@ class User {
log_info("core-user", 'Set class for '.$this->name.' to '.$class); log_info("core-user", 'Set class for '.$this->name.' to '.$class);
} }
/**
* @param string $password
*/
public function set_password(/*string*/ $password) { public function set_password(/*string*/ $password) {
global $database; global $database;
$hash = md5(strtolower($this->name) . $password); $hash = md5(strtolower($this->name) . $password);
@ -157,7 +202,7 @@ class User {
/** /**
* Get a snippet of HTML which will render the user's avatar, be that * Get a snippet of HTML which will render the user's avatar, be that
* a local file, a remote file, a gravatar, a something else, etc * a local file, a remote file, a gravatar, a something else, etc
* @retval String of HTML * @return String of HTML
*/ */
public function get_avatar_html() { public function get_avatar_html() {
// FIXME: configurable // FIXME: configurable
@ -186,7 +231,7 @@ class User {
* the form was generated within the session. Salted and re-hashed so that * the form was generated within the session. Salted and re-hashed so that
* reading a web page from the user's cache doesn't give access to the session key * reading a web page from the user's cache doesn't give access to the session key
* *
* @retval String containing auth token (MD5sum) * @return String containing auth token (MD5sum)
*/ */
public function get_auth_token() { public function get_auth_token() {
global $config; global $config;
@ -218,4 +263,4 @@ class MockUser extends User {
parent::__construct($row); parent::__construct($row);
} }
} }
?>

View File

@ -2,9 +2,9 @@
$_user_classes = array(); $_user_classes = array();
class UserClass { class UserClass {
var $name = null; public $name = null;
var $parent = null; public $parent = null;
var $abilities = array(); public $abilities = array();
public function __construct($name, $parent=null, $abilities=array()) { public function __construct($name, $parent=null, $abilities=array()) {
global $_user_classes; global $_user_classes;
@ -19,6 +19,13 @@ class UserClass {
$_user_classes[$name] = $this; $_user_classes[$name] = $this;
} }
/**
* Determine if this class of user can perform an action or has ability.
*
* @param string $ability
* @return bool
* @throws SCoreException
*/
public function can(/*string*/ $ability) { public function can(/*string*/ $ability) {
global $config; global $config;
@ -164,4 +171,4 @@ new UserClass("hellbanned", "user", array(
)); ));
@include_once "data/config/user-classes.conf.php"; @include_once "data/config/user-classes.conf.php";
?>

View File

@ -10,6 +10,7 @@ require_once "lib/context.php";
/** /**
* Make some data safe for printing into HTML * Make some data safe for printing into HTML
* *
* @param $input
* @return string * @return string
*/ */
function html_escape($input) { function html_escape($input) {
@ -19,6 +20,7 @@ function html_escape($input) {
/** /**
* Make sure some data is safe to be used in integer context * Make sure some data is safe to be used in integer context
* *
* @param $input
* @return int * @return int
*/ */
function int_escape($input) { function int_escape($input) {
@ -32,6 +34,7 @@ function int_escape($input) {
/** /**
* Make sure some data is safe to be used in URL context * Make sure some data is safe to be used in URL context
* *
* @param $input
* @return string * @return string
*/ */
function url_escape($input) { function url_escape($input) {
@ -66,6 +69,7 @@ function url_escape($input) {
/** /**
* Make sure some data is safe to be used in SQL context * Make sure some data is safe to be used in SQL context
* *
* @param $input
* @return string * @return string
*/ */
function sql_escape($input) { function sql_escape($input) {
@ -77,6 +81,7 @@ function sql_escape($input) {
/** /**
* Turn all manner of HTML / INI / JS / DB booleans into a PHP one * Turn all manner of HTML / INI / JS / DB booleans into a PHP one
* *
* @param $input
* @return boolean * @return boolean
*/ */
function bool_escape($input) { function bool_escape($input) {
@ -112,6 +117,7 @@ function bool_escape($input) {
* Some functions require a callback function for escaping, * Some functions require a callback function for escaping,
* but we might not want to alter the data * but we might not want to alter the data
* *
* @param $input
* @return string * @return string
*/ */
function no_escape($input) { function no_escape($input) {
@ -156,6 +162,7 @@ function truncate($string, $limit, $break=" ", $pad="...") {
/** /**
* Turn a human readable filesize into an integer, eg 1KB -> 1024 * Turn a human readable filesize into an integer, eg 1KB -> 1024
* *
* @param $limit
* @return int * @return int
*/ */
function parse_shorthand_int($limit) { function parse_shorthand_int($limit) {
@ -167,8 +174,11 @@ function parse_shorthand_int($limit) {
$value = $m[1]; $value = $m[1];
if (isset($m[2])) { if (isset($m[2])) {
switch(strtolower($m[2])) { switch(strtolower($m[2])) {
/** @noinspection PhpMissingBreakStatementInspection */
case 'g': $value *= 1024; // fall through case 'g': $value *= 1024; // fall through
/** @noinspection PhpMissingBreakStatementInspection */
case 'm': $value *= 1024; // fall through case 'm': $value *= 1024; // fall through
/** @noinspection PhpMissingBreakStatementInspection */
case 'k': $value *= 1024; break; case 'k': $value *= 1024; break;
default: $value = -1; default: $value = -1;
} }
@ -182,6 +192,7 @@ function parse_shorthand_int($limit) {
/** /**
* Turn an integer into a human readable filesize, eg 1024 -> 1KB * Turn an integer into a human readable filesize, eg 1024 -> 1KB
* *
* @param $int
* @return string * @return string
*/ */
function to_shorthand_int($int) { function to_shorthand_int($int) {
@ -203,6 +214,8 @@ function to_shorthand_int($int) {
/** /**
* Turn a date into a time, a date, an "X minutes ago...", etc * Turn a date into a time, a date, an "X minutes ago...", etc
* *
* @param $date
* @param bool $html
* @return string * @return string
*/ */
function autodate($date, $html=true) { function autodate($date, $html=true) {
@ -214,6 +227,7 @@ function autodate($date, $html=true) {
/** /**
* Check if a given string is a valid date-time. ( Format: yyyy-mm-dd hh:mm:ss ) * Check if a given string is a valid date-time. ( Format: yyyy-mm-dd hh:mm:ss )
* *
* @param $dateTime
* @return boolean * @return boolean
*/ */
function isValidDateTime($dateTime) { function isValidDateTime($dateTime) {
@ -229,6 +243,7 @@ function isValidDateTime($dateTime) {
/** /**
* Check if a given string is a valid date. ( Format: yyyy-mm-dd ) * Check if a given string is a valid date. ( Format: yyyy-mm-dd )
* *
* @param $date
* @return boolean * @return boolean
*/ */
function isValidDate($date) { function isValidDate($date) {
@ -248,6 +263,8 @@ function isValidDate($date) {
* *
* FIXME: also check that IP ban ext is installed * FIXME: also check that IP ban ext is installed
* *
* @param $ip
* @param $ban_reason
* @return string * @return string
*/ */
function show_ip($ip, $ban_reason) { function show_ip($ip, $ban_reason) {
@ -295,6 +312,8 @@ function endsWith(/*string*/ $haystack, /*string*/ $needle) {
* *
* eg make_link("post/list") becomes "/v2/index.php?q=post/list" * eg make_link("post/list") becomes "/v2/index.php?q=post/list"
* *
* @param null|string $page
* @param null|string $query
* @return string * @return string
*/ */
function make_link($page=null, $query=null) { function make_link($page=null, $query=null) {
@ -329,8 +348,9 @@ function make_link($page=null, $query=null) {
/** /**
* Take the current URL and modify some paramaters * Take the current URL and modify some parameters
* *
* @param $changes
* @return string * @return string
*/ */
function modify_current_url($changes) { function modify_current_url($changes) {
@ -372,6 +392,7 @@ function modify_url($url, $changes) {
/** /**
* Turn a relative link into an absolute one, including hostname * Turn a relative link into an absolute one, including hostname
* *
* @param string $link
* @return string * @return string
*/ */
function make_http(/*string*/ $link) { function make_http(/*string*/ $link) {
@ -385,11 +406,11 @@ function make_http(/*string*/ $link) {
/** /**
* Make a form tag with relevant auth token and stuff * Make a form tag with relevant auth token and stuff
* *
* @param target string * @param string $target
* @param method string * @param string $method
* @param multipart boolean * @param bool $multipart
* @param form_id string * @param string $form_id
* @param onsubmit string * @param string $onsubmit
* *
* @return string * @return string
*/ */
@ -412,6 +433,11 @@ function mtimefile($file) {
return "$data_href/$file?$mtime"; return "$data_href/$file?$mtime";
} }
/**
* Return the current theme as a string
*
* @return string
*/
function get_theme() { function get_theme() {
global $config; global $config;
$theme = $config->get_string("theme", "default"); $theme = $config->get_string("theme", "default");
@ -505,16 +531,18 @@ function captcha_check() {
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/** /**
* Get MIME type for file * Get MIME type for file
* *
* The contents of this function are taken from the __getMimeType() function * The contents of this function are taken from the __getMimeType() function
* from the "Amazon S3 PHP class" which is Copyright (c) 2008, Donovan Schönknecht * from the "Amazon S3 PHP class" which is Copyright (c) 2008, Donovan Schönknecht
* and released under the 'Simplified BSD License'. * and released under the 'Simplified BSD License'.
* *
* @internal Used to get mime types * @internal Used to get mime types
* @param string &$file File path * @param string &$file File path
* @return string * @param string $ext
*/ * @param bool $list
* @return string
*/
function getMimeType($file, $ext="", $list=false) { function getMimeType($file, $ext="", $list=false) {
// Static extension lookup // Static extension lookup
@ -639,6 +667,8 @@ function _count_execs($db, $sql, $inputarray) {
/** /**
* Compare two Block objects, used to sort them before being displayed * Compare two Block objects, used to sort them before being displayed
* *
* @param Block $a
* @param Block $b
* @return int * @return int
*/ */
function blockcmp(Block $a, Block $b) { function blockcmp(Block $a, Block $b) {
@ -702,6 +732,7 @@ function get_memory_limit() {
* Get the currently active IP, masked to make it not change when the last * Get the currently active IP, masked to make it not change when the last
* octet or two change, for use in session cookies and such * octet or two change, for use in session cookies and such
* *
* @param Config $config
* @return string * @return string
*/ */
function get_session_ip(Config $config) { function get_session_ip(Config $config) {
@ -788,6 +819,7 @@ function get_base_href() {
* A shorthand way to send a TextFormattingEvent and get the * A shorthand way to send a TextFormattingEvent and get the
* results * results
* *
* @param $string
* @return string * @return string
*/ */
function format_text(/*string*/ $string) { function format_text(/*string*/ $string) {
@ -867,9 +899,11 @@ function transload($url, $mfile) {
fwrite($fp, $data); fwrite($fp, $data);
fclose($fp); fclose($fp);
// Scrutinizer-ci complains that $http_response_header not defined. //
// However, it is auto defined by PHP. // Scrutinizer-ci complains that $http_response_header does not exist,
// See: http://us2.php.net/manual/en/reserved.variables.httpresponseheader.php // however, $http_response_header is actually a super-global.
// I have filed a bug with PHP-Analyzer here: https://github.com/scrutinizer-ci/php-analyzer/issues/212
//
$headers = http_parse_headers(implode("\n", $http_response_header)); $headers = http_parse_headers(implode("\n", $http_response_header));
return $headers; return $headers;
@ -1004,6 +1038,8 @@ function get_request_id() {
/** /**
* Remove an item from an array * Remove an item from an array
* *
* @param $array
* @param $to_remove
* @return array * @return array
*/ */
function array_remove($array, $to_remove) { function array_remove($array, $to_remove) {
@ -1022,6 +1058,8 @@ function array_remove($array, $to_remove) {
* *
* Also removes duplicate values from the array. * Also removes duplicate values from the array.
* *
* @param $array
* @param $element
* @return array * @return array
*/ */
function array_add($array, $element) { function array_add($array, $element) {
@ -1035,6 +1073,7 @@ function array_add($array, $element) {
/** /**
* Return the unique elements of an array, case insensitively * Return the unique elements of an array, case insensitively
* *
* @param $array
* @return array * @return array
*/ */
function array_iunique($array) { function array_iunique($array) {
@ -1058,6 +1097,8 @@ function array_iunique($array) {
* *
* from http://uk.php.net/network * from http://uk.php.net/network
* *
* @param $IP
* @param $CIDR
* @return bool * @return bool
*/ */
function ip_in_range($IP, $CIDR) { function ip_in_range($IP, $CIDR) {
@ -1118,7 +1159,7 @@ function deltree($f) {
} }
/** /**
* Copy an entire file heirachy * Copy an entire file hierarchy
* *
* from a comment on http://uk.php.net/copy * from a comment on http://uk.php.net/copy
*/ */
@ -1456,4 +1497,4 @@ function _end_coverage() {
file_put_contents("$absolute_path/$t.$n.log", gzdeflate(serialize(xdebug_get_code_coverage()))); file_put_contents("$absolute_path/$t.$n.log", gzdeflate(serialize(xdebug_get_code_coverage())));
} }
} }
?>

View File

@ -257,4 +257,4 @@ class AdminPage extends Extension {
return true; return true;
} }
} }
?>

View File

@ -80,4 +80,4 @@ class AdminPageTest extends ShimmieWebTestCase {
$this->log_out(); $this->log_out();
} }
} }
?>

View File

@ -68,4 +68,4 @@ class AdminPageTheme extends Themelet {
return $html; return $html;
} }
} }
?>

View File

@ -153,4 +153,4 @@ class AliasEditor extends Extension {
// missing out the images tagged with the oldtag // missing out the images tagged with the oldtag
public function get_priority() {return 60;} public function get_priority() {return 60;}
} }
?>

View File

@ -97,4 +97,4 @@ class AliasEditorTest extends ShimmieWebTestCase {
*/ */
} }
} }
?>

View File

@ -73,4 +73,4 @@ class AliasEditorTheme extends Themelet {
$this->display_paginator($page, "alias/list", null, $pageNumber, $totalPages); $this->display_paginator($page, "alias/list", null, $pageNumber, $totalPages);
} }
} }
?>

View File

@ -72,4 +72,4 @@ class UploadS3 extends Extension {
} }
} }
} }
?>

View File

@ -79,4 +79,4 @@ class ArrowkeyNavigation extends Extension {
return $pageinfo; return $pageinfo;
} }
} }
?>

View File

@ -1221,4 +1221,4 @@ class Artists extends Extension {
return $result; return $result;
} }
} }
?>

View File

@ -5,4 +5,4 @@ class ArtistTest extends ShimmieWebTestCase {
$this->get_page("post/list/author=bob/1"); $this->get_page("post/list/author=bob/1");
} }
} }
?>

View File

@ -514,4 +514,4 @@ class ArtistsTheme extends Themelet {
} }
} }
?>

View File

@ -101,4 +101,4 @@ xanax
public function get_priority() {return 30;} public function get_priority() {return 30;}
} }
?>

View File

@ -42,4 +42,4 @@ class BanWordsTest extends ShimmieWebTestCase {
$this->log_out(); $this->log_out();
} }
} }
?>

View File

@ -156,4 +156,4 @@ class BBCode extends FormatterExtension {
return $text; return $text;
} }
} }
?>

View File

@ -81,4 +81,4 @@ class BBCodeUnitTest extends UnitTestCase {
return $bb->strip($in); return $bb->strip($in);
} }
} }
?>

View File

@ -85,4 +85,4 @@ class Blocks extends Extension {
} }
} }
} }
?>

View File

@ -8,4 +8,4 @@ class BlocksTest extends SCoreWebTestCase {
$this->log_out(); $this->log_out();
} }
} }
?>

View File

@ -43,4 +43,4 @@ class BlocksTheme extends Themelet {
$page->add_block(new Block("Block Editor", $html)); $page->add_block(new Block("Block Editor", $html));
} }
} }
?>

View File

@ -131,4 +131,4 @@ class Blotter extends Extension {
$this->theme->display_blotter($entries); $this->theme->display_blotter($entries);
} }
} }
?>

View File

@ -1,3 +1,5 @@
/*jshint bitwise:true, curly:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
$(document).ready(function() { $(document).ready(function() {
$(".shm-blotter2-toggle").click(function() { $(".shm-blotter2-toggle").click(function() {
$(".shm-blotter2").slideToggle("slow", function() { $(".shm-blotter2").slideToggle("slow", function() {
@ -9,7 +11,7 @@ $(document).ready(function() {
} }
}); });
}); });
if($.cookie("ui-blotter2-hidden") == 'true') { if($.cookie("ui-blotter2-hidden") === 'true') {
$(".shm-blotter2").hide(); $(".shm-blotter2").hide();
} }
}); });

View File

@ -34,4 +34,4 @@ class BlotterTest extends SCoreWebTestCase {
$this->log_out(); $this->log_out();
} }
} }
?>

View File

@ -176,4 +176,4 @@ class BlotterTheme extends Themelet {
return $html; return $html;
} }
} }
?>

View File

@ -32,8 +32,7 @@ class Bookmarks extends Extension {
} }
protected function install() { protected function install() {
global $database; global $database, $config;
global $config;
// shortcut to latest // shortcut to latest
if($config->get_int("ext_bookmarks_version") < 1) { if($config->get_int("ext_bookmarks_version") < 1) {
@ -61,9 +60,9 @@ class Bookmarks extends Extension {
} }
private function add_bookmark(/*string*/ $url, /*string*/ $title) { private function add_bookmark(/*string*/ $url, /*string*/ $title) {
global $database; global $database, $user;
$sql = "INSERT INTO bookmark(owner_id, url, title) VALUES (?, ?, ?)"; $sql = "INSERT INTO bookmark(owner_id, url, title) VALUES (?, ?, ?)";
$database->Execute($sql, array($user->id, $url, $title)); $database->Execute($sql, array($user->id, $url, $title));
} }
} }
?>

View File

@ -1,4 +1,3 @@
<?php <?php
class BookmarksTest extends ShimmieWebTestCase { class BookmarksTest extends ShimmieWebTestCase {
function testBookmarks() { function testBookmarks() {
@ -6,4 +5,4 @@ class BookmarksTest extends ShimmieWebTestCase {
$this->get_page("bookmark/remove"); $this->get_page("bookmark/remove");
} }
} }
?>

View File

@ -2,4 +2,4 @@
class BookmarksTheme extends Themelet { class BookmarksTheme extends Themelet {
} }
?>

View File

@ -101,4 +101,4 @@ class BrowserSearch extends Extension {
$event->panel->add_block($sb); $event->panel->add_block($sb);
} }
} }
?>

View File

@ -5,4 +5,4 @@ class BrowserSearchTest extends SCoreWebTestCase {
$this->get_page("browser_search/test"); $this->get_page("browser_search/test");
} }
} }
?>

View File

@ -111,4 +111,4 @@ class BulkAdd extends Extension {
} }
} }
} }
?>

View File

@ -31,4 +31,4 @@ class BulkAddTest extends ShimmieWebTestCase {
$this->log_out(); $this->log_out();
} }
} }
?>

View File

@ -42,4 +42,4 @@ class BulkAddTheme extends Themelet {
$this->messages[] = new Block($title, $body); $this->messages[] = new Block($title, $body);
} }
} }
?>

View File

@ -136,4 +136,4 @@ class BulkAddCSV extends Extension {
fclose($csvhandle); fclose($csvhandle);
} }
} }
?>

View File

@ -41,4 +41,4 @@ class BulkAddCSVTheme extends Themelet {
$this->messages[] = new Block($title, $body); $this->messages[] = new Block($title, $body);
} }
} }
?>

View File

@ -130,4 +130,4 @@ class BulkRemove extends Extension {
$image_arr = $_POST["bulk_remove_images"]; $image_arr = $_POST["bulk_remove_images"];
} }
} }
?>

View File

@ -1,7 +1,11 @@
/*jshint bitwise:true, curly:true, devel:true, eqeqeq:true, evil:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
Array.prototype.inArray = function (value) { Array.prototype.inArray = function (value) {
for (var i = 0; i < this.length; i++) for (var i = 0; i < this.length; i++) {
if (this[i] === value) if (this[i] === value) {
return true; return true;
}
}
return false; return false;
}; };
@ -25,8 +29,9 @@ AdminCP.prototype = {
this.initializing = true; this.initializing = true;
this.loginForm(); this.loginForm();
this.initEvents(); this.initEvents();
if (this.loaded()) this.afterLogin(); if (this.loaded()) {
else { this.afterLogin();
} else {
$('#login-password')[0].focus(); $('#login-password')[0].focus();
} }
@ -54,10 +59,11 @@ AdminCP.prototype = {
$('.logout').click(function() { self.logout(); return false; }); $('.logout').click(function() { self.logout(); return false; });
// Show the nav // Show the nav
if (this.initializing) if (this.initializing) {
$('#nav ul').css('display', 'block'); $('#nav ul').css('display', 'block');
else } else {
$('#nav ul').slideDown(); $('#nav ul').slideDown();
}
// Some css for betterlookingness // Some css for betterlookingness
$('#preferences-form fieldset:odd').addClass('odd'); $('#preferences-form fieldset:odd').addClass('odd');
@ -75,10 +81,11 @@ AdminCP.prototype = {
// If they want to go directly to a section // If they want to go directly to a section
var anchor = this.getAnchor(); var anchor = this.getAnchor();
if (anchor.length > 0 && ['preferences', 'bans', 'about'].inArray(anchor)) if (anchor.length > 0 && ['preferences', 'bans', 'about'].inArray(anchor)) {
self.show(anchor); self.show(anchor);
else } else {
self.show('preferences'); self.show('preferences');
}
}, },
initEventsAfter: function() { initEventsAfter: function() {
@ -101,15 +108,16 @@ AdminCP.prototype = {
// Preferences // Preferences
$('#preferences-form input').keypress(function(e) { $('#preferences-form input').keypress(function(e) {
var key = window.event ? e.keyCode : e.which; var key = window.event ? e.keyCode : e.which;
if (key == 13 || key == 3) { if (key === 13 || key === 3) {
self.changePref.apply(self, [$(this).attr('rel'), this.value]); self.changePref.apply(self, [$(this).attr('rel'), this.value]);
return false; return false;
} }
}).focus(function() { }).focus(function() {
this.name = this.value; this.name = this.value;
}).blur(function() { }).blur(function() {
if (this.name != this.value) if (this.name !== this.value) {
self.changePref.apply(self, [$(this).attr('rel'), this.value]); self.changePref.apply(self, [$(this).attr('rel'), this.value]);
}
}); });
$('#preferences-form select').change(function() { $('#preferences-form select').change(function() {
@ -125,10 +133,11 @@ AdminCP.prototype = {
'value': value 'value': value
}; };
this.ajax(function(json) { this.ajax(function(json) {
if (!json.error) if (!json.error) {
this.done(); this.done();
else } else {
alert(json.error); alert(json.error);
}
}, pars); }, pars);
}, },
@ -137,20 +146,20 @@ AdminCP.prototype = {
var pars = { var pars = {
mode: 'resetpreferences' mode: 'resetpreferences'
} };
this.ajax(function(json) { this.ajax(function(json) {
this.done(); this.done();
if (json.prefs) if (json.prefs) {
for(pref in json.prefs) { for (pref in json.prefs) {
var value = json.prefs[pref]; var value = json.prefs[pref];
var el = $('#preferences-form input[@rel=' + pref + '], select[@rel=' + pref + ']')[0]; var el = $('#preferences-form input[@rel=' + pref + '], select[@rel=' + pref + ']')[0];
if (el.type == 'text') if (el.type === 'text') {
el.value = value; el.value = value;
else { } else {
if (value == true) value = 'true'; if (value === true) { value = 'true'; }
if (value == false) value = 'false'; if (value === false) { value = 'false'; }
$('#preferences-form select[@rel=' + pref + ']') $('#preferences-form select[@rel=' + pref + ']')
.find('option') .find('option')
@ -158,11 +167,10 @@ AdminCP.prototype = {
.end() .end()
.find('option[@rel=' + value + ']') .find('option[@rel=' + value + ']')
.attr('selected', 'yeah'); .attr('selected', 'yeah');
}
} }
} }
}, pars); }, pars);
}, },
invalidPassword: function() { invalidPassword: function() {
@ -230,49 +238,53 @@ AdminCP.prototype = {
// if (!sections.inArray(section)) section = 'preferences'; // if (!sections.inArray(section)) section = 'preferences';
if ($.browser.msie) { if ($.browser.msie) {
if (section == 'preferences') if (section === 'preferences') {
$('#preferences select').css('display', 'block'); $('#preferences select').css('display', 'block');
else } else {
$('#preferences select').css('display', 'none'); $('#preferences select').css('display', 'none');
} }
}
if (section === this.curSection) { return; }
if (section == this.curSection) return;
this.curSection = section; this.curSection = section;
$('#' + section)[0].style.zIndex = ++this.z; $('#' + section)[0].style.zIndex = ++this.z;
if (this.initializing)
if (this.initializing) {
$('#' + section).css('display', 'block'); $('#' + section).css('display', 'block');
else } else {
$('#' + section).fadeIn(this.animSpeed, callback); $('#' + section).fadeIn(this.animSpeed, callback);
}
}, },
showPrefPane: function(pane) { showPrefPane: function(pane) {
var self = this; var self = this;
if (pane == this.curPrefPane) return; if (pane === this.curPrefPane) { return; }
this.curPrefPane = pane; this.curPrefPane = pane;
$('#preferences .cp-pane').css('display', 'none'); $('#preferences .cp-pane').css('display', 'none');
$('#cp-pane-' + pane).css('display', 'block').fadeIn(this.animSpeed, function() { $('#cp-pane-' + pane).css('display', 'block').fadeIn(this.animSpeed, function() {
if (self.curPrefPane == pane) if (self.curPrefPane === pane) {
$('#preferences .cp-pane').not('#cp-pane-' + pane).css('display', 'none'); $('#preferences .cp-pane').not('#cp-pane-' + pane).css('display', 'none');
else } else {
$('#cp-pane-' + pane).css('display', 'none'); $('#cp-pane-' + pane).css('display', 'none');
}
}); });
}, },
showAboutPane: function(pane) { showAboutPane: function(pane) {
var self = this; var self = this;
if (pane == this.curAboutPane) return; if (pane === this.curAboutPane) { return; }
this.curAboutPane = pane; this.curAboutPane = pane;
$('#about .cp-pane').css('display', 'none'); $('#about .cp-pane').css('display', 'none');
$('#cp-pane-' + pane).css('display', 'block').fadeIn(this.animSpeed, function() { $('#cp-pane-' + pane).css('display', 'block').fadeIn(this.animSpeed, function() {
if (self.curAboutPane == pane) if (self.curAboutPane === pane) {
$('#about .cp-pane').not('#cp-pane-' + pane).css('display', 'none'); $('#about .cp-pane').not('#cp-pane-' + pane).css('display', 'none');
else } else {
$('#cp-pane-' + pane).css('display', 'none'); $('#cp-pane-' + pane).css('display', 'none');
}
}); });
}, },
@ -281,13 +293,15 @@ AdminCP.prototype = {
$.post('ajax.php', pars, function(parse) { $.post('ajax.php', pars, function(parse) {
// alert(parse); // alert(parse);
if (parse) if (parse) {
if (html) if (html) {
callback.apply(self, [parse]); callback.apply(self, [parse]);
else } else {
callback.apply(self, [self.json(parse)]); callback.apply(self, [self.json(parse)]);
else }
} else {
callback.apply(self); callback.apply(self);
}
}); });
}, },
@ -297,7 +311,7 @@ AdminCP.prototype = {
}, },
loaded: function() { loaded: function() {
return ($('#cp-loaded').length == 1); return ($('#cp-loaded').length === 1);
}, },
loading: function() { loading: function() {
@ -326,8 +340,9 @@ AdminCP.prototype = {
getAnchor: function() { getAnchor: function() {
var href = window.location.href; var href = window.location.href;
if (href.indexOf('#') > -1 ) if (href.indexOf('#') > -1 ) {
return href.substr(href.indexOf('#') + 1).toLowerCase(); return href.substr(href.indexOf('#') + 1).toLowerCase();
}
return ''; return '';
}, },
@ -357,7 +372,7 @@ AdminCP.prototype = {
var pars = { var pars = {
mode: 'unbanall' mode: 'unbanall'
} };
this.ajax(function(json) { this.ajax(function(json) {
this.done(); this.done();

View File

@ -83,7 +83,6 @@ if (isset($_POST['p'])) {
} }
?> ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
@ -109,13 +108,13 @@ if (isset($_POST['p'])) {
<div id="top"> <div id="top">
<h1>YShout.History</h1> <h1>YShout.History</h1>
<div id="controls"> <div id="controls">
<? if($admin) : ?> <?php if($admin) : ?>
<a id="clear-log" href="#">Clear this log</a>, or <a id="clear-log" href="#">Clear this log</a>, or
<a id="clear-logs" href="#">Clear all logs</a>. <a id="clear-logs" href="#">Clear all logs</a>.
<? endif; ?> <?php endif; ?>
<select id="log"> <select id="log">
<? <?php
for ($i = 1; $i <= $prefs['logs']; $i++) for ($i = 1; $i <= $prefs['logs']; $i++)
echo '<option' . ($log == $i ? ' selected' : '') . ' rel="' . $i . '">Log ' . $i . '</option>' . "\n"; echo '<option' . ($log == $i ? ' selected' : '') . ' rel="' . $i . '">Log ' . $i . '</option>' . "\n";
?> ?>

View File

@ -1,3 +1,5 @@
/*jshint bitwise:true, curly:true, devel:true, eqeqeq:true, evil:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
var History = function() { var History = function() {
var self = this; var self = this;
var args = arguments; var args = arguments;
@ -17,13 +19,11 @@ History.prototype = {
$('body').ScrollToAnchors({ duration: 800 }); $('body').ScrollToAnchors({ duration: 800 });
}, },
initEvents: function() { initEvents: function() {
var self = this; var self = this;
this.initLogEvents(); this.initLogEvents();
// Select log // Select log
$('#log').change(function() { $('#log').change(function() {
var logIndex = $(this).find('option[@selected]').attr('rel'); var logIndex = $(this).find('option[@selected]').attr('rel');
@ -31,15 +31,13 @@ History.prototype = {
var pars = { var pars = {
p: 'yes', p: 'yes',
log: logIndex log: logIndex
} };
self.ajax(function(html) { self.ajax(function(html) {
$('#ys-posts').html(html) $('#ys-posts').html(html);
$('#yshout').fadeIn(); $('#yshout').fadeIn();
self.initLogEvents(); self.initLogEvents();
}, pars, true, 'index.php'); }, pars, true, 'index.php');
}); });
// Clear the log // Clear the log
@ -56,13 +54,12 @@ History.prototype = {
self.error('You\'re not an admin. Log in through the admin CP to clear the log.'); self.error('You\'re not an admin. Log in through the admin CP to clear the log.');
el.innerHTML = 'Clear this log'; el.innerHTML = 'Clear this log';
return; return;
break;
} }
} }
$('#ys-posts').html(self.noPosts); $('#ys-posts').html(self.noPosts);
self.initLogEvents(); self.initLogEvents();
el.innerHTML = 'Clear this log' el.innerHTML = 'Clear this log';
}, pars); }, pars);
this.innerHTML = 'Clearing...'; this.innerHTML = 'Clearing...';
@ -80,16 +77,15 @@ History.prototype = {
if (json.error) { if (json.error) {
switch(json.error) { switch(json.error) {
case 'admin': case 'admin':
el.innerHTML = 'Clear all logs' el.innerHTML = 'Clear all logs';
self.error('You\'re not an admin. Log in through the admin CP to clear logs.'); self.error('You\'re not an admin. Log in through the admin CP to clear logs.');
return; return;
break;
} }
} }
$('#ys-posts').html(self.noPosts); $('#ys-posts').html(self.noPosts);
self.initLogEvents(); self.initLogEvents();
el.innerHTML = 'Clear all logs' el.innerHTML = 'Clear all logs';
}, pars); }, pars);
this.innerHTML = 'Clearing...'; this.innerHTML = 'Clearing...';
@ -115,26 +111,28 @@ History.prototype = {
showInfo: function(id, el) { showInfo: function(id, el) {
var jEl = $('#' + id + ' .ys-post-info'); var jEl = $('#' + id + ' .ys-post-info');
if (jEl.length == 0) return false; if (jEl.length === 0) { return false; }
if (this.prefsInfo == 'overlay') if (this.prefsInfo === 'overlay') {
jEl.css('display', 'block').fadeIn(this.animSpeed); jEl.css('display', 'block').fadeIn(this.animSpeed);
else } else {
jEl.slideDown(this.animSpeed); jEl.slideDown(this.animSpeed);
}
el.innerHTML ='Close Info' el.innerHTML ='Close Info';
return false; return false;
}, },
hideInfo: function(id, el) { hideInfo: function(id, el) {
var jEl = $('#' + id + ' .ys-post-info'); var jEl = $('#' + id + ' .ys-post-info');
if (jEl.length == 0) return false; if (jEl.length === 0) { return false; }
if (this.prefsInfo == 'overlay') if (this.prefsInfo === 'overlay') {
jEl.fadeOut(this.animSpeed); jEl.fadeOut(this.animSpeed);
else } else {
jEl.slideUp(this.animSpeed); jEl.slideUp(this.animSpeed);
}
el.innerHTML = 'Info'; el.innerHTML = 'Info';
return false; return false;
@ -144,7 +142,8 @@ History.prototype = {
var self = this; var self = this;
var link = $('#' + post.id).find('.ys-ban-link')[0]; var link = $('#' + post.id).find('.ys-ban-link')[0];
switch(link.innerHTML) { switch(link.innerHTML)
{
case 'Ban': case 'Ban':
var pIP = $(post).find('.ys-h-ip').html(); var pIP = $(post).find('.ys-h-ip').html();
var pNickname = $(post).find('.ys-h-nickname').html(); var pNickname = $(post).find('.ys-h-nickname').html();
@ -175,11 +174,9 @@ History.prototype = {
link.innerHTML = 'Banning...'; link.innerHTML = 'Banning...';
return false; return false;
break;
case 'Banning...': case 'Banning...':
return false; return false;
break;
case 'Unban': case 'Unban':
var pIP = $(post).find('.ys-h-ip').html(); var pIP = $(post).find('.ys-h-ip').html();
@ -194,7 +191,6 @@ History.prototype = {
case 'admin': case 'admin':
self.error('You\'re not an admin. Log in through the admin CP to unban people.'); self.error('You\'re not an admin. Log in through the admin CP to unban people.');
return; return;
break;
} }
} }
@ -207,11 +203,9 @@ History.prototype = {
link.innerHTML = 'Unbanning...'; link.innerHTML = 'Unbanning...';
return false; return false;
break;
case 'Unbanning...': case 'Unbanning...':
return false; return false;
break;
} }
}, },
@ -219,7 +213,7 @@ History.prototype = {
var self = this; var self = this;
var link = $('#' + post.id).find('.ys-delete-link')[0]; var link = $('#' + post.id).find('.ys-delete-link')[0];
if (link.innerHTML == 'Deleting...') return; if (link.innerHTML === 'Deleting...') { return; }
var pUID = $(post).find('.ys-h-uid').html(); var pUID = $(post).find('.ys-h-uid').html();
@ -234,7 +228,6 @@ History.prototype = {
case 'admin': case 'admin':
self.error('You\'re not an admin. Log in through the admin CP to ban people.'); self.error('You\'re not an admin. Log in through the admin CP to ban people.');
return; return;
break;
} }
} }
@ -260,16 +253,18 @@ History.prototype = {
var self = this; var self = this;
if (page == null) page = '../yshout.php'; if (page === null) { page = '../yshout.php'; }
$.post(page, pars, function(parse) { $.post(page, pars, function(parse) {
if (parse) if (parse) {
if (html) if (html) {
callback.apply(self, [parse]); callback.apply(self, [parse]);
else } else {
callback.apply(self, [self.json(parse)]); callback.apply(self, [self.json(parse)]);
else }
} else {
callback.apply(self); callback.apply(self);
}
}); });
}, },

View File

@ -1,3 +1,5 @@
/*jshint bitwise:true, curly:true, devel:true, eqeqeq:true, evil:true, forin:false, noarg:true, noempty:true, nonew:true, undef:true, strict:false, browser:true, jquery:true */
String.prototype.sReplace = function(find, replace) { String.prototype.sReplace = function(find, replace) {
return this.split(find).join(replace); return this.split(find).join(replace);
}; };
@ -5,7 +7,7 @@ String.prototype.sReplace = function(find, replace) {
String.prototype.repeat = function(times) { String.prototype.repeat = function(times) {
var rep = new Array(times + 1); var rep = new Array(times + 1);
return rep.join(this); return rep.join(this);
} };
var YShout = function() { var YShout = function() {
var self = this; var self = this;
@ -13,7 +15,7 @@ var YShout = function() {
$(document).ready(function() { $(document).ready(function() {
self.init.apply(self, args); self.init.apply(self, args);
}); });
} };
var yShout; var yShout;
@ -38,12 +40,14 @@ YShout.prototype = {
this.floodAttempt = 0; this.floodAttempt = 0;
// Correct for missing trailing / // Correct for missing trailing /
if ((this.options.yPath.length > 0) && (this.options.yPath.charAt(this.options.yPath.length - 1) != '/')) if ((this.options.yPath.length > 0) && (this.options.yPath.charAt(this.options.yPath.length - 1) !== '/')) {
this.options.yPath += '/'; this.options.yPath += '/';
}
if (this.options.yLink) { if (this.options.yLink) {
if (this.options.yLink.charAt(0) != '#') if (this.options.yLink.charAt(0) !== '#') {
this.options.yLink = '#' + this.options.yLink; this.options.yLink = '#' + this.options.yLink;
}
$(this.options.yLink).click(function() { $(this.options.yLink).click(function() {
self.openYShout.apply(self); self.openYShout.apply(self);
@ -59,20 +63,15 @@ YShout.prototype = {
return false; return false;
}); });
this.load(true); this.load(true);
} else } else {
this.load(); this.load();
}
}, },
load: function(hidden) { load: function(hidden) {
if ($('#yshout').length == 0) return; if ($('#yshout').length === 0) { return; }
if (hidden) $('#yshout').css('display', 'none');
if (hidden) { $('#yshout').css('display', 'none'); }
this.ajax(this.initialLoad, { this.ajax(this.initialLoad, {
reqType: 'init', reqType: 'init',
@ -83,32 +82,28 @@ YShout.prototype = {
initialLoad: function(updates) { initialLoad: function(updates) {
if (updates.yError) {
alert('There appears to be a problem: \n' + updates.yError + '\n\nIf you haven\'t already, try chmodding everything inside the YShout directory to 777.');
}
if (updates.yError) alert('There appears to be a problem: \n' + updates.yError + '\n\nIf you haven\'t already, try chmodding everything inside the YShout directory to 777.');
var self = this; var self = this;
this.prefs = jQuery.extend(updates.prefs, this.options.prefs); this.prefs = jQuery.extend(updates.prefs, this.options.prefs);
this.initForm(); this.initForm();
this.initRefresh(); this.initRefresh();
this.initLinks(); this.initLinks();
if (this.prefs.flood) this.initFlood(); if (this.prefs.flood) { this.initFlood(); }
if (updates.nickname) if (updates.nickname) {
$('#ys-input-nickname') $('#ys-input-nickname')
.removeClass('ys-before-focus') .removeClass('ys-before-focus')
.addClass( 'ys-after-focus') .addClass( 'ys-after-focus')
.val(updates.nickname); .val(updates.nickname);
}
if (updates) if (updates) {
this.updates(updates); this.updates(updates);
}
if (!this.prefs.doTruncate) { if (!this.prefs.doTruncate) {
$('#ys-posts').css('height', $('#ys-posts').height + 'px'); $('#ys-posts').css('height', $('#ys-posts').height + 'px');
@ -132,14 +127,14 @@ YShout.prototype = {
'<input id="ys-input-nickname" value="' + nickname + '" type="hidden" accesskey="N" maxlength="' + this.prefs.nicknameLength + '" class="ys-before-focus" />' + '<input id="ys-input-nickname" value="' + nickname + '" type="hidden" accesskey="N" maxlength="' + this.prefs.nicknameLength + '" class="ys-before-focus" />' +
'<input id="ys-input-message" value="' + this.prefs.defaultMessage + '" type="text" accesskey="M" maxlength="' + this.prefs.messageLength + '" class="ys-before-focus" />' + '<input id="ys-input-message" value="' + this.prefs.defaultMessage + '" type="text" accesskey="M" maxlength="' + this.prefs.messageLength + '" class="ys-before-focus" />' +
(this.prefs.showSubmit ? '<input id="ys-input-submit" value="' + this.prefs.defaultSubmit + '" accesskey="S" type="submit" />' : '') + (this.prefs.showSubmit ? '<input id="ys-input-submit" value="' + this.prefs.defaultSubmit + '" accesskey="S" type="submit" />' : '') +
(this.prefs.postFormLink == 'cp' ? '<a title="View YShout Control Panel" class="ys-post-form-link" id="ys-cp-link" href="' + this.options.yPath + 'cp/index.php">Admin CP</a>' : '') + (this.prefs.postFormLink === 'cp' ? '<a title="View YShout Control Panel" class="ys-post-form-link" id="ys-cp-link" href="' + this.options.yPath + 'cp/index.php">Admin CP</a>' : '') +
(this.prefs.postFormLink == 'history' ? '<a title="View YShout History" class="ys-post-form-link" id="ys-history-link" href="' + this.options.yPath + 'history/index.php?log=' + this.options.log + '">View History</a>' : '') + (this.prefs.postFormLink === 'history' ? '<a title="View YShout History" class="ys-post-form-link" id="ys-history-link" href="' + this.options.yPath + 'history/index.php?log=' + this.options.log + '">View History</a>' : '') +
'</fieldset></form>'; '</fieldset></form>';
var postsDiv = '<div id="ys-posts"></div>'; var postsDiv = '<div id="ys-posts"></div>';
if (this.prefs.inverse) $('#yshout').html(postForm + postsDiv); if (this.prefs.inverse) { $('#yshout').html(postForm + postsDiv); }
else $('#yshout').html(postsDiv + postForm); else { $('#yshout').html(postsDiv + postForm); }
$('#ys-posts') $('#ys-posts')
.before('<div id="ys-before-posts"></div>') .before('<div id="ys-before-posts"></div>')
@ -158,32 +153,35 @@ YShout.prototype = {
var keypress = function(e) { var keypress = function(e) {
var key = window.event ? e.keyCode : e.which; var key = window.event ? e.keyCode : e.which;
if (key == 13 || key == 3) { if (key === 13 || key === 3) {
self.send.apply(self); self.send.apply(self);
return false; return false;
} }
}; };
var focus = function() { var focus = function() {
if (this.value == defaults[this.id]) if (this.value === defaults[this.id]) {
$(this).removeClass('ys-before-focus').addClass( 'ys-after-focus').val(''); $(this).removeClass('ys-before-focus').addClass( 'ys-after-focus').val('');
}
}; };
var blur = function() { var blur = function() {
if (this.value == '') if (this.value === '') {
$(this).removeClass('ys-after-focus').addClass('ys-before-focus').val(defaults[this.id]); $(this).removeClass('ys-after-focus').addClass('ys-before-focus').val(defaults[this.id]);
}
}; };
$('#ys-input-message').keypress(keypress).focus(focus).blur(blur); $('#ys-input-message').keypress(keypress).focus(focus).blur(blur);
$('#ys-input-nickname').keypress(keypress).focus(focus).blur(blur); $('#ys-input-nickname').keypress(keypress).focus(focus).blur(blur);
$('#ys-input-submit').click(function(){ self.send.apply(self) }); $('#ys-input-submit').click(function(){ self.send.apply(self); });
$('#ys-post-form').submit(function(){ return false }); $('#ys-post-form').submit(function(){ return false; });
}, },
initRefresh: function() { initRefresh: function() {
var self = this; var self = this;
if (this.refreshTimer) clearInterval(this.refreshTimer) if (this.refreshTimer) { clearInterval(this.refreshTimer); }
this.refreshTimer = setInterval(function() { this.refreshTimer = setInterval(function() {
self.ajax(self.updates, { reqType: 'refresh' }); self.ajax(self.updates, { reqType: 'refresh' });
}, this.prefs.refresh); // ! 3000..? }, this.prefs.refresh); // ! 3000..?
@ -201,7 +199,7 @@ YShout.prototype = {
}, },
initLinks: function() { initLinks: function() {
if ($.browser.msie) return; if ($.browser.msie) { return; }
var self = this; var self = this;
@ -219,7 +217,7 @@ YShout.prototype = {
openCP: function() { openCP: function() {
var self = this; var self = this;
if (this.cpOpen) return; if (this.cpOpen) { return; }
this.cpOpen = true; this.cpOpen = true;
var url = this.options.yPath + 'cp/index.php'; var url = this.options.yPath + 'cp/index.php';
@ -247,7 +245,7 @@ YShout.prototype = {
openHistory: function() { openHistory: function() {
var self = this; var self = this;
if (this.hOpen) return; if (this.hOpen) { return; }
this.hOpen = true; this.hOpen = true;
var url = this.options.yPath + 'history/index.php?log='+ this.options.log; var url = this.options.yPath + 'history/index.php?log='+ this.options.log;
$('body').append('<div id="ys-overlay"></div><div class="ys-window" id="ys-history"><a title="Close history" href="#" id="ys-closeoverlay-link">Close</a><a title="View Admin CP" href="#" id="ys-switchoverlay-link">View Admin CP</a><object class="ys-browser" id="history-browser" data="' + url +'" type="text/html">Something went horribly wrong.</object></div>'); $('body').append('<div id="ys-overlay"></div><div class="ys-window" id="ys-history"><a title="Close history" href="#" id="ys-closeoverlay-link">Close</a><a title="View Admin CP" href="#" id="ys-switchoverlay-link">View Admin CP</a><object class="ys-browser" id="history-browser" data="' + url +'" type="text/html">Something went horribly wrong.</object></div>');
@ -273,9 +271,9 @@ YShout.prototype = {
openYShout: function() { openYShout: function() {
var self = this; var self = this;
if (this.ysOpen) return; if (this.ysOpen) { return; }
this.ysOpen = true; this.ysOpen = true;
url = this.options.yPath + 'example/yshout.html'; var url = this.options.yPath + 'example/yshout.html';
$('body').append('<div id="ys-overlay"></div><div class="ys-window" id="ys-yshout"><a title="Close YShout" href="#" id="ys-closeoverlay-link">Close</a><object class="ys-browser" id="yshout-browser" data="' + url +'" type="text/html">Something went horribly wrong.</object></div>'); $('body').append('<div id="ys-overlay"></div><div class="ys-window" id="ys-yshout"><a title="Close YShout" href="#" id="ys-closeoverlay-link">Close</a><object class="ys-browser" id="yshout-browser" data="' + url +'" type="text/html">Something went horribly wrong.</object></div>');
@ -292,25 +290,26 @@ YShout.prototype = {
}, },
send: function() { send: function() {
if (!this.validate()) return; if (!this.validate()) { return; }
if (this.prefs.flood && this.floodControl) return; if (this.prefs.flood && this.floodControl) { return; }
var postNickname = $('#ys-input-nickname').val(), postMessage = $('#ys-input-message').val(); var postNickname = $('#ys-input-nickname').val(), postMessage = $('#ys-input-message').val();
if (postMessage == '/cp') if (postMessage === '/cp') {
this.openCP(); this.openCP();
else if (postMessage == '/history') } else if (postMessage === '/history') {
this.openHistory(); this.openHistory();
else } else {
this.ajax(this.updates, { this.ajax(this.updates, {
reqType: 'post', reqType: 'post',
nickname: postNickname, nickname: postNickname,
message: postMessage message: postMessage
}); });
}
$('#ys-input-message').val('') $('#ys-input-message').val('');
if (this.prefs.flood) this.flood(); if (this.prefs.flood) { this.flood(); }
}, },
validate: function() { validate: function() {
@ -321,21 +320,23 @@ YShout.prototype = {
var showInvalid = function(input) { var showInvalid = function(input) {
$(input).removeClass('ys-input-valid').addClass('ys-input-invalid')[0].focus(); $(input).removeClass('ys-input-valid').addClass('ys-input-invalid')[0].focus();
error = true; error = true;
} };
var showValid = function(input) { var showValid = function(input) {
$(input).removeClass('ys-input-invalid').addClass('ys-input-valid'); $(input).removeClass('ys-input-invalid').addClass('ys-input-valid');
};
if (nickname === '' || nickname === this.prefs.defaultNickname) {
showInvalid('#ys-input-nickname');
} else {
showValid('#ys-input-nickname');
} }
if (nickname == '' || nickname == this.prefs.defaultNickname) if (message === '' || message === this.prefs.defaultMessage) {
showInvalid('#ys-input-nickname');
else
showValid('#ys-input-nickname');
if (message == '' || message == this.prefs.defaultMessage)
showInvalid('#ys-input-message'); showInvalid('#ys-input-message');
else } else {
showValid('#ys-input-message'); showValid('#ys-input-message');
}
return !error; return !error;
}, },
@ -351,8 +352,9 @@ YShout.prototype = {
this.floodAttempt++; this.floodAttempt++;
this.disable(); this.disable();
if (this.floodAttempt == this.prefs.autobanFlood) if (this.floodAttempt === this.prefs.autobanFlood) {
this.banSelf('You have been banned for flooding the shoutbox!'); this.banSelf('You have been banned for flooding the shoutbox!');
}
setTimeout(function() { setTimeout(function() {
self.floodCount = 0; self.floodCount = 0;
@ -371,35 +373,39 @@ YShout.prototype = {
}, },
findBySame: function(ip) { findBySame: function(ip) {
if (!$.browser.safari) return; if (!$.browser.safari) {return;}
var same = []; var same = [];
for (var i = 0; i < this.p.length; i++)
if (this.p[i].adminInfo.ip == ip)
same.push(this.p[i]);
for (var i = 0; i < same.length; i++) { for (var i = 0; i < this.p.length; i++) {
$('#' + same[i].id).fadeTo(this.animSpeed, .8).fadeTo(this.animSpeed, 1); if (this.p[i].adminInfo.ip === ip) {
same.push(this.p[i]);
}
}
for (var j = 0; j < same.length; j++) {
$('#' + same[j].id).fadeTo(this.animSpeed, 0.8).fadeTo(this.animSpeed, 1);
} }
}, },
updates: function(updates) { updates: function(updates) {
if (!updates) return; if (!updates) {return;}
if (updates.prefs) this.prefs = updates.prefs; if (updates.prefs) {this.prefs = updates.prefs;}
if (updates.posts) this.posts(updates.posts); if (updates.posts) {this.posts(updates.posts);}
if (updates.banned) this.banned(); if (updates.banned) {this.banned();}
}, },
banned: function() { banned: function() {
var self = this; var self = this;
clearInterval(this.refreshTimer); clearInterval(this.refreshTimer);
clearInterval(this.floodTimer); clearInterval(this.floodTimer);
if (this.initializing) if (this.initializing) {
$('#ys-post-form').css('display', 'none'); $('#ys-post-form').css('display', 'none');
else } else {
$('#ys-post-form').fadeOut(this.animSpeed); $('#ys-post-form').fadeOut(this.animSpeed);
}
if ($('#ys-banned').length == 0) { if ($('#ys-banned').length === 0) {
$('#ys-input-message')[0].blur(); $('#ys-input-message')[0].blur();
$('#ys-posts').append('<div id="ys-banned"><span>You\'re banned. Click <a href="#" id="ys-unban-self">here</a> to unban yourself if you\'re an admin. If you\'re not, go <a href="' + this.options.yPath + 'cp/index.php" id="ys-banned-cp-link">log in</a>!</span></div>'); $('#ys-posts').append('<div id="ys-banned"><span>You\'re banned. Click <a href="#" id="ys-unban-self">here</a> to unban yourself if you\'re an admin. If you\'re not, go <a href="' + this.options.yPath + 'cp/index.php" id="ys-banned-cp-link">log in</a>!</span></div>');
@ -410,10 +416,11 @@ YShout.prototype = {
$('#ys-unban-self').click(function() { $('#ys-unban-self').click(function() {
self.ajax(function(json) { self.ajax(function(json) {
if (!json.error) if (!json.error) {
self.unbanned(); self.unbanned();
else if (json.error == 'admin') } else if (json.error === 'admin') {
alert('You can only unban yourself if you\'re an admin.'); alert('You can only unban yourself if you\'re an admin.');
}
}, { reqType: 'unbanself' }); }, { reqType: 'unbanself' });
return false; return false;
}); });
@ -451,9 +458,9 @@ YShout.prototype = {
var d = date(ts); var d = date(ts);
var h = d.getHours(), m = d.getMinutes(); var h = d.getHours(), m = d.getMinutes();
if (self.prefs.timestamp == 12) { if (self.prefs.timestamp === 12) {
h = (h > 12 ? h - 12 : h); h = (h > 12 ? h - 12 : h);
if (h == 0) h = 12; if (h === 0) { h = 12; }
} }
return pad(h) + ':' + pad(m); return pad(h) + ':' + pad(m);
@ -487,18 +494,19 @@ YShout.prototype = {
(this.prefs.timestamp> 0 ? '<span class="ys-post-timestamp">' + time(post.timestamp) + '</span> ' : '') + (this.prefs.timestamp> 0 ? '<span class="ys-post-timestamp">' + time(post.timestamp) + '</span> ' : '') +
'<span class="ys-post-nickname">' + post.nickname + this.prefs.nicknameSeparator + '</span> ' + '<span class="ys-post-nickname">' + post.nickname + this.prefs.nicknameSeparator + '</span> ' +
'<span class="ys-post-message">' + post.message + '</span> ' + '<span class="ys-post-message">' + post.message + '</span> ' +
'<span class="ys-post-info' + (this.prefs.info == 'overlay' ? ' ys-info-overlay' : ' ys-info-inline') + '">' + (post.adminInfo ? '<em>IP:</em> ' + post.adminInfo.ip + ', ' : '') + '<em>Posted:</em> ' + dateStr(post.timestamp) + ' at ' + time(post.timestamp) + '.</span>' + '<span class="ys-post-info' + (this.prefs.info === 'overlay' ? ' ys-info-overlay' : ' ys-info-inline') + '">' + (post.adminInfo ? '<em>IP:</em> ' + post.adminInfo.ip + ', ' : '') + '<em>Posted:</em> ' + dateStr(post.timestamp) + ' at ' + time(post.timestamp) + '.</span>' +
'<span class="ys-post-actions"><a title="Show post information" class="ys-info-link" href="#">Info</a>' + (post.adminInfo ? ' | <a title="Delete post" class="ys-delete-link" href="#">Delete</a> | ' + (post.banned ? '<a title="Unban user" class="ys-ban-link" href="#">Unban</a>' : '<a title="Ban user" class="ys-ban-link" href="#">Ban</a>') : '') + '</span>' + '<span class="ys-post-actions"><a title="Show post information" class="ys-info-link" href="#">Info</a>' + (post.adminInfo ? ' | <a title="Delete post" class="ys-delete-link" href="#">Delete</a> | ' + (post.banned ? '<a title="Unban user" class="ys-ban-link" href="#">Unban</a>' : '<a title="Ban user" class="ys-ban-link" href="#">Ban</a>') : '') + '</span>' +
'</div>'; '</div>';
if (this.prefs.inverse) $('#ys-posts').prepend(html); if (this.prefs.inverse) { $('#ys-posts').prepend(html); }
else $('#ys-posts').append(html); else { $('#ys-posts').append(html); }
this.p.push(post); this.p.push(post);
$('#' + id) $('#' + id)
.find('.ys-post-nickname').click(function() { .find('.ys-post-nickname').click(function() {
if (post.adminInfo) if (post.adminInfo) {
self.findBySame(post.adminInfo.ip); self.findBySame(post.adminInfo.ip);
}
}).end() }).end()
.find('.ys-info-link').toggle( .find('.ys-info-link').toggle(
function() { self.showInfo.apply(self, [id, this]); return false; }, function() { self.showInfo.apply(self, [id, this]); return false; },
@ -514,21 +522,23 @@ YShout.prototype = {
showInfo: function(id, el) { showInfo: function(id, el) {
var jEl = $('#' + id + ' .ys-post-info'); var jEl = $('#' + id + ' .ys-post-info');
if (this.prefs.info == 'overlay') if (this.prefs.info === 'overlay') {
jEl.css('display', 'block').fadeIn(this.animSpeed); jEl.css('display', 'block').fadeIn(this.animSpeed);
else } else {
jEl.slideDown(this.animSpeed); jEl.slideDown(this.animSpeed);
}
el.innerHTML ='Close Info' el.innerHTML = 'Close Info';
return false; return false;
}, },
hideInfo: function(id, el) { hideInfo: function(id, el) {
var jEl = $('#' + id + ' .ys-post-info'); var jEl = $('#' + id + ' .ys-post-info');
if (this.prefs.info == 'overlay') if (this.prefs.info === 'overlay') {
jEl.fadeOut(this.animSpeed); jEl.fadeOut(this.animSpeed);
else } else {
jEl.slideUp(this.animSpeed); jEl.slideUp(this.animSpeed);
}
el.innerHTML = 'Info'; el.innerHTML = 'Info';
return false; return false;
@ -557,26 +567,24 @@ YShout.prototype = {
return; return;
} }
//alert('p: ' + this.p + ' / ' + this.p.length); //alert('p: ' + this.p + ' / ' + this.p.length);
if (json.bannedSelf) if (json.bannedSelf) {
self.banned(); // ? self.banned(); // ?
} else {
else
$.each(self.p, function(i) { $.each(self.p, function(i) {
if (this.adminInfo && this.adminInfo.ip == post.adminInfo.ip) if (this.adminInfo && this.adminInfo.ip === post.adminInfo.ip) {
$('#' + this.id) $('#' + this.id)
.addClass('ys-banned-post') .addClass('ys-banned-post')
.find('.ys-ban-link').html('Unban'); .find('.ys-ban-link').html('Unban');
}
}); });
}
}, pars); }, pars);
link.innerHTML = 'Banning...'; link.innerHTML = 'Banning...';
return false; return false;
break;
case 'Banning...': case 'Banning...':
return false; return false;
break;
case 'Unban': case 'Unban':
var pars = { var pars = {
@ -590,26 +598,24 @@ YShout.prototype = {
case 'admin': case 'admin':
self.error('You\'re not an admin. Log in through the Admin CP to unban people.'); self.error('You\'re not an admin. Log in through the Admin CP to unban people.');
return; return;
break;
} }
} }
$.each(self.p, function(i) { $.each(self.p, function(i) {
if (this.adminInfo && this.adminInfo.ip == post.adminInfo.ip) if (this.adminInfo && this.adminInfo.ip === post.adminInfo.ip) {
$('#' + this.id) $('#' + this.id)
.removeClass('ys-banned-post') .removeClass('ys-banned-post')
.find('.ys-ban-link').html('Ban'); .find('.ys-ban-link').html('Ban');
}
}); });
}, pars); }, pars);
link.innerHTML = 'Unbanning...'; link.innerHTML = 'Unbanning...';
return false; return false;
break;
case 'Unbanning...': case 'Unbanning...':
return false; return false;
break;
} }
}, },
@ -617,7 +623,7 @@ YShout.prototype = {
var self = this; var self = this;
var link = $('#' + id).find('.ys-delete-link')[0]; var link = $('#' + id).find('.ys-delete-link')[0];
if (link.innerHTML == 'Deleting...') return; if (link.innerHTML === 'Deleting...') { return; }
var pars = { var pars = {
reqType: 'delete', reqType: 'delete',
@ -630,7 +636,6 @@ YShout.prototype = {
case 'admin': case 'admin':
self.error('You\'re not an admin. Log in through the Admin CP to ban people.'); self.error('You\'re not an admin. Log in through the Admin CP to ban people.');
return; return;
break;
} }
} }
self.reload(); self.reload();
@ -638,15 +643,15 @@ YShout.prototype = {
link.innerHTML = 'Deleting...'; link.innerHTML = 'Deleting...';
return false; return false;
}, },
banSelf: function(reason) { banSelf: function(reason) {
var self = this; var self = this;
this.ajax(function(json) { this.ajax(function(json) {
if (json.error == false) if (json.error === false) {
self.banned(); self.banned();
}
}, { }, {
reqType: 'banself', reqType: 'banself',
nickname: $('#ys-input-nickname').val() nickname: $('#ys-input-nickname').val()
@ -710,20 +715,22 @@ YShout.prototype = {
truncate: function(clearAll) { truncate: function(clearAll) {
var truncateTo = clearAll ? 0 : this.prefs.truncate; var truncateTo = clearAll ? 0 : this.prefs.truncate;
var posts = $('#ys-posts .ys-post').length; var posts = $('#ys-posts .ys-post').length;
if (posts <= truncateTo) return; if (posts <= truncateTo) { return; }
//alert(this.initializing); //alert(this.initializing);
if (this.prefs.doTruncate || this.initializing) { if (this.prefs.doTruncate || this.initializing) {
var diff = posts - truncateTo; var diff = posts - truncateTo;
for (var i = 0; i < diff; i++) for (var i = 0; i < diff; i++) {
this.p.shift(); this.p.shift();
}
// $('#ys-posts .ys-post:gt(' + truncateTo + ')').remove(); // $('#ys-posts .ys-post:gt(' + truncateTo + ')').remove();
if (this.prefs.inverse) if (this.prefs.inverse) {
$('#ys-posts .ys-post:gt(' + (truncateTo - 1) + ')').remove(); $('#ys-posts .ys-post:gt(' + (truncateTo - 1) + ')').remove();
else } else {
$('#ys-posts .ys-post:lt(' + (posts - truncateTo) + ')').remove(); $('#ys-posts .ys-post:lt(' + (posts - truncateTo) + ')').remove();
} }
}
this.markEnds(); this.markEnds();
}, },
@ -766,11 +773,11 @@ YShout.prototype = {
json: function(parse) { json: function(parse) {
this.d('In json: ' + parse); this.d('In json: ' + parse);
var json = eval('(' + parse + ')'); var json = eval('(' + parse + ')');
if (!this.checkError(json)) return json; if (!this.checkError(json)) { return json; }
}, },
checkError: function(json) { checkError: function(json) {
if (!json.yError) return false; if (!json.yError) { return false; }
this.d('Error: ' + json.yError); this.d('Error: ' + json.yError);
return true; return true;
@ -789,10 +796,8 @@ YShout.prototype = {
dataType: html ? 'text' : 'json', dataType: html ? 'text' : 'json',
data: pars, data: pars,
success: function(parse) { success: function(parse) {
var arr = [parse]; var arr = [parse];
callback.apply(self, arr); callback.apply(self, arr);
} }
}); });
}, },

View File

@ -33,4 +33,4 @@ class Chatbox extends Extension {
$page->add_block($chatblock); $page->add_block($chatblock);
} }
} }
?>

View File

@ -1,5 +1,9 @@
<?php <?php
class AjaxCall { class AjaxCall {
public $reqType;
public $updates;
function AjaxCall($log = null) { function AjaxCall($log = null) {
header('Content-type: application/json'); header('Content-type: application/json');
session_start(); session_start();
@ -24,8 +28,10 @@
$ys = ys($_SESSION['yLog']); $ys = ys($_SESSION['yLog']);
if ($ys->banned(ip())) { $this->sendBanned(); break; } if ($ys->banned(ip())) { $this->sendBanned(); break; }
if ($post = $ys->post($nickname, $message)) // To use $post somewheres later if ($post = $ys->post($nickname, $message)) {
// To use $post somewheres later
$this->sendUpdates(); $this->sendUpdates();
}
break; break;
case 'refresh': case 'refresh':
@ -138,7 +144,6 @@
$send['error'] = false; $send['error'] = false;
echo jsonEncode($send); echo jsonEncode($send);
} }
function unbanSelf() { function unbanSelf() {
@ -235,7 +240,7 @@
} }
function clearLog() { function clearLog() {
$log = $_POST['log']; //$log = $_POST['log'];
$send = array(); $send = array();
$ys = ys($_SESSION['yLog']); $ys = ys($_SESSION['yLog']);
@ -254,10 +259,10 @@
function clearLogs() { function clearLogs() {
global $prefs; global $prefs;
$log = $_POST['log']; //$log = $_POST['log'];
$send = array(); $send = array();
$ys = ys($_SESSION['yLog']); //$ys = ys($_SESSION['yLog']);
switch(true) { switch(true) {
case !loggedIn(): case !loggedIn():
@ -276,4 +281,4 @@
} }
} }
?>

View File

@ -2,6 +2,8 @@
class FileStorage { class FileStorage {
public $shoutLog, $path, $handle;
function FileStorage($path, $shoutLog = false) { function FileStorage($path, $shoutLog = false) {
$this->shoutLog = $shoutLog; $this->shoutLog = $shoutLog;
$folder = 'logs'; $folder = 'logs';
@ -56,7 +58,6 @@ class FileStorage {
fseek($this->handle, 0); fseek($this->handle, 0);
//return stream_get_contents($this->handle); //return stream_get_contents($this->handle);
return file_get_contents($this->path); return file_get_contents($this->path);
} }
function write($contents) { function write($contents) {
@ -79,7 +80,5 @@ class FileStorage {
$this->save($default, false); $this->save($default, false);
return $default; return $default;
} }
} }
?>

View File

@ -16,8 +16,8 @@
} }
function getVar($name) { function getVar($name) {
if (isset($_POST[$name])) return $_POST[$name]; if (isset($_POST[$name])) { return $_POST[$name]; }
if (isset($_GET[$name])) return $_GET[$name]; if (isset($_GET[$name])) { return $_GET[$name]; }
return null; return null;
} }
@ -28,7 +28,7 @@
} }
function magic($s) { function magic($s) {
if (get_magic_quotes_gpc()) $s = stripslashes($s); if (get_magic_quotes_gpc()) { $s = stripslashes($s); }
return $s; return $s;
} }
@ -147,6 +147,5 @@
return $_SESSION['yLoginHash'] == md5($prefs['password']); return $_SESSION['yLoginHash'] == md5($prefs['password']);
return false; return false;
} }
?>

View File

@ -250,4 +250,3 @@ class YShout {
} }
?>

View File

@ -71,4 +71,4 @@
resetPrefs(); resetPrefs();
//loadPrefs(); //loadPrefs();
?>

View File

@ -558,4 +558,4 @@ class CommentList extends Extension {
} }
// }}} // }}}
} }
?>

View File

@ -101,4 +101,4 @@ class CommentListTest extends ShimmieWebTestCase {
$this->log_out(); $this->log_out();
} }
} }
?>

View File

@ -296,4 +296,4 @@ class CommentListTheme extends Themelet {
'; ';
} }
} }
?>

View File

@ -415,4 +415,4 @@ class CronUploader extends Extension {
file_put_contents ($log_path, $content); file_put_contents ($log_path, $content);
} }
} }
?>

View File

@ -71,4 +71,4 @@ class custom_html_headers extends Extension {
} }
} }
} }
?>

View File

@ -261,6 +261,8 @@ class DanbooruApi extends Extension {
if(($event->get_arg(1) == 'find_posts') || (($event->get_arg(1) == 'post') && ($event->get_arg(2) == 'index.xml'))) if(($event->get_arg(1) == 'find_posts') || (($event->get_arg(1) == 'post') && ($event->get_arg(2) == 'index.xml')))
{ {
$this->authenticate_user(); $this->authenticate_user();
$start = 0;
if(isset($_GET['md5'])) if(isset($_GET['md5']))
{ {
$md5list = explode(",",$_GET['md5']); $md5list = explode(",",$_GET['md5']);
@ -268,6 +270,7 @@ class DanbooruApi extends Extension {
{ {
$results[] = Image::by_hash($md5); $results[] = Image::by_hash($md5);
} }
$count = count($results);
} elseif(isset($_GET['id'])) } elseif(isset($_GET['id']))
{ {
$idlist = explode(",",$_GET['id']); $idlist = explode(",",$_GET['id']);
@ -275,6 +278,7 @@ class DanbooruApi extends Extension {
{ {
$results[] = Image::by_id($id); $results[] = Image::by_id($id);
} }
$count = count($results);
} else } else
{ {
$limit = isset($_GET['limit']) ? int_escape($_GET['limit']) : 100; $limit = isset($_GET['limit']) ? int_escape($_GET['limit']) : 100;
@ -294,7 +298,7 @@ class DanbooruApi extends Extension {
// Now we have the array $results filled with Image objects // Now we have the array $results filled with Image objects
// Let's display them // Let's display them
$xml = "<posts count=\"$count\" offset=\"$start\">\n"; $xml = "<posts count=\"{$count}\" offset=\"{$start}\">\n";
foreach($results as $img) foreach($results as $img)
{ {
// Sanity check to see if $img is really an image object // Sanity check to see if $img is really an image object
@ -435,4 +439,4 @@ class DanbooruApi extends Extension {
} }
} }
?>

View File

@ -23,4 +23,4 @@ class DanbooruApiTest extends ShimmieWebTestCase {
$this->log_out(); $this->log_out();
} }
} }
?>

View File

@ -40,4 +40,4 @@ class Downtime extends Extension {
else return false; else return false;
} }
} }
?>

View File

@ -20,4 +20,4 @@ class DowntimeTest extends SCoreWebTestCase {
$this->log_out(); $this->log_out();
} }
} }
?>

View File

@ -59,4 +59,4 @@ class DowntimeTheme extends Themelet {
EOD; EOD;
} }
} }
?>

View File

@ -32,4 +32,4 @@ class EmoticonList extends Extension {
} }
} }
} }
?>

View File

@ -19,4 +19,4 @@ class EmoticonTest extends ShimmieWebTestCase {
$this->log_out(); $this->log_out();
} }
} }
?>

View File

@ -18,4 +18,4 @@ class EmoticonListTheme extends Themelet {
$page->set_data($html); $page->set_data($html);
} }
} }
?>

View File

@ -83,4 +83,4 @@ class ET extends Extension {
return $info; return $info;
} }
} }
?>

View File

@ -7,4 +7,4 @@ class ETTest extends ShimmieWebTestCase {
$this->log_out(); $this->log_out();
} }
} }
?>

View File

@ -59,4 +59,4 @@ EOD;
return $html; return $html;
} }
} }
?>

View File

@ -199,4 +199,4 @@ class ExtManager extends Extension {
} }
} }
} }
?>

View File

@ -23,4 +23,4 @@ class ExtManagerTest extends SCoreWebTestCase {
# FIXME: test that some extensions can be added and removed? :S # FIXME: test that some extensions can be added and removed? :S
} }
} }
?>

View File

@ -136,4 +136,4 @@ class ExtManagerTheme extends Themelet {
$page->add_block(new Block("Documentation", $html)); $page->add_block(new Block("Documentation", $html));
} }
} }
?>

View File

@ -196,4 +196,4 @@ class Favorites extends Extension {
array("image_id"=>$image->id)); array("image_id"=>$image->id));
} }
} }
?>

View File

@ -30,4 +30,4 @@ class FavoritesTest extends ShimmieWebTestCase {
$this->log_out(); $this->log_out();
} }
} }
?>

View File

@ -35,4 +35,4 @@ class FavoritesTheme extends Themelet {
} }
} }
?>

View File

@ -86,4 +86,4 @@ class Featured extends Extension {
} }
} }
} }
?>

View File

@ -30,4 +30,4 @@ class FeaturedTest extends ShimmieWebTestCase {
$this->assert_no_text("Featured Image"); $this->assert_no_text("Featured Image");
} }
} }
?>

View File

@ -34,4 +34,4 @@ class FeaturedTheme extends Themelet {
"; ";
} }
} }
?>

View File

@ -412,4 +412,4 @@ class Forum extends Extension {
} }
} }
} }
?>

View File

@ -229,4 +229,4 @@ class ForumTheme extends Themelet {
return $html; return $html;
} }
} }
?>

View File

@ -35,4 +35,4 @@ class google_analytics extends Extension {
} }
} }
} }
?>

View File

@ -50,4 +50,4 @@ class Handle404 extends Extension {
public function get_priority() {return 99;} public function get_priority() {return 99;}
} }
?>

View File

@ -10,4 +10,4 @@ class Handle404Test extends SCoreWebTestCase {
$this->assert_response(200); $this->assert_response(200);
} }
} }
?>

View File

@ -110,4 +110,4 @@ class ArchiveFileHandler extends Extension {
// $this->theme->add_status("Adding $subdir", $list); // $this->theme->add_status("Adding $subdir", $list);
} }
} }
?>

View File

@ -46,4 +46,4 @@ class FlashFileHandler extends DataHandlerExtension {
return true; return true;
} }
} }
?>

View File

@ -23,4 +23,4 @@ class FlashFileHandlerTheme extends Themelet {
$page->add_block(new Block("Flash Animation", $html, "main", 10)); $page->add_block(new Block("Flash Animation", $html, "main", 10));
} }
} }
?>

View File

@ -107,4 +107,4 @@ class IcoFileHandler extends Extension {
return true; return true;
} }
} }
?>

View File

@ -17,4 +17,4 @@ class IcoHandlerTest extends ShimmieWebTestCase {
# FIXME: test that it gets displayed properly # FIXME: test that it gets displayed properly
} }
} }
?>

View File

@ -9,4 +9,4 @@ class IcoFileHandlerTheme extends Themelet {
$page->add_block(new Block("Image", $html, "main", 10)); $page->add_block(new Block("Image", $html, "main", 10));
} }
} }
?>

View File

@ -59,4 +59,4 @@ class MP3FileHandler extends DataHandlerExtension {
return FALSE; return FALSE;
} }
} }
?>

View File

@ -20,4 +20,4 @@ class MP3FileHandlerTheme extends Themelet {
$page->add_block(new Block("Music", $html, "main", 10)); $page->add_block(new Block("Music", $html, "main", 10));
} }
} }
?>

View File

@ -177,4 +177,4 @@ class PixelFileHandler extends DataHandlerExtension {
} }
// }}} // }}}
} }
?>

View File

@ -14,4 +14,4 @@ class PixelHandlerTest extends ShimmieWebTestCase {
# FIXME: test that it gets displayed properly # FIXME: test that it gets displayed properly
} }
} }
?>

View File

@ -31,4 +31,4 @@ class PixelFileHandlerTheme extends Themelet {
$page->add_block(new Block("Image", $html, "main", 10)); $page->add_block(new Block("Image", $html, "main", 10));
} }
} }
?>

View File

@ -103,4 +103,4 @@ class MiniSVGParser {
function endElement($parser, $name) { function endElement($parser, $name) {
} }
} }
?>

Some files were not shown because too many files have changed in this diff Show More