more comments
This commit is contained in:
parent
80f5a016c2
commit
1ac88e8923
27 changed files with 195 additions and 160 deletions
|
@ -950,21 +950,19 @@ function transload($url, $mfile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if($config->get_string("transload_engine") === "fopen") {
|
if($config->get_string("transload_engine") === "fopen") {
|
||||||
$fp = @fopen($url, "r");
|
$fp_in = @fopen($url, "r");
|
||||||
if(!$fp) {
|
$fp_out = fopen($mfile, "w");
|
||||||
|
if(!$fp_in || !$fp_out) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$data = "";
|
|
||||||
$length = 0;
|
$length = 0;
|
||||||
while(!feof($fp) && $length <= $config->get_int('upload_size')) {
|
while(!feof($fp_in) && $length <= $config->get_int('upload_size')) {
|
||||||
$data .= fread($fp, 8192);
|
$data = fread($fp_in, 8192);
|
||||||
$length = strlen($data);
|
$length += strlen($data);
|
||||||
|
fwrite($fp_out, $data);
|
||||||
}
|
}
|
||||||
fclose($fp);
|
fclose($fp_in);
|
||||||
|
fclose($fp_out);
|
||||||
$fp = fopen($mfile, "w");
|
|
||||||
fwrite($fp, $data);
|
|
||||||
fclose($fp);
|
|
||||||
|
|
||||||
$headers = http_parse_headers(implode("\n", $http_response_header));
|
$headers = http_parse_headers(implode("\n", $http_response_header));
|
||||||
|
|
||||||
|
|
|
@ -321,44 +321,15 @@ class DanbooruApi extends Extension {
|
||||||
$source = null;
|
$source = null;
|
||||||
}
|
}
|
||||||
} elseif (isset($_REQUEST['source']) || isset($_REQUEST['post']['source'])) { // A url was provided
|
} elseif (isset($_REQUEST['source']) || isset($_REQUEST['post']['source'])) { // A url was provided
|
||||||
$url = isset($_REQUEST['source']) ? $_REQUEST['source'] : $_REQUEST['post']['source'];
|
$source = isset($_REQUEST['source']) ? $_REQUEST['source'] : $_REQUEST['post']['source'];
|
||||||
$source = $url;
|
$file = tempnam("/tmp", "shimmie_transload");
|
||||||
$tmp_filename = tempnam("/tmp", "shimmie_transload");
|
$ok = transload($source, $file);
|
||||||
|
if (!$ok) {
|
||||||
// Are we using fopen wrappers or curl?
|
$page->set_code(409);
|
||||||
if ($config->get_string("transload_engine") == "fopen") {
|
$page->add_http_header("X-Danbooru-Errors: fopen read error");
|
||||||
$fp = fopen($url, "r");
|
return;
|
||||||
if (!$fp) {
|
|
||||||
$page->set_code(409);
|
|
||||||
$page->add_http_header("X-Danbooru-Errors: fopen read error");
|
|
||||||
}
|
|
||||||
|
|
||||||
$data = "";
|
|
||||||
$length = 0;
|
|
||||||
while (!feof($fp) && $length <= $config->get_int('upload_size')) {
|
|
||||||
$data .= fread($fp, 8192);
|
|
||||||
$length = strlen($data);
|
|
||||||
}
|
|
||||||
fclose($fp);
|
|
||||||
|
|
||||||
$fp = fopen($tmp_filename, "w");
|
|
||||||
fwrite($fp, $data);
|
|
||||||
fclose($fp);
|
|
||||||
}
|
}
|
||||||
|
$filename = basename($source);
|
||||||
if ($config->get_string("transload_engine") == "curl") {
|
|
||||||
$ch = curl_init($url);
|
|
||||||
$fp = fopen($tmp_filename, "w");
|
|
||||||
|
|
||||||
curl_setopt($ch, CURLOPT_FILE, $fp);
|
|
||||||
curl_setopt($ch, CURLOPT_HEADER, 0);
|
|
||||||
|
|
||||||
curl_exec($ch);
|
|
||||||
curl_close($ch);
|
|
||||||
fclose($fp);
|
|
||||||
}
|
|
||||||
$file = $tmp_filename;
|
|
||||||
$filename = basename($url);
|
|
||||||
} else { // Nothing was specified at all
|
} else { // Nothing was specified at all
|
||||||
$page->set_code(409);
|
$page->set_code(409);
|
||||||
$page->add_http_header("X-Danbooru-Errors: no input files");
|
$page->add_http_header("X-Danbooru-Errors: no input files");
|
||||||
|
@ -367,8 +338,9 @@ class DanbooruApi extends Extension {
|
||||||
|
|
||||||
// Get tags out of url
|
// Get tags out of url
|
||||||
$posttags = Tag::explode(isset($_REQUEST['tags']) ? $_REQUEST['tags'] : $_REQUEST['post']['tags']);
|
$posttags = Tag::explode(isset($_REQUEST['tags']) ? $_REQUEST['tags'] : $_REQUEST['post']['tags']);
|
||||||
$hash = md5_file($file);
|
|
||||||
// Was an md5 supplied? Does it match the file hash?
|
// Was an md5 supplied? Does it match the file hash?
|
||||||
|
$hash = md5_file($file);
|
||||||
if (isset($_REQUEST['md5']) && strtolower($_REQUEST['md5']) != $hash) {
|
if (isset($_REQUEST['md5']) && strtolower($_REQUEST['md5']) != $hash) {
|
||||||
$page->set_code(409);
|
$page->set_code(409);
|
||||||
$page->add_http_header("X-Danbooru-Errors: md5 mismatch");
|
$page->add_http_header("X-Danbooru-Errors: md5 mismatch");
|
||||||
|
|
|
@ -23,7 +23,7 @@ class ExtensionInfo {
|
||||||
var $description, $documentation, $version, $visibility;
|
var $description, $documentation, $version, $visibility;
|
||||||
var $enabled;
|
var $enabled;
|
||||||
|
|
||||||
function __construct($main) {
|
public function __construct($main) {
|
||||||
$matches = array();
|
$matches = array();
|
||||||
$lines = file($main);
|
$lines = file($main);
|
||||||
$number_of_lines = count($lines);
|
$number_of_lines = count($lines);
|
||||||
|
@ -156,7 +156,7 @@ class ExtManager extends Extension {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $all
|
* @param bool $all
|
||||||
* @return array
|
* @return ExtensionInfo[]
|
||||||
*/
|
*/
|
||||||
private function get_extensions(/*bool*/ $all) {
|
private function get_extensions(/*bool*/ $all) {
|
||||||
$extensions = array();
|
$extensions = array();
|
||||||
|
|
|
@ -204,7 +204,7 @@ class Favorites extends Extension {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Image $image
|
* @param Image $image
|
||||||
* @return array
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
private function list_persons_who_have_favorited(Image $image) {
|
private function list_persons_who_have_favorited(Image $image) {
|
||||||
global $database;
|
global $database;
|
||||||
|
|
|
@ -44,7 +44,7 @@ class ArchiveFileHandler extends Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $ext
|
* @param string $ext
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function supported_ext($ext) {
|
private function supported_ext($ext) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ class FlashFileHandler extends DataHandlerExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $file
|
* @param string $file
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function check_contents(/*string*/ $file) {
|
protected function check_contents(/*string*/ $file) {
|
||||||
|
|
|
@ -50,7 +50,7 @@ class IcoFileHandler extends Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $ext
|
* @param string $ext
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function supported_ext($ext) {
|
private function supported_ext($ext) {
|
||||||
|
@ -59,8 +59,8 @@ class IcoFileHandler extends Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $filename
|
* @param string $filename
|
||||||
* @param $metadata
|
* @param mixed[] $metadata
|
||||||
* @return Image
|
* @return Image
|
||||||
*/
|
*/
|
||||||
private function create_image_from_data($filename, $metadata) {
|
private function create_image_from_data($filename, $metadata) {
|
||||||
|
|
|
@ -26,7 +26,7 @@ class MP3FileHandler extends DataHandlerExtension {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @param array $metadata
|
* @param mixed[] $metadata
|
||||||
* @return Image|null
|
* @return Image|null
|
||||||
*/
|
*/
|
||||||
protected function create_image_from_data($filename, $metadata) {
|
protected function create_image_from_data($filename, $metadata) {
|
||||||
|
|
|
@ -67,7 +67,7 @@ class PixelFileHandler extends DataHandlerExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $hash
|
* @param string $hash
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function create_thumb_force(/*string*/ $hash) {
|
protected function create_thumb_force(/*string*/ $hash) {
|
||||||
|
@ -91,9 +91,6 @@ class PixelFileHandler extends DataHandlerExtension {
|
||||||
return $ok;
|
return $ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param ImageAdminBlockBuildingEvent $event
|
|
||||||
*/
|
|
||||||
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) {
|
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) {
|
||||||
$event->add_part("
|
$event->add_part("
|
||||||
<form>
|
<form>
|
||||||
|
|
|
@ -51,7 +51,7 @@ class SVGFileHandler extends Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $ext
|
* @param string $ext
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function supported_ext($ext) {
|
private function supported_ext($ext) {
|
||||||
|
@ -60,8 +60,8 @@ class SVGFileHandler extends Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $filename
|
* @param string $filename
|
||||||
* @param $metadata
|
* @param mixed[] $metadata
|
||||||
* @return Image
|
* @return Image
|
||||||
*/
|
*/
|
||||||
private function create_image_from_data($filename, $metadata) {
|
private function create_image_from_data($filename, $metadata) {
|
||||||
|
@ -82,7 +82,7 @@ class SVGFileHandler extends Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $file
|
* @param string $file
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
private function check_contents($file) {
|
private function check_contents($file) {
|
||||||
|
|
|
@ -118,7 +118,7 @@ class VideoFileHandler extends DataHandlerExtension {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $filename
|
* @param string $filename
|
||||||
* @param array $metadata
|
* @param mixed[] $metadata
|
||||||
* @return Image|null
|
* @return Image|null
|
||||||
*/
|
*/
|
||||||
protected function create_image_from_data($filename, $metadata) {
|
protected function create_image_from_data($filename, $metadata) {
|
||||||
|
@ -162,7 +162,7 @@ class VideoFileHandler extends DataHandlerExtension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $file
|
* @param string $file
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function check_contents($file) {
|
protected function check_contents($file) {
|
||||||
|
|
|
@ -32,6 +32,9 @@ class ImageAdditionEvent extends Event {
|
||||||
class ImageAdditionException extends SCoreException {
|
class ImageAdditionException extends SCoreException {
|
||||||
var $error;
|
var $error;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $error
|
||||||
|
*/
|
||||||
public function __construct($error) {
|
public function __construct($error) {
|
||||||
$this->error = $error;
|
$this->error = $error;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,9 @@
|
||||||
class RemoveImageHashBanEvent extends Event {
|
class RemoveImageHashBanEvent extends Event {
|
||||||
var $hash;
|
var $hash;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $hash
|
||||||
|
*/
|
||||||
public function __construct($hash) {
|
public function __construct($hash) {
|
||||||
$this->hash = $hash;
|
$this->hash = $hash;
|
||||||
}
|
}
|
||||||
|
@ -23,6 +26,10 @@ class AddImageHashBanEvent extends Event {
|
||||||
var $hash;
|
var $hash;
|
||||||
var $reason;
|
var $reason;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $hash
|
||||||
|
* @param string $reason
|
||||||
|
*/
|
||||||
public function __construct($hash, $reason) {
|
public function __construct($hash, $reason) {
|
||||||
$this->hash = $hash;
|
$this->hash = $hash;
|
||||||
$this->reason = $reason;
|
$this->reason = $reason;
|
||||||
|
@ -126,6 +133,11 @@ class ImageBan extends Extension {
|
||||||
|
|
||||||
// DB funness
|
// DB funness
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $page
|
||||||
|
* @param int $size
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function get_image_hash_bans($page, $size=100) {
|
public function get_image_hash_bans($page, $size=100) {
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,11 @@
|
||||||
class IndexTheme extends Themelet {
|
class IndexTheme extends Themelet {
|
||||||
var $page_number, $total_pages, $search_terms;
|
var $page_number, $total_pages, $search_terms;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $page_number
|
||||||
|
* @param int $total_pages
|
||||||
|
* @param string[] $search_terms
|
||||||
|
*/
|
||||||
public function set_page($page_number, $total_pages, $search_terms) {
|
public function set_page($page_number, $total_pages, $search_terms) {
|
||||||
$this->page_number = $page_number;
|
$this->page_number = $page_number;
|
||||||
$this->total_pages = $total_pages;
|
$this->total_pages = $total_pages;
|
||||||
|
@ -27,6 +32,10 @@ and of course start organising your images :-)
|
||||||
$page->add_block(new Block("Installation Succeeded!", $text, "main", 0));
|
$page->add_block(new Block("Installation Succeeded!", $text, "main", 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Page $page
|
||||||
|
* @param Image[] $images
|
||||||
|
*/
|
||||||
public function display_page(Page $page, $images) {
|
public function display_page(Page $page, $images) {
|
||||||
$this->display_page_header($page, $images);
|
$this->display_page_header($page, $images);
|
||||||
|
|
||||||
|
@ -41,12 +50,21 @@ and of course start organising your images :-)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function display_admin_block(/*array(string)*/ $parts) {
|
/**
|
||||||
|
* @param string[] $parts
|
||||||
|
*/
|
||||||
|
public function display_admin_block($parts) {
|
||||||
global $page;
|
global $page;
|
||||||
$page->add_block(new Block("List Controls", join("<br>", $parts), "left", 50));
|
$page->add_block(new Block("List Controls", join("<br>", $parts), "left", 50));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $page_number
|
||||||
|
* @param int $total_pages
|
||||||
|
* @param string[] $search_terms
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
protected function build_navigation($page_number, $total_pages, $search_terms) {
|
protected function build_navigation($page_number, $total_pages, $search_terms) {
|
||||||
$prev = $page_number - 1;
|
$prev = $page_number - 1;
|
||||||
$next = $page_number + 1;
|
$next = $page_number + 1;
|
||||||
|
@ -72,6 +90,11 @@ and of course start organising your images :-)
|
||||||
return $h_prev.' | '.$h_index.' | '.$h_next.'<br>'.$h_search;
|
return $h_prev.' | '.$h_index.' | '.$h_next.'<br>'.$h_search;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Image[] $images
|
||||||
|
* @param string $query
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
protected function build_table($images, $query) {
|
protected function build_table($images, $query) {
|
||||||
$h_query = html_escape($query);
|
$h_query = html_escape($query);
|
||||||
$table = "<div class='shm-image-list' data-query='$h_query'>";
|
$table = "<div class='shm-image-list' data-query='$h_query'>";
|
||||||
|
@ -82,6 +105,10 @@ and of course start organising your images :-)
|
||||||
return $table;
|
return $table;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Page $page
|
||||||
|
* @param Image[] $images
|
||||||
|
*/
|
||||||
protected function display_page_header(Page $page, $images) {
|
protected function display_page_header(Page $page, $images) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -102,6 +129,10 @@ and of course start organising your images :-)
|
||||||
$page->set_heading($page_title);
|
$page->set_heading($page_title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Page $page
|
||||||
|
* @param Image[] $images
|
||||||
|
*/
|
||||||
protected function display_page_images(Page $page, $images) {
|
protected function display_page_images(Page $page, $images) {
|
||||||
if (count($this->search_terms) > 0) {
|
if (count($this->search_terms) > 0) {
|
||||||
$query = url_escape(implode(' ', $this->search_terms));
|
$query = url_escape(implode(' ', $this->search_terms));
|
||||||
|
|
|
@ -16,62 +16,54 @@ class MassTagger extends Extension {
|
||||||
public function onPostListBuilding(PostListBuildingEvent $event) {
|
public function onPostListBuilding(PostListBuildingEvent $event) {
|
||||||
global $config, $page, $user;
|
global $config, $page, $user;
|
||||||
|
|
||||||
if( !$user->is_admin() ) return;
|
if($user->is_admin()) {
|
||||||
|
$this->theme->display_mass_tagger( $page, $event, $config );
|
||||||
$this->theme->display_mass_tagger( $page, $event, $config );
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function onPageRequest(PageRequestEvent $event) {
|
public function onPageRequest(PageRequestEvent $event) {
|
||||||
global $config, $page, $user;
|
global $page, $user;
|
||||||
if( !$event->page_matches("mass_tagger") ) return;
|
if($event->page_matches("mass_tagger/tag") && $user->is_admin()) {
|
||||||
if( !$user->is_admin() ) return;
|
if( !isset($_POST['ids']) or !isset($_POST['tag']) ) return;
|
||||||
|
|
||||||
if($event->get_arg(0) == "tag") $this->_apply_mass_tags( $config, $page, $user, $event );
|
$tag = $_POST['tag'];
|
||||||
}
|
|
||||||
|
$tag_array = explode(" ",$tag);
|
||||||
private function _apply_mass_tags( $config, Page $page, $user, $event ) {
|
$pos_tag_array = array();
|
||||||
if( !isset($_POST['ids']) or !isset($_POST['tag']) ) return;
|
$neg_tag_array = array();
|
||||||
|
foreach($tag_array as $new_tag) {
|
||||||
$tag = $_POST['tag'];
|
if (strpos($new_tag, '-') === 0)
|
||||||
|
$neg_tag_array[] = substr($new_tag,1);
|
||||||
$tag_array = explode(" ",$tag);
|
|
||||||
$pos_tag_array = array();
|
|
||||||
$neg_tag_array = array();
|
|
||||||
foreach($tag_array as $new_tag) {
|
|
||||||
if (strpos($new_tag, '-') === 0)
|
|
||||||
$neg_tag_array[] = substr($new_tag,1);
|
|
||||||
else
|
|
||||||
$pos_tag_array[] = $new_tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
$ids = explode( ':', $_POST['ids'] );
|
|
||||||
$ids = array_filter ( $ids , 'is_numeric' );
|
|
||||||
|
|
||||||
$images = array_map( "Image::by_id", $ids );
|
|
||||||
|
|
||||||
if(isset($_POST['setadd']) &&
|
|
||||||
$_POST['setadd'] == 'set')
|
|
||||||
{
|
|
||||||
foreach($images as $image) {
|
|
||||||
$image->set_tags(Tag::explode($tag));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
foreach($images as $image) {
|
|
||||||
if (!empty($neg_tag_array)) {
|
|
||||||
$img_tags = array_merge($pos_tag_array, explode(" ",$image->get_tag_list()));
|
|
||||||
$img_tags = array_diff($img_tags, $neg_tag_array);
|
|
||||||
$image->set_tags(Tag::explode($img_tags));
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
$image->set_tags(Tag::explode($tag . " " . $image->get_tag_list()));
|
$pos_tag_array[] = $new_tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$ids = explode( ':', $_POST['ids'] );
|
||||||
|
$ids = array_filter ( $ids , 'is_numeric' );
|
||||||
|
|
||||||
|
$images = array_map( "Image::by_id", $ids );
|
||||||
|
|
||||||
|
if(isset($_POST['setadd']) && $_POST['setadd'] == 'set') {
|
||||||
|
foreach($images as $image) {
|
||||||
|
$image->set_tags(Tag::explode($tag));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
foreach($images as $image) {
|
||||||
|
if (!empty($neg_tag_array)) {
|
||||||
|
$img_tags = array_merge($pos_tag_array, explode(" ",$image->get_tag_list()));
|
||||||
|
$img_tags = array_diff($img_tags, $neg_tag_array);
|
||||||
|
$image->set_tags(Tag::explode($img_tags));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
$image->set_tags(Tag::explode($tag . " " . $image->get_tag_list()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$page->set_mode("redirect");
|
||||||
|
if(!isset($_SERVER['HTTP_REFERER'])) $_SERVER['HTTP_REFERER'] = make_link();
|
||||||
|
$page->set_redirect($_SERVER['HTTP_REFERER']);
|
||||||
}
|
}
|
||||||
|
|
||||||
$page->set_mode("redirect");
|
|
||||||
if(!isset($_SERVER['HTTP_REFERER'])) $_SERVER['HTTP_REFERER'] = make_link();
|
|
||||||
$page->set_redirect($_SERVER['HTTP_REFERER']);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,10 @@ class NotATag extends Extension {
|
||||||
$this->scan($event->tags);
|
$this->scan($event->tags);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function scan(/*array*/ $tags_mixed) {
|
/**
|
||||||
|
* @param string[] $tags_mixed
|
||||||
|
*/
|
||||||
|
private function scan($tags_mixed) {
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
$tags = array();
|
$tags = array();
|
||||||
|
@ -90,6 +93,11 @@ class NotATag extends Extension {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $page
|
||||||
|
* @param int $size
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
public function get_untags($page, $size=100) {
|
public function get_untags($page, $size=100) {
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
|
|
|
@ -13,7 +13,12 @@
|
||||||
class NumericScoreSetEvent extends Event {
|
class NumericScoreSetEvent extends Event {
|
||||||
var $image_id, $user, $score;
|
var $image_id, $user, $score;
|
||||||
|
|
||||||
public function __construct(/*int*/ $image_id, User $user, /*int*/ $score) {
|
/**
|
||||||
|
* @param int $image_id
|
||||||
|
* @param User $user
|
||||||
|
* @param int $score
|
||||||
|
*/
|
||||||
|
public function __construct($image_id, User $user, $score) {
|
||||||
$this->image_id = $image_id;
|
$this->image_id = $image_id;
|
||||||
$this->user = $user;
|
$this->user = $user;
|
||||||
$this->score = $score;
|
$this->score = $score;
|
||||||
|
@ -168,7 +173,10 @@ class NumericScore extends Extension {
|
||||||
$this->delete_votes_by($event->id);
|
$this->delete_votes_by($event->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete_votes_by(/*int*/ $user_id) {
|
/**
|
||||||
|
* @param int $user_id
|
||||||
|
*/
|
||||||
|
public function delete_votes_by($user_id) {
|
||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
$image_ids = $database->get_col("SELECT image_id FROM numeric_score_votes WHERE user_id=?", array($user_id));
|
$image_ids = $database->get_col("SELECT image_id FROM numeric_score_votes WHERE user_id=?", array($user_id));
|
||||||
|
@ -290,7 +298,7 @@ class NumericScore extends Extension {
|
||||||
* @param int $user_id
|
* @param int $user_id
|
||||||
* @param int $score
|
* @param int $score
|
||||||
*/
|
*/
|
||||||
private function add_vote(/*int*/ $image_id, /*int*/ $user_id, /*int*/ $score) {
|
private function add_vote($image_id, $user_id, $score) {
|
||||||
global $database;
|
global $database;
|
||||||
$database->execute(
|
$database->execute(
|
||||||
"DELETE FROM numeric_score_votes WHERE image_id=:imageid AND user_id=:userid",
|
"DELETE FROM numeric_score_votes WHERE image_id=:imageid AND user_id=:userid",
|
||||||
|
|
|
@ -260,13 +260,13 @@ class Pools extends Extension {
|
||||||
|
|
||||||
if($config->get_bool("poolsInfoOnViewImage")) {
|
if($config->get_bool("poolsInfoOnViewImage")) {
|
||||||
$imageID = $event->image->id;
|
$imageID = $event->image->id;
|
||||||
$poolsIDs = $this->get_pool_id($imageID);
|
$poolsIDs = $this->get_pool_ids($imageID);
|
||||||
|
|
||||||
$show_nav = $config->get_bool("poolsShowNavLinks", false);
|
$show_nav = $config->get_bool("poolsShowNavLinks", false);
|
||||||
|
|
||||||
$navInfo = array();
|
$navInfo = array();
|
||||||
foreach($poolsIDs as $poolID) {
|
foreach($poolsIDs as $poolID) {
|
||||||
$pool = $this->get_single_pool($poolID['pool_id']);
|
$pool = $this->get_single_pool($poolID);
|
||||||
|
|
||||||
$navInfo[$pool['id']] = array();
|
$navInfo[$pool['id']] = array();
|
||||||
$navInfo[$pool['id']]['info'] = $pool;
|
$navInfo[$pool['id']]['info'] = $pool;
|
||||||
|
@ -411,7 +411,7 @@ class Pools extends Extension {
|
||||||
/**
|
/**
|
||||||
* HERE WE CREATE A NEW POOL
|
* HERE WE CREATE A NEW POOL
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return int
|
||||||
* @throws PoolCreationException
|
* @throws PoolCreationException
|
||||||
*/
|
*/
|
||||||
private function add_pool() {
|
private function add_pool() {
|
||||||
|
@ -433,12 +433,9 @@ class Pools extends Extension {
|
||||||
VALUES (:uid, :public, :title, :desc, now())",
|
VALUES (:uid, :public, :title, :desc, now())",
|
||||||
array("uid"=>$user->id, "public"=>$public, "title"=>$_POST["title"], "desc"=>$_POST["description"]));
|
array("uid"=>$user->id, "public"=>$public, "title"=>$_POST["title"], "desc"=>$_POST["description"]));
|
||||||
|
|
||||||
$result = array();
|
$poolID = $database->get_last_insert_id('pools_id_seq');
|
||||||
$result['poolID'] = $database->get_last_insert_id('pools_id_seq');
|
log_info("pools", "Pool {$poolID} created by {$user->name}");
|
||||||
|
return $poolID;
|
||||||
log_info("pools", "Pool {$result["poolID"]} created by {$user->name}");
|
|
||||||
|
|
||||||
return $result["poolID"];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -477,11 +474,11 @@ class Pools extends Extension {
|
||||||
/**
|
/**
|
||||||
* Get all of the pool IDs that an image is in, given an image ID.
|
* Get all of the pool IDs that an image is in, given an image ID.
|
||||||
* @param int $imageID Integer ID for the image
|
* @param int $imageID Integer ID for the image
|
||||||
* @return array
|
* @return int[]
|
||||||
*/
|
*/
|
||||||
private function get_pool_id(/*int*/ $imageID) {
|
private function get_pool_ids(/*int*/ $imageID) {
|
||||||
global $database;
|
global $database;
|
||||||
return $database->get_all("SELECT pool_id FROM pool_images WHERE image_id=:iid", array("iid"=>$imageID));
|
return $database->get_col("SELECT pool_id FROM pool_images WHERE image_id=:iid", array("iid"=>$imageID));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -141,7 +141,10 @@ class ReportImage extends Extension {
|
||||||
$this->delete_reports_by($event->id);
|
$this->delete_reports_by($event->id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function delete_reports_by(/*int*/ $user_id) {
|
/**
|
||||||
|
* @param int $user_id
|
||||||
|
*/
|
||||||
|
public function delete_reports_by($user_id) {
|
||||||
global $database;
|
global $database;
|
||||||
$database->execute("DELETE FROM image_reports WHERE reporter_id=?", array($user_id));
|
$database->execute("DELETE FROM image_reports WHERE reporter_id=?", array($user_id));
|
||||||
$database->cache->delete("image-report-count");
|
$database->cache->delete("image-report-count");
|
||||||
|
@ -165,7 +168,7 @@ class ReportImage extends Extension {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Image $image
|
* @param Image $image
|
||||||
* @return array
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
public function get_reporters(Image $image) {
|
public function get_reporters(Image $image) {
|
||||||
global $database;
|
global $database;
|
||||||
|
@ -206,7 +209,7 @@ class ReportImage extends Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return mixed
|
* @return int
|
||||||
*/
|
*/
|
||||||
public function count_reported_images() {
|
public function count_reported_images() {
|
||||||
global $database;
|
global $database;
|
||||||
|
@ -220,13 +223,3 @@ class ReportImage extends Extension {
|
||||||
return $count;
|
return $count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// ===== Changelog =====
|
|
||||||
// * Version 0.3a / 0.3a_rc - 11/06/07 - I can no longer use the same theme.php file for both SVN and RCx. Sorry.
|
|
||||||
// * Same deal with theme.php as it is with main.php
|
|
||||||
// * Version 0.3 / 0.3_rc - 11/06/07 - Added the option to display thumbnails, moved the reported image list to it's
|
|
||||||
// own page, and checked to make sure the user is an admin before letting them delete / view reported images.
|
|
||||||
// * Version 0.2c_rc2 - 10/27/07 - Now (really!) supports Shimmie2 RC2!
|
|
||||||
// * Version 0.2b - 10/27/07 - Now supports Shimmie2 RC2!
|
|
||||||
// * Version 0.2a - 10/24/07 - Fixed some SQL issues. I will make sure to test before commiting :)
|
|
||||||
// * Version 0.2 - 10/24/07 - First public release.
|
|
||||||
|
|
||||||
|
|
|
@ -291,7 +291,7 @@ class ResizeImage extends Extension {
|
||||||
* 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 $info
|
||||||
* @return array
|
* @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'])) {
|
||||||
|
@ -308,7 +308,7 @@ class ResizeImage extends Extension {
|
||||||
* @param Image $image_obj
|
* @param Image $image_obj
|
||||||
* @param $width
|
* @param $width
|
||||||
* @param $height
|
* @param $height
|
||||||
* @return array
|
* @return int[]
|
||||||
*/
|
*/
|
||||||
private function calc_new_size(Image $image_obj, $width, $height) {
|
private function calc_new_size(Image $image_obj, $width, $height) {
|
||||||
/* Calculate the new size of the image */
|
/* Calculate the new size of the image */
|
||||||
|
|
|
@ -113,7 +113,7 @@ class ShimmieApi extends Extension {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $arg
|
* @param string $arg
|
||||||
* @return array
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
private function api_get_tags($arg) {
|
private function api_get_tags($arg) {
|
||||||
global $database;
|
global $database;
|
||||||
|
|
|
@ -234,8 +234,8 @@ class Upload extends Extension {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string|int $id
|
* @param int $id
|
||||||
* @return array
|
* @return string[]
|
||||||
*/
|
*/
|
||||||
private function tags_for_upload_slot($id) {
|
private function tags_for_upload_slot($id) {
|
||||||
if(isset($_POST["tags$id"])) {
|
if(isset($_POST["tags$id"])) {
|
||||||
|
|
|
@ -30,7 +30,7 @@ class Themelet extends BaseThemelet {
|
||||||
* @param string $base_url
|
* @param string $base_url
|
||||||
* @param string $query
|
* @param string $query
|
||||||
* @param int|string $page
|
* @param int|string $page
|
||||||
* @param int|string $current_page
|
* @param int $current_page
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class CustomIndexTheme extends IndexTheme {
|
class CustomIndexTheme extends IndexTheme {
|
||||||
|
/**
|
||||||
|
* @param Page $page
|
||||||
|
* @param Image[] $images
|
||||||
|
*/
|
||||||
public function display_page(Page $page, $images) {
|
public function display_page(Page $page, $images) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
@ -33,7 +37,12 @@ class CustomIndexTheme extends IndexTheme {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param int $page_number
|
||||||
|
* @param int $total_pages
|
||||||
|
* @param string[] $search_terms
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
protected function build_navigation($page_number, $total_pages, $search_terms) {
|
protected function build_navigation($page_number, $total_pages, $search_terms) {
|
||||||
$h_search_string = count($search_terms) == 0 ? "" : html_escape(implode(" ", $search_terms));
|
$h_search_string = count($search_terms) == 0 ? "" : html_escape(implode(" ", $search_terms));
|
||||||
$h_search_link = make_link();
|
$h_search_link = make_link();
|
||||||
|
@ -48,6 +57,11 @@ class CustomIndexTheme extends IndexTheme {
|
||||||
return $h_search;
|
return $h_search;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Image[] $images
|
||||||
|
* @param string $query
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
protected function build_table($images, $query) {
|
protected function build_table($images, $query) {
|
||||||
$h_query = html_escape($query);
|
$h_query = html_escape($query);
|
||||||
$table = "<div class='shm-image-list' data-query='$h_query'>";
|
$table = "<div class='shm-image-list' data-query='$h_query'>";
|
||||||
|
|
|
@ -264,12 +264,18 @@ $header_html
|
||||||
</html>
|
</html>
|
||||||
EOD;
|
EOD;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $link
|
||||||
|
* @param string $desc
|
||||||
|
* @param string[] $pages_matched
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
private function navlinks($link, $desc, $pages_matched) {
|
private function navlinks($link, $desc, $pages_matched) {
|
||||||
/**
|
/**
|
||||||
* Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.)
|
* Woo! We can actually SEE THE CURRENT PAGE!! (well... see it highlighted in the menu.)
|
||||||
*/
|
*/
|
||||||
$html = null;
|
$html = "";
|
||||||
$url = _get_query();
|
$url = _get_query();
|
||||||
|
|
||||||
$re1='.*?';
|
$re1='.*?';
|
||||||
|
@ -286,7 +292,7 @@ EOD;
|
||||||
$html = "<li class='current-page'><a href='$link'>$desc</a></li>";
|
$html = "<li class='current-page'><a href='$link'>$desc</a></li>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(is_null($html)) {$html = "<li><a class='tab' href='$link'>$desc</a></li>";}
|
if(empty($html)) {$html = "<li><a class='tab' href='$link'>$desc</a></li>";}
|
||||||
return $html;
|
return $html;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ class Themelet extends BaseThemelet {
|
||||||
* @param string $base_url
|
* @param string $base_url
|
||||||
* @param string $query
|
* @param string $query
|
||||||
* @param int|string $page
|
* @param int|string $page
|
||||||
* @param int|string $current_page
|
* @param int $current_page
|
||||||
* @param string $name
|
* @param string $name
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -16,7 +16,11 @@ class CustomViewImageTheme extends ViewImageTheme {
|
||||||
$page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 11));
|
$page->add_block(new Block(null, $this->build_info($image, $editor_parts), "main", 11));
|
||||||
$page->add_block(new Block(null, $this->build_pin($image), "main", 11));
|
$page->add_block(new Block(null, $this->build_pin($image), "main", 11));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Image $image
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
private function build_stats(Image $image) {
|
private function build_stats(Image $image) {
|
||||||
$h_owner = html_escape($image->get_owner()->name);
|
$h_owner = html_escape($image->get_owner()->name);
|
||||||
$h_ownerlink = "<a href='".make_link("user/$h_owner")."'>$h_owner</a>";
|
$h_ownerlink = "<a href='".make_link("user/$h_owner")."'>$h_owner</a>";
|
||||||
|
|
Reference in a new issue