Merge pull request #397 from jgen/develop

Manual Merge of More Linting #391
This commit is contained in:
Shish 2014-04-10 00:15:02 +01:00
commit d247713311
56 changed files with 543 additions and 700 deletions

View File

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

View File

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

View File

@ -122,7 +122,7 @@ class Image {
if(SPEED_HAX) { if(SPEED_HAX) {
if(!$user->can("big_search") and count($tags) > 3) { if(!$user->can("big_search") and count($tags) > 3) {
die("Anonymous users may only search for up to 3 tags at a time"); // FIXME: throw an exception? throw new SCoreException("Anonymous users may only search for up to 3 tags at a time");
} }
} }
@ -644,7 +644,7 @@ class Image {
* images table. Yes, MySQL does suck this much. * images table. Yes, MySQL does suck this much.
*/ */
private static function build_accurate_search_querylet($terms) { private static function build_accurate_search_querylet($terms) {
global $config, $database; global $database;
$tag_querylets = array(); $tag_querylets = array();
$img_querylets = array(); $img_querylets = array();
@ -804,7 +804,7 @@ class Image {
* build_accurate_search_querylet() for a full explanation * build_accurate_search_querylet() for a full explanation
*/ */
private static function build_ugly_search_querylet($terms) { private static function build_ugly_search_querylet($terms) {
global $config, $database; global $database;
$tag_querylets = array(); $tag_querylets = array();
$img_querylets = array(); $img_querylets = array();
@ -910,8 +910,6 @@ class Image {
// more than one positive tag, or more than zero negative tags // more than one positive tag, or more than zero negative tags
else { else {
$s_tag_array = array_map("sql_escape", $tag_search->variables);
$tag_id_array = array(); $tag_id_array = array();
$tags_ok = true; $tags_ok = true;
foreach($tag_search->variables as $tag) { foreach($tag_search->variables as $tag) {
@ -1113,7 +1111,6 @@ function move_upload_to_archive(DataUploadEvent $event) {
if(!@copy($event->tmpname, $target)) { if(!@copy($event->tmpname, $target)) {
$errors = error_get_last(); // note: requires php 5.2 $errors = error_get_last(); // note: requires php 5.2
throw new UploadException("Failed to copy file from uploads ({$event->tmpname}) to archive ($target): {$errors['type']} / {$errors['message']}"); throw new UploadException("Failed to copy file from uploads ({$event->tmpname}) to archive ($target): {$errors['type']} / {$errors['message']}");
return false;
} }
return true; return true;
} }

View File

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

View File

@ -385,7 +385,13 @@ function make_http(/*string*/ $link) {
/** /**
* Make a form tag with relevant auth token and stuff * Make a form tag with relevant auth token and stuff
* *
* @retval string * @param target string
* @param method string
* @param multipart boolean
* @param form_id string
* @param onsubmit string
*
* @return string
*/ */
function make_form($target, $method="POST", $multipart=False, $form_id="", $onsubmit="") { function make_form($target, $method="POST", $multipart=False, $form_id="", $onsubmit="") {
global $user; global $user;
@ -451,7 +457,7 @@ function captcha_get_html() {
} }
else { else {
session_start(); session_start();
$securimg = new Securimage(); //$securimg = new Securimage();
$base = get_base_href(); $base = get_base_href();
$captcha = "<br/><img src='$base/lib/securimage/securimage_show.php?sid=". md5(uniqid(time())) ."'>". $captcha = "<br/><img src='$base/lib/securimage/securimage_show.php?sid=". md5(uniqid(time())) ."'>".
"<br/>CAPTCHA: <input type='text' name='code' value='' />"; "<br/>CAPTCHA: <input type='text' name='code' value='' />";
@ -1276,6 +1282,7 @@ function _sanitise_environment() {
} }
function _get_themelet_files($_theme) { function _get_themelet_files($_theme) {
$base_themelets = array();
if(file_exists('themes/'.$_theme.'/custompage.class.php')) $base_themelets[] = 'themes/'.$_theme.'/custompage.class.php'; if(file_exists('themes/'.$_theme.'/custompage.class.php')) $base_themelets[] = 'themes/'.$_theme.'/custompage.class.php';
$base_themelets[] = 'themes/'.$_theme.'/layout.class.php'; $base_themelets[] = 'themes/'.$_theme.'/layout.class.php';
$base_themelets[] = 'themes/'.$_theme.'/themelet.class.php'; $base_themelets[] = 'themes/'.$_theme.'/themelet.class.php';
@ -1406,7 +1413,7 @@ function _decaret($str) {
} }
function _get_user() { function _get_user() {
global $config, $database; global $config;
$user = null; $user = null;
if(get_prefixed_cookie("user") && get_prefixed_cookie("session")) { if(get_prefixed_cookie("user") && get_prefixed_cookie("session")) {
$tmp_user = User::by_session(get_prefixed_cookie("user"), get_prefixed_cookie("session")); $tmp_user = User::by_session(get_prefixed_cookie("user"), get_prefixed_cookie("session"));

View File

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

View File

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

View File

@ -14,19 +14,11 @@ class ArtistsTheme extends Themelet {
"; ";
} }
public function display_artists(){
global $page;
$page->set_title("Artists");
$page->set_heading("Artists");
$page->add_block(new Block("Artists", $html, "main", 10));
//$this->display_paginator($page, "artist/list", null, $pageNumber, $totalPages);
}
public function sidebar_options(/*string*/ $mode, $artistID=NULL, $is_admin=FALSE){ public function sidebar_options(/*string*/ $mode, $artistID=NULL, $is_admin=FALSE){
global $page; global $page, $user;
$html = "";
if($mode == "neutral"){ if($mode == "neutral"){
$html = "<form method='post' action='".make_link("artist/new_artist")."'> $html = "<form method='post' action='".make_link("artist/new_artist")."'>
".$user->get_auth_html()." ".$user->get_auth_html()."
@ -72,49 +64,52 @@ class ArtistsTheme extends Themelet {
<input type='hidden' name='artist_id' value='".$artistID."'> <input type='hidden' name='artist_id' value='".$artistID."'>
</form>"; </form>";
} }
$page->add_block(new Block("Manage Artists", $html, "left", 10));
if($html) $page->add_block(new Block("Manage Artists", $html, "left", 10));
} }
public function show_artist_editor($artist, $aliases, $members, $urls) public function show_artist_editor($artist, $aliases, $members, $urls)
{ {
$artistName = $artist['name']; global $user;
$artistNotes = $artist['notes'];
$artistID = $artist['id'];
// aliases $artistName = $artist['name'];
$aliasesString = ""; $artistNotes = $artist['notes'];
$aliasesIDsString = ""; $artistID = $artist['id'];
foreach ($aliases as $alias)
{
$aliasesString .= $alias["alias_name"]." ";
$aliasesIDsString .= $alias["alias_id"]." ";
}
$aliasesString = rtrim($aliasesString);
$aliasesIDsString = rtrim($aliasesIDsString);
// members // aliases
$membersString = ""; $aliasesString = "";
$membersIDsString = ""; $aliasesIDsString = "";
foreach ($members as $member) foreach ($aliases as $alias)
{ {
$membersString .= $member["name"]." "; $aliasesString .= $alias["alias_name"]." ";
$membersIDsString .= $member["id"]." "; $aliasesIDsString .= $alias["alias_id"]." ";
} }
$membersString = rtrim($membersString); $aliasesString = rtrim($aliasesString);
$membersIDsString = rtrim($membersIDsString); $aliasesIDsString = rtrim($aliasesIDsString);
// urls // members
$urlsString = ""; $membersString = "";
$urlsIDsString = ""; $membersIDsString = "";
foreach ($urls as $url) foreach ($members as $member)
{ {
$urlsString .= $url["url"]."\n"; $membersString .= $member["name"]." ";
$urlsIDsString .= $url["id"]." "; $membersIDsString .= $member["id"]." ";
} }
$urlsString = substr($urlsString, 0, strlen($urlsString) -1); $membersString = rtrim($membersString);
$urlsIDsString = rtrim($urlsIDsString); $membersIDsString = rtrim($membersIDsString);
$html = // urls
$urlsString = "";
$urlsIDsString = "";
foreach ($urls as $url)
{
$urlsString .= $url["url"]."\n";
$urlsIDsString .= $url["id"]." ";
}
$urlsString = substr($urlsString, 0, strlen($urlsString) -1);
$urlsIDsString = rtrim($urlsIDsString);
$html =
' '
<form method="POST" action="'.make_link("artist/edited/".$artist['id']).'"> <form method="POST" action="'.make_link("artist/edited/".$artist['id']).'">
'.$user->get_auth_html().' '.$user->get_auth_html().'
@ -131,111 +126,113 @@ class ArtistsTheme extends Themelet {
<tr><td colspan="2"><input type="submit" value="Submit" /></td></tr> <tr><td colspan="2"><input type="submit" value="Submit" /></td></tr>
</table> </table>
</form> </form>
'; ';
global $page; global $page;
$page->add_block(new Block("Edit artist", $html, "main", 10)); $page->add_block(new Block("Edit artist", $html, "main", 10));
} }
public function new_artist_composer() public function new_artist_composer()
{ {
global $page; global $page, $user;
$html = "<form action=".make_link("artist/create")." method='POST'> $html = "<form action=".make_link("artist/create")." method='POST'>
".$user->get_auth_html()." ".$user->get_auth_html()."
<table> <table>
<tr><td>Name:</td><td><input type='text' name='name' /></td></tr> <tr><td>Name:</td><td><input type='text' name='name' /></td></tr>
<tr><td>Aliases:</td><td><input type='text' name='aliases' /></td></tr> <tr><td>Aliases:</td><td><input type='text' name='aliases' /></td></tr>
<tr><td>Members:</td><td><input type='text' name='members' /></td></tr> <tr><td>Members:</td><td><input type='text' name='members' /></td></tr>
<tr><td>URLs:</td><td><textarea name='urls'></textarea></td></tr> <tr><td>URLs:</td><td><textarea name='urls'></textarea></td></tr>
<tr><td>Notes:</td><td><textarea name='notes'></textarea></td></tr> <tr><td>Notes:</td><td><textarea name='notes'></textarea></td></tr>
<tr><td colspan='2'><input type='submit' value='Submit' /></td></tr> <tr><td colspan='2'><input type='submit' value='Submit' /></td></tr>
</table> </table>
"; ";
$page->set_title("Artists"); $page->set_title("Artists");
$page->set_heading("Artists"); $page->set_heading("Artists");
$page->add_block(new Block("Artists", $html, "main", 10)); $page->add_block(new Block("Artists", $html, "main", 10));
} }
public function list_artists($artists, $pageNumber, $totalPages) public function list_artists($artists, $pageNumber, $totalPages)
{ {
global $user, $page; global $user, $page;
$html = "<table id='poolsList' class='zebra'>". $html = "<table id='poolsList' class='zebra'>".
"<thead><tr>". "<thead><tr>".
"<th>Name</th>". "<th>Name</th>".
"<th>Type</th>". "<th>Type</th>".
"<th>Last updater</th>". "<th>Last updater</th>".
"<th>Posts</th>"; "<th>Posts</th>";
if(!$user->is_anonymous()) $html .= "<th colspan='2'>Action</th>"; // space for edit link if(!$user->is_anonymous()) $html .= "<th colspan='2'>Action</th>"; // space for edit link
$html .= "</tr></thead>"; $html .= "</tr></thead>";
$deletionLinkActionArray = $deletionLinkActionArray =
array('artist' => 'artist/nuke/' array('artist' => 'artist/nuke/'
, 'alias' => 'artist/alias/delete/' , 'alias' => 'artist/alias/delete/'
, 'member' => 'artist/member/delete/' , 'member' => 'artist/member/delete/'
); );
$editionLinkActionArray = $editionLinkActionArray =
array('artist' => 'artist/edit/' array('artist' => 'artist/edit/'
, 'alias' => 'artist/alias/edit/' , 'alias' => 'artist/alias/edit/'
, 'member' => 'artist/member/edit/' , 'member' => 'artist/member/edit/'
); );
$typeTextArray = $typeTextArray =
array('artist' => 'Artist' array('artist' => 'Artist'
, 'alias' => 'Alias' , 'alias' => 'Alias'
, 'member' => 'Member' , 'member' => 'Member'
); );
foreach ($artists as $artist) { foreach ($artists as $artist) {
if ($artist['type'] != 'artist') if ($artist['type'] != 'artist')
$artist['name'] = str_replace("_", " ", $artist['name']); $artist['name'] = str_replace("_", " ", $artist['name']);
$elementLink = "<a href='".make_link("artist/view/".$artist['artist_id'])."'>".str_replace("_", " ", $artist['name'])."</a>"; $elementLink = "<a href='".make_link("artist/view/".$artist['artist_id'])."'>".str_replace("_", " ", $artist['name'])."</a>";
$artist_link = "<a href='".make_link("artist/view/".$artist['artist_id'])."'>".str_replace("_", " ", $artist['artist_name'])."</a>"; //$artist_link = "<a href='".make_link("artist/view/".$artist['artist_id'])."'>".str_replace("_", " ", $artist['artist_name'])."</a>";
$user_link = "<a href='".make_link("user/".$artist['user_name'])."'>".$artist['user_name']."</a>"; $user_link = "<a href='".make_link("user/".$artist['user_name'])."'>".$artist['user_name']."</a>";
$edit_link = "<a href='".make_link($editionLinkActionArray[$artist['type']].$artist['id'])."'>Edit</a>"; $edit_link = "<a href='".make_link($editionLinkActionArray[$artist['type']].$artist['id'])."'>Edit</a>";
$del_link = "<a href='".make_link($deletionLinkActionArray[$artist['type']].$artist['id'])."'>Delete</a>"; $del_link = "<a href='".make_link($deletionLinkActionArray[$artist['type']].$artist['id'])."'>Delete</a>";
$html .= "<tr>". $html .= "<tr>".
"<td class='left'>".$elementLink; "<td class='left'>".$elementLink;
//if ($artist['type'] == 'member') //if ($artist['type'] == 'member')
// $html .= " (member of ".$artist_link.")"; // $html .= " (member of ".$artist_link.")";
//if ($artist['type'] == 'alias') //if ($artist['type'] == 'alias')
// $html .= " (alias for ".$artist_link.")"; // $html .= " (alias for ".$artist_link.")";
$html .= "</td>". $html .= "</td>".
"<td>".$typeTextArray[$artist['type']]."</td>". "<td>".$typeTextArray[$artist['type']]."</td>".
"<td>".$user_link."</td>". "<td>".$user_link."</td>".
"<td>".$artist['posts']."</td>"; "<td>".$artist['posts']."</td>";
if(!$user->is_anonymous()) $html .= "<td>".$edit_link."</td>"; if(!$user->is_anonymous()) $html .= "<td>".$edit_link."</td>";
if($user->is_admin()) $html .= "<td>".$del_link."</td>"; if($user->is_admin()) $html .= "<td>".$del_link."</td>";
$html .= "</tr>"; $html .= "</tr>";
} }
$html .= "</tbody></table>"; $html .= "</tbody></table>";
$page->set_title("Artists"); $page->set_title("Artists");
$page->set_heading("Artists"); $page->set_heading("Artists");
$page->add_block(new Block("Artists", $html, "main", 10)); $page->add_block(new Block("Artists", $html, "main", 10));
$this->display_paginator($page, "artist/list", null, $pageNumber, $totalPages); $this->display_paginator($page, "artist/list", null, $pageNumber, $totalPages);
} }
public function show_new_alias_composer($artistID) public function show_new_alias_composer($artistID)
{ {
$html = global $user;
'<form method="POST" action='.make_link("artist/alias/add").'>
$html =
'<form method="POST" action='.make_link("artist/alias/add").'>
'.$user->get_auth_html().' '.$user->get_auth_html().'
<table> <table>
<tr><td>Alias:</td><td><input type="text" name="aliases" /> <tr><td>Alias:</td><td><input type="text" name="aliases" />
@ -243,256 +240,265 @@ class ArtistsTheme extends Themelet {
<tr><td colspan="2"><input type="submit" value="Submit" /></td></tr> <tr><td colspan="2"><input type="submit" value="Submit" /></td></tr>
</table> </table>
</form> </form>
'; ';
global $page; global $page;
$page->add_block(new Block("Artist Aliases", $html, "main", 20)); $page->add_block(new Block("Artist Aliases", $html, "main", 20));
} }
public function show_new_member_composer($artistID) public function show_new_member_composer($artistID)
{ {
$html = global $user;
' <form method="POST" action='.make_link("artist/member/add").'>
$html =
' <form method="POST" action='.make_link("artist/member/add").'>
'.$user->get_auth_html().' '.$user->get_auth_html().'
<table> <table>
<tr><td>Members:</td><td><input type="text" name="members" /> <tr><td>Members:</td><td><input type="text" name="members" />
<input type="hidden" name="artistID" value='.$artistID.' /></td></tr> <input type="hidden" name="artistID" value='.$artistID.' /></td></tr>
<tr><td colspan="2"><input type="submit" value="Submit" /></td></tr> <tr><td colspan="2"><input type="submit" value="Submit" /></td></tr>
</table> </table>
</form> </form>
'; ';
global $page; global $page;
$page->add_block(new Block("Artist members", $html, "main", 30)); $page->add_block(new Block("Artist members", $html, "main", 30));
} }
public function show_new_url_composer($artistID) public function show_new_url_composer($artistID)
{ {
$html = global $user;
' <form method="POST" action='.make_link("artist/url/add").'>
$html =
' <form method="POST" action='.make_link("artist/url/add").'>
'.$user->get_auth_html().' '.$user->get_auth_html().'
<table> <table>
<tr><td>URL:</td><td><textarea name="urls"></textarea> <tr><td>URL:</td><td><textarea name="urls"></textarea>
<input type="hidden" name="artistID" value='.$artistID.' /></td></tr> <input type="hidden" name="artistID" value='.$artistID.' /></td></tr>
<tr><td colspan="2"><input type="submit" value="Submit" /></td></tr> <tr><td colspan="2"><input type="submit" value="Submit" /></td></tr>
</table> </table>
</form> </form>
'; ';
global $page; global $page;
$page->add_block(new Block("Artist URLs", $html, "main", 40)); $page->add_block(new Block("Artist URLs", $html, "main", 40));
} }
public function show_alias_editor($alias) public function show_alias_editor($alias)
{ {
$html = global $user;
'
<form method="POST" action="'.make_link("artist/alias/edited/".$alias['id']).'"> $html =
'
<form method="POST" action="'.make_link("artist/alias/edited/".$alias['id']).'">
'.$user->get_auth_html().' '.$user->get_auth_html().'
<label for="alias">Alias:</label> <label for="alias">Alias:</label>
<input type="text" name="alias" value="'.$alias['alias'].'" /> <input type="text" name="alias" value="'.$alias['alias'].'" />
<input type="hidden" name="aliasID" value="'.$alias['id'].'" /> <input type="hidden" name="aliasID" value="'.$alias['id'].'" />
<input type="submit" value="Submit" /> <input type="submit" value="Submit" />
</form> </form>
'; ';
global $page; global $page;
$page->add_block(new Block("Edit Alias", $html, "main", 10)); $page->add_block(new Block("Edit Alias", $html, "main", 10));
} }
public function show_url_editor($url) public function show_url_editor($url)
{ {
$html = global $user;
'
<form method="POST" action="'.make_link("artist/url/edited/".$url['id']).'"> $html =
'
<form method="POST" action="'.make_link("artist/url/edited/".$url['id']).'">
'.$user->get_auth_html().' '.$user->get_auth_html().'
<label for="url">URL:</label> <label for="url">URL:</label>
<input type="text" name="url" value="'.$url['url'].'" /> <input type="text" name="url" value="'.$url['url'].'" />
<input type="hidden" name="urlID" value="'.$url['id'].'" /> <input type="hidden" name="urlID" value="'.$url['id'].'" />
<input type="submit" value="Submit" /> <input type="submit" value="Submit" />
</form> </form>
'; ';
global $page; global $page;
$page->add_block(new Block("Edit URL", $html, "main", 10)); $page->add_block(new Block("Edit URL", $html, "main", 10));
} }
public function show_member_editor($member) public function show_member_editor($member)
{ {
$html = global $user;
'
<form method="POST" action="'.make_link("artist/member/edited/".$member['id']).'"> $html =
'
<form method="POST" action="'.make_link("artist/member/edited/".$member['id']).'">
'.$user->get_auth_html().' '.$user->get_auth_html().'
<label for="member">Member name:</label> <label for="member">Member name:</label>
<input type="text" name="name" value="'.$member['name'].'" /> <input type="text" name="name" value="'.$member['name'].'" />
<input type="hidden" name="memberID" value="'.$member['id'].'" /> <input type="hidden" name="memberID" value="'.$member['id'].'" />
<input type="submit" value="Submit" /> <input type="submit" value="Submit" />
</form> </form>
'; ';
global $page; global $page;
$page->add_block(new Block("Edit Member", $html, "main", 10)); $page->add_block(new Block("Edit Member", $html, "main", 10));
} }
public function show_artist($artist, $aliases, $members, $urls, $images, $userIsLogged, $userIsAdmin) public function show_artist($artist, $aliases, $members, $urls, $images, $userIsLogged, $userIsAdmin)
{ {
global $user, $event, $page; global $page;
$artist_link = "<a href='".make_link("post/list/".$artist['name']."/1")."'>".str_replace("_", " ", $artist['name'])."</a>"; $artist_link = "<a href='".make_link("post/list/".$artist['name']."/1")."'>".str_replace("_", " ", $artist['name'])."</a>";
$html = "<table id='poolsList' class='zebra'> $html = "<table id='poolsList' class='zebra'>
<thead> <thead>
<tr> <tr>
<th></th> <th></th>
<th></th>"; <th></th>";
if ($userIsLogged)
$html .= "<th></th>";
if ($userIsAdmin)
$html .= "<th></th>";
$html .= " <tr>
</thead>
<tr>
<td class='left'>Name:</td>
<td class='left'>".$artist_link."</td>";
if ($userIsLogged) $html .= "<td></td>";
if ($userIsAdmin) $html .= "<td></td>";
$html .= "</tr>";
if (count($aliases) > 0)
{
$aliasViewLink = str_replace("_", " ", $aliases[0]['alias_name']); // no link anymore
$aliasEditLink = "<a href='".make_link("artist/alias/edit/".$aliases[0]['alias_id'])."'>Edit</a>";
$aliasDeleteLink = "<a href='".make_link("artist/alias/delete/".$aliases[0]['alias_id'])."'>Delete</a>";
$html .= "<tr>
<td class='left'>Aliases:</td>
<td class='left'>".$aliasViewLink."</td>";
if ($userIsLogged)
$html .= "<td class='left'>".$aliasEditLink."</td>";
if ($userIsAdmin)
$html .= "<td class='left'>".$aliasDeleteLink."</td>";
$html .= "</tr>";
if (count($aliases) > 1)
{
for ($i = 1; $i < count($aliases); $i++)
{
$aliasViewLink = str_replace("_", " ", $aliases[$i]['alias_name']); // no link anymore
$aliasEditLink = "<a href='".make_link("artist/alias/edit/".$aliases[$i]['alias_id'])."'>Edit</a>";
$aliasDeleteLink = "<a href='".make_link("artist/alias/delete/".$aliases[$i]['alias_id'])."'>Delete</a>";
$html .= "<tr>
<td class='left'>&nbsp;</td>
<td class='left'>".$aliasViewLink."</td>";
if ($userIsLogged)
$html .= "<td class='left'>".$aliasEditLink."</td>";
if ($userIsAdmin)
$html .= "<td class='left'>".$aliasDeleteLink."</td>";
$html .= "</tr>";
}
}
}
if (count($members) > 0)
{
$memberViewLink = str_replace("_", " ", $members[0]['name']); // no link anymore
$memberEditLink = "<a href='".make_link("artist/member/edit/".$members[0]['id'])."'>Edit</a>";
$memberDeleteLink = "<a href='".make_link("artist/member/delete/".$members[0]['id'])."'>Delete</a>";
$html .= "<tr>
<td class='left'>Members:</td>
<td class='left'>".$memberViewLink."</td>";
if ($userIsLogged)
$html .= "<td class='left'>".$memberEditLink."</td>";
if ($userIsAdmin)
$html .= "<td class='left'>".$memberDeleteLink."</td>";
$html .= "</tr>";
if (count($members) > 1)
{
for ($i = 1; $i < count($members); $i++)
{
$memberViewLink = str_replace("_", " ", $members[$i]['name']); // no link anymore
$memberEditLink = "<a href='".make_link("artist/member/edit/".$members[$i]['id'])."'>Edit</a>";
$memberDeleteLink = "<a href='".make_link("artist/member/delete/".$members[$i]['id'])."'>Delete</a>";
$html .= "<tr>
<td class='left'>&nbsp;</td>
<td class='left'>".$memberViewLink."</td>";
if ($userIsLogged)
$html .= "<td class='left'>".$memberEditLink."</td>";
if ($userIsAdmin)
$html .= "<td class='left'>".$memberDeleteLink."</td>";
$html .= "</tr>";
}
}
}
if (count($urls) > 0)
{
$urlViewLink = "<a href='".str_replace("_", " ", $urls[0]['url'])."' target='_blank'>".str_replace("_", " ", $urls[0]['url'])."</a>";
$urlEditLink = "<a href='".make_link("artist/url/edit/".$urls[0]['id'])."'>Edit</a>";
$urlDeleteLink = "<a href='".make_link("artist/url/delete/".$urls[0]['id'])."'>Delete</a>";
$html .= "<tr>
<td class='left'>URLs:</td>
<td class='left'>".$urlViewLink."</td>";
if ($userIsLogged)
$html .= "<td class='left'>".$urlEditLink."</td>";
if ($userIsAdmin)
$html .= "<td class='left'>".$urlDeleteLink."</td>";
$html .= "</tr>";
if (count($urls) > 1)
{
for ($i = 1; $i < count($urls); $i++)
{
$urlViewLink = "<a href='".str_replace("_", " ", $urls[$i]['url'])."' target='_blank'>".str_replace("_", " ", $urls[$i]['url'])."</a>";
$urlEditLink = "<a href='".make_link("artist/url/edit/".$urls[$i]['id'])."'>Edit</a>";
$urlDeleteLink = "<a href='".make_link("artist/url/delete/".$urls[$i]['id'])."'>Delete</a>";
$html .= "<tr>
<td class='left'>&nbsp;</td>
<td class='left'>".$urlViewLink."</td>";
if ($userIsLogged)
$html .= "<td class='left'>".$urlEditLink."</td>";
if ($userIsAdmin)
$html .= "<td class='left'>".$urlDeleteLink."</td>";
$html .= "</tr>";
}
}
}
$html .=
"<tr>
<td class='left'>Notes:</td>
<td class='left'>".$artist["notes"]."</td>";
if ($userIsLogged) $html .= "<td></td>";
if ($userIsAdmin) $html .= "<td></td>";
//TODO how will notes be edited? On edit artist? (should there be an editartist?) or on a editnotes?
//same question for deletion
$html .= "</tr>
</table>";
$page->set_title("Artist");
$page->set_heading("Artist");
$page->add_block(new Block("Artist", $html, "main", 10));
if ($userIsLogged)
$html .= "<th></th>";
if ($userIsAdmin)
$html .= "<th></th>";
$html .= " <tr>
</thead>
<tr>
<td class='left'>Name:</td>
<td class='left'>".$artist_link."</td>";
if ($userIsLogged) $html .= "<td></td>";
if ($userIsAdmin) $html .= "<td></td>";
$html .= "</tr>";
if (count($aliases) > 0)
{
$aliasViewLink = str_replace("_", " ", $aliases[0]['alias_name']); // no link anymore
$aliasEditLink = "<a href='".make_link("artist/alias/edit/".$aliases[0]['alias_id'])."'>Edit</a>";
$aliasDeleteLink = "<a href='".make_link("artist/alias/delete/".$aliases[0]['alias_id'])."'>Delete</a>";
$html .= "<tr>
<td class='left'>Aliases:</td>
<td class='left'>".$aliasViewLink."</td>";
if ($userIsLogged)
$html .= "<td class='left'>".$aliasEditLink."</td>";
if ($userIsAdmin)
$html .= "<td class='left'>".$aliasDeleteLink."</td>";
$html .= "</tr>";
if (count($aliases) > 1)
{
for ($i = 1; $i < count($aliases); $i++)
{
$aliasViewLink = str_replace("_", " ", $aliases[$i]['alias_name']); // no link anymore
$aliasEditLink = "<a href='".make_link("artist/alias/edit/".$aliases[$i]['alias_id'])."'>Edit</a>";
$aliasDeleteLink = "<a href='".make_link("artist/alias/delete/".$aliases[$i]['alias_id'])."'>Delete</a>";
$html .= "<tr>
<td class='left'>&nbsp;</td>
<td class='left'>".$aliasViewLink."</td>";
if ($userIsLogged)
$html .= "<td class='left'>".$aliasEditLink."</td>";
if ($userIsAdmin)
$html .= "<td class='left'>".$aliasDeleteLink."</td>";
$html .= "</tr>";
}
}
}
if (count($members) > 0)
{
$memberViewLink = str_replace("_", " ", $members[0]['name']); // no link anymore
$memberEditLink = "<a href='".make_link("artist/member/edit/".$members[0]['id'])."'>Edit</a>";
$memberDeleteLink = "<a href='".make_link("artist/member/delete/".$members[0]['id'])."'>Delete</a>";
$html .= "<tr>
<td class='left'>Members:</td>
<td class='left'>".$memberViewLink."</td>";
if ($userIsLogged)
$html .= "<td class='left'>".$memberEditLink."</td>";
if ($userIsAdmin)
$html .= "<td class='left'>".$memberDeleteLink."</td>";
$html .= "</tr>";
if (count($members) > 1)
{
for ($i = 1; $i < count($members); $i++)
{
$memberViewLink = str_replace("_", " ", $members[$i]['name']); // no link anymore
$memberEditLink = "<a href='".make_link("artist/member/edit/".$members[$i]['id'])."'>Edit</a>";
$memberDeleteLink = "<a href='".make_link("artist/member/delete/".$members[$i]['id'])."'>Delete</a>";
$html .= "<tr>
<td class='left'>&nbsp;</td>
<td class='left'>".$memberViewLink."</td>";
if ($userIsLogged)
$html .= "<td class='left'>".$memberEditLink."</td>";
if ($userIsAdmin)
$html .= "<td class='left'>".$memberDeleteLink."</td>";
$html .= "</tr>";
}
}
}
if (count($urls) > 0)
{
$urlViewLink = "<a href='".str_replace("_", " ", $urls[0]['url'])."' target='_blank'>".str_replace("_", " ", $urls[0]['url'])."</a>";
$urlEditLink = "<a href='".make_link("artist/url/edit/".$urls[0]['id'])."'>Edit</a>";
$urlDeleteLink = "<a href='".make_link("artist/url/delete/".$urls[0]['id'])."'>Delete</a>";
$html .= "<tr>
<td class='left'>URLs:</td>
<td class='left'>".$urlViewLink."</td>";
if ($userIsLogged)
$html .= "<td class='left'>".$urlEditLink."</td>";
if ($userIsAdmin)
$html .= "<td class='left'>".$urlDeleteLink."</td>";
$html .= "</tr>";
if (count($urls) > 1)
{
for ($i = 1; $i < count($urls); $i++)
{
$urlViewLink = "<a href='".str_replace("_", " ", $urls[$i]['url'])."' target='_blank'>".str_replace("_", " ", $urls[$i]['url'])."</a>";
$urlEditLink = "<a href='".make_link("artist/url/edit/".$urls[$i]['id'])."'>Edit</a>";
$urlDeleteLink = "<a href='".make_link("artist/url/delete/".$urls[$i]['id'])."'>Delete</a>";
$html .= "<tr>
<td class='left'>&nbsp;</td>
<td class='left'>".$urlViewLink."</td>";
if ($userIsLogged)
$html .= "<td class='left'>".$urlEditLink."</td>";
if ($userIsAdmin)
$html .= "<td class='left'>".$urlDeleteLink."</td>";
$html .= "</tr>";
}
}
}
$html .=
"<tr>
<td class='left'>Notes:</td>
<td class='left'>".$artist["notes"]."</td>";
if ($userIsLogged) $html .= "<td></td>";
if ($userIsAdmin) $html .= "<td></td>";
//TODO how will notes be edited? On edit artist? (should there be an editartist?) or on a editnotes?
//same question for deletion
$html .= "</tr>
</table>";
$page->set_title("Artist");
$page->set_heading("Artist");
$page->add_block(new Block("Artist", $html, "main", 10));
//we show the images for the artist //we show the images for the artist
$artist_images = ""; $artist_images = "";
foreach($images as $image) { foreach($images as $image) {

View File

@ -133,7 +133,7 @@ class BlotterTheme extends Themelet {
// Reset variables: // Reset variables:
$i_open = ""; $i_open = "";
$i_close = ""; $i_close = "";
$id = $entries[$i]['id']; //$id = $entries[$i]['id'];
$messy_date = $entries[$i]['entry_date']; $messy_date = $entries[$i]['entry_date'];
$clean_date = date("m/d/y", strtotime($messy_date)); $clean_date = date("m/d/y", strtotime($messy_date));
$entry_text = $entries[$i]['entry_text']; $entry_text = $entries[$i]['entry_text'];
@ -144,8 +144,6 @@ class BlotterTheme extends Themelet {
$entries_list .= "<li>{$i_open}{$clean_date} - {$entry_text}{$i_close}</li>"; $entries_list .= "<li>{$i_open}{$clean_date} - {$entry_text}{$i_close}</li>";
} }
$out_text = "";
$in_text = "";
$pos_break = ""; $pos_break = "";
$pos_align = "text-align: right; position: absolute; right: 0px;"; $pos_align = "text-align: right; position: absolute; right: 0px;";

View File

@ -30,7 +30,7 @@ class BulkAdd extends Extension {
public function onCommand(CommandEvent $event) { public function onCommand(CommandEvent $event) {
if($event->cmd == "help") { if($event->cmd == "help") {
print " bulk-add [directory]\n"; print " bulk-add [directory]\n";
print " Import this directory\n\n"; print " Import this directory\n\n";
} }
if($event->cmd == "bulk-add") { if($event->cmd == "bulk-add") {
if(count($event->args) == 1) { if(count($event->args) == 1) {
@ -53,6 +53,7 @@ class BulkAdd extends Extension {
if(!array_key_exists('extension', $pathinfo)) { if(!array_key_exists('extension', $pathinfo)) {
throw new UploadException("File has no extension"); throw new UploadException("File has no extension");
} }
$metadata = array();
$metadata['filename'] = $pathinfo['basename']; $metadata['filename'] = $pathinfo['basename'];
$metadata['extension'] = $pathinfo['extension']; $metadata['extension'] = $pathinfo['extension'];
$metadata['tags'] = $tags; $metadata['tags'] = $tags;
@ -65,8 +66,6 @@ class BulkAdd extends Extension {
} }
private function add_dir(/*string*/ $base, $subdir="") { private function add_dir(/*string*/ $base, $subdir="") {
global $page;
if(!is_dir($base)) { if(!is_dir($base)) {
$this->theme->add_status("Error", "$base is not a directory"); $this->theme->add_status("Error", "$base is not a directory");
return; return;

View File

@ -33,7 +33,7 @@ class BulkAddCSV extends Extension {
public function onCommand(CommandEvent $event) { public function onCommand(CommandEvent $event) {
if($event->cmd == "help") { if($event->cmd == "help") {
print " bulk-add-csv [/path/to.csv]\n"; print " bulk-add-csv [/path/to.csv]\n";
print " Import this .csv file (refer to documentation)\n\n"; print " Import this .csv file (refer to documentation)\n\n";
} }
if($event->cmd == "bulk-add-csv") { if($event->cmd == "bulk-add-csv") {
global $user; global $user;
@ -62,6 +62,7 @@ class BulkAddCSV extends Extension {
if(!array_key_exists('extension', $pathinfo)) { if(!array_key_exists('extension', $pathinfo)) {
throw new UploadException("File has no extension"); throw new UploadException("File has no extension");
} }
$metadata = array();
$metadata['filename'] = $pathinfo['basename']; $metadata['filename'] = $pathinfo['basename'];
$metadata['extension'] = $pathinfo['extension']; $metadata['extension'] = $pathinfo['extension'];
$metadata['tags'] = $tags; $metadata['tags'] = $tags;
@ -82,8 +83,6 @@ class BulkAddCSV extends Extension {
} }
private function add_csv(/*string*/ $csvfile) { private function add_csv(/*string*/ $csvfile) {
global $page;
if(!file_exists($csvfile)) { if(!file_exists($csvfile)) {
$this->theme->add_status("Error", "$csvfile not found"); $this->theme->add_status("Error", "$csvfile not found");
return; return;

View File

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

View File

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

View File

@ -244,7 +244,7 @@ class CommentListTheme extends Themelet {
$hb = ($comment->owner_class == "hellbanned" ? "hb" : ""); $hb = ($comment->owner_class == "hellbanned" ? "hb" : "");
if($trim) { if($trim) {
return " $html = "
<div class=\"comment $hb\"> <div class=\"comment $hb\">
$h_userlink: $h_comment $h_userlink: $h_comment
<a href=\"".make_link("post/view/$i_image_id#c$i_comment_id")."\">&gt;&gt;&gt;</a> <a href=\"".make_link("post/view/$i_image_id#c$i_comment_id")."\">&gt;&gt;&gt;</a>
@ -263,7 +263,7 @@ class CommentListTheme extends Themelet {
$h_del = $user->can("delete_comment") ? $h_del = $user->can("delete_comment") ?
' - <a onclick="return confirm(\'Delete comment by '.$h_name.':\\n'.$stripped_nonl.'\');" '. ' - <a onclick="return confirm(\'Delete comment by '.$h_name.':\\n'.$stripped_nonl.'\');" '.
'href="'.make_link('comment/delete/'.$i_comment_id.'/'.$i_image_id).'">Del</a>' : ''; 'href="'.make_link('comment/delete/'.$i_comment_id.'/'.$i_image_id).'">Del</a>' : '';
return " $html = "
<div class=\"comment $hb\" id=\"c$i_comment_id\"> <div class=\"comment $hb\" id=\"c$i_comment_id\">
<div class=\"info\"> <div class=\"info\">
$h_avatar $h_avatar
@ -273,7 +273,7 @@ class CommentListTheme extends Themelet {
</div> </div>
"; ";
} }
return ""; return $html;
} }
protected function build_postbox(/*int*/ $image_id) { protected function build_postbox(/*int*/ $image_id) {

View File

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

View File

@ -106,9 +106,6 @@ class DanbooruApi extends Extension {
if($user->can("create_image")) if($user->can("create_image"))
{ {
$file = null;
$filename = "";
$source = "";
if(isset($_FILES['file'])) if(isset($_FILES['file']))
{ // A file was POST'd in { // A file was POST'd in
$file = $_FILES['file']['tmp_name']; $file = $_FILES['file']['tmp_name'];

View File

@ -21,6 +21,7 @@ function __extman_extcmp(ExtensionInfo $a, ExtensionInfo $b) {
class ExtensionInfo { class ExtensionInfo {
var $ext_name, $name, $link, $author, $email; var $ext_name, $name, $link, $author, $email;
var $description, $documentation, $version, $visibility; var $description, $documentation, $version, $visibility;
var $enabled;
function __construct($main) { function __construct($main) {
$matches = array(); $matches = array();
@ -131,7 +132,7 @@ class ExtManager extends Extension {
public function onCommand(CommandEvent $event) { public function onCommand(CommandEvent $event) {
if($event->cmd == "help") { if($event->cmd == "help") {
print " disable-all-ext\n"; print " disable-all-ext\n";
print " disable all extensions\n\n"; print " disable all extensions\n\n";
} }
if($event->cmd == "disable-all-ext") { if($event->cmd == "disable-all-ext") {
$this->write_config(array()); $this->write_config(array());
@ -167,6 +168,7 @@ class ExtManager extends Extension {
private function set_things($settings) { private function set_things($settings) {
$core = explode(",", CORE_EXTS); $core = explode(",", CORE_EXTS);
$extras = array();
foreach(glob("ext/*/main.php") as $main) { foreach(glob("ext/*/main.php") as $main) {
$matches = array(); $matches = array();

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,6 @@ class SVGFileHandler extends Extension {
public function onDataUpload(DataUploadEvent $event) { public function onDataUpload(DataUploadEvent $event) {
if($this->supported_ext($event->type) && $this->check_contents($event->tmpname)) { if($this->supported_ext($event->type) && $this->check_contents($event->tmpname)) {
$hash = $event->hash; $hash = $event->hash;
$ha = substr($hash, 0, 2);
if(!move_upload_to_archive($event)) return; if(!move_upload_to_archive($event)) return;
send_event(new ThumbnailGenerationEvent($event->hash, $event->type)); send_event(new ThumbnailGenerationEvent($event->hash, $event->type));
$image = $this->create_image_from_data(warehouse_path("images", $hash), $event->metadata); $image = $this->create_image_from_data(warehouse_path("images", $hash), $event->metadata);
@ -27,7 +26,6 @@ class SVGFileHandler extends Extension {
global $config; global $config;
if($this->supported_ext($event->type)) { if($this->supported_ext($event->type)) {
$hash = $event->hash; $hash = $event->hash;
$ha = substr($hash, 0, 2);
copy("ext/handle_svg/thumb.jpg", warehouse_path("thumbs", $hash)); copy("ext/handle_svg/thumb.jpg", warehouse_path("thumbs", $hash));
} }

View File

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

View File

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

View File

@ -22,7 +22,6 @@ class ImageBanTheme extends Themelet {
*/ */
public function display_image_hash_bans(Page $page, $page_number, $page_count, $bans) { public function display_image_hash_bans(Page $page, $page_number, $page_count, $bans) {
$h_bans = ""; $h_bans = "";
$n = 0;
foreach($bans as $ban) { foreach($bans as $ban) {
$h_bans .= " $h_bans .= "
<tr> <tr>

View File

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

View File

@ -14,7 +14,6 @@ class IPBanTheme extends Themelet {
public function display_bans(Page $page, $bans) { public function display_bans(Page $page, $bans) {
global $database, $user; global $database, $user;
$h_bans = ""; $h_bans = "";
$n = 0;
$prefix = ($database->get_driver_name() == "sqlite" ? "bans." : ""); $prefix = ($database->get_driver_name() == "sqlite" ? "bans." : "");
$prefix2 = ($database->get_driver_name() == "sqlite" ? "users." : ""); $prefix2 = ($database->get_driver_name() == "sqlite" ? "users." : "");
foreach($bans as $ban) { foreach($bans as $ban) {

View File

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

View File

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

View File

@ -40,7 +40,6 @@ class LogDatabaseTheme extends Themelet {
</form> </form>
</thead> </thead>
<tbody>\n"; <tbody>\n";
$n = 0;
reset($events); // rewind to first element in array. reset($events); // rewind to first element in array.
foreach($events as $event) { foreach($events as $event) {

View File

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

View File

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

View File

@ -2,7 +2,6 @@
class NotATagTheme extends Themelet { class NotATagTheme extends Themelet {
public function display_untags(Page $page, $page_number, $page_count, $bans) { public function display_untags(Page $page, $page_number, $page_count, $bans) {
$h_bans = ""; $h_bans = "";
$n = 0;
foreach($bans as $ban) { foreach($bans as $ban) {
$h_bans .= " $h_bans .= "
<tr> <tr>

View File

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

View File

@ -1,6 +1,6 @@
<?php <?php
class NotesTheme extends Themelet { class NotesTheme extends Themelet {
public function note_button($image_id) { public function note_button($image_id) {
return ' return '
<!-- <a href="#" id="addnotelink" >Add a note</a> --> <!-- <a href="#" id="addnotelink" >Add a note</a> -->
<form action="" method=""> <form action="" method="">
@ -39,32 +39,32 @@ class NotesTheme extends Themelet {
$page->set_title(html_escape("Search Note")); $page->set_title(html_escape("Search Note"));
$page->set_heading(html_escape("Search Note")); $page->set_heading(html_escape("Search Note"));
$page->add_block(new Block("Search Note", $html, "main", 10)); $page->add_block(new Block("Search Note", $html, "main", 10));
} }
// check action POST on form // check action POST on form
public function display_note_system(Page $page, $image_id, $recovered_notes, $adminOptions) public function display_note_system(Page $page, $image_id, $recovered_notes, $adminOptions)
{ {
$to_json = array(); $to_json = array();
foreach($recovered_notes as $note) foreach($recovered_notes as $note)
{ {
$parsedNote = $note["note"]; $parsedNote = $note["note"];
$parsedNote = str_replace("\n", "\\n", $parsedNote); $parsedNote = str_replace("\n", "\\n", $parsedNote);
$parsedNote = str_replace("\r", "\\r", $parsedNote); $parsedNote = str_replace("\r", "\\r", $parsedNote);
$to_json[] = array( $to_json[] = array(
'x1' => $note["x1"], 'x1' => $note["x1"],
'y1' => $note["y1"], 'y1' => $note["y1"],
'height' => $note["height"], 'height' => $note["height"],
'width' => $note["width"], 'width' => $note["width"],
'note' => $parsedNote, 'note' => $parsedNote,
'note_id' => $note["id"], 'note_id' => $note["id"],
); );
} }
$html = "<script type='text/javascript'>"; $html = "<script type='text/javascript'>";
$html .= "notes = " . json_encode($to_json); $html .= "notes = " . json_encode($to_json);
$html .= "</script> $html .= "</script>
<div id='noteform'> <div id='noteform'>
".make_form(make_link("note/add_note"))." ".make_form(make_link("note/add_note"))."
@ -88,41 +88,41 @@ class NotesTheme extends Themelet {
</form> </form>
</div> </div>
<div id='noteEditForm'> <div id='noteEditForm'>
".make_form(make_link("note/edit_note"))." ".make_form(make_link("note/edit_note"))."
<input type='hidden' name='image_id' value='".$image_id."' /> <input type='hidden' name='image_id' value='".$image_id."' />
<input type='hidden' name='note_id' id='EditNoteID' value='' /> <input type='hidden' name='note_id' id='EditNoteID' value='' />
<input name='note_x1' type='hidden' value='' id='EditNoteX1' /> <input name='note_x1' type='hidden' value='' id='EditNoteX1' />
<input name='note_y1' type='hidden' value='' id='EditNoteY1' /> <input name='note_y1' type='hidden' value='' id='EditNoteY1' />
<input name='note_height' type='hidden' value='' id='EditNoteHeight' /> <input name='note_height' type='hidden' value='' id='EditNoteHeight' />
<input name='note_width' type='hidden' value='' id='EditNoteWidth' /> <input name='note_width' type='hidden' value='' id='EditNoteWidth' />
<table> <table>
<tr> <tr>
<td colspan='2'> <td colspan='2'>
<textarea name='note_text' id='EditNoteNote' ></textarea> <textarea name='note_text' id='EditNoteNote' ></textarea>
</td> </td>
</tr> </tr>
<tr> <tr>
<td><input type='submit' value='Save Note' /></td> <td><input type='submit' value='Save Note' /></td>
<td><input type='button' value='Cancel' id='EditCancelNote' /></td> <td><input type='button' value='Cancel' id='EditCancelNote' /></td>
</tr> </tr>
</table> </table>
</form>"; </form>";
if($adminOptions) if($adminOptions)
$html .= " $html .= "
".make_form(make_link("note/delete_note"))." ".make_form(make_link("note/delete_note"))."
<input type='hidden' name='image_id' value='".$image_id."' /> <input type='hidden' name='image_id' value='".$image_id."' />
<input type='hidden' name='note_id' value='' id='DeleteNoteNoteID' /> <input type='hidden' name='note_id' value='' id='DeleteNoteNoteID' />
<table> <table>
<tr> <tr>
<td><input type='submit' value='Delete note' /></td> <td><input type='submit' value='Delete note' /></td>
</tr> </tr>
</table> </table>
</form> </form>
"; ";
$html .= "</div>"; $html .= "</div>";
$page->add_block(new Block(null, $html, "main", 1)); $page->add_block(new Block(null, $html, "main", 1));
} }
@ -169,101 +169,71 @@ class NotesTheme extends Themelet {
$page->set_heading("Note Requests"); $page->set_heading("Note Requests");
$page->add_block(new Block("Note Requests", $pool_images, "main", 20)); $page->add_block(new Block("Note Requests", $pool_images, "main", 20));
} }
public function display_histories($histories, $pageNumber, $totalPages) { private function get_history($histories) {
global $user, $page; global $user;
$html = "<table id='poolsList' class='zebra'>". $html = "<table id='poolsList' class='zebra'>".
"<thead><tr>". "<thead><tr>".
"<th>Image</th>". "<th>Image</th>".
"<th>Note</th>". "<th>Note</th>".
"<th>Body</th>". "<th>Body</th>".
"<th>Updater</th>". "<th>Updater</th>".
"<th>Date</th>"; "<th>Date</th>";
if(!$user->is_anonymous()){ if(!$user->is_anonymous()){
$html .= "<th>Action</th>"; $html .= "<th>Action</th>";
} }
$html .= "</tr></thead>". $html .= "</tr></thead>".
"<tbody>"; "<tbody>";
$n = 0;
foreach($histories as $history) { foreach($histories as $history) {
$image_link = "<a href='".make_link("post/view/".$history['image_id'])."'>".$history['image_id']."</a>"; $image_link = "<a href='".make_link("post/view/".$history['image_id'])."'>".$history['image_id']."</a>";
$history_link = "<a href='".make_link("note/history/".$history['note_id'])."'>".$history['note_id'].".".$history['review_id']."</a>"; $history_link = "<a href='".make_link("note/history/".$history['note_id'])."'>".$history['note_id'].".".$history['review_id']."</a>";
$user_link = "<a href='".make_link("user/".$history['user_name'])."'>".$history['user_name']."</a>"; $user_link = "<a href='".make_link("user/".$history['user_name'])."'>".$history['user_name']."</a>";
$revert_link = "<a href='".make_link("note/revert/".$history['note_id']."/".$history['review_id'])."'>Revert</a>"; $revert_link = "<a href='".make_link("note/revert/".$history['note_id']."/".$history['review_id'])."'>Revert</a>";
$html .= "<tr>". $html .= "<tr>".
"<td>".$image_link."</td>". "<td>".$image_link."</td>".
"<td>".$history_link."</td>". "<td>".$history_link."</td>".
"<td style='text-align:left;'>".$history['note']."</td>". "<td style='text-align:left;'>".$history['note']."</td>".
"<td>".$user_link."</td>". "<td>".$user_link."</td>".
"<td>".autodate($history['date'])."</td>"; "<td>".autodate($history['date'])."</td>";
if(!$user->is_anonymous()){ if(!$user->is_anonymous()){
$html .= "<td>".$revert_link."</td>"; $html .= "<td>".$revert_link."</td>";
} }
} }
$html .= "</tr></tbody></table>"; $html .= "</tr></tbody></table>";
return $html;
}
public function display_histories($histories, $pageNumber, $totalPages) {
global $page;
$html = $this->get_history($histories);
$page->set_title("Note Updates"); $page->set_title("Note Updates");
$page->set_heading("Note Updates"); $page->set_heading("Note Updates");
$page->add_block(new Block("Note Updates", $html, "main", 10)); $page->add_block(new Block("Note Updates", $html, "main", 10));
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages); $this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
} }
public function display_history($histories, $pageNumber, $totalPages) { public function display_history($histories, $pageNumber, $totalPages) {
global $user, $page; global $page;
$html = "<table id='poolsList' class='zebra'>". $html = $this->get_history($histories);
"<thead><tr>".
"<th>Image</th>".
"<th>Note</th>".
"<th>Body</th>".
"<th>Updater</th>".
"<th>Date</th>";
if(!$user->is_anonymous()){
$html .= "<th>Action</th>";
}
$html .= "</tr></thead>".
"<tbody>";
$n = 0;
foreach($histories as $history) {
$image_link = "<a href='".make_link("post/view/".$history['image_id'])."'>".$history['image_id']."</a>";
$history_link = "<a href='".make_link("note/history/".$history['note_id'])."'>".$history['note_id'].".".$history['review_id']."</a>";
$user_link = "<a href='".make_link("user/".$history['user_name'])."'>".$history['user_name']."</a>";
$revert_link = "<a href='".make_link("note/revert/".$history['note_id']."/".$history['review_id'])."'>Revert</a>";
$html .= "<tr>".
"<td>".$image_link."</td>".
"<td>".$history_link."</td>".
"<td style='text-align:left;'>".$history['note']."</td>".
"<td>".$user_link."</td>".
"<td>".autodate($history['date'])."</td>";
if(!$user->is_anonymous()){
$html .= "<td>".$revert_link."</td>";
}
}
$html .= "</tr></tbody></table>";
$page->set_title("Note History"); $page->set_title("Note History");
$page->set_heading("Note History"); $page->set_heading("Note History");
$page->add_block(new Block("Note History", $html, "main", 10)); $page->add_block(new Block("Note History", $html, "main", 10));
$this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages); $this->display_paginator($page, "note/updated", null, $pageNumber, $totalPages);
} }
} }
?> ?>

View File

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

View File

@ -9,7 +9,6 @@ class OekakiTheme extends Themelet {
global $config, $page; global $config, $page;
$base_href = get_base_href(); $base_href = get_base_href();
$http_base = make_http($base_href);
$oekW = $config->get_int("oekaki_width", 400); $oekW = $config->get_int("oekaki_width", 400);
$oekH = $config->get_int("oekaki_height", 400); $oekH = $config->get_int("oekaki_height", 400);

View File

@ -8,7 +8,6 @@ class PrivMsgTheme extends Themelet {
<table id='pms' class='zebra sortable'> <table id='pms' class='zebra sortable'>
<thead><tr><th>R?</th><th>Subject</th><th>From</th><th>Date</th><th>Action</th></tr></thead> <thead><tr><th>R?</th><th>Subject</th><th>From</th><th>Date</th><th>Action</th></tr></thead>
<tbody>"; <tbody>";
$n = 0;
foreach($pms as $pm) { foreach($pms as $pm) {
$h_subject = html_escape($pm->subject); $h_subject = html_escape($pm->subject);
if(strlen(trim($h_subject)) == 0) $h_subject = "(No subject)"; if(strlen(trim($h_subject)) == 0) $h_subject = "(No subject)";

View File

@ -12,7 +12,6 @@ class PoolsTheme extends Themelet {
} }
public function get_adder_html(Image $image, /*array*/ $pools) { public function get_adder_html(Image $image, /*array*/ $pools) {
$editor = "";
$h = ""; $h = "";
foreach($pools as $pool) { foreach($pools as $pool) {
$h .= "<option value='".$pool['id']."'>".html_escape($pool['title'])."</option>"; $h .= "<option value='".$pool['id']."'>".html_escape($pool['title'])."</option>";
@ -43,8 +42,6 @@ class PoolsTheme extends Themelet {
<th>Public</th> <th>Public</th>
</tr></thead><tbody>'; </tr></thead><tbody>';
$n = 0;
// Build up the list of pools. // Build up the list of pools.
foreach($pools as $pool) { foreach($pools as $pool) {
$pool_link = '<a href="'.make_link("pool/view/".$pool['id']).'">'.html_escape($pool['title'])."</a>"; $pool_link = '<a href="'.make_link("pool/view/".$pool['id']).'">'.html_escape($pool['title'])."</a>";
@ -133,7 +130,6 @@ class PoolsTheme extends Themelet {
<th class="left">Description</th> <th class="left">Description</th>
</tr></thead><tbody>'; </tr></thead><tbody>';
$n = 0;
foreach($pools as $pool) { foreach($pools as $pool) {
$pool_info .= "<tr>". $pool_info .= "<tr>".
"<td class='left'>".html_escape($pool['title'])."</td>". "<td class='left'>".html_escape($pool['title'])."</td>".
@ -303,15 +299,15 @@ class PoolsTheme extends Themelet {
$this->display_top($pools, "Sorting Pool"); $this->display_top($pools, "Sorting Pool");
$pool_images = "\n<form action='".make_link("pool/order")."' method='POST' name='checks'>"; $pool_images = "\n<form action='".make_link("pool/order")."' method='POST' name='checks'>";
$n = 0; $i = 0;
foreach($images as $pair) { foreach($images as $pair) {
$image = $pair[0]; $image = $pair[0];
$thumb_html = $this->build_thumb_html($image); $thumb_html = $this->build_thumb_html($image);
$pool_images .= '<span class="thumb">'."\n".$thumb_html."\n". $pool_images .= '<span class="thumb">'."\n".$thumb_html."\n".
'<br><input name="imgs['.$n.'][]" type="text" style="max-width:50px;" value="'.$image->image_order.'" />'. '<br><input name="imgs['.$i.'][]" type="text" style="max-width:50px;" value="'.$image->image_order.'" />'.
'<input name="imgs['.$n.'][]" type="hidden" value="'.$image->id.'" />'. '<input name="imgs['.$i.'][]" type="hidden" value="'.$image->id.'" />'.
'</span>'; '</span>';
$n++; $i++;
} }
$pool_images .= "<br>". $pool_images .= "<br>".
@ -382,7 +378,6 @@ class PoolsTheme extends Themelet {
<th>Action</th> <th>Action</th>
</tr></thead><tbody>'; </tr></thead><tbody>';
$n = 0;
foreach($histories as $history) { foreach($histories as $history) {
$pool_link = "<a href='".make_link("pool/view/".$history['pool_id'])."'>".html_escape($history['title'])."</a>"; $pool_link = "<a href='".make_link("pool/view/".$history['pool_id'])."'>".html_escape($history['title'])."</a>";
$user_link = "<a href='".make_link("user/".url_escape($history['user_name']))."'>".html_escape($history['user_name'])."</a>"; $user_link = "<a href='".make_link("user/".url_escape($history['user_name']))."'>".html_escape($history['user_name'])."</a>";

View File

@ -2,7 +2,6 @@
class RatingsTheme extends Themelet { class RatingsTheme extends Themelet {
public function get_rater_html(/*int*/ $image_id, /*string*/ $rating) { public function get_rater_html(/*int*/ $image_id, /*string*/ $rating) {
$i_image_id = int_escape($image_id);
$s_checked = $rating == 's' ? " checked" : ""; $s_checked = $rating == 's' ? " checked" : "";
$q_checked = $rating == 'q' ? " checked" : ""; $q_checked = $rating == 'q' ? " checked" : "";
$e_checked = $rating == 'e' ? " checked" : ""; $e_checked = $rating == 'e' ? " checked" : "";

View File

@ -15,7 +15,6 @@ class ReportImageTheme extends Themelet {
global $config; global $config;
$h_reportedimages = ""; $h_reportedimages = "";
$n = 0;
foreach($reports as $report) { foreach($reports as $report) {
$image = $report['image']; $image = $report['image'];
$h_reason = format_text($report['reason']); $h_reason = format_text($report['reason']);

View File

@ -7,7 +7,6 @@ class ResizeImageTheme extends Themelet {
public function get_resize_html(Image $image) { public function get_resize_html(Image $image) {
global $user, $config; global $user, $config;
$i_image_id = int_escape($image->id);
$default_width = $config->get_int('resize_default_width'); $default_width = $config->get_int('resize_default_width');
$default_height = $config->get_int('resize_default_height'); $default_height = $config->get_int('resize_default_height');

View File

@ -7,8 +7,6 @@ class RotateImageTheme extends Themelet {
public function get_rotate_html(/*int*/ $image_id) { public function get_rotate_html(/*int*/ $image_id) {
global $user, $config; global $user, $config;
$i_image_id = int_escape($image_id);
$html = " $html = "
".make_form(make_link('rotate/'.$image_id), 'POST')." ".make_form(make_link('rotate/'.$image_id), 'POST')."
<input type='hidden' name='image_id' value='$image_id'> <input type='hidden' name='image_id' value='$image_id'>

View File

@ -23,7 +23,6 @@ class SetupTheme extends Themelet {
*/ */
$setupblock_html = ""; $setupblock_html = "";
foreach($panel->blocks as $block) { foreach($panel->blocks as $block) {
$html = $this->sb_to_html($block);
$setupblock_html .= $this->sb_to_html($block); $setupblock_html .= $this->sb_to_html($block);
} }
@ -44,12 +43,10 @@ class SetupTheme extends Themelet {
global $user; global $user;
$h_rows = ""; $h_rows = "";
$n = 0;
ksort($options); ksort($options);
foreach($options as $name => $value) { foreach($options as $name => $value) {
$h_name = html_escape($name); $h_name = html_escape($name);
$h_value = html_escape($value); $h_value = html_escape($value);
$len = strlen($h_value);
$h_box = ""; $h_box = "";
if(strpos($value, "\n") > 0) { if(strpos($value, "\n") > 0) {

View File

@ -63,7 +63,7 @@ class XMLSitemap extends Extension {
{ {
global $database, $config; global $database, $config;
// add index // add index
$index[0] = $base_href = $config->get_string("front_page"); $index[0] = $config->get_string("front_page");
$this->add_sitemap_queue($index, "weekly", "1"); $this->add_sitemap_queue($index, "weekly", "1");
/* --- Add 20 most used tags --- */ /* --- Add 20 most used tags --- */
@ -162,4 +162,4 @@ class XMLSitemap extends Extension {
$page->set_data($xml); $page->set_data($xml);
} }
} }
?> ?>

View File

@ -351,7 +351,7 @@ class Source_History extends Extension {
} }
// add a history entry // add a history entry
$row = $database->execute(" $database->execute("
INSERT INTO source_histories(image_id, source, user_id, user_ip, date_set) INSERT INTO source_histories(image_id, source, user_id, user_ip, date_set)
VALUES (?, ?, ?, ?, now())", VALUES (?, ?, ?, ?, now())",
array($image->id, $new_source, $user->id, $_SERVER['REMOTE_ADDR'])); array($image->id, $new_source, $user->id, $_SERVER['REMOTE_ADDR']));

View File

@ -80,7 +80,6 @@ class TaggerXML extends Extension {
$q_where = "WHERE {$match} {$hidden} AND count > 0"; $q_where = "WHERE {$match} {$hidden} AND count > 0";
// FROM based on return count // FROM based on return count
$q_from = null;
$count = $this->count($q_where,$values); $count = $this->count($q_where,$values);
if ($count > $max_rows) { if ($count > $max_rows) {
$q_from = "FROM (SELECT * FROM `tags` {$q_where} ". $q_from = "FROM (SELECT * FROM `tags` {$q_where} ".
@ -139,25 +138,5 @@ class TaggerXML extends Extension {
return $database->Execute( return $database->Execute(
"SELECT COUNT(*) FROM `tags` $query",$values)->fields['COUNT(*)']; "SELECT COUNT(*) FROM `tags` $query",$values)->fields['COUNT(*)'];
} }
private function image_tags ($image_id) {
global $database;
$list = "(";
$i_tags = $database->Execute(
"SELECT tag_id FROM `image_tags` WHERE image_id=?",
array($image_id));
$b = false;
foreach($i_tags as $tag) {
if($b)
$list .= ",";
$b = true;
$list .= $tag['tag_id'];
}
$list .= ")";
return $list;
}
} }
?> ?>

View File

@ -65,7 +65,6 @@ class TipsTheme extends Themelet {
$html .= "</tr></thead>"; $html .= "</tr></thead>";
$n = 0;
foreach ($tips as $tip) { foreach ($tips as $tip) {
$tip_enable = ($tip['enable'] == "Y") ? "Yes" : "No"; $tip_enable = ($tip['enable'] == "Y") ? "Yes" : "No";
$set_link = "<a href='".make_link("tips/status/".$tip['id'])."'>".$tip_enable."</a>"; $set_link = "<a href='".make_link("tips/status/".$tip['id'])."'>".$tip_enable."</a>";

View File

@ -39,7 +39,6 @@ class WikiTheme extends Themelet {
protected function create_edit_html(WikiPage $page) { protected function create_edit_html(WikiPage $page) {
$h_title = html_escape($page->title); $h_title = html_escape($page->title);
$u_title = url_escape($page->title);
$i_revision = int_escape($page->revision) + 1; $i_revision = int_escape($page->revision) + 1;
global $user; global $user;

View File

@ -21,7 +21,6 @@ class Themelet extends BaseThemelet {
private function build_paginator($current_page, $total_pages, $base_url, $query) { private function build_paginator($current_page, $total_pages, $base_url, $query) {
$next = $current_page + 1; $next = $current_page + 1;
$prev = $current_page - 1; $prev = $current_page - 1;
$rand = mt_rand(1, $total_pages);
$at_start = ($current_page <= 3 || $total_pages <= 3); $at_start = ($current_page <= 3 || $total_pages <= 3);
$at_end = ($current_page >= $total_pages -2); $at_end = ($current_page >= $total_pages -2);

View File

@ -35,7 +35,6 @@ class CustomUserPageTheme extends UserPageTheme {
} }
public function display_user_block(Page $page, User $user, $parts) { public function display_user_block(Page $page, User $user, $parts) {
$h_name = html_escape($user->name);
$html = ""; $html = "";
$blocked = array("Pools", "Pool Changes", "Alias Editor", "My Profile"); $blocked = array("Pools", "Pool Changes", "Alias Editor", "My Profile");
foreach($parts as $part) { foreach($parts as $part) {

View File

@ -21,7 +21,6 @@ class Themelet extends BaseThemelet {
private function build_paginator($current_page, $total_pages, $base_url, $query) { private function build_paginator($current_page, $total_pages, $base_url, $query) {
$next = $current_page + 1; $next = $current_page + 1;
$prev = $current_page - 1; $prev = $current_page - 1;
$rand = mt_rand(1, $total_pages);
$at_start = ($current_page <= 3 || $total_pages <= 3); $at_start = ($current_page <= 3 || $total_pages <= 3);
$at_end = ($current_page >= $total_pages -2); $at_end = ($current_page >= $total_pages -2);

View File

@ -35,7 +35,6 @@ class CustomUserPageTheme extends UserPageTheme {
} }
public function display_user_block(Page $page, User $user, $parts) { public function display_user_block(Page $page, User $user, $parts) {
$h_name = html_escape($user->name);
$html = ""; $html = "";
$blocked = array("Pools", "Pool Changes", "Alias Editor", "My Profile"); $blocked = array("Pools", "Pool Changes", "Alias Editor", "My Profile");
foreach($parts as $part) { foreach($parts as $part) {