lots of minor doc tweaks, type hints, etc
This commit is contained in:
parent
edd3e49a2f
commit
dc10a18086
15 changed files with 435 additions and 360 deletions
|
@ -11,8 +11,14 @@
|
||||||
# Shimmie
|
# Shimmie
|
||||||
|
|
||||||
[![Build Status](https://travis-ci.org/shish/shimmie2.svg?branch=master)](https://travis-ci.org/shish/shimmie2)
|
[![Build Status](https://travis-ci.org/shish/shimmie2.svg?branch=master)](https://travis-ci.org/shish/shimmie2)
|
||||||
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/shish/shimmie2/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/shish/shimmie2/?branch=master)
|
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/shish/shimmie2/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/shish/shimmie2/?branch=master)
|
||||||
[![Code Coverage](https://scrutinizer-ci.com/g/shish/shimmie2/badges/coverage.png?b=develop)](https://scrutinizer-ci.com/g/shish/shimmie2/?branch=master)
|
[![Code Coverage](https://scrutinizer-ci.com/g/shish/shimmie2/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/shish/shimmie2/?branch=master)
|
||||||
|
(master)
|
||||||
|
|
||||||
|
[![Build Status](https://travis-ci.org/shish/shimmie2.svg?branch=develop)](https://travis-ci.org/shish/shimmie2)
|
||||||
|
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/shish/shimmie2/badges/quality-score.png?b=develop)](https://scrutinizer-ci.com/g/shish/shimmie2/?branch=develop)
|
||||||
|
[![Code Coverage](https://scrutinizer-ci.com/g/shish/shimmie2/badges/coverage.png?b=develop)](https://scrutinizer-ci.com/g/shish/shimmie2/?branch=develop)
|
||||||
|
(develop)
|
||||||
|
|
||||||
This is the main branch of Shimmie, if you know anything at all about running
|
This is the main branch of Shimmie, if you know anything at all about running
|
||||||
websites, this is the version to use.
|
websites, this is the version to use.
|
||||||
|
@ -23,14 +29,14 @@ check out one of the versioned branches.
|
||||||
# Requirements
|
# Requirements
|
||||||
|
|
||||||
- MySQL/MariaDB 5.1+ (with experimental support for PostgreSQL 9+ and SQLite 3)
|
- MySQL/MariaDB 5.1+ (with experimental support for PostgreSQL 9+ and SQLite 3)
|
||||||
- PHP 5.4.8+
|
- Stable PHP ([5.5 as of writing](https://en.wikipedia.org/wiki/PHP#Release_history))
|
||||||
- GD or ImageMagick
|
- GD or ImageMagick
|
||||||
|
|
||||||
# Installation
|
# Installation
|
||||||
|
|
||||||
1. Download the latest release under [Releases](https://github.com/shish/shimmie2/releases).
|
1. Download the latest release under [Releases](https://github.com/shish/shimmie2/releases).
|
||||||
2. Create a blank database
|
2. Unzip shimmie into a folder on the web host
|
||||||
3. Unzip shimmie into a folder on the web host
|
3. Create a blank database
|
||||||
4. Visit the folder with a web browser
|
4. Visit the folder with a web browser
|
||||||
5. Enter the location of the database
|
5. Enter the location of the database
|
||||||
6. Click "install". Hopefully you'll end up at the welcome screen; if
|
6. Click "install". Hopefully you'll end up at the welcome screen; if
|
||||||
|
@ -43,7 +49,7 @@ check out one of the versioned branches.
|
||||||
3. Install [Composer](https://getcomposer.org/). (If you don't already have it)
|
3. Install [Composer](https://getcomposer.org/). (If you don't already have it)
|
||||||
4. Run `composer global require "fxp/composer-asset-plugin:~1.1" --no-plugins`. (This is installed globally due to a known composer bug)
|
4. Run `composer global require "fxp/composer-asset-plugin:~1.1" --no-plugins`. (This is installed globally due to a known composer bug)
|
||||||
5. Run `composer install` in the shimmie folder.
|
5. Run `composer install` in the shimmie folder.
|
||||||
6. Follow instructions noted in "Installation" (Excluding 1 & 3).
|
6. Follow instructions noted in "Installation" starting from step 3.
|
||||||
|
|
||||||
## Upgrade from 2.3.X
|
## Upgrade from 2.3.X
|
||||||
|
|
||||||
|
@ -155,7 +161,7 @@ Issue/Bug tracker: http://github.com/shish/shimmie2/issues
|
||||||
|
|
||||||
All code is released under the [GNU GPL Version 2](http://www.gnu.org/licenses/gpl-2.0.html) unless mentioned otherwise.
|
All code is released under the [GNU GPL Version 2](http://www.gnu.org/licenses/gpl-2.0.html) unless mentioned otherwise.
|
||||||
|
|
||||||
If you give shimmie to someone else, you have to give them the source (which should be easy, as PHP
|
If you give shimmie to someone else, you have to give them the source (which
|
||||||
is an interpreted language...). If you want to add customisations to your own
|
should be easy, as PHP is an interpreted language...). If you want to add
|
||||||
site, then those customisations belong to you, and you can do what you want
|
customisations to your own site, then those customisations belong to you,
|
||||||
with them.
|
and you can do what you want with them.
|
||||||
|
|
|
@ -166,8 +166,15 @@ function xml_tag($name, $attrs=array(), $children=array()) {
|
||||||
return $xml;
|
return $xml;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Original PHP code by Chirp Internet: www.chirp.com.au
|
/**
|
||||||
// Please acknowledge use of this code by including this header.
|
* Original PHP code by Chirp Internet: www.chirp.com.au
|
||||||
|
* Please acknowledge use of this code by including this header.
|
||||||
|
*
|
||||||
|
* @param string $string input data
|
||||||
|
* @param int $limit how long the string should be
|
||||||
|
* @param string $break where to break the string
|
||||||
|
* @param string $pad what to add to the end of the string after truncating
|
||||||
|
*/
|
||||||
function truncate($string, $limit, $break=" ", $pad="...") {
|
function truncate($string, $limit, $break=" ", $pad="...") {
|
||||||
// return with no change if string is shorter than $limit
|
// return with no change if string is shorter than $limit
|
||||||
if(strlen($string) <= $limit) return $string;
|
if(strlen($string) <= $limit) return $string;
|
||||||
|
@ -1031,8 +1038,8 @@ if (!function_exists('http_parse_headers')) { #http://www.php.net/manual/en/func
|
||||||
* In cases like these, we need to make sure to check for them if the camelcase version does not exist.
|
* In cases like these, we need to make sure to check for them if the camelcase version does not exist.
|
||||||
*
|
*
|
||||||
* @param array $headers
|
* @param array $headers
|
||||||
* @param mixed $name
|
* @param string $name
|
||||||
* @return mixed
|
* @return string|bool
|
||||||
*/
|
*/
|
||||||
function findHeader ($headers, $name) {
|
function findHeader ($headers, $name) {
|
||||||
if (!is_array($headers)) {
|
if (!is_array($headers)) {
|
||||||
|
@ -1441,6 +1448,10 @@ function _set_event_listeners() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $event_listeners
|
||||||
|
* @param string $path
|
||||||
|
*/
|
||||||
function _dump_event_listeners($event_listeners, $path) {
|
function _dump_event_listeners($event_listeners, $path) {
|
||||||
$p = "<"."?php\n";
|
$p = "<"."?php\n";
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class ExtManagerTheme extends Themelet {
|
class ExtManagerTheme extends Themelet {
|
||||||
|
/**
|
||||||
|
* @param Page $page
|
||||||
|
* @param Extension[] $extensions
|
||||||
|
* @param bool $editable
|
||||||
|
*/
|
||||||
public function display_table(Page $page, /*array*/ $extensions, /*bool*/ $editable) {
|
public function display_table(Page $page, /*array*/ $extensions, /*bool*/ $editable) {
|
||||||
$h_en = $editable ? "<th>Enabled</th>" : "";
|
$h_en = $editable ? "<th>Enabled</th>" : "";
|
||||||
$html = "
|
$html = "
|
||||||
|
|
|
@ -87,328 +87,347 @@ class Forum extends Extension {
|
||||||
|
|
||||||
|
|
||||||
public function onPageRequest(PageRequestEvent $event) {
|
public function onPageRequest(PageRequestEvent $event) {
|
||||||
global $page, $user;
|
global $page, $user;
|
||||||
|
|
||||||
if($event->page_matches("forum")) {
|
if($event->page_matches("forum")) {
|
||||||
switch($event->get_arg(0)) {
|
switch($event->get_arg(0)) {
|
||||||
case "index":
|
case "index":
|
||||||
{
|
$this->show_last_threads($page, $event, $user->is_admin());
|
||||||
$this->show_last_threads($page, $event, $user->is_admin());
|
if(!$user->is_anonymous()) $this->theme->display_new_thread_composer($page);
|
||||||
if(!$user->is_anonymous()) $this->theme->display_new_thread_composer($page);
|
break;
|
||||||
break;
|
case "view":
|
||||||
}
|
$threadID = int_escape($event->get_arg(1));
|
||||||
case "view":
|
$pageNumber = int_escape($event->get_arg(2));
|
||||||
{
|
list($errors) = $this->sanity_check_viewed_thread($threadID);
|
||||||
$threadID = int_escape($event->get_arg(1));
|
|
||||||
$pageNumber = int_escape($event->get_arg(2));
|
if($errors!=null)
|
||||||
list($errors) = $this->sanity_check_viewed_thread($threadID);
|
{
|
||||||
|
$this->theme->display_error(500, "Error", $errors);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->show_posts($event, $user->is_admin());
|
||||||
|
if($user->is_admin()) $this->theme->add_actions_block($page, $threadID);
|
||||||
|
if(!$user->is_anonymous()) $this->theme->display_new_post_composer($page, $threadID);
|
||||||
|
break;
|
||||||
|
case "new":
|
||||||
|
global $page;
|
||||||
|
$this->theme->display_new_thread_composer($page);
|
||||||
|
break;
|
||||||
|
case "create":
|
||||||
|
$redirectTo = "forum/index";
|
||||||
|
if (!$user->is_anonymous())
|
||||||
|
{
|
||||||
|
list($errors) = $this->sanity_check_new_thread();
|
||||||
|
|
||||||
if($errors!=null)
|
if($errors!=null)
|
||||||
{
|
{
|
||||||
$this->theme->display_error(500, "Error", $errors);
|
$this->theme->display_error(500, "Error", $errors);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->show_posts($event, $user->is_admin());
|
$newThreadID = $this->save_new_thread($user);
|
||||||
if($user->is_admin()) $this->theme->add_actions_block($page, $threadID);
|
$this->save_new_post($newThreadID, $user);
|
||||||
if(!$user->is_anonymous()) $this->theme->display_new_post_composer($page, $threadID);
|
$redirectTo = "forum/view/".$newThreadID."/1";
|
||||||
break;
|
}
|
||||||
}
|
|
||||||
case "new":
|
|
||||||
{
|
|
||||||
global $page;
|
|
||||||
$this->theme->display_new_thread_composer($page);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "create":
|
|
||||||
{
|
|
||||||
$redirectTo = "forum/index";
|
|
||||||
if (!$user->is_anonymous())
|
|
||||||
{
|
|
||||||
list($errors) = $this->sanity_check_new_thread();
|
|
||||||
|
|
||||||
if($errors!=null)
|
$page->set_mode("redirect");
|
||||||
{
|
$page->set_redirect(make_link($redirectTo));
|
||||||
$this->theme->display_error(500, "Error", $errors);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
$newThreadID = $this->save_new_thread($user);
|
break;
|
||||||
$this->save_new_post($newThreadID, $user);
|
case "delete":
|
||||||
$redirectTo = "forum/view/".$newThreadID."/1";
|
$threadID = int_escape($event->get_arg(1));
|
||||||
}
|
$postID = int_escape($event->get_arg(2));
|
||||||
|
|
||||||
$page->set_mode("redirect");
|
if ($user->is_admin()) {$this->delete_post($postID);}
|
||||||
$page->set_redirect(make_link($redirectTo));
|
|
||||||
|
|
||||||
break;
|
$page->set_mode("redirect");
|
||||||
}
|
$page->set_redirect(make_link("forum/view/".$threadID));
|
||||||
case "delete":
|
break;
|
||||||
$threadID = int_escape($event->get_arg(1));
|
case "nuke":
|
||||||
$postID = int_escape($event->get_arg(2));
|
$threadID = int_escape($event->get_arg(1));
|
||||||
|
|
||||||
if ($user->is_admin()) {$this->delete_post($postID);}
|
if ($user->is_admin())
|
||||||
|
$this->delete_thread($threadID);
|
||||||
|
|
||||||
$page->set_mode("redirect");
|
$page->set_mode("redirect");
|
||||||
$page->set_redirect(make_link("forum/view/".$threadID));
|
$page->set_redirect(make_link("forum/index"));
|
||||||
break;
|
break;
|
||||||
case "nuke":
|
case "answer":
|
||||||
$threadID = int_escape($event->get_arg(1));
|
$threadID = int_escape($_POST["threadID"]);
|
||||||
|
$total_pages = $this->get_total_pages_for_thread($threadID);
|
||||||
|
if (!$user->is_anonymous())
|
||||||
|
{
|
||||||
|
list($errors) = $this->sanity_check_new_post();
|
||||||
|
|
||||||
if ($user->is_admin())
|
if ($errors!=null)
|
||||||
$this->delete_thread($threadID);
|
{
|
||||||
|
$this->theme->display_error(500, "Error", $errors);
|
||||||
$page->set_mode("redirect");
|
break;
|
||||||
$page->set_redirect(make_link("forum/index"));
|
}
|
||||||
break;
|
$this->save_new_post($threadID, $user);
|
||||||
case "answer":
|
}
|
||||||
$threadID = int_escape($_POST["threadID"]);
|
$page->set_mode("redirect");
|
||||||
$total_pages = $this->get_total_pages_for_thread($threadID);
|
$page->set_redirect(make_link("forum/view/".$threadID."/".$total_pages));
|
||||||
if (!$user->is_anonymous())
|
break;
|
||||||
{
|
default:
|
||||||
list($errors) = $this->sanity_check_new_post();
|
$page->set_mode("redirect");
|
||||||
|
$page->set_redirect(make_link("forum/index"));
|
||||||
if ($errors!=null)
|
//$this->theme->display_error(400, "Invalid action", "You should check forum/index.");
|
||||||
{
|
break;
|
||||||
$this->theme->display_error(500, "Error", $errors);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
$this->save_new_post($threadID, $user);
|
|
||||||
}
|
|
||||||
$page->set_mode("redirect");
|
|
||||||
$page->set_redirect(make_link("forum/view/".$threadID."/".$total_pages));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
$page->set_mode("redirect");
|
|
||||||
$page->set_redirect(make_link("forum/index"));
|
|
||||||
//$this->theme->display_error(400, "Invalid action", "You should check forum/index.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function get_total_pages_for_thread(/*int*/ $threadID)
|
|
||||||
{
|
|
||||||
global $database, $config;
|
|
||||||
$result = $database->get_row("SELECT COUNT(1) AS count FROM forum_posts WHERE thread_id = ?", array($threadID));
|
|
||||||
|
|
||||||
return ceil($result["count"] / $config->get_int("forumPostsPerPage"));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function sanity_check_new_thread()
|
|
||||||
{
|
|
||||||
$errors = null;
|
|
||||||
if (!array_key_exists("title", $_POST))
|
|
||||||
{
|
|
||||||
$errors .= "<div id='error'>No title supplied.</div>";
|
|
||||||
}
|
|
||||||
else if (strlen($_POST["title"]) == 0)
|
|
||||||
{
|
|
||||||
$errors .= "<div id='error'>You cannot have an empty title.</div>";
|
|
||||||
}
|
|
||||||
else if (strlen(html_escape($_POST["title"])) > 255)
|
|
||||||
{
|
|
||||||
$errors .= "<div id='error'>Your title is too long.</div>";
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!array_key_exists("message", $_POST))
|
|
||||||
{
|
|
||||||
$errors .= "<div id='error'>No message supplied.</div>";
|
|
||||||
}
|
|
||||||
else if (strlen($_POST["message"]) == 0)
|
|
||||||
{
|
|
||||||
$errors .= "<div id='error'>You cannot have an empty message.</div>";
|
|
||||||
}
|
|
||||||
|
|
||||||
return array($errors);
|
|
||||||
}
|
|
||||||
private function sanity_check_new_post()
|
|
||||||
{
|
|
||||||
$errors = null;
|
|
||||||
if (!array_key_exists("threadID", $_POST))
|
|
||||||
{
|
|
||||||
$errors = "<div id='error'>No thread ID supplied.</div>";
|
|
||||||
}
|
|
||||||
else if (strlen($_POST["threadID"]) == 0)
|
|
||||||
{
|
|
||||||
$errors = "<div id='error'>No thread ID supplied.</div>";
|
|
||||||
}
|
|
||||||
else if (is_numeric($_POST["threadID"]))
|
|
||||||
|
|
||||||
if (!array_key_exists("message", $_POST))
|
|
||||||
{
|
|
||||||
$errors .= "<div id='error'>No message supplied.</div>";
|
|
||||||
}
|
|
||||||
else if (strlen($_POST["message"]) == 0)
|
|
||||||
{
|
|
||||||
$errors .= "<div id='error'>You cannot have an empty message.</div>";
|
|
||||||
}
|
|
||||||
|
|
||||||
return array($errors);
|
|
||||||
}
|
|
||||||
private function sanity_check_viewed_thread($threadID)
|
|
||||||
{
|
|
||||||
$errors = null;
|
|
||||||
if (!$this->threadExists($threadID))
|
|
||||||
{
|
|
||||||
$errors = "<div id='error'>Inexistent thread.</div>";
|
|
||||||
}
|
|
||||||
return array($errors);
|
|
||||||
}
|
|
||||||
private function get_thread_title($threadID)
|
|
||||||
{
|
|
||||||
global $database;
|
|
||||||
$result = $database->get_row("SELECT t.title FROM forum_threads AS t WHERE t.id = ? ", array($threadID));
|
|
||||||
return $result["title"];
|
|
||||||
}
|
|
||||||
|
|
||||||
private function show_last_threads(Page $page, $event, $showAdminOptions = false)
|
|
||||||
{
|
|
||||||
global $config, $database;
|
|
||||||
$pageNumber = $event->get_arg(1);
|
|
||||||
$threadsPerPage = $config->get_int('forumThreadsPerPage', 15);
|
|
||||||
$totalPages = ceil($database->get_one("SELECT COUNT(*) FROM forum_threads") / $threadsPerPage);
|
|
||||||
|
|
||||||
if(is_null($pageNumber) || !is_numeric($pageNumber))
|
|
||||||
$pageNumber = 0;
|
|
||||||
else if ($pageNumber <= 0)
|
|
||||||
$pageNumber = 0;
|
|
||||||
else if ($pageNumber >= $totalPages)
|
|
||||||
$pageNumber = $totalPages - 1;
|
|
||||||
else
|
|
||||||
$pageNumber--;
|
|
||||||
|
|
||||||
$threads = $database->get_all(
|
|
||||||
"SELECT f.id, f.sticky, f.title, f.date, f.uptodate, u.name AS user_name, u.email AS user_email, u.class AS user_class, sum(1) - 1 AS response_count ".
|
|
||||||
"FROM forum_threads AS f ".
|
|
||||||
"INNER JOIN users AS u ".
|
|
||||||
"ON f.user_id = u.id ".
|
|
||||||
"INNER JOIN forum_posts AS p ".
|
|
||||||
"ON p.thread_id = f.id ".
|
|
||||||
"GROUP BY f.id, f.sticky, f.title, f.date, u.name, u.email, u.class ".
|
|
||||||
"ORDER BY f.sticky ASC, f.uptodate DESC LIMIT :limit OFFSET :offset"
|
|
||||||
, array("limit"=>$threadsPerPage, "offset"=>$pageNumber * $threadsPerPage)
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->theme->display_thread_list($page, $threads, $showAdminOptions, $pageNumber + 1, $totalPages);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function show_posts($event, $showAdminOptions = false)
|
|
||||||
{
|
|
||||||
global $config, $database;
|
|
||||||
$threadID = $event->get_arg(1);
|
|
||||||
$pageNumber = $event->get_arg(2);
|
|
||||||
$postsPerPage = $config->get_int('forumPostsPerPage', 15);
|
|
||||||
$totalPages = ceil($database->get_one("SELECT COUNT(*) FROM forum_posts WHERE thread_id = ?", array($threadID)) / $postsPerPage);
|
|
||||||
$threadTitle = $this->get_thread_title($threadID);
|
|
||||||
|
|
||||||
if(is_null($pageNumber) || !is_numeric($pageNumber))
|
|
||||||
$pageNumber = 0;
|
|
||||||
else if ($pageNumber <= 0)
|
|
||||||
$pageNumber = 0;
|
|
||||||
else if ($pageNumber >= $totalPages)
|
|
||||||
$pageNumber = $totalPages - 1;
|
|
||||||
else
|
|
||||||
$pageNumber--;
|
|
||||||
|
|
||||||
$posts = $database->get_all(
|
|
||||||
"SELECT p.id, p.date, p.message, u.name as user_name, u.email AS user_email, u.class AS user_class ".
|
|
||||||
"FROM forum_posts AS p ".
|
|
||||||
"INNER JOIN users AS u ".
|
|
||||||
"ON p.user_id = u.id ".
|
|
||||||
"WHERE thread_id = :thread_id ".
|
|
||||||
"ORDER BY p.date ASC ".
|
|
||||||
"LIMIT :limit OFFSET :offset"
|
|
||||||
, array("thread_id"=>$threadID, "offset"=>$pageNumber * $postsPerPage, "limit"=>$postsPerPage)
|
|
||||||
);
|
|
||||||
$this->theme->display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber + 1, $totalPages);
|
|
||||||
}
|
|
||||||
|
|
||||||
private function save_new_thread($user)
|
|
||||||
{
|
|
||||||
$title = html_escape($_POST["title"]);
|
|
||||||
$sticky = !empty($_POST["sticky"]) ? html_escape($_POST["sticky"]) : "N";
|
|
||||||
|
|
||||||
if($sticky == ""){
|
|
||||||
$sticky = "N";
|
|
||||||
}
|
|
||||||
|
|
||||||
global $database;
|
|
||||||
$database->execute("
|
|
||||||
INSERT INTO forum_threads
|
|
||||||
(title, sticky, user_id, date, uptodate)
|
|
||||||
VALUES
|
|
||||||
(?, ?, ?, now(), now())",
|
|
||||||
array($title, $sticky, $user->id));
|
|
||||||
|
|
||||||
$threadID = $database->get_last_insert_id("forum_threads_id_seq");
|
|
||||||
|
|
||||||
log_info("forum", "Thread {$threadID} created by {$user->name}");
|
|
||||||
|
|
||||||
return $threadID;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function save_new_post($threadID, $user)
|
|
||||||
{
|
|
||||||
global $config;
|
|
||||||
$userID = $user->id;
|
|
||||||
$message = html_escape($_POST["message"]);
|
|
||||||
|
|
||||||
$max_characters = $config->get_int('forumMaxCharsPerPost');
|
|
||||||
$message = substr($message, 0, $max_characters);
|
|
||||||
|
|
||||||
global $database;
|
|
||||||
$database->execute("INSERT INTO forum_posts
|
|
||||||
(thread_id, user_id, date, message)
|
|
||||||
VALUES
|
|
||||||
(?, ?, now(), ?)"
|
|
||||||
, array($threadID, $userID, $message));
|
|
||||||
|
|
||||||
$postID = $database->get_last_insert_id("forum_posts_id_seq");
|
|
||||||
|
|
||||||
log_info("forum", "Post {$postID} created by {$user->name}");
|
|
||||||
|
|
||||||
$database->execute("UPDATE forum_threads SET uptodate=now() WHERE id=?", array ($threadID));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function retrieve_posts($threadID, $pageNumber)
|
|
||||||
{
|
|
||||||
global $database, $config;
|
|
||||||
$postsPerPage = $config->get_int('forumPostsPerPage', 15);
|
|
||||||
|
|
||||||
return $database->get_all(
|
|
||||||
"SELECT p.id, p.date, p.message, u.name as user_name, u.email AS user_email, u.class AS user_class ".
|
|
||||||
"FROM forum_posts AS p ".
|
|
||||||
"INNER JOIN users AS u ".
|
|
||||||
"ON p.user_id = u.id ".
|
|
||||||
"WHERE thread_id = :thread_id ".
|
|
||||||
"ORDER BY p.date ASC ".
|
|
||||||
"LIMIT :limit OFFSET :offset "
|
|
||||||
, array("thread_id"=>$threadID, "offset"=>($pageNumber - 1) * $postsPerPage, "limit"=>$postsPerPage));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function delete_thread($threadID)
|
|
||||||
{
|
|
||||||
global $database;
|
|
||||||
$database->execute("DELETE FROM forum_threads WHERE id = ?", array($threadID));
|
|
||||||
$database->execute("DELETE FROM forum_posts WHERE thread_id = ?", array($threadID));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function delete_post($postID)
|
|
||||||
{
|
|
||||||
global $database;
|
|
||||||
$database->execute("DELETE FROM forum_posts WHERE id = ?", array($postID));
|
|
||||||
}
|
|
||||||
private function threadExists($threadID){
|
|
||||||
global $database;
|
|
||||||
$result=$database->get_one("SELECT EXISTS (SELECT * FROM forum_threads WHERE id= ?)", array($threadID));
|
|
||||||
if ($result==1){
|
|
||||||
return true;
|
|
||||||
}else{
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $threadID
|
||||||
|
*/
|
||||||
|
private function get_total_pages_for_thread($threadID)
|
||||||
|
{
|
||||||
|
global $database, $config;
|
||||||
|
$result = $database->get_row("SELECT COUNT(1) AS count FROM forum_posts WHERE thread_id = ?", array($threadID));
|
||||||
|
|
||||||
|
return ceil($result["count"] / $config->get_int("forumPostsPerPage"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sanity_check_new_thread()
|
||||||
|
{
|
||||||
|
$errors = null;
|
||||||
|
if (!array_key_exists("title", $_POST))
|
||||||
|
{
|
||||||
|
$errors .= "<div id='error'>No title supplied.</div>";
|
||||||
|
}
|
||||||
|
else if (strlen($_POST["title"]) == 0)
|
||||||
|
{
|
||||||
|
$errors .= "<div id='error'>You cannot have an empty title.</div>";
|
||||||
|
}
|
||||||
|
else if (strlen(html_escape($_POST["title"])) > 255)
|
||||||
|
{
|
||||||
|
$errors .= "<div id='error'>Your title is too long.</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!array_key_exists("message", $_POST))
|
||||||
|
{
|
||||||
|
$errors .= "<div id='error'>No message supplied.</div>";
|
||||||
|
}
|
||||||
|
else if (strlen($_POST["message"]) == 0)
|
||||||
|
{
|
||||||
|
$errors .= "<div id='error'>You cannot have an empty message.</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
return array($errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function sanity_check_new_post()
|
||||||
|
{
|
||||||
|
$errors = null;
|
||||||
|
if (!array_key_exists("threadID", $_POST))
|
||||||
|
{
|
||||||
|
$errors = "<div id='error'>No thread ID supplied.</div>";
|
||||||
|
}
|
||||||
|
else if (strlen($_POST["threadID"]) == 0)
|
||||||
|
{
|
||||||
|
$errors = "<div id='error'>No thread ID supplied.</div>";
|
||||||
|
}
|
||||||
|
else if (is_numeric($_POST["threadID"]))
|
||||||
|
|
||||||
|
if (!array_key_exists("message", $_POST))
|
||||||
|
{
|
||||||
|
$errors .= "<div id='error'>No message supplied.</div>";
|
||||||
|
}
|
||||||
|
else if (strlen($_POST["message"]) == 0)
|
||||||
|
{
|
||||||
|
$errors .= "<div id='error'>You cannot have an empty message.</div>";
|
||||||
|
}
|
||||||
|
|
||||||
|
return array($errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $threadID
|
||||||
|
*/
|
||||||
|
private function sanity_check_viewed_thread($threadID)
|
||||||
|
{
|
||||||
|
$errors = null;
|
||||||
|
if (!$this->threadExists($threadID))
|
||||||
|
{
|
||||||
|
$errors = "<div id='error'>Inexistent thread.</div>";
|
||||||
|
}
|
||||||
|
return array($errors);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $threadID
|
||||||
|
*/
|
||||||
|
private function get_thread_title($threadID)
|
||||||
|
{
|
||||||
|
global $database;
|
||||||
|
$result = $database->get_row("SELECT t.title FROM forum_threads AS t WHERE t.id = ? ", array($threadID));
|
||||||
|
return $result["title"];
|
||||||
|
}
|
||||||
|
|
||||||
|
private function show_last_threads(Page $page, PageRequestEvent $event, $showAdminOptions = false)
|
||||||
|
{
|
||||||
|
global $config, $database;
|
||||||
|
$pageNumber = $event->get_arg(1);
|
||||||
|
$threadsPerPage = $config->get_int('forumThreadsPerPage', 15);
|
||||||
|
$totalPages = ceil($database->get_one("SELECT COUNT(*) FROM forum_threads") / $threadsPerPage);
|
||||||
|
|
||||||
|
if(is_null($pageNumber) || !is_numeric($pageNumber))
|
||||||
|
$pageNumber = 0;
|
||||||
|
else if ($pageNumber <= 0)
|
||||||
|
$pageNumber = 0;
|
||||||
|
else if ($pageNumber >= $totalPages)
|
||||||
|
$pageNumber = $totalPages - 1;
|
||||||
|
else
|
||||||
|
$pageNumber--;
|
||||||
|
|
||||||
|
$threads = $database->get_all(
|
||||||
|
"SELECT f.id, f.sticky, f.title, f.date, f.uptodate, u.name AS user_name, u.email AS user_email, u.class AS user_class, sum(1) - 1 AS response_count ".
|
||||||
|
"FROM forum_threads AS f ".
|
||||||
|
"INNER JOIN users AS u ".
|
||||||
|
"ON f.user_id = u.id ".
|
||||||
|
"INNER JOIN forum_posts AS p ".
|
||||||
|
"ON p.thread_id = f.id ".
|
||||||
|
"GROUP BY f.id, f.sticky, f.title, f.date, u.name, u.email, u.class ".
|
||||||
|
"ORDER BY f.sticky ASC, f.uptodate DESC LIMIT :limit OFFSET :offset"
|
||||||
|
, array("limit"=>$threadsPerPage, "offset"=>$pageNumber * $threadsPerPage)
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->theme->display_thread_list($page, $threads, $showAdminOptions, $pageNumber + 1, $totalPages);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function show_posts(PageRequestEvent $event, $showAdminOptions = false)
|
||||||
|
{
|
||||||
|
global $config, $database;
|
||||||
|
$threadID = $event->get_arg(1);
|
||||||
|
$pageNumber = $event->get_arg(2);
|
||||||
|
$postsPerPage = $config->get_int('forumPostsPerPage', 15);
|
||||||
|
$totalPages = ceil($database->get_one("SELECT COUNT(*) FROM forum_posts WHERE thread_id = ?", array($threadID)) / $postsPerPage);
|
||||||
|
$threadTitle = $this->get_thread_title($threadID);
|
||||||
|
|
||||||
|
if(is_null($pageNumber) || !is_numeric($pageNumber))
|
||||||
|
$pageNumber = 0;
|
||||||
|
else if ($pageNumber <= 0)
|
||||||
|
$pageNumber = 0;
|
||||||
|
else if ($pageNumber >= $totalPages)
|
||||||
|
$pageNumber = $totalPages - 1;
|
||||||
|
else
|
||||||
|
$pageNumber--;
|
||||||
|
|
||||||
|
$posts = $database->get_all(
|
||||||
|
"SELECT p.id, p.date, p.message, u.name as user_name, u.email AS user_email, u.class AS user_class ".
|
||||||
|
"FROM forum_posts AS p ".
|
||||||
|
"INNER JOIN users AS u ".
|
||||||
|
"ON p.user_id = u.id ".
|
||||||
|
"WHERE thread_id = :thread_id ".
|
||||||
|
"ORDER BY p.date ASC ".
|
||||||
|
"LIMIT :limit OFFSET :offset"
|
||||||
|
, array("thread_id"=>$threadID, "offset"=>$pageNumber * $postsPerPage, "limit"=>$postsPerPage)
|
||||||
|
);
|
||||||
|
$this->theme->display_thread($posts, $showAdminOptions, $threadTitle, $threadID, $pageNumber + 1, $totalPages);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function save_new_thread(User $user)
|
||||||
|
{
|
||||||
|
$title = html_escape($_POST["title"]);
|
||||||
|
$sticky = !empty($_POST["sticky"]) ? html_escape($_POST["sticky"]) : "N";
|
||||||
|
|
||||||
|
if($sticky == ""){
|
||||||
|
$sticky = "N";
|
||||||
|
}
|
||||||
|
|
||||||
|
global $database;
|
||||||
|
$database->execute("
|
||||||
|
INSERT INTO forum_threads
|
||||||
|
(title, sticky, user_id, date, uptodate)
|
||||||
|
VALUES
|
||||||
|
(?, ?, ?, now(), now())",
|
||||||
|
array($title, $sticky, $user->id));
|
||||||
|
|
||||||
|
$threadID = $database->get_last_insert_id("forum_threads_id_seq");
|
||||||
|
|
||||||
|
log_info("forum", "Thread {$threadID} created by {$user->name}");
|
||||||
|
|
||||||
|
return $threadID;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $threadID
|
||||||
|
*/
|
||||||
|
private function save_new_post($threadID, User $user)
|
||||||
|
{
|
||||||
|
global $config;
|
||||||
|
$userID = $user->id;
|
||||||
|
$message = html_escape($_POST["message"]);
|
||||||
|
|
||||||
|
$max_characters = $config->get_int('forumMaxCharsPerPost');
|
||||||
|
$message = substr($message, 0, $max_characters);
|
||||||
|
|
||||||
|
global $database;
|
||||||
|
$database->execute("INSERT INTO forum_posts
|
||||||
|
(thread_id, user_id, date, message)
|
||||||
|
VALUES
|
||||||
|
(?, ?, now(), ?)"
|
||||||
|
, array($threadID, $userID, $message));
|
||||||
|
|
||||||
|
$postID = $database->get_last_insert_id("forum_posts_id_seq");
|
||||||
|
|
||||||
|
log_info("forum", "Post {$postID} created by {$user->name}");
|
||||||
|
|
||||||
|
$database->execute("UPDATE forum_threads SET uptodate=now() WHERE id=?", array ($threadID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $threadID
|
||||||
|
* @param int $pageNumber
|
||||||
|
*/
|
||||||
|
private function retrieve_posts($threadID, $pageNumber)
|
||||||
|
{
|
||||||
|
global $database, $config;
|
||||||
|
$postsPerPage = $config->get_int('forumPostsPerPage', 15);
|
||||||
|
|
||||||
|
return $database->get_all(
|
||||||
|
"SELECT p.id, p.date, p.message, u.name as user_name, u.email AS user_email, u.class AS user_class ".
|
||||||
|
"FROM forum_posts AS p ".
|
||||||
|
"INNER JOIN users AS u ".
|
||||||
|
"ON p.user_id = u.id ".
|
||||||
|
"WHERE thread_id = :thread_id ".
|
||||||
|
"ORDER BY p.date ASC ".
|
||||||
|
"LIMIT :limit OFFSET :offset "
|
||||||
|
, array("thread_id"=>$threadID, "offset"=>($pageNumber - 1) * $postsPerPage, "limit"=>$postsPerPage));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $threadID
|
||||||
|
*/
|
||||||
|
private function delete_thread($threadID)
|
||||||
|
{
|
||||||
|
global $database;
|
||||||
|
$database->execute("DELETE FROM forum_threads WHERE id = ?", array($threadID));
|
||||||
|
$database->execute("DELETE FROM forum_posts WHERE thread_id = ?", array($threadID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $postID
|
||||||
|
*/
|
||||||
|
private function delete_post($postID)
|
||||||
|
{
|
||||||
|
global $database;
|
||||||
|
$database->execute("DELETE FROM forum_posts WHERE id = ?", array($postID));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $threadID
|
||||||
|
*/
|
||||||
|
private function threadExists($threadID)
|
||||||
|
{
|
||||||
|
global $database;
|
||||||
|
$result=$database->get_one("SELECT EXISTS (SELECT * FROM forum_threads WHERE id= ?)", array($threadID));
|
||||||
|
if ($result==1){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -101,6 +101,7 @@ class MiniSVGParser {
|
||||||
/** @var int */
|
/** @var int */
|
||||||
public $height=0;
|
public $height=0;
|
||||||
|
|
||||||
|
/** @param string $file */
|
||||||
function __construct($file) {
|
function __construct($file) {
|
||||||
$xml_parser = xml_parser_create();
|
$xml_parser = xml_parser_create();
|
||||||
xml_set_element_handler($xml_parser, array($this, "startElement"), array($this, "endElement"));
|
xml_set_element_handler($xml_parser, array($this, "startElement"), array($this, "endElement"));
|
||||||
|
|
|
@ -133,7 +133,7 @@ class VideoFileHandler extends DataHandlerExtension {
|
||||||
/**
|
/**
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @param mixed[] $metadata
|
* @param mixed[] $metadata
|
||||||
* @return Image|null
|
* @return Image
|
||||||
*/
|
*/
|
||||||
protected function create_image_from_data($filename, $metadata) {
|
protected function create_image_from_data($filename, $metadata) {
|
||||||
|
|
||||||
|
|
|
@ -587,9 +587,9 @@ class OuroborosAPI extends Extension
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for getting a list of posts
|
* Wrapper for getting a list of posts
|
||||||
* @param $limit
|
* @param int $limit
|
||||||
* @param $page
|
* @param int $page
|
||||||
* @param $tags
|
* @param string[] $tags
|
||||||
*/
|
*/
|
||||||
protected function postIndex($limit, $page, $tags)
|
protected function postIndex($limit, $page, $tags)
|
||||||
{
|
{
|
||||||
|
@ -611,13 +611,13 @@ class OuroborosAPI extends Extension
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper for getting a list of tags
|
* Wrapper for getting a list of tags
|
||||||
* @param $limit
|
* @param int $limit
|
||||||
* @param $page
|
* @param int $page
|
||||||
* @param $order
|
* @param string $order
|
||||||
* @param $id
|
* @param int $id
|
||||||
* @param $after_id
|
* @param int $after_id
|
||||||
* @param $name
|
* @param string $name
|
||||||
* @param $name_pattern
|
* @param string $name_pattern
|
||||||
*/
|
*/
|
||||||
protected function tagIndex($limit, $page, $order, $id, $after_id, $name, $name_pattern)
|
protected function tagIndex($limit, $page, $order, $id, $after_id, $name, $name_pattern)
|
||||||
{
|
{
|
||||||
|
@ -830,7 +830,7 @@ class OuroborosAPI extends Extension
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper for matching API methods from event
|
* Helper for matching API methods from event
|
||||||
* @param $page
|
* @param string $page
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function match($page)
|
private function match($page)
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
class ImageResizeException extends SCoreException {
|
class ImageResizeException extends SCoreException {
|
||||||
var $error;
|
var $error;
|
||||||
|
|
||||||
|
/** @param string $error */
|
||||||
public function __construct($error) {
|
public function __construct($error) {
|
||||||
$this->error = $error;
|
$this->error = $error;
|
||||||
}
|
}
|
||||||
|
@ -282,7 +283,7 @@ class ResizeImage extends Extension {
|
||||||
* Check Memory usage limits
|
* Check Memory usage limits
|
||||||
*
|
*
|
||||||
* Old check: $memory_use = (filesize($image_filename)*2) + ($width*$height*4) + (4*1024*1024);
|
* Old check: $memory_use = (filesize($image_filename)*2) + ($width*$height*4) + (4*1024*1024);
|
||||||
* New check: memory_use = width * height * (bits per channel) * channels * 2.5
|
* New check: $memory_use = $width * $height * ($bits_per_channel) * channels * 2.5
|
||||||
*
|
*
|
||||||
* It didn't make sense to compute the memory usage based on the NEW size for the image. ($width*$height*4)
|
* It didn't make sense to compute the memory usage based on the NEW size for the image. ($width*$height*4)
|
||||||
* We need to consider the size that we are GOING TO instead.
|
* We need to consider the size that we are GOING TO instead.
|
||||||
|
@ -290,24 +291,25 @@ class ResizeImage extends Extension {
|
||||||
* The factor of 2.5 is simply a rough guideline.
|
* The factor of 2.5 is simply a rough guideline.
|
||||||
* http://stackoverflow.com/questions/527532/reasonable-php-memory-limit-for-image-resize
|
* http://stackoverflow.com/questions/527532/reasonable-php-memory-limit-for-image-resize
|
||||||
*
|
*
|
||||||
* @param $info
|
* @param mixed[] $info
|
||||||
* @return int
|
* @return int
|
||||||
*/
|
*/
|
||||||
private function calc_memory_use($info) {
|
private function calc_memory_use($info) {
|
||||||
if (isset($info['bits']) && isset($info['channels'])) {
|
if (isset($info['bits']) && isset($info['channels'])) {
|
||||||
return $memory_use = ($info[0] * $info[1] * ($info['bits'] / 8) * $info['channels'] * 2.5) / 1024;
|
$memory_use = ($info[0] * $info[1] * ($info['bits'] / 8) * $info['channels'] * 2.5) / 1024;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// If we don't have bits and channel info from the image then assume default values
|
// If we don't have bits and channel info from the image then assume default values
|
||||||
// of 8 bits per color and 4 channels (R,G,B,A) -- ie: regular 24-bit color
|
// of 8 bits per color and 4 channels (R,G,B,A) -- ie: regular 24-bit color
|
||||||
return $memory_use = ($info[0] * $info[1] * 1 * 4 * 2.5) / 1024;
|
$memory_use = ($info[0] * $info[1] * 1 * 4 * 2.5) / 1024;
|
||||||
}
|
}
|
||||||
|
return (int)$memory_use;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Image $image_obj
|
* @param Image $image_obj
|
||||||
* @param $width
|
* @param int $width
|
||||||
* @param $height
|
* @param int $height
|
||||||
* @return int[]
|
* @return int[]
|
||||||
*/
|
*/
|
||||||
private function calc_new_size(Image $image_obj, $width, $height) {
|
private function calc_new_size(Image $image_obj, $width, $height) {
|
||||||
|
@ -320,7 +322,7 @@ class ResizeImage extends Extension {
|
||||||
// Scale the new image
|
// Scale the new image
|
||||||
if ($width == 0) $factor = $height / $image_obj->height;
|
if ($width == 0) $factor = $height / $image_obj->height;
|
||||||
elseif ($height == 0) $factor = $width / $image_obj->width;
|
elseif ($height == 0) $factor = $width / $image_obj->width;
|
||||||
else $factor = min($width / $image_obj->width, $height / $image_obj->height);
|
else $factor = min($width / $image_obj->width, $height / $image_obj->height);
|
||||||
|
|
||||||
$new_width = round($image_obj->width * $factor);
|
$new_width = round($image_obj->width * $factor);
|
||||||
$new_height = round($image_obj->height * $factor);
|
$new_height = round($image_obj->height * $factor);
|
||||||
|
|
|
@ -128,8 +128,8 @@ class ShimmieApi extends Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $type
|
* @param string $type
|
||||||
* @param $query
|
* @param string $query
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
private function api_get_user($type, $query) {
|
private function api_get_user($type, $query) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ function dstat($name, $val) {
|
||||||
class StatsDInterface extends Extension {
|
class StatsDInterface extends Extension {
|
||||||
public static $stats = array();
|
public static $stats = array();
|
||||||
|
|
||||||
|
/** @param string $type */
|
||||||
private function _stats($type) {
|
private function _stats($type) {
|
||||||
global $_shm_event_count, $database, $_shm_load_start;
|
global $_shm_event_count, $database, $_shm_load_start;
|
||||||
$time = microtime(true) - $_shm_load_start;
|
$time = microtime(true) - $_shm_load_start;
|
||||||
|
@ -32,7 +33,7 @@ class StatsDInterface extends Extension {
|
||||||
StatsDInterface::$stats["shimmie.$type.cache-misses"] = $database->cache->get_misses()."|c";
|
StatsDInterface::$stats["shimmie.$type.cache-misses"] = $database->cache->get_misses()."|c";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPageRequest($event) {
|
public function onPageRequest(PageRequestEvent $event) {
|
||||||
$this->_stats("overall");
|
$this->_stats("overall");
|
||||||
|
|
||||||
if($event->page_matches("post/view")) { # 40%
|
if($event->page_matches("post/view")) { # 40%
|
||||||
|
@ -64,19 +65,19 @@ class StatsDInterface extends Extension {
|
||||||
StatsDInterface::$stats = array();
|
StatsDInterface::$stats = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onUserCreation($event) {
|
public function onUserCreation(UserCreationEvent $event) {
|
||||||
StatsDInterface::$stats["shimmie.events.user_creations"] = "1|c";
|
StatsDInterface::$stats["shimmie.events.user_creations"] = "1|c";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onDataUpload($event) {
|
public function onDataUpload(DataUploadEvent $event) {
|
||||||
StatsDInterface::$stats["shimmie.events.uploads"] = "1|c";
|
StatsDInterface::$stats["shimmie.events.uploads"] = "1|c";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onCommentPosting($event) {
|
public function onCommentPosting(CommentPostingEvent $event) {
|
||||||
StatsDInterface::$stats["shimmie.events.comments"] = "1|c";
|
StatsDInterface::$stats["shimmie.events.comments"] = "1|c";
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onImageInfoSet($event) {
|
public function onImageInfoSet(ImageInfoSetEvent $event) {
|
||||||
StatsDInterface::$stats["shimmie.events.info-sets"] = "1|c";
|
StatsDInterface::$stats["shimmie.events.info-sets"] = "1|c";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +86,10 @@ class StatsDInterface extends Extension {
|
||||||
*/
|
*/
|
||||||
public function get_priority() {return 99;}
|
public function get_priority() {return 99;}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array $data
|
||||||
|
* @param int $sampleRate
|
||||||
|
*/
|
||||||
private function send($data, $sampleRate=1) {
|
private function send($data, $sampleRate=1) {
|
||||||
if (!STATSD_HOST) { return; }
|
if (!STATSD_HOST) { return; }
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,10 @@ class TagSetEvent extends Event {
|
||||||
public $tags;
|
public $tags;
|
||||||
public $metatags;
|
public $metatags;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Image $image
|
||||||
|
* @param string $tags
|
||||||
|
*/
|
||||||
public function __construct(Image $image, $tags) {
|
public function __construct(Image $image, $tags) {
|
||||||
$this->image = $image;
|
$this->image = $image;
|
||||||
|
|
||||||
|
@ -165,6 +169,11 @@ class TagTermParseEvent extends Event {
|
||||||
/** @var bool */
|
/** @var bool */
|
||||||
public $parse = TRUE; //marks the tag to be parsed, and not just checked if valid metatag
|
public $parse = TRUE; //marks the tag to be parsed, and not just checked if valid metatag
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $term
|
||||||
|
* @param int $id
|
||||||
|
* @param bool $parse
|
||||||
|
*/
|
||||||
public function __construct($term, $id, $parse) {
|
public function __construct($term, $id, $parse) {
|
||||||
$this->term = $term;
|
$this->term = $term;
|
||||||
$this->id = $id;
|
$this->id = $id;
|
||||||
|
|
|
@ -248,8 +248,12 @@ class Tag_History extends Extension {
|
||||||
return ($row ? $row : array());
|
return ($row ? $row : array());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/**
|
||||||
* This function attempts to revert all changes by a given IP within an (optional) timeframe.
|
* This function attempts to revert all changes by a given IP within an (optional) timeframe.
|
||||||
|
*
|
||||||
|
* @param string $name
|
||||||
|
* @param string $ip
|
||||||
|
* @param string $date
|
||||||
*/
|
*/
|
||||||
public function process_revert_all_changes($name, $ip, $date) {
|
public function process_revert_all_changes($name, $ip, $date) {
|
||||||
global $database;
|
global $database;
|
||||||
|
|
|
@ -57,6 +57,7 @@ class TaggerXML extends Extension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param string $s */
|
||||||
private function match_tag_list ($s) {
|
private function match_tag_list ($s) {
|
||||||
global $database, $config;
|
global $database, $config;
|
||||||
|
|
||||||
|
@ -101,6 +102,7 @@ class TaggerXML extends Extension {
|
||||||
return $this->list_to_xml($tags,"search",$s,$count);
|
return $this->list_to_xml($tags,"search",$s,$count);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @param int $image_id */
|
||||||
private function image_tag_list ($image_id) {
|
private function image_tag_list ($image_id) {
|
||||||
global $database;
|
global $database;
|
||||||
$tags = $database->Execute("
|
$tags = $database->Execute("
|
||||||
|
@ -110,6 +112,12 @@ class TaggerXML extends Extension {
|
||||||
return $this->list_to_xml($tags,"image",$image_id);
|
return $this->list_to_xml($tags,"image",$image_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param PDOStatement $tags
|
||||||
|
* @param string $type
|
||||||
|
* @param string $query
|
||||||
|
* @param array $misc
|
||||||
|
*/
|
||||||
private function list_to_xml ($tags,$type,$query,$misc=null) {
|
private function list_to_xml ($tags,$type,$query,$misc=null) {
|
||||||
$r = $tags->_numOfRows;
|
$r = $tags->_numOfRows;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
class CustomIndexTheme extends IndexTheme {
|
class CustomIndexTheme extends IndexTheme {
|
||||||
/**
|
/**
|
||||||
* @param Page $page
|
* @param Page $page
|
||||||
* @param null|Image[] $images
|
* @param Image[] $images
|
||||||
*/
|
*/
|
||||||
public function display_page(Page $page, $images) {
|
public function display_page(Page $page, $images) {
|
||||||
global $config;
|
global $config;
|
||||||
|
@ -40,7 +40,7 @@ class CustomIndexTheme extends IndexTheme {
|
||||||
/**
|
/**
|
||||||
* @param int $page_number
|
* @param int $page_number
|
||||||
* @param int $total_pages
|
* @param int $total_pages
|
||||||
* @param array $search_terms
|
* @param string[] $search_terms
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
protected function build_navigation($page_number, $total_pages, $search_terms) {
|
protected function build_navigation($page_number, $total_pages, $search_terms) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ Tips
|
||||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||||
|
|
||||||
class Layout {
|
class Layout {
|
||||||
public function display_page($page) {
|
public function display_page(Page $page) {
|
||||||
global $config, $user;
|
global $config, $user;
|
||||||
|
|
||||||
$theme_name = $config->get_string('theme');
|
$theme_name = $config->get_string('theme');
|
||||||
|
@ -233,10 +233,16 @@ $header_html
|
||||||
EOD;
|
EOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function navlinks($link, $desc, $pages_matched) {
|
|
||||||
/**
|
/**
|
||||||
* Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.)
|
* @param string $link
|
||||||
|
* @param string $desc
|
||||||
|
* @param string[] $pages_matched
|
||||||
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
private function navlinks($link, $desc, $pages_matched) {
|
||||||
|
/**
|
||||||
|
* Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.)
|
||||||
|
*/
|
||||||
$html = null;
|
$html = null;
|
||||||
$url = ltrim(_get_query(), "/");
|
$url = ltrim(_get_query(), "/");
|
||||||
|
|
||||||
|
|
Reference in a new issue