commit
e9d8ae7f5b
@ -3,4 +3,4 @@ imports:
|
||||
- php
|
||||
|
||||
filter:
|
||||
excluded_paths: [lib/*,ext/chatbox/js/jquery.js]
|
||||
excluded_paths: [lib/*,ext/tagger/script.js]
|
||||
|
@ -1,10 +1,18 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Class BaseThemelet
|
||||
*
|
||||
* A collection of common functions for theme parts
|
||||
*/
|
||||
class BaseThemelet {
|
||||
|
||||
/**
|
||||
* Generic error message display
|
||||
*
|
||||
* @param int $code
|
||||
* @param string $title
|
||||
* @param string $message
|
||||
*/
|
||||
public function display_error(/*int*/ $code, /*string*/ $title, /*string*/ $message) {
|
||||
global $page;
|
||||
@ -24,7 +32,6 @@ class BaseThemelet {
|
||||
$page->add_block(new Block("Error", $message));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* A specific, common error message
|
||||
*/
|
||||
@ -36,6 +43,9 @@ class BaseThemelet {
|
||||
/**
|
||||
* Generic thumbnail code; returns HTML rather than adding
|
||||
* a block since thumbs tend to go inside blocks...
|
||||
*
|
||||
* @param Image $image
|
||||
* @return string
|
||||
*/
|
||||
public function build_thumb_html(Image $image) {
|
||||
global $config;
|
||||
@ -56,18 +66,23 @@ class BaseThemelet {
|
||||
|
||||
$custom_classes = "";
|
||||
if(class_exists("Relationships")){
|
||||
if($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', 'parent_id') && $image->parent_id !== NULL){ $custom_classes .= "shm-thumb-has_parent "; }
|
||||
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'>".
|
||||
"<img id='thumb_$i_id' title='$h_tip' alt='$h_tip' height='{$tsize[1]}' width='{$tsize[0]}' src='$h_thumb_link'>".
|
||||
"</a>\n";
|
||||
"<img id='thumb_$i_id' title='$h_tip' alt='$h_tip' height='{$tsize[1]}' width='{$tsize[0]}' src='$h_thumb_link'>".
|
||||
"</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) {
|
||||
if($total_pages == 0) $total_pages = 1;
|
||||
@ -75,11 +90,28 @@ class BaseThemelet {
|
||||
$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) {
|
||||
$link = make_link($base_url.'/'.$page, $query);
|
||||
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) {
|
||||
$paginator = "";
|
||||
if($page == $current_page) $paginator .= "<b>";
|
||||
@ -87,7 +119,16 @@ class BaseThemelet {
|
||||
if($page == $current_page) $paginator .= "</b>";
|
||||
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) {
|
||||
$next = $current_page + 1;
|
||||
$prev = $current_page - 1;
|
||||
@ -115,4 +156,4 @@ class BaseThemelet {
|
||||
.'<br><< '.$pages_html.' >>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -6,39 +6,48 @@ class Block {
|
||||
/**
|
||||
* The block's title
|
||||
*
|
||||
* @retval string
|
||||
* @var string
|
||||
*/
|
||||
var $header;
|
||||
public $header;
|
||||
|
||||
/**
|
||||
* The content
|
||||
*
|
||||
* @retval string
|
||||
* @var string
|
||||
*/
|
||||
var $body;
|
||||
public $body;
|
||||
|
||||
/**
|
||||
* Where the block should be placed. The default theme supports
|
||||
* "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
|
||||
* numbers appear lower. The scale is 0-100 by convention,
|
||||
* 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) {
|
||||
$this->header = $header;
|
||||
$this->body = $body;
|
||||
@ -47,6 +56,12 @@ class Block {
|
||||
$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) {
|
||||
$h = $this->header;
|
||||
$b = $this->body;
|
||||
@ -71,4 +86,4 @@ class NavBlock extends Block {
|
||||
parent::__construct("Navigation", "<a href='".make_link()."'>Index</a>", "left", 0);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -224,4 +224,4 @@ class MockConfig extends HardcodeConfig {
|
||||
parent::__construct($config);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -45,7 +45,7 @@ class ImgQuerylet {
|
||||
// }}}
|
||||
// {{{ db engines
|
||||
class DBEngine {
|
||||
var $name = null;
|
||||
public $name = null;
|
||||
|
||||
public function init($db) {}
|
||||
|
||||
@ -58,7 +58,7 @@ class DBEngine {
|
||||
}
|
||||
}
|
||||
class MySQL extends DBEngine {
|
||||
var $name = "mysql";
|
||||
public $name = "mysql";
|
||||
|
||||
public function init($db) {
|
||||
$db->exec("SET NAMES utf8;");
|
||||
@ -84,7 +84,7 @@ class MySQL extends DBEngine {
|
||||
}
|
||||
}
|
||||
class PostgreSQL extends DBEngine {
|
||||
var $name = "pgsql";
|
||||
public $name = "pgsql";
|
||||
|
||||
public function init($db) {
|
||||
$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); }
|
||||
|
||||
class SQLite extends DBEngine {
|
||||
var $name = "sqlite";
|
||||
public $name = "sqlite";
|
||||
|
||||
public function init($db) {
|
||||
ini_set('sqlite.assoc_case', 0);
|
||||
@ -553,4 +553,4 @@ class MockDatabase extends Database {
|
||||
public function create_table($name, $def) {}
|
||||
public function connect_engine() {}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -4,17 +4,17 @@ class Email {
|
||||
/**
|
||||
* A generic email.
|
||||
*/
|
||||
var $to;
|
||||
var $subject;
|
||||
var $header;
|
||||
var $style;
|
||||
var $header_img;
|
||||
var $sitename;
|
||||
var $sitedomain;
|
||||
var $siteemail;
|
||||
var $date;
|
||||
var $body;
|
||||
var $footer;
|
||||
public $to;
|
||||
public $subject;
|
||||
public $header;
|
||||
public $style;
|
||||
public $header_img;
|
||||
public $sitename;
|
||||
public $sitedomain;
|
||||
public $siteemail;
|
||||
public $date;
|
||||
public $body;
|
||||
public $footer;
|
||||
|
||||
public function __construct($to, $subject, $header, $body) {
|
||||
global $config;
|
||||
@ -116,4 +116,4 @@ Copyright (C) <a href="'.$this->sitedomain.'">'.$this->sitename.'</a><br />
|
||||
return $sent;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -26,10 +26,13 @@ class InitExtEvent extends Event {}
|
||||
* $event->get_arg(0) = "42"
|
||||
*/
|
||||
class PageRequestEvent extends Event {
|
||||
var $args;
|
||||
var $arg_count;
|
||||
var $part_count;
|
||||
public $args;
|
||||
public $arg_count;
|
||||
public $part_count;
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*/
|
||||
public function __construct($path) {
|
||||
global $config;
|
||||
|
||||
@ -63,7 +66,8 @@ class PageRequestEvent extends Event {
|
||||
*
|
||||
* If it matches, store the remaining path elements in $args
|
||||
*
|
||||
* @retval bool
|
||||
* @param string $name
|
||||
* @return bool
|
||||
*/
|
||||
public function page_matches(/*string*/ $name) {
|
||||
$parts = explode("/", $name);
|
||||
@ -84,8 +88,9 @@ class PageRequestEvent extends Event {
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
$offset = $this->part_count + $n;
|
||||
@ -99,7 +104,7 @@ class PageRequestEvent extends Event {
|
||||
|
||||
/**
|
||||
* Returns the number of arguments the page request has.
|
||||
* @retval int
|
||||
* @return int
|
||||
*/
|
||||
public function count_args() {
|
||||
return (int)($this->arg_count - $this->part_count);
|
||||
@ -108,6 +113,10 @@ class PageRequestEvent extends Event {
|
||||
/*
|
||||
* Many things use these functions
|
||||
*/
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function get_search_terms() {
|
||||
$search_terms = array();
|
||||
if($this->count_args() === 2) {
|
||||
@ -115,6 +124,10 @@ class PageRequestEvent extends Event {
|
||||
}
|
||||
return $search_terms;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function get_page_number() {
|
||||
$page_number = 1;
|
||||
if($this->count_args() === 1) {
|
||||
@ -126,6 +139,10 @@ class PageRequestEvent extends Event {
|
||||
if($page_number === 0) $page_number = 1; // invalid -> 0
|
||||
return $page_number;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function get_page_size() {
|
||||
global $config;
|
||||
return $config->get_int('index_images');
|
||||
@ -227,28 +244,28 @@ class LogEvent extends Event {
|
||||
/**
|
||||
* a category, normally the extension name
|
||||
*
|
||||
* @retval string
|
||||
* @return string
|
||||
*/
|
||||
var $section;
|
||||
|
||||
/**
|
||||
* See python...
|
||||
*
|
||||
* @retval int
|
||||
* @return int
|
||||
*/
|
||||
var $priority = 0;
|
||||
|
||||
/**
|
||||
* Free text to be logged
|
||||
*
|
||||
* @retval text
|
||||
* @return text
|
||||
*/
|
||||
var $message;
|
||||
|
||||
/**
|
||||
* The time that the event was created
|
||||
*
|
||||
* @retval int
|
||||
* @return int
|
||||
*/
|
||||
var $time;
|
||||
|
||||
@ -265,4 +282,4 @@ class LogEvent extends Event {
|
||||
$this->time = time();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -8,4 +8,12 @@ class SCoreException extends Exception {}
|
||||
* A fairly common, generic exception
|
||||
*/
|
||||
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 {}
|
||||
|
@ -81,7 +81,7 @@
|
||||
*/
|
||||
abstract class Extension {
|
||||
/** this theme's Themelet object */
|
||||
var $theme;
|
||||
public $theme;
|
||||
|
||||
/** @private */
|
||||
var $_child;
|
||||
@ -220,15 +220,18 @@ abstract class DataHandlerExtension extends Extension {
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
public function onSetupBuilding(SetupBuildingEvent $event) {
|
||||
$sb = $this->setup();
|
||||
if($sb) $event->panel->add_block($sb);
|
||||
}
|
||||
|
||||
protected function setup() {}
|
||||
*/
|
||||
|
||||
abstract protected function supported_ext($ext);
|
||||
abstract protected function check_contents($tmpname);
|
||||
abstract protected function create_image_from_data($filename, $metadata);
|
||||
abstract protected function create_thumb($hash);
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -36,14 +36,14 @@ require_once "lib/flexihash.php";
|
||||
* sound file, or any other supported upload type.
|
||||
*/
|
||||
class Image {
|
||||
var $id = null;
|
||||
var $height, $width;
|
||||
var $hash, $filesize;
|
||||
var $filename, $ext;
|
||||
var $owner_ip;
|
||||
var $posted;
|
||||
var $source;
|
||||
var $locked;
|
||||
public $id = null;
|
||||
public $height, $width;
|
||||
public $hash, $filesize;
|
||||
public $filename, $ext;
|
||||
public $owner_id, $owner_ip;
|
||||
public $posted, $posted_timestamp;
|
||||
public $source;
|
||||
public $locked;
|
||||
|
||||
/**
|
||||
* One will very rarely construct an image directly, more common
|
||||
@ -54,7 +54,7 @@ class Image {
|
||||
foreach($row as $name => $value) {
|
||||
// some databases use table.name rather than 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->locked = bool_escape($this->locked);
|
||||
@ -68,7 +68,8 @@ class Image {
|
||||
/**
|
||||
* Find an image by ID
|
||||
*
|
||||
* @retval Image
|
||||
* @param int $id
|
||||
* @return Image
|
||||
*/
|
||||
public static function by_id(/*int*/ $id) {
|
||||
assert(is_numeric($id));
|
||||
@ -80,7 +81,8 @@ class Image {
|
||||
/**
|
||||
* Find an image by hash
|
||||
*
|
||||
* @retval Image
|
||||
* @param string $hash
|
||||
* @return Image
|
||||
*/
|
||||
public static function by_hash(/*string*/ $hash) {
|
||||
assert(is_string($hash));
|
||||
@ -92,7 +94,8 @@ class Image {
|
||||
/**
|
||||
* Pick a random image out of a set
|
||||
*
|
||||
* @retval Image
|
||||
* @param array $tags
|
||||
* @return Image
|
||||
*/
|
||||
public static function by_random($tags=array()) {
|
||||
assert(is_array($tags));
|
||||
@ -107,7 +110,11 @@ class Image {
|
||||
/**
|
||||
* 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()) {
|
||||
assert(is_numeric($start));
|
||||
@ -145,6 +152,9 @@ class Image {
|
||||
|
||||
/**
|
||||
* Count the number of image results for a given search
|
||||
*
|
||||
* @param array $tags
|
||||
* @return mixed
|
||||
*/
|
||||
public static function count_images($tags=array()) {
|
||||
assert(is_array($tags));
|
||||
@ -174,6 +184,9 @@ class Image {
|
||||
|
||||
/**
|
||||
* Count the number of pages for a given search
|
||||
*
|
||||
* @param array $tags
|
||||
* @return float
|
||||
*/
|
||||
public static function count_pages($tags=array()) {
|
||||
assert(is_array($tags));
|
||||
@ -192,7 +205,9 @@ class Image {
|
||||
* Rather than simply $this_id + 1, one must take into account
|
||||
* deleted images and search queries
|
||||
*
|
||||
* @retval Image
|
||||
* @param array $tags
|
||||
* @param bool $next
|
||||
* @return Image
|
||||
*/
|
||||
public function get_next($tags=array(), $next=true) {
|
||||
assert(is_array($tags));
|
||||
@ -224,7 +239,8 @@ class Image {
|
||||
/**
|
||||
* The reverse of get_next
|
||||
*
|
||||
* @retval Image
|
||||
* @param array $tags
|
||||
* @return Image
|
||||
*/
|
||||
public function get_prev($tags=array()) {
|
||||
return $this->get_next($tags, false);
|
||||
@ -233,14 +249,16 @@ class Image {
|
||||
/**
|
||||
* Find the User who owns this Image
|
||||
*
|
||||
* @retval User
|
||||
* @return User
|
||||
*/
|
||||
public function get_owner() {
|
||||
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) {
|
||||
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() {
|
||||
return Tag::implode($this->get_tag_array());
|
||||
@ -271,7 +291,7 @@ class Image {
|
||||
/**
|
||||
* Get the URL for the full size image
|
||||
*
|
||||
* @retval string
|
||||
* @return string
|
||||
*/
|
||||
public function get_image_link() {
|
||||
global $config;
|
||||
@ -296,7 +316,7 @@ class Image {
|
||||
* Get a short link to the full size image
|
||||
*
|
||||
* @deprecated
|
||||
* @retval string
|
||||
* @return string
|
||||
*/
|
||||
public function get_short_link() {
|
||||
global $config;
|
||||
@ -306,7 +326,7 @@ class Image {
|
||||
/**
|
||||
* Get the URL for the thumbnail
|
||||
*
|
||||
* @retval string
|
||||
* @return string
|
||||
*/
|
||||
public function get_thumb_link() {
|
||||
global $config;
|
||||
@ -331,7 +351,7 @@ class Image {
|
||||
* Get the tooltip for this image, formatted according to the
|
||||
* configured template
|
||||
*
|
||||
* @retval string
|
||||
* @return string
|
||||
*/
|
||||
public function get_tooltip() {
|
||||
global $config;
|
||||
@ -360,7 +380,7 @@ class Image {
|
||||
/**
|
||||
* Figure out where the full size image is on disk
|
||||
*
|
||||
* @retval string
|
||||
* @return string
|
||||
*/
|
||||
public function get_image_filename() {
|
||||
return warehouse_path("images", $this->hash);
|
||||
@ -369,7 +389,7 @@ class Image {
|
||||
/**
|
||||
* Figure out where the thumbnail is on disk
|
||||
*
|
||||
* @retval string
|
||||
* @return string
|
||||
*/
|
||||
public function get_thumb_filename() {
|
||||
return warehouse_path("thumbs", $this->hash);
|
||||
@ -378,7 +398,7 @@ class Image {
|
||||
/**
|
||||
* Get the original filename
|
||||
*
|
||||
* @retval string
|
||||
* @return string
|
||||
*/
|
||||
public function get_filename() {
|
||||
return $this->filename;
|
||||
@ -387,7 +407,7 @@ class Image {
|
||||
/**
|
||||
* Get the image's mime type
|
||||
*
|
||||
* @retval string
|
||||
* @return string
|
||||
*/
|
||||
public function get_mime_type() {
|
||||
return getMimeType($this->get_image_filename(), $this->get_ext());
|
||||
@ -396,7 +416,7 @@ class Image {
|
||||
/**
|
||||
* Get the image's filename extension
|
||||
*
|
||||
* @retval string
|
||||
* @return string
|
||||
*/
|
||||
public function get_ext() {
|
||||
return $this->ext;
|
||||
@ -405,7 +425,7 @@ class Image {
|
||||
/**
|
||||
* Get the image's source URL
|
||||
*
|
||||
* @retval string
|
||||
* @return string
|
||||
*/
|
||||
public function get_source() {
|
||||
return $this->source;
|
||||
@ -413,6 +433,8 @@ class Image {
|
||||
|
||||
/**
|
||||
* Set the image's source URL
|
||||
*
|
||||
* @param string $new_source
|
||||
*/
|
||||
public function set_source(/*string*/ $new_source) {
|
||||
global $database;
|
||||
@ -426,7 +448,7 @@ class Image {
|
||||
|
||||
/**
|
||||
* Check if the image is locked.
|
||||
* @retval bool
|
||||
* @return bool
|
||||
*/
|
||||
public function is_locked() {
|
||||
return $this->locked;
|
||||
@ -542,7 +564,9 @@ class Image {
|
||||
/**
|
||||
* Someone please explain this
|
||||
*
|
||||
* @retval string
|
||||
* @param $tmpl
|
||||
* @param string $_escape
|
||||
* @return string
|
||||
*/
|
||||
public function parse_link_template($tmpl, $_escape="url_escape") {
|
||||
global $config;
|
||||
@ -682,8 +706,8 @@ class Image {
|
||||
else {
|
||||
$expansions = Tag::resolve_wildcard($term);
|
||||
if($expansions && $positive) $positive_tag_count++;
|
||||
foreach($expansions as $term) {
|
||||
$tag_querylets[] = new TagQuerylet($term, $positive);
|
||||
foreach($expansions as $expanded_term) {
|
||||
$tag_querylets[] = new TagQuerylet($expanded_term, $positive);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -966,6 +990,9 @@ class Image {
|
||||
class Tag {
|
||||
/**
|
||||
* Remove any excess fluff from a user-input tag
|
||||
*
|
||||
* @param string $tag
|
||||
* @return mixed
|
||||
*/
|
||||
public static function sanitise($tag) {
|
||||
assert(is_string($tag));
|
||||
@ -1005,6 +1032,10 @@ class Tag {
|
||||
return $tag_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $tags
|
||||
* @return string
|
||||
*/
|
||||
public static function implode($tags) {
|
||||
assert(is_string($tags) || is_array($tags));
|
||||
|
||||
@ -1019,6 +1050,10 @@ class Tag {
|
||||
return $tags;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $tag
|
||||
* @return string
|
||||
*/
|
||||
public static function resolve_alias($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
|
||||
*
|
||||
* @param $tags Array of tags
|
||||
* @return Array of tags
|
||||
* @param array $tags Array of tags
|
||||
* @return array of tags
|
||||
*/
|
||||
public static function resolve_aliases($tags) {
|
||||
assert(is_array($tags));
|
||||
@ -1104,7 +1139,7 @@ class Tag {
|
||||
|
||||
/**
|
||||
* 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) {
|
||||
$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
|
||||
*
|
||||
* @param int $orig_width
|
||||
* @param int $orig_height
|
||||
* @return array
|
||||
*/
|
||||
function get_thumbnail_size(/*int*/ $orig_width, /*int*/ $orig_height) {
|
||||
global $config;
|
||||
@ -1143,4 +1182,4 @@ function get_thumbnail_size(/*int*/ $orig_width, /*int*/ $orig_height) {
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
@ -251,11 +251,11 @@ class Page {
|
||||
$data_href = get_base_href();
|
||||
$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
|
||||
$this->add_html_header("<link rel='icon' type='image/x-icon' href='$data_href/favicon.ico'>");
|
||||
$this->add_html_header("<link rel='apple-touch-icon' href='$data_href/apple-touch-icon.png'>");
|
||||
$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'>", 42);
|
||||
|
||||
$css_files = array();
|
||||
$css_latest = 0;
|
||||
@ -275,7 +275,7 @@ class Page {
|
||||
}
|
||||
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_latest = 0;
|
||||
@ -291,10 +291,10 @@ class Page {
|
||||
}
|
||||
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 {
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -46,4 +46,5 @@ _d("EXTRA_EXTS", ""); // optional extra extensions
|
||||
*/
|
||||
_d("SCORE_VERSION", 's2hack/'.VERSION); // string SCore version
|
||||
_d("ENABLED_EXTS", CORE_EXTS.",".EXTRA_EXTS);
|
||||
?>
|
||||
|
||||
|
||||
|
@ -8,16 +8,23 @@ function _new_user($row) {
|
||||
/**
|
||||
* 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 {
|
||||
var $id;
|
||||
var $name;
|
||||
var $email;
|
||||
var $join_date;
|
||||
var $passhash;
|
||||
/** @var int */
|
||||
public $id;
|
||||
|
||||
/* @var UserClass */
|
||||
/** @var string */
|
||||
public $name;
|
||||
|
||||
/** @var string */
|
||||
public $email;
|
||||
|
||||
public $join_date;
|
||||
|
||||
public $passhash;
|
||||
|
||||
/** @var UserClass */
|
||||
var $class;
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
@ -44,6 +51,13 @@ class User {
|
||||
$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) {
|
||||
global $config, $database;
|
||||
$row = $database->cache->get("user-session-$name-$session");
|
||||
@ -60,6 +74,11 @@ class User {
|
||||
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) {
|
||||
assert(is_numeric($id));
|
||||
global $database;
|
||||
@ -72,6 +91,11 @@ class User {
|
||||
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) {
|
||||
assert(is_string($name));
|
||||
global $database;
|
||||
@ -79,6 +103,12 @@ class User {
|
||||
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) {
|
||||
assert(is_string($name));
|
||||
assert(is_string($hash));
|
||||
@ -88,6 +118,11 @@ class User {
|
||||
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) {
|
||||
assert(is_numeric($offset));
|
||||
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) {
|
||||
return $this->class->can($ability);
|
||||
@ -108,7 +147,7 @@ class User {
|
||||
/**
|
||||
* Test if this user is anonymous (not logged in)
|
||||
*
|
||||
* @retval bool
|
||||
* @return bool
|
||||
*/
|
||||
public function is_anonymous() {
|
||||
global $config;
|
||||
@ -118,7 +157,7 @@ class User {
|
||||
/**
|
||||
* Test if this user is logged in
|
||||
*
|
||||
* @retval bool
|
||||
* @return bool
|
||||
*/
|
||||
public function is_logged_in() {
|
||||
global $config;
|
||||
@ -128,12 +167,15 @@ class User {
|
||||
/**
|
||||
* Test if this user is an administrator
|
||||
*
|
||||
* @retval bool
|
||||
* @return bool
|
||||
*/
|
||||
public function is_admin() {
|
||||
return ($this->class->name === "admin");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $class
|
||||
*/
|
||||
public function set_class(/*string*/ $class) {
|
||||
assert(is_string($class));
|
||||
global $database;
|
||||
@ -141,6 +183,9 @@ class User {
|
||||
log_info("core-user", 'Set class for '.$this->name.' to '.$class);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $password
|
||||
*/
|
||||
public function set_password(/*string*/ $password) {
|
||||
global $database;
|
||||
$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
|
||||
* 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() {
|
||||
// FIXME: configurable
|
||||
@ -186,7 +231,7 @@ class User {
|
||||
* 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
|
||||
*
|
||||
* @retval String containing auth token (MD5sum)
|
||||
* @return String containing auth token (MD5sum)
|
||||
*/
|
||||
public function get_auth_token() {
|
||||
global $config;
|
||||
@ -218,4 +263,4 @@ class MockUser extends User {
|
||||
parent::__construct($row);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -2,9 +2,9 @@
|
||||
$_user_classes = array();
|
||||
|
||||
class UserClass {
|
||||
var $name = null;
|
||||
var $parent = null;
|
||||
var $abilities = array();
|
||||
public $name = null;
|
||||
public $parent = null;
|
||||
public $abilities = array();
|
||||
|
||||
public function __construct($name, $parent=null, $abilities=array()) {
|
||||
global $_user_classes;
|
||||
@ -19,6 +19,13 @@ class UserClass {
|
||||
$_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) {
|
||||
global $config;
|
||||
|
||||
@ -164,4 +171,4 @@ new UserClass("hellbanned", "user", array(
|
||||
));
|
||||
|
||||
@include_once "data/config/user-classes.conf.php";
|
||||
?>
|
||||
|
||||
|
@ -10,6 +10,7 @@ require_once "lib/context.php";
|
||||
/**
|
||||
* Make some data safe for printing into HTML
|
||||
*
|
||||
* @param $input
|
||||
* @return string
|
||||
*/
|
||||
function html_escape($input) {
|
||||
@ -19,6 +20,7 @@ function html_escape($input) {
|
||||
/**
|
||||
* Make sure some data is safe to be used in integer context
|
||||
*
|
||||
* @param $input
|
||||
* @return int
|
||||
*/
|
||||
function int_escape($input) {
|
||||
@ -32,6 +34,7 @@ function int_escape($input) {
|
||||
/**
|
||||
* Make sure some data is safe to be used in URL context
|
||||
*
|
||||
* @param $input
|
||||
* @return string
|
||||
*/
|
||||
function url_escape($input) {
|
||||
@ -66,6 +69,7 @@ function url_escape($input) {
|
||||
/**
|
||||
* Make sure some data is safe to be used in SQL context
|
||||
*
|
||||
* @param $input
|
||||
* @return string
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param $input
|
||||
* @return boolean
|
||||
*/
|
||||
function bool_escape($input) {
|
||||
@ -112,6 +117,7 @@ function bool_escape($input) {
|
||||
* Some functions require a callback function for escaping,
|
||||
* but we might not want to alter the data
|
||||
*
|
||||
* @param $input
|
||||
* @return string
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param $limit
|
||||
* @return int
|
||||
*/
|
||||
function parse_shorthand_int($limit) {
|
||||
@ -167,8 +174,11 @@ function parse_shorthand_int($limit) {
|
||||
$value = $m[1];
|
||||
if (isset($m[2])) {
|
||||
switch(strtolower($m[2])) {
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case 'g': $value *= 1024; // fall through
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case 'm': $value *= 1024; // fall through
|
||||
/** @noinspection PhpMissingBreakStatementInspection */
|
||||
case 'k': $value *= 1024; break;
|
||||
default: $value = -1;
|
||||
}
|
||||
@ -182,6 +192,7 @@ function parse_shorthand_int($limit) {
|
||||
/**
|
||||
* Turn an integer into a human readable filesize, eg 1024 -> 1KB
|
||||
*
|
||||
* @param $int
|
||||
* @return string
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @param $date
|
||||
* @param bool $html
|
||||
* @return string
|
||||
*/
|
||||
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 )
|
||||
*
|
||||
* @param $dateTime
|
||||
* @return boolean
|
||||
*/
|
||||
function isValidDateTime($dateTime) {
|
||||
@ -229,6 +243,7 @@ function isValidDateTime($dateTime) {
|
||||
/**
|
||||
* Check if a given string is a valid date. ( Format: yyyy-mm-dd )
|
||||
*
|
||||
* @param $date
|
||||
* @return boolean
|
||||
*/
|
||||
function isValidDate($date) {
|
||||
@ -248,6 +263,8 @@ function isValidDate($date) {
|
||||
*
|
||||
* FIXME: also check that IP ban ext is installed
|
||||
*
|
||||
* @param $ip
|
||||
* @param $ban_reason
|
||||
* @return string
|
||||
*/
|
||||
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"
|
||||
*
|
||||
* @param null|string $page
|
||||
* @param null|string $query
|
||||
* @return string
|
||||
*/
|
||||
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
|
||||
*/
|
||||
function modify_current_url($changes) {
|
||||
@ -372,6 +392,7 @@ function modify_url($url, $changes) {
|
||||
/**
|
||||
* Turn a relative link into an absolute one, including hostname
|
||||
*
|
||||
* @param string $link
|
||||
* @return string
|
||||
*/
|
||||
function make_http(/*string*/ $link) {
|
||||
@ -385,11 +406,11 @@ function make_http(/*string*/ $link) {
|
||||
/**
|
||||
* Make a form tag with relevant auth token and stuff
|
||||
*
|
||||
* @param target string
|
||||
* @param method string
|
||||
* @param multipart boolean
|
||||
* @param form_id string
|
||||
* @param onsubmit string
|
||||
* @param string $target
|
||||
* @param string $method
|
||||
* @param bool $multipart
|
||||
* @param string $form_id
|
||||
* @param string $onsubmit
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
@ -412,6 +433,11 @@ function mtimefile($file) {
|
||||
return "$data_href/$file?$mtime";
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the current theme as a string
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_theme() {
|
||||
global $config;
|
||||
$theme = $config->get_string("theme", "default");
|
||||
@ -505,16 +531,18 @@ function captcha_check() {
|
||||
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
/**
|
||||
* Get MIME type for file
|
||||
*
|
||||
* 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
|
||||
* and released under the 'Simplified BSD License'.
|
||||
*
|
||||
* @internal Used to get mime types
|
||||
* @param string &$file File path
|
||||
* @return string
|
||||
*/
|
||||
* Get MIME type for file
|
||||
*
|
||||
* 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
|
||||
* and released under the 'Simplified BSD License'.
|
||||
*
|
||||
* @internal Used to get mime types
|
||||
* @param string &$file File path
|
||||
* @param string $ext
|
||||
* @param bool $list
|
||||
* @return string
|
||||
*/
|
||||
function getMimeType($file, $ext="", $list=false) {
|
||||
|
||||
// Static extension lookup
|
||||
@ -639,6 +667,8 @@ function _count_execs($db, $sql, $inputarray) {
|
||||
/**
|
||||
* Compare two Block objects, used to sort them before being displayed
|
||||
*
|
||||
* @param Block $a
|
||||
* @param Block $b
|
||||
* @return int
|
||||
*/
|
||||
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
|
||||
* octet or two change, for use in session cookies and such
|
||||
*
|
||||
* @param Config $config
|
||||
* @return string
|
||||
*/
|
||||
function get_session_ip(Config $config) {
|
||||
@ -788,6 +819,7 @@ function get_base_href() {
|
||||
* A shorthand way to send a TextFormattingEvent and get the
|
||||
* results
|
||||
*
|
||||
* @param $string
|
||||
* @return string
|
||||
*/
|
||||
function format_text(/*string*/ $string) {
|
||||
@ -867,9 +899,11 @@ function transload($url, $mfile) {
|
||||
fwrite($fp, $data);
|
||||
fclose($fp);
|
||||
|
||||
// Scrutinizer-ci complains that $http_response_header not defined.
|
||||
// However, it is auto defined by PHP.
|
||||
// See: http://us2.php.net/manual/en/reserved.variables.httpresponseheader.php
|
||||
//
|
||||
// Scrutinizer-ci complains that $http_response_header does not exist,
|
||||
// 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));
|
||||
|
||||
return $headers;
|
||||
@ -1004,6 +1038,8 @@ function get_request_id() {
|
||||
/**
|
||||
* Remove an item from an array
|
||||
*
|
||||
* @param $array
|
||||
* @param $to_remove
|
||||
* @return array
|
||||
*/
|
||||
function array_remove($array, $to_remove) {
|
||||
@ -1022,6 +1058,8 @@ function array_remove($array, $to_remove) {
|
||||
*
|
||||
* Also removes duplicate values from the array.
|
||||
*
|
||||
* @param $array
|
||||
* @param $element
|
||||
* @return array
|
||||
*/
|
||||
function array_add($array, $element) {
|
||||
@ -1035,6 +1073,7 @@ function array_add($array, $element) {
|
||||
/**
|
||||
* Return the unique elements of an array, case insensitively
|
||||
*
|
||||
* @param $array
|
||||
* @return array
|
||||
*/
|
||||
function array_iunique($array) {
|
||||
@ -1058,6 +1097,8 @@ function array_iunique($array) {
|
||||
*
|
||||
* from http://uk.php.net/network
|
||||
*
|
||||
* @param $IP
|
||||
* @param $CIDR
|
||||
* @return bool
|
||||
*/
|
||||
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
|
||||
*/
|
||||
@ -1456,4 +1497,4 @@ function _end_coverage() {
|
||||
file_put_contents("$absolute_path/$t.$n.log", gzdeflate(serialize(xdebug_get_code_coverage())));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -257,4 +257,4 @@ class AdminPage extends Extension {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -80,4 +80,4 @@ class AdminPageTest extends ShimmieWebTestCase {
|
||||
$this->log_out();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -68,4 +68,4 @@ class AdminPageTheme extends Themelet {
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -153,4 +153,4 @@ class AliasEditor extends Extension {
|
||||
// missing out the images tagged with the oldtag
|
||||
public function get_priority() {return 60;}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -97,4 +97,4 @@ class AliasEditorTest extends ShimmieWebTestCase {
|
||||
*/
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -73,4 +73,4 @@ class AliasEditorTheme extends Themelet {
|
||||
$this->display_paginator($page, "alias/list", null, $pageNumber, $totalPages);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -72,4 +72,4 @@ class UploadS3 extends Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -79,4 +79,4 @@ class ArrowkeyNavigation extends Extension {
|
||||
return $pageinfo;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -1221,4 +1221,4 @@ class Artists extends Extension {
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -5,4 +5,4 @@ class ArtistTest extends ShimmieWebTestCase {
|
||||
$this->get_page("post/list/author=bob/1");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -514,4 +514,4 @@ class ArtistsTheme extends Themelet {
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -101,4 +101,4 @@ xanax
|
||||
|
||||
public function get_priority() {return 30;}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -42,4 +42,4 @@ class BanWordsTest extends ShimmieWebTestCase {
|
||||
$this->log_out();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -156,4 +156,4 @@ class BBCode extends FormatterExtension {
|
||||
return $text;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -81,4 +81,4 @@ class BBCodeUnitTest extends UnitTestCase {
|
||||
return $bb->strip($in);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -85,4 +85,4 @@ class Blocks extends Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -8,4 +8,4 @@ class BlocksTest extends SCoreWebTestCase {
|
||||
$this->log_out();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -43,4 +43,4 @@ class BlocksTheme extends Themelet {
|
||||
$page->add_block(new Block("Block Editor", $html));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -131,4 +131,4 @@ class Blotter extends Extension {
|
||||
$this->theme->display_blotter($entries);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -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() {
|
||||
$(".shm-blotter2-toggle").click(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();
|
||||
}
|
||||
});
|
||||
|
@ -34,4 +34,4 @@ class BlotterTest extends SCoreWebTestCase {
|
||||
$this->log_out();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -176,4 +176,4 @@ class BlotterTheme extends Themelet {
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -32,8 +32,7 @@ class Bookmarks extends Extension {
|
||||
}
|
||||
|
||||
protected function install() {
|
||||
global $database;
|
||||
global $config;
|
||||
global $database, $config;
|
||||
|
||||
// shortcut to latest
|
||||
if($config->get_int("ext_bookmarks_version") < 1) {
|
||||
@ -61,9 +60,9 @@ class Bookmarks extends Extension {
|
||||
}
|
||||
|
||||
private function add_bookmark(/*string*/ $url, /*string*/ $title) {
|
||||
global $database;
|
||||
global $database, $user;
|
||||
$sql = "INSERT INTO bookmark(owner_id, url, title) VALUES (?, ?, ?)";
|
||||
$database->Execute($sql, array($user->id, $url, $title));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -1,4 +1,3 @@
|
||||
|
||||
<?php
|
||||
class BookmarksTest extends ShimmieWebTestCase {
|
||||
function testBookmarks() {
|
||||
@ -6,4 +5,4 @@ class BookmarksTest extends ShimmieWebTestCase {
|
||||
$this->get_page("bookmark/remove");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -2,4 +2,4 @@
|
||||
|
||||
class BookmarksTheme extends Themelet {
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -101,4 +101,4 @@ class BrowserSearch extends Extension {
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -5,4 +5,4 @@ class BrowserSearchTest extends SCoreWebTestCase {
|
||||
$this->get_page("browser_search/test");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -111,4 +111,4 @@ class BulkAdd extends Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -31,4 +31,4 @@ class BulkAddTest extends ShimmieWebTestCase {
|
||||
$this->log_out();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -42,4 +42,4 @@ class BulkAddTheme extends Themelet {
|
||||
$this->messages[] = new Block($title, $body);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -136,4 +136,4 @@ class BulkAddCSV extends Extension {
|
||||
fclose($csvhandle);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -41,4 +41,4 @@ class BulkAddCSVTheme extends Themelet {
|
||||
$this->messages[] = new Block($title, $body);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -130,4 +130,4 @@ class BulkRemove extends Extension {
|
||||
$image_arr = $_POST["bulk_remove_images"];
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -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) {
|
||||
for (var i = 0; i < this.length; i++)
|
||||
if (this[i] === value)
|
||||
for (var i = 0; i < this.length; i++) {
|
||||
if (this[i] === value) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
@ -25,8 +29,9 @@ AdminCP.prototype = {
|
||||
this.initializing = true;
|
||||
this.loginForm();
|
||||
this.initEvents();
|
||||
if (this.loaded()) this.afterLogin();
|
||||
else {
|
||||
if (this.loaded()) {
|
||||
this.afterLogin();
|
||||
} else {
|
||||
$('#login-password')[0].focus();
|
||||
}
|
||||
|
||||
@ -54,10 +59,11 @@ AdminCP.prototype = {
|
||||
$('.logout').click(function() { self.logout(); return false; });
|
||||
|
||||
// Show the nav
|
||||
if (this.initializing)
|
||||
if (this.initializing) {
|
||||
$('#nav ul').css('display', 'block');
|
||||
else
|
||||
} else {
|
||||
$('#nav ul').slideDown();
|
||||
}
|
||||
|
||||
// Some css for betterlookingness
|
||||
$('#preferences-form fieldset:odd').addClass('odd');
|
||||
@ -75,10 +81,11 @@ AdminCP.prototype = {
|
||||
// If they want to go directly to a section
|
||||
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);
|
||||
else
|
||||
} else {
|
||||
self.show('preferences');
|
||||
}
|
||||
},
|
||||
|
||||
initEventsAfter: function() {
|
||||
@ -101,15 +108,16 @@ AdminCP.prototype = {
|
||||
// Preferences
|
||||
$('#preferences-form input').keypress(function(e) {
|
||||
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]);
|
||||
return false;
|
||||
}
|
||||
}).focus(function() {
|
||||
this.name = this.value;
|
||||
}).blur(function() {
|
||||
if (this.name != this.value)
|
||||
if (this.name !== this.value) {
|
||||
self.changePref.apply(self, [$(this).attr('rel'), this.value]);
|
||||
}
|
||||
});
|
||||
|
||||
$('#preferences-form select').change(function() {
|
||||
@ -125,10 +133,11 @@ AdminCP.prototype = {
|
||||
'value': value
|
||||
};
|
||||
this.ajax(function(json) {
|
||||
if (!json.error)
|
||||
if (!json.error) {
|
||||
this.done();
|
||||
else
|
||||
} else {
|
||||
alert(json.error);
|
||||
}
|
||||
}, pars);
|
||||
},
|
||||
|
||||
@ -137,20 +146,20 @@ AdminCP.prototype = {
|
||||
|
||||
var pars = {
|
||||
mode: 'resetpreferences'
|
||||
}
|
||||
};
|
||||
|
||||
this.ajax(function(json) {
|
||||
this.done();
|
||||
if (json.prefs)
|
||||
for(pref in json.prefs) {
|
||||
if (json.prefs) {
|
||||
for (pref in json.prefs) {
|
||||
var value = json.prefs[pref];
|
||||
var el = $('#preferences-form input[@rel=' + pref + '], select[@rel=' + pref + ']')[0];
|
||||
|
||||
if (el.type == 'text')
|
||||
if (el.type === 'text') {
|
||||
el.value = value;
|
||||
else {
|
||||
if (value == true) value = 'true';
|
||||
if (value == false) value = 'false';
|
||||
} else {
|
||||
if (value === true) { value = 'true'; }
|
||||
if (value === false) { value = 'false'; }
|
||||
|
||||
$('#preferences-form select[@rel=' + pref + ']')
|
||||
.find('option')
|
||||
@ -158,11 +167,10 @@ AdminCP.prototype = {
|
||||
.end()
|
||||
.find('option[@rel=' + value + ']')
|
||||
.attr('selected', 'yeah');
|
||||
|
||||
}
|
||||
}
|
||||
}, pars);
|
||||
|
||||
}
|
||||
}, pars);
|
||||
},
|
||||
|
||||
invalidPassword: function() {
|
||||
@ -230,49 +238,53 @@ AdminCP.prototype = {
|
||||
// if (!sections.inArray(section)) section = 'preferences';
|
||||
|
||||
if ($.browser.msie) {
|
||||
if (section == 'preferences')
|
||||
if (section === 'preferences') {
|
||||
$('#preferences select').css('display', 'block');
|
||||
else
|
||||
} else {
|
||||
$('#preferences select').css('display', 'none');
|
||||
}
|
||||
}
|
||||
|
||||
if (section == this.curSection) return;
|
||||
if (section === this.curSection) { return; }
|
||||
|
||||
this.curSection = section;
|
||||
|
||||
$('#' + section)[0].style.zIndex = ++this.z;
|
||||
if (this.initializing)
|
||||
|
||||
if (this.initializing) {
|
||||
$('#' + section).css('display', 'block');
|
||||
else
|
||||
} else {
|
||||
$('#' + section).fadeIn(this.animSpeed, callback);
|
||||
}
|
||||
},
|
||||
|
||||
showPrefPane: function(pane) {
|
||||
var self = this;
|
||||
|
||||
if (pane == this.curPrefPane) return;
|
||||
if (pane === this.curPrefPane) { return; }
|
||||
this.curPrefPane = pane;
|
||||
$('#preferences .cp-pane').css('display', 'none');
|
||||
$('#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');
|
||||
else
|
||||
} else {
|
||||
$('#cp-pane-' + pane).css('display', 'none');
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
showAboutPane: function(pane) {
|
||||
var self = this;
|
||||
|
||||
if (pane == this.curAboutPane) return;
|
||||
if (pane === this.curAboutPane) { return; }
|
||||
this.curAboutPane = pane;
|
||||
$('#about .cp-pane').css('display', 'none');
|
||||
$('#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');
|
||||
else
|
||||
} else {
|
||||
$('#cp-pane-' + pane).css('display', 'none');
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@ -281,13 +293,15 @@ AdminCP.prototype = {
|
||||
|
||||
$.post('ajax.php', pars, function(parse) {
|
||||
// alert(parse);
|
||||
if (parse)
|
||||
if (html)
|
||||
if (parse) {
|
||||
if (html) {
|
||||
callback.apply(self, [parse]);
|
||||
else
|
||||
} else {
|
||||
callback.apply(self, [self.json(parse)]);
|
||||
else
|
||||
}
|
||||
} else {
|
||||
callback.apply(self);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
@ -297,7 +311,7 @@ AdminCP.prototype = {
|
||||
},
|
||||
|
||||
loaded: function() {
|
||||
return ($('#cp-loaded').length == 1);
|
||||
return ($('#cp-loaded').length === 1);
|
||||
},
|
||||
|
||||
loading: function() {
|
||||
@ -325,10 +339,11 @@ AdminCP.prototype = {
|
||||
},
|
||||
|
||||
getAnchor: function() {
|
||||
var href = window.location.href;
|
||||
if (href.indexOf('#') > -1 )
|
||||
return href.substr(href.indexOf('#') + 1).toLowerCase();
|
||||
return '';
|
||||
var href = window.location.href;
|
||||
if (href.indexOf('#') > -1 ) {
|
||||
return href.substr(href.indexOf('#') + 1).toLowerCase();
|
||||
}
|
||||
return '';
|
||||
},
|
||||
|
||||
unban: function(ip, el) {
|
||||
@ -357,7 +372,7 @@ AdminCP.prototype = {
|
||||
|
||||
var pars = {
|
||||
mode: 'unbanall'
|
||||
}
|
||||
};
|
||||
|
||||
this.ajax(function(json) {
|
||||
this.done();
|
||||
|
@ -83,7 +83,6 @@ if (isset($_POST['p'])) {
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
@ -109,13 +108,13 @@ if (isset($_POST['p'])) {
|
||||
<div id="top">
|
||||
<h1>YShout.History</h1>
|
||||
<div id="controls">
|
||||
<? if($admin) : ?>
|
||||
<?php if($admin) : ?>
|
||||
<a id="clear-log" href="#">Clear this log</a>, or
|
||||
<a id="clear-logs" href="#">Clear all logs</a>.
|
||||
<? endif; ?>
|
||||
<?php endif; ?>
|
||||
|
||||
<select id="log">
|
||||
<?
|
||||
<?php
|
||||
for ($i = 1; $i <= $prefs['logs']; $i++)
|
||||
echo '<option' . ($log == $i ? ' selected' : '') . ' rel="' . $i . '">Log ' . $i . '</option>' . "\n";
|
||||
?>
|
||||
|
@ -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 self = this;
|
||||
var args = arguments;
|
||||
@ -17,13 +19,11 @@ History.prototype = {
|
||||
$('body').ScrollToAnchors({ duration: 800 });
|
||||
},
|
||||
|
||||
|
||||
initEvents: function() {
|
||||
var self = this;
|
||||
|
||||
this.initLogEvents();
|
||||
|
||||
|
||||
// Select log
|
||||
$('#log').change(function() {
|
||||
var logIndex = $(this).find('option[@selected]').attr('rel');
|
||||
@ -31,15 +31,13 @@ History.prototype = {
|
||||
var pars = {
|
||||
p: 'yes',
|
||||
log: logIndex
|
||||
}
|
||||
};
|
||||
|
||||
self.ajax(function(html) {
|
||||
$('#ys-posts').html(html)
|
||||
$('#ys-posts').html(html);
|
||||
$('#yshout').fadeIn();
|
||||
self.initLogEvents();
|
||||
}, pars, true, 'index.php');
|
||||
|
||||
|
||||
});
|
||||
|
||||
// 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.');
|
||||
el.innerHTML = 'Clear this log';
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$('#ys-posts').html(self.noPosts);
|
||||
self.initLogEvents();
|
||||
el.innerHTML = 'Clear this log'
|
||||
el.innerHTML = 'Clear this log';
|
||||
}, pars);
|
||||
|
||||
this.innerHTML = 'Clearing...';
|
||||
@ -80,16 +77,15 @@ History.prototype = {
|
||||
if (json.error) {
|
||||
switch(json.error) {
|
||||
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.');
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$('#ys-posts').html(self.noPosts);
|
||||
self.initLogEvents();
|
||||
el.innerHTML = 'Clear all logs'
|
||||
el.innerHTML = 'Clear all logs';
|
||||
}, pars);
|
||||
|
||||
this.innerHTML = 'Clearing...';
|
||||
@ -115,27 +111,29 @@ History.prototype = {
|
||||
showInfo: function(id, el) {
|
||||
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);
|
||||
else
|
||||
} else {
|
||||
jEl.slideDown(this.animSpeed);
|
||||
}
|
||||
|
||||
el.innerHTML ='Close Info'
|
||||
el.innerHTML ='Close Info';
|
||||
return false;
|
||||
},
|
||||
|
||||
hideInfo: function(id, el) {
|
||||
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);
|
||||
else
|
||||
} else {
|
||||
jEl.slideUp(this.animSpeed);
|
||||
|
||||
}
|
||||
|
||||
el.innerHTML = 'Info';
|
||||
return false;
|
||||
},
|
||||
@ -144,7 +142,8 @@ History.prototype = {
|
||||
var self = this;
|
||||
var link = $('#' + post.id).find('.ys-ban-link')[0];
|
||||
|
||||
switch(link.innerHTML) {
|
||||
switch(link.innerHTML)
|
||||
{
|
||||
case 'Ban':
|
||||
var pIP = $(post).find('.ys-h-ip').html();
|
||||
var pNickname = $(post).find('.ys-h-nickname').html();
|
||||
@ -175,11 +174,9 @@ History.prototype = {
|
||||
|
||||
link.innerHTML = 'Banning...';
|
||||
return false;
|
||||
break;
|
||||
|
||||
case 'Banning...':
|
||||
return false;
|
||||
break;
|
||||
|
||||
case 'Unban':
|
||||
var pIP = $(post).find('.ys-h-ip').html();
|
||||
@ -194,7 +191,6 @@ History.prototype = {
|
||||
case 'admin':
|
||||
self.error('You\'re not an admin. Log in through the admin CP to unban people.');
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,11 +203,9 @@ History.prototype = {
|
||||
|
||||
link.innerHTML = 'Unbanning...';
|
||||
return false;
|
||||
break;
|
||||
|
||||
case 'Unbanning...':
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
@ -219,7 +213,7 @@ History.prototype = {
|
||||
var self = this;
|
||||
|
||||
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();
|
||||
|
||||
@ -234,7 +228,6 @@ History.prototype = {
|
||||
case 'admin':
|
||||
self.error('You\'re not an admin. Log in through the admin CP to ban people.');
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -260,16 +253,18 @@ History.prototype = {
|
||||
|
||||
var self = this;
|
||||
|
||||
if (page == null) page = '../yshout.php';
|
||||
if (page === null) { page = '../yshout.php'; }
|
||||
|
||||
$.post(page, pars, function(parse) {
|
||||
if (parse)
|
||||
if (html)
|
||||
if (parse) {
|
||||
if (html) {
|
||||
callback.apply(self, [parse]);
|
||||
else
|
||||
} else {
|
||||
callback.apply(self, [self.json(parse)]);
|
||||
else
|
||||
}
|
||||
} else {
|
||||
callback.apply(self);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
|
@ -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) {
|
||||
return this.split(find).join(replace);
|
||||
};
|
||||
@ -5,7 +7,7 @@ String.prototype.sReplace = function(find, replace) {
|
||||
String.prototype.repeat = function(times) {
|
||||
var rep = new Array(times + 1);
|
||||
return rep.join(this);
|
||||
}
|
||||
};
|
||||
|
||||
var YShout = function() {
|
||||
var self = this;
|
||||
@ -13,7 +15,7 @@ var YShout = function() {
|
||||
$(document).ready(function() {
|
||||
self.init.apply(self, args);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
var yShout;
|
||||
|
||||
@ -35,15 +37,17 @@ YShout.prototype = {
|
||||
this.options = jQuery.extend(dOptions, options);
|
||||
|
||||
this.postNum = 0;
|
||||
this.floodAttempt = 0;
|
||||
this.floodAttempt = 0;
|
||||
|
||||
// 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 += '/';
|
||||
}
|
||||
|
||||
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).click(function() {
|
||||
self.openYShout.apply(self);
|
||||
@ -59,21 +63,16 @@ YShout.prototype = {
|
||||
return false;
|
||||
});
|
||||
this.load(true);
|
||||
} else
|
||||
} else {
|
||||
this.load();
|
||||
|
||||
|
||||
}
|
||||
},
|
||||
|
||||
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, {
|
||||
reqType: 'init',
|
||||
yPath: this.options.yPath,
|
||||
@ -83,32 +82,28 @@ YShout.prototype = {
|
||||
|
||||
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.');
|
||||
|
||||
|
||||
|
||||
var self = this;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
this.prefs = jQuery.extend(updates.prefs, this.options.prefs);
|
||||
this.initForm();
|
||||
this.initRefresh();
|
||||
this.initLinks();
|
||||
if (this.prefs.flood) this.initFlood();
|
||||
if (this.prefs.flood) { this.initFlood(); }
|
||||
|
||||
if (updates.nickname)
|
||||
if (updates.nickname) {
|
||||
$('#ys-input-nickname')
|
||||
.removeClass('ys-before-focus')
|
||||
.addClass( 'ys-after-focus')
|
||||
.val(updates.nickname);
|
||||
}
|
||||
|
||||
if (updates)
|
||||
if (updates) {
|
||||
this.updates(updates);
|
||||
|
||||
}
|
||||
|
||||
if (!this.prefs.doTruncate) {
|
||||
$('#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-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.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 === '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>' : '') +
|
||||
'</fieldset></form>';
|
||||
|
||||
var postsDiv = '<div id="ys-posts"></div>';
|
||||
|
||||
if (this.prefs.inverse) $('#yshout').html(postForm + postsDiv);
|
||||
else $('#yshout').html(postsDiv + postForm);
|
||||
if (this.prefs.inverse) { $('#yshout').html(postForm + postsDiv); }
|
||||
else { $('#yshout').html(postsDiv + postForm); }
|
||||
|
||||
$('#ys-posts')
|
||||
.before('<div id="ys-before-posts"></div>')
|
||||
@ -158,32 +153,35 @@ YShout.prototype = {
|
||||
|
||||
var keypress = function(e) {
|
||||
var key = window.event ? e.keyCode : e.which;
|
||||
if (key == 13 || key == 3) {
|
||||
if (key === 13 || key === 3) {
|
||||
self.send.apply(self);
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
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('');
|
||||
}
|
||||
};
|
||||
|
||||
var blur = function() {
|
||||
if (this.value == '')
|
||||
$(this).removeClass('ys-after-focus').addClass('ys-before-focus').val(defaults[this.id]);
|
||||
if (this.value === '') {
|
||||
$(this).removeClass('ys-after-focus').addClass('ys-before-focus').val(defaults[this.id]);
|
||||
}
|
||||
};
|
||||
|
||||
$('#ys-input-message').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-post-form').submit(function(){ return false });
|
||||
$('#ys-input-submit').click(function(){ self.send.apply(self); });
|
||||
$('#ys-post-form').submit(function(){ return false; });
|
||||
},
|
||||
|
||||
initRefresh: function() {
|
||||
var self = this;
|
||||
if (this.refreshTimer) clearInterval(this.refreshTimer)
|
||||
if (this.refreshTimer) { clearInterval(this.refreshTimer); }
|
||||
|
||||
this.refreshTimer = setInterval(function() {
|
||||
self.ajax(self.updates, { reqType: 'refresh' });
|
||||
}, this.prefs.refresh); // ! 3000..?
|
||||
@ -201,7 +199,7 @@ YShout.prototype = {
|
||||
},
|
||||
|
||||
initLinks: function() {
|
||||
if ($.browser.msie) return;
|
||||
if ($.browser.msie) { return; }
|
||||
|
||||
var self = this;
|
||||
|
||||
@ -219,7 +217,7 @@ YShout.prototype = {
|
||||
|
||||
openCP: function() {
|
||||
var self = this;
|
||||
if (this.cpOpen) return;
|
||||
if (this.cpOpen) { return; }
|
||||
this.cpOpen = true;
|
||||
|
||||
var url = this.options.yPath + 'cp/index.php';
|
||||
@ -247,7 +245,7 @@ YShout.prototype = {
|
||||
|
||||
openHistory: function() {
|
||||
var self = this;
|
||||
if (this.hOpen) return;
|
||||
if (this.hOpen) { return; }
|
||||
this.hOpen = true;
|
||||
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>');
|
||||
@ -273,9 +271,9 @@ YShout.prototype = {
|
||||
|
||||
openYShout: function() {
|
||||
var self = this;
|
||||
if (this.ysOpen) return;
|
||||
if (this.ysOpen) { return; }
|
||||
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>');
|
||||
|
||||
@ -292,25 +290,26 @@ YShout.prototype = {
|
||||
},
|
||||
|
||||
send: function() {
|
||||
if (!this.validate()) return;
|
||||
if (this.prefs.flood && this.floodControl) return;
|
||||
if (!this.validate()) { return; }
|
||||
if (this.prefs.flood && this.floodControl) { return; }
|
||||
|
||||
var postNickname = $('#ys-input-nickname').val(), postMessage = $('#ys-input-message').val();
|
||||
|
||||
if (postMessage == '/cp')
|
||||
if (postMessage === '/cp') {
|
||||
this.openCP();
|
||||
else if (postMessage == '/history')
|
||||
} else if (postMessage === '/history') {
|
||||
this.openHistory();
|
||||
else
|
||||
} else {
|
||||
this.ajax(this.updates, {
|
||||
reqType: 'post',
|
||||
nickname: postNickname,
|
||||
message: postMessage
|
||||
});
|
||||
}
|
||||
|
||||
$('#ys-input-message').val('')
|
||||
$('#ys-input-message').val('');
|
||||
|
||||
if (this.prefs.flood) this.flood();
|
||||
if (this.prefs.flood) { this.flood(); }
|
||||
},
|
||||
|
||||
validate: function() {
|
||||
@ -321,21 +320,23 @@ YShout.prototype = {
|
||||
var showInvalid = function(input) {
|
||||
$(input).removeClass('ys-input-valid').addClass('ys-input-invalid')[0].focus();
|
||||
error = true;
|
||||
}
|
||||
};
|
||||
|
||||
var showValid = function(input) {
|
||||
$(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)
|
||||
showInvalid('#ys-input-nickname');
|
||||
else
|
||||
showValid('#ys-input-nickname');
|
||||
|
||||
if (message == '' || message == this.prefs.defaultMessage)
|
||||
if (message === '' || message === this.prefs.defaultMessage) {
|
||||
showInvalid('#ys-input-message');
|
||||
else
|
||||
} else {
|
||||
showValid('#ys-input-message');
|
||||
}
|
||||
|
||||
return !error;
|
||||
},
|
||||
@ -351,8 +352,9 @@ YShout.prototype = {
|
||||
this.floodAttempt++;
|
||||
this.disable();
|
||||
|
||||
if (this.floodAttempt == this.prefs.autobanFlood)
|
||||
if (this.floodAttempt === this.prefs.autobanFlood) {
|
||||
this.banSelf('You have been banned for flooding the shoutbox!');
|
||||
}
|
||||
|
||||
setTimeout(function() {
|
||||
self.floodCount = 0;
|
||||
@ -371,35 +373,39 @@ YShout.prototype = {
|
||||
},
|
||||
|
||||
findBySame: function(ip) {
|
||||
if (!$.browser.safari) return;
|
||||
if (!$.browser.safari) {return;}
|
||||
|
||||
var same = [];
|
||||
for (var i = 0; i < this.p.length; i++)
|
||||
if (this.p[i].adminInfo.ip == ip)
|
||||
|
||||
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++) {
|
||||
$('#' + same[i].id).fadeTo(this.animSpeed, .8).fadeTo(this.animSpeed, 1);
|
||||
}
|
||||
}
|
||||
|
||||
for (var j = 0; j < same.length; j++) {
|
||||
$('#' + same[j].id).fadeTo(this.animSpeed, 0.8).fadeTo(this.animSpeed, 1);
|
||||
}
|
||||
},
|
||||
|
||||
updates: function(updates) {
|
||||
if (!updates) return;
|
||||
if (updates.prefs) this.prefs = updates.prefs;
|
||||
if (updates.posts) this.posts(updates.posts);
|
||||
if (updates.banned) this.banned();
|
||||
if (!updates) {return;}
|
||||
if (updates.prefs) {this.prefs = updates.prefs;}
|
||||
if (updates.posts) {this.posts(updates.posts);}
|
||||
if (updates.banned) {this.banned();}
|
||||
},
|
||||
|
||||
banned: function() {
|
||||
var self = this;
|
||||
clearInterval(this.refreshTimer);
|
||||
clearInterval(this.floodTimer);
|
||||
if (this.initializing)
|
||||
if (this.initializing) {
|
||||
$('#ys-post-form').css('display', 'none');
|
||||
else
|
||||
} else {
|
||||
$('#ys-post-form').fadeOut(this.animSpeed);
|
||||
|
||||
if ($('#ys-banned').length == 0) {
|
||||
}
|
||||
|
||||
if ($('#ys-banned').length === 0) {
|
||||
$('#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>');
|
||||
|
||||
@ -410,14 +416,15 @@ YShout.prototype = {
|
||||
|
||||
$('#ys-unban-self').click(function() {
|
||||
self.ajax(function(json) {
|
||||
if (!json.error)
|
||||
if (!json.error) {
|
||||
self.unbanned();
|
||||
else if (json.error == 'admin')
|
||||
} else if (json.error === 'admin') {
|
||||
alert('You can only unban yourself if you\'re an admin.');
|
||||
}
|
||||
}, { reqType: 'unbanself' });
|
||||
return false;
|
||||
});
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
unbanned: function() {
|
||||
@ -451,9 +458,9 @@ YShout.prototype = {
|
||||
var d = date(ts);
|
||||
var h = d.getHours(), m = d.getMinutes();
|
||||
|
||||
if (self.prefs.timestamp == 12) {
|
||||
if (self.prefs.timestamp === 12) {
|
||||
h = (h > 12 ? h - 12 : h);
|
||||
if (h == 0) h = 12;
|
||||
if (h === 0) { h = 12; }
|
||||
}
|
||||
|
||||
return pad(h) + ':' + pad(m);
|
||||
@ -462,15 +469,15 @@ YShout.prototype = {
|
||||
var dateStr = function(ts) {
|
||||
var t = date(ts);
|
||||
|
||||
var Y = t.getFullYear();
|
||||
var M = t.getMonth();
|
||||
var D = t.getDay();
|
||||
var d = t.getDate();
|
||||
var day = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][D];
|
||||
var mon = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
||||
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][M];
|
||||
var Y = t.getFullYear();
|
||||
var M = t.getMonth();
|
||||
var D = t.getDay();
|
||||
var d = t.getDate();
|
||||
var day = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'][D];
|
||||
var mon = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
|
||||
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'][M];
|
||||
|
||||
return day + ' ' + mon + '. ' + d + ', ' + Y;
|
||||
return day + ' ' + mon + '. ' + d + ', ' + Y;
|
||||
};
|
||||
|
||||
var self = this;
|
||||
@ -487,18 +494,19 @@ YShout.prototype = {
|
||||
(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-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>' +
|
||||
'</div>';
|
||||
if (this.prefs.inverse) $('#ys-posts').prepend(html);
|
||||
else $('#ys-posts').append(html);
|
||||
if (this.prefs.inverse) { $('#ys-posts').prepend(html); }
|
||||
else { $('#ys-posts').append(html); }
|
||||
|
||||
this.p.push(post);
|
||||
|
||||
$('#' + id)
|
||||
.find('.ys-post-nickname').click(function() {
|
||||
if (post.adminInfo)
|
||||
if (post.adminInfo) {
|
||||
self.findBySame(post.adminInfo.ip);
|
||||
}
|
||||
}).end()
|
||||
.find('.ys-info-link').toggle(
|
||||
function() { self.showInfo.apply(self, [id, this]); return false; },
|
||||
@ -514,22 +522,24 @@ YShout.prototype = {
|
||||
|
||||
showInfo: function(id, el) {
|
||||
var jEl = $('#' + id + ' .ys-post-info');
|
||||
if (this.prefs.info == 'overlay')
|
||||
if (this.prefs.info === 'overlay') {
|
||||
jEl.css('display', 'block').fadeIn(this.animSpeed);
|
||||
else
|
||||
} else {
|
||||
jEl.slideDown(this.animSpeed);
|
||||
}
|
||||
|
||||
el.innerHTML ='Close Info'
|
||||
el.innerHTML = 'Close Info';
|
||||
return false;
|
||||
},
|
||||
|
||||
hideInfo: function(id, el) {
|
||||
var jEl = $('#' + id + ' .ys-post-info');
|
||||
if (this.prefs.info == 'overlay')
|
||||
if (this.prefs.info === 'overlay') {
|
||||
jEl.fadeOut(this.animSpeed);
|
||||
else
|
||||
} else {
|
||||
jEl.slideUp(this.animSpeed);
|
||||
|
||||
}
|
||||
|
||||
el.innerHTML = 'Info';
|
||||
return false;
|
||||
},
|
||||
@ -557,26 +567,24 @@ YShout.prototype = {
|
||||
return;
|
||||
}
|
||||
//alert('p: ' + this.p + ' / ' + this.p.length);
|
||||
if (json.bannedSelf)
|
||||
if (json.bannedSelf) {
|
||||
self.banned(); // ?
|
||||
|
||||
else
|
||||
} else {
|
||||
$.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)
|
||||
.addClass('ys-banned-post')
|
||||
.find('.ys-ban-link').html('Unban');
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}, pars);
|
||||
|
||||
link.innerHTML = 'Banning...';
|
||||
return false;
|
||||
break;
|
||||
|
||||
case 'Banning...':
|
||||
return false;
|
||||
break;
|
||||
|
||||
case 'Unban':
|
||||
var pars = {
|
||||
@ -590,26 +598,24 @@ YShout.prototype = {
|
||||
case 'admin':
|
||||
self.error('You\'re not an admin. Log in through the Admin CP to unban people.');
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$.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)
|
||||
.removeClass('ys-banned-post')
|
||||
.find('.ys-ban-link').html('Ban');
|
||||
}
|
||||
});
|
||||
|
||||
}, pars);
|
||||
|
||||
link.innerHTML = 'Unbanning...';
|
||||
return false;
|
||||
break;
|
||||
|
||||
case 'Unbanning...':
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
@ -617,7 +623,7 @@ YShout.prototype = {
|
||||
var self = this;
|
||||
var link = $('#' + id).find('.ys-delete-link')[0];
|
||||
|
||||
if (link.innerHTML == 'Deleting...') return;
|
||||
if (link.innerHTML === 'Deleting...') { return; }
|
||||
|
||||
var pars = {
|
||||
reqType: 'delete',
|
||||
@ -630,7 +636,6 @@ YShout.prototype = {
|
||||
case 'admin':
|
||||
self.error('You\'re not an admin. Log in through the Admin CP to ban people.');
|
||||
return;
|
||||
break;
|
||||
}
|
||||
}
|
||||
self.reload();
|
||||
@ -638,15 +643,15 @@ YShout.prototype = {
|
||||
|
||||
link.innerHTML = 'Deleting...';
|
||||
return false;
|
||||
|
||||
},
|
||||
|
||||
banSelf: function(reason) {
|
||||
var self = this;
|
||||
|
||||
this.ajax(function(json) {
|
||||
if (json.error == false)
|
||||
if (json.error === false) {
|
||||
self.banned();
|
||||
}
|
||||
}, {
|
||||
reqType: 'banself',
|
||||
nickname: $('#ys-input-nickname').val()
|
||||
@ -710,22 +715,24 @@ YShout.prototype = {
|
||||
truncate: function(clearAll) {
|
||||
var truncateTo = clearAll ? 0 : this.prefs.truncate;
|
||||
var posts = $('#ys-posts .ys-post').length;
|
||||
if (posts <= truncateTo) return;
|
||||
if (posts <= truncateTo) { return; }
|
||||
//alert(this.initializing);
|
||||
if (this.prefs.doTruncate || this.initializing) {
|
||||
var diff = posts - truncateTo;
|
||||
for (var i = 0; i < diff; i++)
|
||||
for (var i = 0; i < diff; i++) {
|
||||
this.p.shift();
|
||||
}
|
||||
|
||||
// $('#ys-posts .ys-post:gt(' + truncateTo + ')').remove();
|
||||
|
||||
if (this.prefs.inverse)
|
||||
if (this.prefs.inverse) {
|
||||
$('#ys-posts .ys-post:gt(' + (truncateTo - 1) + ')').remove();
|
||||
else
|
||||
} else {
|
||||
$('#ys-posts .ys-post:lt(' + (posts - truncateTo) + ')').remove();
|
||||
}
|
||||
}
|
||||
|
||||
this.markEnds();
|
||||
this.markEnds();
|
||||
},
|
||||
|
||||
markEnds: function() {
|
||||
@ -766,11 +773,11 @@ YShout.prototype = {
|
||||
json: function(parse) {
|
||||
this.d('In json: ' + parse);
|
||||
var json = eval('(' + parse + ')');
|
||||
if (!this.checkError(json)) return json;
|
||||
if (!this.checkError(json)) { return json; }
|
||||
},
|
||||
|
||||
checkError: function(json) {
|
||||
if (!json.yError) return false;
|
||||
if (!json.yError) { return false; }
|
||||
|
||||
this.d('Error: ' + json.yError);
|
||||
return true;
|
||||
@ -789,10 +796,8 @@ YShout.prototype = {
|
||||
dataType: html ? 'text' : 'json',
|
||||
data: pars,
|
||||
success: function(parse) {
|
||||
var arr = [parse];
|
||||
|
||||
var arr = [parse];
|
||||
callback.apply(self, arr);
|
||||
|
||||
}
|
||||
});
|
||||
},
|
||||
|
@ -33,4 +33,4 @@ class Chatbox extends Extension {
|
||||
$page->add_block($chatblock);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -1,5 +1,9 @@
|
||||
<?php
|
||||
class AjaxCall {
|
||||
|
||||
public $reqType;
|
||||
public $updates;
|
||||
|
||||
function AjaxCall($log = null) {
|
||||
header('Content-type: application/json');
|
||||
session_start();
|
||||
@ -24,8 +28,10 @@
|
||||
$ys = ys($_SESSION['yLog']);
|
||||
|
||||
if ($ys->banned(ip())) { $this->sendBanned(); break; }
|
||||
if ($post = $ys->post($nickname, $message)) // To use $post somewheres later
|
||||
$this->sendUpdates();
|
||||
if ($post = $ys->post($nickname, $message)) {
|
||||
// To use $post somewheres later
|
||||
$this->sendUpdates();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'refresh':
|
||||
@ -138,7 +144,6 @@
|
||||
$send['error'] = false;
|
||||
|
||||
echo jsonEncode($send);
|
||||
|
||||
}
|
||||
|
||||
function unbanSelf() {
|
||||
@ -235,7 +240,7 @@
|
||||
}
|
||||
|
||||
function clearLog() {
|
||||
$log = $_POST['log'];
|
||||
//$log = $_POST['log'];
|
||||
$send = array();
|
||||
$ys = ys($_SESSION['yLog']);
|
||||
|
||||
@ -254,10 +259,10 @@
|
||||
function clearLogs() {
|
||||
global $prefs;
|
||||
|
||||
$log = $_POST['log'];
|
||||
//$log = $_POST['log'];
|
||||
$send = array();
|
||||
|
||||
$ys = ys($_SESSION['yLog']);
|
||||
//$ys = ys($_SESSION['yLog']);
|
||||
|
||||
switch(true) {
|
||||
case !loggedIn():
|
||||
@ -272,8 +277,8 @@
|
||||
$send['error'] = false;
|
||||
}
|
||||
|
||||
echo jsonEncode($send);
|
||||
echo jsonEncode($send);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
class FileStorage {
|
||||
|
||||
public $shoutLog, $path, $handle;
|
||||
|
||||
function FileStorage($path, $shoutLog = false) {
|
||||
$this->shoutLog = $shoutLog;
|
||||
$folder = 'logs';
|
||||
@ -56,7 +58,6 @@ class FileStorage {
|
||||
fseek($this->handle, 0);
|
||||
//return stream_get_contents($this->handle);
|
||||
return file_get_contents($this->path);
|
||||
|
||||
}
|
||||
|
||||
function write($contents) {
|
||||
@ -79,7 +80,5 @@ class FileStorage {
|
||||
$this->save($default, false);
|
||||
return $default;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
@ -16,8 +16,8 @@
|
||||
}
|
||||
|
||||
function getVar($name) {
|
||||
if (isset($_POST[$name])) return $_POST[$name];
|
||||
if (isset($_GET[$name])) return $_GET[$name];
|
||||
if (isset($_POST[$name])) { return $_POST[$name]; }
|
||||
if (isset($_GET[$name])) { return $_GET[$name]; }
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
}
|
||||
|
||||
function magic($s) {
|
||||
if (get_magic_quotes_gpc()) $s = stripslashes($s);
|
||||
if (get_magic_quotes_gpc()) { $s = stripslashes($s); }
|
||||
return $s;
|
||||
}
|
||||
|
||||
@ -147,6 +147,5 @@
|
||||
return $_SESSION['yLoginHash'] == md5($prefs['password']);
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -250,4 +250,3 @@ class YShout {
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -71,4 +71,4 @@
|
||||
resetPrefs();
|
||||
//loadPrefs();
|
||||
|
||||
?>
|
||||
|
||||
|
@ -332,7 +332,7 @@ class CommentList extends Extension {
|
||||
$image = null; // this is "clever", I may live to regret it
|
||||
}
|
||||
}
|
||||
if(!is_null($image)) $images[] = array($image, $comments);
|
||||
if(!is_null($image)) $images[] = array($image, $comments);
|
||||
}
|
||||
}
|
||||
|
||||
@ -558,4 +558,4 @@ class CommentList extends Extension {
|
||||
}
|
||||
// }}}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -101,4 +101,4 @@ class CommentListTest extends ShimmieWebTestCase {
|
||||
$this->log_out();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -296,4 +296,4 @@ class CommentListTheme extends Themelet {
|
||||
';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -415,4 +415,4 @@ class CronUploader extends Extension {
|
||||
file_put_contents ($log_path, $content);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -71,4 +71,4 @@ class custom_html_headers extends Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -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')))
|
||||
{
|
||||
$this->authenticate_user();
|
||||
$start = 0;
|
||||
|
||||
if(isset($_GET['md5']))
|
||||
{
|
||||
$md5list = explode(",",$_GET['md5']);
|
||||
@ -268,6 +270,7 @@ class DanbooruApi extends Extension {
|
||||
{
|
||||
$results[] = Image::by_hash($md5);
|
||||
}
|
||||
$count = count($results);
|
||||
} elseif(isset($_GET['id']))
|
||||
{
|
||||
$idlist = explode(",",$_GET['id']);
|
||||
@ -275,6 +278,7 @@ class DanbooruApi extends Extension {
|
||||
{
|
||||
$results[] = Image::by_id($id);
|
||||
}
|
||||
$count = count($results);
|
||||
} else
|
||||
{
|
||||
$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
|
||||
// Let's display them
|
||||
$xml = "<posts count=\"$count\" offset=\"$start\">\n";
|
||||
$xml = "<posts count=\"{$count}\" offset=\"{$start}\">\n";
|
||||
foreach($results as $img)
|
||||
{
|
||||
// Sanity check to see if $img is really an image object
|
||||
@ -435,4 +439,4 @@ class DanbooruApi extends Extension {
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
@ -23,4 +23,4 @@ class DanbooruApiTest extends ShimmieWebTestCase {
|
||||
$this->log_out();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -40,4 +40,4 @@ class Downtime extends Extension {
|
||||
else return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -20,4 +20,4 @@ class DowntimeTest extends SCoreWebTestCase {
|
||||
$this->log_out();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -59,4 +59,4 @@ class DowntimeTheme extends Themelet {
|
||||
EOD;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -32,4 +32,4 @@ class EmoticonList extends Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -19,4 +19,4 @@ class EmoticonTest extends ShimmieWebTestCase {
|
||||
$this->log_out();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -18,4 +18,4 @@ class EmoticonListTheme extends Themelet {
|
||||
$page->set_data($html);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -83,4 +83,4 @@ class ET extends Extension {
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -7,4 +7,4 @@ class ETTest extends ShimmieWebTestCase {
|
||||
$this->log_out();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -59,4 +59,4 @@ EOD;
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -199,4 +199,4 @@ class ExtManager extends Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -23,4 +23,4 @@ class ExtManagerTest extends SCoreWebTestCase {
|
||||
# FIXME: test that some extensions can be added and removed? :S
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -136,4 +136,4 @@ class ExtManagerTheme extends Themelet {
|
||||
$page->add_block(new Block("Documentation", $html));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -196,4 +196,4 @@ class Favorites extends Extension {
|
||||
array("image_id"=>$image->id));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -30,4 +30,4 @@ class FavoritesTest extends ShimmieWebTestCase {
|
||||
$this->log_out();
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -35,4 +35,4 @@ class FavoritesTheme extends Themelet {
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
|
@ -86,4 +86,4 @@ class Featured extends Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -30,4 +30,4 @@ class FeaturedTest extends ShimmieWebTestCase {
|
||||
$this->assert_no_text("Featured Image");
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -34,4 +34,4 @@ class FeaturedTheme extends Themelet {
|
||||
";
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -412,4 +412,4 @@ class Forum extends Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -229,4 +229,4 @@ class ForumTheme extends Themelet {
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -35,4 +35,4 @@ class google_analytics extends Extension {
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -50,4 +50,4 @@ class Handle404 extends Extension {
|
||||
|
||||
public function get_priority() {return 99;}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -10,4 +10,4 @@ class Handle404Test extends SCoreWebTestCase {
|
||||
$this->assert_response(200);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -110,4 +110,4 @@ class ArchiveFileHandler extends Extension {
|
||||
// $this->theme->add_status("Adding $subdir", $list);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -46,4 +46,4 @@ class FlashFileHandler extends DataHandlerExtension {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -23,4 +23,4 @@ class FlashFileHandlerTheme extends Themelet {
|
||||
$page->add_block(new Block("Flash Animation", $html, "main", 10));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -107,4 +107,4 @@ class IcoFileHandler extends Extension {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -17,4 +17,4 @@ class IcoHandlerTest extends ShimmieWebTestCase {
|
||||
# FIXME: test that it gets displayed properly
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -9,4 +9,4 @@ class IcoFileHandlerTheme extends Themelet {
|
||||
$page->add_block(new Block("Image", $html, "main", 10));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -59,4 +59,4 @@ class MP3FileHandler extends DataHandlerExtension {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -20,4 +20,4 @@ class MP3FileHandlerTheme extends Themelet {
|
||||
$page->add_block(new Block("Music", $html, "main", 10));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -177,4 +177,4 @@ class PixelFileHandler extends DataHandlerExtension {
|
||||
}
|
||||
// }}}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -14,4 +14,4 @@ class PixelHandlerTest extends ShimmieWebTestCase {
|
||||
# FIXME: test that it gets displayed properly
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -31,4 +31,4 @@ class PixelFileHandlerTheme extends Themelet {
|
||||
$page->add_block(new Block("Image", $html, "main", 10));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -103,4 +103,4 @@ class MiniSVGParser {
|
||||
function endElement($parser, $name) {
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user