more dos2unix

This commit is contained in:
Shish 2009-11-24 14:12:20 +00:00
parent 95eadbdd1f
commit 578a1e46fb
3 changed files with 694 additions and 694 deletions

View File

@ -1,121 +1,121 @@
<?php <?php
/** /**
V4.50 6 July 2004 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. 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. Released under both BSD license and Lesser GPL library license.
Whenever there is any discrepancy between the two licenses, Whenever there is any discrepancy between the two licenses,
the BSD license will take precedence. the BSD license will take precedence.
Set tabs to 4 for best viewing. Set tabs to 4 for best viewing.
Modified from datadict-generic.inc.php for sapdb by RalfBecker-AT-outdoor-training.de Modified from datadict-generic.inc.php for sapdb by RalfBecker-AT-outdoor-training.de
*/ */
// security - hide paths // security - hide paths
if (!defined('ADODB_DIR')) die(); if (!defined('ADODB_DIR')) die();
class ADODB2_sapdb extends ADODB_DataDict { class ADODB2_sapdb extends ADODB_DataDict {
var $databaseType = 'sapdb'; var $databaseType = 'sapdb';
var $seqField = false; var $seqField = false;
var $renameColumn = 'RENAME COLUMN %s.%s TO %s'; var $renameColumn = 'RENAME COLUMN %s.%s TO %s';
function ActualType($meta) function ActualType($meta)
{ {
switch($meta) { switch($meta) {
case 'C': return 'VARCHAR'; case 'C': return 'VARCHAR';
case 'XL': case 'XL':
case 'X': return 'LONG'; case 'X': return 'LONG';
case 'C2': return 'VARCHAR UNICODE'; case 'C2': return 'VARCHAR UNICODE';
case 'X2': return 'LONG UNICODE'; case 'X2': return 'LONG UNICODE';
case 'B': return 'LONG'; case 'B': return 'LONG';
case 'D': return 'DATE'; case 'D': return 'DATE';
case 'T': return 'TIMESTAMP'; case 'T': return 'TIMESTAMP';
case 'L': return 'BOOLEAN'; case 'L': return 'BOOLEAN';
case 'I': return 'INTEGER'; case 'I': return 'INTEGER';
case 'I1': return 'FIXED(3)'; case 'I1': return 'FIXED(3)';
case 'I2': return 'SMALLINT'; case 'I2': return 'SMALLINT';
case 'I4': return 'INTEGER'; case 'I4': return 'INTEGER';
case 'I8': return 'FIXED(20)'; case 'I8': return 'FIXED(20)';
case 'F': return 'FLOAT(38)'; case 'F': return 'FLOAT(38)';
case 'N': return 'FIXED'; case 'N': return 'FIXED';
default: default:
return $meta; return $meta;
} }
} }
function MetaType($t,$len=-1,$fieldobj=false) function MetaType($t,$len=-1,$fieldobj=false)
{ {
if (is_object($t)) { if (is_object($t)) {
$fieldobj = $t; $fieldobj = $t;
$t = $fieldobj->type; $t = $fieldobj->type;
$len = $fieldobj->max_length; $len = $fieldobj->max_length;
} }
static $maxdb_type2adodb = array( static $maxdb_type2adodb = array(
'VARCHAR' => 'C', 'VARCHAR' => 'C',
'CHARACTER' => 'C', 'CHARACTER' => 'C',
'LONG' => 'X', // no way to differ between 'X' and 'B' :-( 'LONG' => 'X', // no way to differ between 'X' and 'B' :-(
'DATE' => 'D', 'DATE' => 'D',
'TIMESTAMP' => 'T', 'TIMESTAMP' => 'T',
'BOOLEAN' => 'L', 'BOOLEAN' => 'L',
'INTEGER' => 'I4', 'INTEGER' => 'I4',
'SMALLINT' => 'I2', 'SMALLINT' => 'I2',
'FLOAT' => 'F', 'FLOAT' => 'F',
'FIXED' => 'N', 'FIXED' => 'N',
); );
$type = isset($maxdb_type2adodb[$t]) ? $maxdb_type2adodb[$t] : 'C'; $type = isset($maxdb_type2adodb[$t]) ? $maxdb_type2adodb[$t] : 'C';
// convert integer-types simulated with fixed back to integer // convert integer-types simulated with fixed back to integer
if ($t == 'FIXED' && !$fieldobj->scale && ($len == 20 || $len == 3)) { if ($t == 'FIXED' && !$fieldobj->scale && ($len == 20 || $len == 3)) {
$type = $len == 20 ? 'I8' : 'I1'; $type = $len == 20 ? 'I8' : 'I1';
} }
if ($fieldobj->auto_increment) $type = 'R'; if ($fieldobj->auto_increment) $type = 'R';
return $type; return $type;
} }
// return string must begin with space // return string must begin with space
function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned) function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned)
{ {
$suffix = ''; $suffix = '';
if ($funsigned) $suffix .= ' UNSIGNED'; if ($funsigned) $suffix .= ' UNSIGNED';
if ($fnotnull) $suffix .= ' NOT NULL'; if ($fnotnull) $suffix .= ' NOT NULL';
if ($fautoinc) $suffix .= ' DEFAULT SERIAL'; if ($fautoinc) $suffix .= ' DEFAULT SERIAL';
elseif (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; elseif (strlen($fdefault)) $suffix .= " DEFAULT $fdefault";
if ($fconstraint) $suffix .= ' '.$fconstraint; if ($fconstraint) $suffix .= ' '.$fconstraint;
return $suffix; return $suffix;
} }
function AddColumnSQL($tabname, $flds) function AddColumnSQL($tabname, $flds)
{ {
$tabname = $this->TableName ($tabname); $tabname = $this->TableName ($tabname);
$sql = array(); $sql = array();
list($lines,$pkey) = $this->_GenFields($flds); list($lines,$pkey) = $this->_GenFields($flds);
return array( 'ALTER TABLE ' . $tabname . ' ADD (' . implode(', ',$lines) . ')' ); return array( 'ALTER TABLE ' . $tabname . ' ADD (' . implode(', ',$lines) . ')' );
} }
function AlterColumnSQL($tabname, $flds) function AlterColumnSQL($tabname, $flds)
{ {
$tabname = $this->TableName ($tabname); $tabname = $this->TableName ($tabname);
$sql = array(); $sql = array();
list($lines,$pkey) = $this->_GenFields($flds); list($lines,$pkey) = $this->_GenFields($flds);
return array( 'ALTER TABLE ' . $tabname . ' MODIFY (' . implode(', ',$lines) . ')' ); return array( 'ALTER TABLE ' . $tabname . ' MODIFY (' . implode(', ',$lines) . ')' );
} }
function DropColumnSQL($tabname, $flds) function DropColumnSQL($tabname, $flds)
{ {
$tabname = $this->TableName ($tabname); $tabname = $this->TableName ($tabname);
if (!is_array($flds)) $flds = explode(',',$flds); if (!is_array($flds)) $flds = explode(',',$flds);
foreach($flds as $k => $v) { foreach($flds as $k => $v) {
$flds[$k] = $this->NameQuote($v); $flds[$k] = $this->NameQuote($v);
} }
return array( 'ALTER TABLE ' . $tabname . ' DROP (' . implode(', ',$flds) . ')' ); return array( 'ALTER TABLE ' . $tabname . ' DROP (' . implode(', ',$flds) . ')' );
} }
} }
?> ?>

