forked from Cavemanon/cavepaintings
merge
This commit is contained in:
commit
ee40a9aad3
6
.gitignore
vendored
6
.gitignore
vendored
@ -7,6 +7,7 @@ sql.log
|
||||
shimmie.log
|
||||
!lib/images
|
||||
ext/admin
|
||||
ext/amazon_s3
|
||||
ext/artists
|
||||
ext/autocomplete
|
||||
ext/ban_words
|
||||
@ -28,6 +29,7 @@ ext/handle_flash
|
||||
ext/handle_ico
|
||||
ext/handle_mp3
|
||||
ext/handle_svg
|
||||
ext/holiday
|
||||
ext/home
|
||||
ext/image_hash_ban
|
||||
ext/ipban
|
||||
@ -36,6 +38,7 @@ ext/log_db
|
||||
ext/news
|
||||
ext/notes
|
||||
ext/numeric_score
|
||||
ext/oekaki
|
||||
ext/piclens
|
||||
ext/pm
|
||||
ext/pools
|
||||
@ -44,6 +47,7 @@ ext/random_image
|
||||
ext/rating
|
||||
ext/regen_thumb
|
||||
ext/report_image
|
||||
ext/resize
|
||||
ext/res_limit
|
||||
ext/rss_comments
|
||||
ext/rss_images
|
||||
@ -56,7 +60,7 @@ ext/tagger
|
||||
ext/tag_history
|
||||
ext/text_score
|
||||
ext/tips
|
||||
ext/amazon_s3
|
||||
ext/twitter_soc
|
||||
ext/upload_cmd
|
||||
ext/wiki
|
||||
ext/word_filter
|
||||
|
@ -40,10 +40,10 @@ Installation
|
||||
Upgrade from 2.3.X
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
The database connection setting in config.php has changed; now using
|
||||
PDO DSN format [1] rather than ADODB URI [2]
|
||||
PDO DSN format rather than ADODB URI:
|
||||
|
||||
[1] <proto>:user=<username>;password=<password>;host=<host>;dbname=<database>
|
||||
[2] <proto>://<username>:<password>@<host>/<database>
|
||||
OLD: $database_dsn = "<proto>://<username>:<password>@<host>/<database>";
|
||||
NEW: define("DATABASE_DSN", "<proto>:user=<username>;password=<password>;host=<host>;dbname=<database>");
|
||||
|
||||
The rest should be automatic, just unzip into a clean folder and copy across
|
||||
config.php, images and thumbs folders from the old version. This
|
||||
|
@ -35,14 +35,15 @@ class AdminPageTheme extends Themelet {
|
||||
|
||||
/* First check
|
||||
Requires you to click the checkbox to enable the delete by query form */
|
||||
$dbqcheck = "
|
||||
if(document.getElementById("dbqcheck").checked == false){
|
||||
document.getElementById("dbqtags").disabled = true;
|
||||
document.getElementById("dbqsubmit").disabled = true;
|
||||
$dbqcheck = 'javascript:$(function() {
|
||||
if($("#dbqcheck:checked").length != 0){
|
||||
$("#dbqtags").attr("disabled", false);
|
||||
$("#dbqsubmit").attr("disabled", false);
|
||||
}else{
|
||||
document.getElementById("dbqtags").disabled = false;
|
||||
document.getElementById("dbqsubmit").disabled = false;
|
||||
}";
|
||||
$("#dbqtags").attr("disabled", true);
|
||||
$("#dbqsubmit").attr("disabled", true);
|
||||
}
|
||||
});';
|
||||
|
||||
/* Second check
|
||||
Requires you to confirm the deletion by clicking ok. */
|
||||
@ -52,7 +53,7 @@ class AdminPageTheme extends Themelet {
|
||||
if(confirm('Are you sure you wish to delete all images using these tags?')){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
</script>"
|
||||
|
@ -43,6 +43,14 @@ class Artists implements Extension {
|
||||
|
||||
if ($event instanceof PageRequestEvent)
|
||||
$this->handle_commands($event);
|
||||
|
||||
if ($event instanceof SearchTermParseEvent) {
|
||||
$matches = array();
|
||||
if(preg_match("/^author=(.*)$/", $event->term, $matches)) {
|
||||
$char = $matches[1];
|
||||
$event->add_querylet(new Querylet("Author = :author_char", array("author_char"=>$char)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function try_install() {
|
||||
@ -131,7 +139,7 @@ class Artists implements Extension {
|
||||
|
||||
$database->execute("UPDATE images SET author = ? WHERE id = ?"
|
||||
, array(
|
||||
mysql_real_escape_string($artistName)
|
||||
$artistName
|
||||
, $event->image->id
|
||||
));
|
||||
}
|
||||
@ -434,7 +442,7 @@ class Artists implements Extension {
|
||||
{
|
||||
global $database;
|
||||
|
||||
$result = $database->get_one("SELECT COUNT(1) FROM artist_urls WHERE url = ?", array(mysql_real_escape_string($url)));
|
||||
$result = $database->get_one("SELECT COUNT(1) FROM artist_urls WHERE url = ?", array($url));
|
||||
return ($result != 0);
|
||||
}
|
||||
|
||||
@ -442,7 +450,7 @@ class Artists implements Extension {
|
||||
{
|
||||
global $database;
|
||||
|
||||
$result = $database->get_one("SELECT COUNT(1) FROM artist_members WHERE name = ?", array(mysql_real_escape_string($member)));
|
||||
$result = $database->get_one("SELECT COUNT(1) FROM artist_members WHERE name = ?", array($member));
|
||||
return ($result != 0);
|
||||
}
|
||||
|
||||
@ -450,7 +458,7 @@ class Artists implements Extension {
|
||||
{
|
||||
global $database;
|
||||
|
||||
$result = $database->get_one("SELECT COUNT(1) FROM artist_alias WHERE alias = ?", array(mysql_real_escape_string($alias)));
|
||||
$result = $database->get_one("SELECT COUNT(1) FROM artist_alias WHERE alias = ?", array($alias));
|
||||
return ($result != 0);
|
||||
}
|
||||
|
||||
@ -461,7 +469,7 @@ class Artists implements Extension {
|
||||
|
||||
$result = $database->get_one("SELECT COUNT(1) FROM artist_alias WHERE artist_id = ? AND alias = ?", array(
|
||||
$artistID
|
||||
, mysql_real_escape_string($alias)
|
||||
, $alias
|
||||
));
|
||||
return ($result != 0);
|
||||
}
|
||||
@ -469,14 +477,14 @@ class Artists implements Extension {
|
||||
private function get_artistID_by_url($url)
|
||||
{
|
||||
global $database;
|
||||
$result = $database->get_row("SELECT artist_id FROM artist_urls WHERE url = ?", array(mysql_real_escape_string($url)));
|
||||
$result = $database->get_row("SELECT artist_id FROM artist_urls WHERE url = ?", array($url));
|
||||
return $result['artist_id'];
|
||||
}
|
||||
|
||||
private function get_artistID_by_memberName($member)
|
||||
{
|
||||
global $database;
|
||||
$result = $database->get_row("SELECT artist_id FROM artist_members WHERE name = ?", array(mysql_real_escape_string($member)));
|
||||
$result = $database->get_row("SELECT artist_id FROM artist_members WHERE name = ?", array($member));
|
||||
return $result['artist_id'];
|
||||
}
|
||||
private function get_artistName_by_artistID($artistID)
|
||||
@ -623,8 +631,8 @@ class Artists implements Extension {
|
||||
global $database;
|
||||
$database->execute("UPDATE artists SET name = ?, notes = ?, updated = now(), user_id = ? WHERE id = ? "
|
||||
, array(
|
||||
mysql_real_escape_string($name)
|
||||
, mysql_real_escape_string($notes)
|
||||
$name
|
||||
, $notes
|
||||
, $userID
|
||||
, $artistID
|
||||
));
|
||||
@ -719,7 +727,7 @@ class Artists implements Extension {
|
||||
global $database;
|
||||
$database->execute("UPDATE artist_alias SET alias = ?, updated = now(), user_id = ? WHERE id = ? "
|
||||
, array(
|
||||
mysql_real_escape_string($alias)
|
||||
$alias
|
||||
, $userID
|
||||
, $aliasID
|
||||
));
|
||||
@ -748,7 +756,7 @@ class Artists implements Extension {
|
||||
global $database;
|
||||
$database->execute("UPDATE artist_urls SET url = ?, updated = now(), user_id = ? WHERE id = ?"
|
||||
, array(
|
||||
mysql_real_escape_string($url)
|
||||
$url
|
||||
, $userID
|
||||
, $urlID
|
||||
));
|
||||
@ -778,7 +786,7 @@ class Artists implements Extension {
|
||||
|
||||
$database->execute("UPDATE artist_members SET name = ?, updated = now(), user_id = ? WHERE id = ?"
|
||||
, array(
|
||||
mysql_real_escape_string($memberName)
|
||||
$memberName
|
||||
, $userID
|
||||
, $memberID
|
||||
));
|
||||
@ -855,8 +863,8 @@ class Artists implements Extension {
|
||||
(?, ?, ?, now(), now())",
|
||||
array(
|
||||
$user->id
|
||||
, mysql_real_escape_string($name)
|
||||
, mysql_real_escape_string($notes)
|
||||
, $name
|
||||
, $notes
|
||||
));
|
||||
|
||||
$result = $database->get_row("SELECT LAST_INSERT_ID() AS artistID", array());
|
||||
@ -872,7 +880,7 @@ class Artists implements Extension {
|
||||
|
||||
$result = $database->get_one("SELECT COUNT(1) FROM artists WHERE name = ?"
|
||||
, array(
|
||||
mysql_real_escape_string($name)
|
||||
$name
|
||||
));
|
||||
return ($result != 0);
|
||||
}
|
||||
@ -938,7 +946,7 @@ class Artists implements Extension {
|
||||
global $database;
|
||||
$artistID = $database->get_row("SELECT id FROM artists WHERE name = ?"
|
||||
, array(
|
||||
mysql_real_escape_string($name)
|
||||
$name
|
||||
));
|
||||
return $artistID['id'];
|
||||
}
|
||||
@ -949,7 +957,7 @@ class Artists implements Extension {
|
||||
|
||||
$artistID = $database->get_row("SELECT artist_id FROM artist_alias WHERE alias = ?"
|
||||
, array(
|
||||
mysql_real_escape_string($alias)
|
||||
$alias
|
||||
));
|
||||
return $artistID["artist_id"];
|
||||
}
|
||||
@ -1092,7 +1100,7 @@ class Artists implements Extension {
|
||||
$database->execute("INSERT INTO artist_urls (artist_id, created, updated, url, user_id) VALUES (?, now(), now(), ?, ?)"
|
||||
, array(
|
||||
$artistID
|
||||
, mysql_real_escape_string($url)
|
||||
, $url
|
||||
, $userID
|
||||
));
|
||||
}
|
||||
@ -1126,7 +1134,7 @@ class Artists implements Extension {
|
||||
$database->execute("INSERT INTO artist_alias (artist_id, created, updated, alias, user_id) VALUES (?, now(), now(), ?, ?)"
|
||||
, array(
|
||||
$artistID
|
||||
, mysql_real_escape_string($alias)
|
||||
, $alias
|
||||
, $userID
|
||||
));
|
||||
}
|
||||
@ -1159,7 +1167,7 @@ class Artists implements Extension {
|
||||
$database->execute("INSERT INTO artist_members (artist_id, name, created, updated, user_id) VALUES (?, ?, now(), now(), ?)"
|
||||
, array(
|
||||
$artistID
|
||||
, mysql_real_escape_string($member)
|
||||
, $member
|
||||
, $userID
|
||||
));
|
||||
}
|
||||
@ -1173,7 +1181,7 @@ class Artists implements Extension {
|
||||
$result = $database->get_one("SELECT COUNT(1) FROM artist_members WHERE artist_id = ? AND name = ?"
|
||||
, array(
|
||||
$artistID
|
||||
, mysql_real_escape_string($member)
|
||||
, $member
|
||||
));
|
||||
return ($result != 0);
|
||||
}
|
||||
@ -1187,7 +1195,7 @@ class Artists implements Extension {
|
||||
$result = $database->get_one("SELECT COUNT(1) FROM artist_urls WHERE artist_id = ? AND url = ?"
|
||||
, array(
|
||||
$artistID
|
||||
, mysql_real_escape_string($url)
|
||||
, $url
|
||||
));
|
||||
return ($result != 0);
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ class BrowserSearch implements Extension {
|
||||
// First, we need to build all the variables we'll need
|
||||
|
||||
$search_title = $config->get_string('title');
|
||||
//$search_form_url = $config->get_string('base_href'); //make_link('post/list');
|
||||
$search_form_url = make_link('post/list/{searchTerms}');
|
||||
$suggenton_url = make_link('browser_search/')."{searchTerms}";
|
||||
$icon_b64 = base64_encode(file_get_contents("favicon.ico"));
|
||||
|
@ -48,8 +48,7 @@ class ET implements Extension {
|
||||
$info['sys_disk'] = to_shorthand_int(disk_total_space("./") - disk_free_space("./")) . " / " .
|
||||
to_shorthand_int(disk_total_space("./"));
|
||||
$info['sys_server'] = $_SERVER["SERVER_SOFTWARE"];
|
||||
include "config.php"; // more magical hax
|
||||
$proto = preg_replace("#(.*)://.*#", "$1", $database_dsn);
|
||||
$proto = preg_replace("#(.*)://.*#", "$1", DATABASE_DSN);
|
||||
#$db = $database->db->ServerInfo();
|
||||
#$info['sys_db'] = "$proto / {$db['version']}";
|
||||
|
||||
|
@ -144,8 +144,10 @@ class Favorites extends SimpleExtension {
|
||||
image_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
created_at DATETIME NOT NULL,
|
||||
INDEX(image_id),
|
||||
UNIQUE(image_id, user_id),
|
||||
INDEX(image_id)
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE
|
||||
)
|
||||
");
|
||||
$config->set_int("ext_favorites_version", 1);
|
||||
|
@ -197,7 +197,7 @@ class Forum extends SimpleExtension {
|
||||
$hasErrors = true;
|
||||
$errors .= "<div id='error'>You cannot have an empty title.</div>";
|
||||
}
|
||||
else if (strlen(mysql_real_escape_string(html_escape($_POST["title"]))) > 255)
|
||||
else if (strlen(html_escape($_POST["title"])) > 255)
|
||||
{
|
||||
$hasErrors = true;
|
||||
$errors .= "<div id='error'>Your title is too long.</div>";
|
||||
@ -318,7 +318,7 @@ class Forum extends SimpleExtension {
|
||||
|
||||
private function save_new_thread($user)
|
||||
{
|
||||
$title = mysql_real_escape_string(html_escape($_POST["title"]));
|
||||
$title = html_escape($_POST["title"]);
|
||||
$sticky = html_escape($_POST["sticky"]);
|
||||
|
||||
if($sticky == ""){
|
||||
@ -344,7 +344,7 @@ class Forum extends SimpleExtension {
|
||||
{
|
||||
global $config;
|
||||
$userID = $user->id;
|
||||
$message = mysql_real_escape_string(html_escape($_POST["message"]));
|
||||
$message = html_escape($_POST["message"]);
|
||||
|
||||
$max_characters = $config->get_int('forumMaxCharsPerPost');
|
||||
$message = substr($message, 0, $max_characters);
|
||||
|
@ -83,8 +83,6 @@ class ForumTheme extends Themelet {
|
||||
global $config, $page/*, $user*/;
|
||||
|
||||
$theme_name = $config->get_string('theme');
|
||||
$data_href = $config->get_string('base_href');
|
||||
$base_href = $config->get_string('base_href');
|
||||
|
||||
$html = "";
|
||||
$n = 0;
|
||||
|
@ -9,6 +9,7 @@ class FlashFileHandlerTheme extends Themelet {
|
||||
codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0'
|
||||
height='{$image->height}'
|
||||
width='{$image->width}'
|
||||
wmode='opaque'
|
||||
>
|
||||
<param name='movie' value='$ilink'/>
|
||||
<param name='quality' value='high' />
|
||||
@ -16,6 +17,7 @@ class FlashFileHandlerTheme extends Themelet {
|
||||
pluginspage='http://www.macromedia.com/go/getflashplayer'
|
||||
height='{$image->height}'
|
||||
width='{$image->width}'
|
||||
wmode='opaque'
|
||||
type='application/x-shockwave-flash'></embed>
|
||||
</object>";
|
||||
$page->add_block(new Block("Flash Animation", $html, "main", 0));
|
||||
|
33
contrib/holiday/main.php
Normal file
33
contrib/holiday/main.php
Normal file
@ -0,0 +1,33 @@
|
||||
<?php
|
||||
/**
|
||||
* Name: Holiday Theme
|
||||
* Author: DakuTree <thedakutree@codeanimu.net>
|
||||
* Link: http://www.codeanimu.net
|
||||
* License: GPLv2
|
||||
* Description: Use an additional stylesheet on certain holidays.
|
||||
*/
|
||||
class Holiday extends SimpleExtension {
|
||||
public function onInitExt(Event $event) {
|
||||
global $config;
|
||||
$config->set_default_bool("holiday_aprilfools", false);
|
||||
}
|
||||
|
||||
public function onSetupBuilding(Event $event) {
|
||||
global $config;
|
||||
$sb = new SetupBlock("Holiday Theme");
|
||||
$sb->add_bool_option("holiday_aprilfools", "Enable April Fools");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
|
||||
public function onPageRequest(Event $event) {
|
||||
global $config;
|
||||
$date = /*date('d/m') == '01/01' ||date('d/m') == '14/02' || */date('d/m') == '01/04'/* || date('d/m') == '24/12' || date('d/m') == '25/12' || date('d/m') == '31/12'*/;
|
||||
if($date){
|
||||
if($config->get_bool("holiday_aprilfools")){
|
||||
$this->theme->display_holiday($date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
11
contrib/holiday/stylesheets/aprilfools.css
Normal file
11
contrib/holiday/stylesheets/aprilfools.css
Normal file
@ -0,0 +1,11 @@
|
||||
BODY {
|
||||
/* It's a bit crazy but, april fools is supposed to be crazy.
|
||||
This flips the entire page upside down.
|
||||
TODO: Add a way for the user to disable this */
|
||||
|
||||
-webkit-transform: rotate(-180deg); /*Safari*/
|
||||
-moz-transform: rotate(-180deg); /*Firefox*/
|
||||
-o-transform: rotate(-180deg); /*Opera*/
|
||||
filter: progid:DXImageTransform.Microsoft.BasicImage(rotation=2); /*IE6*/
|
||||
ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=2)"; /*IE7+?*/
|
||||
}
|
20
contrib/holiday/theme.php
Normal file
20
contrib/holiday/theme.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
class HolidayTheme extends Themelet {
|
||||
public function display_holiday($date) {
|
||||
global $page;
|
||||
if($date){
|
||||
$csssheet = "<link rel='stylesheet' href='".get_base_href()."/contrib/holiday/stylesheets/";
|
||||
|
||||
// April Fools
|
||||
// Flips the entire page upside down!
|
||||
// TODO: Make it possible for the user to turn this off!
|
||||
if(date('d/m') == '01/04'){
|
||||
$csssheet .= "aprilfools.css";
|
||||
}
|
||||
|
||||
$csssheet .= "' type='text/css'>";
|
||||
$page->add_html_header("$csssheet");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
@ -28,14 +28,13 @@ class Home extends SimpleExtension {
|
||||
public function onPageRequest(PageRequestEvent $event) {
|
||||
global $config, $page;
|
||||
if($event->page_matches("home")) {
|
||||
$base_href = $config->get_string('base_href');
|
||||
$data_href = get_base_href();
|
||||
$base_href = get_base_href();
|
||||
$sitename = $config->get_string('title');
|
||||
$theme_name = $config->get_string('theme');
|
||||
|
||||
$body = $this->get_body();
|
||||
|
||||
$this->theme->display_page($page, $sitename, $data_href, $theme_name, $body);
|
||||
$this->theme->display_page($page, $sitename, $base_href, $theme_name, $body);
|
||||
}
|
||||
}
|
||||
|
||||
@ -58,8 +57,7 @@ class Home extends SimpleExtension {
|
||||
// returns just the contents of the body
|
||||
global $database;
|
||||
global $config;
|
||||
$base_href = $config->get_string('base_href');
|
||||
$data_href = get_base_href();
|
||||
$base_href = get_base_href();
|
||||
$sitename = $config->get_string('title');
|
||||
$contact_link = $config->get_string('contact_link');
|
||||
$counter_dir = $config->get_string('home_counter', 'default');
|
||||
@ -71,7 +69,7 @@ class Home extends SimpleExtension {
|
||||
$counter_text = "";
|
||||
for($n=0; $n<strlen($strtotal); $n++) {
|
||||
$cur = $strtotal[$n];
|
||||
$counter_text .= " <img alt='$cur' src='$data_href/ext/home/counters/$counter_dir/$cur.gif' /> ";
|
||||
$counter_text .= " <img alt='$cur' src='$base_href/ext/home/counters/$counter_dir/$cur.gif' /> ";
|
||||
}
|
||||
|
||||
// get the homelinks and process them
|
||||
|
@ -1,14 +1,14 @@
|
||||
<?php
|
||||
|
||||
class HomeTheme extends Themelet {
|
||||
public function display_page(Page $page, $sitename, $data_href, $theme_name, $body) {
|
||||
public function display_page(Page $page, $sitename, $base_href, $theme_name, $body) {
|
||||
$page->set_mode("data");
|
||||
$page->set_data(<<<EOD
|
||||
<html>
|
||||
<head>
|
||||
<title>$sitename</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||
<link rel='stylesheet' href='$data_href/themes/$theme_name/style.css' type='text/css'>
|
||||
<link rel='stylesheet' href='$base_href/themes/$theme_name/style.css' type='text/css'>
|
||||
</head>
|
||||
<style>
|
||||
div#front-page h1 {font-size: 4em; margin-top: 2em; margin-bottom: 0px; text-align: center; border: none; background: none; box-shadow: none; -webkit-box-shadow: none; -moz-box-shadow: none;}
|
||||
|
@ -128,11 +128,30 @@ class ImageBan extends SimpleExtension {
|
||||
// DB funness
|
||||
|
||||
public function get_image_hash_bans($page, $size=100) {
|
||||
global $database;
|
||||
|
||||
// FIXME: many
|
||||
$size_i = int_escape($size);
|
||||
$offset_i = int_escape($page-1)*$size_i;
|
||||
global $database;
|
||||
$bans = $database->get_all("SELECT * FROM image_bans ORDER BY id DESC LIMIT $size_i OFFSET $offset_i");
|
||||
$where = array("(1=1)");
|
||||
$args = array();
|
||||
if(!empty($_GET['hash'])) {
|
||||
$where[] = 'hash = ?';
|
||||
$args[] = $_GET['hash'];
|
||||
}
|
||||
if(!empty($_GET['reason'])) {
|
||||
$where[] = 'reason SCORE_ILIKE ?';
|
||||
$args[] = "%".$_GET['reason']."%";
|
||||
}
|
||||
$where = implode(" AND ", $where);
|
||||
$bans = $database->get_all($database->engine->scoreql_to_sql("
|
||||
SELECT *
|
||||
FROM image_bans
|
||||
WHERE $where
|
||||
ORDER BY id DESC
|
||||
LIMIT $size_i
|
||||
OFFSET $offset_i
|
||||
"), $args);
|
||||
if($bans) {return $bans;}
|
||||
else {return array();}
|
||||
}
|
||||
|
@ -45,7 +45,16 @@ class ImageBanTheme extends Themelet {
|
||||
});
|
||||
</script>
|
||||
<table id='image_bans' class='zebra'>
|
||||
<thead><th>Hash</th><th>Reason</th><th>Action</th></thead>
|
||||
<thead>
|
||||
<th>Hash</th><th>Reason</th><th>Action</th>
|
||||
<tr>
|
||||
<form action='".make_link("image_hash_ban/list/1")."' method='GET'>
|
||||
<td><input type='text' name='hash'></td>
|
||||
<td><input type='text' name='reason'></td>
|
||||
<td><input type='submit' value='Search'></td>
|
||||
</form>
|
||||
</tr>
|
||||
</thead>
|
||||
$h_bans
|
||||
<tfoot><tr>
|
||||
".make_form(make_link("image_hash_ban/add"))."
|
||||
|
@ -161,13 +161,29 @@ class IPBan implements Extension {
|
||||
// }}}
|
||||
// deal with banned person {{{
|
||||
private function check_ip_ban() {
|
||||
global $config;
|
||||
global $database;
|
||||
$remote = $_SERVER['REMOTE_ADDR'];
|
||||
$bans = $this->get_active_bans_sorted();
|
||||
|
||||
// bans[0] = IPs
|
||||
if(isset($bans[0][$remote])) {
|
||||
$this->block($remote); // never returns
|
||||
}
|
||||
|
||||
// bans[1] = CIDR nets
|
||||
foreach($bans[1] as $ip => $true) {
|
||||
if(ip_in_range($remote, $ip)) {
|
||||
$this->block($remote); // never returns
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function block($remote) {
|
||||
global $config, $database;
|
||||
|
||||
$prefix = ($database->engine->name == "sqlite" ? "bans." : "");
|
||||
|
||||
$remote = $_SERVER['REMOTE_ADDR'];
|
||||
$bans = $this->get_active_bans();
|
||||
|
||||
foreach($bans as $row) {
|
||||
$ip = $row[$prefix."ip"];
|
||||
if(
|
||||
@ -204,9 +220,6 @@ class IPBan implements Extension {
|
||||
private function get_active_bans() {
|
||||
global $database;
|
||||
|
||||
$cached = $database->cache->get("ip_bans");
|
||||
if($cached) return $cached;
|
||||
|
||||
$bans = $database->get_all("
|
||||
SELECT bans.*, users.name as banner_name
|
||||
FROM bans
|
||||
@ -215,12 +228,34 @@ class IPBan implements Extension {
|
||||
ORDER BY end_timestamp, bans.id
|
||||
", array("end_timestamp"=>time()));
|
||||
|
||||
$database->cache->set("ip_bans", $bans, 600);
|
||||
|
||||
if($bans) {return $bans;}
|
||||
else {return array();}
|
||||
}
|
||||
|
||||
// returns [ips, nets]
|
||||
private function get_active_bans_sorted() {
|
||||
global $database;
|
||||
|
||||
$cached = $database->cache->get("ip_bans_sorted");
|
||||
if($cached) return $cached;
|
||||
|
||||
$bans = $this->get_active_bans();
|
||||
$ips = array("0.0.0.0" => false);
|
||||
$nets = array("0.0.0.0/32" => false);
|
||||
foreach($bans as $row) {
|
||||
if(strstr($row['ip'], '/')) {
|
||||
$nets[$row['ip']] = true;
|
||||
}
|
||||
else {
|
||||
$ips[$row['ip']] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$sorted = array($ips, $nets);
|
||||
$database->cache->set("ip_bans_sorted", $sorted, 600);
|
||||
return $sorted;
|
||||
}
|
||||
|
||||
private function add_ip_ban($ip, $reason, $end, $user) {
|
||||
global $database;
|
||||
$sql = "INSERT INTO bans (ip, reason, end_timestamp, banner_id) VALUES (:ip, :reason, :end, :admin_id)";
|
||||
|
@ -264,7 +264,7 @@ class Notes extends SimpleExtension {
|
||||
$noteY1 = int_escape($_POST["note_y1"]);
|
||||
$noteHeight = int_escape($_POST["note_height"]);
|
||||
$noteWidth = int_escape($_POST["note_width"]);
|
||||
$noteText = mysql_real_escape_string(html_escape($_POST["note_text"]));
|
||||
$noteText = html_escape($_POST["note_text"]);
|
||||
|
||||
$database->execute("
|
||||
INSERT INTO notes
|
||||
|
@ -56,7 +56,12 @@ class NotesTheme extends Themelet {
|
||||
}
|
||||
|
||||
// check action POST on form
|
||||
public function display_note_system(Page $page, $image_id, $recovered_notes, $adminOptions) {
|
||||
public function display_note_system(Page $page, $image_id, $recovered_notes, $adminOptions)
|
||||
{
|
||||
$data_href = get_base_href();
|
||||
$page->add_html_header("<script src='$data_href/contrib/notes/jquery.qimgareaselect-0.4.js' type='text/javascript'></script>", 100);
|
||||
$page->add_html_header("<script src='$data_href/contrib/notes/jquery.rimgnotes-0.2.js' type='text/javascript'></script>", 101);
|
||||
|
||||
$html = "<script type='text/javascript'>
|
||||
|
||||
notes = [";
|
||||
|
@ -104,6 +104,77 @@ class NumericScore implements Extension {
|
||||
$page->set_redirect(make_link());
|
||||
}
|
||||
}
|
||||
if($event->page_matches("popular_by_day") || $event->page_matches("popular_by_month") || $event->page_matches("popular_by_year")) {
|
||||
$t_images = $config->get_int("index_height") * $config->get_int("index_width");
|
||||
|
||||
//TODO: Somehow make popular_by_#/2012/12/31 > popular_by_#?day=31&month=12&year=2012 (So no problems with date formats)
|
||||
//TODO: Add Popular_by_week.
|
||||
|
||||
$sql = "SELECT * FROM images ";
|
||||
$args = array();
|
||||
|
||||
//year
|
||||
if(int_escape($event->get_arg(0)) == 0){
|
||||
$year = date("Y");
|
||||
}else{
|
||||
$year = $event->get_arg(0);
|
||||
}
|
||||
//month
|
||||
if(int_escape($event->get_arg(1)) == 0 || int_escape($event->get_arg(1)) > 12){
|
||||
$month = date("m");
|
||||
}else{
|
||||
$month = $event->get_arg(1);
|
||||
}
|
||||
//day
|
||||
if(int_escape($event->get_arg(2)) == 0 || int_escape($event->get_arg(2)) > 31){
|
||||
$day = date("d");
|
||||
}else{
|
||||
$day = $event->get_arg(2);
|
||||
}
|
||||
$totaldate = $year."/".$month."/".$day;
|
||||
|
||||
if($event->page_matches("popular_by_day")){
|
||||
$sql .=
|
||||
"WHERE EXTRACT(YEAR FROM posted) = :year
|
||||
AND EXTRACT(MONTH FROM posted) = :month
|
||||
AND EXTRACT(DAY FROM posted) = :day
|
||||
AND NOT numeric_score=0
|
||||
";
|
||||
$dte = array($totaldate, date("F jS, Y", (strtotime($totaldate))), "Y/m/d", "day");
|
||||
}
|
||||
if($event->page_matches("popular_by_month")){
|
||||
$sql .=
|
||||
"WHERE EXTRACT(YEAR FROM posted) = :year
|
||||
AND EXTRACT(MONTH FROM posted) = :month
|
||||
AND NOT numeric_score=0
|
||||
";
|
||||
$title = date("F Y", (strtotime($totaldate)));
|
||||
$dte = array($totaldate, $title, "Y/m", "month");
|
||||
}
|
||||
if($event->page_matches("popular_by_year")){
|
||||
$sql .=
|
||||
"WHERE EXTRACT(YEAR FROM posted) = :year
|
||||
AND NOT numeric_score=0
|
||||
";
|
||||
$dte = array($totaldate, $year, "Y", "year");
|
||||
}
|
||||
$sql .= " ORDER BY numeric_score DESC LIMIT :limit OFFSET 0";
|
||||
|
||||
//filter images by year/score != 0 > limit to max images on one page > order from highest to lowest score
|
||||
$args = array(
|
||||
"year" => $year,
|
||||
"month" => $month,
|
||||
"day" => $day,
|
||||
"limit" => $t_images
|
||||
);
|
||||
$result = $database->get_all($sql, $args);
|
||||
|
||||
$images = array();
|
||||
foreach($result as $singleResult) {
|
||||
$images[] = Image::by_id($singleResult["id"]);
|
||||
}
|
||||
$this->theme->view_popular($images, $dte);
|
||||
}
|
||||
}
|
||||
|
||||
if($event instanceof NumericScoreSetEvent) {
|
||||
|
@ -55,6 +55,32 @@ class NumericScoreTheme extends Themelet {
|
||||
";
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function view_popular($images, $dte) {
|
||||
global $user, $page;
|
||||
|
||||
$pop_images = '';
|
||||
foreach($images as $image) {
|
||||
$thumb_html = $this->build_thumb_html($image);
|
||||
$pop_images .= '<span class="thumb">'.
|
||||
'<a href="$image_link">'.$thumb_html.'</a>'.
|
||||
'</span>';
|
||||
}
|
||||
|
||||
$b_dte = make_link("popular_by_".$dte[3]."/".date($dte[2], (strtotime('-1 '.$dte[3], strtotime($dte[0])))));
|
||||
$f_dte = make_link("popular_by_".$dte[3]."/".date($dte[2], (strtotime('+1 '.$dte[3], strtotime($dte[0])))));
|
||||
|
||||
$html = '<center><h3><a href="'.$b_dte.'">«</a> '.$dte[1]
|
||||
.' <a href="'.$f_dte.'">»</a>'
|
||||
.'</h3></center>
|
||||
<br>'.$pop_images;
|
||||
|
||||
|
||||
$nav_html = "<a href=".make_link().">Index</a>";
|
||||
|
||||
$page->add_block(new Block("Navigation", $nav_html, "left", 10));
|
||||
$page->add_block(new Block(null, $html, "main", 30));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
BIN
contrib/oekaki/chibipaint.jar
Normal file
BIN
contrib/oekaki/chibipaint.jar
Normal file
Binary file not shown.
674
contrib/oekaki/license.txt
Normal file
674
contrib/oekaki/license.txt
Normal file
@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
96
contrib/oekaki/main.php
Normal file
96
contrib/oekaki/main.php
Normal file
@ -0,0 +1,96 @@
|
||||
<?php
|
||||
/*
|
||||
* Name: [Beta] Oekaki
|
||||
* Author: Shish
|
||||
* Description: ChibiPaint-based Oekaki uploader
|
||||
*/
|
||||
|
||||
class Oekaki extends SimpleExtension {
|
||||
public function onPageRequest($event) {
|
||||
global $user, $page;
|
||||
|
||||
if($event->page_matches("oekaki")) {
|
||||
if(!$this->can_upload($user)) {
|
||||
$this->theme->display_permission_denied($page);
|
||||
}
|
||||
|
||||
if($event->get_arg(0) == "create") {
|
||||
$this->theme->display_page();
|
||||
}
|
||||
if($event->get_arg(0) == "upload") {
|
||||
// FIXME: this allows anyone to upload anything to /data ...
|
||||
// hardcoding the ext to .png should stop the obvious exploit,
|
||||
// but more checking may be wise
|
||||
if(isset($_FILES["picture"])) {
|
||||
header('Content-type: text/plain');
|
||||
|
||||
$uploaddir = './data/oekaki_unclaimed/';
|
||||
if(!file_exists($uploaddir)) mkdir($uploaddir, 0755, true);
|
||||
$file = $_FILES['picture']['name'];
|
||||
$ext = (strpos($file, '.') === FALSE) ? '' : substr($file, strrpos($file, '.'));
|
||||
$uploadname = $_SERVER['REMOTE_ADDR'] . "." . time();
|
||||
$uploadfile = $uploaddir . $uploadname;
|
||||
|
||||
log_info("oekaki", "Uploading file [$uploadname]");
|
||||
|
||||
$success = TRUE;
|
||||
if (isset($_FILES["chibifile"]))
|
||||
$success = $success && move_uploaded_file($_FILES['chibifile']['tmp_name'], $uploadfile . ".chi");
|
||||
|
||||
// hardcode the ext, so nobody can upload "foo.php"
|
||||
$success = $success && move_uploaded_file($_FILES['picture']['tmp_name'], $uploadfile . ".png"); # $ext);
|
||||
if ($success) {
|
||||
echo "CHIBIOK\n";
|
||||
} else {
|
||||
echo "CHIBIERROR\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
echo "CHIBIERROR No Data\n";
|
||||
}
|
||||
}
|
||||
if($event->get_arg(0) == "claim") {
|
||||
// FIXME: move .chi to data/oekaki/$ha/$hash mirroring images and thumbs
|
||||
// FIXME: .chi viewer?
|
||||
// FIXME: clean out old unclaimed images?
|
||||
$pattern = './data/oekaki_unclaimed/' . $_SERVER['REMOTE_ADDR'] . ".*.png";
|
||||
foreach(glob($pattern) as $tmpname) {
|
||||
assert(file_exists($tmpname));
|
||||
|
||||
$pathinfo = pathinfo($tmpname);
|
||||
if(!array_key_exists('extension', $pathinfo)) {
|
||||
throw new UploadException("File has no extension");
|
||||
}
|
||||
log_info("oekaki", "Processing file [{$pathinfo['filename']}]");
|
||||
$metadata['filename'] = 'oekaki.png';
|
||||
$metadata['extension'] = $pathinfo['extension'];
|
||||
$metadata['tags'] = 'oekaki tagme';
|
||||
$metadata['source'] = null;
|
||||
$event = new DataUploadEvent($user, $tmpname, $metadata);
|
||||
send_event($event);
|
||||
if($event->image_id == -1) {
|
||||
throw new UploadException("File type not recognised");
|
||||
}
|
||||
else {
|
||||
unlink($tmpname);
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/".$event->image_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME: "edit this image" button on existing images?
|
||||
function onPostListBuilding($event) {
|
||||
if($this->can_upload($user)) {
|
||||
$this->theme->display_block($page);
|
||||
}
|
||||
}
|
||||
|
||||
private function can_upload($user) {
|
||||
global $config;
|
||||
return ($config->get_bool("upload_anon") || !$user->is_anonymous());
|
||||
}
|
||||
}
|
||||
?>
|
106
contrib/oekaki/readme.txt
Normal file
106
contrib/oekaki/readme.txt
Normal file
@ -0,0 +1,106 @@
|
||||
ChibiPaint
|
||||
|
||||
Copyright (c) 2006-2008 Marc Schefer
|
||||
|
||||
This file is part of ChibiPaint.
|
||||
|
||||
ChibiPaint is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
ChibiPaint is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with ChibiPaint. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
CHIBIPAINT
|
||||
|
||||
ChibiPaint is an oekaki applet. A software that allows people to draw and paint online and share the result with
|
||||
other art enthusiasts. It's designed to be integrated with an oekaki board, a web server running dedicated software.
|
||||
Several are available but we don't currently provide an integrated solution for ChibiPaint.
|
||||
|
||||
INTEGRATION
|
||||
|
||||
ChibiPaint is still in the alpha stage of its development and the following integration specs are likely to evolve
|
||||
in the future.
|
||||
|
||||
APPLET PARAMETERS
|
||||
|
||||
Here's an example on how to integrate the applet in a html webpage
|
||||
|
||||
<applet archive="chibipaint.jar" code="chibipaint.ChibiPaint.class" width="800" height="600">
|
||||
<param name="canvasWidth" value="400" />
|
||||
<param name="canvasHeight" value="300" />
|
||||
<param name="postUrl" value="http://yourserver/oekaki/cpget.php" />
|
||||
<param name="exitUrl" value="http://yourserver/oekaki/" />
|
||||
<param name="exitUrlTarget" value="_self" />
|
||||
<param name="loadImage" value="http://yourserver/oekaki/pictures/168.png" />
|
||||
<param name="loadChibiFile" value="http://yourserver/oekaki/pictures/168.chi" />
|
||||
JAVA NOT SUPPORTED! <!-- alternative content for users who don't have Java installed -->
|
||||
</applet>
|
||||
|
||||
The parameters are:
|
||||
canvasWidth - width of the area on which users can draw (currently capped to 1024)
|
||||
canvasHeight - height of the area on which users can draw (currently capped to 1024)
|
||||
|
||||
postUrl - url that will be used to post the resulting files (see below for more details)
|
||||
exitUrl - after sending the oekaki the user will be redirected to that url
|
||||
exitUrlTarget - optional target to allow different frames configuration
|
||||
|
||||
loadImage - an image (png format) that will be loaded in the applet to be edited
|
||||
loadChibiFile - a chibifile format (.chi) multi-layer image that will be loaded in the applet to be edited
|
||||
|
||||
NOTE: The last two parameters can be omited when they don't apply. If both loadImage and loadChibiFile are specified,
|
||||
loadChibiFile takes precedence
|
||||
|
||||
POST FORMAT
|
||||
|
||||
The applet will send the resulting png file and optionally a multi-layer chibifile format file.
|
||||
|
||||
The files are sent as a regular multipart HTTP POST file upload, similar to the one used by form based file uploads
|
||||
for ease of processing by the server side script.
|
||||
|
||||
The form data name for the png file is 'picture' and 'chibifile' for the multilayer file. The recommended extension
|
||||
for chibifiles is '.chi'
|
||||
|
||||
The applet expects the server to answer with the single line reply "CHIBIOK" followed by a newline character.
|
||||
|
||||
"CHIBIERROR" followed by an error message on the same list is the planned way to report an error but currently the
|
||||
applet will just ignore the error message and report a failure on any reply except CHIBIOK.
|
||||
|
||||
PHP EXAMPLE
|
||||
|
||||
Here's an example of how a php script might handle the applet's POST
|
||||
|
||||
<?php
|
||||
if (isset($_FILES["picture"]))
|
||||
{
|
||||
header ('Content-type: text/plain');
|
||||
|
||||
$uploaddir = $_SERVER["DOCUMENT_ROOT"].'/oekaki/pictures/';
|
||||
$file = $_FILES['picture']['name'];
|
||||
$ext = (strpos($file, '.') === FALSE) ? '' : substr($file, strrpos($file, '.'));
|
||||
$uploadfile = $uploaddir . time();
|
||||
|
||||
$success = TRUE;
|
||||
if (isset($_FILES["chibifile"]))
|
||||
$success = $success && move_uploaded_file($_FILES['chibifile']['tmp_name'], $uploadfile . ".chi");
|
||||
|
||||
$success = $success && move_uploaded_file($_FILES['picture']['tmp_name'], $uploadfile . $ext);
|
||||
if ($success) {
|
||||
echo "CHIBIOK\n";
|
||||
} else {
|
||||
echo "CHIBIERROR\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
echo "CHIBIERROR No Data\n";
|
||||
?>
|
||||
|
||||
CONTACT INFORMATION
|
||||
|
||||
Author: Marc Schefer (codexus@codexus.com)
|
35
contrib/oekaki/theme.php
Normal file
35
contrib/oekaki/theme.php
Normal file
@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
class OekakiTheme extends Themelet {
|
||||
public function display_page() {
|
||||
global $config, $page;
|
||||
|
||||
$base_href = get_base_href();
|
||||
$http_base = make_http($base_href);
|
||||
|
||||
$html = "
|
||||
<applet archive='$base_href/ext/oekaki/chibipaint.jar' code='chibipaint.ChibiPaint.class' width='800' height='600'>
|
||||
<param name='canvasWidth' value='400' />
|
||||
<param name='canvasHeight' value='300' />
|
||||
<param name='postUrl' value='".make_http(make_link("oekaki/upload"))."' />
|
||||
<param name='exitUrl' value='".make_http(make_link("oekaki/claim"))."' />
|
||||
<param name='exitUrlTarget' value='_self' />
|
||||
JAVA NOT SUPPORTED! <!-- alternative content for users who don't have Java installed -->
|
||||
</applet>
|
||||
";
|
||||
|
||||
# <param name='loadImage' value='http://yourserver/oekaki/pictures/168.png' />
|
||||
# <param name='loadChibiFile' value='http://yourserver/oekaki/pictures/168.chi' />
|
||||
|
||||
$page->set_title("Oekaki");
|
||||
$page->set_heading("Oekiaki");
|
||||
$page->add_block(new NavBlock());
|
||||
$page->add_block(new Block("Oekaki", $html, "main", 20));
|
||||
}
|
||||
|
||||
public function display_block() {
|
||||
global $page;
|
||||
$page->add_block(new Block(null, "<a href='".make_link("oekaki/create")."'>Open Oekaki</a>", "left", 21)); // upload is 20
|
||||
}
|
||||
}
|
||||
?>
|
@ -550,12 +550,12 @@ class Pools extends SimpleExtension {
|
||||
private function nuke_pool($poolID) {
|
||||
global $user, $database;
|
||||
|
||||
$p_id = $database->get_one("SELECT user_id FROM pools WHERE id = :pid", array("pid"=>$poolID));
|
||||
if($user->is_admin()) {
|
||||
$database->execute("DELETE FROM pool_history WHERE pool_id = :pid", array("pid"=>$poolID));
|
||||
$database->execute("DELETE FROM pool_images WHERE pool_id = :pid", array("pid"=>$poolID));
|
||||
$database->execute("DELETE FROM pools WHERE id = :pid", array("pid"=>$poolID));
|
||||
} elseif(!$user->is_anonymous()) {
|
||||
// FIXME: WE CHECK IF THE USER IS THE OWNER OF THE POOL IF NOT HE CAN'T DO ANYTHING
|
||||
} elseif($user->id == $p_id) {
|
||||
$database->execute("DELETE FROM pool_history WHERE pool_id = :pid", array("pid"=>$poolID));
|
||||
$database->execute("DELETE FROM pool_images WHERE pool_id = :pid", array("pid"=>$poolID));
|
||||
$database->execute("DELETE FROM pools WHERE id = :pid AND user_id = :uid", array("pid"=>$poolID, "uid"=>$user->id));
|
||||
|
@ -64,7 +64,12 @@ class Ratings implements Extension {
|
||||
}
|
||||
|
||||
if($event instanceof RatingSetEvent) {
|
||||
$this->set_rating($event->image->id, $event->rating);
|
||||
if(empty($event->image->rating)){
|
||||
$old_rating = "";
|
||||
}else{
|
||||
$old_rating = $event->image->rating;
|
||||
}
|
||||
$this->set_rating($event->image->id, $event->rating, $old_rating);
|
||||
}
|
||||
|
||||
if($event instanceof ImageInfoBoxBuildingEvent) {
|
||||
@ -116,7 +121,7 @@ class Ratings implements Extension {
|
||||
if(preg_match("/^rating=(safe|questionable|explicit|unknown)$/", strtolower($event->term), $matches)) {
|
||||
$text = $matches[1];
|
||||
$char = $text[0];
|
||||
$event->add_querylet(new Querylet("rating = ?", array($char)));
|
||||
$event->add_querylet(new Querylet("rating = :img_rating", array("img_rating"=>$char)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -205,9 +210,12 @@ class Ratings implements Extension {
|
||||
}
|
||||
}
|
||||
|
||||
private function set_rating($image_id, $rating) {
|
||||
private function set_rating($image_id, $rating, $old_rating) {
|
||||
global $database;
|
||||
$database->Execute("UPDATE images SET rating=? WHERE id=?", array($rating, $image_id));
|
||||
if($old_rating != $rating){
|
||||
$database->Execute("UPDATE images SET rating=? WHERE id=?", array($rating, $image_id));
|
||||
log_info("rating", "Rating for Image #{$image_id} set to: ".$this->theme->rating_to_name($rating));
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new Ratings());
|
||||
|
@ -18,7 +18,7 @@ class RegenThumb extends SimpleExtension {
|
||||
|
||||
if($event->page_matches("regen_thumb") && $user->is_admin() && isset($_POST['image_id'])) {
|
||||
$image = Image::by_id(int_escape($_POST['image_id']));
|
||||
send_event(new ThumbnailGenerationEvent($image->hash, $image->ext));
|
||||
send_event(new ThumbnailGenerationEvent($image->hash, $image->ext, true));
|
||||
$this->theme->display_results($page, $image);
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ class ResizeImage extends SimpleExtension {
|
||||
public function onInitExt($event) {
|
||||
global $config;
|
||||
$config->set_default_bool('resize_enabled', true);
|
||||
$config->set_default_bool('resize_upload', false);
|
||||
$config->set_default_int('resize_default_width', 0);
|
||||
$config->set_default_int('resize_default_height', 0);
|
||||
}
|
||||
@ -46,6 +47,7 @@ class ResizeImage extends SimpleExtension {
|
||||
public function onSetupBuilding($event) {
|
||||
$sb = new SetupBlock("Image Resize");
|
||||
$sb->add_bool_option("resize_enabled", "Allow resizing images: ");
|
||||
$sb->add_bool_option("resize_upload", "<br>Resize on upload: ");
|
||||
$sb->add_label("<br>Preset/Default Width: ");
|
||||
$sb->add_int_option("resize_default_width");
|
||||
$sb->add_label(" px");
|
||||
@ -56,6 +58,37 @@ class ResizeImage extends SimpleExtension {
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
|
||||
public function onDataUpload(DataUploadEvent $event) {
|
||||
global $config;
|
||||
$image_obj = Image::by_id($event->image_id);
|
||||
//No auto resizing for gifs due to animated gif causing errors :(
|
||||
//Also PNG resizing seems to be completely broken.
|
||||
if($config->get_bool("resize_upload") == true && ($image_obj->ext == "jpg")){
|
||||
$width = $height = 0;
|
||||
|
||||
if ($config->get_int("resize_default_width") !== 0) {
|
||||
$height = $config->get_int("resize_default_width");
|
||||
}
|
||||
if ($config->get_int("resize_default_height") !== 0) {
|
||||
$height = $config->get_int("resize_default_height");
|
||||
}
|
||||
|
||||
try {
|
||||
$this->resize_image($event->image_id, $width, $height);
|
||||
} catch (ImageResizeException $e) {
|
||||
$this->theme->display_resize_error($page, "Error Resizing", $e->error);
|
||||
}
|
||||
|
||||
//Need to generate thumbnail again...
|
||||
//This only seems to be an issue if one of the sizes was set to 0.
|
||||
$image_obj = Image::by_id($event->image_id); //Must be a better way to grab the new hash than setting this again..
|
||||
send_event(new ThumbnailGenerationEvent($image_obj->hash, $image_obj->ext, true));
|
||||
|
||||
log_info("resize", "Image #{$event->image_id} has been resized to: ".$width."x".$height);
|
||||
//TODO: Notify user that image has been resized.
|
||||
}
|
||||
}
|
||||
|
||||
public function onPageRequest($event) {
|
||||
global $page, $user;
|
||||
|
||||
@ -167,7 +200,8 @@ class ResizeImage extends SimpleExtension {
|
||||
switch ( $info[2] ) {
|
||||
case IMAGETYPE_GIF: $image = imagecreatefromgif($image_filename); break;
|
||||
case IMAGETYPE_JPEG: $image = imagecreatefromjpeg($image_filename); break;
|
||||
case IMAGETYPE_PNG: $image = imagecreatefrompng($image_filename); break;
|
||||
/* FIXME: PNG support seems to be broken.
|
||||
case IMAGETYPE_PNG: $image = imagecreatefrompng($image_filename); break;*/
|
||||
default:
|
||||
throw new ImageResizeException("Unsupported image type.");
|
||||
}
|
||||
|
@ -55,7 +55,7 @@ class RSS_Comments extends SimpleExtension {
|
||||
}
|
||||
|
||||
$title = $config->get_string('title');
|
||||
$base_href = make_http($config->get_string('base_href'));
|
||||
$base_href = make_http(get_base_href());
|
||||
$version = $config->get_string('version');
|
||||
$xml = <<<EOD
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
|
@ -66,7 +66,7 @@ class RSS_Images extends SimpleExtension {
|
||||
}
|
||||
|
||||
$title = $config->get_string('title');
|
||||
$base_href = make_http($config->get_string('base_href'));
|
||||
$base_href = make_http(get_base_href());
|
||||
$search = "";
|
||||
if(count($search_terms) > 0) {
|
||||
$search = url_escape(implode(" ", $search_terms)) . "/";
|
||||
|
@ -1,8 +1,8 @@
|
||||
<?php
|
||||
/*
|
||||
* Name: Tag History
|
||||
* Author: Bzchan <bzchan@animemahou.com>
|
||||
* Description: Keep a record of tag changes
|
||||
* Author: Bzchan <bzchan@animemahou.com>, modified by jgen <jgen.tech@gmail.com>
|
||||
* Description: Keep a record of tag changes, and allows you to revert changes.
|
||||
*/
|
||||
|
||||
class Tag_History implements Extension {
|
||||
@ -20,8 +20,44 @@ class Tag_History implements Extension {
|
||||
$this->install();
|
||||
}
|
||||
}
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("tag_history"))
|
||||
|
||||
if(($event instanceof AdminBuildingEvent))
|
||||
{
|
||||
if(isset($_POST['revert_ip']) && $user->is_admin() && $user->check_auth_token())
|
||||
{
|
||||
$revert_ip = filter_var($_POST['revert_ip'], FILTER_VALIDATE_IP, FILTER_FLAG_NO_RES_RANGE);
|
||||
|
||||
if ($revert_ip === false) {
|
||||
// invalid ip given.
|
||||
$this->theme->display_admin_block('Invalid IP');
|
||||
return;
|
||||
}
|
||||
|
||||
if (isset($_POST['revert_date']) && !empty($_POST['revert_date'])) {
|
||||
if (isValidDate($_POST['revert_date'])){
|
||||
$revert_date = addslashes($_POST['revert_date']); // addslashes is really unnecessary since we just checked if valid, but better safe.
|
||||
} else {
|
||||
$this->theme->display_admin_block('Invalid Date');
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$revert_date = null;
|
||||
}
|
||||
|
||||
set_time_limit(0); // reverting changes can take a long time, disable php's timelimit if possible.
|
||||
|
||||
// Call the revert function.
|
||||
$this->process_revert_all_changes_by_ip($revert_ip, $revert_date);
|
||||
// output results
|
||||
$this->theme->display_revert_ip_results();
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->theme->display_admin_block(); // add a block to the admin panel
|
||||
}
|
||||
}
|
||||
|
||||
if (($event instanceof PageRequestEvent) && ($event->page_matches("tag_history")))
|
||||
{
|
||||
if($event->get_arg(0) == "revert")
|
||||
{
|
||||
@ -40,6 +76,7 @@ class Tag_History implements Extension {
|
||||
$this->theme->display_global_page($page, $this->get_global_tag_history());
|
||||
}
|
||||
}
|
||||
|
||||
if(($event instanceof DisplayingImageEvent))
|
||||
{
|
||||
// handle displaying a link on the view page
|
||||
@ -107,7 +144,7 @@ class Tag_History implements Extension {
|
||||
{
|
||||
global $page;
|
||||
// check for the nothing case
|
||||
if($revert_id=="nothing")
|
||||
if(empty($revert_id) || $revert_id=="nothing")
|
||||
{
|
||||
// tried to set it too the same thing so ignore it (might be a bot)
|
||||
// go back to the index page with you
|
||||
@ -121,11 +158,12 @@ class Tag_History implements Extension {
|
||||
// lets get this revert id assuming it exists
|
||||
$result = $this->get_tag_history_from_revert($revert_id);
|
||||
|
||||
if($result==null)
|
||||
if(empty($result))
|
||||
{
|
||||
// there is no history entry with that id so either the image was deleted
|
||||
// while the user was viewing the history, someone is playing with form
|
||||
// variables or we have messed up in code somewhere.
|
||||
/* calling die() is probably not a good idea, we should throw an Exception */
|
||||
die("Error: No tag history with specified id was found.");
|
||||
}
|
||||
|
||||
@ -134,13 +172,43 @@ class Tag_History implements Extension {
|
||||
$stored_image_id = $result['image_id'];
|
||||
$stored_tags = $result['tags'];
|
||||
|
||||
log_debug("tag_history", "Reverting tags of $stored_image_id to [$stored_tags]");
|
||||
log_debug("tag_history", 'Reverting tags of Image #'.$stored_image_id.' to ['.$stored_tags.']');
|
||||
// all should be ok so we can revert by firing the SetUserTags event.
|
||||
send_event(new TagSetEvent(Image::by_id($stored_image_id), $stored_tags));
|
||||
|
||||
// all should be done now so redirect the user back to the image
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/$stored_image_id"));
|
||||
$page->set_redirect(make_link('post/view/'.$stored_image_id));
|
||||
}
|
||||
|
||||
/*
|
||||
* This function is used by process_revert_all_changes_by_ip()
|
||||
* to just revert an image's tag history.
|
||||
*/
|
||||
private function process_revert_request_only($revert_id)
|
||||
{
|
||||
if(empty($revert_id)) {
|
||||
return;
|
||||
}
|
||||
$id = (int) $revert_id;
|
||||
$result = $this->get_tag_history_from_revert($id);
|
||||
|
||||
if(empty($result)) {
|
||||
// there is no history entry with that id so either the image was deleted
|
||||
// while the user was viewing the history, or something messed up
|
||||
/* calling die() is probably not a good idea, we should throw an Exception */
|
||||
die('Error: No tag history with specified id ('.$id.') was found in the database.'."\n\n".
|
||||
'Perhaps the image was deleted while processing this request.');
|
||||
}
|
||||
|
||||
// lets get the values out of the result
|
||||
$stored_result_id = $result['id'];
|
||||
$stored_image_id = $result['image_id'];
|
||||
$stored_tags = $result['tags'];
|
||||
|
||||
log_debug("tag_history", 'Reverting tags of Image #'.$stored_image_id.' to ['.$stored_tags.']');
|
||||
// all should be ok so we can revert by firing the SetUserTags event.
|
||||
send_event(new TagSetEvent(Image::by_id($stored_image_id), $stored_tags));
|
||||
}
|
||||
|
||||
public function get_tag_history_from_revert($revert_id)
|
||||
@ -179,6 +247,56 @@ class Tag_History implements Extension {
|
||||
return ($row ? $row : array());
|
||||
}
|
||||
|
||||
/*
|
||||
* This function attempts to revert all changes by a given IP within an (optional) timeframe.
|
||||
*/
|
||||
public function process_revert_all_changes_by_ip($ip, $date=null)
|
||||
{
|
||||
global $database;
|
||||
$date_select = '';
|
||||
|
||||
if (!empty($date)) {
|
||||
$date_select = 'and date_set >= '.$date;
|
||||
} else {
|
||||
$date = 'forever';
|
||||
}
|
||||
|
||||
log_info("tag_history", 'Attempting to revert edits by ip='.$ip.' (from '.$date.' to now).');
|
||||
|
||||
// Get all the images that the given IP has changed tags on (within the timeframe) that were last editied by the given IP
|
||||
$result = $database->get_all('
|
||||
SELECT t1.image_id FROM tag_histories t1 LEFT JOIN tag_histories t2
|
||||
ON (t1.image_id = t2.image_id AND t1.date_set < t2.date_set)
|
||||
WHERE t2.image_id IS NULL AND t1.user_ip="'.$ip.'" AND t1.image_id IN
|
||||
( select image_id from `tag_histories` where user_ip="'.$ip.'" '.$date_select.')
|
||||
ORDER BY t1.image_id;');
|
||||
|
||||
if (empty($result)) {
|
||||
log_info("tag_history", 'Nothing to revert! for ip='.$ip.' (from '.$date.' to now).');
|
||||
$this->theme->add_status('Nothing to Revert','Nothing to revert for ip='.$ip.' (from '.$date.' to now)');
|
||||
return; // nothing to do.
|
||||
}
|
||||
|
||||
for ($i = 0 ; $i < count($result) ; $i++)
|
||||
{
|
||||
$image_id = (int) $result[$i]['image_id'];
|
||||
|
||||
// Get the first tag history that was done before the given IP edit
|
||||
$row = $database->get_row('
|
||||
SELECT id,tags FROM `tag_histories` WHERE image_id="'.$image_id.'" AND user_ip!="'.$ip.'" '.$date_select.' ORDER BY date_set DESC LIMIT 1');
|
||||
|
||||
if (empty($row)) {
|
||||
// we can not revert this image based on the date restriction.
|
||||
// Output a message perhaps?
|
||||
} else {
|
||||
$id = (int) $row['id'];
|
||||
$this->process_revert_request_only($id);
|
||||
$this->theme->add_status('Reverted Change','Reverted Image #'.$image_id.' to Tag History #'.$id.' ('.$row['tags'].')');
|
||||
}
|
||||
}
|
||||
log_info("tag_history", 'Reverted '.count($result).' edits by ip='.$ip.' (from '.$date.' to now).');
|
||||
}
|
||||
|
||||
/*
|
||||
* this function is called when an image has been deleted
|
||||
*/
|
||||
@ -207,6 +325,7 @@ class Tag_History implements Extension {
|
||||
// if the image has no history, make one with the old tags
|
||||
$entries = $database->get_one("SELECT COUNT(*) FROM tag_histories WHERE image_id = ?", array($image->id));
|
||||
if($entries == 0){
|
||||
/* these two queries could probably be combined */
|
||||
$database->execute("
|
||||
INSERT INTO tag_histories(image_id, tags, user_id, user_ip, date_set)
|
||||
VALUES (?, ?, ?, ?, now())",
|
||||
|
@ -1,6 +1,12 @@
|
||||
<?php
|
||||
/*
|
||||
* Name: Tag History
|
||||
* Author: Bzchan <bzchan@animemahou.com>, modified by jgen <jgen.tech@gmail.com>
|
||||
*/
|
||||
|
||||
class Tag_HistoryTheme extends Themelet {
|
||||
var $messages = array();
|
||||
|
||||
public function display_history_page(Page $page, $image_id, $history) {
|
||||
global $user;
|
||||
$start_string = "
|
||||
@ -22,11 +28,12 @@ class Tag_HistoryTheme extends Themelet {
|
||||
$setter .= " / " . $fields['user_ip'];
|
||||
}
|
||||
$selected = ($n == 2) ? " checked" : "";
|
||||
$history_list .= "
|
||||
$history_list .= '
|
||||
<li>
|
||||
<input type='radio' name='revert' id='$current_id' value='$current_id'$selected>
|
||||
<label for='$current_id'>$current_tags (Set by $setter)</label>
|
||||
</li>\n";
|
||||
<input type="radio" name="revert" id="'.$current_id.'" value="'.$current_id.'"$selected>
|
||||
<label for="'.$current_id.'">'.$current_tags.' (Set by '.$setter.')</label>
|
||||
</li>
|
||||
';
|
||||
}
|
||||
|
||||
$end_string = "
|
||||
@ -37,8 +44,8 @@ class Tag_HistoryTheme extends Themelet {
|
||||
";
|
||||
$history_html = $start_string . $history_list . $end_string;
|
||||
|
||||
$page->set_title("Image $image_id Tag History");
|
||||
$page->set_heading("Tag History: $image_id");
|
||||
$page->set_title('Image '.$image_id.' Tag History');
|
||||
$page->set_heading('Tag History: '.$image_id);
|
||||
$page->add_block(new NavBlock());
|
||||
$page->add_block(new Block("Tag History", $history_html, "main", 10));
|
||||
}
|
||||
@ -68,13 +75,13 @@ class Tag_HistoryTheme extends Themelet {
|
||||
if($user->is_admin()) {
|
||||
$setter .= " / " . $fields['user_ip'];
|
||||
}
|
||||
$history_list .= "
|
||||
$history_list .= '
|
||||
<li>
|
||||
<input type='radio' name='revert' value='$current_id'>
|
||||
<a href='".make_link("post/view/$image_id")."'>$image_id</a>:
|
||||
$current_tags (Set by $setter)
|
||||
<input type="radio" name="revert" value="'.$current_id.'">
|
||||
<a href="'.make_link('post/view/'.$image_id).'">'.$image_id.'</a>:
|
||||
'.$current_tags.' (Set by '.$setter.')
|
||||
</li>
|
||||
";
|
||||
';
|
||||
}
|
||||
|
||||
$history_html = $start_string . $history_list . $end_string;
|
||||
@ -85,8 +92,46 @@ class Tag_HistoryTheme extends Themelet {
|
||||
}
|
||||
|
||||
public function display_history_link(Page $page, $image_id) {
|
||||
$link = "<a href='".make_link("tag_history/$image_id")."'>Tag History</a>\n";
|
||||
$link = '<a href="'.make_link('tag_history/'.$image_id).'">Tag History</a>';
|
||||
$page->add_block(new Block(null, $link, "main", 5));
|
||||
}
|
||||
|
||||
/*
|
||||
* Add a section to the admin page.
|
||||
*/
|
||||
public function display_admin_block($validation_msg='') {
|
||||
global $page;
|
||||
|
||||
if (!empty($validation_msg)) {
|
||||
$validation_msg = '<br><b>'. $validation_msg .'</b>';
|
||||
}
|
||||
|
||||
$html = '
|
||||
Revert tag changes/edit by a specific IP address.<br>
|
||||
You can restrict the time frame to revert these edits as well.
|
||||
<br>(Date format: 2011-10-23)
|
||||
'.$validation_msg.'
|
||||
|
||||
<br><br>'.make_form(make_link("admin/revert_ip"),'POST',false,'revert_ip_form')."
|
||||
IP Address: <input type='text' id='revert_ip' name='revert_ip' size='15'><br>
|
||||
Date range: <input type='text' id='revert_date' name='revert_date' size='15'><br><br>
|
||||
<input type='submit' value='Revert' onclick='return confirm(\"Revert all edits by this IP?\");'>
|
||||
</form><br>
|
||||
";
|
||||
$page->add_block(new Block("Revert By IP", $html));
|
||||
}
|
||||
|
||||
/*
|
||||
* Show a standard page for results to be put into
|
||||
*/
|
||||
public function display_revert_ip_results() {
|
||||
global $page;
|
||||
$html = implode($this->messages, "\n");
|
||||
$page->add_block(new Block("Revert by IP", $html));
|
||||
}
|
||||
|
||||
public function add_status($title, $body) {
|
||||
$this->messages[] = '<p><b>'. $title .'</b><br>'. $body .'</p>';
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -9,7 +9,7 @@ class taggerTheme extends Themelet {
|
||||
public function build_tagger (Page $page, $event) {
|
||||
global $config;
|
||||
// Initialization code
|
||||
$base_href = $config->get_string('base_href');
|
||||
$base_href = get_base_href();
|
||||
// TODO: AJAX test and fallback.
|
||||
$page->add_html_header("<script src='$base_href/ext/tagger/webtoolkit.drag.js' type='text/javascript'></script>");
|
||||
$page->add_block(new Block(null,
|
||||
|
23
contrib/twitter_soc/main.php
Normal file
23
contrib/twitter_soc/main.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
/*
|
||||
* Name: Tweet!
|
||||
* Author: Shish <webmaster@shishnet.org>
|
||||
* License: GPLv2
|
||||
* Description: Show a twitter feed with the Sea of Clouds script
|
||||
*/
|
||||
|
||||
class TwitterSoc extends SimpleExtension {
|
||||
public function onPostListBuilding($event) {
|
||||
global $config, $page;
|
||||
if(strlen($config->get_string("twitter_soc_username")) > 0) {
|
||||
$this->theme->display_feed($page, $config->get_string("twitter_soc_username"));
|
||||
}
|
||||
}
|
||||
|
||||
public function onSetupBuilding($event) {
|
||||
$sb = new SetupBlock("Tweet!");
|
||||
$sb->add_text_option("twitter_soc_username", "Username ");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
}
|
||||
?>
|
238
contrib/twitter_soc/script.js
Normal file
238
contrib/twitter_soc/script.js
Normal file
@ -0,0 +1,238 @@
|
||||
// jquery.tweet.js - See http://tweet.seaofclouds.com/ or https://github.com/seaofclouds/tweet for more info
|
||||
// Copyright (c) 2008-2011 Todd Matthews & Steve Purcell
|
||||
(function($) {
|
||||
$.fn.tweet = function(o){
|
||||
var s = $.extend({
|
||||
username: null, // [string or array] required unless using the 'query' option; one or more twitter screen names (use 'list' option for multiple names, where possible)
|
||||
list: null, // [string] optional name of list belonging to username
|
||||
favorites: false, // [boolean] display the user's favorites instead of his tweets
|
||||
query: null, // [string] optional search query (see also: http://search.twitter.com/operators)
|
||||
avatar_size: null, // [integer] height and width of avatar if displayed (48px max)
|
||||
count: 3, // [integer] how many tweets to display?
|
||||
fetch: null, // [integer] how many tweets to fetch via the API (set this higher than 'count' if using the 'filter' option)
|
||||
page: 1, // [integer] which page of results to fetch (if count != fetch, you'll get unexpected results)
|
||||
retweets: true, // [boolean] whether to fetch (official) retweets (not supported in all display modes)
|
||||
intro_text: null, // [string] do you want text BEFORE your your tweets?
|
||||
outro_text: null, // [string] do you want text AFTER your tweets?
|
||||
join_text: null, // [string] optional text in between date and tweet, try setting to "auto"
|
||||
auto_join_text_default: "i said,", // [string] auto text for non verb: "i said" bullocks
|
||||
auto_join_text_ed: "i", // [string] auto text for past tense: "i" surfed
|
||||
auto_join_text_ing: "i am", // [string] auto tense for present tense: "i was" surfing
|
||||
auto_join_text_reply: "i replied to", // [string] auto tense for replies: "i replied to" @someone "with"
|
||||
auto_join_text_url: "i was looking at", // [string] auto tense for urls: "i was looking at" http:...
|
||||
loading_text: null, // [string] optional loading text, displayed while tweets load
|
||||
refresh_interval: null , // [integer] optional number of seconds after which to reload tweets
|
||||
twitter_url: "twitter.com", // [string] custom twitter url, if any (apigee, etc.)
|
||||
twitter_api_url: "api.twitter.com", // [string] custom twitter api url, if any (apigee, etc.)
|
||||
twitter_search_url: "search.twitter.com", // [string] custom twitter search url, if any (apigee, etc.)
|
||||
template: "{avatar}{time}{join}{text}", // [string or function] template used to construct each tweet <li> - see code for available vars
|
||||
comparator: function(tweet1, tweet2) { // [function] comparator used to sort tweets (see Array.sort)
|
||||
return tweet2["tweet_time"] - tweet1["tweet_time"];
|
||||
},
|
||||
filter: function(tweet) { // [function] whether or not to include a particular tweet (be sure to also set 'fetch')
|
||||
return true;
|
||||
}
|
||||
}, o);
|
||||
|
||||
// See http://daringfireball.net/2010/07/improved_regex_for_matching_urls
|
||||
var url_regexp = /\b((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/gi;
|
||||
|
||||
// Expand values inside simple string templates with {placeholders}
|
||||
function t(template, info) {
|
||||
if (typeof template === "string") {
|
||||
var result = template;
|
||||
for(var key in info) {
|
||||
var val = info[key];
|
||||
result = result.replace(new RegExp('{'+key+'}','g'), val === null ? '' : val);
|
||||
}
|
||||
return result;
|
||||
} else return template(info);
|
||||
}
|
||||
// Export the t function for use when passing a function as the 'template' option
|
||||
$.extend({tweet: {t: t}});
|
||||
|
||||
function replacer (regex, replacement) {
|
||||
return function() {
|
||||
var returning = [];
|
||||
this.each(function() {
|
||||
returning.push(this.replace(regex, replacement));
|
||||
});
|
||||
return $(returning);
|
||||
};
|
||||
}
|
||||
|
||||
function escapeHTML(s) {
|
||||
return s.replace(/</g,"<").replace(/>/g,"^>");
|
||||
}
|
||||
|
||||
$.fn.extend({
|
||||
linkUser: replacer(/(^|[\W])@(\w+)/gi, "$1@<a href=\"http://"+s.twitter_url+"/$2\">$2</a>"),
|
||||
// Support various latin1 (\u00**) and arabic (\u06**) alphanumeric chars
|
||||
linkHash: replacer(/(?:^| )[\#]+([\w\u00c0-\u00d6\u00d8-\u00f6\u00f8-\u00ff\u0600-\u06ff]+)/gi,
|
||||
' <a href="http://'+s.twitter_search_url+'/search?q=&tag=$1&lang=all'+((s.username && s.username.length == 1 && !s.list) ? '&from='+s.username.join("%2BOR%2B") : '')+'">#$1</a>'),
|
||||
capAwesome: replacer(/\b(awesome)\b/gi, '<span class="awesome">$1</span>'),
|
||||
capEpic: replacer(/\b(epic)\b/gi, '<span class="epic">$1</span>'),
|
||||
makeHeart: replacer(/(<)+[3]/gi, "<tt class='heart'>♥</tt>")
|
||||
});
|
||||
|
||||
function linkURLs(text, entities) {
|
||||
return text.replace(url_regexp, function(match) {
|
||||
var url = (/^[a-z]+:/i).test(match) ? match : "http://"+match;
|
||||
var text = match;
|
||||
for(var i = 0; i < entities.length; ++i) {
|
||||
var entity = entities[i];
|
||||
if (entity.url == url && entity.expanded_url) {
|
||||
url = entity.expanded_url;
|
||||
text = entity.display_url;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "<a href=\""+escapeHTML(url)+"\">"+escapeHTML(text)+"</a>";
|
||||
});
|
||||
}
|
||||
|
||||
function parse_date(date_str) {
|
||||
// The non-search twitter APIs return inconsistently-formatted dates, which Date.parse
|
||||
// cannot handle in IE. We therefore perform the following transformation:
|
||||
// "Wed Apr 29 08:53:31 +0000 2009" => "Wed, Apr 29 2009 08:53:31 +0000"
|
||||
return Date.parse(date_str.replace(/^([a-z]{3})( [a-z]{3} \d\d?)(.*)( \d{4})$/i, '$1,$2$4$3'));
|
||||
}
|
||||
|
||||
function relative_time(date) {
|
||||
var relative_to = (arguments.length > 1) ? arguments[1] : new Date();
|
||||
var delta = parseInt((relative_to.getTime() - date) / 1000, 10);
|
||||
var r = '';
|
||||
if (delta < 1) {
|
||||
r = 'just now';
|
||||
} else if (delta < 60) {
|
||||
r = delta + ' seconds ago';
|
||||
} else if(delta < 120) {
|
||||
r = 'a minute ago';
|
||||
} else if(delta < (45*60)) {
|
||||
r = (parseInt(delta / 60, 10)).toString() + ' minutes ago';
|
||||
} else if(delta < (2*60*60)) {
|
||||
r = 'an hour ago';
|
||||
} else if(delta < (24*60*60)) {
|
||||
r = '' + (parseInt(delta / 3600, 10)).toString() + ' hours ago';
|
||||
} else if(delta < (48*60*60)) {
|
||||
r = 'a day ago';
|
||||
} else {
|
||||
r = (parseInt(delta / 86400, 10)).toString() + ' days ago';
|
||||
}
|
||||
return 'about ' + r;
|
||||
}
|
||||
|
||||
function build_auto_join_text(text) {
|
||||
if (text.match(/^(@([A-Za-z0-9-_]+)) .*/i)) {
|
||||
return s.auto_join_text_reply;
|
||||
} else if (text.match(url_regexp)) {
|
||||
return s.auto_join_text_url;
|
||||
} else if (text.match(/^((\w+ed)|just) .*/im)) {
|
||||
return s.auto_join_text_ed;
|
||||
} else if (text.match(/^(\w*ing) .*/i)) {
|
||||
return s.auto_join_text_ing;
|
||||
} else {
|
||||
return s.auto_join_text_default;
|
||||
}
|
||||
}
|
||||
|
||||
function build_api_url() {
|
||||
var proto = ('https:' == document.location.protocol ? 'https:' : 'http:');
|
||||
var count = (s.fetch === null) ? s.count : s.fetch;
|
||||
var common_params = '&include_entities=1&callback=?';
|
||||
if (s.list) {
|
||||
return proto+"//"+s.twitter_api_url+"/1/"+s.username[0]+"/lists/"+s.list+"/statuses.json?page="+s.page+"&per_page="+count+common_params;
|
||||
} else if (s.favorites) {
|
||||
return proto+"//"+s.twitter_api_url+"/favorites/"+s.username[0]+".json?page="+s.page+"&count="+count+common_params;
|
||||
} else if (s.query === null && s.username.length == 1) {
|
||||
return proto+'//'+s.twitter_api_url+'/1/statuses/user_timeline.json?screen_name='+s.username[0]+'&count='+count+(s.retweets ? '&include_rts=1' : '')+'&page='+s.page+common_params;
|
||||
} else {
|
||||
var query = (s.query || 'from:'+s.username.join(' OR from:'));
|
||||
return proto+'//'+s.twitter_search_url+'/search.json?&q='+encodeURIComponent(query)+'&rpp='+count+'&page='+s.page+common_params;
|
||||
}
|
||||
}
|
||||
|
||||
function extract_avatar_url(item, secure) {
|
||||
if (secure) {
|
||||
return ('user' in item) ?
|
||||
item.user.profile_image_url_https :
|
||||
extract_avatar_url(item, false).
|
||||
replace(/^http:\/\/[a-z0-9]{1,3}\.twimg\.com\//, "https://s3.amazonaws.com/twitter_production/");
|
||||
} else {
|
||||
return item.profile_image_url || item.user.profile_image_url;
|
||||
}
|
||||
}
|
||||
|
||||
// Convert twitter API objects into data available for
|
||||
// constructing each tweet <li> using a template
|
||||
function extract_template_data(item){
|
||||
var o = {};
|
||||
o.item = item;
|
||||
o.source = item.source;
|
||||
o.screen_name = item.from_user || item.user.screen_name;
|
||||
o.avatar_size = s.avatar_size;
|
||||
o.avatar_url = extract_avatar_url(item, (document.location.protocol === 'https:'));
|
||||
o.retweet = typeof(item.retweeted_status) != 'undefined';
|
||||
o.tweet_time = parse_date(item.created_at);
|
||||
o.join_text = s.join_text == "auto" ? build_auto_join_text(item.text) : s.join_text;
|
||||
o.tweet_id = item.id_str;
|
||||
o.twitter_base = "http://"+s.twitter_url+"/";
|
||||
o.user_url = o.twitter_base+o.screen_name;
|
||||
o.tweet_url = o.user_url+"/status/"+o.tweet_id;
|
||||
o.reply_url = o.twitter_base+"intent/tweet?in_reply_to="+o.tweet_id;
|
||||
o.retweet_url = o.twitter_base+"intent/retweet?tweet_id="+o.tweet_id;
|
||||
o.favorite_url = o.twitter_base+"intent/favorite?tweet_id="+o.tweet_id;
|
||||
o.retweeted_screen_name = o.retweet && item.retweeted_status.user.screen_name;
|
||||
o.tweet_relative_time = relative_time(o.tweet_time);
|
||||
o.entities = item.entities ? (item.entities.urls || []).concat(item.entities.media || []) : [];
|
||||
o.tweet_raw_text = o.retweet ? ('RT @'+o.retweeted_screen_name+' '+item.retweeted_status.text) : item.text; // avoid '...' in long retweets
|
||||
o.tweet_text = $([linkURLs(o.tweet_raw_text, o.entities)]).linkUser().linkHash()[0];
|
||||
o.tweet_text_fancy = $([o.tweet_text]).makeHeart().capAwesome().capEpic()[0];
|
||||
|
||||
// Default spans, and pre-formatted blocks for common layouts
|
||||
o.user = t('<a class="tweet_user" href="{user_url}">{screen_name}</a>', o);
|
||||
o.join = s.join_text ? t(' <span class="tweet_join">{join_text}</span> ', o) : ' ';
|
||||
o.avatar = o.avatar_size ?
|
||||
t('<a class="tweet_avatar" href="{user_url}"><img src="{avatar_url}" height="{avatar_size}" width="{avatar_size}" alt="{screen_name}\'s avatar" title="{screen_name}\'s avatar" border="0"/></a>', o) : '';
|
||||
o.time = t('<span class="tweet_time"><a href="{tweet_url}" title="view tweet on twitter">{tweet_relative_time}</a></span>', o);
|
||||
o.text = t('<span class="tweet_text">{tweet_text_fancy}</span>', o);
|
||||
o.reply_action = t('<a class="tweet_action tweet_reply" href="{reply_url}">reply</a>', o);
|
||||
o.retweet_action = t('<a class="tweet_action tweet_retweet" href="{retweet_url}">retweet</a>', o);
|
||||
o.favorite_action = t('<a class="tweet_action tweet_favorite" href="{favorite_url}">favorite</a>', o);
|
||||
return o;
|
||||
}
|
||||
|
||||
return this.each(function(i, widget){
|
||||
var list = $('<ul class="tweet_list">');
|
||||
var intro = '<p class="tweet_intro">'+s.intro_text+'</p>';
|
||||
var outro = '<p class="tweet_outro">'+s.outro_text+'</p>';
|
||||
var loading = $('<p class="loading">'+s.loading_text+'</p>');
|
||||
|
||||
if(s.username && typeof(s.username) == "string"){
|
||||
s.username = [s.username];
|
||||
}
|
||||
|
||||
$(widget).bind("tweet:load", function(){
|
||||
if (s.loading_text) $(widget).empty().append(loading);
|
||||
$.getJSON(build_api_url(), function(data){
|
||||
$(widget).empty().append(list);
|
||||
if (s.intro_text) list.before(intro);
|
||||
list.empty();
|
||||
|
||||
var tweets = $.map(data.results || data, extract_template_data);
|
||||
tweets = $.grep(tweets, s.filter).sort(s.comparator).slice(0, s.count);
|
||||
list.append($.map(tweets, function(o) { return "<li>" + t(s.template, o) + "</li>"; }).join('')).
|
||||
children('li:first').addClass('tweet_first').end().
|
||||
children('li:odd').addClass('tweet_even').end().
|
||||
children('li:even').addClass('tweet_odd');
|
||||
|
||||
if (s.outro_text) list.after(outro);
|
||||
$(widget).trigger("loaded").trigger((tweets.length === 0 ? "empty" : "full"));
|
||||
if (s.refresh_interval) {
|
||||
window.setTimeout(function() { $(widget).trigger("tweet:load"); }, 1000 * s.refresh_interval);
|
||||
}
|
||||
});
|
||||
}).trigger("tweet:load");
|
||||
});
|
||||
};
|
||||
})(jQuery);
|
44
contrib/twitter_soc/style.css
Normal file
44
contrib/twitter_soc/style.css
Normal file
@ -0,0 +1,44 @@
|
||||
.tweet,
|
||||
.query {
|
||||
font: 120% Georgia, serif;
|
||||
color: #085258;
|
||||
}
|
||||
|
||||
.tweet_list {
|
||||
-webkit-border-radius: 0.5em;
|
||||
-moz-border-radius: 0.5em;
|
||||
border-radius: 0.5em;
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
overflow-y: hidden;
|
||||
/*background-color: #8ADEE2;*/
|
||||
}
|
||||
|
||||
.tweet_list .awesome,
|
||||
.tweet_list .epic {
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.tweet_list li {
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
padding: 0.5em;
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.tweet_list li a {
|
||||
color: #0C717A;
|
||||
}
|
||||
|
||||
.tweet_list .tweet_even {
|
||||
/*background-color: #91E5E7;*/
|
||||
}
|
||||
|
||||
.tweet_list .tweet_avatar {
|
||||
padding-right: .5em; float: left;
|
||||
}
|
||||
|
||||
.tweet_list .tweet_avatar img {
|
||||
vertical-align: middle;
|
||||
}
|
29
contrib/twitter_soc/test.php
Normal file
29
contrib/twitter_soc/test.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
class TwitterSocTest extends SCoreWebTestCase {
|
||||
function testFeed() {
|
||||
$this->log_in_as_admin();
|
||||
|
||||
$this->get_page("setup");
|
||||
$this->set_field("_config_twitter_soc_username", "shish2k");
|
||||
$this->click("Save Settings");
|
||||
|
||||
/*
|
||||
$this->get_page("post/list");
|
||||
$this->assert_text("Note");
|
||||
$this->assert_text("kittens");
|
||||
*/
|
||||
|
||||
$this->get_page("setup");
|
||||
$this->set_field("_config_twitter_soc_username", "");
|
||||
$this->click("Save Settings");
|
||||
|
||||
/*
|
||||
$this->get_page("post/list");
|
||||
$this->assert_no_text("Note");
|
||||
$this->assert_no_text("kittens");
|
||||
*/
|
||||
|
||||
$this->log_out();
|
||||
}
|
||||
}
|
||||
?>
|
25
contrib/twitter_soc/theme.php
Normal file
25
contrib/twitter_soc/theme.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
class TwitterSocTheme extends Themelet {
|
||||
/*
|
||||
* Show $text on the $page
|
||||
*/
|
||||
public function display_feed(Page $page, $username) {
|
||||
$page->add_block(new Block("Tweets", '
|
||||
<div class="tweet_soc"></div>
|
||||
<p><a href="http://twitter.com/'.url_escape($username).'">Follow us on Twitter</a>
|
||||
<script type="text/javascript">
|
||||
$(function() {
|
||||
$(".tweet_soc").tweet({
|
||||
username: "'.html_escape($username).'",
|
||||
join_text: "auto",
|
||||
template: "{text} -- {time}",
|
||||
count: 6,
|
||||
loading_text: "loading tweets..."
|
||||
});
|
||||
});
|
||||
</script>
|
||||
', "left", 25));
|
||||
}
|
||||
}
|
||||
?>
|
@ -274,8 +274,6 @@ class Database {
|
||||
* stored in config.php in the root shimmie folder
|
||||
*/
|
||||
public function Database() {
|
||||
global $database_dsn, $cache_dsn;
|
||||
|
||||
# FIXME: detect ADODB URI, automatically translate PDO DSN
|
||||
|
||||
/*
|
||||
@ -285,11 +283,13 @@ class Database {
|
||||
* http://stackoverflow.com/questions/237367
|
||||
*/
|
||||
$matches = array(); $db_user=null; $db_pass=null;
|
||||
if(preg_match("/user=([^;]*)/", $database_dsn, $matches)) $db_user=$matches[1];
|
||||
if(preg_match("/password=([^;]*)/", $database_dsn, $matches)) $db_pass=$matches[1];
|
||||
if(preg_match("/user=([^;]*)/", DATABASE_DSN, $matches)) $db_user=$matches[1];
|
||||
if(preg_match("/password=([^;]*)/", DATABASE_DSN, $matches)) $db_pass=$matches[1];
|
||||
|
||||
$this->db = new PDO($database_dsn, $db_user, $db_pass);
|
||||
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
$this->db = new PDO(DATABASE_DSN, $db_user, $db_pass, array(
|
||||
PDO::ATTR_PERSISTENT => true,
|
||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION
|
||||
));
|
||||
|
||||
$db_proto = $this->db->getAttribute(PDO::ATTR_DRIVER_NAME);
|
||||
if($db_proto == "mysql") {
|
||||
@ -305,9 +305,8 @@ class Database {
|
||||
die("Unknown PDO driver: $db_proto");
|
||||
}
|
||||
|
||||
if(isset($cache_dsn) && !empty($cache_dsn)) {
|
||||
$matches = array();
|
||||
preg_match("#(memcache|apc)://(.*)#", $cache_dsn, $matches);
|
||||
$matches = array();
|
||||
if(CACHE_DSN && preg_match("#(memcache|apc)://(.*)#", CACHE_DSN, $matches)) {
|
||||
if($matches[1] == "memcache") {
|
||||
$this->cache = new MemcacheCache($matches[2]);
|
||||
}
|
||||
|
@ -194,7 +194,12 @@ abstract class DataHandlerExtension implements Extension {
|
||||
}
|
||||
|
||||
if(($event instanceof ThumbnailGenerationEvent) && $this->supported_ext($event->type)) {
|
||||
$this->create_thumb($event->hash);
|
||||
if (method_exists($this, 'create_thumb_force') && $event->force == true) {
|
||||
$this->create_thumb_force($event->hash);
|
||||
}
|
||||
else {
|
||||
$this->create_thumb($event->hash);
|
||||
}
|
||||
}
|
||||
|
||||
if(($event instanceof DisplayingImageEvent) && $this->supported_ext($event->image->ext)) {
|
||||
|
@ -24,6 +24,8 @@
|
||||
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
$tag_n = 0; // temp hack
|
||||
$_flexihash = null;
|
||||
$_fh_last_opts = null;
|
||||
|
||||
/**
|
||||
* An object representing an entry in the images table. As of 2.2, this no
|
||||
@ -229,14 +231,9 @@ class Image {
|
||||
*/
|
||||
public function get_tag_array() {
|
||||
global $database;
|
||||
$cached = $database->cache->get("image-{$this->id}-tags");
|
||||
if($cached) return $cached;
|
||||
|
||||
if(!isset($this->tag_array)) {
|
||||
$this->tag_array = $database->get_col("SELECT tag FROM image_tags JOIN tags ON image_tags.tag_id = tags.id WHERE image_id=:id ORDER BY tag", array("id"=>$this->id));
|
||||
}
|
||||
|
||||
$database->cache->set("image-{$this->id}-tags", $this->tag_array);
|
||||
return $this->tag_array;
|
||||
}
|
||||
|
||||
@ -369,7 +366,10 @@ class Image {
|
||||
public function set_source($source) {
|
||||
global $database;
|
||||
if(empty($source)) $source = null;
|
||||
$database->execute("UPDATE images SET source=:source WHERE id=:id", array("source"=>$source, "id"=>$this->id));
|
||||
if($source != $this->source) {
|
||||
$database->execute("UPDATE images SET source=:source WHERE id=:id", array("source"=>$source, "id"=>$this->id));
|
||||
log_info("core-image", "Source for Image #{$this->id} set to: ".$source);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -382,7 +382,10 @@ class Image {
|
||||
$sln = $database->engine->scoreql_to_sql("SCORE_BOOL_$ln");
|
||||
$sln = str_replace("'", "", $sln);
|
||||
$sln = str_replace('"', "", $sln);
|
||||
$database->execute("UPDATE images SET locked=:yn WHERE id=:id", array("yn"=>$sln, "id"=>$this->id));
|
||||
if($sln != $this->locked) {
|
||||
$database->execute("UPDATE images SET locked=:yn WHERE id=:id", array("yn"=>$sln, "id"=>$this->id));
|
||||
log_info("core-image", "Setting Image #{$this->id} lock to: $ln");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -403,46 +406,49 @@ class Image {
|
||||
*/
|
||||
public function set_tags($tags) {
|
||||
global $database;
|
||||
|
||||
$tags = Tag::resolve_list($tags);
|
||||
|
||||
assert(is_array($tags));
|
||||
assert(count($tags) > 0);
|
||||
$new_tags = implode(" ", $tags);
|
||||
|
||||
// delete old
|
||||
$this->delete_tags_from_image();
|
||||
|
||||
// insert each new tags
|
||||
foreach($tags as $tag) {
|
||||
$id = $database->get_one(
|
||||
$database->engine->scoreql_to_sql(
|
||||
"SELECT id FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"
|
||||
),
|
||||
array("tag"=>$tag));
|
||||
if(empty($id)) {
|
||||
// a new tag
|
||||
$database->execute(
|
||||
"INSERT INTO tags(tag) VALUES (:tag)",
|
||||
if($new_tags != $this->get_tag_list()) {
|
||||
// delete old
|
||||
$this->delete_tags_from_image();
|
||||
// insert each new tags
|
||||
foreach($tags as $tag) {
|
||||
$id = $database->get_one(
|
||||
$database->engine->scoreql_to_sql(
|
||||
"SELECT id FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"
|
||||
),
|
||||
array("tag"=>$tag));
|
||||
if(empty($id)) {
|
||||
// a new tag
|
||||
$database->execute(
|
||||
"INSERT INTO tags(tag) VALUES (:tag)",
|
||||
array("tag"=>$tag));
|
||||
$database->execute(
|
||||
"INSERT INTO image_tags(image_id, tag_id)
|
||||
VALUES(:id, (SELECT id FROM tags WHERE tag = :tag))",
|
||||
array("id"=>$this->id, "tag"=>$tag));
|
||||
}
|
||||
else {
|
||||
// user of an existing tag
|
||||
$database->execute(
|
||||
"INSERT INTO image_tags(image_id, tag_id) VALUES(:iid, :tid)",
|
||||
array("iid"=>$this->id, "tid"=>$id));
|
||||
}
|
||||
$database->execute(
|
||||
"INSERT INTO image_tags(image_id, tag_id)
|
||||
VALUES(:id, (SELECT id FROM tags WHERE tag = :tag))",
|
||||
array("id"=>$this->id, "tag"=>$tag));
|
||||
$database->engine->scoreql_to_sql(
|
||||
"UPDATE tags SET count = count + 1 WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"
|
||||
),
|
||||
array("tag"=>$tag));
|
||||
}
|
||||
else {
|
||||
// user of an existing tag
|
||||
$database->execute(
|
||||
"INSERT INTO image_tags(image_id, tag_id) VALUES(:iid, :tid)",
|
||||
array("iid"=>$this->id, "tid"=>$id));
|
||||
}
|
||||
$database->execute(
|
||||
$database->engine->scoreql_to_sql(
|
||||
"UPDATE tags SET count = count + 1 WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"
|
||||
),
|
||||
array("tag"=>$tag));
|
||||
}
|
||||
|
||||
log_info("core-image", "Tags for Image #{$this->id} set to: ".implode(" ", $tags));
|
||||
$database->cache->delete("image-{$this->id}-tags");
|
||||
log_info("core-image", "Tags for Image #{$this->id} set to: ".implode(" ", $tags));
|
||||
$database->cache->delete("image-{$this->id}-tags");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -507,6 +513,37 @@ class Image {
|
||||
$tmpl = $plte->link;
|
||||
}
|
||||
|
||||
global $_flexihash, $_fh_last_opts;
|
||||
$matches = array();
|
||||
if(preg_match("/(.*){(.*)}(.*)/", $tmpl, $matches)) {
|
||||
$pre = $matches[1];
|
||||
$opts = $matches[2];
|
||||
$post = $matches[3];
|
||||
|
||||
if($opts != $_fh_last_opts) {
|
||||
$_fh_last_opts = $opts;
|
||||
require_once("lib/flexihash.php");
|
||||
$_flexihash = new Flexihash();
|
||||
foreach(explode(",", $opts) as $opt) {
|
||||
$parts = explode("=", $opt);
|
||||
$opt_val = "";
|
||||
$opt_weight = 0;
|
||||
if(count($parts) == 2) {
|
||||
$opt_val = $parts[0];
|
||||
$opt_weight = $parts[1];
|
||||
}
|
||||
elseif(count($parts) == 1) {
|
||||
$opt_val = $parts[0];
|
||||
$opt_weight = 1;
|
||||
}
|
||||
$_flexihash->addTarget($opt_val, $opt_weight);
|
||||
}
|
||||
}
|
||||
|
||||
$choice = $_flexihash->lookup($pre.$post);
|
||||
$tmpl = $pre.$choice.$post;
|
||||
}
|
||||
|
||||
return $tmpl;
|
||||
}
|
||||
|
||||
@ -556,10 +593,13 @@ class Image {
|
||||
// various types of querylet
|
||||
foreach($terms as $term) {
|
||||
$positive = true;
|
||||
if((strlen($term) > 0) && ($term[0] == '-')) {
|
||||
if(strlen($term) > 0 && $term[0] == '-') {
|
||||
$positive = false;
|
||||
$term = substr($term, 1);
|
||||
}
|
||||
if(strlen($term) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$term = Tag::resolve_alias($term);
|
||||
|
||||
|
@ -208,10 +208,10 @@ class Page {
|
||||
header('Expires: ' . gmdate('D, d M Y H:i:s', time() - 600) . ' GMT');
|
||||
}
|
||||
}
|
||||
else {
|
||||
header("Cache-control: no-cache");
|
||||
header('Expires: ' . gmdate('D, d M Y H:i:s', time() - 600) . ' GMT');
|
||||
}
|
||||
#else {
|
||||
# header("Cache-control: no-cache");
|
||||
# header('Expires: ' . gmdate('D, d M Y H:i:s', time() - 600) . ' GMT');
|
||||
#}
|
||||
usort($this->blocks, "blockcmp");
|
||||
$this->add_auto_html_headers();
|
||||
$layout = new Layout();
|
||||
|
@ -184,7 +184,7 @@ class User {
|
||||
}
|
||||
|
||||
public function check_auth_token() {
|
||||
return ($_POST["auth_token"] == $this->get_auth_token());
|
||||
return (isset($_POST["auth_token"]) && $_POST["auth_token"] == $this->get_auth_token());
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -130,10 +130,42 @@ function to_shorthand_int($int) {
|
||||
*/
|
||||
function autodate($date, $html=true) {
|
||||
$cpu = date('c', strtotime($date));
|
||||
$hum = date('F j, Y', strtotime($date));
|
||||
$hum = date('F j, Y; H:i', strtotime($date));
|
||||
return ($html ? "<time datetime='$cpu'>$hum</time>" : $hum);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given string is a valid date-time. ( Format: yyyy-mm-dd hh:mm:ss )
|
||||
*
|
||||
* @retval boolean
|
||||
*/
|
||||
function isValidDateTime($dateTime)
|
||||
{
|
||||
if (preg_match("/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/", $dateTime, $matches)) {
|
||||
if (checkdate($matches[2], $matches[3], $matches[1])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a given string is a valid date. ( Format: yyyy-mm-dd )
|
||||
*
|
||||
* @retval boolean
|
||||
*/
|
||||
function isValidDate($date)
|
||||
{
|
||||
if (preg_match("/^(\d{4})-(\d{2})-(\d{2})$/", $date, $matches)) {
|
||||
// checkdate wants (month, day, year)
|
||||
if (checkdate($matches[2], $matches[3], $matches[1])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a pluraliser if necessary
|
||||
@ -172,7 +204,7 @@ function make_link($page=null, $query=null) {
|
||||
|
||||
if(is_null($page)) $page = $config->get_string('main_page');
|
||||
|
||||
if(FORCE_NICE_URLS || $config->get_bool('nice_urls', false)) {
|
||||
if(NICE_URLS || $config->get_bool('nice_urls', false)) {
|
||||
#$full = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"];
|
||||
$full = $_SERVER["PHP_SELF"];
|
||||
$base = str_replace("/index.php", "", $full);
|
||||
@ -507,7 +539,10 @@ function set_prefixed_cookie($name, $value, $time, $path) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Figure out the path to the shimmie install root.
|
||||
* Figure out the path to the shimmie install directory.
|
||||
*
|
||||
* eg if shimmie is visible at http://foo.com/gallery, this
|
||||
* function should return /gallery
|
||||
*
|
||||
* PHP really, really sucks.
|
||||
*
|
||||
@ -788,8 +823,12 @@ function send_event(Event $event) {
|
||||
* Debugging functions *
|
||||
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
// SHIT by default this returns the time as a string. And it's not even a
|
||||
// string representation of a number, it's two numbers separated by a space.
|
||||
// What the fuck were the PHP developers smoking.
|
||||
$_load_start = microtime(true);
|
||||
function get_debug_info() {
|
||||
global $config, $_event_count, $database, $_execs;
|
||||
global $config, $_event_count, $database, $_execs, $_load_start;
|
||||
|
||||
if(function_exists('memory_get_usage')) {
|
||||
$i_mem = sprintf("%5.2f", ((memory_get_usage()+512)/1024)/1024);
|
||||
@ -797,25 +836,16 @@ function get_debug_info() {
|
||||
else {
|
||||
$i_mem = "???";
|
||||
}
|
||||
if(function_exists('getrusage')) {
|
||||
$ru = getrusage();
|
||||
$i_utime = sprintf("%5.2f", ($ru["ru_utime.tv_sec"]*1e6+$ru["ru_utime.tv_usec"])/1000000);
|
||||
$i_stime = sprintf("%5.2f", ($ru["ru_stime.tv_sec"]*1e6+$ru["ru_stime.tv_usec"])/1000000);
|
||||
}
|
||||
else {
|
||||
$i_utime = "???";
|
||||
$i_stime = "???";
|
||||
}
|
||||
|
||||
$time = sprintf("%5.2f", microtime(true) - $_load_start);
|
||||
$i_files = count(get_included_files());
|
||||
$hits = $database->cache->get_hits();
|
||||
$miss = $database->cache->get_misses();
|
||||
|
||||
$debug = "<br>Took $i_utime + $i_stime seconds and {$i_mem}MB of RAM";
|
||||
$debug = "<br>Took $time seconds and {$i_mem}MB of RAM";
|
||||
$debug .= "; Used $i_files files and $_execs queries";
|
||||
$debug .= "; Sent $_event_count events";
|
||||
$debug .= "; $hits cache hits and $miss misses";
|
||||
$debug .= "; Shimmie version ". VERSION .", SCore Version ". SCORE_VERSION;
|
||||
$debug .= "; Shimmie version ". VERSION; // .", SCore Version ". SCORE_VERSION;
|
||||
|
||||
return $debug;
|
||||
}
|
||||
@ -881,10 +911,11 @@ function _stripslashes_r($arr) {
|
||||
function _sanitise_environment() {
|
||||
if(DEBUG) {
|
||||
error_reporting(E_ALL);
|
||||
assert_options(ASSERT_ACTIVE, 1);
|
||||
assert_options(ASSERT_BAIL, 1);
|
||||
}
|
||||
|
||||
assert_options(ASSERT_ACTIVE, 1);
|
||||
assert_options(ASSERT_BAIL, 1);
|
||||
|
||||
ob_start();
|
||||
|
||||
if(get_magic_quotes_gpc()) {
|
||||
@ -1019,7 +1050,7 @@ function _start_cache() {
|
||||
$_cache_hash = md5($_SERVER["QUERY_STRING"]);
|
||||
$ab = substr($_cache_hash, 0, 2);
|
||||
$cd = substr($_cache_hash, 2, 2);
|
||||
$_cache_filename = "data/$ab/$cd/$_cache_hash";
|
||||
$_cache_filename = "data/http_cache/$ab/$cd/$_cache_hash";
|
||||
|
||||
if(!file_exists(dirname($_cache_filename))) {
|
||||
mkdir(dirname($_cache_filename), 0750, true);
|
||||
|
@ -63,6 +63,7 @@ class BBCode extends FormatterExtension {
|
||||
$text = preg_replace("/\[li\](.*?)\[\/li\]/s", "<li>\\1</li>", $text);
|
||||
$text = preg_replace("#\[\*\]#s", "<li>", $text);
|
||||
$text = preg_replace("#<br><(li|ul|ol|/ul|/ol)>#s", "<\\1>", $text);
|
||||
$text = preg_replace("#\[align=(left|center|right)\](.*?)\[\/align\]#s", "<div style='text-align:\\1;'>\\2</div>", $text);
|
||||
$text = $this->filter_spoiler($text);
|
||||
$text = $this->insert_code($text);
|
||||
return $text;
|
||||
@ -132,7 +133,8 @@ class BBCode extends FormatterExtension {
|
||||
# at the end of this function, the only code! blocks should be
|
||||
# the ones we've added -- others may contain malicious content,
|
||||
# which would only appear after decoding
|
||||
$text = preg_replace("/\[code!\](.*?)\[\/code!\]/s", "[code]\\1[/code]", $text);
|
||||
$text = str_replace("[code!]", "[code]", $text);
|
||||
$text = str_replace("[/code!]", "[/code]", $text);
|
||||
|
||||
$l1 = strlen("[code]");
|
||||
$l2 = strlen("[/code]");
|
||||
|
@ -146,7 +146,8 @@ class CommentList extends SimpleExtension {
|
||||
}
|
||||
}
|
||||
else if($event->get_arg(0) == "list") {
|
||||
$this->build_page($event->get_arg(1));
|
||||
$page_num = int_escape($event->get_arg(1));
|
||||
$this->build_page($page_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -264,9 +265,10 @@ class CommentList extends SimpleExtension {
|
||||
$threads_per_page = 10;
|
||||
$start = $threads_per_page * ($current_page - 1);
|
||||
|
||||
$where = SPEED_HAX ? "WHERE posted > now() - interval '24 hours'" : "";
|
||||
$get_threads = "
|
||||
SELECT image_id,MAX(posted) AS latest
|
||||
FROM comments
|
||||
FROM comments $where
|
||||
GROUP BY image_id
|
||||
ORDER BY latest DESC
|
||||
LIMIT :limit OFFSET :offset
|
||||
@ -275,7 +277,7 @@ class CommentList extends SimpleExtension {
|
||||
|
||||
$total_pages = $database->cache->get("comment_pages");
|
||||
if(empty($total_pages)) {
|
||||
$total_pages = (int)($database->get_one("SELECT COUNT(c1) FROM (SELECT COUNT(image_id) AS c1 FROM comments GROUP BY image_id) AS s1") / 10);
|
||||
$total_pages = (int)($database->get_one("SELECT COUNT(c1) FROM (SELECT COUNT(image_id) AS c1 FROM comments $where GROUP BY image_id) AS s1") / 10);
|
||||
$database->cache->set("comment_pages", $total_pages, 600);
|
||||
}
|
||||
|
||||
@ -372,9 +374,10 @@ class CommentList extends SimpleExtension {
|
||||
$window = int_escape($config->get_int('comment_window'));
|
||||
$max = int_escape($config->get_int('comment_limit'));
|
||||
|
||||
// window doesn't work as an SQL param because it's inside quotes >_<
|
||||
$result = $database->get_all("SELECT * FROM comments WHERE owner_ip = :remote_ip ".
|
||||
"AND posted > date_sub(now(), interval :window minute)",
|
||||
Array("remote_ip"=>$_SERVER['REMOTE_ADDR'], "window"=>$window));
|
||||
"AND posted > now() - interval '$window minute'",
|
||||
Array("remote_ip"=>$_SERVER['REMOTE_ADDR']));
|
||||
|
||||
return (count($result) >= $max);
|
||||
}
|
||||
@ -405,6 +408,17 @@ class CommentList extends SimpleExtension {
|
||||
'permalink' => '',
|
||||
);
|
||||
|
||||
# akismet breaks if there's no referrer in the environment; so if there
|
||||
# isn't, supply one manually
|
||||
if(!isset($_SERVER['HTTP_REFERER'])) {
|
||||
$comment['referrer'] = 'none';
|
||||
log_warning("comment", "User '{$user->name}' commented with no referrer: $text");
|
||||
}
|
||||
if(!isset($_SERVER['HTTP_USER_AGENT'])) {
|
||||
$comment['user_agent'] = 'none';
|
||||
log_warning("comment", "User '{$user->name}' commented with no user-agent: $text");
|
||||
}
|
||||
|
||||
$akismet = new Akismet(
|
||||
$_SERVER['SERVER_NAME'],
|
||||
$config->get_string('comment_wordpress_key'),
|
||||
|
@ -123,6 +123,9 @@ class CommentListTheme extends Themelet {
|
||||
foreach($comments as $comment) {
|
||||
$html .= $this->comment_to_html($comment, true);
|
||||
}
|
||||
if(empty($html)) {
|
||||
$html = '<p>No comments by this user.</p>';
|
||||
}
|
||||
$page->add_block(new Block("Comments", $html, "left", 70));
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,14 @@ class PixelFileHandler extends DataHandlerExtension {
|
||||
}
|
||||
|
||||
protected function create_thumb($hash) {
|
||||
$outname = warehouse_path("thumbs", $hash);
|
||||
if(file_exists($outname)) {
|
||||
return true;
|
||||
}
|
||||
return $this->create_thumb_force($hash);
|
||||
}
|
||||
|
||||
protected function create_thumb_force($hash) {
|
||||
$inname = warehouse_path("images", $hash);
|
||||
$outname = warehouse_path("thumbs", $hash);
|
||||
global $config;
|
||||
|
@ -89,17 +89,18 @@ class ImageReplaceException extends SCoreException {
|
||||
* Request a thumbnail be made for an image object.
|
||||
*/
|
||||
class ThumbnailGenerationEvent extends Event {
|
||||
var $hash, $type;
|
||||
|
||||
var $hash, $type, $force;
|
||||
|
||||
/**
|
||||
* Request a thumbnail be made for an image object
|
||||
*
|
||||
* @param $hash The unique hash of the image
|
||||
* @param $type The type of the image
|
||||
*/
|
||||
public function ThumbnailGenerationEvent($hash, $type) {
|
||||
public function ThumbnailGenerationEvent($hash, $type, $force=false) {
|
||||
$this->hash = $hash;
|
||||
$this->type = $type;
|
||||
$this->force = $force;
|
||||
}
|
||||
}
|
||||
|
||||
@ -347,6 +348,7 @@ class ImageIO extends SimpleExtension {
|
||||
$tags_to_set = $image->get_tag_array();
|
||||
$image->tag_array = array();
|
||||
send_event(new TagSetEvent($image, $tags_to_set));
|
||||
log_info("core-image", "Source for Image #{$image->id} set to: {$image->source}");
|
||||
}
|
||||
// }}} end add
|
||||
|
||||
|
@ -167,7 +167,6 @@ class Setup extends SimpleExtension {
|
||||
$config->set_default_string("title", "Shimmie");
|
||||
$config->set_default_string("front_page", "post/list");
|
||||
$config->set_default_string("main_page", "post/list");
|
||||
$config->set_default_string("base_href", "./index.php?q=");
|
||||
$config->set_default_string("theme", "default");
|
||||
$config->set_default_bool("word_wrap", true);
|
||||
$config->set_default_bool("comment_captcha", false);
|
||||
|
@ -85,7 +85,8 @@ class TagEdit implements Extension {
|
||||
$this->theme->display_error($page, "Error", "Anonymous tag editing is disabled");
|
||||
}
|
||||
if($user->is_admin()) {
|
||||
send_event(new LockSetEvent($event->image, $_POST['tag_edit__locked']=="on"));
|
||||
$locked = isset($_POST['tag_edit__locked']) && $_POST['tag_edit__locked']=="on";
|
||||
send_event(new LockSetEvent($event->image, $locked));
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,7 +104,6 @@ class TagEdit implements Extension {
|
||||
|
||||
if($event instanceof LockSetEvent) {
|
||||
if($user->is_admin()) {
|
||||
log_debug("tag_edit", "Setting Image #{$event->image->id} lock to: {$event->locked}");
|
||||
$event->image->set_locked($event->locked);
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,8 @@ class TagList implements Extension {
|
||||
}
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("api/internal/tag_list/complete")) {
|
||||
if(!isset($_GET["s"])) return;
|
||||
|
||||
$all = $database->get_all(
|
||||
"SELECT tag FROM tags WHERE tag LIKE :search AND count > 0 LIMIT 10",
|
||||
array("search"=>$_GET["s"]."%"));
|
||||
|
66
ext/upload/bookmarklet.js
Normal file
66
ext/upload/bookmarklet.js
Normal file
@ -0,0 +1,66 @@
|
||||
/* Imageboard to Shimmie */
|
||||
// This should work with "most" sites running Danbooru/Gelbooru/Shimmie
|
||||
|
||||
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 notsup = "The file you are trying to upload is not supported!";
|
||||
|
||||
if (confirm("OK = Use Current tags.\nCancel = Use new tags.")==true){}else{var tag=prompt("Enter Tags","");var chk=1;};
|
||||
|
||||
// Danbooru
|
||||
if(document.getElementById("post_tags") !== null){
|
||||
if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("post_tags").value;}
|
||||
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){
|
||||
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(supext.search(document.getElementById("highres").href.match("http\:\/\/.*\\.([a-z0-9]+)")[1]) !== -1){
|
||||
if(filesze <= maxsze){
|
||||
location.href=ste+document.getElementById("highres").href+"&tags="+tag+"&rating="+rtg+"&source="+srx;
|
||||
}else{alert(toobig);}
|
||||
}else{alert(notsup);}
|
||||
}else{
|
||||
if(supext.search("swf") !== -1){
|
||||
location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+tag+"&rating="+rtg+"&source="+srx;
|
||||
}else{alert(notsup);}
|
||||
}
|
||||
}
|
||||
/* Shimmie
|
||||
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.
|
||||
This crazy way of checking "should" work with older releases though (Seems to work with 2009~ ver) */
|
||||
else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.-]+\: ")==0){
|
||||
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.
|
||||
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.)*/
|
||||
if(tag.search(/\bflash\b/)==-1){
|
||||
var img = document.getElementById("main_image").src;
|
||||
if(supext.search(img.match(".*\\.([a-z0-9]+)")[1]) !== -1){
|
||||
location.href=ste+img+"&tags="+tag+"&source="+srx;
|
||||
}else{alert(notsup);}
|
||||
}else{
|
||||
var mov = document.location.hostname+document.getElementsByName("movie")[0].value;
|
||||
if(supext.search("swf") !== -1){
|
||||
location.href=ste+mov+"&tags="+tag+"&source="+srx;
|
||||
}else{alert(notsup);}
|
||||
}
|
||||
}
|
||||
// Gelbooru
|
||||
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;}
|
||||
var rtg=document.getElementById("stats").innerHTML.match("<li>Rating: (.*)<\/li>")[1];
|
||||
//Can't seem to grab source due to url containing a &
|
||||
//var srx="http://" + document.location.hostname + document.location.href.match("\/index\.php?page=post&s=view\\&id=.*");
|
||||
var gmi=document.getElementById("image").src.match(".*img[0-9]+\.gelbooru\.com\/\/images\/[0-9]+\/[a-z0-9]+\.[a-z0-9]+")[0];
|
||||
//Since Gelbooru does not allow flash, no need to search for flash tag.
|
||||
//Gelbooru doesn't show file size in statistics either...
|
||||
if(supext.search(gmi.match("http\:\/\/.*\\.([a-z0-9]+)")[1]) !== -1){
|
||||
location.href=ste+gmi+"&tags="+tag+"&rating="+rtg[1];//+"&source="+srx;
|
||||
}else{alert(notsup);}
|
||||
}
|
@ -179,7 +179,9 @@ class Upload implements Extension {
|
||||
}
|
||||
else
|
||||
{
|
||||
if(!$is_full) {
|
||||
if ($is_full) {
|
||||
$this->theme->display_full($page);
|
||||
} else {
|
||||
$this->theme->display_page($page);
|
||||
}
|
||||
}
|
||||
@ -312,7 +314,7 @@ class Upload implements Extension {
|
||||
}
|
||||
|
||||
// Checks if user is admin > check if you want locked.
|
||||
if($user->is_admin()){
|
||||
if($user->is_admin() && !empty($_GET['locked'])){
|
||||
$locked = bool_escape($_GET['locked']);
|
||||
}
|
||||
|
||||
|
@ -10,64 +10,93 @@ class UploadTheme extends Themelet {
|
||||
}
|
||||
|
||||
public function display_page(Page $page) {
|
||||
global $config;
|
||||
$tl_enabled = ($config->get_string("transload_engine", "none") != "none");
|
||||
global $config, $page;
|
||||
$page->add_html_header("<link rel='stylesheet' href='".get_base_href()."/ext/upload/_style.css' type='text/css'>");
|
||||
|
||||
$tl_enabled = ($config->get_string("transload_engine", "none") != "none");
|
||||
// Uploader 2.0!
|
||||
$upload_list = "";
|
||||
for($i=0; $i<$config->get_int('upload_count'); $i++) {
|
||||
for($i=0; $i<$config->get_int('upload_count'); $i++)
|
||||
{
|
||||
$a=$i+1;
|
||||
$s=$i-1;
|
||||
|
||||
if(!$i==0){
|
||||
$upload_list .="<tr id='row$i' style='display:none'>";
|
||||
}else{
|
||||
$upload_list .= "<tr id='row$i'>";
|
||||
}
|
||||
$upload_list .= "<td width='15'>";
|
||||
|
||||
if($i==0){
|
||||
$upload_list .= "<div id='hide$i'><img id='wrapper' src='ext/upload/minus.png' />" .
|
||||
"<a href='#' onclick='javascript:document.getElementById("row$a").style.display = "";document.getElementById("hide$i").style.display = "none";document.getElementById("hide$a").style.display = "";'>".
|
||||
"<img src='ext/upload/plus.png'></a></div></td>";
|
||||
}else{
|
||||
$upload_list .="<div id='hide$i'>
|
||||
<a href='#' onclick='javascript:document.getElementById("row$i").style.display = "none";".
|
||||
"document.getElementById("hide$i").style.display = "none";".
|
||||
"document.getElementById("hide$s").style.display = "";".
|
||||
"document.getElementById("data$i").value = "";".
|
||||
"document.getElementById("url$i").value = "";'>".
|
||||
"<img src='ext/upload/minus.png' /></a>";
|
||||
if($a==$config->get_int('upload_count')){
|
||||
$upload_list .="<img id='wrapper' src='ext/upload/plus.png' />";
|
||||
}else{
|
||||
$upload_list .=
|
||||
"<a href='#' onclick='javascript:document.getElementById("row$a").style.display = "";".
|
||||
"document.getElementById("hide$i").style.display = "none";".
|
||||
"document.getElementById("hide$a").style.display = "";'>".
|
||||
"<img src='ext/upload/plus.png' /></a>";
|
||||
}
|
||||
$upload_list .= "</div></td>";
|
||||
}
|
||||
}
|
||||
|
||||
$upload_list .= "<td width='15'>";
|
||||
|
||||
if($i==0){
|
||||
$js = 'javascript:$(function() {
|
||||
$("#row'.$a.'").show();
|
||||
$("#hide'.$i.'").hide();
|
||||
$("#hide'.$a.'").show();});';
|
||||
|
||||
$upload_list .= "<div id='hide$i'><img id='wrapper' src='ext/upload/minus.png' />" .
|
||||
"<a href='#' onclick='$js'>".
|
||||
"<img src='ext/upload/plus.png'></a></div></td>";
|
||||
} else {
|
||||
$js = 'javascript:$(function() {
|
||||
$("#row'.$i.'").hide();
|
||||
$("#hide'.$i.'").hide();
|
||||
$("#hide'.$s.'").show();
|
||||
$("#data'.$i.'").val("");
|
||||
$("#url'.$i.'").val("");
|
||||
});';
|
||||
|
||||
$upload_list .="<div id='hide$i'>
|
||||
<a href='#' onclick='$js'>".
|
||||
"<img src='ext/upload/minus.png' /></a>";
|
||||
|
||||
if($a==$config->get_int('upload_count')){
|
||||
$upload_list .="<img id='wrapper' src='ext/upload/plus.png' />";
|
||||
}else{
|
||||
$js1 = 'javascript:$(function() {
|
||||
$("#row'.$a.'").show();
|
||||
$("#hide'.$i.'").hide();
|
||||
$("#hide'.$a.'").show(); });';
|
||||
|
||||
$upload_list .=
|
||||
"<td width='60'><form><input id='radio_buttona' type='radio' name='method' value='file' checked='checked' onclick='javascript:document.getElementById("url$i").style.display = "none";document.getElementById("url$i").value = "";document.getElementById("data$i").style.display = ""' /> File<br>";
|
||||
if($tl_enabled) {
|
||||
$upload_list .=
|
||||
"<input id='radio_buttonb' type='radio' name='method' value='url' onclick='javascript:document.getElementById("data$i").style.display = "none";document.getElementById("data$i").value = "";document.getElementById("url$i").style.display = ""' /> URL</ br></td></form>
|
||||
"<a href='#' onclick='$js1'>".
|
||||
"<img src='ext/upload/plus.png' /></a>";
|
||||
}
|
||||
$upload_list .= "</div></td>";
|
||||
}
|
||||
|
||||
<td><input id='data$i' name='data$i' class='wid' type='file'><input id='url$i' name='url$i' class='wid' type='text' style='display:none'></td>
|
||||
";
|
||||
}
|
||||
else {
|
||||
$upload_list .= "</form></td>
|
||||
<td width='250'><input id='data$i' name='data$i' class='wid' type='file'></td>
|
||||
";
|
||||
}
|
||||
$js2 = 'javascript:$(function() {
|
||||
$("#url'.$i.'").hide();
|
||||
$("#url'.$i.'").val("");
|
||||
$("#data'.$i.'").show(); });';
|
||||
|
||||
$upload_list .=
|
||||
"<form><td width='60'><input id='radio_button_a$i' type='radio' name='method' value='file' checked='checked' onclick='$js2' /> File<br>";
|
||||
|
||||
if($tl_enabled) {
|
||||
$js = 'javascript:$(function() {
|
||||
$("#data'.$i.'").hide();
|
||||
$("#data'.$i.'").val("");
|
||||
$("#url'.$i.'").show(); });';
|
||||
|
||||
$upload_list .=
|
||||
"<input id='radio_button_b$i' type='radio' name='method' value='url' onclick='$js' /> URL</ br></td></form>
|
||||
<td>
|
||||
<input id='data$i' name='data$i' class='wid' type='file'>
|
||||
<input id='url$i' name='url$i' class='wid' type='text' style='display:none'>
|
||||
</td>";
|
||||
} else {
|
||||
$upload_list .= "</td>
|
||||
<td width='250'><input id='data$i' name='data$i' class='wid' type='file'></td>
|
||||
";
|
||||
}
|
||||
|
||||
$upload_list .= "
|
||||
</tr>
|
||||
";
|
||||
}
|
||||
|
||||
$max_size = $config->get_int('upload_size');
|
||||
$max_kb = to_shorthand_int($max_size);
|
||||
$html = "
|
||||
@ -86,7 +115,7 @@ class UploadTheme extends Themelet {
|
||||
});
|
||||
});
|
||||
</script>
|
||||
".make_form(make_link("upload"), "POST", $multipart=True)."
|
||||
".make_form(make_link("upload"), "POST", $multipart=True, 'file_upload')."
|
||||
<table id='large_upload_form' class='vert'>
|
||||
$upload_list
|
||||
<tr><td></td><td>Tags<td colspan='3'><input id='tag_box' name='tags' type='text'></td></tr>
|
||||
@ -98,47 +127,35 @@ class UploadTheme extends Themelet {
|
||||
";
|
||||
|
||||
if($tl_enabled) {
|
||||
$link = make_http(make_link("upload"));
|
||||
$link = make_http(make_link("upload"));
|
||||
$main_page = make_http(make_link());
|
||||
$title = $config->get_string('title');
|
||||
|
||||
if($config->get_bool('nice_urls')){
|
||||
$delimiter = '?';
|
||||
} else {
|
||||
$delimiter = '&';
|
||||
}
|
||||
{
|
||||
$title = "Upload to " . $config->get_string('title');
|
||||
$html .= '<p><a href="javascript:location.href="' .
|
||||
$link . $delimiter . 'url="+location.href+"&tags="+prompt("enter tags")">' .
|
||||
$title . '</a> (Drag & drop onto your bookmarks toolbar, then click when looking at an image)';
|
||||
{
|
||||
$js='javascript:(function(){if(typeof window=="undefined"||!window.location||window.location.href=="about:blank"){window.location="'. $main_page .'";}else if(typeof document=="undefined"||!document.body){window.location="'. $main_page .'?url="+encodeURIComponent(window.location.href);} else if(window.location.href.match("\/\/'. $_SERVER["HTTP_HOST"] .'.*")){alert("You are already at '. $title .'!");} else{var tags=prompt("Please enter tags","tagme");if(tags!=""&&tags!=null){var link="'. $link . $delimiter .'url="+location.href+"&tags="+tags;var w=window.open(link,"_blank");}}})();';
|
||||
$html .= '<p><a href=\''.$js.'\'>Upload to '.$title.'</a> (Drag & drop onto your bookmarks toolbar, then click when looking at an image)';
|
||||
}
|
||||
{
|
||||
/* Danbooru > Shimmie Bookmarklet.
|
||||
This "should" work on any site running danbooru, unless for some odd reason they switched around the id's or aren't using post/list.
|
||||
Most likely this will stop working when Danbooru updates to v2, all depends if they switch the ids or not >_>.
|
||||
Clicking the link on a danbooru image page should give you something along the lines of:
|
||||
'http://www.website.com/shimmie/upload?url="http://sonohara.donmai.us/data/crazylongurl.jpg&tags="too many tags"&rating="s"&source="http://danbooru.donmai.us/post/show/012345/"'
|
||||
TODO: Possibly make the entire/most of the script into a .js file, and just make the bookmarklet load it on click (Something like that?)
|
||||
/* Imageboard > Shimmie Bookmarklet
|
||||
This is more or less, an upgraded version of the "Danbooru>Shimmie" bookmarklet.
|
||||
At the moment this works with Shimmie & Danbooru.
|
||||
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.
|
||||
*/
|
||||
$title = "Danbooru to " . $config->get_string('title');
|
||||
$html .= '<p><a href="javascript:'.
|
||||
/* This should stop the bookmarklet being insanely long...not that it's already huge or anything. */
|
||||
'var ste="'. $link . $delimiter .'url=";var tag=document.getElementById("post_tags").value;var rtg=document.documentElement.innerHTML.match("<li>Rating: (.*)<\/li>");var srx="http://" + document.location.hostname+document.location.href.match("\/post\/show\/.*\/");' .
|
||||
//The default confirm sucks, mainly due to being unable to change the text in the Ok/Cancel box (Yes/No would be better.)
|
||||
'if (confirm("OK = Use Current tags.\nCancel = Use new tags.")==true){' . //Just incase some people don't want the insane amount of tags danbooru has.
|
||||
//The flash check is kind of picky, although it should work on "most" images..there will be either some old or extremely new ones that lack the flash tag.
|
||||
'if(tag.search(/\bflash\b/)==-1){'.
|
||||
'location.href=ste+document.getElementById("highres").href+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx;}'.
|
||||
'else{'.
|
||||
'location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx;}'.
|
||||
//The following is more or less the same as above, instead using the tags on danbooru, should load a prompt box instead.
|
||||
'}else{'.
|
||||
'var p=prompt("Enter Tags","");'.
|
||||
'if(tag.search(/\bflash\b/)==-1){'.
|
||||
'location.href=ste+document.getElementById("highres").href+"&tags="+p+"&rating="+rtg[1]+"&source="+srx;}' .
|
||||
'else{'.
|
||||
'location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+p+"&rating="+rtg[1]+"&source="+srx;}'.
|
||||
'}">' .
|
||||
$title . '</a> (As above, Click on a Danbooru-run image page. (This also grabs the tags/rating/source!))';
|
||||
|
||||
//Bookmarklet checks if shimmie supports ext. If not, won't upload to site/shows alert saying not supported.
|
||||
$supported_ext = "jpg jpeg gif png";
|
||||
if(file_exists("ext/handle_flash")){$supported_ext .= " swf";}
|
||||
if(file_exists("ext/handle_ico")){$supported_ext .= " ico ani cur";}
|
||||
if(file_exists("ext/handle_mp3")){$supported_ext .= " mp3";}
|
||||
if(file_exists("ext/handle_svg")){$supported_ext .= " svg";}
|
||||
$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")).'")">'.
|
||||
$title . '</a> (Click when looking at an image page. Works on sites running Shimmie/Danbooru/Gelbooru. (This also grabs the tags/rating/source!))';
|
||||
}
|
||||
|
||||
}
|
||||
@ -151,17 +168,28 @@ class UploadTheme extends Themelet {
|
||||
|
||||
/* only allows 1 file to be uploaded - for replacing another image file */
|
||||
public function display_replace_page(Page $page, $image_id) {
|
||||
global $config;
|
||||
global $config, $page;
|
||||
$page->add_html_header("<link rel='stylesheet' href='".get_base_href()."/ext/upload/_style.css' type='text/css'>");
|
||||
$tl_enabled = ($config->get_string("transload_engine", "none") != "none");
|
||||
|
||||
$js2 = 'javascript:$(function() {
|
||||
$("#data").hide();
|
||||
$("#data").val("");
|
||||
$("#url").show(); });';
|
||||
|
||||
$js1 = 'javascript:$(function() {
|
||||
$("#url").hide();
|
||||
$("#url").val("");
|
||||
$("#data").show(); });';
|
||||
|
||||
$upload_list = '';
|
||||
$upload_list .= "
|
||||
<tr>
|
||||
<td width='60'><form><input id='radio_buttona' type='radio' name='method' value='file' checked='checked' onclick='javascript:document.getElementById("url0").style.display = "none";document.getElementById("url0").value = "";document.getElementById("data0").style.display = ""' /> File<br>";
|
||||
<td width='60'><form><input id='radio_button_a' type='radio' name='method' value='file' checked='checked' onclick='$js1' /> File<br>";
|
||||
if($tl_enabled) {
|
||||
$upload_list .="
|
||||
<input id='radio_buttonb' type='radio' name='method' value='url' onclick='javascript:document.getElementById("data0").style.display = "none";document.getElementById("data0").value = "";document.getElementById("url0").style.display = ""' /> URL</ br></td></form>
|
||||
<td><input id='data0' name='data0' class='wid' type='file'><input id='url0' name='url0' class='wid' type='text' style='display:none'></td>
|
||||
<input id='radio_button_b' type='radio' name='method' value='url' onclick='$js2' /> URL</ br></td></form>
|
||||
<td><input id='data' name='data' class='wid' type='file'><input id='url' name='url' class='wid' type='text' style='display:none'></td>
|
||||
";
|
||||
} else {
|
||||
$upload_list .= "</form></td>
|
||||
|
@ -79,7 +79,7 @@ class UserPage extends SimpleExtension {
|
||||
}
|
||||
else if($event->get_arg(0) == "logout") {
|
||||
set_prefixed_cookie("session", "", time()+60*60*24*$config->get_int('login_memory'), "/");
|
||||
if(CACHE_HTTP) {
|
||||
if(CACHE_HTTP || SPEED_HAX) {
|
||||
# to keep as few versions of content as possible,
|
||||
# make cookies all-or-nothing
|
||||
set_prefixed_cookie("user", "", time()+60*60*24*$config->get_int('login_memory'), "/");
|
||||
@ -144,6 +144,12 @@ class UserPage extends SimpleExtension {
|
||||
// join (select owner_id,count(*) as comment_count from comments group by owner_id) as _comments on _comments.owner_id=users.id;
|
||||
$this->theme->display_user_list($page, User::by_list(0), $user);
|
||||
}
|
||||
else if($event->get_arg(0) == "delete_user") {
|
||||
$this->delete_user($page);
|
||||
}
|
||||
else if($event->get_arg(0) == "delete_user_with_images") {
|
||||
$this->delete_user_with_images($page);
|
||||
}
|
||||
}
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("user")) {
|
||||
@ -181,8 +187,8 @@ class UserPage extends SimpleExtension {
|
||||
$this->theme->display_user_links($page, $user, $ubbe->parts);
|
||||
}
|
||||
if(
|
||||
($user->is_admin() || $user->id == $event->display_user->id) &&
|
||||
($user->id != $config->get_int('anon_id'))
|
||||
($user->is_admin() || ($user->is_logged_in() && $user->id == $event->display_user->id)) && # admin or self-user
|
||||
($event->display_user->id != $config->get_int('anon_id')) # don't show anon's IP list, it is le huge
|
||||
) {
|
||||
$this->theme->display_ip_list(
|
||||
$page,
|
||||
@ -463,6 +469,72 @@ class UserPage extends SimpleExtension {
|
||||
ORDER BY most_recent DESC", array("id"=>$duser->id));
|
||||
return $rows;
|
||||
}
|
||||
|
||||
private function delete_user($page) {
|
||||
global $user;
|
||||
global $config;
|
||||
global $database;
|
||||
|
||||
$page->set_title("Error");
|
||||
$page->set_heading("Error");
|
||||
$page->add_block(new NavBlock());
|
||||
|
||||
if (!$user->is_admin()) {
|
||||
$page->add_block(new Block("Not Admin", "Only admins can delete accounts"));
|
||||
}
|
||||
else if(!isset($_POST['id']) || !is_numeric($_POST['id'])) {
|
||||
$page->add_block(new Block("No ID Specified",
|
||||
"You need to specify the account number to edit"));
|
||||
}
|
||||
else{
|
||||
$database->Execute(
|
||||
"UPDATE images SET owner_id = :new_owner_id WHERE owner_id = :old_owner_id",
|
||||
array("new_owner_id" => $config->get_int('anon_id'), "old_owner_id" => $_POST['id'])
|
||||
);
|
||||
$database->execute(
|
||||
"DELETE FROM users WHERE id = :id",
|
||||
array("id" => $_POST['id'])
|
||||
);
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/list"));
|
||||
}
|
||||
}
|
||||
|
||||
private function delete_user_with_images($page) {
|
||||
global $user;
|
||||
global $config;
|
||||
global $database;
|
||||
|
||||
$page->set_title("Error");
|
||||
$page->set_heading("Error");
|
||||
$page->add_block(new NavBlock());
|
||||
|
||||
if (!$user->is_admin()) {
|
||||
$page->add_block(new Block("Not Admin", "Only admins can delete accounts"));
|
||||
}
|
||||
else if(!isset($_POST['id']) || !is_numeric($_POST['id'])) {
|
||||
$page->add_block(new Block("No ID Specified",
|
||||
"You need to specify the account number to edit"));
|
||||
}
|
||||
else{
|
||||
$rows = $database->get_all("SELECT * FROM images WHERE owner_id = :owner_id", array("owner_id" => $_POST['id']));
|
||||
foreach ($rows as $key => $value)
|
||||
{
|
||||
$image = Image::by_id($value['id']);
|
||||
if($image) {
|
||||
send_event(new ImageDeletionEvent($image));
|
||||
}
|
||||
}
|
||||
$database->execute("DELETE FROM users
|
||||
WHERE id = :id"
|
||||
, array("id"=>$_POST['id']));
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/list"));
|
||||
}
|
||||
}
|
||||
|
||||
// }}}
|
||||
}
|
||||
add_event_listener(new UserPage());
|
||||
|
@ -17,7 +17,7 @@ class UserPageTheme extends Themelet {
|
||||
$html .= "<tr><td>Name</td></tr>";
|
||||
foreach($users as $duser) {
|
||||
$html .= "<tr>";
|
||||
$html .= "<td><a href='".make_link("user/"+$duser->name)."'>".html_escape($duser->name)."</a></td>";
|
||||
$html .= "<td><a href='".make_link("user/".$duser->name)."'>".html_escape($duser->name)."</a></td>";
|
||||
$html .= "</tr>";
|
||||
}
|
||||
$html .= "</table>";
|
||||
@ -149,38 +149,50 @@ class UserPageTheme extends Themelet {
|
||||
|
||||
protected function build_options(User $duser) {
|
||||
global $config, $database, $user;
|
||||
|
||||
$html = "
|
||||
".make_form(make_link("user_admin/change_pass"))."
|
||||
<input type='hidden' name='id' value='{$duser->id}'>
|
||||
<table style='width: 300px;'>
|
||||
<tr><th colspan='2'>Change Password</th></tr>
|
||||
<tr><td>Password</td><td><input type='password' name='pass1'></td></tr>
|
||||
<tr><td>Repeat Password</td><td><input type='password' name='pass2'></td></tr>
|
||||
<tr><td colspan='2'><input type='Submit' value='Change Password'></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<p>".make_form(make_link("user_admin/change_email"))."
|
||||
<input type='hidden' name='id' value='{$duser->id}'>
|
||||
<table style='width: 300px;'>
|
||||
<tr><th colspan='2'>Change Email</th></tr>
|
||||
<tr><td>Address</td><td><input type='text' name='address' value='".html_escape($duser->email)."'></td></tr>
|
||||
<tr><td colspan='2'><input type='Submit' value='Set'></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
";
|
||||
|
||||
if($user->is_admin()) {
|
||||
$i_user_id = int_escape($duser->id);
|
||||
$h_is_admin = $duser->is_admin() ? " checked" : "";
|
||||
$html = "";
|
||||
if($duser->id != $config->get_int('anon_id')){ //justa fool-admin protection so they dont mess around with anon users.
|
||||
|
||||
$html .= "
|
||||
<p>".make_form(make_link("user_admin/set_more"))."
|
||||
<input type='hidden' name='id' value='$i_user_id'>
|
||||
Admin: <input name='admin' type='checkbox'$h_is_admin>
|
||||
<input type='submit' value='Set'>
|
||||
</form>
|
||||
".make_form(make_link("user_admin/change_pass"))."
|
||||
<input type='hidden' name='id' value='{$duser->id}'>
|
||||
<table style='width: 300px;'>
|
||||
<tr><th colspan='2'>Change Password</th></tr>
|
||||
<tr><td>Password</td><td><input type='password' name='pass1'></td></tr>
|
||||
<tr><td>Repeat Password</td><td><input type='password' name='pass2'></td></tr>
|
||||
<tr><td colspan='2'><input type='Submit' value='Change Password'></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
|
||||
<p>".make_form(make_link("user_admin/change_email"))."
|
||||
<input type='hidden' name='id' value='{$duser->id}'>
|
||||
<table style='width: 300px;'>
|
||||
<tr><th colspan='2'>Change Email</th></tr>
|
||||
<tr><td>Address</td><td><input type='text' name='address' value='".html_escape($duser->email)."'></td></tr>
|
||||
<tr><td colspan='2'><input type='Submit' value='Set'></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
";
|
||||
|
||||
if($user->is_admin()) {
|
||||
$i_user_id = int_escape($duser->id);
|
||||
$h_is_admin = $duser->is_admin() ? " checked" : "";
|
||||
$html .= "
|
||||
<p>".make_form(make_link("user_admin/set_more"))."
|
||||
<input type='hidden' name='id' value='$i_user_id'>
|
||||
Admin: <input name='admin' type='checkbox'$h_is_admin>
|
||||
<input type='submit' value='Set'>
|
||||
</form>
|
||||
|
||||
".make_form(make_link("user_admin/delete_user"))."
|
||||
<input type='hidden' name='id' value='$i_user_id'>
|
||||
<input type='submit' value='Delete User' onclick='confirm(\"Delete the user?\");' />
|
||||
</form>
|
||||
|
||||
".make_form(make_link("user_admin/delete_user_with_images"))."
|
||||
<input type='hidden' name='id' value='$i_user_id'>
|
||||
<input type='submit' value='Delete User with images' onclick='confirm(\"Delete the user with his uploaded images?\");' />
|
||||
</form>";
|
||||
}
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ class ViewImage extends SimpleExtension {
|
||||
$this->theme->display_error($page, "Image not found", "Image $image_id could not be found");
|
||||
return;
|
||||
}
|
||||
|
||||
if($event->page_matches("post/next")) {
|
||||
$image = $image->get_next($search_terms);
|
||||
}
|
||||
@ -98,13 +99,13 @@ class ViewImage extends SimpleExtension {
|
||||
$image = $image->get_prev($search_terms);
|
||||
}
|
||||
|
||||
if(!is_null($image)) {
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/{$image->id}", $query));
|
||||
}
|
||||
else {
|
||||
if(is_null($image)) {
|
||||
$this->theme->display_error($page, "Image not found", "No more images");
|
||||
return;
|
||||
}
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/{$image->id}", $query));
|
||||
}
|
||||
|
||||
if($event->page_matches("post/view")) {
|
||||
@ -125,6 +126,8 @@ class ViewImage extends SimpleExtension {
|
||||
}
|
||||
|
||||
if($event->page_matches("post/set")) {
|
||||
if(!isset($_POST['image_id'])) return;
|
||||
|
||||
$image_id = int_escape($_POST['image_id']);
|
||||
|
||||
send_event(new ImageInfoSetEvent(Image::by_id($image_id)));
|
||||
|
33
index.php
33
index.php
@ -56,19 +56,26 @@ if(empty($database_dsn) && !file_exists("config.php")) {
|
||||
}
|
||||
require_once "config.php";
|
||||
|
||||
// to change these system-level settings, do define("FOO", 123); in config.php
|
||||
function _d($name, $value) {if(!defined($name)) define($name, $value);}
|
||||
_d("DATABASE_DSN", null); // string PDO database connection details
|
||||
_d("CACHE_DSN", null); // string cache connection details
|
||||
_d("DEBUG", false); // boolean print various debugging details
|
||||
_d("COVERAGE", false); // boolean activate xdebug coverage monitor
|
||||
_d("CONTEXT", null); // string file to log performance data into
|
||||
_d("CACHE_MEMCACHE", false); // boolean store complete rendered pages in memcache
|
||||
_d("CACHE_DIR", false); // boolean store complete rendered pages on disk
|
||||
_d("CACHE_HTTP", false); // boolean output explicit HTTP caching headers
|
||||
_d("COOKIE_PREFIX", 'shm'); // string if you run multiple galleries with non-shared logins, give them different prefixes
|
||||
_d("SPEED_HAX", false); // boolean do some questionable things in the name of performance
|
||||
_d("NICE_URLS", false); // boolean force niceurl mode
|
||||
_d("WH_SPLITS", 1); // int how many levels of subfolders to put in the warehouse
|
||||
_d("VERSION", 'trunk'); // string shimmie version
|
||||
_d("SCORE_VERSION", 's2hack/'.VERSION); // string SCore version
|
||||
_d("TIMEZONE", 'UTC'); // string timezone
|
||||
|
||||
// set up and purify the environment
|
||||
if(!defined("DEBUG")) define("DEBUG", false);
|
||||
if(!defined("COVERAGE")) define("COVERAGE", false);
|
||||
if(!defined("CONTEXT")) define("CONTEXT", false);
|
||||
if(!defined("CACHE_MEMCACHE")) define("CACHE_MEMCACHE", false);
|
||||
if(!defined("CACHE_DIR")) define("CACHE_DIR", false);
|
||||
if(!defined("CACHE_HTTP")) define("CACHE_HTTP", false);
|
||||
if(!defined("VERSION")) define("VERSION", 'trunk');
|
||||
if(!defined("SCORE_VERSION")) define("SCORE_VERSION", 's2hack/'.VERSION);
|
||||
if(!defined("COOKIE_PREFIX")) define("COOKIE_PREFIX", 'shm');
|
||||
if(!defined("SPEED_HAX")) define("SPEED_HAX", false);
|
||||
if(!defined("FORCE_NICE_URLS")) define("FORCE_NICE_URLS", false);
|
||||
if(!defined("WH_SPLITS")) define("WH_SPLITS", 1);
|
||||
date_default_timezone_set(TIMEZONE);
|
||||
|
||||
require_once "core/util.inc.php";
|
||||
require_once "lib/context.php";
|
||||
@ -170,7 +177,7 @@ catch(Exception $e) {
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
$database->db->rollback();
|
||||
if($database && $database->db) $database->db->rollback();
|
||||
ctx_log_ender();
|
||||
}
|
||||
?>
|
||||
|
67
install.php
67
install.php
@ -52,7 +52,7 @@ if(is_readable("config.php")) {
|
||||
<h1>Shimmie Repair Console</h1>
|
||||
<?php
|
||||
include "config.php";
|
||||
if($_SESSION['dsn'] == $database_dsn || $_POST['dsn'] == $database_dsn) {
|
||||
if($_SESSION['dsn'] == DATABASE_DSN || $_POST['dsn'] == DATABASE_DSN) {
|
||||
if($_POST['dsn']) {$_SESSION['dsn'] = $_POST['dsn'];}
|
||||
|
||||
if(empty($_GET["action"])) {
|
||||
@ -76,6 +76,15 @@ if(is_readable("config.php")) {
|
||||
</form>
|
||||
";
|
||||
*/
|
||||
echo "<h3>Database quick fix for User deletion</h3>";
|
||||
echo "just a database fix for those who instaled shimmie before 2012 january the 22rd.<br>";
|
||||
echo "Note: some things needs to be done manually, to work properly.<br>";
|
||||
echo "WARNING: ONLY PROCEEDS IF YOU KNOW WHAT YOU ARE DOING!";
|
||||
echo "
|
||||
<form action='install.php?action=Database_user_deletion_fix' method='POST'>
|
||||
<input type='submit' value='go!'>
|
||||
</form>
|
||||
";
|
||||
|
||||
echo "<h3>Log Out</h3>";
|
||||
echo "
|
||||
@ -87,6 +96,9 @@ if(is_readable("config.php")) {
|
||||
else if($_GET["action"] == "logout") {
|
||||
session_destroy();
|
||||
}
|
||||
else if($_GET["action"] == "Database_user_deletion_fix") {
|
||||
Database_user_deletion_fix();
|
||||
}
|
||||
} else {
|
||||
echo "
|
||||
<h3>Login</h3>
|
||||
@ -285,7 +297,7 @@ function create_tables() { // {{{
|
||||
INDEX(owner_id),
|
||||
INDEX(width),
|
||||
INDEX(height),
|
||||
FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
CONSTRAINT foreign_images_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT
|
||||
");
|
||||
$db->create_table("tags", "
|
||||
id SCORE_AIPK,
|
||||
@ -298,8 +310,8 @@ function create_tables() { // {{{
|
||||
INDEX(image_id),
|
||||
INDEX(tag_id),
|
||||
UNIQUE(image_id, tag_id),
|
||||
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE
|
||||
CONSTRAINT foreign_image_tags_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
|
||||
CONSTRAINT foreign_image_tags_tag_id FOREIGN KEY (tag_id) REFERENCES tags(id) ON DELETE CASCADE
|
||||
");
|
||||
$db->execute("INSERT INTO config(name, value) VALUES('db_version', 8)");
|
||||
}
|
||||
@ -350,7 +362,9 @@ function build_dirs() { // {{{
|
||||
} // }}}
|
||||
function write_config() { // {{{
|
||||
global $database_dsn;
|
||||
$file_content = "<?php \$database_dsn='$database_dsn'; ?>";
|
||||
$file_content = "<"+"?php\n"+
|
||||
"define('DATABASE_DSN', '$database_dsn');\n"+
|
||||
"?"+">";
|
||||
|
||||
if(is_writable("./") && file_put_contents("config.php", $file_content)) {
|
||||
assert(file_exists("config.php"));
|
||||
@ -370,6 +384,49 @@ EOD;
|
||||
exit;
|
||||
}
|
||||
} // }}}
|
||||
|
||||
function Database_user_deletion_fix() {
|
||||
try {
|
||||
require_once "core/database.class.php";
|
||||
$db = new Database();
|
||||
|
||||
echo "Fixing user_favorites table....";
|
||||
|
||||
($db->Execute("ALTER TABLE user_favorites ENGINE=InnoDB;")) ? print_r("ok<br>") : print_r("failed<br>");
|
||||
echo "adding Foreign key to user ids...";
|
||||
|
||||
($db->Execute("ALTER TABLE user_favorites ADD CONSTRAINT foreign_user_favorites_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;"))? print_r("ok<br>"):print_r("failed<br>");
|
||||
echo "cleaning, the table from deleted image favorites...<br>";
|
||||
|
||||
$rows = $db->get_all("SELECT * FROM user_favorites WHERE image_id NOT IN ( SELECT id FROM images );");
|
||||
|
||||
foreach( $rows as $key => $value)
|
||||
$db->Execute("DELETE FROM user_favorites WHERE image_id = :image_id;", array("image_id" => $value["image_id"]));
|
||||
|
||||
echo "adding forign key to image ids...";
|
||||
|
||||
($db->Execute("ALTER TABLE user_favorites ADD CONSTRAINT user_favorites_image_id FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE;"))? print_r("ok<br>"):print_r("failed<br>");
|
||||
|
||||
echo "adding foreign keys to private messages...";
|
||||
|
||||
($db->Execute("ALTER TABLE private_message
|
||||
ADD CONSTRAINT foreign_private_message_from_id FOREIGN KEY (from_id) REFERENCES users(id) ON DELETE CASCADE,
|
||||
ADD CONSTRAINT foreign_private_message_to_id FOREIGN KEY (to_id) REFERENCES users(id) ON DELETE CASCADE;")) ? print_r("ok<br>"):print_r("failed<br>");
|
||||
|
||||
echo "Just one more step...which you need to do manually:<br>";
|
||||
echo "You need to go to your database and Delete the foreign key on the owner_id in the images table.<br><br>";
|
||||
echo "<a href='http://www.justin-cook.com/wp/2006/05/09/how-to-remove-foreign-keys-in-mysql/'>How to remove foreign keys</a><br><br>";
|
||||
echo "and finally execute this querry:<br><br>";
|
||||
echo "ALTER TABLE images ADD CONSTRAINT foreign_images_owner_id FOREIGN KEY (owner_id) REFERENCES users(id) ON DELETE RESTRICT;<br><br>";
|
||||
echo "if this is all sucesfull you are done!";
|
||||
|
||||
}
|
||||
catch (PDOException $e)
|
||||
{
|
||||
// FIXME: Make the error message user friendly
|
||||
exit($e->getMessage());
|
||||
}
|
||||
}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
||||
|
269
lib/flexihash.php
Normal file
269
lib/flexihash.php
Normal file
@ -0,0 +1,269 @@
|
||||
<?php
|
||||
|
||||
interface Flexihash_Hasher
|
||||
{
|
||||
public function hash($string);
|
||||
}
|
||||
|
||||
class Flexihash_Crc32Hasher
|
||||
implements Flexihash_Hasher
|
||||
{
|
||||
|
||||
public function hash($string)
|
||||
{
|
||||
return crc32($string);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class Flexihash_Exception extends Exception
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* A simple consistent hashing implementation with pluggable hash algorithms.
|
||||
*
|
||||
* @author Paul Annesley
|
||||
* @package Flexihash
|
||||
* @licence http://www.opensource.org/licenses/mit-license.php
|
||||
*/
|
||||
class Flexihash
|
||||
{
|
||||
|
||||
/**
|
||||
* The number of positions to hash each target to.
|
||||
*
|
||||
* @var int
|
||||
*/
|
||||
private $_replicas = 64;
|
||||
|
||||
/**
|
||||
* The hash algorithm, encapsulated in a Flexihash_Hasher implementation.
|
||||
* @var object Flexihash_Hasher
|
||||
*/
|
||||
private $_hasher;
|
||||
|
||||
/**
|
||||
* Internal counter for current number of targets.
|
||||
* @var int
|
||||
*/
|
||||
private $_targetCount = 0;
|
||||
|
||||
/**
|
||||
* Internal map of positions (hash outputs) to targets
|
||||
* @var array { position => target, ... }
|
||||
*/
|
||||
private $_positionToTarget = array();
|
||||
|
||||
/**
|
||||
* Internal map of targets to lists of positions that target is hashed to.
|
||||
* @var array { target => [ position, position, ... ], ... }
|
||||
*/
|
||||
private $_targetToPositions = array();
|
||||
|
||||
/**
|
||||
* Whether the internal map of positions to targets is already sorted.
|
||||
* @var boolean
|
||||
*/
|
||||
private $_positionToTargetSorted = false;
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
* @param object $hasher Flexihash_Hasher
|
||||
* @param int $replicas Amount of positions to hash each target to.
|
||||
*/
|
||||
public function __construct(Flexihash_Hasher $hasher = null, $replicas = null)
|
||||
{
|
||||
$this->_hasher = $hasher ? $hasher : new Flexihash_Crc32Hasher();
|
||||
if (!empty($replicas)) $this->_replicas = $replicas;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a target.
|
||||
* @param string $target
|
||||
* @param float $weight
|
||||
* @chainable
|
||||
*/
|
||||
public function addTarget($target, $weight=1)
|
||||
{
|
||||
if (isset($this->_targetToPositions[$target]))
|
||||
{
|
||||
throw new Flexihash_Exception("Target '$target' already exists.");
|
||||
}
|
||||
|
||||
$this->_targetToPositions[$target] = array();
|
||||
|
||||
// hash the target into multiple positions
|
||||
for ($i = 0; $i < round($this->_replicas*$weight); $i++)
|
||||
{
|
||||
$position = $this->_hasher->hash($target . $i);
|
||||
$this->_positionToTarget[$position] = $target; // lookup
|
||||
$this->_targetToPositions[$target] []= $position; // target removal
|
||||
}
|
||||
|
||||
$this->_positionToTargetSorted = false;
|
||||
$this->_targetCount++;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a list of targets.
|
||||
* @param array $targets
|
||||
* @param float $weight
|
||||
* @chainable
|
||||
*/
|
||||
public function addTargets($targets, $weight=1)
|
||||
{
|
||||
foreach ($targets as $target)
|
||||
{
|
||||
$this->addTarget($target,$weight);
|
||||
}
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a target.
|
||||
* @param string $target
|
||||
* @chainable
|
||||
*/
|
||||
public function removeTarget($target)
|
||||
{
|
||||
if (!isset($this->_targetToPositions[$target]))
|
||||
{
|
||||
throw new Flexihash_Exception("Target '$target' does not exist.");
|
||||
}
|
||||
|
||||
foreach ($this->_targetToPositions[$target] as $position)
|
||||
{
|
||||
unset($this->_positionToTarget[$position]);
|
||||
}
|
||||
|
||||
unset($this->_targetToPositions[$target]);
|
||||
|
||||
$this->_targetCount--;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* A list of all potential targets
|
||||
* @return array
|
||||
*/
|
||||
public function getAllTargets()
|
||||
{
|
||||
return array_keys($this->_targetToPositions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up the target for the given resource.
|
||||
* @param string $resource
|
||||
* @return string
|
||||
*/
|
||||
public function lookup($resource)
|
||||
{
|
||||
$targets = $this->lookupList($resource, 1);
|
||||
if (empty($targets)) throw new Flexihash_Exception('No targets exist');
|
||||
return $targets[0];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of targets for the resource, in order of precedence.
|
||||
* Up to $requestedCount targets are returned, less if there are fewer in total.
|
||||
*
|
||||
* @param string $resource
|
||||
* @param int $requestedCount The length of the list to return
|
||||
* @return array List of targets
|
||||
*/
|
||||
public function lookupList($resource, $requestedCount)
|
||||
{
|
||||
if (!$requestedCount)
|
||||
throw new Flexihash_Exception('Invalid count requested');
|
||||
|
||||
// handle no targets
|
||||
if (empty($this->_positionToTarget))
|
||||
return array();
|
||||
|
||||
// optimize single target
|
||||
if ($this->_targetCount == 1)
|
||||
return array_unique(array_values($this->_positionToTarget));
|
||||
|
||||
// hash resource to a position
|
||||
$resourcePosition = $this->_hasher->hash($resource);
|
||||
|
||||
$results = array();
|
||||
$collect = false;
|
||||
|
||||
$this->_sortPositionTargets();
|
||||
|
||||
// search values above the resourcePosition
|
||||
foreach ($this->_positionToTarget as $key => $value)
|
||||
{
|
||||
// start collecting targets after passing resource position
|
||||
if (!$collect && $key > $resourcePosition)
|
||||
{
|
||||
$collect = true;
|
||||
}
|
||||
|
||||
// only collect the first instance of any target
|
||||
if ($collect && !in_array($value, $results))
|
||||
{
|
||||
$results []= $value;
|
||||
}
|
||||
|
||||
// return when enough results, or list exhausted
|
||||
if (count($results) == $requestedCount || count($results) == $this->_targetCount)
|
||||
{
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
||||
// loop to start - search values below the resourcePosition
|
||||
foreach ($this->_positionToTarget as $key => $value)
|
||||
{
|
||||
if (!in_array($value, $results))
|
||||
{
|
||||
$results []= $value;
|
||||
}
|
||||
|
||||
// return when enough results, or list exhausted
|
||||
if (count($results) == $requestedCount || count($results) == $this->_targetCount)
|
||||
{
|
||||
return $results;
|
||||
}
|
||||
}
|
||||
|
||||
// return results after iterating through both "parts"
|
||||
return $results;
|
||||
}
|
||||
|
||||
public function __toString()
|
||||
{
|
||||
return sprintf(
|
||||
'%s{targets:[%s]}',
|
||||
get_class($this),
|
||||
implode(',', $this->getAllTargets())
|
||||
);
|
||||
}
|
||||
|
||||
// ----------------------------------------
|
||||
// private methods
|
||||
|
||||
/**
|
||||
* Sorts the internal mapping (positions to targets) by position
|
||||
*/
|
||||
private function _sortPositionTargets()
|
||||
{
|
||||
// sort by key (position) if not already
|
||||
if (!$this->_positionToTargetSorted)
|
||||
{
|
||||
ksort($this->_positionToTarget, SORT_REGULAR);
|
||||
$this->_positionToTargetSorted = true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
16
lib/jquery-1.5.1.min.js
vendored
16
lib/jquery-1.5.1.min.js
vendored
File diff suppressed because one or more lines are too long
2
lib/jquery-1.7.1.min.js
vendored
Normal file
2
lib/jquery-1.7.1.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@ -140,9 +140,12 @@ class Layout {
|
||||
# be nice to be correct
|
||||
case "post":
|
||||
case "upload":
|
||||
if(file_exists("ext/numeric_score")){ $custom_sublinks .= "<li><b>Popular by </b><a href='".make_link('popular_by_day')."'>Day</a>/<a href='".make_link('popular_by_month')."'>Month</a>/<a href='".make_link('popular_by_year')."'>Year</a></li>";}
|
||||
$custom_sublinks .= "<li><a href='".make_link('post/list')."'>All</a></li>";
|
||||
$custom_sublinks .= "<li><a href='".make_link("post/list/favorited_by=$username/1")."'>My Favorites</a></li>";
|
||||
$custom_sublinks .= "<li><a href='".make_link("ext_doc/index")."'>Help</a></li>";
|
||||
if(file_exists("ext/random_image")){ $custom_sublinks .= "<li><a href='".make_link("random_image/view")."'>Random Image</a></li>";}
|
||||
if($hw){ $custom_sublinks .= "<li><a href='".make_link("wiki/posts")."'>Help</a></li>";
|
||||
}else{ $custom_sublinks .= "<li><a href='".make_link("ext_doc/index")."'>Help</a></li>";}
|
||||
break;
|
||||
case "comment":
|
||||
$custom_sublinks .= "<li><a href='".make_link('comment/list')."'>All</a></li>";
|
||||
|
@ -38,6 +38,14 @@ class CustomViewImageTheme extends ViewImageTheme {
|
||||
$html .= "<br>Source: <a href='$h_source'>link</a>";
|
||||
}
|
||||
|
||||
if(!is_null($image->rating) && file_exists("ext/rating")) {
|
||||
if($image->rating == null || $image->rating == "u"){
|
||||
$image->rating = "u";
|
||||
}
|
||||
$h_rating = Ratings::rating_to_human($image->rating);
|
||||
$html .= "<br>Rating: $h_rating";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@ class Layout {
|
||||
foreach($page->html_headers as $line) {
|
||||
$header_html .= "\t\t$line\n";
|
||||
}
|
||||
|
||||
|
||||
$menu = "<div class='menu'>
|
||||
<script type='text/javascript' src='$data_href/themes/$theme_name/wz_tooltip.js'></script>
|
||||
<a href='".make_link()."' onmouseover='Tip('Home', BGCOLOR, '#C3D2E0', FADEIN, 100)' onmouseout='UnTip()'><img src='$data_href/favicon.ico' style='position: relative; top: 3px;'></a>
|
||||
@ -39,6 +39,9 @@ class Layout {
|
||||
$custom_links .= $this->navlinks(make_link('post/list'), "Posts", array("post", "view"));
|
||||
$custom_links .= $this->navlinks(make_link('comment/list'), "Comments", array("comment"));
|
||||
$custom_links .= $this->navlinks(make_link('tags'), "Tags", array("tags"));
|
||||
if(class_exists("Pools")) {
|
||||
$custom_links .= $this->navlinks(make_link('pool/list'), "Pools", array("pool"));
|
||||
}
|
||||
$custom_links .= $this->navlinks(make_link('upload'), "Upload", array("upload"));
|
||||
if(class_exists("Wiki")) {
|
||||
$custom_links .= $this->navlinks(make_link('wiki/rules'), "Rules", array("wiki/rules"));
|
||||
@ -91,10 +94,13 @@ class Layout {
|
||||
# the subnav links aren't shown, but it would
|
||||
# be nice to be correct
|
||||
case "post":
|
||||
if(file_exists("ext/numeric_score")){ $cs .= "<b>Popular by </b><a href='".make_link('popular_by_day')."'>Day</a><b>/</b><a href='".make_link('popular_by_month')."'>Month</a><b>/</b><a href='".make_link('popular_by_year')."'>Year</a> ";}
|
||||
$cs .= "<a class='tab' href='".make_link('post/list')."'>All</a>";
|
||||
$cs .= "<a class='tab' href='".make_link("post/list/favorited_by=$username/1")."'>My Favorites</a>";
|
||||
$cs .= "<a class='tab' href='".make_link('rss/images')."'>Feed</a>";
|
||||
if($hw) $cs .= "<a class='tab' href='".make_link("wiki/posts")."'>Help</a>";
|
||||
if(file_exists("ext/random_image")){ $cs .= "<a class='tab' href='".make_link("random_image/view")."'>Random Image</a>";}
|
||||
if($hw){ $cs .= "<a class='tab' href='".make_link("wiki/posts")."'>Help</a>";
|
||||
}else{ $cs .= "<a class='tab' href='".make_link("ext_doc/index")."'>Help</a>";}
|
||||
break;
|
||||
case "comment":
|
||||
$cs .= "<a class='tab' href='".make_link('comment/list')."'>All</a>";
|
||||
@ -160,10 +166,12 @@ class Layout {
|
||||
<title>{$page->title}</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||
<link rel="stylesheet" href="$data_href/themes/$theme_name/style.css" type="text/css">
|
||||
|
||||
$header_html
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
$menu
|
||||
$custom_sublinks
|
||||
|
||||
|
@ -107,12 +107,20 @@ class CustomUserPageTheme extends UserPageTheme {
|
||||
<input type='hidden' name='name' value='{$duser->name}'>
|
||||
<input type='hidden' name='id' value='{$duser->id}'>
|
||||
<table style='width: 300px;'>
|
||||
<tr><td colspan='2'>Change Password</td></tr>
|
||||
<tr><th colspan='2'>Change Password</th></tr>
|
||||
<tr><td>Password</td><td><input type='password' name='pass1'></td></tr>
|
||||
<tr><td>Repeat Password</td><td><input type='password' name='pass2'></td></tr>
|
||||
<tr><td colspan='2'><input type='Submit' value='Change Password'></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
<p><form action='".make_link("user_admin/change_email")."' method='POST'>
|
||||
<input type='hidden' name='id' value='{$duser->id}'>
|
||||
<table style='width: 300px;'>
|
||||
<tr><th colspan='2'>Change Email</th></tr>
|
||||
<tr><td>Address</td><td><input type='text' name='address' value='".html_escape($duser->email)."'></td></tr>
|
||||
<tr><td colspan='2'><input type='Submit' value='Set'></td></tr>
|
||||
</table>
|
||||
</form></p>
|
||||
";
|
||||
|
||||
if($user->is_admin()) {
|
||||
|
@ -44,6 +44,14 @@ class CustomViewImageTheme extends ViewImageTheme {
|
||||
$html .= "<br>Source: <a href='$h_source'>link</a>";
|
||||
}
|
||||
|
||||
if(!is_null($image->rating) && file_exists("ext/rating")) {
|
||||
if($image->rating == null || $image->rating == "u"){
|
||||
$image->rating = "u";
|
||||
}
|
||||
$h_rating = Ratings::rating_to_human($image->rating);
|
||||
$html .= "<br>Rating: $h_rating";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user