dos2unix
This commit is contained in:
parent
7c946db89f
commit
e0584f6e3e
@ -1,43 +1,43 @@
|
||||
<?php
|
||||
|
||||
class FavoritesTheme extends Themelet {
|
||||
public function get_voter_html(Image $image, $is_favorited) {
|
||||
global $page, $user;
|
||||
|
||||
$i_image_id = int_escape($image->id);
|
||||
if(!$is_favorited) {
|
||||
$html = "<form action='".make_link("change_favorite")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id'>
|
||||
<input type='hidden' name='favorite_action' value='set'>
|
||||
<input type='submit' value='Favorite'>
|
||||
</form>
|
||||
";
|
||||
}
|
||||
else {
|
||||
$html = "<form action='".make_link("change_favorite")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id'>
|
||||
<input type='hidden' name='favorite_action' value='unset'>
|
||||
<input type='submit' value='Un-Favorite'>
|
||||
</form>
|
||||
";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function display_people($username_array) {
|
||||
global $page;
|
||||
|
||||
$i_favorites = count($username_array);
|
||||
$html = "$i_favorites people:";
|
||||
|
||||
foreach($username_array as $row) {
|
||||
$username = html_escape($row['name']);
|
||||
$html .= "<br><a href='".make_link("user/$username")."'>$username</a>";
|
||||
}
|
||||
|
||||
$page->add_block(new Block("Favorited By", $html, "left", 25));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<?php
|
||||
|
||||
class FavoritesTheme extends Themelet {
|
||||
public function get_voter_html(Image $image, $is_favorited) {
|
||||
global $page, $user;
|
||||
|
||||
$i_image_id = int_escape($image->id);
|
||||
if(!$is_favorited) {
|
||||
$html = "<form action='".make_link("change_favorite")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id'>
|
||||
<input type='hidden' name='favorite_action' value='set'>
|
||||
<input type='submit' value='Favorite'>
|
||||
</form>
|
||||
";
|
||||
}
|
||||
else {
|
||||
$html = "<form action='".make_link("change_favorite")."' method='POST'>
|
||||
<input type='hidden' name='image_id' value='$i_image_id'>
|
||||
<input type='hidden' name='favorite_action' value='unset'>
|
||||
<input type='submit' value='Un-Favorite'>
|
||||
</form>
|
||||
";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function display_people($username_array) {
|
||||
global $page;
|
||||
|
||||
$i_favorites = count($username_array);
|
||||
$html = "$i_favorites people:";
|
||||
|
||||
foreach($username_array as $row) {
|
||||
$username = html_escape($row['name']);
|
||||
$html .= "<br><a href='".make_link("user/$username")."'>$username</a>";
|
||||
}
|
||||
|
||||
$page->add_block(new Block("Favorited By", $html, "left", 25));
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -1,54 +1,54 @@
|
||||
<?php
|
||||
/*
|
||||
* Name: XML Sitemap
|
||||
* Author: Sein Kraft <mail@seinkraft.info>
|
||||
* License: GPLv2
|
||||
* Description: Adds sitemap.xml on request.
|
||||
* Documentation:
|
||||
*/
|
||||
|
||||
class XMLSitemap extends SimpleExtension {
|
||||
public function onPageRequest($event) {
|
||||
if($event->page_matches("sitemap.xml")) {
|
||||
$images = Image::find_images(0, 50, array());
|
||||
$this->do_xml($images);
|
||||
}
|
||||
}
|
||||
|
||||
private function do_xml($images) {
|
||||
global $page;
|
||||
$page->set_mode("data");
|
||||
$page->set_type("application/xml");
|
||||
|
||||
$data = "";
|
||||
foreach($images as $image) {
|
||||
$link = make_http(make_link("post/view/{$image->id}"));
|
||||
$posted = date("Y-m-d", $image->posted_timestamp);
|
||||
|
||||
$data .= "
|
||||
<url>
|
||||
<loc>$link</loc>
|
||||
<lastmod>$posted</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>0.8</priority>
|
||||
</url>
|
||||
";
|
||||
}
|
||||
|
||||
$base_href = make_http(make_link("post/list"));
|
||||
|
||||
$xml = "<"."?xml version=\"1.0\" encoding=\"utf-8\"?".">
|
||||
<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">
|
||||
<url>
|
||||
<loc>$base_href</loc>
|
||||
<lastmod>2009-01-01</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>1</priority>
|
||||
</url>
|
||||
$data
|
||||
</urlset>
|
||||
";
|
||||
$page->set_data($xml);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/*
|
||||
* Name: XML Sitemap
|
||||
* Author: Sein Kraft <mail@seinkraft.info>
|
||||
* License: GPLv2
|
||||
* Description: Adds sitemap.xml on request.
|
||||
* Documentation:
|
||||
*/
|
||||
|
||||
class XMLSitemap extends SimpleExtension {
|
||||
public function onPageRequest($event) {
|
||||
if($event->page_matches("sitemap.xml")) {
|
||||
$images = Image::find_images(0, 50, array());
|
||||
$this->do_xml($images);
|
||||
}
|
||||
}
|
||||
|
||||
private function do_xml($images) {
|
||||
global $page;
|
||||
$page->set_mode("data");
|
||||
$page->set_type("application/xml");
|
||||
|
||||
$data = "";
|
||||
foreach($images as $image) {
|
||||
$link = make_http(make_link("post/view/{$image->id}"));
|
||||
$posted = date("Y-m-d", $image->posted_timestamp);
|
||||
|
||||
$data .= "
|
||||
<url>
|
||||
<loc>$link</loc>
|
||||
<lastmod>$posted</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>0.8</priority>
|
||||
</url>
|
||||
";
|
||||
}
|
||||
|
||||
$base_href = make_http(make_link("post/list"));
|
||||
|
||||
$xml = "<"."?xml version=\"1.0\" encoding=\"utf-8\"?".">
|
||||
<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">
|
||||
<url>
|
||||
<loc>$base_href</loc>
|
||||
<lastmod>2009-01-01</lastmod>
|
||||
<changefreq>monthly</changefreq>
|
||||
<priority>1</priority>
|
||||
</url>
|
||||
$data
|
||||
</urlset>
|
||||
";
|
||||
$page->set_data($xml);
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,219 +1,219 @@
|
||||
<?php
|
||||
/*
|
||||
* Name: Tag History
|
||||
* Author: Bzchan <bzchan@animemahou.com>
|
||||
* Description: Keep a record of tag changes
|
||||
*/
|
||||
|
||||
class Tag_History implements Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
global $config, $database, $page, $user;
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if(($event instanceof InitExtEvent)) {
|
||||
$config->set_default_int("history_limit", -1);
|
||||
|
||||
// shimmie is being installed so call install to create the table.
|
||||
if($config->get_int("ext_tag_history_version") < 3) {
|
||||
$this->install();
|
||||
}
|
||||
}
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("tag_history"))
|
||||
{
|
||||
if($event->get_arg(0) == "revert")
|
||||
{
|
||||
// this is a request to revert to a previous version of the tags
|
||||
if($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
|
||||
$this->process_revert_request($_POST['revert']);
|
||||
}
|
||||
}
|
||||
else if($event->count_args() == 1)
|
||||
{
|
||||
// must be an attempt to view a tag history
|
||||
$image_id = int_escape($event->get_arg(0));
|
||||
$this->theme->display_history_page($page, $image_id, $this->get_tag_history_from_id($image_id));
|
||||
}
|
||||
else {
|
||||
$this->theme->display_global_page($page, $this->get_global_tag_history());
|
||||
}
|
||||
}
|
||||
if(($event instanceof DisplayingImageEvent))
|
||||
{
|
||||
// handle displaying a link on the view page
|
||||
$this->theme->display_history_link($page, $event->image->id);
|
||||
}
|
||||
if(($event instanceof ImageDeletionEvent))
|
||||
{
|
||||
// handle removing of history when an image is deleted
|
||||
$this->delete_all_tag_history($event->image->id);
|
||||
}
|
||||
if(($event instanceof SetupBuildingEvent)) {
|
||||
$sb = new SetupBlock("Tag History");
|
||||
$sb->add_label("Limit to ");
|
||||
$sb->add_int_option("history_limit");
|
||||
$sb->add_label(" entires per image");
|
||||
$sb->add_label("<br>(-1 for unlimited)");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
if(($event instanceof TagSetEvent)) {
|
||||
$this->add_tag_history($event->image, $event->tags);
|
||||
}
|
||||
}
|
||||
|
||||
protected function install()
|
||||
{
|
||||
global $database;
|
||||
global $config;
|
||||
|
||||
if($config->get_int("ext_tag_history_version") < 1) {
|
||||
$database->create_table("tag_histories", "
|
||||
id SCORE_AIPK,
|
||||
image_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
user_ip SCORE_INET NOT NULL,
|
||||
tags TEXT NOT NULL,
|
||||
date_set DATETIME NOT NULL,
|
||||
INDEX(image_id),
|
||||
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
");
|
||||
$config->set_int("ext_tag_history_version", 3);
|
||||
}
|
||||
|
||||
if($config->get_int("ext_tag_history_version") == 1) {
|
||||
$database->Execute("ALTER TABLE tag_histories ADD COLUMN user_id INTEGER NOT NULL");
|
||||
$database->Execute("ALTER TABLE tag_histories ADD COLUMN date_set DATETIME NOT NULL");
|
||||
$config->set_int("ext_tag_history_version", 2);
|
||||
}
|
||||
|
||||
if($config->get_int("ext_tag_history_version") == 2) {
|
||||
$database->Execute("ALTER TABLE tag_histories ADD COLUMN user_ip CHAR(15) NOT NULL");
|
||||
$config->set_int("ext_tag_history_version", 3);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* this function is called when a revert request is received
|
||||
*/
|
||||
private function process_revert_request($revert_id)
|
||||
{
|
||||
global $page;
|
||||
// check for the nothing case
|
||||
if($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
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link());
|
||||
return;
|
||||
}
|
||||
|
||||
$revert_id = int_escape($revert_id);
|
||||
|
||||
// lets get this revert id assuming it exists
|
||||
$result = $this->get_tag_history_from_revert($revert_id);
|
||||
|
||||
if($result==null)
|
||||
{
|
||||
// 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.
|
||||
die("Error: No tag history with specified id was found.");
|
||||
}
|
||||
|
||||
// lets get the values out of the result
|
||||
$stored_result_id = $result->fields['id'];
|
||||
$stored_image_id = $result->fields['image_id'];
|
||||
$stored_tags = $result->fields['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"));
|
||||
}
|
||||
|
||||
public function get_tag_history_from_revert($revert_id)
|
||||
{
|
||||
global $database;
|
||||
$row = $database->execute("
|
||||
SELECT tag_histories.*, users.name
|
||||
FROM tag_histories
|
||||
JOIN users ON tag_histories.user_id = users.id
|
||||
WHERE tag_histories.id = ?", array($revert_id));
|
||||
return ($row ? $row : null);
|
||||
}
|
||||
|
||||
public function get_tag_history_from_id($image_id)
|
||||
{
|
||||
global $database;
|
||||
$row = $database->get_all("
|
||||
SELECT tag_histories.*, users.name
|
||||
FROM tag_histories
|
||||
JOIN users ON tag_histories.user_id = users.id
|
||||
WHERE image_id = ?
|
||||
ORDER BY tag_histories.id DESC",
|
||||
array($image_id));
|
||||
return ($row ? $row : array());
|
||||
}
|
||||
|
||||
public function get_global_tag_history()
|
||||
{
|
||||
global $database;
|
||||
$row = $database->get_all("
|
||||
SELECT tag_histories.*, users.name
|
||||
FROM tag_histories
|
||||
JOIN users ON tag_histories.user_id = users.id
|
||||
ORDER BY tag_histories.id DESC
|
||||
LIMIT 100");
|
||||
return ($row ? $row : array());
|
||||
}
|
||||
|
||||
/*
|
||||
* this function is called when an image has been deleted
|
||||
*/
|
||||
private function delete_all_tag_history($image_id)
|
||||
{
|
||||
global $database;
|
||||
$database->execute("DELETE FROM tag_histories WHERE image_id = ?", array($image_id));
|
||||
}
|
||||
|
||||
/*
|
||||
* this function is called just before an images tag are changed
|
||||
*/
|
||||
private function add_tag_history($image, $tags)
|
||||
{
|
||||
global $database;
|
||||
global $config;
|
||||
global $user;
|
||||
|
||||
$new_tags = Tag::implode($tags);
|
||||
$old_tags = Tag::implode($image->get_tag_array());
|
||||
if($new_tags == $old_tags) return;
|
||||
|
||||
// add a history entry
|
||||
$allowed = $config->get_int("history_limit");
|
||||
if($allowed == 0) return;
|
||||
|
||||
$row = $database->execute("
|
||||
INSERT INTO tag_histories(image_id, tags, user_id, user_ip, date_set)
|
||||
VALUES (?, ?, ?, ?, now())",
|
||||
array($image->id, $new_tags, $user->id, $_SERVER['REMOTE_ADDR']));
|
||||
|
||||
// if needed remove oldest one
|
||||
if($allowed == -1) return;
|
||||
$entries = $database->db->GetOne("SELECT COUNT(*) FROM tag_histories WHERE image_id = ?", array($image->id));
|
||||
if($entries > $allowed)
|
||||
{
|
||||
// TODO: Make these queries better
|
||||
$min_id = $database->db->GetOne("SELECT MIN(id) FROM tag_histories WHERE image_id = ?", array($image->id));
|
||||
$database->execute("DELETE FROM tag_histories WHERE id = ?", array($min_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new Tag_History(), 40); // in before tags are actually set, so that "get current tags" works
|
||||
?>
|
||||
<?php
|
||||
/*
|
||||
* Name: Tag History
|
||||
* Author: Bzchan <bzchan@animemahou.com>
|
||||
* Description: Keep a record of tag changes
|
||||
*/
|
||||
|
||||
class Tag_History implements Extension {
|
||||
var $theme;
|
||||
|
||||
public function receive_event(Event $event) {
|
||||
global $config, $database, $page, $user;
|
||||
if(is_null($this->theme)) $this->theme = get_theme_object($this);
|
||||
|
||||
if(($event instanceof InitExtEvent)) {
|
||||
$config->set_default_int("history_limit", -1);
|
||||
|
||||
// shimmie is being installed so call install to create the table.
|
||||
if($config->get_int("ext_tag_history_version") < 3) {
|
||||
$this->install();
|
||||
}
|
||||
}
|
||||
|
||||
if(($event instanceof PageRequestEvent) && $event->page_matches("tag_history"))
|
||||
{
|
||||
if($event->get_arg(0) == "revert")
|
||||
{
|
||||
// this is a request to revert to a previous version of the tags
|
||||
if($config->get_bool("tag_edit_anon") || !$user->is_anonymous()) {
|
||||
$this->process_revert_request($_POST['revert']);
|
||||
}
|
||||
}
|
||||
else if($event->count_args() == 1)
|
||||
{
|
||||
// must be an attempt to view a tag history
|
||||
$image_id = int_escape($event->get_arg(0));
|
||||
$this->theme->display_history_page($page, $image_id, $this->get_tag_history_from_id($image_id));
|
||||
}
|
||||
else {
|
||||
$this->theme->display_global_page($page, $this->get_global_tag_history());
|
||||
}
|
||||
}
|
||||
if(($event instanceof DisplayingImageEvent))
|
||||
{
|
||||
// handle displaying a link on the view page
|
||||
$this->theme->display_history_link($page, $event->image->id);
|
||||
}
|
||||
if(($event instanceof ImageDeletionEvent))
|
||||
{
|
||||
// handle removing of history when an image is deleted
|
||||
$this->delete_all_tag_history($event->image->id);
|
||||
}
|
||||
if(($event instanceof SetupBuildingEvent)) {
|
||||
$sb = new SetupBlock("Tag History");
|
||||
$sb->add_label("Limit to ");
|
||||
$sb->add_int_option("history_limit");
|
||||
$sb->add_label(" entires per image");
|
||||
$sb->add_label("<br>(-1 for unlimited)");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
if(($event instanceof TagSetEvent)) {
|
||||
$this->add_tag_history($event->image, $event->tags);
|
||||
}
|
||||
}
|
||||
|
||||
protected function install()
|
||||
{
|
||||
global $database;
|
||||
global $config;
|
||||
|
||||
if($config->get_int("ext_tag_history_version") < 1) {
|
||||
$database->create_table("tag_histories", "
|
||||
id SCORE_AIPK,
|
||||
image_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
user_ip SCORE_INET NOT NULL,
|
||||
tags TEXT NOT NULL,
|
||||
date_set DATETIME NOT NULL,
|
||||
INDEX(image_id),
|
||||
FOREIGN KEY (image_id) REFERENCES images(id) ON DELETE CASCADE,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
");
|
||||
$config->set_int("ext_tag_history_version", 3);
|
||||
}
|
||||
|
||||
if($config->get_int("ext_tag_history_version") == 1) {
|
||||
$database->Execute("ALTER TABLE tag_histories ADD COLUMN user_id INTEGER NOT NULL");
|
||||
$database->Execute("ALTER TABLE tag_histories ADD COLUMN date_set DATETIME NOT NULL");
|
||||
$config->set_int("ext_tag_history_version", 2);
|
||||
}
|
||||
|
||||
if($config->get_int("ext_tag_history_version") == 2) {
|
||||
$database->Execute("ALTER TABLE tag_histories ADD COLUMN user_ip CHAR(15) NOT NULL");
|
||||
$config->set_int("ext_tag_history_version", 3);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* this function is called when a revert request is received
|
||||
*/
|
||||
private function process_revert_request($revert_id)
|
||||
{
|
||||
global $page;
|
||||
// check for the nothing case
|
||||
if($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
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link());
|
||||
return;
|
||||
}
|
||||
|
||||
$revert_id = int_escape($revert_id);
|
||||
|
||||
// lets get this revert id assuming it exists
|
||||
$result = $this->get_tag_history_from_revert($revert_id);
|
||||
|
||||
if($result==null)
|
||||
{
|
||||
// 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.
|
||||
die("Error: No tag history with specified id was found.");
|
||||
}
|
||||
|
||||
// lets get the values out of the result
|
||||
$stored_result_id = $result->fields['id'];
|
||||
$stored_image_id = $result->fields['image_id'];
|
||||
$stored_tags = $result->fields['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"));
|
||||
}
|
||||
|
||||
public function get_tag_history_from_revert($revert_id)
|
||||
{
|
||||
global $database;
|
||||
$row = $database->execute("
|
||||
SELECT tag_histories.*, users.name
|
||||
FROM tag_histories
|
||||
JOIN users ON tag_histories.user_id = users.id
|
||||
WHERE tag_histories.id = ?", array($revert_id));
|
||||
return ($row ? $row : null);
|
||||
}
|
||||
|
||||
public function get_tag_history_from_id($image_id)
|
||||
{
|
||||
global $database;
|
||||
$row = $database->get_all("
|
||||
SELECT tag_histories.*, users.name
|
||||
FROM tag_histories
|
||||
JOIN users ON tag_histories.user_id = users.id
|
||||
WHERE image_id = ?
|
||||
ORDER BY tag_histories.id DESC",
|
||||
array($image_id));
|
||||
return ($row ? $row : array());
|
||||
}
|
||||
|
||||
public function get_global_tag_history()
|
||||
{
|
||||
global $database;
|
||||
$row = $database->get_all("
|
||||
SELECT tag_histories.*, users.name
|
||||
FROM tag_histories
|
||||
JOIN users ON tag_histories.user_id = users.id
|
||||
ORDER BY tag_histories.id DESC
|
||||
LIMIT 100");
|
||||
return ($row ? $row : array());
|
||||
}
|
||||
|
||||
/*
|
||||
* this function is called when an image has been deleted
|
||||
*/
|
||||
private function delete_all_tag_history($image_id)
|
||||
{
|
||||
global $database;
|
||||
$database->execute("DELETE FROM tag_histories WHERE image_id = ?", array($image_id));
|
||||
}
|
||||
|
||||
/*
|
||||
* this function is called just before an images tag are changed
|
||||
*/
|
||||
private function add_tag_history($image, $tags)
|
||||
{
|
||||
global $database;
|
||||
global $config;
|
||||
global $user;
|
||||
|
||||
$new_tags = Tag::implode($tags);
|
||||
$old_tags = Tag::implode($image->get_tag_array());
|
||||
if($new_tags == $old_tags) return;
|
||||
|
||||
// add a history entry
|
||||
$allowed = $config->get_int("history_limit");
|
||||
if($allowed == 0) return;
|
||||
|
||||
$row = $database->execute("
|
||||
INSERT INTO tag_histories(image_id, tags, user_id, user_ip, date_set)
|
||||
VALUES (?, ?, ?, ?, now())",
|
||||
array($image->id, $new_tags, $user->id, $_SERVER['REMOTE_ADDR']));
|
||||
|
||||
// if needed remove oldest one
|
||||
if($allowed == -1) return;
|
||||
$entries = $database->db->GetOne("SELECT COUNT(*) FROM tag_histories WHERE image_id = ?", array($image->id));
|
||||
if($entries > $allowed)
|
||||
{
|
||||
// TODO: Make these queries better
|
||||
$min_id = $database->db->GetOne("SELECT MIN(id) FROM tag_histories WHERE image_id = ?", array($image->id));
|
||||
$database->execute("DELETE FROM tag_histories WHERE id = ?", array($min_id));
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new Tag_History(), 40); // in before tags are actually set, so that "get current tags" works
|
||||
?>
|
||||
|
@ -1,175 +1,175 @@
|
||||
<?php
|
||||
/**
|
||||
* Name: Random Tip
|
||||
* Author: Sein Kraft <mail@seinkraft.info>
|
||||
* License: GPLv2
|
||||
* Description: Show a random line of text in the subheader space
|
||||
* Documentation:
|
||||
* Formatting is done with HTML
|
||||
*/
|
||||
|
||||
class Tips extends SimpleExtension {
|
||||
public function onInitExt($event) {
|
||||
global $config, $database;
|
||||
|
||||
if ($config->get_int("ext_tips_version") < 1){
|
||||
$database->create_table("tips", "
|
||||
id SCORE_AIPK,
|
||||
enable SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||
image TEXT NOT NULL,
|
||||
text TEXT NOT NULL,
|
||||
INDEX (id)
|
||||
");
|
||||
|
||||
$database->execute("
|
||||
INSERT INTO tips (enable, image, text)
|
||||
VALUES (?, ?, ?)",
|
||||
array("Y", "coins.png", "Do you like this extension? Please support us for developing new ones. <a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8235933\" target=\"_blank\">Donate through paypal</a>."));
|
||||
|
||||
$config->set_int("ext_tips_version", 1);
|
||||
log_info("tips", "extension installed");
|
||||
}
|
||||
}
|
||||
|
||||
public function onPageRequest($event) {
|
||||
global $page, $user;
|
||||
|
||||
$this->getTip();
|
||||
|
||||
if($event->page_matches("tips")) {
|
||||
switch($event->get_arg(0)) {
|
||||
case "list":
|
||||
{
|
||||
if($user->is_admin()) {
|
||||
$this->manageTips();
|
||||
$this->getAll();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "new":
|
||||
{
|
||||
break;
|
||||
}
|
||||
case "save":
|
||||
{
|
||||
if($user->is_admin()) {
|
||||
$this->saveTip();
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("tips/list"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "status":
|
||||
{
|
||||
if($user->is_admin()) {
|
||||
$tipID = int_escape($event->get_arg(1));
|
||||
$this->setStatus($tipID);
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("tips/list"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "delete":
|
||||
{
|
||||
if($user->is_admin()) {
|
||||
$tipID = int_escape($event->get_arg(1));
|
||||
$this->deleteTip($tipID);
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("tips/list"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onUserBlockBuilding($event) {
|
||||
global $user;
|
||||
if($user->is_admin()) {
|
||||
$event->add_link("Tips Editor", make_link("tips/list"));
|
||||
}
|
||||
}
|
||||
|
||||
private function manageTips() {
|
||||
$data_href = get_base_href();
|
||||
$url = $data_href."/ext/tips/images/";
|
||||
|
||||
$dirPath = dir('./ext/tips/images');
|
||||
$images = array();
|
||||
while(($file = $dirPath->read()) !== false) {
|
||||
if($file[0] != ".") {
|
||||
$images[] = trim($file);
|
||||
}
|
||||
}
|
||||
$dirPath->close();
|
||||
sort($images);
|
||||
|
||||
$this->theme->manageTips($url, $images);
|
||||
}
|
||||
|
||||
private function saveTip() {
|
||||
global $database;
|
||||
|
||||
$enable = isset($_POST["enable"]) ? "Y" : "N";
|
||||
$image = html_escape($_POST["image"]);
|
||||
$text = $_POST["text"];
|
||||
|
||||
$database->execute("
|
||||
INSERT INTO tips (enable, image, text)
|
||||
VALUES (?, ?, ?)",
|
||||
array($enable, $image, $text));
|
||||
|
||||
}
|
||||
|
||||
private function getTip() {
|
||||
global $database;
|
||||
|
||||
$data_href = get_base_href();
|
||||
$url = $data_href."/ext/tips/images/";
|
||||
|
||||
$tip = $database->get_row("SELECT * ".
|
||||
"FROM tips ".
|
||||
"WHERE enable = 'Y' ".
|
||||
"ORDER BY RAND() ".
|
||||
"LIMIT 1");
|
||||
|
||||
if($tip) {
|
||||
$this->theme->showTip($url, $tip);
|
||||
}
|
||||
}
|
||||
|
||||
private function getAll() {
|
||||
global $database;
|
||||
|
||||
$data_href = get_base_href();
|
||||
$url = $data_href."/ext/tips/images/";
|
||||
|
||||
$tips = $database->get_all("SELECT * FROM tips ORDER BY id ASC");
|
||||
|
||||
$this->theme->showAll($url, $tips);
|
||||
}
|
||||
|
||||
private function setStatus($tipID) {
|
||||
global $database;
|
||||
|
||||
$tip = $database->get_row("SELECT * FROM tips WHERE id = ? ", array($tipID));
|
||||
|
||||
if($tip['enable'] == "Y") {
|
||||
$enable = "N";
|
||||
} elseif($tip['enable'] == "N") {
|
||||
$enable = "Y";
|
||||
}
|
||||
|
||||
$database->execute("UPDATE tips SET enable = ? WHERE id = ?", array ($enable, $tipID));
|
||||
}
|
||||
|
||||
private function deleteTip($tipID) {
|
||||
global $database;
|
||||
$database->execute("DELETE FROM tips WHERE id = ?", array($tipID));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* Name: Random Tip
|
||||
* Author: Sein Kraft <mail@seinkraft.info>
|
||||
* License: GPLv2
|
||||
* Description: Show a random line of text in the subheader space
|
||||
* Documentation:
|
||||
* Formatting is done with HTML
|
||||
*/
|
||||
|
||||
class Tips extends SimpleExtension {
|
||||
public function onInitExt($event) {
|
||||
global $config, $database;
|
||||
|
||||
if ($config->get_int("ext_tips_version") < 1){
|
||||
$database->create_table("tips", "
|
||||
id SCORE_AIPK,
|
||||
enable SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,
|
||||
image TEXT NOT NULL,
|
||||
text TEXT NOT NULL,
|
||||
INDEX (id)
|
||||
");
|
||||
|
||||
$database->execute("
|
||||
INSERT INTO tips (enable, image, text)
|
||||
VALUES (?, ?, ?)",
|
||||
array("Y", "coins.png", "Do you like this extension? Please support us for developing new ones. <a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8235933\" target=\"_blank\">Donate through paypal</a>."));
|
||||
|
||||
$config->set_int("ext_tips_version", 1);
|
||||
log_info("tips", "extension installed");
|
||||
}
|
||||
}
|
||||
|
||||
public function onPageRequest($event) {
|
||||
global $page, $user;
|
||||
|
||||
$this->getTip();
|
||||
|
||||
if($event->page_matches("tips")) {
|
||||
switch($event->get_arg(0)) {
|
||||
case "list":
|
||||
{
|
||||
if($user->is_admin()) {
|
||||
$this->manageTips();
|
||||
$this->getAll();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "new":
|
||||
{
|
||||
break;
|
||||
}
|
||||
case "save":
|
||||
{
|
||||
if($user->is_admin()) {
|
||||
$this->saveTip();
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("tips/list"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "status":
|
||||
{
|
||||
if($user->is_admin()) {
|
||||
$tipID = int_escape($event->get_arg(1));
|
||||
$this->setStatus($tipID);
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("tips/list"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
case "delete":
|
||||
{
|
||||
if($user->is_admin()) {
|
||||
$tipID = int_escape($event->get_arg(1));
|
||||
$this->deleteTip($tipID);
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("tips/list"));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function onUserBlockBuilding($event) {
|
||||
global $user;
|
||||
if($user->is_admin()) {
|
||||
$event->add_link("Tips Editor", make_link("tips/list"));
|
||||
}
|
||||
}
|
||||
|
||||
private function manageTips() {
|
||||
$data_href = get_base_href();
|
||||
$url = $data_href."/ext/tips/images/";
|
||||
|
||||
$dirPath = dir('./ext/tips/images');
|
||||
$images = array();
|
||||
while(($file = $dirPath->read()) !== false) {
|
||||
if($file[0] != ".") {
|
||||
$images[] = trim($file);
|
||||
}
|
||||
}
|
||||
$dirPath->close();
|
||||
sort($images);
|
||||
|
||||
$this->theme->manageTips($url, $images);
|
||||
}
|
||||
|
||||
private function saveTip() {
|
||||
global $database;
|
||||
|
||||
$enable = isset($_POST["enable"]) ? "Y" : "N";
|
||||
$image = html_escape($_POST["image"]);
|
||||
$text = $_POST["text"];
|
||||
|
||||
$database->execute("
|
||||
INSERT INTO tips (enable, image, text)
|
||||
VALUES (?, ?, ?)",
|
||||
array($enable, $image, $text));
|
||||
|
||||
}
|
||||
|
||||
private function getTip() {
|
||||
global $database;
|
||||
|
||||
$data_href = get_base_href();
|
||||
$url = $data_href."/ext/tips/images/";
|
||||
|
||||
$tip = $database->get_row("SELECT * ".
|
||||
"FROM tips ".
|
||||
"WHERE enable = 'Y' ".
|
||||
"ORDER BY RAND() ".
|
||||
"LIMIT 1");
|
||||
|
||||
if($tip) {
|
||||
$this->theme->showTip($url, $tip);
|
||||
}
|
||||
}
|
||||
|
||||
private function getAll() {
|
||||
global $database;
|
||||
|
||||
$data_href = get_base_href();
|
||||
$url = $data_href."/ext/tips/images/";
|
||||
|
||||
$tips = $database->get_all("SELECT * FROM tips ORDER BY id ASC");
|
||||
|
||||
$this->theme->showAll($url, $tips);
|
||||
}
|
||||
|
||||
private function setStatus($tipID) {
|
||||
global $database;
|
||||
|
||||
$tip = $database->get_row("SELECT * FROM tips WHERE id = ? ", array($tipID));
|
||||
|
||||
if($tip['enable'] == "Y") {
|
||||
$enable = "N";
|
||||
} elseif($tip['enable'] == "N") {
|
||||
$enable = "Y";
|
||||
}
|
||||
|
||||
$database->execute("UPDATE tips SET enable = ? WHERE id = ?", array ($enable, $tipID));
|
||||
}
|
||||
|
||||
private function deleteTip($tipID) {
|
||||
global $database;
|
||||
$database->execute("DELETE FROM tips WHERE id = ?", array($tipID));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
|
@ -1,99 +1,99 @@
|
||||
<?php
|
||||
class TipsTheme extends Themelet {
|
||||
public function manageTips($url, $images) {
|
||||
global $page;
|
||||
$select = "<select name='image'><option value=''>- Select Image -</option>";
|
||||
|
||||
foreach($images as $image){
|
||||
$select .= "<option style='background-image:url(".$url.$image."); background-repeat:no-repeat; padding-left:20px;' value=\"".$image."\">".$image."</option>\n";
|
||||
}
|
||||
|
||||
$select .= "</select>";
|
||||
|
||||
$html = "
|
||||
<form action='".make_link("tips/save")."' method='POST'>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Enable:</td>
|
||||
<td><input name='enable' type='checkbox' value='Y' checked/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Image:</td>
|
||||
<td>{$select}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Message:</td>
|
||||
<td><textarea name='text'></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2'><input type='submit' value='Submit' /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
";
|
||||
|
||||
$page->set_title("Tips List");
|
||||
$page->set_heading("Tips List");
|
||||
$page->add_block(new NavBlock());
|
||||
$page->add_block(new Block("Add Tip", $html, "main", 10));
|
||||
}
|
||||
|
||||
public function showTip($url, $tip) {
|
||||
global $page;
|
||||
|
||||
$img = "";
|
||||
if(!empty($tip['image'])) {
|
||||
$img = "<img src=".$url.$tip['image']." /> ";
|
||||
}
|
||||
$html = "<div id='tips'>".$img.$tip['text']."</div>";
|
||||
$page->add_block(new Block(null, $html, "subheading", 10));
|
||||
}
|
||||
|
||||
public function showAll($url, $tips){
|
||||
global $user, $page;
|
||||
|
||||
$html = "<table id='poolsList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>ID</th>".
|
||||
"<th>Enabled</th>".
|
||||
"<th>Image</th>".
|
||||
"<th>Text</th>";
|
||||
|
||||
if($user->is_admin()){
|
||||
$html .= "<th>Action</th>";
|
||||
}
|
||||
|
||||
$html .= "</tr></thead>";
|
||||
|
||||
$n = 0;
|
||||
foreach ($tips as $tip)
|
||||
{
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
||||
$tip_enable = ($tip['enable'] == "Y") ? "Yes" : "No";
|
||||
$set_link = "<a href='".make_link("tips/status/".$tip['id'])."'>".$tip_enable."</a>";
|
||||
|
||||
$html .= "<tr class='$oe'>".
|
||||
"<td>".$tip['id']."</td>".
|
||||
"<td>".$set_link."</td>".
|
||||
(
|
||||
empty($tip['image']) ?
|
||||
"<td></td>" :
|
||||
"<td><img src=".$url.$tip['image']." /></td>"
|
||||
).
|
||||
"<td class='left'>".$tip['text']."</td>";
|
||||
|
||||
$del_link = "<a href='".make_link("tips/delete/".$tip['id'])."'>Delete</a>";
|
||||
|
||||
if($user->is_admin()){
|
||||
$html .= "<td>".$del_link."</td>";
|
||||
}
|
||||
|
||||
$html .= "</tr>";
|
||||
}
|
||||
$html .= "</tbody></table>";
|
||||
|
||||
$page->add_block(new Block("All Tips", $html, "main", 20));
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
class TipsTheme extends Themelet {
|
||||
public function manageTips($url, $images) {
|
||||
global $page;
|
||||
$select = "<select name='image'><option value=''>- Select Image -</option>";
|
||||
|
||||
foreach($images as $image){
|
||||
$select .= "<option style='background-image:url(".$url.$image."); background-repeat:no-repeat; padding-left:20px;' value=\"".$image."\">".$image."</option>\n";
|
||||
}
|
||||
|
||||
$select .= "</select>";
|
||||
|
||||
$html = "
|
||||
<form action='".make_link("tips/save")."' method='POST'>
|
||||
<table>
|
||||
<tr>
|
||||
<td>Enable:</td>
|
||||
<td><input name='enable' type='checkbox' value='Y' checked/></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Image:</td>
|
||||
<td>{$select}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Message:</td>
|
||||
<td><textarea name='text'></textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan='2'><input type='submit' value='Submit' /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
";
|
||||
|
||||
$page->set_title("Tips List");
|
||||
$page->set_heading("Tips List");
|
||||
$page->add_block(new NavBlock());
|
||||
$page->add_block(new Block("Add Tip", $html, "main", 10));
|
||||
}
|
||||
|
||||
public function showTip($url, $tip) {
|
||||
global $page;
|
||||
|
||||
$img = "";
|
||||
if(!empty($tip['image'])) {
|
||||
$img = "<img src=".$url.$tip['image']." /> ";
|
||||
}
|
||||
$html = "<div id='tips'>".$img.$tip['text']."</div>";
|
||||
$page->add_block(new Block(null, $html, "subheading", 10));
|
||||
}
|
||||
|
||||
public function showAll($url, $tips){
|
||||
global $user, $page;
|
||||
|
||||
$html = "<table id='poolsList' class='zebra'>".
|
||||
"<thead><tr>".
|
||||
"<th>ID</th>".
|
||||
"<th>Enabled</th>".
|
||||
"<th>Image</th>".
|
||||
"<th>Text</th>";
|
||||
|
||||
if($user->is_admin()){
|
||||
$html .= "<th>Action</th>";
|
||||
}
|
||||
|
||||
$html .= "</tr></thead>";
|
||||
|
||||
$n = 0;
|
||||
foreach ($tips as $tip)
|
||||
{
|
||||
$oe = ($n++ % 2 == 0) ? "even" : "odd";
|
||||
|
||||
$tip_enable = ($tip['enable'] == "Y") ? "Yes" : "No";
|
||||
$set_link = "<a href='".make_link("tips/status/".$tip['id'])."'>".$tip_enable."</a>";
|
||||
|
||||
$html .= "<tr class='$oe'>".
|
||||
"<td>".$tip['id']."</td>".
|
||||
"<td>".$set_link."</td>".
|
||||
(
|
||||
empty($tip['image']) ?
|
||||
"<td></td>" :
|
||||
"<td><img src=".$url.$tip['image']." /></td>"
|
||||
).
|
||||
"<td class='left'>".$tip['text']."</td>";
|
||||
|
||||
$del_link = "<a href='".make_link("tips/delete/".$tip['id'])."'>Delete</a>";
|
||||
|
||||
if($user->is_admin()){
|
||||
$html .= "<td>".$del_link."</td>";
|
||||
}
|
||||
|
||||
$html .= "</tr>";
|
||||
}
|
||||
$html .= "</tbody></table>";
|
||||
|
||||
$page->add_block(new Block("All Tips", $html, "main", 20));
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -1,121 +1,121 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
V4.50 6 July 2004 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
Modified from datadict-generic.inc.php for sapdb by RalfBecker-AT-outdoor-training.de
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
class ADODB2_sapdb extends ADODB_DataDict {
|
||||
|
||||
var $databaseType = 'sapdb';
|
||||
var $seqField = false;
|
||||
var $renameColumn = 'RENAME COLUMN %s.%s TO %s';
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch($meta) {
|
||||
case 'C': return 'VARCHAR';
|
||||
case 'XL':
|
||||
case 'X': return 'LONG';
|
||||
|
||||
case 'C2': return 'VARCHAR UNICODE';
|
||||
case 'X2': return 'LONG UNICODE';
|
||||
|
||||
case 'B': return 'LONG';
|
||||
|
||||
case 'D': return 'DATE';
|
||||
case 'T': return 'TIMESTAMP';
|
||||
|
||||
case 'L': return 'BOOLEAN';
|
||||
case 'I': return 'INTEGER';
|
||||
case 'I1': return 'FIXED(3)';
|
||||
case 'I2': return 'SMALLINT';
|
||||
case 'I4': return 'INTEGER';
|
||||
case 'I8': return 'FIXED(20)';
|
||||
|
||||
case 'F': return 'FLOAT(38)';
|
||||
case 'N': return 'FIXED';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
function MetaType($t,$len=-1,$fieldobj=false)
|
||||
{
|
||||
if (is_object($t)) {
|
||||
$fieldobj = $t;
|
||||
$t = $fieldobj->type;
|
||||
$len = $fieldobj->max_length;
|
||||
}
|
||||
static $maxdb_type2adodb = array(
|
||||
'VARCHAR' => 'C',
|
||||
'CHARACTER' => 'C',
|
||||
'LONG' => 'X', // no way to differ between 'X' and 'B' :-(
|
||||
'DATE' => 'D',
|
||||
'TIMESTAMP' => 'T',
|
||||
'BOOLEAN' => 'L',
|
||||
'INTEGER' => 'I4',
|
||||
'SMALLINT' => 'I2',
|
||||
'FLOAT' => 'F',
|
||||
'FIXED' => 'N',
|
||||
);
|
||||
$type = isset($maxdb_type2adodb[$t]) ? $maxdb_type2adodb[$t] : 'C';
|
||||
|
||||
// convert integer-types simulated with fixed back to integer
|
||||
if ($t == 'FIXED' && !$fieldobj->scale && ($len == 20 || $len == 3)) {
|
||||
$type = $len == 20 ? 'I8' : 'I1';
|
||||
}
|
||||
if ($fieldobj->auto_increment) $type = 'R';
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
// return string must begin with space
|
||||
function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
|
||||
{
|
||||
$suffix = '';
|
||||
if ($funsigned) $suffix .= ' UNSIGNED';
|
||||
if ($fnotnull) $suffix .= ' NOT NULL';
|
||||
if ($fautoinc) $suffix .= ' DEFAULT SERIAL';
|
||||
elseif (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
|
||||
if ($fconstraint) $suffix .= ' '.$fconstraint;
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
function AddColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$sql = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
return array( 'ALTER TABLE ' . $tabname . ' ADD (' . implode(', ',$lines) . ')' );
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$sql = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
return array( 'ALTER TABLE ' . $tabname . ' MODIFY (' . implode(', ',$lines) . ')' );
|
||||
}
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
if (!is_array($flds)) $flds = explode(',',$flds);
|
||||
foreach($flds as $k => $v) {
|
||||
$flds[$k] = $this->NameQuote($v);
|
||||
}
|
||||
return array( 'ALTER TABLE ' . $tabname . ' DROP (' . implode(', ',$flds) . ')' );
|
||||
}
|
||||
}
|
||||
|
||||
<?php
|
||||
|
||||
/**
|
||||
V4.50 6 July 2004 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved.
|
||||
Released under both BSD license and Lesser GPL library license.
|
||||
Whenever there is any discrepancy between the two licenses,
|
||||
the BSD license will take precedence.
|
||||
|
||||
Set tabs to 4 for best viewing.
|
||||
|
||||
Modified from datadict-generic.inc.php for sapdb by RalfBecker-AT-outdoor-training.de
|
||||
*/
|
||||
|
||||
// security - hide paths
|
||||
if (!defined('ADODB_DIR')) die();
|
||||
|
||||
class ADODB2_sapdb extends ADODB_DataDict {
|
||||
|
||||
var $databaseType = 'sapdb';
|
||||
var $seqField = false;
|
||||
var $renameColumn = 'RENAME COLUMN %s.%s TO %s';
|
||||
|
||||
function ActualType($meta)
|
||||
{
|
||||
switch($meta) {
|
||||
case 'C': return 'VARCHAR';
|
||||
case 'XL':
|
||||
case 'X': return 'LONG';
|
||||
|
||||
case 'C2': return 'VARCHAR UNICODE';
|
||||
case 'X2': return 'LONG UNICODE';
|
||||
|
||||
case 'B': return 'LONG';
|
||||
|
||||
case 'D': return 'DATE';
|
||||
case 'T': return 'TIMESTAMP';
|
||||
|
||||
case 'L': return 'BOOLEAN';
|
||||
case 'I': return 'INTEGER';
|
||||
case 'I1': return 'FIXED(3)';
|
||||
case 'I2': return 'SMALLINT';
|
||||
case 'I4': return 'INTEGER';
|
||||
case 'I8': return 'FIXED(20)';
|
||||
|
||||
case 'F': return 'FLOAT(38)';
|
||||
case 'N': return 'FIXED';
|
||||
default:
|
||||
return $meta;
|
||||
}
|
||||
}
|
||||
|
||||
function MetaType($t,$len=-1,$fieldobj=false)
|
||||
{
|
||||
if (is_object($t)) {
|
||||
$fieldobj = $t;
|
||||
$t = $fieldobj->type;
|
||||
$len = $fieldobj->max_length;
|
||||
}
|
||||
static $maxdb_type2adodb = array(
|
||||
'VARCHAR' => 'C',
|
||||
'CHARACTER' => 'C',
|
||||
'LONG' => 'X', // no way to differ between 'X' and 'B' :-(
|
||||
'DATE' => 'D',
|
||||
'TIMESTAMP' => 'T',
|
||||
'BOOLEAN' => 'L',
|
||||
'INTEGER' => 'I4',
|
||||
'SMALLINT' => 'I2',
|
||||
'FLOAT' => 'F',
|
||||
'FIXED' => 'N',
|
||||
);
|
||||
$type = isset($maxdb_type2adodb[$t]) ? $maxdb_type2adodb[$t] : 'C';
|
||||
|
||||
// convert integer-types simulated with fixed back to integer
|
||||
if ($t == 'FIXED' && !$fieldobj->scale && ($len == 20 || $len == 3)) {
|
||||
$type = $len == 20 ? 'I8' : 'I1';
|
||||
}
|
||||
if ($fieldobj->auto_increment) $type = 'R';
|
||||
|
||||
return $type;
|
||||
}
|
||||
|
||||
// return string must begin with space
|
||||
function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
|
||||
{
|
||||
$suffix = '';
|
||||
if ($funsigned) $suffix .= ' UNSIGNED';
|
||||
if ($fnotnull) $suffix .= ' NOT NULL';
|
||||
if ($fautoinc) $suffix .= ' DEFAULT SERIAL';
|
||||
elseif (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
|
||||
if ($fconstraint) $suffix .= ' '.$fconstraint;
|
||||
return $suffix;
|
||||
}
|
||||
|
||||
function AddColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$sql = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
return array( 'ALTER TABLE ' . $tabname . ' ADD (' . implode(', ',$lines) . ')' );
|
||||
}
|
||||
|
||||
function AlterColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
$sql = array();
|
||||
list($lines,$pkey) = $this->_GenFields($flds);
|
||||
return array( 'ALTER TABLE ' . $tabname . ' MODIFY (' . implode(', ',$lines) . ')' );
|
||||
}
|
||||
|
||||
function DropColumnSQL($tabname, $flds)
|
||||
{
|
||||
$tabname = $this->TableName ($tabname);
|
||||
if (!is_array($flds)) $flds = explode(',',$flds);
|
||||
foreach($flds as $k => $v) {
|
||||
$flds[$k] = $this->NameQuote($v);
|
||||
}
|
||||
return array( 'ALTER TABLE ' . $tabname . ' DROP (' . implode(', ',$flds) . ')' );
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@ -1,356 +1,356 @@
|
||||
<?php
|
||||
/**
|
||||
* 01.26.2006 12:29:28est
|
||||
*
|
||||
* Akismet PHP4 class
|
||||
*
|
||||
* <b>Usage</b>
|
||||
* <code>
|
||||
* $comment = array(
|
||||
* 'author' => 'viagra-test-123',
|
||||
* 'email' => 'test@example.com',
|
||||
* 'website' => 'http://www.example.com/',
|
||||
* 'body' => 'This is a test comment',
|
||||
* 'permalink' => 'http://yourdomain.com/yourblogpost.url',
|
||||
* );
|
||||
*
|
||||
* $akismet = new Akismet('http://www.yourdomain.com/', 'YOUR_WORDPRESS_API_KEY', $comment);
|
||||
*
|
||||
* if($akismet->isError()) {
|
||||
* echo"Couldn't connected to Akismet server!";
|
||||
* } else {
|
||||
* if($akismet->isSpam()) {
|
||||
* echo"Spam detected";
|
||||
* } else {
|
||||
* echo"yay, no spam!";
|
||||
* }
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @author Bret Kuhns {@link www.miphp.net}
|
||||
* @link http://www.miphp.net/blog/view/php4_akismet_class/
|
||||
* @version 0.3.3
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// Error constants
|
||||
define("AKISMET_SERVER_NOT_FOUND", 0);
|
||||
define("AKISMET_RESPONSE_FAILED", 1);
|
||||
define("AKISMET_INVALID_KEY", 2);
|
||||
|
||||
|
||||
|
||||
// Base class to assist in error handling between Akismet classes
|
||||
class AkismetObject {
|
||||
var $errors = array();
|
||||
|
||||
|
||||
/**
|
||||
* Add a new error to the errors array in the object
|
||||
*
|
||||
* @param String $name A name (array key) for the error
|
||||
* @param String $string The error message
|
||||
* @return void
|
||||
*/
|
||||
// Set an error in the object
|
||||
function setError($name, $message) {
|
||||
$this->errors[$name] = $message;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a specific error message from the errors array
|
||||
*
|
||||
* @param String $name The name of the error you want
|
||||
* @return mixed Returns a String if the error exists, a false boolean if it does not exist
|
||||
*/
|
||||
function getError($name) {
|
||||
if($this->isError($name)) {
|
||||
return $this->errors[$name];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return all errors in the object
|
||||
*
|
||||
* @return String[]
|
||||
*/
|
||||
function getErrors() {
|
||||
return (array)$this->errors;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a certain error exists
|
||||
*
|
||||
* @param String $name The name of the error you want
|
||||
* @return boolean
|
||||
*/
|
||||
function isError($name) {
|
||||
return isset($this->errors[$name]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if any errors exist
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function errorsExist() {
|
||||
return (count($this->errors) > 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Used by the Akismet class to communicate with the Akismet service
|
||||
class AkismetHttpClient extends AkismetObject {
|
||||
var $akismetVersion = '1.1';
|
||||
var $con;
|
||||
var $host;
|
||||
var $port;
|
||||
var $apiKey;
|
||||
var $blogUrl;
|
||||
var $errors = array();
|
||||
|
||||
|
||||
// Constructor
|
||||
function AkismetHttpClient($host, $blogUrl, $apiKey, $port = 80) {
|
||||
$this->host = $host;
|
||||
$this->port = $port;
|
||||
$this->blogUrl = $blogUrl;
|
||||
$this->apiKey = $apiKey;
|
||||
}
|
||||
|
||||
|
||||
// Use the connection active in $con to get a response from the server and return that response
|
||||
function getResponse($request, $path, $type = "post", $responseLength = 1160) {
|
||||
$this->_connect();
|
||||
|
||||
if($this->con && !$this->isError(AKISMET_SERVER_NOT_FOUND)) {
|
||||
$request =
|
||||
strToUpper($type)." /{$this->akismetVersion}/$path HTTP/1.1\r\n" .
|
||||
"Host: ".((!empty($this->apiKey)) ? $this->apiKey."." : null)."{$this->host}\r\n" .
|
||||
"Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" .
|
||||
"Content-Length: ".strlen($request)."\r\n" .
|
||||
"User-Agent: Akismet PHP4 Class\r\n" .
|
||||
"\r\n" .
|
||||
$request
|
||||
;
|
||||
$response = "";
|
||||
|
||||
@fwrite($this->con, $request);
|
||||
|
||||
while(!feof($this->con)) {
|
||||
$response .= @fgets($this->con, $responseLength);
|
||||
}
|
||||
|
||||
$response = explode("\r\n\r\n", $response, 2);
|
||||
return $response[1];
|
||||
} else {
|
||||
$this->setError(AKISMET_RESPONSE_FAILED, "The response could not be retrieved.");
|
||||
}
|
||||
|
||||
$this->_disconnect();
|
||||
}
|
||||
|
||||
|
||||
// Connect to the Akismet server and store that connection in the instance variable $con
|
||||
function _connect() {
|
||||
if(!($this->con = @fsockopen($this->host, $this->port))) {
|
||||
$this->setError(AKISMET_SERVER_NOT_FOUND, "Could not connect to akismet server.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Close the connection to the Akismet server
|
||||
function _disconnect() {
|
||||
@fclose($this->con);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// The controlling class. This is the ONLY class the user should instantiate in
|
||||
// order to use the Akismet service!
|
||||
class Akismet extends AkismetObject {
|
||||
var $apiPort = 80;
|
||||
var $akismetServer = 'rest.akismet.com';
|
||||
var $akismetVersion = '1.1';
|
||||
var $http;
|
||||
|
||||
var $ignore = array(
|
||||
'HTTP_COOKIE',
|
||||
'HTTP_X_FORWARDED_FOR',
|
||||
'HTTP_X_FORWARDED_HOST',
|
||||
'HTTP_MAX_FORWARDS',
|
||||
'HTTP_X_FORWARDED_SERVER',
|
||||
'REDIRECT_STATUS',
|
||||
'SERVER_PORT',
|
||||
'PATH',
|
||||
'DOCUMENT_ROOT',
|
||||
'SERVER_ADMIN',
|
||||
'QUERY_STRING',
|
||||
'PHP_SELF'
|
||||
);
|
||||
|
||||
var $blogUrl = "";
|
||||
var $apiKey = "";
|
||||
var $comment = array();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Set instance variables, connect to Akismet, and check API key
|
||||
*
|
||||
* @param String $blogUrl The URL to your own blog
|
||||
* @param String $apiKey Your wordpress API key
|
||||
* @param String[] $comment A formatted comment array to be examined by the Akismet service
|
||||
*/
|
||||
function Akismet($blogUrl, $apiKey, $comment) {
|
||||
$this->blogUrl = $blogUrl;
|
||||
$this->apiKey = $apiKey;
|
||||
|
||||
// Populate the comment array with information needed by Akismet
|
||||
$this->comment = $comment;
|
||||
$this->_formatCommentArray();
|
||||
|
||||
if(!isset($this->comment['user_ip'])) {
|
||||
$this->comment['user_ip'] = ($_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR')) ? $_SERVER['REMOTE_ADDR'] : getenv('HTTP_X_FORWARDED_FOR');
|
||||
}
|
||||
if(!isset($this->comment['user_agent'])) {
|
||||
$this->comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
|
||||
}
|
||||
if(!isset($this->comment['referrer'])) {
|
||||
$this->comment['referrer'] = $_SERVER['HTTP_REFERER'];
|
||||
}
|
||||
$this->comment['blog'] = $blogUrl;
|
||||
|
||||
// Connect to the Akismet server and populate errors if they exist
|
||||
$this->http = new AkismetHttpClient($this->akismetServer, $blogUrl, $apiKey);
|
||||
if($this->http->errorsExist()) {
|
||||
$this->errors = array_merge($this->errors, $this->http->getErrors());
|
||||
}
|
||||
|
||||
// Check if the API key is valid
|
||||
if(!$this->_isValidApiKey($apiKey)) {
|
||||
$this->setError(AKISMET_INVALID_KEY, "Your Akismet API key is not valid.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query the Akismet and determine if the comment is spam or not
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function isSpam() {
|
||||
$response = $this->http->getResponse($this->_getQueryString(), 'comment-check');
|
||||
|
||||
return ($response == "true");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Submit this comment as an unchecked spam to the Akismet server
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function submitSpam() {
|
||||
$this->http->getResponse($this->_getQueryString(), 'submit-spam');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Submit a false-positive comment as "ham" to the Akismet server
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function submitHam() {
|
||||
$this->http->getResponse($this->_getQueryString(), 'submit-ham');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check with the Akismet server to determine if the API key is valid
|
||||
*
|
||||
* @access Protected
|
||||
* @param String $key The Wordpress API key passed from the constructor argument
|
||||
* @return boolean
|
||||
*/
|
||||
function _isValidApiKey($key) {
|
||||
$keyCheck = $this->http->getResponse("key=".$this->apiKey."&blog=".$this->blogUrl, 'verify-key');
|
||||
|
||||
return ($keyCheck == "valid");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Format the comment array in accordance to the Akismet API
|
||||
*
|
||||
* @access Protected
|
||||
* @return void
|
||||
*/
|
||||
function _formatCommentArray() {
|
||||
$format = array(
|
||||
'type' => 'comment_type',
|
||||
'author' => 'comment_author',
|
||||
'email' => 'comment_author_email',
|
||||
'website' => 'comment_author_url',
|
||||
'body' => 'comment_content'
|
||||
);
|
||||
|
||||
foreach($format as $short => $long) {
|
||||
if(isset($this->comment[$short])) {
|
||||
$this->comment[$long] = $this->comment[$short];
|
||||
unset($this->comment[$short]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build a query string for use with HTTP requests
|
||||
*
|
||||
* @access Protected
|
||||
* @return String
|
||||
*/
|
||||
function _getQueryString() {
|
||||
foreach($_SERVER as $key => $value) {
|
||||
if(!in_array($key, $this->ignore)) {
|
||||
if($key == 'REMOTE_ADDR') {
|
||||
$this->comment[$key] = $this->comment['user_ip'];
|
||||
} else {
|
||||
$this->comment[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$query_string = '';
|
||||
|
||||
foreach($this->comment as $key => $data) {
|
||||
if(is_string($data)) {
|
||||
$query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
|
||||
}
|
||||
}
|
||||
|
||||
return $query_string;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* 01.26.2006 12:29:28est
|
||||
*
|
||||
* Akismet PHP4 class
|
||||
*
|
||||
* <b>Usage</b>
|
||||
* <code>
|
||||
* $comment = array(
|
||||
* 'author' => 'viagra-test-123',
|
||||
* 'email' => 'test@example.com',
|
||||
* 'website' => 'http://www.example.com/',
|
||||
* 'body' => 'This is a test comment',
|
||||
* 'permalink' => 'http://yourdomain.com/yourblogpost.url',
|
||||
* );
|
||||
*
|
||||
* $akismet = new Akismet('http://www.yourdomain.com/', 'YOUR_WORDPRESS_API_KEY', $comment);
|
||||
*
|
||||
* if($akismet->isError()) {
|
||||
* echo"Couldn't connected to Akismet server!";
|
||||
* } else {
|
||||
* if($akismet->isSpam()) {
|
||||
* echo"Spam detected";
|
||||
* } else {
|
||||
* echo"yay, no spam!";
|
||||
* }
|
||||
* }
|
||||
* </code>
|
||||
*
|
||||
* @author Bret Kuhns {@link www.miphp.net}
|
||||
* @link http://www.miphp.net/blog/view/php4_akismet_class/
|
||||
* @version 0.3.3
|
||||
* @license http://www.opensource.org/licenses/mit-license.php MIT License
|
||||
*/
|
||||
|
||||
|
||||
|
||||
// Error constants
|
||||
define("AKISMET_SERVER_NOT_FOUND", 0);
|
||||
define("AKISMET_RESPONSE_FAILED", 1);
|
||||
define("AKISMET_INVALID_KEY", 2);
|
||||
|
||||
|
||||
|
||||
// Base class to assist in error handling between Akismet classes
|
||||
class AkismetObject {
|
||||
var $errors = array();
|
||||
|
||||
|
||||
/**
|
||||
* Add a new error to the errors array in the object
|
||||
*
|
||||
* @param String $name A name (array key) for the error
|
||||
* @param String $string The error message
|
||||
* @return void
|
||||
*/
|
||||
// Set an error in the object
|
||||
function setError($name, $message) {
|
||||
$this->errors[$name] = $message;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return a specific error message from the errors array
|
||||
*
|
||||
* @param String $name The name of the error you want
|
||||
* @return mixed Returns a String if the error exists, a false boolean if it does not exist
|
||||
*/
|
||||
function getError($name) {
|
||||
if($this->isError($name)) {
|
||||
return $this->errors[$name];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return all errors in the object
|
||||
*
|
||||
* @return String[]
|
||||
*/
|
||||
function getErrors() {
|
||||
return (array)$this->errors;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if a certain error exists
|
||||
*
|
||||
* @param String $name The name of the error you want
|
||||
* @return boolean
|
||||
*/
|
||||
function isError($name) {
|
||||
return isset($this->errors[$name]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check if any errors exist
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function errorsExist() {
|
||||
return (count($this->errors) > 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// Used by the Akismet class to communicate with the Akismet service
|
||||
class AkismetHttpClient extends AkismetObject {
|
||||
var $akismetVersion = '1.1';
|
||||
var $con;
|
||||
var $host;
|
||||
var $port;
|
||||
var $apiKey;
|
||||
var $blogUrl;
|
||||
var $errors = array();
|
||||
|
||||
|
||||
// Constructor
|
||||
function AkismetHttpClient($host, $blogUrl, $apiKey, $port = 80) {
|
||||
$this->host = $host;
|
||||
$this->port = $port;
|
||||
$this->blogUrl = $blogUrl;
|
||||
$this->apiKey = $apiKey;
|
||||
}
|
||||
|
||||
|
||||
// Use the connection active in $con to get a response from the server and return that response
|
||||
function getResponse($request, $path, $type = "post", $responseLength = 1160) {
|
||||
$this->_connect();
|
||||
|
||||
if($this->con && !$this->isError(AKISMET_SERVER_NOT_FOUND)) {
|
||||
$request =
|
||||
strToUpper($type)." /{$this->akismetVersion}/$path HTTP/1.1\r\n" .
|
||||
"Host: ".((!empty($this->apiKey)) ? $this->apiKey."." : null)."{$this->host}\r\n" .
|
||||
"Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" .
|
||||
"Content-Length: ".strlen($request)."\r\n" .
|
||||
"User-Agent: Akismet PHP4 Class\r\n" .
|
||||
"\r\n" .
|
||||
$request
|
||||
;
|
||||
$response = "";
|
||||
|
||||
@fwrite($this->con, $request);
|
||||
|
||||
while(!feof($this->con)) {
|
||||
$response .= @fgets($this->con, $responseLength);
|
||||
}
|
||||
|
||||
$response = explode("\r\n\r\n", $response, 2);
|
||||
return $response[1];
|
||||
} else {
|
||||
$this->setError(AKISMET_RESPONSE_FAILED, "The response could not be retrieved.");
|
||||
}
|
||||
|
||||
$this->_disconnect();
|
||||
}
|
||||
|
||||
|
||||
// Connect to the Akismet server and store that connection in the instance variable $con
|
||||
function _connect() {
|
||||
if(!($this->con = @fsockopen($this->host, $this->port))) {
|
||||
$this->setError(AKISMET_SERVER_NOT_FOUND, "Could not connect to akismet server.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Close the connection to the Akismet server
|
||||
function _disconnect() {
|
||||
@fclose($this->con);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// The controlling class. This is the ONLY class the user should instantiate in
|
||||
// order to use the Akismet service!
|
||||
class Akismet extends AkismetObject {
|
||||
var $apiPort = 80;
|
||||
var $akismetServer = 'rest.akismet.com';
|
||||
var $akismetVersion = '1.1';
|
||||
var $http;
|
||||
|
||||
var $ignore = array(
|
||||
'HTTP_COOKIE',
|
||||
'HTTP_X_FORWARDED_FOR',
|
||||
'HTTP_X_FORWARDED_HOST',
|
||||
'HTTP_MAX_FORWARDS',
|
||||
'HTTP_X_FORWARDED_SERVER',
|
||||
'REDIRECT_STATUS',
|
||||
'SERVER_PORT',
|
||||
'PATH',
|
||||
'DOCUMENT_ROOT',
|
||||
'SERVER_ADMIN',
|
||||
'QUERY_STRING',
|
||||
'PHP_SELF'
|
||||
);
|
||||
|
||||
var $blogUrl = "";
|
||||
var $apiKey = "";
|
||||
var $comment = array();
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* Set instance variables, connect to Akismet, and check API key
|
||||
*
|
||||
* @param String $blogUrl The URL to your own blog
|
||||
* @param String $apiKey Your wordpress API key
|
||||
* @param String[] $comment A formatted comment array to be examined by the Akismet service
|
||||
*/
|
||||
function Akismet($blogUrl, $apiKey, $comment) {
|
||||
$this->blogUrl = $blogUrl;
|
||||
$this->apiKey = $apiKey;
|
||||
|
||||
// Populate the comment array with information needed by Akismet
|
||||
$this->comment = $comment;
|
||||
$this->_formatCommentArray();
|
||||
|
||||
if(!isset($this->comment['user_ip'])) {
|
||||
$this->comment['user_ip'] = ($_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR')) ? $_SERVER['REMOTE_ADDR'] : getenv('HTTP_X_FORWARDED_FOR');
|
||||
}
|
||||
if(!isset($this->comment['user_agent'])) {
|
||||
$this->comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
|
||||
}
|
||||
if(!isset($this->comment['referrer'])) {
|
||||
$this->comment['referrer'] = $_SERVER['HTTP_REFERER'];
|
||||
}
|
||||
$this->comment['blog'] = $blogUrl;
|
||||
|
||||
// Connect to the Akismet server and populate errors if they exist
|
||||
$this->http = new AkismetHttpClient($this->akismetServer, $blogUrl, $apiKey);
|
||||
if($this->http->errorsExist()) {
|
||||
$this->errors = array_merge($this->errors, $this->http->getErrors());
|
||||
}
|
||||
|
||||
// Check if the API key is valid
|
||||
if(!$this->_isValidApiKey($apiKey)) {
|
||||
$this->setError(AKISMET_INVALID_KEY, "Your Akismet API key is not valid.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Query the Akismet and determine if the comment is spam or not
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function isSpam() {
|
||||
$response = $this->http->getResponse($this->_getQueryString(), 'comment-check');
|
||||
|
||||
return ($response == "true");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Submit this comment as an unchecked spam to the Akismet server
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function submitSpam() {
|
||||
$this->http->getResponse($this->_getQueryString(), 'submit-spam');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Submit a false-positive comment as "ham" to the Akismet server
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function submitHam() {
|
||||
$this->http->getResponse($this->_getQueryString(), 'submit-ham');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check with the Akismet server to determine if the API key is valid
|
||||
*
|
||||
* @access Protected
|
||||
* @param String $key The Wordpress API key passed from the constructor argument
|
||||
* @return boolean
|
||||
*/
|
||||
function _isValidApiKey($key) {
|
||||
$keyCheck = $this->http->getResponse("key=".$this->apiKey."&blog=".$this->blogUrl, 'verify-key');
|
||||
|
||||
return ($keyCheck == "valid");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Format the comment array in accordance to the Akismet API
|
||||
*
|
||||
* @access Protected
|
||||
* @return void
|
||||
*/
|
||||
function _formatCommentArray() {
|
||||
$format = array(
|
||||
'type' => 'comment_type',
|
||||
'author' => 'comment_author',
|
||||
'email' => 'comment_author_email',
|
||||
'website' => 'comment_author_url',
|
||||
'body' => 'comment_content'
|
||||
);
|
||||
|
||||
foreach($format as $short => $long) {
|
||||
if(isset($this->comment[$short])) {
|
||||
$this->comment[$long] = $this->comment[$short];
|
||||
unset($this->comment[$short]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Build a query string for use with HTTP requests
|
||||
*
|
||||
* @access Protected
|
||||
* @return String
|
||||
*/
|
||||
function _getQueryString() {
|
||||
foreach($_SERVER as $key => $value) {
|
||||
if(!in_array($key, $this->ignore)) {
|
||||
if($key == 'REMOTE_ADDR') {
|
||||
$this->comment[$key] = $this->comment['user_ip'];
|
||||
} else {
|
||||
$this->comment[$key] = $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$query_string = '';
|
||||
|
||||
foreach($this->comment as $key => $data) {
|
||||
if(is_string($data)) {
|
||||
$query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
|
||||
}
|
||||
}
|
||||
|
||||
return $query_string;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
?>
|
||||
|
@ -1,218 +1,218 @@
|
||||
<?php
|
||||
/**
|
||||
* Name: Danbooru Theme
|
||||
* Author: Bzchan <bzchan@animemahou.com>
|
||||
* Link: http://trac.shishnet.org/shimmie2/
|
||||
* License: GPLv2
|
||||
* Description: This is a simple theme changing the css to make shimme
|
||||
* look more like danbooru as well as adding a custom links
|
||||
* bar and title to the top of every page.
|
||||
*/
|
||||
//Small changes added by zshall <http://seemslegit.com>
|
||||
//Changed CSS and layout to make shimmie look even more like danbooru
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
Danbooru Theme - Notes (Bzchan)
|
||||
|
||||
Files: default.php, sidebar.js, style.css
|
||||
|
||||
How to use a theme
|
||||
- Copy the danbooru folder with all its contained files into the "themes"
|
||||
directory in your shimmie installation.
|
||||
- Log into your shimmie and change the Theme in the Board Config to your
|
||||
desired theme.
|
||||
|
||||
Changes in this theme include
|
||||
- Adding and editing various elements in the style.css file.
|
||||
- $site_name and $front_name retreival from config added.
|
||||
- $custom_link and $title_link preparation just before html is outputed.
|
||||
- Altered outputed html to include the custom links and removed heading
|
||||
from being displayed (subheading is still displayed)
|
||||
- Note that only the sidebar has been left aligned. Could not properly
|
||||
left align the main block because blocks without headers currently do
|
||||
not have ids on there div elements. (this was a problem because
|
||||
paginator block must be centered and everything else left aligned)
|
||||
|
||||
Tips
|
||||
- You can change custom links to point to whatever pages you want as well as adding
|
||||
more custom links.
|
||||
- The main title link points to the Front Page set in your Board Config options.
|
||||
- The text of the main title is the Title set in your Board Config options.
|
||||
- Themes make no changes to your database or main code files so you can switch
|
||||
back and forward to other themes all you like.
|
||||
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
class Layout {
|
||||
public function display_page($page) {
|
||||
global $config;
|
||||
|
||||
$theme_name = $config->get_string('theme');
|
||||
$base_href = $config->get_string('base_href');
|
||||
$data_href = get_base_href();
|
||||
$contact_link = $config->get_string('contact_link');
|
||||
$version = "Shimmie-".VERSION;
|
||||
|
||||
|
||||
$header_html = "";
|
||||
foreach($page->headers as $line) {
|
||||
$header_html .= "\t\t$line\n";
|
||||
}
|
||||
|
||||
$left_block_html = "";
|
||||
$user_block_html = "";
|
||||
$main_block_html = "";
|
||||
|
||||
foreach($page->blocks as $block) {
|
||||
switch($block->section) {
|
||||
case "left":
|
||||
$left_block_html .= $this->block_to_html($block, true);
|
||||
break;
|
||||
case "user":
|
||||
$user_block_html .= $block->body; // $this->block_to_html($block, true);
|
||||
break;
|
||||
case "main":
|
||||
if($block->header == "Images") {
|
||||
$block->header = " ";
|
||||
}
|
||||
$main_block_html .= $this->block_to_html($block, false);
|
||||
break;
|
||||
default:
|
||||
print "<p>error: {$block->header} using an unknown section ({$block->section})";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$debug = get_debug_info();
|
||||
|
||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
||||
|
||||
if(empty($this->subheading)) {
|
||||
$subheading = "";
|
||||
}
|
||||
else {
|
||||
$subheading = "<div id='subtitle'>{$this->subheading}</div>";
|
||||
}
|
||||
|
||||
$site_name = $config->get_string('title'); // bzchan: change from normal default to get title for top of page
|
||||
$main_page = $config->get_string('main_page'); // bzchan: change from normal default to get main page for top of page
|
||||
|
||||
// bzchan: CUSTOM LINKS are prepared here, change these to whatever you like
|
||||
$custom_links = "";
|
||||
$custom_links .= "<li><a href='".make_link('user')."'>My Account</a></li>";
|
||||
$custom_links .= "<li><a href='".make_link('post/list')."'>Posts</a></li>";
|
||||
$custom_links .= "<li><a href='".make_link('comment/list')."'>Comments</a></li>";
|
||||
$custom_links .= "<li><a href='".make_link('tags')."'>Tags</a></li>";
|
||||
$custom_links .= "<li><a href='".make_link('upload')."'>Upload</a></li>";
|
||||
$custom_links .= "<li><a href='".make_link('wiki')."'>Wiki</a></li>";
|
||||
$custom_links .= "<li><a href='".make_link('wiki/more')."'>More »</a></li>";
|
||||
|
||||
$custom_sublinks = "";
|
||||
// hack
|
||||
global $user;
|
||||
$username = url_escape($user->name);
|
||||
// hack
|
||||
$qp = _get_query_parts();
|
||||
// php sucks
|
||||
switch($qp[0]) {
|
||||
default:
|
||||
$custom_sublinks .= $user_block_html;
|
||||
break;
|
||||
case "post":
|
||||
case "comment":
|
||||
case "upload":
|
||||
$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("wiki/posts")."'>Help</a></li>";
|
||||
break;
|
||||
case "wiki":
|
||||
$custom_sublinks .= "<li><a href='".make_link('wiki')."'>Index</a></li>";
|
||||
$custom_sublinks .= "<li><a href='".make_link("wiki/rules")."'>Rules</a></li>";
|
||||
$custom_sublinks .= "<li><a href='".make_link("wiki/wiki")."'>Help</a></li>";
|
||||
break;
|
||||
case "tags":
|
||||
$custom_sublinks .= "<li><a href='".make_link('tags/map')."'>Map</a></li>";
|
||||
$custom_sublinks .= "<li><a href='".make_link('tags/alphabetic')."'>Alphabetic</a></li>";
|
||||
$custom_sublinks .= "<li><a href='".make_link('tags/popularity')."'>Popularity</a></li>";
|
||||
$custom_sublinks .= "<li><a href='".make_link('tags/categories')."'>Categories</a></li>";
|
||||
$custom_sublinks .= "<li><a href='".make_link('alias/list')."'>Aliases</a></li>";
|
||||
$custom_sublinks .= "<li><a href='".make_link("wiki/tags")."'>Help</a></li>";
|
||||
break;
|
||||
}
|
||||
|
||||
// bzchan: failed attempt to add heading after title_link (failure was it looked bad)
|
||||
//if($this->heading==$site_name)$this->heading = '';
|
||||
//$title_link = "<h1><a href='".make_link($main_page)."'>$site_name</a>/$this->heading</h1>";
|
||||
|
||||
// bzchan: prepare main title link
|
||||
$title_link = "<h1 id='site-title'><a href='".make_link($main_page)."'>$site_name</a></h1>";
|
||||
|
||||
if($page->left_enabled) {
|
||||
$left = "<div id='nav'>$left_block_html</div>";
|
||||
$withleft = "withleft";
|
||||
}
|
||||
else {
|
||||
$left = "";
|
||||
$withleft = "noleft";
|
||||
}
|
||||
|
||||
print <<<EOD
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html>
|
||||
<head>
|
||||
<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
|
||||
<script src='$data_href/themes/$theme_name/sidebar.js' type='text/javascript'></script>
|
||||
<script src='$data_href/themes/$theme_name/script.js' type='text/javascript'></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="header">
|
||||
$title_link
|
||||
<ul id="navbar" class="flat-list">
|
||||
$custom_links
|
||||
</ul>
|
||||
<ul id="subnavbar" class="flat-list">
|
||||
$custom_sublinks
|
||||
</ul>
|
||||
</div>
|
||||
$subheading
|
||||
|
||||
$left
|
||||
<div id="body" class="$withleft">$main_block_html</div>
|
||||
|
||||
<div id="footer">
|
||||
<em>
|
||||
Images © their respective owners,
|
||||
<a href="http://code.shishnet.org/shimmie2/">$version</a> ©
|
||||
<a href="http://www.shishnet.org/">Shish</a> 2007-2009,
|
||||
based on the Danbooru concept.
|
||||
$debug
|
||||
$contact
|
||||
</em>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
}
|
||||
|
||||
function block_to_html($block, $hidable=false) {
|
||||
$h = $block->header;
|
||||
$s = $block->section;
|
||||
$b = $block->body;
|
||||
$html = "";
|
||||
if($hidable) {
|
||||
$i = str_replace(' ', '_', $h.$s);
|
||||
if(!is_null($h)) $html .= "\n<h3 id='$i-toggle' onclick=\"toggle('$i')\">$h</h3>\n";
|
||||
if(!is_null($b)) $html .= "<div id='$i'>$b</div>\n";
|
||||
}
|
||||
else {
|
||||
$i = str_replace(' ', '_', $h.$s);
|
||||
if(!is_null($h)) $html .= "\n<h3>$h</h3>\n";
|
||||
if(!is_null($b)) $html .= "<div id='$i'>$b</div>\n";
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php
|
||||
/**
|
||||
* Name: Danbooru Theme
|
||||
* Author: Bzchan <bzchan@animemahou.com>
|
||||
* Link: http://trac.shishnet.org/shimmie2/
|
||||
* License: GPLv2
|
||||
* Description: This is a simple theme changing the css to make shimme
|
||||
* look more like danbooru as well as adding a custom links
|
||||
* bar and title to the top of every page.
|
||||
*/
|
||||
//Small changes added by zshall <http://seemslegit.com>
|
||||
//Changed CSS and layout to make shimmie look even more like danbooru
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
||||
Danbooru Theme - Notes (Bzchan)
|
||||
|
||||
Files: default.php, sidebar.js, style.css
|
||||
|
||||
How to use a theme
|
||||
- Copy the danbooru folder with all its contained files into the "themes"
|
||||
directory in your shimmie installation.
|
||||
- Log into your shimmie and change the Theme in the Board Config to your
|
||||
desired theme.
|
||||
|
||||
Changes in this theme include
|
||||
- Adding and editing various elements in the style.css file.
|
||||
- $site_name and $front_name retreival from config added.
|
||||
- $custom_link and $title_link preparation just before html is outputed.
|
||||
- Altered outputed html to include the custom links and removed heading
|
||||
from being displayed (subheading is still displayed)
|
||||
- Note that only the sidebar has been left aligned. Could not properly
|
||||
left align the main block because blocks without headers currently do
|
||||
not have ids on there div elements. (this was a problem because
|
||||
paginator block must be centered and everything else left aligned)
|
||||
|
||||
Tips
|
||||
- You can change custom links to point to whatever pages you want as well as adding
|
||||
more custom links.
|
||||
- The main title link points to the Front Page set in your Board Config options.
|
||||
- The text of the main title is the Title set in your Board Config options.
|
||||
- Themes make no changes to your database or main code files so you can switch
|
||||
back and forward to other themes all you like.
|
||||
|
||||
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
class Layout {
|
||||
public function display_page($page) {
|
||||
global $config;
|
||||
|
||||
$theme_name = $config->get_string('theme');
|
||||
$base_href = $config->get_string('base_href');
|
||||
$data_href = get_base_href();
|
||||
$contact_link = $config->get_string('contact_link');
|
||||
$version = "Shimmie-".VERSION;
|
||||
|
||||
|
||||
$header_html = "";
|
||||
foreach($page->headers as $line) {
|
||||
$header_html .= "\t\t$line\n";
|
||||
}
|
||||
|
||||
$left_block_html = "";
|
||||
$user_block_html = "";
|
||||
$main_block_html = "";
|
||||
|
||||
foreach($page->blocks as $block) {
|
||||
switch($block->section) {
|
||||
case "left":
|
||||
$left_block_html .= $this->block_to_html($block, true);
|
||||
break;
|
||||
case "user":
|
||||
$user_block_html .= $block->body; // $this->block_to_html($block, true);
|
||||
break;
|
||||
case "main":
|
||||
if($block->header == "Images") {
|
||||
$block->header = " ";
|
||||
}
|
||||
$main_block_html .= $this->block_to_html($block, false);
|
||||
break;
|
||||
default:
|
||||
print "<p>error: {$block->header} using an unknown section ({$block->section})";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$debug = get_debug_info();
|
||||
|
||||
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
|
||||
|
||||
if(empty($this->subheading)) {
|
||||
$subheading = "";
|
||||
}
|
||||
else {
|
||||
$subheading = "<div id='subtitle'>{$this->subheading}</div>";
|
||||
}
|
||||
|
||||
$site_name = $config->get_string('title'); // bzchan: change from normal default to get title for top of page
|
||||
$main_page = $config->get_string('main_page'); // bzchan: change from normal default to get main page for top of page
|
||||
|
||||
// bzchan: CUSTOM LINKS are prepared here, change these to whatever you like
|
||||
$custom_links = "";
|
||||
$custom_links .= "<li><a href='".make_link('user')."'>My Account</a></li>";
|
||||
$custom_links .= "<li><a href='".make_link('post/list')."'>Posts</a></li>";
|
||||
$custom_links .= "<li><a href='".make_link('comment/list')."'>Comments</a></li>";
|
||||
$custom_links .= "<li><a href='".make_link('tags')."'>Tags</a></li>";
|
||||
$custom_links .= "<li><a href='".make_link('upload')."'>Upload</a></li>";
|
||||
$custom_links .= "<li><a href='".make_link('wiki')."'>Wiki</a></li>";
|
||||
$custom_links .= "<li><a href='".make_link('wiki/more')."'>More »</a></li>";
|
||||
|
||||
$custom_sublinks = "";
|
||||
// hack
|
||||
global $user;
|
||||
$username = url_escape($user->name);
|
||||
// hack
|
||||
$qp = _get_query_parts();
|
||||
// php sucks
|
||||
switch($qp[0]) {
|
||||
default:
|
||||
$custom_sublinks .= $user_block_html;
|
||||
break;
|
||||
case "post":
|
||||
case "comment":
|
||||
case "upload":
|
||||
$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("wiki/posts")."'>Help</a></li>";
|
||||
break;
|
||||
case "wiki":
|
||||
$custom_sublinks .= "<li><a href='".make_link('wiki')."'>Index</a></li>";
|
||||
$custom_sublinks .= "<li><a href='".make_link("wiki/rules")."'>Rules</a></li>";
|
||||
$custom_sublinks .= "<li><a href='".make_link("wiki/wiki")."'>Help</a></li>";
|
||||
break;
|
||||
case "tags":
|
||||
$custom_sublinks .= "<li><a href='".make_link('tags/map')."'>Map</a></li>";
|
||||
$custom_sublinks .= "<li><a href='".make_link('tags/alphabetic')."'>Alphabetic</a></li>";
|
||||
$custom_sublinks .= "<li><a href='".make_link('tags/popularity')."'>Popularity</a></li>";
|
||||
$custom_sublinks .= "<li><a href='".make_link('tags/categories')."'>Categories</a></li>";
|
||||
$custom_sublinks .= "<li><a href='".make_link('alias/list')."'>Aliases</a></li>";
|
||||
$custom_sublinks .= "<li><a href='".make_link("wiki/tags")."'>Help</a></li>";
|
||||
break;
|
||||
}
|
||||
|
||||
// bzchan: failed attempt to add heading after title_link (failure was it looked bad)
|
||||
//if($this->heading==$site_name)$this->heading = '';
|
||||
//$title_link = "<h1><a href='".make_link($main_page)."'>$site_name</a>/$this->heading</h1>";
|
||||
|
||||
// bzchan: prepare main title link
|
||||
$title_link = "<h1 id='site-title'><a href='".make_link($main_page)."'>$site_name</a></h1>";
|
||||
|
||||
if($page->left_enabled) {
|
||||
$left = "<div id='nav'>$left_block_html</div>";
|
||||
$withleft = "withleft";
|
||||
}
|
||||
else {
|
||||
$left = "";
|
||||
$withleft = "noleft";
|
||||
}
|
||||
|
||||
print <<<EOD
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html>
|
||||
<head>
|
||||
<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
|
||||
<script src='$data_href/themes/$theme_name/sidebar.js' type='text/javascript'></script>
|
||||
<script src='$data_href/themes/$theme_name/script.js' type='text/javascript'></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="header">
|
||||
$title_link
|
||||
<ul id="navbar" class="flat-list">
|
||||
$custom_links
|
||||
</ul>
|
||||
<ul id="subnavbar" class="flat-list">
|
||||
$custom_sublinks
|
||||
</ul>
|
||||
</div>
|
||||
$subheading
|
||||
|
||||
$left
|
||||
<div id="body" class="$withleft">$main_block_html</div>
|
||||
|
||||
<div id="footer">
|
||||
<em>
|
||||
Images © their respective owners,
|
||||
<a href="http://code.shishnet.org/shimmie2/">$version</a> ©
|
||||
<a href="http://www.shishnet.org/">Shish</a> 2007-2009,
|
||||
based on the Danbooru concept.
|
||||
$debug
|
||||
$contact
|
||||
</em>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
EOD;
|
||||
}
|
||||
|
||||
function block_to_html($block, $hidable=false) {
|
||||
$h = $block->header;
|
||||
$s = $block->section;
|
||||
$b = $block->body;
|
||||
$html = "";
|
||||
if($hidable) {
|
||||
$i = str_replace(' ', '_', $h.$s);
|
||||
if(!is_null($h)) $html .= "\n<h3 id='$i-toggle' onclick=\"toggle('$i')\">$h</h3>\n";
|
||||
if(!is_null($b)) $html .= "<div id='$i'>$b</div>\n";
|
||||
}
|
||||
else {
|
||||
$i = str_replace(' ', '_', $h.$s);
|
||||
if(!is_null($h)) $html .= "\n<h3>$h</h3>\n";
|
||||
if(!is_null($b)) $html .= "<div id='$i'>$b</div>\n";
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
Loading…
x
Reference in New Issue
Block a user