View File

@ -1,356 +1,356 @@
<?php <?php
/** /**
* 01.26.2006 12:29:28est * 01.26.2006 12:29:28est
* *
* Akismet PHP4 class * Akismet PHP4 class
* *
* <b>Usage</b> * <b>Usage</b>
* <code> * <code>
* $comment = array( * $comment = array(
* 'author' => 'viagra-test-123', * 'author' => 'viagra-test-123',
* 'email' => 'test@example.com', * 'email' => 'test@example.com',
* 'website' => 'http://www.example.com/', * 'website' => 'http://www.example.com/',
* 'body' => 'This is a test comment', * 'body' => 'This is a test comment',
* 'permalink' => 'http://yourdomain.com/yourblogpost.url', * 'permalink' => 'http://yourdomain.com/yourblogpost.url',
* ); * );
* *
* $akismet = new Akismet('http://www.yourdomain.com/', 'YOUR_WORDPRESS_API_KEY', $comment); * $akismet = new Akismet('http://www.yourdomain.com/', 'YOUR_WORDPRESS_API_KEY', $comment);
* *
* if($akismet->isError()) { * if($akismet->isError()) {
* echo"Couldn't connected to Akismet server!"; * echo"Couldn't connected to Akismet server!";
* } else { * } else {
* if($akismet->isSpam()) { * if($akismet->isSpam()) {
* echo"Spam detected"; * echo"Spam detected";
* } else { * } else {
* echo"yay, no spam!"; * echo"yay, no spam!";
* } * }
* } * }
* </code> * </code>
* *
* @author Bret Kuhns {@link www.miphp.net} * @author Bret Kuhns {@link www.miphp.net}
* @link http://www.miphp.net/blog/view/php4_akismet_class/ * @link http://www.miphp.net/blog/view/php4_akismet_class/
* @version 0.3.3 * @version 0.3.3
* @license http://www.opensource.org/licenses/mit-license.php MIT License * @license http://www.opensource.org/licenses/mit-license.php MIT License
*/ */
// Error constants // Error constants
define("AKISMET_SERVER_NOT_FOUND", 0); define("AKISMET_SERVER_NOT_FOUND", 0);
define("AKISMET_RESPONSE_FAILED", 1); define("AKISMET_RESPONSE_FAILED", 1);
define("AKISMET_INVALID_KEY", 2); define("AKISMET_INVALID_KEY", 2);
// Base class to assist in error handling between Akismet classes // Base class to assist in error handling between Akismet classes
class AkismetObject { class AkismetObject {
var $errors = array(); var $errors = array();
/** /**
* Add a new error to the errors array in the object * Add a new error to the errors array in the object
* *
* @param String $name A name (array key) for the error * @param String $name A name (array key) for the error
* @param String $string The error message * @param String $string The error message
* @return void * @return void
*/ */
// Set an error in the object // Set an error in the object
function setError($name, $message) { function setError($name, $message) {
$this->errors[$name] = $message; $this->errors[$name] = $message;
} }
/** /**
* Return a specific error message from the errors array * Return a specific error message from the errors array
* *
* @param String $name The name of the error you want * @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 * @return mixed Returns a String if the error exists, a false boolean if it does not exist
*/ */
function getError($name) { function getError($name) {
if($this->isError($name)) { if($this->isError($name)) {
return $this->errors[$name]; return $this->errors[$name];
} else { } else {
return false; return false;
} }
} }
/** /**
* Return all errors in the object * Return all errors in the object
* *
* @return String[] * @return String[]
*/ */
function getErrors() { function getErrors() {
return (array)$this->errors; return (array)$this->errors;
} }
/** /**
* Check if a certain error exists * Check if a certain error exists
* *
* @param String $name The name of the error you want * @param String $name The name of the error you want
* @return boolean * @return boolean
*/ */
function isError($name) { function isError($name) {
return isset($this->errors[$name]); return isset($this->errors[$name]);
} }
/** /**
* Check if any errors exist * Check if any errors exist
* *
* @return boolean * @return boolean
*/ */
function errorsExist() { function errorsExist() {
return (count($this->errors) > 0); return (count($this->errors) > 0);
} }
} }
// Used by the Akismet class to communicate with the Akismet service // Used by the Akismet class to communicate with the Akismet service
class AkismetHttpClient extends AkismetObject { class AkismetHttpClient extends AkismetObject {
var $akismetVersion = '1.1'; var $akismetVersion = '1.1';
var $con; var $con;
var $host; var $host;
var $port; var $port;
var $apiKey; var $apiKey;
var $blogUrl; var $blogUrl;
var $errors = array(); var $errors = array();
// Constructor // Constructor
function AkismetHttpClient($host, $blogUrl, $apiKey, $port = 80) { function AkismetHttpClient($host, $blogUrl, $apiKey, $port = 80) {
$this->host = $host; $this->host = $host;
$this->port = $port; $this->port = $port;
$this->blogUrl = $blogUrl; $this->blogUrl = $blogUrl;
$this->apiKey = $apiKey; $this->apiKey = $apiKey;
} }
// Use the connection active in $con to get a response from the server and return that response // 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) { function getResponse($request, $path, $type = "post", $responseLength = 1160) {
$this->_connect(); $this->_connect();
if($this->con && !$this->isError(AKISMET_SERVER_NOT_FOUND)) { if($this->con && !$this->isError(AKISMET_SERVER_NOT_FOUND)) {
$request = $request =
strToUpper($type)." /{$this->akismetVersion}/$path HTTP/1.1\r\n" . strToUpper($type)." /{$this->akismetVersion}/$path HTTP/1.1\r\n" .
"Host: ".((!empty($this->apiKey)) ? $this->apiKey."." : null)."{$this->host}\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-Type: application/x-www-form-urlencoded; charset=utf-8\r\n" .
"Content-Length: ".strlen($request)."\r\n" . "Content-Length: ".strlen($request)."\r\n" .
"User-Agent: Akismet PHP4 Class\r\n" . "User-Agent: Akismet PHP4 Class\r\n" .
"\r\n" . "\r\n" .
$request $request
; ;
$response = ""; $response = "";
@fwrite($this->con, $request); @fwrite($this->con, $request);
while(!feof($this->con)) { while(!feof($this->con)) {
$response .= @fgets($this->con, $responseLength); $response .= @fgets($this->con, $responseLength);
} }
$response = explode("\r\n\r\n", $response, 2); $response = explode("\r\n\r\n", $response, 2);
return $response[1]; return $response[1];
} else { } else {
$this->setError(AKISMET_RESPONSE_FAILED, "The response could not be retrieved."); $this->setError(AKISMET_RESPONSE_FAILED, "The response could not be retrieved.");
} }
$this->_disconnect(); $this->_disconnect();
} }
// Connect to the Akismet server and store that connection in the instance variable $con // Connect to the Akismet server and store that connection in the instance variable $con
function _connect() { function _connect() {
if(!($this->con = @fsockopen($this->host, $this->port))) { if(!($this->con = @fsockopen($this->host, $this->port))) {
$this->setError(AKISMET_SERVER_NOT_FOUND, "Could not connect to akismet server."); $this->setError(AKISMET_SERVER_NOT_FOUND, "Could not connect to akismet server.");
} }
} }
// Close the connection to the Akismet server // Close the connection to the Akismet server
function _disconnect() { function _disconnect() {
@fclose($this->con); @fclose($this->con);
} }
} }
// The controlling class. This is the ONLY class the user should instantiate in // The controlling class. This is the ONLY class the user should instantiate in
// order to use the Akismet service! // order to use the Akismet service!
class Akismet extends AkismetObject { class Akismet extends AkismetObject {
var $apiPort = 80; var $apiPort = 80;
var $akismetServer = 'rest.akismet.com'; var $akismetServer = 'rest.akismet.com';
var $akismetVersion = '1.1'; var $akismetVersion = '1.1';
var $http; var $http;
var $ignore = array( var $ignore = array(
'HTTP_COOKIE', 'HTTP_COOKIE',
'HTTP_X_FORWARDED_FOR', 'HTTP_X_FORWARDED_FOR',
'HTTP_X_FORWARDED_HOST', 'HTTP_X_FORWARDED_HOST',
'HTTP_MAX_FORWARDS', 'HTTP_MAX_FORWARDS',
'HTTP_X_FORWARDED_SERVER', 'HTTP_X_FORWARDED_SERVER',
'REDIRECT_STATUS', 'REDIRECT_STATUS',
'SERVER_PORT', 'SERVER_PORT',
'PATH', 'PATH',
'DOCUMENT_ROOT', 'DOCUMENT_ROOT',
'SERVER_ADMIN', 'SERVER_ADMIN',
'QUERY_STRING', 'QUERY_STRING',
'PHP_SELF' 'PHP_SELF'
); );
var $blogUrl = ""; var $blogUrl = "";
var $apiKey = ""; var $apiKey = "";
var $comment = array(); var $comment = array();
/** /**
* Constructor * Constructor
* *
* Set instance variables, connect to Akismet, and check API key * Set instance variables, connect to Akismet, and check API key
* *
* @param String $blogUrl The URL to your own blog * @param String $blogUrl The URL to your own blog
* @param String $apiKey Your wordpress API key * @param String $apiKey Your wordpress API key
* @param String[] $comment A formatted comment array to be examined by the Akismet service * @param String[] $comment A formatted comment array to be examined by the Akismet service
*/ */
function Akismet($blogUrl, $apiKey, $comment) { function Akismet($blogUrl, $apiKey, $comment) {
$this->blogUrl = $blogUrl; $this->blogUrl = $blogUrl;
$this->apiKey = $apiKey; $this->apiKey = $apiKey;
// Populate the comment array with information needed by Akismet // Populate the comment array with information needed by Akismet
$this->comment = $comment; $this->comment = $comment;
$this->_formatCommentArray(); $this->_formatCommentArray();
if(!isset($this->comment['user_ip'])) { if(!isset($this->comment['user_ip'])) {
$this->comment['user_ip'] = ($_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR')) ? $_SERVER['REMOTE_ADDR'] : getenv('HTTP_X_FORWARDED_FOR'); $this->comment['user_ip'] = ($_SERVER['REMOTE_ADDR'] != getenv('SERVER_ADDR')) ? $_SERVER['REMOTE_ADDR'] : getenv('HTTP_X_FORWARDED_FOR');
} }
if(!isset($this->comment['user_agent'])) { if(!isset($this->comment['user_agent'])) {
$this->comment['user_agent'] = $_SERVER['HTTP_USER_AGENT']; $this->comment['user_agent'] = $_SERVER['HTTP_USER_AGENT'];
} }
if(!isset($this->comment['referrer'])) { if(!isset($this->comment['referrer'])) {
$this->comment['referrer'] = $_SERVER['HTTP_REFERER']; $this->comment['referrer'] = $_SERVER['HTTP_REFERER'];
} }
$this->comment['blog'] = $blogUrl; $this->comment['blog'] = $blogUrl;
// Connect to the Akismet server and populate errors if they exist // Connect to the Akismet server and populate errors if they exist
$this->http = new AkismetHttpClient($this->akismetServer, $blogUrl, $apiKey); $this->http = new AkismetHttpClient($this->akismetServer, $blogUrl, $apiKey);
if($this->http->errorsExist()) { if($this->http->errorsExist()) {
$this->errors = array_merge($this->errors, $this->http->getErrors()); $this->errors = array_merge($this->errors, $this->http->getErrors());
} }
// Check if the API key is valid // Check if the API key is valid
if(!$this->_isValidApiKey($apiKey)) { if(!$this->_isValidApiKey($apiKey)) {
$this->setError(AKISMET_INVALID_KEY, "Your Akismet API key is not valid."); $this->setError(AKISMET_INVALID_KEY, "Your Akismet API key is not valid.");
} }
} }
/** /**
* Query the Akismet and determine if the comment is spam or not * Query the Akismet and determine if the comment is spam or not
* *
* @return boolean * @return boolean
*/ */
function isSpam() { function isSpam() {
$response = $this->http->getResponse($this->_getQueryString(), 'comment-check'); $response = $this->http->getResponse($this->_getQueryString(), 'comment-check');
return ($response == "true"); return ($response == "true");
} }
/** /**
* Submit this comment as an unchecked spam to the Akismet server * Submit this comment as an unchecked spam to the Akismet server
* *
* @return void * @return void
*/ */
function submitSpam() { function submitSpam() {
$this->http->getResponse($this->_getQueryString(), 'submit-spam'); $this->http->getResponse($this->_getQueryString(), 'submit-spam');
} }
/** /**
* Submit a false-positive comment as "ham" to the Akismet server * Submit a false-positive comment as "ham" to the Akismet server
* *
* @return void * @return void
*/ */
function submitHam() { function submitHam() {
$this->http->getResponse($this->_getQueryString(), 'submit-ham'); $this->http->getResponse($this->_getQueryString(), 'submit-ham');
} }
/** /**
* Check with the Akismet server to determine if the API key is valid * Check with the Akismet server to determine if the API key is valid
* *
* @access Protected * @access Protected
* @param String $key The Wordpress API key passed from the constructor argument * @param String $key The Wordpress API key passed from the constructor argument
* @return boolean * @return boolean
*/ */
function _isValidApiKey($key) { function _isValidApiKey($key) {
$keyCheck = $this->http->getResponse("key=".$this->apiKey."&blog=".$this->blogUrl, 'verify-key'); $keyCheck = $this->http->getResponse("key=".$this->apiKey."&blog=".$this->blogUrl, 'verify-key');
return ($keyCheck == "valid"); return ($keyCheck == "valid");
} }
/** /**
* Format the comment array in accordance to the Akismet API * Format the comment array in accordance to the Akismet API
* *
* @access Protected * @access Protected
* @return void * @return void
*/ */
function _formatCommentArray() { function _formatCommentArray() {
$format = array( $format = array(
'type' => 'comment_type', 'type' => 'comment_type',
'author' => 'comment_author', 'author' => 'comment_author',
'email' => 'comment_author_email', 'email' => 'comment_author_email',
'website' => 'comment_author_url', 'website' => 'comment_author_url',
'body' => 'comment_content' 'body' => 'comment_content'
); );
foreach($format as $short => $long) { foreach($format as $short => $long) {
if(isset($this->comment[$short])) { if(isset($this->comment[$short])) {
$this->comment[$long] = $this->comment[$short]; $this->comment[$long] = $this->comment[$short];
unset($this->comment[$short]); unset($this->comment[$short]);
} }
} }
} }
/** /**
* Build a query string for use with HTTP requests * Build a query string for use with HTTP requests
* *
* @access Protected * @access Protected
* @return String * @return String
*/ */
function _getQueryString() { function _getQueryString() {
foreach($_SERVER as $key => $value) { foreach($_SERVER as $key => $value) {
if(!in_array($key, $this->ignore)) { if(!in_array($key, $this->ignore)) {
if($key == 'REMOTE_ADDR') { if($key == 'REMOTE_ADDR') {
$this->comment[$key] = $this->comment['user_ip']; $this->comment[$key] = $this->comment['user_ip'];
} else { } else {
$this->comment[$key] = $value; $this->comment[$key] = $value;
} }
} }
} }
$query_string = ''; $query_string = '';
foreach($this->comment as $key => $data) { foreach($this->comment as $key => $data) {
if(is_string($data)) { if(is_string($data)) {
$query_string .= $key . '=' . urlencode(stripslashes($data)) . '&'; $query_string .= $key . '=' . urlencode(stripslashes($data)) . '&';
} }
} }
return $query_string; return $query_string;
} }
} }
?> ?>

View File

@ -1,218 +1,218 @@
<?php <?php
/** /**
* Name: Danbooru Theme * Name: Danbooru Theme
* Author: Bzchan <bzchan@animemahou.com> * Author: Bzchan <bzchan@animemahou.com>
* Link: http://trac.shishnet.org/shimmie2/ * Link: http://trac.shishnet.org/shimmie2/
* License: GPLv2 * License: GPLv2
* Description: This is a simple theme changing the css to make shimme * Description: This is a simple theme changing the css to make shimme
* look more like danbooru as well as adding a custom links * look more like danbooru as well as adding a custom links
* bar and title to the top of every page. * bar and title to the top of every page.
*/ */
//Small changes added by zshall <http://seemslegit.com> //Small changes added by zshall <http://seemslegit.com>
//Changed CSS and layout to make shimmie look even more like danbooru //Changed CSS and layout to make shimmie look even more like danbooru
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
Danbooru Theme - Notes (Bzchan) Danbooru Theme - Notes (Bzchan)
Files: default.php, sidebar.js, style.css Files: default.php, sidebar.js, style.css
How to use a theme How to use a theme
- Copy the danbooru folder with all its contained files into the "themes" - Copy the danbooru folder with all its contained files into the "themes"
directory in your shimmie installation. directory in your shimmie installation.
- Log into your shimmie and change the Theme in the Board Config to your - Log into your shimmie and change the Theme in the Board Config to your
desired theme. desired theme.
Changes in this theme include Changes in this theme include
- Adding and editing various elements in the style.css file. - Adding and editing various elements in the style.css file.
- $site_name and $front_name retreival from config added. - $site_name and $front_name retreival from config added.
- $custom_link and $title_link preparation just before html is outputed. - $custom_link and $title_link preparation just before html is outputed.
- Altered outputed html to include the custom links and removed heading - Altered outputed html to include the custom links and removed heading
from being displayed (subheading is still displayed) from being displayed (subheading is still displayed)
- Note that only the sidebar has been left aligned. Could not properly - Note that only the sidebar has been left aligned. Could not properly
left align the main block because blocks without headers currently do left align the main block because blocks without headers currently do
not have ids on there div elements. (this was a problem because not have ids on there div elements. (this was a problem because
paginator block must be centered and everything else left aligned) paginator block must be centered and everything else left aligned)
Tips Tips
- You can change custom links to point to whatever pages you want as well as adding - You can change custom links to point to whatever pages you want as well as adding
more custom links. more custom links.
- The main title link points to the Front Page set in your Board Config options. - 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. - 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 - Themes make no changes to your database or main code files so you can switch
back and forward to other themes all you like. back and forward to other themes all you like.
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
class Layout { class Layout {
public function display_page($page) { public function display_page($page) {
global $config; global $config;
$theme_name = $config->get_string('theme'); $theme_name = $config->get_string('theme');
$base_href = $config->get_string('base_href'); $base_href = $config->get_string('base_href');
$data_href = get_base_href(); $data_href = get_base_href();
$contact_link = $config->get_string('contact_link'); $contact_link = $config->get_string('contact_link');
$version = "Shimmie-".VERSION; $version = "Shimmie-".VERSION;
$header_html = ""; $header_html = "";
foreach($page->headers as $line) { foreach($page->headers as $line) {
$header_html .= "\t\t$line\n"; $header_html .= "\t\t$line\n";
} }
$left_block_html = ""; $left_block_html = "";
$user_block_html = ""; $user_block_html = "";
$main_block_html = ""; $main_block_html = "";
foreach($page->blocks as $block) { foreach($page->blocks as $block) {
switch($block->section) { switch($block->section) {
case "left": case "left":
$left_block_html .= $this->block_to_html($block, true); $left_block_html .= $this->block_to_html($block, true);
break; break;
case "user": case "user":
$user_block_html .= $block->body; // $this->block_to_html($block, true); $user_block_html .= $block->body; // $this->block_to_html($block, true);
break; break;
case "main": case "main":
if($block->header == "Images") { if($block->header == "Images") {
$block->header = "&nbsp;"; $block->header = "&nbsp;";
} }
$main_block_html .= $this->block_to_html($block, false); $main_block_html .= $this->block_to_html($block, false);
break; break;
default: default:
print "<p>error: {$block->header} using an unknown section ({$block->section})"; print "<p>error: {$block->header} using an unknown section ({$block->section})";
break; break;
} }
} }
$debug = get_debug_info(); $debug = get_debug_info();
$contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>"; $contact = empty($contact_link) ? "" : "<br><a href='$contact_link'>Contact</a>";
if(empty($this->subheading)) { if(empty($this->subheading)) {
$subheading = ""; $subheading = "";
} }
else { else {
$subheading = "<div id='subtitle'>{$this->subheading}</div>"; $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 $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 $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 // bzchan: CUSTOM LINKS are prepared here, change these to whatever you like
$custom_links = ""; $custom_links = "";
$custom_links .= "<li><a href='".make_link('user')."'>My Account</a></li>"; $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('post/list')."'>Posts</a></li>";
$custom_links .= "<li><a href='".make_link('comment/list')."'>Comments</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('tags')."'>Tags</a></li>";
$custom_links .= "<li><a href='".make_link('upload')."'>Upload</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')."'>Wiki</a></li>";
$custom_links .= "<li><a href='".make_link('wiki/more')."'>More &raquo;</a></li>"; $custom_links .= "<li><a href='".make_link('wiki/more')."'>More &raquo;</a></li>";
$custom_sublinks = ""; $custom_sublinks = "";
// hack // hack
global $user; global $user;
$username = url_escape($user->name); $username = url_escape($user->name);
// hack // hack
$qp = _get_query_parts(); $qp = _get_query_parts();
// php sucks // php sucks
switch($qp[0]) { switch($qp[0]) {
default: default:
$custom_sublinks .= $user_block_html; $custom_sublinks .= $user_block_html;
break; break;
case "post": case "post":
case "comment": case "comment":
case "upload": case "upload":
$custom_sublinks .= "<li><a href='".make_link('post/list')."'>All</a></li>"; $custom_sublinks .= "<li><a href='".make_link('post/list')."'>All</a></li>";
$custom_sublinks .= "<li><a href='".make_link("post/list/favorited_by=$username/1")."'>My Favorites</a></li>"; $custom_sublinks .= "<li><a href='".make_link("post/list/favorited_by=$username/1")."'>My Favorites</a></li>";
$custom_sublinks .= "<li><a href='".make_link("wiki/posts")."'>Help</a></li>"; $custom_sublinks .= "<li><a href='".make_link("wiki/posts")."'>Help</a></li>";
break; break;
case "wiki": case "wiki":
$custom_sublinks .= "<li><a href='".make_link('wiki')."'>Index</a></li>"; $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/rules")."'>Rules</a></li>";
$custom_sublinks .= "<li><a href='".make_link("wiki/wiki")."'>Help</a></li>"; $custom_sublinks .= "<li><a href='".make_link("wiki/wiki")."'>Help</a></li>";
break; break;
case "tags": case "tags":
$custom_sublinks .= "<li><a href='".make_link('tags/map')."'>Map</a></li>"; $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/alphabetic')."'>Alphabetic</a></li>";
$custom_sublinks .= "<li><a href='".make_link('tags/popularity')."'>Popularity</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('tags/categories')."'>Categories</a></li>";
$custom_sublinks .= "<li><a href='".make_link('alias/list')."'>Aliases</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>"; $custom_sublinks .= "<li><a href='".make_link("wiki/tags")."'>Help</a></li>";
break; break;
} }
// bzchan: failed attempt to add heading after title_link (failure was it looked bad) // bzchan: failed attempt to add heading after title_link (failure was it looked bad)
//if($this->heading==$site_name)$this->heading = ''; //if($this->heading==$site_name)$this->heading = '';
//$title_link = "<h1><a href='".make_link($main_page)."'>$site_name</a>/$this->heading</h1>"; //$title_link = "<h1><a href='".make_link($main_page)."'>$site_name</a>/$this->heading</h1>";
// bzchan: prepare main title link // bzchan: prepare main title link
$title_link = "<h1 id='site-title'><a href='".make_link($main_page)."'>$site_name</a></h1>"; $title_link = "<h1 id='site-title'><a href='".make_link($main_page)."'>$site_name</a></h1>";
if($page->left_enabled) { if($page->left_enabled) {
$left = "<div id='nav'>$left_block_html</div>"; $left = "<div id='nav'>$left_block_html</div>";
$withleft = "withleft"; $withleft = "withleft";
} }
else { else {
$left = ""; $left = "";
$withleft = "noleft"; $withleft = "noleft";
} }
print <<<EOD print <<<EOD
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
<html> <html>
<head> <head>
<title>{$page->title}</title> <title>{$page->title}</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8"> <meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<link rel="stylesheet" href="$data_href/themes/$theme_name/style.css" type="text/css"> <link rel="stylesheet" href="$data_href/themes/$theme_name/style.css" type="text/css">
$header_html $header_html
<script src='$data_href/themes/$theme_name/sidebar.js' type='text/javascript'></script> <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> <script src='$data_href/themes/$theme_name/script.js' type='text/javascript'></script>
</head> </head>
<body> <body>
<div id="header"> <div id="header">
$title_link $title_link
<ul id="navbar" class="flat-list"> <ul id="navbar" class="flat-list">
$custom_links $custom_links
</ul> </ul>
<ul id="subnavbar" class="flat-list"> <ul id="subnavbar" class="flat-list">
$custom_sublinks $custom_sublinks
</ul> </ul>
</div> </div>
$subheading $subheading
$left $left
<div id="body" class="$withleft">$main_block_html</div> <div id="body" class="$withleft">$main_block_html</div>
<div id="footer"> <div id="footer">
<em> <em>
Images &copy; their respective owners, Images &copy; their respective owners,
<a href="http://code.shishnet.org/shimmie2/">$version</a> &copy; <a href="http://code.shishnet.org/shimmie2/">$version</a> &copy;
<a href="http://www.shishnet.org/">Shish</a> 2007-2009, <a href="http://www.shishnet.org/">Shish</a> 2007-2009,
based on the Danbooru concept. based on the Danbooru concept.
$debug $debug
$contact $contact
</em> </em>
</div> </div>
</body> </body>
</html> </html>
EOD; EOD;
} }
function block_to_html($block, $hidable=false) { function block_to_html($block, $hidable=false) {
$h = $block->header; $h = $block->header;
$s = $block->section; $s = $block->section;
$b = $block->body; $b = $block->body;
$html = ""; $html = "";
if($hidable) { if($hidable) {
$i = str_replace(' ', '_', $h.$s); $i = str_replace(' ', '_', $h.$s);
if(!is_null($h)) $html .= "\n<h3 id='$i-toggle' onclick=\"toggle('$i')\">$h</h3>\n"; 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"; if(!is_null($b)) $html .= "<div id='$i'>$b</div>\n";
} }
else { else {
$i = str_replace(' ', '_', $h.$s); $i = str_replace(' ', '_', $h.$s);
if(!is_null($h)) $html .= "\n<h3>$h</h3>\n"; if(!is_null($h)) $html .= "\n<h3>$h</h3>\n";
if(!is_null($b)) $html .= "<div id='$i'>$b</div>\n"; if(!is_null($b)) $html .= "<div id='$i'>$b</div>\n";
} }
return $html; return $html;
} }
} }
?> ?>