A bunch of small changes from scrutinizer-ci; some tidying, some actual bug fixes

This commit is contained in:
Shish 2014-03-30 13:26:48 +01:00
parent db5aa56300
commit c8aa3327a1
31 changed files with 170 additions and 266 deletions

View File

@ -271,11 +271,13 @@ class Database {
/**
* Meta info about the database engine
* @var DBEngine
*/
private $engine = null;
/**
* The currently active cache engine
* @var CacheEngine
*/
public $cache = null;

View File

@ -140,9 +140,9 @@ abstract class FormatterExtension extends Extension {
*/
abstract class DataHandlerExtension extends Extension {
public function onDataUpload(DataUploadEvent $event) {
global $user;
if(($supported_ext = $this->supported_ext($event->type)) && ($check_contents = $this->check_contents($event->tmpname))) {
$supported_ext = $this->supported_ext($event->type);
$check_contents = $this->check_contents($event->tmpname);
if($supported_ext && $check_contents) {
if(!move_upload_to_archive($event)) return;
send_event(new ThumbnailGenerationEvent($event->hash, $event->type));

View File

@ -122,7 +122,7 @@ class Image {
if(SPEED_HAX) {
if(!$user->can("big_search") and count($tags) > 3) {
die("Anonymous users may only search for up to 3 tags at a time"); // FIXME: throw an exception?
throw new SCoreException("Anonymous users may only search for up to 3 tags at a time");
}
}
@ -644,7 +644,7 @@ class Image {
* images table. Yes, MySQL does suck this much.
*/
private static function build_accurate_search_querylet($terms) {
global $config, $database;
global $database;
$tag_querylets = array();
$img_querylets = array();
@ -804,7 +804,7 @@ class Image {
* build_accurate_search_querylet() for a full explanation
*/
private static function build_ugly_search_querylet($terms) {
global $config, $database;
global $database;
$tag_querylets = array();
$img_querylets = array();

View File

@ -15,6 +15,9 @@ class User {
var $name;
var $email;
var $join_date;
var $passhash;
/* @var UserClass */
var $class;
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *

View File

@ -385,7 +385,13 @@ function make_http(/*string*/ $link) {
/**
* Make a form tag with relevant auth token and stuff
*
* @retval string
* @param target string
* @param method string
* @param multipart boolean
* @param form_id string
* @param onsubmit string
*
* @return string
*/
function make_form($target, $method="POST", $multipart=False, $form_id="", $onsubmit="") {
global $user;
@ -1276,6 +1282,7 @@ function _sanitise_environment() {
}
function _get_themelet_files($_theme) {
$base_themelets = array();
if(file_exists('themes/'.$_theme.'/custompage.class.php')) $base_themelets[] = 'themes/'.$_theme.'/custompage.class.php';
$base_themelets[] = 'themes/'.$_theme.'/layout.class.php';
$base_themelets[] = 'themes/'.$_theme.'/themelet.class.php';
@ -1406,7 +1413,7 @@ function _decaret($str) {
}
function _get_user() {
global $config, $database;
global $config;
$user = null;
if(get_prefixed_cookie("user") && get_prefixed_cookie("session")) {
$tmp_user = User::by_session(get_prefixed_cookie("user"), get_prefixed_cookie("session"));

View File

@ -14,9 +14,9 @@ class AdminPageTheme extends Themelet {
protected function button(/*string*/ $name, /*string*/ $action, /*boolean*/ $protected=false) {
$c_protected = $protected ? " protected" : "";
$html = make_form(make_link("admin/$action"), "POST", false, false, false, "admin$c_protected");
$html = make_form(make_link("admin/$action"), "POST", false, null, null, "admin$c_protected");
if($protected) {
$html .= "<input type='submit' id='$action' value='$name' disabled='true'>";
$html .= "<input type='submit' id='$action' value='$name' disabled='disabled'>";
$html .= "<input type='checkbox' onclick='$(\"#$action\").attr(\"disabled\", !$(this).is(\":checked\"))'>";
}
else {

View File

@ -143,7 +143,7 @@ class Artists extends Extension {
}
public function handle_commands($event)
{
global $config, $page, $user;
global $page, $user;
if($event->page_matches("artist"))
{

View File

@ -14,19 +14,11 @@ class ArtistsTheme extends Themelet {
";
}
public function display_artists(){
global $page;
$page->set_title("Artists");
$page->set_heading("Artists");
$page->add_block(new Block("Artists", $html, "main", 10));
//$this->display_paginator($page, "artist/list", null, $pageNumber, $totalPages);
}
public function sidebar_options(/*string*/ $mode, $artistID=NULL, $is_admin=FALSE){
global $page;
global $page, $user;
$html = "";
if($mode == "neutral"){
$html = "<form method='post' action='".make_link("artist/new_artist")."'>
".$user->get_auth_html()."
@ -72,11 +64,14 @@ class ArtistsTheme extends Themelet {
<input type='hidden' name='artist_id' value='".$artistID."'>
</form>";
}
$page->add_block(new Block("Manage Artists", $html, "left", 10));
if($html) $page->add_block(new Block("Manage Artists", $html, "left", 10));
}
public function show_artist_editor($artist, $aliases, $members, $urls)
{
global $user;
$artistName = $artist['name'];
$artistNotes = $artist['notes'];
$artistID = $artist['id'];
@ -140,7 +135,7 @@ class ArtistsTheme extends Themelet {
public function new_artist_composer()
{
global $page;
global $page, $user;
$html = "<form action=".make_link("artist/create")." method='POST'>
".$user->get_auth_html()."
@ -234,6 +229,8 @@ class ArtistsTheme extends Themelet {
public function show_new_alias_composer($artistID)
{
global $user;
$html =
'<form method="POST" action='.make_link("artist/alias/add").'>
'.$user->get_auth_html().'
@ -250,6 +247,8 @@ class ArtistsTheme extends Themelet {
}
public function show_new_member_composer($artistID)
{
global $user;
$html =
' <form method="POST" action='.make_link("artist/member/add").'>
'.$user->get_auth_html().'
@ -267,6 +266,8 @@ class ArtistsTheme extends Themelet {
public function show_new_url_composer($artistID)
{
global $user;
$html =
' <form method="POST" action='.make_link("artist/url/add").'>
'.$user->get_auth_html().'
@ -284,6 +285,8 @@ class ArtistsTheme extends Themelet {
public function show_alias_editor($alias)
{
global $user;
$html =
'
<form method="POST" action="'.make_link("artist/alias/edited/".$alias['id']).'">
@ -301,6 +304,8 @@ class ArtistsTheme extends Themelet {
public function show_url_editor($url)
{
global $user;
$html =
'
<form method="POST" action="'.make_link("artist/url/edited/".$url['id']).'">
@ -318,6 +323,8 @@ class ArtistsTheme extends Themelet {
public function show_member_editor($member)
{
global $user;
$html =
'
<form method="POST" action="'.make_link("artist/member/edited/".$member['id']).'">
@ -335,7 +342,7 @@ class ArtistsTheme extends Themelet {
public function show_artist($artist, $aliases, $members, $urls, $images, $userIsLogged, $userIsAdmin)
{
global $user, $event, $page;
global $page;
$artist_link = "<a href='".make_link("post/list/".$artist['name']."/1")."'>".str_replace("_", " ", $artist['name'])."</a>";

View File

@ -53,6 +53,7 @@ class BulkAdd extends Extension {
if(!array_key_exists('extension', $pathinfo)) {
throw new UploadException("File has no extension");
}
$metadata = array();
$metadata['filename'] = $pathinfo['basename'];
$metadata['extension'] = $pathinfo['extension'];
$metadata['tags'] = $tags;
@ -65,8 +66,6 @@ class BulkAdd extends Extension {
}
private function add_dir(/*string*/ $base, $subdir="") {
global $page;
if(!is_dir($base)) {
$this->theme->add_status("Error", "$base is not a directory");
return;

View File

@ -62,6 +62,7 @@ class BulkAddCSV extends Extension {
if(!array_key_exists('extension', $pathinfo)) {
throw new UploadException("File has no extension");
}
$metadata = array();
$metadata['filename'] = $pathinfo['basename'];
$metadata['extension'] = $pathinfo['extension'];
$metadata['tags'] = $tags;
@ -82,8 +83,6 @@ class BulkAddCSV extends Extension {
}
private function add_csv(/*string*/ $csvfile) {
global $page;
if(!file_exists($csvfile)) {
$this->theme->add_status("Error", "$csvfile not found");
return;

View File

@ -12,7 +12,7 @@
class BulkRemove extends Extension {
public function onPageRequest(PageRequestEvent $event) {
global $page, $user;
global $user;
if($event->page_matches("bulk_remove") && $user->is_admin() && $user->check_auth_token()) {
if ($event->get_arg(0) == "confirm") $this->do_bulk_remove();
else $this->show_confirm();
@ -20,7 +20,7 @@ class BulkRemove extends Extension {
}
public function onAdminBuilding(AdminBuildingEvent $event) {
global $page, $user;
global $page;
$html = "<b>Be extremely careful when using this!</b><br>
Once an image is removed there is no way to recover it so it is recommended that
you first take when removing a large amount of images.<br>
@ -83,10 +83,10 @@ class BulkRemove extends Extension {
// if no images were found with the given info
if (count($images_for_removal) == 0 && $html == "")
if (count($images_for_removal) == 0)
$error = "No images selected for removal";
var_dump($tags_arr);
//var_dump($tags_arr);
return array(
"error" => $error,
"images_for_removal" => $images_for_removal);
@ -119,6 +119,7 @@ class BulkRemove extends Extension {
private function do_bulk_remove()
{
global $page;
// display error if user didn't go through admin board
if (!isset($_POST["bulk_remove_images"])) {
$page->add_block(new Block("Bulk Remove Error",

View File

@ -13,7 +13,7 @@ class Chatbox extends Extension {
global $page, $user;
// Adds header to enable chatbox
$root = make_http();
$root = get_base_href();
$yPath = "$root/ext/chatbox/";
$page->add_html_header("
<script src=\"$root/ext/chatbox/js/jquery.js\" type=\"text/javascript\"></script>

View File

@ -206,7 +206,7 @@ class CronUploader extends Extension {
/**
* Returns amount of files & total size of dir.
* @param unknown $path
* @param $path string
* @return multitype:number
*/
function scan_dir($path){
@ -227,7 +227,7 @@ class CronUploader extends Extension {
/**
* Uploads the image & handles everything
* @param number $upload_count to upload a non-config amount of imgs
* @param $upload_count int to upload a non-config amount of imgs
* @return boolean returns true if the upload was successful
*/
public function process_upload($upload_count = 0) {
@ -254,11 +254,11 @@ class CronUploader extends Extension {
try {
$this->add_image($img[0], $img[1], $img[2]);
$newPath = $this->move_uploaded($img[0], $img[1], false);
$this->move_uploaded($img[0], $img[1], false);
}
catch (Exception $e) {
$newPath = $this->move_uploaded($img[0], $img[1], true);
$this->move_uploaded($img[0], $img[1], true);
}
// Remove img from queue array
@ -295,37 +295,17 @@ class CronUploader extends Extension {
$this->add_upload_info($info . "Image \"$filename\" moved from queue to \"$newPath\".");
}
/**
* moves a directory up or gets the directory of a file
*
* @param string $path Path to modify
* @param int $depth Amount of directories to go up
* @return unknown Path to correct Directory
*/
private function move_directory_up($path, $depth=1)
{
$path = str_replace("//", "/", $path);
$array = explode("/", $path);
for ($i = 0; $i < $depth; $i++) {
$to_remove = count($array) -1; // Gets number of element to remove
unset($array[$to_remove]);
}
return implode("/", $array);
}
/**
* Generate the necessary DataUploadEvent for a given image and tags.
*/
private function add_image($tmpname, $filename, $tags) {
global $user, $image;
assert ( file_exists ( $tmpname ) );
$pathinfo = pathinfo ( $filename );
if (! array_key_exists ( 'extension', $pathinfo )) {
throw new UploadException ( "File has no extension" );
}
$metadata = array();
$metadata ['filename'] = $pathinfo ['basename'];
$metadata ['extension'] = $pathinfo ['extension'];
$metadata ['tags'] = ""; // = $tags; doesn't work when not logged in here
@ -343,12 +323,9 @@ class CronUploader extends Extension {
// Set tags
$img = Image::by_id($event->image_id);
$img->set_tags($tags);
}
private function generate_image_queue($base = "", $subdir = "") {
global $config;
if ($base == "")
$base = $this->root_dir . "/queue";
@ -391,8 +368,9 @@ class CronUploader extends Extension {
/**
* Adds a message to the info being published at the end
* @param string $text
* @param int $addon Enter a value to modify an existing value (enter value number)
* @param $text string
* @param $addon int Enter a value to modify an existing value (enter value number)
* @return int
*/
private function add_upload_info($text, $addon = 0) {
$info = $this->upload_info;
@ -409,7 +387,7 @@ class CronUploader extends Extension {
// else if addon function is used, select the line & modify it
$lines = substr($info, "\n"); // Seperate the string to array in lines
$lines[$addon] = "$line[$addon] $text"; // Add the content to the line
$lines[$addon] = "$lines[$addon] $text"; // Add the content to the line
$this->upload_info = implode("\n", $lines); // Put string back together & update
return $addon; // Return line number
@ -419,7 +397,7 @@ class CronUploader extends Extension {
* This is run at the end to display & save the log.
*/
private function handle_log() {
global $page, $config;
global $page;
// Display message
$page->set_mode("data");

View File

@ -21,6 +21,7 @@ function __extman_extcmp(ExtensionInfo $a, ExtensionInfo $b) {
class ExtensionInfo {
var $ext_name, $name, $link, $author, $email;
var $description, $documentation, $version, $visibility;
var $enabled;
function __construct($main) {
$matches = array();
@ -167,6 +168,7 @@ class ExtManager extends Extension {
private function set_things($settings) {
$core = explode(",", CORE_EXTS);
$extras = array();
foreach(glob("ext/*/main.php") as $main) {
$matches = array();

View File

@ -35,7 +35,7 @@ class Favorites extends Extension {
}
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) {
global $database, $page, $user;
global $database, $user;
if(!$user->is_anonymous()) {
$user_id = $user->id;
$image_id = $event->image->id;
@ -88,7 +88,7 @@ class Favorites extends Extension {
in_array('favorite_action', $_POST) &&
(($_POST['favorite_action'] == "set") || ($_POST['favorite_action'] == "unset"))
) {
send_event(new FavoriteSetEvent($event->image_id, $user, ($_POST['favorite_action'] == "set")));
send_event(new FavoriteSetEvent($event->image->id, $user, ($_POST['favorite_action'] == "set")));
}
}

View File

@ -50,11 +50,11 @@ class ArchiveFileHandler extends Extension {
assert(file_exists($tmpname));
try {
global $user;
$pathinfo = pathinfo($filename);
if(!array_key_exists('extension', $pathinfo)) {
throw new UploadException("File has no extension");
}
$metadata = array();
$metadata['filename'] = $pathinfo['basename'];
$metadata['extension'] = $pathinfo['extension'];
$metadata['tags'] = $tags;
@ -69,8 +69,6 @@ class ArchiveFileHandler extends Extension {
// copied from bulk add extension
private function add_dir($base, $subdir="") {
global $page;
$list = "";
$dir = opendir("$base/$subdir");

View File

@ -17,8 +17,6 @@ class FlashFileHandler extends DataHandlerExtension {
}
protected function create_image_from_data(/*string*/ $filename, /*array*/ $metadata) {
global $config;
$image = new Image();
$image->filesize = $metadata['size'];
@ -28,15 +26,8 @@ class FlashFileHandler extends DataHandlerExtension {
$image->tag_array = Tag::explode($metadata['tags']);
$image->source = $metadata['source'];
// redundant, since getimagesize() works on SWF o_O
// $rect = $this->swf_get_bounds($filename);
// if(is_null($rect)) {
// return $null;
// }
// $image->width = $rect[1];
// $image->height = $rect[3];
if(!($info = getimagesize($filename))) return null;
$info = getimagesize($filename);
if(!$info) return null;
$image->width = $info[0];
$image->height = $info[1];
@ -45,61 +36,14 @@ class FlashFileHandler extends DataHandlerExtension {
}
protected function check_contents(/*string*/ $file) {
if(!file_exists($file)) return false;
if (!file_exists($file)) return false;
$fp = fopen($file, "r");
$head = fread($fp, 3);
fclose($fp);
if(!in_array($head, array("CWS", "FWS"))) return false;
$fp = fopen($file, "r");
$head = fread($fp, 3);
fclose($fp);
if (!in_array($head, array("CWS", "FWS"))) return false;
return true;
}
private function str_to_binarray(/*string*/ $string) {
$binary = array();
$length = strlen($string);
for($j=0; $j<$length; $j++) {
$c = ord($string[$j]);
for($i=7; $i>=0; $i--) {
$binary[] = ($c >> $i) & 0x01;
}
}
return $binary;
}
private function binarray_to_int($binarray, $start=0, $length=32) {
$int = 0;
for($i=$start; $i<$start + $length; $i++) {
$int = $int << 1;
$int = $int + ($binarray[$i] == "1" ? 1 : 0);
}
return $int;
}
private function swf_get_bounds(/*string*/ $filename) {
$fp = fopen($filename, "r");
$head = fread($fp, 3);
$version = fread($fp, 1);
$length = fread($fp, 4);
if($head == "FWS") {
$data = fread($fp, 16);
}
else if($head == "CWS") {
$data = fread($fp, 128*1024);
$data = gzuncompress($data);
$data = substr($data, 0, 16);
}
$bounds = array();
$rect_bin = $this->str_to_binarray($data);
$nbits = $this->binarray_to_int($rect_bin, 0, 5);
$bounds[] = $this->binarray_to_int($rect_bin, 5 + 0 * $nbits, $nbits) / 20;
$bounds[] = $this->binarray_to_int($rect_bin, 5 + 1 * $nbits, $nbits) / 20;
$bounds[] = $this->binarray_to_int($rect_bin, 5 + 2 * $nbits, $nbits) / 20;
$bounds[] = $this->binarray_to_int($rect_bin, 5 + 3 * $nbits, $nbits) / 20;
return $bounds;
}
return true;
}
}
?>

View File

@ -36,7 +36,7 @@ class IcoFileHandler extends Extension {
}
public function onPageRequest(PageRequestEvent $event) {
global $config, $database, $page;
global $page;
if($event->page_matches("get_ico")) {
$id = int_escape($event->get_arg(0));
$image = Image::by_id($id);
@ -56,8 +56,6 @@ class IcoFileHandler extends Extension {
}
private function create_image_from_data($filename, $metadata) {
global $config;
$image = new Image();
$fp = fopen($filename, "r");

View File

@ -6,8 +6,8 @@ class IcoHandlerTest extends ShimmieWebTestCase {
$this->assert_response(302);
$this->log_out();
$raw = $this->get_page("post/view/$image_id"); // test for no crash
$raw = $this->get_page("get_ico/$image_id"); // test for no crash
$this->get_page("post/view/$image_id"); // test for no crash
$this->get_page("get_ico/$image_id"); // test for no crash
$this->log_in_as_admin();
$this->delete_image($image_id);

View File

@ -14,8 +14,6 @@ class PixelFileHandler extends DataHandlerExtension {
}
protected function create_image_from_data(/*string*/ $filename, /*array*/ $metadata) {
global $config;
$image = new Image();
$info = getimagesize($filename);
@ -52,9 +50,10 @@ class PixelFileHandler extends DataHandlerExtension {
}
protected function create_thumb_force(/*string*/ $hash) {
global $config;
$inname = warehouse_path("images", $hash);
$outname = warehouse_path("thumbs", $hash);
global $config;
$ok = false;
@ -165,7 +164,7 @@ class PixelFileHandler extends DataHandlerExtension {
if($width > $height*5) $width = $height*5;
if($height > $width*5) $height = $width*5;
$image = imagecreatefromstring($this->read_file($tmpname));
$image = imagecreatefromstring(file_get_contents($tmpname));
$tsize = get_thumbnail_size($width, $height);
$thumb = imagecreatetruecolor($tsize[0], $tsize[1]);
@ -176,16 +175,6 @@ class PixelFileHandler extends DataHandlerExtension {
return $thumb;
}
}
private function read_file(/*string*/ $fname) {
$fp = fopen($fname, "r");
if(!$fp) return false;
$data = fread($fp, filesize($fname));
fclose($fp);
return $data;
}
// }}}
}
?>

View File

@ -15,26 +15,26 @@ $(function() {
}
});
function zoom(zoom) {
function zoom(zoom_type) {
var img = $('.shm-main-image');
if(zoom == "full") {
if(zoom_type == "full") {
img.css('max-width', img.data('width') + 'px');
img.css('max-height', img.data('height') + 'px');
}
if(zoom == "width") {
if(zoom_type == "width") {
img.css('max-width', '95%');
img.css('max-height', img.data('height') + 'px');
}
if(zoom == "height") {
if(zoom_type == "height") {
img.css('max-width', img.data('width') + 'px');
img.css('max-height', (window.innerHeight * 0.95) + 'px');
}
if(zoom == "both") {
if(zoom_type == "both") {
img.css('max-width', '95%');
img.css('max-height', (window.innerHeight * 0.95) + 'px');
}
$(".shm-zoomer").val(zoom);
$(".shm-zoomer").val(zoom_type);
$.cookie("ui-image-zoom", zoom, {path: '/', expires: 365});
$.cookie("ui-image-zoom", zoom_type, {path: '/', expires: 365});
}

View File

@ -31,6 +31,9 @@ else {
<source src='" . make_link("/image/" . $image->id) . "' type='video/webm' />
</video>";
}
else {
$html = "Video type '$ext' not recognised";
}
$page->add_block(new Block("Video", $html, "main", 10));
}
}

View File

@ -20,7 +20,7 @@ class ImageAdditionEvent extends Event {
* this new image.
*
* @sa TagSetEvent
* @param $image The new image to add.
* @param $image Image The new image to add.
*/
public function __construct(Image $image) {
$this->image = $image;
@ -46,7 +46,7 @@ class ImageDeletionEvent extends Event {
* Used by things like tags and comments handlers to
* clean out related rows in their tables.
*
* @param $image The image being deleted
* @param $image Image The image being deleted
*/
public function __construct(Image $image) {
$this->image = $image;
@ -93,8 +93,9 @@ class ThumbnailGenerationEvent extends Event {
/**
* Request a thumbnail be made for an image object
*
* @param $hash The unique hash of the image
* @param $type The type of the image
* @param $hash string The unique hash of the image
* @param $type string The type of the image
* @param $force boolean Regenerate the thumbnail even if one already exists
*/
public function __construct($hash, $type, $force=false) {
$this->hash = $hash;
@ -223,9 +224,6 @@ class ImageIO extends Extension {
}
public function onUserPageBuilding(UserPageBuildingEvent $event) {
global $user;
global $config;
$u_id = url_escape($event->display_user->id);
$i_image_count = Image::count_images(array("user_id={$event->display_user->id}"));
$i_days_old = ((time() - strtotime($event->display_user->join_date)) / 86400) + 1;
@ -279,7 +277,7 @@ class ImageIO extends Extension {
// add image {{{
private function add_image($image) {
private function add_image(Image $image) {
global $page, $user, $database, $config;
/*
@ -401,11 +399,8 @@ class ImageIO extends Extension {
// replace image {{{
private function replace_image($id, $image) {
global $page;
global $user;
global $database;
global $config;
/* Check to make sure the image exists. */
$existing = Image::by_id($id);

View File

@ -1,6 +1,8 @@
<?php
class IndexTheme extends Themelet {
var $page_number, $total_pages, $search_terms;
public function set_page($page_number, $total_pages, $search_terms) {
$this->page_number = $page_number;
$this->total_pages = $total_pages;

View File

@ -62,7 +62,7 @@ class LinkImageTheme extends Themelet {
$text = "[url=".$url."]".$content."[/url]";
break;
default:
$text = $link." - ".$content;
$text = $url." - ".$content;
}
return $text;
}

View File

@ -63,6 +63,7 @@ class LiveFeed extends Extension {
fwrite($fp, "$data\n");
fclose($fp);
} catch (Exception $e) {
/* logging errors shouldn't break everything */
}
}
}

View File

@ -42,6 +42,7 @@ class LogNet extends Extension {
fwrite($fp, "$data\n");
fclose($fp);
} catch (Exception $e) {
/* logging errors shouldn't break everything */
}
}
}

View File

@ -29,7 +29,7 @@ class NotATag extends Extension {
}
private function scan(/*array*/ $tags_mixed) {
global $config, $database;
global $database;
$tags = array();
foreach($tags_mixed as $tag) $tags[] = strtolower($tag);
@ -53,12 +53,12 @@ class NotATag extends Extension {
}
public function onPageRequest(PageRequestEvent $event) {
global $config, $database, $page, $user;
global $database, $page, $user;
if($event->page_matches("untag")) {
if($user->can("ban_image")) {
if($event->get_arg(0) == "add") {
$tag = isset($_POST["tag"]) ? $_POST["tag"] : $image->tag;
$tag = $_POST["tag"];
$redirect = isset($_POST['redirect']) ? $_POST['redirect'] : "DNP";
$database->Execute(

View File

@ -363,6 +363,8 @@ class Notes extends Extension {
*/
private function delete_note()
{
global $user;
$imageID = int_escape($_POST["image_id"]);
$noteID = int_escape($_POST["note_id"]);
@ -388,7 +390,7 @@ class Notes extends Extension {
* HERE WE DELETE ALL NOTES FROM IMAGE
*/
private function nuke_notes() {
global $database;
global $database, $user;
$image_id = int_escape($_POST["image_id"]);
$database->execute("DELETE FROM notes WHERE image_id = ?", array($image_id));
log_info("notes", "Notes deleted from {$image_id} by {$user->name}");
@ -400,7 +402,7 @@ class Notes extends Extension {
* HERE WE DELETE ALL REQUESTS FOR IMAGE
*/
private function nuke_requests() {
global $database;
global $database, $user;
$image_id = int_escape($_POST["image_id"]);
$database->execute("DELETE FROM note_request WHERE image_id = ?", array($image_id));

View File

@ -42,7 +42,7 @@ class NotesTheme extends Themelet {
$page->add_block(new Block("Search Note", $html, "main", 10));
}
// check action POST on form
// check action POST on form
public function display_note_system(Page $page, $image_id, $recovered_notes, $adminOptions)
{
$to_json = array();
@ -169,94 +169,66 @@ class NotesTheme extends Themelet {
$page->set_heading("Note Requests");
$page->add_block(new Block("Note Requests", $pool_images, "main", 20));
}
private function get_history($histories) {
global $user;
$html = "<table id='poolsList' class='zebra'>".
"<thead><tr>".
"<th>Image</th>".
"<th>Note</th>".
"<th>Body</th>".
"<th>Updater</th>".
"<th>Date</th>";
if(!$user->is_anonymous()){
$html .= "<th>Action</th>";
}
$html .= "</tr></thead>".
"<tbody>";
foreach($histories as $history) {
$image_link = "<a href='".make_link("post/view/".$history['image_id'])."'>".$history['image_id']."</a>";
$history_link = "<a href='".make_link("note/history/".$history['note_id'])."'>".$history['note_id'].".".$history['review_id']."</a>";
$user_link = "<a href='".make_link("user/".$history['user_name'])."'>".$history['user_name']."</a>";
$revert_link = "<a href='".make_link("note/revert/".$history['note_id']."/".$history['review_id'])."'>Revert</a>";
$html .= "<tr>".
"<td>".$image_link."</td>".
"<td>".$history_link."</td>".
"<td style='text-align:left;'>".$history['note']."</td>".
"<td>".$user_link."</td>".
"<td>".autodate($history['date'])."</td>";
if(!$user->is_anonymous()){
$html .= "<td>".$revert_link."</td>";
}
}
$html .= "</tr></tbody></table>";
return $html;
}
public function display_histories($histories, $pageNumber, $totalPages) {
global $user, $page;
$html = "<table id='poolsList' class='zebra'>".
"<thead><tr>".
"<th>Image</th>".
"<th>Note</th>".
"<th>Body</th>".
"<th>Updater</th>".
"<th>Date</th>";
if(!$user->is_anonymous()){
$html .= "<th>Action</th>";
}
$html .= "</tr></thead>".
"<tbody>";
foreach($histories as $history) {
$image_link = "<a href='".make_link("post/view/".$history['image_id'])."'>".$history['image_id']."</a>";
$history_link = "<a href='".make_link("note/history/".$history['note_id'])."'>".$history['note_id'].".".$history['review_id']."</a>";
$user_link = "<a href='".make_link("user/".$history['user_name'])."'>".$history['user_name']."</a>";
$revert_link = "<a href='".make_link("note/revert/".$history['note_id']."/".$history['review_id'])."'>Revert</a>";
$html .= "<tr>".
"<td>".$image_link."</td>".
"<td>".$history_link."</td>".
"<td style='text-align:left;'>".$history['note']."</td>".
"<td>".$user_link."</td>".
"<td>".autodate($history['date'])."</td>";
if(!$user->is_anonymous()){
$html .= "<td>".$revert_link."</td>";
}
}
$html .= "</tr></tbody></table>";
$page->set_title("Note Updates");
$page->set_heading("Note Updates");
$page->add_block(new Block("Note Updates", $html, "main", 10));
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
global $page;
$html = $this->get_history($histories);
$page->set_title("Note Updates");
$page->set_heading("Note Updates");
$page->add_block(new Block("Note Updates", $html, "main", 10));
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
}
public function display_history($histories, $pageNumber, $totalPages) {
global $user, $page;
$html = "<table id='poolsList' class='zebra'>".
"<thead><tr>".
"<th>Image</th>".
"<th>Note</th>".
"<th>Body</th>".
"<th>Updater</th>".
"<th>Date</th>";
if(!$user->is_anonymous()){
$html .= "<th>Action</th>";
}
$html .= "</tr></thead>".
"<tbody>";
foreach($histories as $history) {
$image_link = "<a href='".make_link("post/view/".$history['image_id'])."'>".$history['image_id']."</a>";
$history_link = "<a href='".make_link("note/history/".$history['note_id'])."'>".$history['note_id'].".".$history['review_id']."</a>";
$user_link = "<a href='".make_link("user/".$history['user_name'])."'>".$history['user_name']."</a>";
$revert_link = "<a href='".make_link("note/revert/".$history['note_id']."/".$history['review_id'])."'>Revert</a>";
$html .= "<tr>".
"<td>".$image_link."</td>".
"<td>".$history_link."</td>".
"<td style='text-align:left;'>".$history['note']."</td>".
"<td>".$user_link."</td>".
"<td>".autodate($history['date'])."</td>";
if(!$user->is_anonymous()){
$html .= "<td>".$revert_link."</td>";
}
}
$html .= "</tr></tbody></table>";
global $page;
$html = $this->get_history($histories);
$page->set_title("Note History");
$page->set_heading("Note History");
$page->add_block(new Block("Note History", $html, "main", 10));

View File

@ -28,6 +28,7 @@ class Oekaki extends Extension {
throw new UploadException("File has no extension");
}
log_info("oekaki", "Processing file [{$pathinfo['filename']}]");
$metadata = array();
$metadata['filename'] = 'oekaki.png';
$metadata['extension'] = $pathinfo['extension'];
$metadata['tags'] = 'oekaki tagme';