Merge branch 'master' of github.com:shish/shimmie2
This commit is contained in:
commit
3584f40551
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,8 +1,10 @@
|
|||||||
.svn
|
.svn
|
||||||
|
backup
|
||||||
config.php
|
config.php
|
||||||
images
|
|
||||||
thumbs
|
|
||||||
data
|
data
|
||||||
|
images
|
||||||
|
imgdump-*.zip
|
||||||
|
thumbs
|
||||||
sql.log
|
sql.log
|
||||||
shimmie.log
|
shimmie.log
|
||||||
!lib/images
|
!lib/images
|
||||||
|
@ -78,6 +78,13 @@ class AdminPage extends Extension {
|
|||||||
case 'database dump':
|
case 'database dump':
|
||||||
$this->dbdump($page);
|
$this->dbdump($page);
|
||||||
break;
|
break;
|
||||||
|
case 'reset image ids':
|
||||||
|
$this->reset_imageids();
|
||||||
|
$redirect = true;
|
||||||
|
break;
|
||||||
|
case 'image dump':
|
||||||
|
$this->imgdump($page);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($redirect) {
|
if($redirect) {
|
||||||
@ -175,5 +182,67 @@ class AdminPage extends Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
private function reset_imageids() {
|
||||||
|
global $database;
|
||||||
|
//This might be a bit laggy on boards with lots of images (?)
|
||||||
|
//Seems to work fine with 1.2k~ images though.
|
||||||
|
$i = 0;
|
||||||
|
$image = $database->get_all("SELECT * FROM images ORDER BY images.id ASC");
|
||||||
|
/*$score_log = $database->get_all("SELECT message FROM score_log");*/
|
||||||
|
foreach($image as $img){
|
||||||
|
$xid = $img[0];
|
||||||
|
$i = $i + 1;
|
||||||
|
$table = array( //Might be missing some tables?
|
||||||
|
"image_tags", "tag_histories", "image_reports", "comments", "user_favorites", "tag_histories",
|
||||||
|
"numeric_score_votes", "pool_images", "slext_progress_cache", "notes");
|
||||||
|
|
||||||
|
$sql =
|
||||||
|
"SET FOREIGN_KEY_CHECKS=0;
|
||||||
|
UPDATE images
|
||||||
|
SET id=".$i.
|
||||||
|
" WHERE id=".$xid.";"; //id for images
|
||||||
|
|
||||||
|
foreach($table as $tbl){
|
||||||
|
$sql .= "
|
||||||
|
UPDATE ".$tbl."
|
||||||
|
SET image_id=".$i."
|
||||||
|
WHERE image_id=".$xid.";";
|
||||||
|
}
|
||||||
|
|
||||||
|
/*foreach($score_log as $sl){
|
||||||
|
//This seems like a bad idea.
|
||||||
|
//TODO: Might be better for log_info to have an $id option (which would then affix the id to the table?)
|
||||||
|
preg_replace(".Image \\#[0-9]+.", "Image #".$i, $sl);
|
||||||
|
}*/
|
||||||
|
$sql .= " SET FOREIGN_KEY_CHECKS=1;";
|
||||||
|
$database->execute($sql);
|
||||||
|
}
|
||||||
|
$count = (count($image)) + 1;
|
||||||
|
$database->execute("ALTER TABLE images AUTO_INCREMENT=".$count);
|
||||||
|
}
|
||||||
|
|
||||||
|
private function imgdump($page) {
|
||||||
|
global $database;
|
||||||
|
$zip = new ZipArchive;
|
||||||
|
$images = $database->get_all("SELECT * FROM images");
|
||||||
|
$filename = 'imgdump-'.date('Ymd').'.zip';
|
||||||
|
|
||||||
|
if($zip->open($filename, 1 ? ZIPARCHIVE::OVERWRITE:ZIPARCHIVE::CREATE)===TRUE){
|
||||||
|
foreach($images as $img){
|
||||||
|
$hash = $img["hash"];
|
||||||
|
preg_match("^[A-Za-z0-9]{2}^", $hash, $matches);
|
||||||
|
$img_loc = "images/".$matches[0]."/".$hash;
|
||||||
|
if(file_exists($img_loc)){
|
||||||
|
$zip->addFile($img_loc, $hash.".".$img["ext"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
$zip->close();
|
||||||
|
}
|
||||||
|
$page->set_mode("redirect");
|
||||||
|
$page->set_redirect(make_link($filename)); //Fairly sure there is better way to do this..
|
||||||
|
//TODO: Delete file after downloaded?
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -19,13 +19,26 @@ class AdminPageTheme extends Themelet {
|
|||||||
public function display_form(Page $page) {
|
public function display_form(Page $page) {
|
||||||
global $user;
|
global $user;
|
||||||
|
|
||||||
$html = "
|
$html = '
|
||||||
".make_form(make_link("admin_utils"))."
|
<script type="text/javascript">
|
||||||
<select name='action'>
|
function imgidconfirm(){
|
||||||
|
if(document.getElementById("misc").selectedIndex == 4){
|
||||||
|
if(confirm("This function WILL break any bookmarks & links.\n The event log will also not be updated with new ids. \n Are you sure you wish to continue?")){
|
||||||
|
return true;
|
||||||
|
}else{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
'.make_form(make_link("admin_utils"),"post", false, false, "return imgidconfirm()")."
|
||||||
|
<select name='action' id='misc'>
|
||||||
<option value='lowercase all tags'>All tags to lowercase</option>
|
<option value='lowercase all tags'>All tags to lowercase</option>
|
||||||
<option value='recount tag use'>Recount tag use</option>
|
<option value='recount tag use'>Recount tag use</option>
|
||||||
<option value='purge unused tags'>Purge unused tags</option>
|
<option value='purge unused tags'>Purge unused tags</option>
|
||||||
<option value='database dump'>Download database contents</option>
|
<option value='database dump'>Download database contents</option>
|
||||||
|
<option value='reset image ids'>Reset image ids</option>
|
||||||
|
<option value='image dump'>Download all images</option>
|
||||||
<!--<option value='convert to innodb'>Convert database to InnoDB (MySQL only)</option>-->
|
<!--<option value='convert to innodb'>Convert database to InnoDB (MySQL only)</option>-->
|
||||||
</select>
|
</select>
|
||||||
<input type='submit' value='Go'>
|
<input type='submit' value='Go'>
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* Name: Comment Word Ban
|
* Name: Comment Word Ban
|
||||||
* Author: Shish <webmaster@shishnet.org>
|
* Author: Shish <webmaster@shishnet.org>
|
||||||
|
* Link: http://code.shishnet.org/shimmie2/
|
||||||
* License: GPLv2
|
* License: GPLv2
|
||||||
* Description: For stopping spam and other comment abuse
|
* Description: For stopping spam and other comment abuse
|
||||||
* Documentation:
|
* Documentation:
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* Name: Bulk Add
|
* Name: Bulk Add
|
||||||
* Author: Shish <webmaster@shishnet.org>
|
* Author: Shish <webmaster@shishnet.org>
|
||||||
|
* Link: http://code.shishnet.org/shimmie2/
|
||||||
* License: GPLv2
|
* License: GPLv2
|
||||||
* Description: Bulk add server-side images
|
* Description: Bulk add server-side images
|
||||||
* Documentation:
|
* Documentation:
|
||||||
@ -30,7 +31,9 @@ class BulkAdd extends Extension {
|
|||||||
$this->theme->display_admin_block();
|
$this->theme->display_admin_block();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate the necessary DataUploadEvent for a given image and tags.
|
||||||
|
*/
|
||||||
private function add_image($tmpname, $filename, $tags) {
|
private function add_image($tmpname, $filename, $tags) {
|
||||||
assert(file_exists($tmpname));
|
assert(file_exists($tmpname));
|
||||||
|
|
||||||
|
@ -29,6 +29,9 @@ class ET extends Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collect the information and return it in a keyed array.
|
||||||
|
*/
|
||||||
private function get_info() {
|
private function get_info() {
|
||||||
global $config, $database;
|
global $config, $database;
|
||||||
global $_event_listeners; // yay for using secret globals \o/
|
global $_event_listeners; // yay for using secret globals \o/
|
||||||
|
@ -24,6 +24,8 @@ class FavoritesTheme extends Themelet {
|
|||||||
$i_favorites = count($username_array);
|
$i_favorites = count($username_array);
|
||||||
$html = "$i_favorites people:";
|
$html = "$i_favorites people:";
|
||||||
|
|
||||||
|
reset($username_array); // rewind to first element in array.
|
||||||
|
|
||||||
foreach($username_array as $row) {
|
foreach($username_array as $row) {
|
||||||
$username = html_escape($row);
|
$username = html_escape($row);
|
||||||
$html .= "<br><a href='".make_link("user/$username")."'>$username</a>";
|
$html .= "<br><a href='".make_link("user/$username")."'>$username</a>";
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* Name: Featured Image
|
* Name: Featured Image
|
||||||
* Author: Shish <webmaster@shishnet.org>
|
* Author: Shish <webmaster@shishnet.org>
|
||||||
|
* Link: http://code.shishnet.org/shimmie2/
|
||||||
* License: GPLv2
|
* License: GPLv2
|
||||||
* Description: Bring a specific image to the users' attentions
|
* Description: Bring a specific image to the users' attentions
|
||||||
* Documentation:
|
* Documentation:
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
/*
|
/*
|
||||||
* Name: Handle Flash
|
* Name: Handle Flash
|
||||||
* Author: Shish <webmaster@shishnet.org>
|
* Author: Shish <webmaster@shishnet.org>
|
||||||
* Description: Handle Flash files
|
* Link: http://code.shishnet.org/shimmie2/
|
||||||
|
* Description: Handle Flash files. (No thumbnail is generated for flash files)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class FlashFileHandler extends DataHandlerExtension {
|
class FlashFileHandler extends DataHandlerExtension {
|
||||||
|
@ -2,7 +2,8 @@
|
|||||||
/*
|
/*
|
||||||
* Name: Handle SVG
|
* Name: Handle SVG
|
||||||
* Author: Shish <webmaster@shishnet.org>
|
* Author: Shish <webmaster@shishnet.org>
|
||||||
* Description: Handle SVG files
|
* Link: http://code.shishnet.org/shimmie2/
|
||||||
|
* Description: Handle SVG files. (No thumbnail is generated for SVG files)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class SVGFileHandler extends Extension {
|
class SVGFileHandler extends Extension {
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* Name: IP Ban
|
* Name: IP Ban
|
||||||
* Author: Shish <webmaster@shishnet.org>
|
* Author: Shish <webmaster@shishnet.org>
|
||||||
|
* Link: http://code.shishnet.org/shimmie2/
|
||||||
* License: GPLv2
|
* License: GPLv2
|
||||||
* Description: Ban IP addresses
|
* Description: Ban IP addresses
|
||||||
* Documentation:
|
* Documentation:
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Name: Logging (Database)
|
* Name: Logging (Database)
|
||||||
* Author: Shish
|
* Author: Shish <webmaster@shishnet.org>
|
||||||
* Description: Keep a record of SCore events
|
* Link: http://code.shishnet.org/shimmie2/
|
||||||
|
* Description: Keep a record of SCore events (in the database).
|
||||||
* Visibility: admin
|
* Visibility: admin
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
@ -41,6 +41,8 @@ class LogDatabaseTheme extends Themelet {
|
|||||||
</thead>
|
</thead>
|
||||||
<tbody>\n";
|
<tbody>\n";
|
||||||
$n = 0;
|
$n = 0;
|
||||||
|
reset($events); // rewind to first element in array.
|
||||||
|
|
||||||
foreach($events as $event) {
|
foreach($events as $event) {
|
||||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||||
$c = $this->pri_to_col($event['priority']);
|
$c = $this->pri_to_col($event['priority']);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* Name: News
|
* Name: News
|
||||||
* Author: Shish <webmaster@shishnet.org>
|
* Author: Shish <webmaster@shishnet.org>
|
||||||
|
* Link: http://code.shishnet.org/shimmie2/
|
||||||
* License: GPLv2
|
* License: GPLv2
|
||||||
* Description: Show a short amount of text in a block on the post list
|
* Description: Show a short amount of text in a block on the post list
|
||||||
* Documentation:
|
* Documentation:
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* Name: Image Scores (Numeric)
|
* Name: Image Scores (Numeric)
|
||||||
* Author: Shish <webmaster@shishnet.org>
|
* Author: Shish <webmaster@shishnet.org>
|
||||||
|
* Link: http://code.shishnet.org/shimmie2/
|
||||||
* License: GPLv2
|
* License: GPLv2
|
||||||
* Description: Allow users to score images
|
* Description: Allow users to score images
|
||||||
* Documentation:
|
* Documentation:
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* Name: Random Image
|
* Name: Random Image
|
||||||
* Author: Shish <webmaster@shishnet.org>
|
* Author: Shish <webmaster@shishnet.org>
|
||||||
|
* Link: http://code.shishnet.org/shimmie2/
|
||||||
* License: GPLv2
|
* License: GPLv2
|
||||||
* Description: Do things with a random image
|
* Description: Do things with a random image
|
||||||
* Documentation:
|
* Documentation:
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* Name: Image Ratings
|
* Name: Image Ratings
|
||||||
* Author: Shish <webmaster@shishnet.org>
|
* Author: Shish <webmaster@shishnet.org>
|
||||||
|
* Link: http://code.shishnet.org/shimmie2/
|
||||||
* License: GPLv2
|
* License: GPLv2
|
||||||
* Description: Allow users to rate images "safe", "questionable" or "explicit"
|
* Description: Allow users to rate images "safe", "questionable" or "explicit"
|
||||||
*/
|
*/
|
||||||
@ -33,6 +34,9 @@ class Ratings extends Extension {
|
|||||||
while(true) {
|
while(true) {
|
||||||
$images = Image::find_images($n, 100, Tag::explode($_POST["query"]));
|
$images = Image::find_images($n, 100, Tag::explode($_POST["query"]));
|
||||||
if(count($images) == 0) break;
|
if(count($images) == 0) break;
|
||||||
|
|
||||||
|
reset($images); // rewind to first element in array.
|
||||||
|
|
||||||
foreach($images as $image) {
|
foreach($images as $image) {
|
||||||
send_event(new RatingSetEvent($image, $user, $_POST['rating']));
|
send_event(new RatingSetEvent($image, $user, $_POST['rating']));
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* Name: Regen Thumb
|
* Name: Regen Thumb
|
||||||
* Author: Shish <webmaster@shishnet.org>
|
* Author: Shish <webmaster@shishnet.org>
|
||||||
|
* Link: http://code.shishnet.org/shimmie2/
|
||||||
* License: GPLv2
|
* License: GPLv2
|
||||||
* Description: Regenerate a thumbnail image
|
* Description: Regenerate a thumbnail image
|
||||||
* Documentation:
|
* Documentation:
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
/*
|
/*
|
||||||
* Name: Site Description
|
* Name: Site Description
|
||||||
* Author: Shish <webmaster@shishnet.org>
|
* Author: Shish <webmaster@shishnet.org>
|
||||||
|
* Link: http://code.shishnet.org/shimmie2/
|
||||||
* License: GPLv2
|
* License: GPLv2
|
||||||
* Visibility: admin
|
* Visibility: admin
|
||||||
* Description: A description for search engines
|
* Description: A description for search engines
|
||||||
|
@ -188,6 +188,7 @@ class DatabaseConfig extends BaseConfig {
|
|||||||
*/
|
*/
|
||||||
public function save(/*string*/ $name=null) {
|
public function save(/*string*/ $name=null) {
|
||||||
if(is_null($name)) {
|
if(is_null($name)) {
|
||||||
|
reset($this->values); // rewind the array to the first element
|
||||||
foreach($this->values as $name => $value) {
|
foreach($this->values as $name => $value) {
|
||||||
$this->save(/*string*/ $name);
|
$this->save(/*string*/ $name);
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,8 @@ class PageRequestEvent extends Event {
|
|||||||
* Test if the requested path matches a given pattern.
|
* Test if the requested path matches a given pattern.
|
||||||
*
|
*
|
||||||
* If it matches, store the remaining path elements in $args
|
* If it matches, store the remaining path elements in $args
|
||||||
|
*
|
||||||
|
* @retval bool
|
||||||
*/
|
*/
|
||||||
public function page_matches(/*string*/ $name) {
|
public function page_matches(/*string*/ $name) {
|
||||||
$parts = explode("/", $name);
|
$parts = explode("/", $name);
|
||||||
@ -57,6 +59,11 @@ class PageRequestEvent extends Event {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the n th argument of the page request (if it exists.)
|
||||||
|
* @param $n integer
|
||||||
|
* @retval The argmuent (string) or NULL
|
||||||
|
*/
|
||||||
public function get_arg(/*int*/ $n) {
|
public function get_arg(/*int*/ $n) {
|
||||||
$offset = $this->part_count + $n;
|
$offset = $this->part_count + $n;
|
||||||
if($offset >= 0 && $offset < $this->arg_count) {
|
if($offset >= 0 && $offset < $this->arg_count) {
|
||||||
@ -67,6 +74,10 @@ class PageRequestEvent extends Event {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the number of arguments the page request has.
|
||||||
|
* @retval int
|
||||||
|
*/
|
||||||
public function count_args() {
|
public function count_args() {
|
||||||
return (int)($this->arg_count - $this->part_count);
|
return (int)($this->arg_count - $this->part_count);
|
||||||
}
|
}
|
||||||
|
@ -106,8 +106,10 @@ class Image {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Search for an array of images
|
* Search for an array of images
|
||||||
|
*
|
||||||
|
* @retval Array
|
||||||
*/
|
*/
|
||||||
public static function find_images($start, $limit, $tags=array()) {
|
public static function find_images(/*int*/ $start, /*int*/ $limit, $tags=array()) {
|
||||||
assert(is_numeric($start));
|
assert(is_numeric($start));
|
||||||
assert(is_numeric($limit));
|
assert(is_numeric($limit));
|
||||||
assert(is_array($tags));
|
assert(is_array($tags));
|
||||||
@ -383,7 +385,7 @@ class Image {
|
|||||||
/**
|
/**
|
||||||
* Set the image's source URL
|
* Set the image's source URL
|
||||||
*/
|
*/
|
||||||
public function set_source($source) {
|
public function set_source(/*string*/ $source) {
|
||||||
global $database;
|
global $database;
|
||||||
if(empty($source)) $source = null;
|
if(empty($source)) $source = null;
|
||||||
if($source != $this->source) {
|
if($source != $this->source) {
|
||||||
@ -392,7 +394,10 @@ class Image {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the image is locked.
|
||||||
|
* @retval bool
|
||||||
|
*/
|
||||||
public function is_locked() {
|
public function is_locked() {
|
||||||
return ($this->locked === true || $this->locked == "Y" || $this->locked == "t");
|
return ($this->locked === true || $this->locked == "Y" || $this->locked == "t");
|
||||||
}
|
}
|
||||||
@ -776,6 +781,8 @@ class Image {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
reset($terms); // rewind to first element in array.
|
||||||
|
|
||||||
// turn each term into a specific type of querylet
|
// turn each term into a specific type of querylet
|
||||||
foreach($terms as $term) {
|
foreach($terms as $term) {
|
||||||
$negative = false;
|
$negative = false;
|
||||||
@ -1008,8 +1015,15 @@ class Tag {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function takes a list (array) of tags and changes any tags that have aliases
|
||||||
|
*
|
||||||
|
* @param $tags Array of tags
|
||||||
|
* @return Array of tags
|
||||||
|
*/
|
||||||
public static function resolve_list($tags) {
|
public static function resolve_list($tags) {
|
||||||
$tags = Tag::explode($tags);
|
$tags = Tag::explode($tags);
|
||||||
|
reset($tags); // rewind array to the first element.
|
||||||
$new = array();
|
$new = array();
|
||||||
foreach($tags as $tag) {
|
foreach($tags as $tag) {
|
||||||
$new_set = explode(' ', Tag::resolve_alias($tag));
|
$new_set = explode(' ', Tag::resolve_alias($tag));
|
||||||
|
@ -237,7 +237,7 @@ class Page {
|
|||||||
protected function add_auto_html_headers() {
|
protected function add_auto_html_headers() {
|
||||||
$data_href = get_base_href();
|
$data_href = get_base_href();
|
||||||
|
|
||||||
$this->add_html_header("<script>base_href = '$data_href';</script>");
|
$this->add_html_header("<script type='text/javascript'>base_href = '$data_href';</script>");
|
||||||
|
|
||||||
/* Attempt to cache the CSS & JavaScript files */
|
/* Attempt to cache the CSS & JavaScript files */
|
||||||
if ($this->add_cached_auto_html_headers() === FALSE) {
|
if ($this->add_cached_auto_html_headers() === FALSE) {
|
||||||
@ -291,7 +291,11 @@ class Page {
|
|||||||
{
|
{
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
if (!$config->get_bool("autocache_css") && !$config->get_bool("autocache_js")) {
|
// store local copy for speed.
|
||||||
|
$autocache_css = $config->get_bool("autocache_css");
|
||||||
|
$autocache_js = $config->get_bool("autocache_js");
|
||||||
|
|
||||||
|
if (!$autocache_css && !$autocache_js) {
|
||||||
return false; // caching disabled
|
return false; // caching disabled
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,7 +313,7 @@ class Page {
|
|||||||
$data_href = get_base_href();
|
$data_href = get_base_href();
|
||||||
|
|
||||||
/* ----- CSS Files ----- */
|
/* ----- CSS Files ----- */
|
||||||
if ($config->get_bool("autocache_css"))
|
if ($autocache_css)
|
||||||
{
|
{
|
||||||
// First get all the CSS from the lib directory
|
// First get all the CSS from the lib directory
|
||||||
$contents_from_lib = '';
|
$contents_from_lib = '';
|
||||||
@ -376,7 +380,7 @@ class Page {
|
|||||||
|
|
||||||
|
|
||||||
/* ----- JavaScript Files ----- */
|
/* ----- JavaScript Files ----- */
|
||||||
if ($config->get_bool("autocache_js"))
|
if ($autocache_js)
|
||||||
{
|
{
|
||||||
$data = '';
|
$data = '';
|
||||||
$js_files = glob("lib/*.js");
|
$js_files = glob("lib/*.js");
|
||||||
@ -394,7 +398,7 @@ class Page {
|
|||||||
// Minify the JS if enabled.
|
// Minify the JS if enabled.
|
||||||
if ($config->get_bool("autocache_min_js")){
|
if ($config->get_bool("autocache_min_js")){
|
||||||
// not supported yet.
|
// not supported yet.
|
||||||
// TODO: add support for Minifying CSS files.
|
// TODO: add support for Minifying JS files.
|
||||||
}
|
}
|
||||||
|
|
||||||
// compute the MD5 sum of the concatenated JavaScript files
|
// compute the MD5 sum of the concatenated JavaScript files
|
||||||
|
@ -216,6 +216,7 @@ class User {
|
|||||||
/**
|
/**
|
||||||
* Get a snippet of HTML which will render the user's avatar, be that
|
* Get a snippet of HTML which will render the user's avatar, be that
|
||||||
* a local file, a remote file, a gravatar, a something else, etc
|
* a local file, a remote file, a gravatar, a something else, etc
|
||||||
|
* @retval String of HTML
|
||||||
*/
|
*/
|
||||||
public function get_avatar_html() {
|
public function get_avatar_html() {
|
||||||
// FIXME: configurable
|
// FIXME: configurable
|
||||||
@ -242,6 +243,8 @@ class User {
|
|||||||
* authtok = md5(sesskey, salt), presented to the user in web forms, to make sure that
|
* authtok = md5(sesskey, salt), presented to the user in web forms, to make sure that
|
||||||
* the form was generated within the session. Salted and re-hashed so that
|
* the form was generated within the session. Salted and re-hashed so that
|
||||||
* reading a web page from the user's cache doesn't give access to the session key
|
* reading a web page from the user's cache doesn't give access to the session key
|
||||||
|
*
|
||||||
|
* @retval String containing auth token (MD5sum)
|
||||||
*/
|
*/
|
||||||
public function get_auth_token() {
|
public function get_auth_token() {
|
||||||
global $config;
|
global $config;
|
||||||
|
@ -190,12 +190,26 @@ function undb_bool($val) {
|
|||||||
if($val === false || $val == 'N' || $val == 'n' || $val == 'F' || $val == 'f' || $val === 0) return false;
|
if($val === false || $val == 'N' || $val == 'n' || $val == 'F' || $val == 'f' || $val === 0) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
function startsWith($haystack, $needle) {
|
/**
|
||||||
|
* Checks if a given string contains another at the beginning.
|
||||||
|
*
|
||||||
|
* @param $haystack String to examine.
|
||||||
|
* @param $needle String to look for.
|
||||||
|
* @retval bool
|
||||||
|
*/
|
||||||
|
function startsWith(/*string*/ $haystack, /*string*/ $needle) {
|
||||||
$length = strlen($needle);
|
$length = strlen($needle);
|
||||||
return (substr($haystack, 0, $length) === $needle);
|
return (substr($haystack, 0, $length) === $needle);
|
||||||
}
|
}
|
||||||
|
|
||||||
function endsWith($haystack, $needle) {
|
/**
|
||||||
|
* Checks if a given string contains another at the end.
|
||||||
|
*
|
||||||
|
* @param $haystack String to examine.
|
||||||
|
* @param $needle String to look for.
|
||||||
|
* @retval bool
|
||||||
|
*/
|
||||||
|
function endsWith(/*string*/ $haystack, /*string*/ $needle) {
|
||||||
$length = strlen($needle);
|
$length = strlen($needle);
|
||||||
$start = $length * -1; //negative
|
$start = $length * -1; //negative
|
||||||
return (substr($haystack, $start) === $needle);
|
return (substr($haystack, $start) === $needle);
|
||||||
@ -621,6 +635,7 @@ function log_msg($section, $priority, $message) {
|
|||||||
send_event(new LogEvent($section, $priority, $message));
|
send_event(new LogEvent($section, $priority, $message));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// More shorthand ways of logging
|
||||||
function log_debug($section, $message) {log_msg($section, SCORE_LOG_DEBUG, $message);}
|
function log_debug($section, $message) {log_msg($section, SCORE_LOG_DEBUG, $message);}
|
||||||
function log_info($section, $message) {log_msg($section, SCORE_LOG_INFO, $message);}
|
function log_info($section, $message) {log_msg($section, SCORE_LOG_INFO, $message);}
|
||||||
function log_warning($section, $message) {log_msg($section, SCORE_LOG_WARNING, $message);}
|
function log_warning($section, $message) {log_msg($section, SCORE_LOG_WARNING, $message);}
|
||||||
@ -848,6 +863,13 @@ function send_event(Event $event) {
|
|||||||
// string representation of a number, it's two numbers separated by a space.
|
// string representation of a number, it's two numbers separated by a space.
|
||||||
// What the fuck were the PHP developers smoking.
|
// What the fuck were the PHP developers smoking.
|
||||||
$_load_start = microtime(true);
|
$_load_start = microtime(true);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Collects some debug information (execution time, memory usage, queries, etc)
|
||||||
|
* and formats it to stick in the footer of the page.
|
||||||
|
*
|
||||||
|
* @retval String of debug info to add to the page.
|
||||||
|
*/
|
||||||
function get_debug_info() {
|
function get_debug_info() {
|
||||||
global $config, $_event_count, $database, $_execs, $_load_start;
|
global $config, $_event_count, $database, $_execs, $_load_start;
|
||||||
|
|
||||||
@ -1045,6 +1067,9 @@ function _load_extensions() {
|
|||||||
ctx_log_endok();
|
ctx_log_endok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used to display fatal errors to the web user.
|
||||||
|
*/
|
||||||
function _fatal_error(Exception $e) {
|
function _fatal_error(Exception $e) {
|
||||||
$version = VERSION;
|
$version = VERSION;
|
||||||
$message = $e->getMessage();
|
$message = $e->getMessage();
|
||||||
|
@ -35,14 +35,17 @@ class CommentListTheme extends Themelet {
|
|||||||
|
|
||||||
// parts for each image
|
// parts for each image
|
||||||
$position = 10;
|
$position = 10;
|
||||||
|
|
||||||
|
$comment_limit = $config->get_int("comment_list_count", 10);
|
||||||
|
$comment_captcha = $config->get_bool('comment_captcha');
|
||||||
|
|
||||||
foreach($images as $pair) {
|
foreach($images as $pair) {
|
||||||
$image = $pair[0];
|
$image = $pair[0];
|
||||||
$comments = $pair[1];
|
$comments = $pair[1];
|
||||||
|
|
||||||
$thumb_html = $this->build_thumb_html($image);
|
$thumb_html = $this->build_thumb_html($image);
|
||||||
|
|
||||||
$comment_html = "";
|
$comment_html = "";
|
||||||
$comment_limit = $config->get_int("comment_list_count", 10);
|
|
||||||
$comment_count = count($comments);
|
$comment_count = count($comments);
|
||||||
if($comment_limit > 0 && $comment_count > $comment_limit) {
|
if($comment_limit > 0 && $comment_count > $comment_limit) {
|
||||||
$hidden = $comment_count - $comment_limit;
|
$hidden = $comment_count - $comment_limit;
|
||||||
@ -59,7 +62,7 @@ class CommentListTheme extends Themelet {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($can_post) {
|
if ($can_post) {
|
||||||
if(!$config->get_bool('comment_captcha')) {
|
if(!$comment_captcha) {
|
||||||
$comment_html .= $this->build_postbox($image->id);
|
$comment_html .= $this->build_postbox($image->id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Name: Tag List
|
* Name: Tag List
|
||||||
* Author: Shish
|
* Author: Shish <webmaster@shishnet.org>
|
||||||
|
* Link: http://code.shishnet.org/shimmie2/
|
||||||
* Description: Show the tags in various ways
|
* Description: Show the tags in various ways
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@ -107,13 +108,18 @@ class TagList extends Extension {
|
|||||||
return make_link("post/list/$u_tag/1");
|
return make_link("post/list/$u_tag/1");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the minimum number of times a tag needs to be used
|
||||||
|
* in order to be considered in the tag list.
|
||||||
|
* @retval int
|
||||||
|
*/
|
||||||
private function get_tags_min() {
|
private function get_tags_min() {
|
||||||
if(isset($_GET['mincount'])) {
|
if(isset($_GET['mincount'])) {
|
||||||
return int_escape($_GET['mincount']);
|
return int_escape($_GET['mincount']);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
global $config;
|
global $config;
|
||||||
return $config->get_int('tags_min');
|
return $config->get_int('tags_min'); // get the default.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -170,6 +176,8 @@ class TagList extends Extension {
|
|||||||
|
|
||||||
$tags_min = $this->get_tags_min();
|
$tags_min = $this->get_tags_min();
|
||||||
$starts_with = $this->get_starts_with();
|
$starts_with = $this->get_starts_with();
|
||||||
|
|
||||||
|
// check if we have a cached version
|
||||||
$cache_key = "data/tag_cloud-" . md5("tc" . $tags_min . $starts_with) . ".html";
|
$cache_key = "data/tag_cloud-" . md5("tc" . $tags_min . $starts_with) . ".html";
|
||||||
if(file_exists($cache_key)) {return file_get_contents($cache_key);}
|
if(file_exists($cache_key)) {return file_get_contents($cache_key);}
|
||||||
|
|
||||||
@ -205,6 +213,8 @@ class TagList extends Extension {
|
|||||||
|
|
||||||
$tags_min = $this->get_tags_min();
|
$tags_min = $this->get_tags_min();
|
||||||
$starts_with = $this->get_starts_with();
|
$starts_with = $this->get_starts_with();
|
||||||
|
|
||||||
|
// check if we have a cached version
|
||||||
$cache_key = "data/tag_alpha-" . md5("ta" . $tags_min . $starts_with) . ".html";
|
$cache_key = "data/tag_alpha-" . md5("ta" . $tags_min . $starts_with) . ".html";
|
||||||
if(file_exists($cache_key)) {return file_get_contents($cache_key);}
|
if(file_exists($cache_key)) {return file_get_contents($cache_key);}
|
||||||
|
|
||||||
@ -239,6 +249,8 @@ class TagList extends Extension {
|
|||||||
global $database;
|
global $database;
|
||||||
|
|
||||||
$tags_min = $this->get_tags_min();
|
$tags_min = $this->get_tags_min();
|
||||||
|
|
||||||
|
// check if we have a cached version
|
||||||
$cache_key = "data/tag_popul-" . md5("tp" . $tags_min) . ".html";
|
$cache_key = "data/tag_popul-" . md5("tp" . $tags_min) . ".html";
|
||||||
if(file_exists($cache_key)) {return file_get_contents($cache_key);}
|
if(file_exists($cache_key)) {return file_get_contents($cache_key);}
|
||||||
|
|
||||||
|
@ -70,22 +70,27 @@ class TagListTheme extends Themelet {
|
|||||||
public function display_popular_block(Page $page, $tag_infos) {
|
public function display_popular_block(Page $page, $tag_infos) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// store local copies for speed.
|
||||||
|
$info_link = $config->get_string('info_link');
|
||||||
|
$tag_list_num = $config->get_bool("tag_list_numbers");
|
||||||
|
|
||||||
$html = "";
|
$html = "";
|
||||||
$n = 0;
|
$n = 0;
|
||||||
|
|
||||||
foreach($tag_infos as $row) {
|
foreach($tag_infos as $row) {
|
||||||
$tag = $row['tag'];
|
$tag = $row['tag'];
|
||||||
$h_tag = html_escape($tag);
|
$h_tag = html_escape($tag);
|
||||||
$h_tag_no_underscores = str_replace("_", " ", $h_tag);
|
$h_tag_no_underscores = str_replace("_", " ", $h_tag);
|
||||||
$count = $row['count'];
|
$count = $row['count'];
|
||||||
if($n++) $html .= "\n<br/>";
|
if($n++) $html .= "\n<br/>";
|
||||||
if(!is_null($config->get_string('info_link'))) {
|
if(!is_null($info_link)) {
|
||||||
$link = str_replace('$tag', $tag, $config->get_string('info_link'));
|
$link = str_replace('$tag', $tag, $info_link);
|
||||||
$html .= " <a class='tag_info_link' href='$link'>?</a>";
|
$html .= ' <a class="tag_info_link" href="'.$link.'">?</a>';
|
||||||
}
|
}
|
||||||
$link = $this->tag_link($row['tag']);
|
$link = $this->tag_link($row['tag']);
|
||||||
$html .= " <a class='tag_name' href='$link'>$h_tag_no_underscores</a>";
|
$html .= ' <a class="tag_name" href="$link">'.$h_tag_no_underscores.'</a>';
|
||||||
if($config->get_bool("tag_list_numbers")) {
|
if($tag_list_num) {
|
||||||
$html .= " <span class='tag_count'>$count</span>";
|
$html .= ' <span class="tag_count">'.$count.'</span>';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,19 +108,23 @@ class TagListTheme extends Themelet {
|
|||||||
public function display_refine_block(Page $page, $tag_infos, $search) {
|
public function display_refine_block(Page $page, $tag_infos, $search) {
|
||||||
global $config;
|
global $config;
|
||||||
|
|
||||||
|
// store local copy for speed.
|
||||||
|
$info_link = $config->get_string('info_link');
|
||||||
|
|
||||||
$html = "";
|
$html = "";
|
||||||
$n = 0;
|
$n = 0;
|
||||||
|
|
||||||
foreach($tag_infos as $row) {
|
foreach($tag_infos as $row) {
|
||||||
$tag = $row['tag'];
|
$tag = $row['tag'];
|
||||||
$h_tag = html_escape($tag);
|
$h_tag = html_escape($tag);
|
||||||
$h_tag_no_underscores = str_replace("_", " ", $h_tag);
|
$h_tag_no_underscores = str_replace("_", " ", $h_tag);
|
||||||
if($n++) $html .= "\n<br/>";
|
if($n++) $html .= "\n<br/>";
|
||||||
if(!is_null($config->get_string('info_link'))) {
|
if(!is_null($info_link)) {
|
||||||
$link = str_replace('$tag', $tag, $config->get_string('info_link'));
|
$link = str_replace('$tag', $tag, $info_link);
|
||||||
$html .= " <a class='tag_info_link' href='$link'>?</a>";
|
$html .= ' <a class="tag_info_link" href="'.$link.'">?</a>';
|
||||||
}
|
}
|
||||||
$link = $this->tag_link($row['tag']);
|
$link = $this->tag_link($row['tag']);
|
||||||
$html .= " <a class='tag_name' href='$link'>$h_tag_no_underscores</a>";
|
$html .= ' <a class="tag_name" href="'.$link.'">'.$h_tag_no_underscores.'</a>';
|
||||||
$html .= $this->ars($tag, $search);
|
$html .= $this->ars($tag, $search);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
* Name: Database Upgrader
|
* Name: Database Upgrader
|
||||||
* Author: Shish
|
* Author: Shish <webmaster@shishnet.org>
|
||||||
|
* Link: http://code.shishnet.org/shimmie2/
|
||||||
* Description: Keeps things happy behind the scenes
|
* Description: Keeps things happy behind the scenes
|
||||||
* Visibility: admin
|
* Visibility: admin
|
||||||
*/
|
*/
|
||||||
|
@ -4,22 +4,49 @@
|
|||||||
var maxsze = (maxsze.match("(?:\.*[0-9])")) * 1024; //This assumes we are only working with MB.
|
var maxsze = (maxsze.match("(?:\.*[0-9])")) * 1024; //This assumes we are only working with MB.
|
||||||
var toobig = "The file you are trying to upload is too big to upload!";
|
var toobig = "The file you are trying to upload is too big to upload!";
|
||||||
var notsup = "The file you are trying to upload is not supported!";
|
var notsup = "The file you are trying to upload is not supported!";
|
||||||
|
if (CA === 0 || CA > 2){ //Default
|
||||||
|
if (confirm("OK = Use Current tags.\nCancel = Use new tags.")==true){
|
||||||
|
}else{
|
||||||
|
var tag=prompt("Enter Tags","");
|
||||||
|
var chk=1; //This makes sure it doesn't use current tags.
|
||||||
|
}
|
||||||
|
}else if (CA === 1){ //Current Tags
|
||||||
|
}else if (CA === 2){ //New Tags
|
||||||
|
var tag=prompt("Enter Tags","");
|
||||||
|
var chk=1;
|
||||||
|
}
|
||||||
|
|
||||||
if (confirm("OK = Use Current tags.\nCancel = Use new tags.")==true){}else{var tag=prompt("Enter Tags","");var chk=1;};
|
// Danbooru | oreno.imouto | konachan | sankakucomplex
|
||||||
|
|
||||||
// Danbooru
|
|
||||||
if(document.getElementById("post_tags") !== null){
|
if(document.getElementById("post_tags") !== null){
|
||||||
if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("post_tags").value;}
|
if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("post_tags").value;}
|
||||||
|
var srx="http://" + document.location.hostname + document.location.href.match("\/post\/show\/[0-9]+");
|
||||||
|
if(srx.search("oreno\\.imouto") >= 0 || srx.search("konachan\\.com") >= 0){
|
||||||
|
var rtg=document.getElementById("stats").innerHTML.match("<li>Rating: (.*) <span")[1];
|
||||||
|
}else{
|
||||||
var rtg=document.getElementById("stats").innerHTML.match("<li>Rating: (.*)<\/li>")[1];
|
var rtg=document.getElementById("stats").innerHTML.match("<li>Rating: (.*)<\/li>")[1];
|
||||||
var srx="http://" + document.location.hostname + document.location.href.match("\/post\/show\/[0-9]+\/");
|
}
|
||||||
|
|
||||||
if(tag.search(/\bflash\b/)===-1){
|
if(tag.search(/\bflash\b/)===-1){
|
||||||
|
var hrs=document.getElementById("highres").href;
|
||||||
|
if(srx.search("oreno\\.imouto") >= 0 || srx.search("konachan\\.com") >= 0){ //oreno's theme seems to have moved the filesize
|
||||||
|
var filesze = document.getElementById("highres").innerHTML.match("[a-zA-Z0-9]+ \\(+([0-9]+\\.[0-9]+) ([a-zA-Z]+)");
|
||||||
|
}else{
|
||||||
var filesze=document.getElementById("stats").innerHTML.match("[0-9] \\(((?:\.*[0-9])) ([a-zA-Z]+)");
|
var filesze=document.getElementById("stats").innerHTML.match("[0-9] \\(((?:\.*[0-9])) ([a-zA-Z]+)");
|
||||||
|
}
|
||||||
if(filesze[2] == "MB"){var filesze = filesze[1] * 1024;}else{var filesze = filesze[2].match("[0-9]+");}
|
if(filesze[2] == "MB"){var filesze = filesze[1] * 1024;}else{var filesze = filesze[2].match("[0-9]+");}
|
||||||
|
|
||||||
if(supext.search(document.getElementById("highres").href.match("http\:\/\/.*\\.([a-z0-9]+)")[1]) !== -1){
|
if(supext.search(hrs.match("http\:\/\/.*\\.([a-z0-9]+)")[1]) !== -1){
|
||||||
if(filesze <= maxsze){
|
if(filesze <= maxsze){
|
||||||
location.href=ste+document.getElementById("highres").href+"&tags="+tag+"&rating="+rtg+"&source="+srx;
|
if(srx.search("oreno\\.imouto") >= 0){
|
||||||
|
//this regex tends to be a bit picky with tags -_-;;
|
||||||
|
var hrs=hrs.match("(http\:\/\/[a-z0-9]+\.[a-z]+\.[a-z]\/[a-z0-9]+\/[a-z0-9]+)\/[a-z0-9A-Z%_-]+(\.[a-zA-Z0-9]+)");
|
||||||
|
var hrs=hrs[1]+hrs[2]; //this should bypass hotlink protection
|
||||||
|
}else if(srx.search("konachan\\.com") >= 0){
|
||||||
|
//konachan affixs konachan.com to the start of the tags, this requires different regex
|
||||||
|
var hrs=hrs.match("(http\:\/\/[a-z0-9]+\.[a-z]+\.[a-z]\/[a-z0-9]+\/[a-z0-9]+)\/[a-z0-9A-Z%_]+\.[a-zA-Z0-9%_-]+(\.[a-z0-9A-Z]+)")
|
||||||
|
var hrs=hrs[1]+hrs[2];
|
||||||
|
}
|
||||||
|
location.href=ste+hrs+"&tags="+tag+"&rating="+rtg+"&source="+srx;
|
||||||
}else{alert(toobig);}
|
}else{alert(toobig);}
|
||||||
}else{alert(notsup);}
|
}else{alert(notsup);}
|
||||||
}else{
|
}else{
|
||||||
@ -29,6 +56,7 @@ if(document.getElementById("post_tags") !== null){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Shimmie
|
/* Shimmie
|
||||||
|
One problem with shimmie is each theme does not show the same info as other themes (I.E only the danbooru & lite themes show statistics)
|
||||||
Shimmie doesn't seem to have any way to grab tags via id unless you have the ability to edit tags.
|
Shimmie doesn't seem to have any way to grab tags via id unless you have the ability to edit tags.
|
||||||
Have to go the round about way of checking the title for tags.
|
Have to go the round about way of checking the title for tags.
|
||||||
This crazy way of checking "should" work with older releases though (Seems to work with 2009~ ver) */
|
This crazy way of checking "should" work with older releases though (Seems to work with 2009~ ver) */
|
||||||
@ -36,7 +64,6 @@ else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.-
|
|||||||
if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementsByTagName("title")[0].innerHTML.match("Image [0-9.-]+\: (.*)")[1];}
|
if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementsByTagName("title")[0].innerHTML.match("Image [0-9.-]+\: (.*)")[1];}
|
||||||
//TODO: Make rating show in statistics.
|
//TODO: Make rating show in statistics.
|
||||||
var srx="http://" + document.location.hostname + document.location.href.match("\/post\/view\/[0-9]+");
|
var srx="http://" + document.location.hostname + document.location.href.match("\/post\/view\/[0-9]+");
|
||||||
/*TODO: Figure out regex for shortening file link. I.E http://blah.net/_images/1234abcd/everysingletag.png > http://blah.net/_images/1234abcd.png*/
|
|
||||||
/*TODO: Make file size show on all themes (Only seems to show in lite/Danbooru themes.)*/
|
/*TODO: Make file size show on all themes (Only seems to show in lite/Danbooru themes.)*/
|
||||||
if(tag.search(/\bflash\b/)==-1){
|
if(tag.search(/\bflash\b/)==-1){
|
||||||
var img = document.getElementById("main_image").src;
|
var img = document.getElementById("main_image").src;
|
||||||
@ -52,7 +79,6 @@ else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.-
|
|||||||
}
|
}
|
||||||
// Gelbooru
|
// Gelbooru
|
||||||
else if(document.getElementById("tags") !== null){
|
else if(document.getElementById("tags") !== null){
|
||||||
//Gelbooru has an annoying anti-hotlinking thing which doesn't seem to like the bookmarklet.
|
|
||||||
if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("tags").value;}
|
if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("tags").value;}
|
||||||
var rtg=document.getElementById("stats").innerHTML.match("<li>Rating: (.*)<\/li>")[1];
|
var rtg=document.getElementById("stats").innerHTML.match("<li>Rating: (.*)<\/li>")[1];
|
||||||
//Can't seem to grab source due to url containing a &
|
//Can't seem to grab source due to url containing a &
|
||||||
@ -61,6 +87,6 @@ else if(document.getElementById("tags") !== null){
|
|||||||
//Since Gelbooru does not allow flash, no need to search for flash tag.
|
//Since Gelbooru does not allow flash, no need to search for flash tag.
|
||||||
//Gelbooru doesn't show file size in statistics either...
|
//Gelbooru doesn't show file size in statistics either...
|
||||||
if(supext.search(gmi.match("http\:\/\/.*\\.([a-z0-9]+)")[1]) !== -1){
|
if(supext.search(gmi.match("http\:\/\/.*\\.([a-z0-9]+)")[1]) !== -1){
|
||||||
location.href=ste+gmi+"&tags="+tag+"&rating="+rtg[1];//+"&source="+srx;
|
location.href=ste+gmi+"&tags="+tag+"&rating="+rtg;//+"&source="+srx;
|
||||||
}else{alert(notsup);}
|
}else{alert(notsup);}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/*
|
/**
|
||||||
* Name: Uploader
|
* Name: Uploader
|
||||||
* Author: Shish
|
* Author: Shish
|
||||||
* Description: Allows people to upload files to the website
|
* Description: Allows people to upload files to the website
|
||||||
@ -58,6 +58,8 @@ class Upload extends Extension {
|
|||||||
$this->is_full = false;
|
$this->is_full = false;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// TODO: This size limit should be configureable by the admin...
|
||||||
|
// currently set to 100 MB
|
||||||
$this->is_full = $free_num < 100*1024*1024;
|
$this->is_full = $free_num < 100*1024*1024;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,12 +152,14 @@ class Upload extends Extension {
|
|||||||
$tags = ''; // Tags aren't changed when uploading. Set to null to stop PHP warnings.
|
$tags = ''; // Tags aren't changed when uploading. Set to null to stop PHP warnings.
|
||||||
|
|
||||||
if(count($_FILES)) {
|
if(count($_FILES)) {
|
||||||
|
reset($_FILES); // rewind to first element in array.
|
||||||
foreach($_FILES as $file) {
|
foreach($_FILES as $file) {
|
||||||
$ok = $this->try_upload($file, $tags, $source, $image_id);
|
$ok = $this->try_upload($file, $tags, $source, $image_id);
|
||||||
break; // leave the foreach loop.
|
break; // leave the foreach loop.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
reset($_POST); // rewind to first element in array.
|
||||||
foreach($_POST as $name => $value) {
|
foreach($_POST as $name => $value) {
|
||||||
if(substr($name, 0, 3) == "url" && strlen($value) > 0) {
|
if(substr($name, 0, 3) == "url" && strlen($value) > 0) {
|
||||||
$ok = $this->try_transload($value, $tags, $source, $image_id);
|
$ok = $this->try_transload($value, $tags, $source, $image_id);
|
||||||
@ -186,9 +190,11 @@ class Upload extends Extension {
|
|||||||
$source = isset($_POST['source']) ? $_POST['source'] : null;
|
$source = isset($_POST['source']) ? $_POST['source'] : null;
|
||||||
$ok = true;
|
$ok = true;
|
||||||
foreach($_FILES as $file) {
|
foreach($_FILES as $file) {
|
||||||
|
reset($_FILES); // rewind to first element in array.
|
||||||
$ok = $ok & $this->try_upload($file, $tags, $source);
|
$ok = $ok & $this->try_upload($file, $tags, $source);
|
||||||
}
|
}
|
||||||
foreach($_POST as $name => $value) {
|
foreach($_POST as $name => $value) {
|
||||||
|
reset($_POST); // rewind to first element in array.
|
||||||
if(substr($name, 0, 3) == "url" && strlen($value) > 0) {
|
if(substr($name, 0, 3) == "url" && strlen($value) > 0) {
|
||||||
$ok = $ok & $this->try_transload($value, $tags, $source);
|
$ok = $ok & $this->try_transload($value, $tags, $source);
|
||||||
}
|
}
|
||||||
@ -218,14 +224,28 @@ class Upload extends Extension {
|
|||||||
}
|
}
|
||||||
// }}}
|
// }}}
|
||||||
// do things {{{
|
// do things {{{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a given user can upload.
|
||||||
|
* @param $user The user to check.
|
||||||
|
* @retval bool
|
||||||
|
*/
|
||||||
private function can_upload(User $user) {
|
private function can_upload(User $user) {
|
||||||
global $config;
|
global $config;
|
||||||
return ($config->get_bool("upload_anon") || !$user->is_anonymous());
|
return ($config->get_bool("upload_anon") || !$user->is_anonymous());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper function based on the one from the online PHP Documentation
|
/**
|
||||||
// which is licensed under Creative Commons Attribution 3.0 License
|
* Returns a descriptive error message for the specified PHP error code.
|
||||||
// TODO: Make these messages user/admin editable
|
*
|
||||||
|
* This is a helper function based on the one from the online PHP Documentation
|
||||||
|
* which is licensed under Creative Commons Attribution 3.0 License
|
||||||
|
*
|
||||||
|
* TODO: Make these messages user/admin editable
|
||||||
|
*
|
||||||
|
* @param $error_code PHP error code (int)
|
||||||
|
* @retval String
|
||||||
|
*/
|
||||||
private function upload_error_message($error_code) {
|
private function upload_error_message($error_code) {
|
||||||
switch ($error_code) {
|
switch ($error_code) {
|
||||||
case UPLOAD_ERR_INI_SIZE:
|
case UPLOAD_ERR_INI_SIZE:
|
||||||
@ -247,6 +267,10 @@ class Upload extends Extension {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an upload.
|
||||||
|
* @retval bool TRUE on upload successful.
|
||||||
|
*/
|
||||||
private function try_upload($file, $tags, $source, $replace='') {
|
private function try_upload($file, $tags, $source, $replace='') {
|
||||||
global $page;
|
global $page;
|
||||||
global $config;
|
global $config;
|
||||||
@ -293,6 +317,10 @@ class Upload extends Extension {
|
|||||||
return $ok;
|
return $ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handle an transload.
|
||||||
|
* @retval bool TRUE on transload successful.
|
||||||
|
*/
|
||||||
private function try_transload($url, $tags, $source, $replace='') {
|
private function try_transload($url, $tags, $source, $replace='') {
|
||||||
global $page;
|
global $page;
|
||||||
global $config;
|
global $config;
|
||||||
|
@ -18,6 +18,7 @@ class UploadTheme extends Themelet {
|
|||||||
$upload_list = "";
|
$upload_list = "";
|
||||||
$upload_count = $config->get_int('upload_count');
|
$upload_count = $config->get_int('upload_count');
|
||||||
|
|
||||||
|
|
||||||
for($i=0; $i<$upload_count; $i++)
|
for($i=0; $i<$upload_count; $i++)
|
||||||
{
|
{
|
||||||
$a=$i+1;
|
$a=$i+1;
|
||||||
@ -53,7 +54,7 @@ class UploadTheme extends Themelet {
|
|||||||
<a href='#' onclick='$js'>".
|
<a href='#' onclick='$js'>".
|
||||||
"<img src='ext/upload/minus.png' /></a>";
|
"<img src='ext/upload/minus.png' /></a>";
|
||||||
|
|
||||||
if($a==$config->get_int('upload_count')){
|
if($a == $upload_count){
|
||||||
$upload_list .="<img id='wrapper' src='ext/upload/plus.png' />";
|
$upload_list .="<img id='wrapper' src='ext/upload/plus.png' />";
|
||||||
}else{
|
}else{
|
||||||
$js1 = 'javascript:$(function() {
|
$js1 = 'javascript:$(function() {
|
||||||
@ -145,8 +146,7 @@ class UploadTheme extends Themelet {
|
|||||||
{
|
{
|
||||||
/* Imageboard > Shimmie Bookmarklet
|
/* Imageboard > Shimmie Bookmarklet
|
||||||
This is more or less, an upgraded version of the "Danbooru>Shimmie" bookmarklet.
|
This is more or less, an upgraded version of the "Danbooru>Shimmie" bookmarklet.
|
||||||
At the moment this works with Shimmie & Danbooru.
|
At the moment this is known to work with Shimmie/Danbooru/Gelbooru/oreno.imouto/konachan/sankakucomplex.
|
||||||
It would also work with Gelbooru but unless someone can figure out how to bypass their hotlinking..meh.
|
|
||||||
The bookmarklet is now also loaded via the .js file in this folder.
|
The bookmarklet is now also loaded via the .js file in this folder.
|
||||||
*/
|
*/
|
||||||
//Bookmarklet checks if shimmie supports ext. If not, won't upload to site/shows alert saying not supported.
|
//Bookmarklet checks if shimmie supports ext. If not, won't upload to site/shows alert saying not supported.
|
||||||
@ -156,7 +156,8 @@ class UploadTheme extends Themelet {
|
|||||||
if(file_exists("ext/handle_mp3")){$supported_ext .= " mp3";}
|
if(file_exists("ext/handle_mp3")){$supported_ext .= " mp3";}
|
||||||
if(file_exists("ext/handle_svg")){$supported_ext .= " svg";}
|
if(file_exists("ext/handle_svg")){$supported_ext .= " svg";}
|
||||||
$title = "Booru to " . $config->get_string('title');
|
$title = "Booru to " . $config->get_string('title');
|
||||||
$html .= '<p><a href="javascript:var ste="'. $link . $delimiter .'url="; var supext="'.$supported_ext.'"; var maxsze="'.$max_kb.'"; void(document.body.appendChild(document.createElement("script")).src="'.make_http(make_link("ext/upload/bookmarklet.js")).'")">'.
|
//CA=0: Ask to use current or new tags | CA=1: Always use current tags | CA=2: Always use new tags
|
||||||
|
$html .= '<p><a href="javascript:var ste="'. $link . $delimiter .'url="; var supext="'.$supported_ext.'"; var maxsze="'.$max_kb.'"; var CA=0; void(document.body.appendChild(document.createElement("script")).src="'.make_http(get_base_href())."/ext/upload/bookmarklet.js".'")">'.
|
||||||
$title . '</a> (Click when looking at an image page. Works on sites running Shimmie/Danbooru/Gelbooru. (This also grabs the tags/rating/source!))';
|
$title . '</a> (Click when looking at an image page. Works on sites running Shimmie/Danbooru/Gelbooru. (This also grabs the tags/rating/source!))';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,10 @@ class CustomCommentListTheme extends CommentListTheme {
|
|||||||
|
|
||||||
// parts for each image
|
// parts for each image
|
||||||
$position = 10;
|
$position = 10;
|
||||||
|
|
||||||
|
$comment_captcha = $config->get_bool('comment_captcha');
|
||||||
|
$comment_limit = $config->get_int("comment_list_count", 10);
|
||||||
|
|
||||||
foreach($images as $pair) {
|
foreach($images as $pair) {
|
||||||
$image = $pair[0];
|
$image = $pair[0];
|
||||||
$comments = $pair[1];
|
$comments = $pair[1];
|
||||||
@ -42,7 +46,7 @@ class CustomCommentListTheme extends CommentListTheme {
|
|||||||
|
|
||||||
$r = class_exists("Ratings") ? "<b>Rating</b> ".Ratings::rating_to_human($image->rating) : "";
|
$r = class_exists("Ratings") ? "<b>Rating</b> ".Ratings::rating_to_human($image->rating) : "";
|
||||||
$comment_html = "<b>Date</b> $p $s <b>User</b> $un $s $r<br><b>Tags</b> $t<p> ";
|
$comment_html = "<b>Date</b> $p $s <b>User</b> $un $s $r<br><b>Tags</b> $t<p> ";
|
||||||
$comment_limit = $config->get_int("comment_list_count", 10);
|
|
||||||
$comment_count = count($comments);
|
$comment_count = count($comments);
|
||||||
if($comment_limit > 0 && $comment_count > $comment_limit) {
|
if($comment_limit > 0 && $comment_count > $comment_limit) {
|
||||||
$hidden = $comment_count - $comment_limit;
|
$hidden = $comment_count - $comment_limit;
|
||||||
@ -57,7 +61,7 @@ class CustomCommentListTheme extends CommentListTheme {
|
|||||||
$comment_html .= $this->build_postbox($image->id);
|
$comment_html .= $this->build_postbox($image->id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!$config->get_bool('comment_captcha')) {
|
if(!$comment_captcha) {
|
||||||
$comment_html .= $this->build_postbox($image->id);
|
$comment_html .= $this->build_postbox($image->id);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -38,7 +38,7 @@ class CustomViewImageTheme extends ViewImageTheme {
|
|||||||
$html .= "<br>Source: <a href='$h_source'>link</a>";
|
$html .= "<br>Source: <a href='$h_source'>link</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_null($image->rating) && file_exists("ext/rating")) {
|
if(file_exists("ext/rating")) {
|
||||||
if($image->rating == null || $image->rating == "u"){
|
if($image->rating == null || $image->rating == "u"){
|
||||||
$image->rating = "u";
|
$image->rating = "u";
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ class CustomViewImageTheme extends ViewImageTheme {
|
|||||||
$html .= "<br>Source: <a href='$h_source'>link</a>";
|
$html .= "<br>Source: <a href='$h_source'>link</a>";
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!is_null($image->rating) && file_exists("ext/rating")) {
|
if(file_exists("ext/rating")) {
|
||||||
if($image->rating == null || $image->rating == "u"){
|
if($image->rating == null || $image->rating == "u"){
|
||||||
$image->rating = "u";
|
$image->rating = "u";
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user