Merge branch 'master' of git://github.com/shish/shimmie2
This commit is contained in:
commit
1ccc26ebd4
29 changed files with 236 additions and 182 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -7,6 +7,7 @@ sql.log
|
|||
shimmie.log
|
||||
!lib/images
|
||||
ext/admin
|
||||
ext/amazon_s3
|
||||
ext/artists
|
||||
ext/autocomplete
|
||||
ext/ban_words
|
||||
|
@ -28,6 +29,7 @@ ext/handle_flash
|
|||
ext/handle_ico
|
||||
ext/handle_mp3
|
||||
ext/handle_svg
|
||||
ext/holiday
|
||||
ext/home
|
||||
ext/image_hash_ban
|
||||
ext/ipban
|
||||
|
@ -44,6 +46,7 @@ ext/random_image
|
|||
ext/rating
|
||||
ext/regen_thumb
|
||||
ext/report_image
|
||||
ext/resize
|
||||
ext/res_limit
|
||||
ext/rss_comments
|
||||
ext/rss_images
|
||||
|
@ -56,7 +59,7 @@ ext/tagger
|
|||
ext/tag_history
|
||||
ext/text_score
|
||||
ext/tips
|
||||
ext/amazon_s3
|
||||
ext/twitter_soc
|
||||
ext/upload_cmd
|
||||
ext/wiki
|
||||
ext/word_filter
|
||||
|
@ -69,4 +72,4 @@ ext/zoom
|
|||
/ext/twitter_soc/script.js
|
||||
/ext/twitter_soc/style.css
|
||||
/ext/twitter_soc/test.php
|
||||
/ext/twitter_soc/theme.php
|
||||
/ext/twitter_soc/theme.php
|
||||
|
|
|
@ -40,10 +40,10 @@ Installation
|
|||
Upgrade from 2.3.X
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
The database connection setting in config.php has changed; now using
|
||||
PDO DSN format [1] rather than ADODB URI [2]
|
||||
PDO DSN format rather than ADODB URI:
|
||||
|
||||
[1] <proto>:user=<username>;password=<password>;host=<host>;dbname=<database>
|
||||
[2] <proto>://<username>:<password>@<host>/<database>
|
||||
OLD: $database_dsn = "<proto>://<username>:<password>@<host>/<database>";
|
||||
NEW: define("DATABASE_DSN", "<proto>:user=<username>;password=<password>;host=<host>;dbname=<database>");
|
||||
|
||||
The rest should be automatic, just unzip into a clean folder and copy across
|
||||
config.php, images and thumbs folders from the old version. This
|
||||
|
|
|
@ -43,8 +43,8 @@ class Artists implements Extension {
|
|||
|
||||
if ($event instanceof PageRequestEvent)
|
||||
$this->handle_commands($event);
|
||||
|
||||
if($event instanceof SearchTermParseEvent) {
|
||||
|
||||
if ($event instanceof SearchTermParseEvent) {
|
||||
$matches = array();
|
||||
if(preg_match("/^author=(.*)$/", $event->term, $matches)) {
|
||||
$char = $matches[1];
|
||||
|
|
|
@ -36,7 +36,6 @@ class BrowserSearch implements Extension {
|
|||
// First, we need to build all the variables we'll need
|
||||
|
||||
$search_title = $config->get_string('title');
|
||||
//$search_form_url = $config->get_string('base_href'); //make_link('post/list');
|
||||
$search_form_url = make_link('post/list/{searchTerms}');
|
||||
$suggenton_url = make_link('browser_search/')."{searchTerms}";
|
||||
$icon_b64 = base64_encode(file_get_contents("favicon.ico"));
|
||||
|
|
|
@ -83,8 +83,6 @@ class ForumTheme extends Themelet {
|
|||
global $config, $page/*, $user*/;
|
||||
|
||||
$theme_name = $config->get_string('theme');
|
||||
$data_href = $config->get_string('base_href');
|
||||
$base_href = $config->get_string('base_href');
|
||||
|
||||
$html = "";
|
||||
$n = 0;
|
||||
|
|
|
@ -9,6 +9,7 @@ class FlashFileHandlerTheme extends Themelet {
|
|||
codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0'
|
||||
height='{$image->height}'
|
||||
width='{$image->width}'
|
||||
wmode='opaque'
|
||||
>
|
||||
<param name='movie' value='$ilink'/>
|
||||
<param name='quality' value='high' />
|
||||
|
@ -16,6 +17,7 @@ class FlashFileHandlerTheme extends Themelet {
|
|||
pluginspage='http://www.macromedia.com/go/getflashplayer'
|
||||
height='{$image->height}'
|
||||
width='{$image->width}'
|
||||
wmode='opaque'
|
||||
type='application/x-shockwave-flash'></embed>
|
||||
</object>";
|
||||
$page->add_block(new Block("Flash Animation", $html, "main", 0));
|
||||
|
|
33
contrib/holiday/main.php
Normal file
33
contrib/holiday/main.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* Name: Holiday Theme
|
||||
* Author: DakuTree <thedakutree@codeanimu.net>
|
||||
* Link: http://www.codeanimu.net
|
||||
* License: GPLv2
|
||||
* Description: Use an additional stylesheet on certain holidays.
|
||||
*/
|
||||
class Holiday extends SimpleExtension {
|
||||
public function onInitExt(Event $event) {
|
||||
global $config;
|
||||
$config->set_default_bool("holiday_aprilfools", false);
|
||||
}
|
||||
|
||||
public function onSetupBuilding(Event $event) {
|
||||
global $config;
|
||||
$sb = new SetupBlock("Holiday Theme");
|
||||
$sb->add_bool_option("holiday_aprilfools", "Enable April Fools");
|
||||
$event->panel->add_block($sb);
|
||||
}
|
||||
|
||||
public function onPageRequest(Event $event) {
|
||||
global $config;
|
||||
$date = /*date('d/m') == '01/01' ||date('d/m') == '14/02' || */date('d/m') == '01/04'/* || date('d/m') == '24/12' || date('d/m') == '25/12' || date('d/m') == '31/12'*/;
|
||||
if($date){
|
||||
if($config->get_bool("holiday_aprilfools")){
|
||||
$this->theme->display_holiday($date);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
|
@ -1,18 +1,8 @@
|
|||
/*
|
||||
If you wish to play about with colors, the main two colors to replace are:
|
||||
Main color: #CEDFF0
|
||||
Secondary color: #E3EFFA
|
||||
*/
|
||||
|
||||
BODY {
|
||||
background: #F0F7FF;
|
||||
font-family: sans-serif;
|
||||
font-size: 14px;
|
||||
margin: 0px;
|
||||
/* It's a bit crazy but, april fools is supposed to be crazy.
|
||||
This flips the entire page upside down.
|
||||
TODO: Add a way for the user to disable this */
|
||||
|
||||
|
||||
-webkit-transform: rotate(-180deg); /*Safari*/
|
||||
-moz-transform: rotate(-180deg); /*Firefox*/
|
||||
-o-transform: rotate(-180deg); /*Opera*/
|
20
contrib/holiday/theme.php
Normal file
20
contrib/holiday/theme.php
Normal file
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
class HolidayTheme extends Themelet {
|
||||
public function display_holiday($date) {
|
||||
global $page;
|
||||
if($date){
|
||||
$csssheet = "<link rel='stylesheet' href='".get_base_href()."/contrib/holiday/stylesheets/";
|
||||
|
||||
// April Fools
|
||||
// Flips the entire page upside down!
|
||||
// TODO: Make it possible for the user to turn this off!
|
||||
if(date('d/m') == '01/04'){
|
||||
$csssheet .= "aprilfools.css";
|
||||
}
|
||||
|
||||
$csssheet .= "' type='text/css'>";
|
||||
$page->add_html_header("$csssheet");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -28,14 +28,13 @@ class Home extends SimpleExtension {
|
|||
public function onPageRequest(PageRequestEvent $event) {
|
||||
global $config, $page;
|
||||
if($event->page_matches("home")) {
|
||||
$base_href = $config->get_string('base_href');
|
||||
$data_href = get_base_href();
|
||||
$base_href = get_base_href();
|
||||
$sitename = $config->get_string('title');
|
||||
$theme_name = $config->get_string('theme');
|
||||
|
||||
$body = $this->get_body();
|
||||
|
||||
$this->theme->display_page($page, $sitename, $data_href, $theme_name, $body);
|
||||
$this->theme->display_page($page, $sitename, $base_href, $theme_name, $body);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -58,8 +57,7 @@ class Home extends SimpleExtension {
|
|||
// returns just the contents of the body
|
||||
global $database;
|
||||
global $config;
|
||||
$base_href = $config->get_string('base_href');
|
||||
$data_href = get_base_href();
|
||||
$base_href = get_base_href();
|
||||
$sitename = $config->get_string('title');
|
||||
$contact_link = $config->get_string('contact_link');
|
||||
$counter_dir = $config->get_string('home_counter', 'default');
|
||||
|
@ -71,7 +69,7 @@ class Home extends SimpleExtension {
|
|||
$counter_text = "";
|
||||
for($n=0; $n<strlen($strtotal); $n++) {
|
||||
$cur = $strtotal[$n];
|
||||
$counter_text .= " <img alt='$cur' src='$data_href/ext/home/counters/$counter_dir/$cur.gif' /> ";
|
||||
$counter_text .= " <img alt='$cur' src='$base_href/ext/home/counters/$counter_dir/$cur.gif' /> ";
|
||||
}
|
||||
|
||||
// get the homelinks and process them
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
<?php
|
||||
|
||||
class HomeTheme extends Themelet {
|
||||
public function display_page(Page $page, $sitename, $data_href, $theme_name, $body) {
|
||||
public function display_page(Page $page, $sitename, $base_href, $theme_name, $body) {
|
||||
$page->set_mode("data");
|
||||
$page->set_data(<<<EOD
|
||||
<html>
|
||||
<head>
|
||||
<title>$sitename</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||
<link rel='stylesheet' href='$data_href/themes/$theme_name/style.css' type='text/css'>
|
||||
<link rel='stylesheet' href='$base_href/themes/$theme_name/style.css' type='text/css'>
|
||||
</head>
|
||||
<style>
|
||||
div#front-page h1 {font-size: 4em; margin-top: 2em; margin-bottom: 0px; text-align: center; border: none; background: none; box-shadow: none; -webkit-box-shadow: none; -moz-box-shadow: none;}
|
||||
|
|
|
@ -64,7 +64,7 @@ class Ratings implements Extension {
|
|||
}
|
||||
|
||||
if($event instanceof RatingSetEvent) {
|
||||
$this->set_rating($event->image->id, $event->rating);
|
||||
$this->set_rating($event->image->id, $event->rating, $event->image->rating);
|
||||
}
|
||||
|
||||
if($event instanceof ImageInfoBoxBuildingEvent) {
|
||||
|
@ -205,9 +205,12 @@ class Ratings implements Extension {
|
|||
}
|
||||
}
|
||||
|
||||
private function set_rating($image_id, $rating) {
|
||||
private function set_rating($image_id, $rating, $old_rating) {
|
||||
global $database;
|
||||
$database->Execute("UPDATE images SET rating=? WHERE id=?", array($rating, $image_id));
|
||||
if($old_rating != $rating){
|
||||
$database->Execute("UPDATE images SET rating=? WHERE id=?", array($rating, $image_id));
|
||||
log_info("core-image", "Rating for Image #{$image_id} set to: ".$this->theme->rating_to_name($rating));
|
||||
}
|
||||
}
|
||||
}
|
||||
add_event_listener(new Ratings());
|
||||
|
|
|
@ -55,7 +55,7 @@ class RSS_Comments extends SimpleExtension {
|
|||
}
|
||||
|
||||
$title = $config->get_string('title');
|
||||
$base_href = make_http($config->get_string('base_href'));
|
||||
$base_href = make_http(get_base_href());
|
||||
$version = $config->get_string('version');
|
||||
$xml = <<<EOD
|
||||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
|
|
|
@ -66,7 +66,7 @@ class RSS_Images extends SimpleExtension {
|
|||
}
|
||||
|
||||
$title = $config->get_string('title');
|
||||
$base_href = make_http($config->get_string('base_href'));
|
||||
$base_href = make_http(get_base_href());
|
||||
$search = "";
|
||||
if(count($search_terms) > 0) {
|
||||
$search = url_escape(implode(" ", $search_terms)) . "/";
|
||||
|
|
|
@ -9,7 +9,7 @@ class taggerTheme extends Themelet {
|
|||
public function build_tagger (Page $page, $event) {
|
||||
global $config;
|
||||
// Initialization code
|
||||
$base_href = $config->get_string('base_href');
|
||||
$base_href = get_base_href();
|
||||
// TODO: AJAX test and fallback.
|
||||
$page->add_html_header("<script src='$base_href/ext/tagger/webtoolkit.drag.js' type='text/javascript'></script>");
|
||||
$page->add_block(new Block(null,
|
||||
|
|
|
@ -274,8 +274,6 @@ class Database {
|
|||
* stored in config.php in the root shimmie folder
|
||||
*/
|
||||
public function Database() {
|
||||
global $database_dsn, $cache_dsn;
|
||||
|
||||
# FIXME: detect ADODB URI, automatically translate PDO DSN
|
||||
|
||||
/*
|
||||
|
@ -285,10 +283,10 @@ class Database {
|
|||
* http://stackoverflow.com/questions/237367
|
||||
*/
|
||||
$matches = array(); $db_user=null; $db_pass=null;
|
||||
if(preg_match("/user=([^;]*)/", $database_dsn, $matches)) $db_user=$matches[1];
|
||||
if(preg_match("/password=([^;]*)/", $database_dsn, $matches)) $db_pass=$matches[1];
|
||||
if(preg_match("/user=([^;]*)/", DATABASE_DSN, $matches)) $db_user=$matches[1];
|
||||
if(preg_match("/password=([^;]*)/", DATABASE_DSN, $matches)) $db_pass=$matches[1];
|
||||
|
||||
$this->db = new PDO($database_dsn, $db_user, $db_pass);
|
||||
$this->db = new PDO(DATABASE_DSN, $db_user, $db_pass);
|
||||
$this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
|
||||
|
||||
$db_proto = $this->db->getAttribute(PDO::ATTR_DRIVER_NAME);
|
||||
|
@ -305,9 +303,8 @@ class Database {
|
|||
die("Unknown PDO driver: $db_proto");
|
||||
}
|
||||
|
||||
if(isset($cache_dsn) && !empty($cache_dsn)) {
|
||||
$matches = array();
|
||||
preg_match("#(memcache|apc)://(.*)#", $cache_dsn, $matches);
|
||||
$matches = array();
|
||||
if(CACHE_DSN && preg_match("#(memcache|apc)://(.*)#", CACHE_DSN, $matches)) {
|
||||
if($matches[1] == "memcache") {
|
||||
$this->cache = new MemcacheCache($matches[2]);
|
||||
}
|
||||
|
|
|
@ -231,14 +231,9 @@ class Image {
|
|||
*/
|
||||
public function get_tag_array() {
|
||||
global $database;
|
||||
$cached = $database->cache->get("image-{$this->id}-tags");
|
||||
if($cached) return $cached;
|
||||
|
||||
if(!isset($this->tag_array)) {
|
||||
$this->tag_array = $database->get_col("SELECT tag FROM image_tags JOIN tags ON image_tags.tag_id = tags.id WHERE image_id=:id ORDER BY tag", array("id"=>$this->id));
|
||||
}
|
||||
|
||||
$database->cache->set("image-{$this->id}-tags", $this->tag_array);
|
||||
return $this->tag_array;
|
||||
}
|
||||
|
||||
|
@ -368,23 +363,29 @@ class Image {
|
|||
/**
|
||||
* Set the image's source URL
|
||||
*/
|
||||
public function set_source($source) {
|
||||
public function set_source($source, $old_source) {
|
||||
global $database;
|
||||
if(empty($source)) $source = null;
|
||||
$database->execute("UPDATE images SET source=:source WHERE id=:id", array("source"=>$source, "id"=>$this->id));
|
||||
if($old_source != $source){
|
||||
$database->execute("UPDATE images SET source=:source WHERE id=:id", array("source"=>$source, "id"=>$this->id));
|
||||
log_info("core-image", "Source for Image #{$this->id} set to: ".$source);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public function is_locked() {
|
||||
return ($this->locked === true || $this->locked == "Y" || $this->locked == "t");
|
||||
}
|
||||
public function set_locked($tf) {
|
||||
public function set_locked($tf, $old_sln) {
|
||||
global $database;
|
||||
$ln = $tf ? "Y" : "N";
|
||||
$sln = $database->engine->scoreql_to_sql("SCORE_BOOL_$ln");
|
||||
$sln = str_replace("'", "", $sln);
|
||||
$sln = str_replace('"', "", $sln);
|
||||
$database->execute("UPDATE images SET locked=:yn WHERE id=:id", array("yn"=>$sln, "id"=>$this->id));
|
||||
if($old_sln != $sln){
|
||||
$database->execute("UPDATE images SET locked=:yn WHERE id=:id", array("yn"=>$sln, "id"=>$this->id));
|
||||
log_info("core-image", "Setting Image #{$this->id} lock to: {$event->locked}".$sln);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -403,48 +404,49 @@ class Image {
|
|||
/**
|
||||
* Set the tags for this image
|
||||
*/
|
||||
public function set_tags($tags) {
|
||||
public function set_tags($tags, $old_tags) {
|
||||
global $database;
|
||||
$tags = Tag::resolve_list($tags);
|
||||
|
||||
assert(is_array($tags));
|
||||
assert(count($tags) > 0);
|
||||
|
||||
// delete old
|
||||
$this->delete_tags_from_image();
|
||||
|
||||
// insert each new tags
|
||||
foreach($tags as $tag) {
|
||||
$id = $database->get_one(
|
||||
$database->engine->scoreql_to_sql(
|
||||
"SELECT id FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"
|
||||
),
|
||||
array("tag"=>$tag));
|
||||
if(empty($id)) {
|
||||
// a new tag
|
||||
$database->execute(
|
||||
"INSERT INTO tags(tag) VALUES (:tag)",
|
||||
$new_tags = implode(" ", $tags);
|
||||
if($old_tags != $new_tags){
|
||||
// delete old
|
||||
$this->delete_tags_from_image();
|
||||
// insert each new tags
|
||||
foreach($tags as $tag) {
|
||||
$id = $database->get_one(
|
||||
$database->engine->scoreql_to_sql(
|
||||
"SELECT id FROM tags WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"
|
||||
),
|
||||
array("tag"=>$tag));
|
||||
if(empty($id)) {
|
||||
// a new tag
|
||||
$database->execute(
|
||||
"INSERT INTO tags(tag) VALUES (:tag)",
|
||||
array("tag"=>$tag));
|
||||
$database->execute(
|
||||
"INSERT INTO image_tags(image_id, tag_id)
|
||||
VALUES(:id, (SELECT id FROM tags WHERE tag = :tag))",
|
||||
array("id"=>$this->id, "tag"=>$tag));
|
||||
}
|
||||
else {
|
||||
// user of an existing tag
|
||||
$database->execute(
|
||||
"INSERT INTO image_tags(image_id, tag_id) VALUES(:iid, :tid)",
|
||||
array("iid"=>$this->id, "tid"=>$id));
|
||||
}
|
||||
$database->execute(
|
||||
"INSERT INTO image_tags(image_id, tag_id)
|
||||
VALUES(:id, (SELECT id FROM tags WHERE tag = :tag))",
|
||||
array("id"=>$this->id, "tag"=>$tag));
|
||||
$database->engine->scoreql_to_sql(
|
||||
"UPDATE tags SET count = count + 1 WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"
|
||||
),
|
||||
array("tag"=>$tag));
|
||||
}
|
||||
else {
|
||||
// user of an existing tag
|
||||
$database->execute(
|
||||
"INSERT INTO image_tags(image_id, tag_id) VALUES(:iid, :tid)",
|
||||
array("iid"=>$this->id, "tid"=>$id));
|
||||
}
|
||||
$database->execute(
|
||||
$database->engine->scoreql_to_sql(
|
||||
"UPDATE tags SET count = count + 1 WHERE SCORE_STRNORM(tag) = SCORE_STRNORM(:tag)"
|
||||
),
|
||||
array("tag"=>$tag));
|
||||
}
|
||||
|
||||
log_info("core-image", "Tags for Image #{$this->id} set to: ".implode(" ", $tags));
|
||||
$database->cache->delete("image-{$this->id}-tags");
|
||||
log_info("core-image", "Tags for Image #{$this->id} set to: ".implode(" ", $tags));
|
||||
$database->cache->delete("image-{$this->id}-tags");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -130,7 +130,7 @@ function to_shorthand_int($int) {
|
|||
*/
|
||||
function autodate($date, $html=true) {
|
||||
$cpu = date('c', strtotime($date));
|
||||
$hum = date('F j, Y', strtotime($date));
|
||||
$hum = date('F j, Y; H:i', strtotime($date));
|
||||
return ($html ? "<time datetime='$cpu'>$hum</time>" : $hum);
|
||||
}
|
||||
|
||||
|
@ -204,7 +204,7 @@ function make_link($page=null, $query=null) {
|
|||
|
||||
if(is_null($page)) $page = $config->get_string('main_page');
|
||||
|
||||
if(FORCE_NICE_URLS || $config->get_bool('nice_urls', false)) {
|
||||
if(NICE_URLS || $config->get_bool('nice_urls', false)) {
|
||||
#$full = "http://" . $_SERVER["SERVER_NAME"] . $_SERVER["PHP_SELF"];
|
||||
$full = $_SERVER["PHP_SELF"];
|
||||
$base = str_replace("/index.php", "", $full);
|
||||
|
@ -539,7 +539,10 @@ function set_prefixed_cookie($name, $value, $time, $path) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Figure out the path to the shimmie install root.
|
||||
* Figure out the path to the shimmie install directory.
|
||||
*
|
||||
* eg if shimmie is visible at http://foo.com/gallery, this
|
||||
* function should return /gallery
|
||||
*
|
||||
* PHP really, really sucks.
|
||||
*
|
||||
|
@ -820,8 +823,12 @@ function send_event(Event $event) {
|
|||
* Debugging functions *
|
||||
\* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
||||
|
||||
// SHIT by default this returns the time as a string. And it's not even a
|
||||
// string representation of a number, it's two numbers separated by a space.
|
||||
// What the fuck were the PHP developers smoking.
|
||||
$_load_start = microtime(true);
|
||||
function get_debug_info() {
|
||||
global $config, $_event_count, $database, $_execs;
|
||||
global $config, $_event_count, $database, $_execs, $_load_start;
|
||||
|
||||
if(function_exists('memory_get_usage')) {
|
||||
$i_mem = sprintf("%5.2f", ((memory_get_usage()+512)/1024)/1024);
|
||||
|
@ -829,21 +836,12 @@ function get_debug_info() {
|
|||
else {
|
||||
$i_mem = "???";
|
||||
}
|
||||
if(function_exists('getrusage')) {
|
||||
$ru = getrusage();
|
||||
$i_utime = sprintf("%5.2f", ($ru["ru_utime.tv_sec"]*1e6+$ru["ru_utime.tv_usec"])/1000000);
|
||||
$i_stime = sprintf("%5.2f", ($ru["ru_stime.tv_sec"]*1e6+$ru["ru_stime.tv_usec"])/1000000);
|
||||
}
|
||||
else {
|
||||
$i_utime = "???";
|
||||
$i_stime = "???";
|
||||
}
|
||||
|
||||
$time = sprintf("%5.2f", microtime(true) - $_load_start);
|
||||
$i_files = count(get_included_files());
|
||||
$hits = $database->cache->get_hits();
|
||||
$miss = $database->cache->get_misses();
|
||||
|
||||
$debug = "<br>Took $i_utime + $i_stime seconds and {$i_mem}MB of RAM";
|
||||
$debug = "<br>Took $time seconds and {$i_mem}MB of RAM";
|
||||
$debug .= "; Used $i_files files and $_execs queries";
|
||||
$debug .= "; Sent $_event_count events";
|
||||
$debug .= "; $hits cache hits and $miss misses";
|
||||
|
|
|
@ -146,7 +146,8 @@ class CommentList extends SimpleExtension {
|
|||
}
|
||||
}
|
||||
else if($event->get_arg(0) == "list") {
|
||||
$this->build_page($event->get_arg(1));
|
||||
$page_num = int_escape($event->get_arg(1));
|
||||
$this->build_page($page_num);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -264,9 +265,10 @@ class CommentList extends SimpleExtension {
|
|||
$threads_per_page = 10;
|
||||
$start = $threads_per_page * ($current_page - 1);
|
||||
|
||||
$where = SPEED_HAX ? "WHERE posted > now() - interval '24 hours'" : "";
|
||||
$get_threads = "
|
||||
SELECT image_id,MAX(posted) AS latest
|
||||
FROM comments
|
||||
FROM comments $where
|
||||
GROUP BY image_id
|
||||
ORDER BY latest DESC
|
||||
LIMIT :limit OFFSET :offset
|
||||
|
@ -275,7 +277,7 @@ class CommentList extends SimpleExtension {
|
|||
|
||||
$total_pages = $database->cache->get("comment_pages");
|
||||
if(empty($total_pages)) {
|
||||
$total_pages = (int)($database->get_one("SELECT COUNT(c1) FROM (SELECT COUNT(image_id) AS c1 FROM comments GROUP BY image_id) AS s1") / 10);
|
||||
$total_pages = (int)($database->get_one("SELECT COUNT(c1) FROM (SELECT COUNT(image_id) AS c1 FROM comments $where GROUP BY image_id) AS s1") / 10);
|
||||
$database->cache->set("comment_pages", $total_pages, 600);
|
||||
}
|
||||
|
||||
|
@ -372,9 +374,10 @@ class CommentList extends SimpleExtension {
|
|||
$window = int_escape($config->get_int('comment_window'));
|
||||
$max = int_escape($config->get_int('comment_limit'));
|
||||
|
||||
// window doesn't work as an SQL param because it's inside quotes >_<
|
||||
$result = $database->get_all("SELECT * FROM comments WHERE owner_ip = :remote_ip ".
|
||||
"AND posted > date_sub(now(), interval :window minute)",
|
||||
Array("remote_ip"=>$_SERVER['REMOTE_ADDR'], "window"=>$window));
|
||||
"AND posted > now() - interval '$window minute'",
|
||||
Array("remote_ip"=>$_SERVER['REMOTE_ADDR']));
|
||||
|
||||
return (count($result) >= $max);
|
||||
}
|
||||
|
@ -405,6 +408,17 @@ class CommentList extends SimpleExtension {
|
|||
'permalink' => '',
|
||||
);
|
||||
|
||||
# akismet breaks if there's no referrer in the environment; so if there
|
||||
# isn't, supply one manually
|
||||
if(!isset($_SERVER['HTTP_REFERER'])) {
|
||||
$comment['referrer'] = 'none';
|
||||
log_warning("comment", "User '{$user->name}' commented with no referrer: $text");
|
||||
}
|
||||
if(!isset($_SERVER['HTTP_USER_AGENT'])) {
|
||||
$comment['user_agent'] = 'none';
|
||||
log_warning("comment", "User '{$user->name}' commented with no user-agent: $text");
|
||||
}
|
||||
|
||||
$akismet = new Akismet(
|
||||
$_SERVER['SERVER_NAME'],
|
||||
$config->get_string('comment_wordpress_key'),
|
||||
|
|
|
@ -167,7 +167,6 @@ class Setup extends SimpleExtension {
|
|||
$config->set_default_string("title", "Shimmie");
|
||||
$config->set_default_string("front_page", "post/list");
|
||||
$config->set_default_string("main_page", "post/list");
|
||||
$config->set_default_string("base_href", "./index.php?q=");
|
||||
$config->set_default_string("theme", "default");
|
||||
$config->set_default_bool("word_wrap", true);
|
||||
$config->set_default_bool("comment_captcha", false);
|
||||
|
|
|
@ -91,20 +91,19 @@ class TagEdit implements Extension {
|
|||
|
||||
if($event instanceof TagSetEvent) {
|
||||
if($user->is_admin() || !$event->image->is_locked()) {
|
||||
$event->image->set_tags($event->tags);
|
||||
$event->image->set_tags($event->tags, $event->image->get_tag_list());
|
||||
}
|
||||
}
|
||||
|
||||
if($event instanceof SourceSetEvent) {
|
||||
if($user->is_admin() || !$event->image->is_locked()) {
|
||||
$event->image->set_source($event->source);
|
||||
$event->image->set_source($event->source, $event->image->source);
|
||||
}
|
||||
}
|
||||
|
||||
if($event instanceof LockSetEvent) {
|
||||
if($user->is_admin()) {
|
||||
log_debug("tag_edit", "Setting Image #{$event->image->id} lock to: {$event->locked}");
|
||||
$event->image->set_locked($event->locked);
|
||||
$event->image->set_locked($event->locked, $event->image->locked);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -12,19 +12,19 @@ if(document.getElementById("post_tags") !== null){
|
|||
if (typeof tag !=="ftp://ftp." && chk !==1){var tag=document.getElementById("post_tags").value;}
|
||||
var rtg=document.getElementById("stats").innerHTML.match("<li>Rating: (.*)<\/li>")[1];
|
||||
var srx="http://" + document.location.hostname + document.location.href.match("\/post\/show\/[0-9]+\/");
|
||||
var filesze=document.getElementById("stats").innerHTML.match("[0-9] \\(((?:\.*[0-9])) ([a-zA-Z]+)");
|
||||
if(filesze[2] == "MB"){var filesze = filesze[1] * 1024;}else{var filesze = filesze[2].match("[0-9]+");}
|
||||
if(tag.search(/\bflash\b/)==-1){
|
||||
|
||||
if(tag.search(/\bflash\b/)===-1){
|
||||
var filesze=document.getElementById("stats").innerHTML.match("[0-9] \\(((?:\.*[0-9])) ([a-zA-Z]+)");
|
||||
if(filesze[2] == "MB"){var filesze = filesze[1] * 1024;}else{var filesze = filesze[2].match("[0-9]+");}
|
||||
|
||||
if(supext.search(document.getElementById("highres").href.match("http\:\/\/.*\\.([a-z0-9]+)")[1]) !== -1){
|
||||
if(filesze <= maxsze){
|
||||
location.href=ste+document.getElementById("highres").href+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx;
|
||||
location.href=ste+document.getElementById("highres").href+"&tags="+tag+"&rating="+rtg+"&source="+srx;
|
||||
}else{alert(toobig);}
|
||||
}else{alert(notsup);}
|
||||
}else{
|
||||
if(supext.search(document.getElementById("highres").href.match("http\:\/\/.*\\.([a-z0-9]+)")[1]) !== -1){
|
||||
if(filesze <= maxsze){
|
||||
location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+tag+"&rating="+rtg[1]+"&source="+srx;
|
||||
}else{alert(toobig);}
|
||||
if(supext.search("swf") !== -1){
|
||||
location.href=ste+document.getElementsByName("movie")[0].value+"&tags="+tag+"&rating="+rtg+"&source="+srx;
|
||||
}else{alert(notsup);}
|
||||
}
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ else if(document.getElementsByTagName("title")[0].innerHTML.search("Image [0-9.-
|
|||
}else{alert(notsup);}
|
||||
}else{
|
||||
var mov = document.location.hostname+document.getElementsByName("movie")[0].value;
|
||||
if(supext.search(mov.match(".*\\.([a-z0-9]+)")[1]) !== -1){
|
||||
if(supext.search("swf") !== -1){
|
||||
location.href=ste+mov+"&tags="+tag+"&source="+srx;
|
||||
}else{alert(notsup);}
|
||||
}
|
||||
|
|
|
@ -10,9 +10,10 @@ class UploadTheme extends Themelet {
|
|||
}
|
||||
|
||||
public function display_page(Page $page) {
|
||||
global $config;
|
||||
$tl_enabled = ($config->get_string("transload_engine", "none") != "none");
|
||||
global $config, $page;
|
||||
$page->add_html_header("<link rel='stylesheet' href='".get_base_href()."/ext/upload/_style.css' type='text/css'>");
|
||||
|
||||
$tl_enabled = ($config->get_string("transload_engine", "none") != "none");
|
||||
// Uploader 2.0!
|
||||
$upload_list = "";
|
||||
for($i=0; $i<$config->get_int('upload_count'); $i++)
|
||||
|
@ -167,17 +168,28 @@ class UploadTheme extends Themelet {
|
|||
|
||||
/* only allows 1 file to be uploaded - for replacing another image file */
|
||||
public function display_replace_page(Page $page, $image_id) {
|
||||
global $config;
|
||||
global $config, $page;
|
||||
$page->add_html_header("<link rel='stylesheet' href='".get_base_href()."/ext/upload/_style.css' type='text/css'>");
|
||||
$tl_enabled = ($config->get_string("transload_engine", "none") != "none");
|
||||
|
||||
$js2 = 'javascript:$(function() {
|
||||
$("#data").hide();
|
||||
$("#data").val("");
|
||||
$("#url").show(); });';
|
||||
|
||||
$js1 = 'javascript:$(function() {
|
||||
$("#url").hide();
|
||||
$("#url").val("");
|
||||
$("#data").show(); });';
|
||||
|
||||
$upload_list = '';
|
||||
$upload_list .= "
|
||||
<tr>
|
||||
<td width='60'><form><input id='radio_buttona' type='radio' name='method' value='file' checked='checked' onclick='javascript:document.getElementById("url0").style.display = "none";document.getElementById("url0").value = "";document.getElementById("data0").style.display = ""' /> File<br>";
|
||||
<td width='60'><form><input id='radio_button_a' type='radio' name='method' value='file' checked='checked' onclick='$js1' /> File<br>";
|
||||
if($tl_enabled) {
|
||||
$upload_list .="
|
||||
<input id='radio_buttonb' type='radio' name='method' value='url' onclick='javascript:document.getElementById("data0").style.display = "none";document.getElementById("data0").value = "";document.getElementById("url0").style.display = ""' /> URL</ br></td></form>
|
||||
<td><input id='data0' name='data0' class='wid' type='file'><input id='url0' name='url0' class='wid' type='text' style='display:none'></td>
|
||||
<input id='radio_button_b' type='radio' name='method' value='url' onclick='$js2' /> URL</ br></td></form>
|
||||
<td><input id='data' name='data' class='wid' type='file'><input id='url' name='url' class='wid' type='text' style='display:none'></td>
|
||||
";
|
||||
} else {
|
||||
$upload_list .= "</form></td>
|
||||
|
|
|
@ -87,6 +87,11 @@ class ViewImage extends SimpleExtension {
|
|||
}
|
||||
|
||||
$image = Image::by_id($image_id);
|
||||
if(is_null($image)) {
|
||||
$this->theme->display_error($page, "Image not found", "Couldn't find image $image_id");
|
||||
return;
|
||||
}
|
||||
|
||||
if($event->page_matches("post/next")) {
|
||||
$image = $image->get_next($search_terms);
|
||||
}
|
||||
|
@ -94,13 +99,12 @@ class ViewImage extends SimpleExtension {
|
|||
$image = $image->get_prev($search_terms);
|
||||
}
|
||||
|
||||
if(!is_null($image)) {
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/{$image->id}", $query));
|
||||
}
|
||||
else {
|
||||
if(is_null($image)) {
|
||||
$this->theme->display_error($page, "Image not found", "No more images");
|
||||
}
|
||||
|
||||
$page->set_mode("redirect");
|
||||
$page->set_redirect(make_link("post/view/{$image->id}", $query));
|
||||
}
|
||||
|
||||
if($event->page_matches("post/view")) {
|
||||
|
|
32
index.php
32
index.php
|
@ -57,18 +57,26 @@ if(empty($database_dsn) && !file_exists("config.php")) {
|
|||
require_once "config.php";
|
||||
|
||||
// set up and purify the environment
|
||||
if(!defined("DEBUG")) define("DEBUG", false);
|
||||
if(!defined("COVERAGE")) define("COVERAGE", false);
|
||||
if(!defined("CONTEXT")) define("CONTEXT", false);
|
||||
if(!defined("CACHE_MEMCACHE")) define("CACHE_MEMCACHE", false);
|
||||
if(!defined("CACHE_DIR")) define("CACHE_DIR", false);
|
||||
if(!defined("CACHE_HTTP")) define("CACHE_HTTP", false);
|
||||
if(!defined("VERSION")) define("VERSION", 'trunk');
|
||||
if(!defined("SCORE_VERSION")) define("SCORE_VERSION", 's2hack/'.VERSION);
|
||||
if(!defined("COOKIE_PREFIX")) define("COOKIE_PREFIX", 'shm');
|
||||
if(!defined("SPEED_HAX")) define("SPEED_HAX", false);
|
||||
if(!defined("FORCE_NICE_URLS")) define("FORCE_NICE_URLS", false);
|
||||
if(!defined("WH_SPLITS")) define("WH_SPLITS", 1);
|
||||
function _d($name, $value) {
|
||||
if(!defined($name)) define($name, $value);
|
||||
}
|
||||
_d("DATABASE_DSN", null); // string PDO database connection details
|
||||
_d("CACHE_DSN", null); // string cache connection details
|
||||
_d("DEBUG", false); // boolean print various debugging details
|
||||
_d("COVERAGE", false); // boolean activate xdebug coverage monitor
|
||||
_d("CONTEXT", null); // string file to log performance data into
|
||||
_d("CACHE_MEMCACHE", false); // boolean store complete rendered pages in memcache
|
||||
_d("CACHE_DIR", false); // boolean store complete rendered pages on disk
|
||||
_d("CACHE_HTTP", false); // boolean output explicit HTTP caching headers
|
||||
_d("COOKIE_PREFIX", 'shm'); // string if you run multiple galleries with non-shared logins, give them different prefixes
|
||||
_d("SPEED_HAX", false); // boolean do some questionable things in the name of performance
|
||||
_d("NICE_URLS", false); // boolean force niceurl mode
|
||||
_d("WH_SPLITS", 1); // int how many levels of subfolders to put in the warehouse
|
||||
_d("VERSION", 'trunk'); // string shimmie version
|
||||
_d("SCORE_VERSION", 's2hack/'.VERSION); // string SCore version
|
||||
_d("TIMEZONE", 'UTC'); // string timezone
|
||||
|
||||
date_default_timezone_set(TIMEZONE);
|
||||
|
||||
require_once "core/util.inc.php";
|
||||
require_once "lib/context.php";
|
||||
|
|
|
@ -52,7 +52,7 @@ if(is_readable("config.php")) {
|
|||
<h1>Shimmie Repair Console</h1>
|
||||
<?php
|
||||
include "config.php";
|
||||
if($_SESSION['dsn'] == $database_dsn || $_POST['dsn'] == $database_dsn) {
|
||||
if($_SESSION['dsn'] == DATABASE_DSN || $_POST['dsn'] == DATABASE_DSN) {
|
||||
if($_POST['dsn']) {$_SESSION['dsn'] = $_POST['dsn'];}
|
||||
|
||||
if(empty($_GET["action"])) {
|
||||
|
@ -350,7 +350,9 @@ function build_dirs() { // {{{
|
|||
} // }}}
|
||||
function write_config() { // {{{
|
||||
global $database_dsn;
|
||||
$file_content = "<?php \$database_dsn='$database_dsn'; ?>";
|
||||
$file_content = "<"+"?php\n"+
|
||||
"define('DATABASE_DSN', '$database_dsn');\n"+
|
||||
"?"+">";
|
||||
|
||||
if(is_writable("./") && file_put_contents("config.php", $file_content)) {
|
||||
assert(file_exists("config.php"));
|
||||
|
|
|
@ -23,33 +23,6 @@ class Layout {
|
|||
foreach($page->html_headers as $line) {
|
||||
$header_html .= "\t\t$line\n";
|
||||
}
|
||||
|
||||
/* Holiday Stuff!
|
||||
If the current day is one of the set holidays, it will use a seperate stylesheet. Aswell as a few extra things depending on the day.
|
||||
This only adds April Fools for now.
|
||||
TODO: Add setup block to make the whole holiday thing "optional". / Choose what holidays you wish to use.
|
||||
*/
|
||||
if(/*date('d/m') == '01/01' || date('d/m') == '14/02' || */date('d/m') == '01/04'/* || date('d/m') == '24/12' || date('d/m') == '25/12' || date('d/m') == '31/12'*/){
|
||||
|
||||
$csssheet = "<link rel='stylesheet' href='$data_href/themes/$theme_name/holidays/";
|
||||
|
||||
// April Fools
|
||||
// Flips the entire page upside down!
|
||||
// TODO: Make it possible for the user to turn this off!
|
||||
if(date('d/m') == '01/04'){
|
||||
$csssheet .= "style_aprilfools.css";
|
||||
$holtag = "april_fools";
|
||||
}
|
||||
$csssheet .= "' type='text/css'>";
|
||||
//Optional! Uses a random image with a size lower then 800x91 & using the holiday tag and sticks it at top of page like a banner.
|
||||
/*$banner = "<div>";
|
||||
if(file_exists("ext/random_image")){
|
||||
$banner .= "<center><img src='$data_href/random_image/download/size<800x91+$holtag'></center>";
|
||||
}
|
||||
$banner .= "</div>";*/
|
||||
}else{
|
||||
$banner = "";
|
||||
}
|
||||
|
||||
$menu = "<div class='menu'>
|
||||
<script type='text/javascript' src='$data_href/themes/$theme_name/wz_tooltip.js'></script>
|
||||
|
@ -180,14 +153,6 @@ class Layout {
|
|||
$main_block_html = "<div id='body'>$main_block_html</div>";
|
||||
}
|
||||
|
||||
// This is required for the holiday feature.
|
||||
if(empty($csssheet)){
|
||||
$csssheet = "";
|
||||
}
|
||||
if(empty($banner)){
|
||||
$holiday = "";
|
||||
}
|
||||
|
||||
print <<<EOD
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
|
||||
<html>
|
||||
|
@ -195,12 +160,12 @@ class Layout {
|
|||
<title>{$page->title}</title>
|
||||
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
|
||||
<link rel="stylesheet" href="$data_href/themes/$theme_name/style.css" type="text/css">
|
||||
$csssheet
|
||||
|
||||
$header_html
|
||||
</head>
|
||||
|
||||
<body>
|
||||
$banner
|
||||
|
||||
$menu
|
||||
$custom_sublinks
|
||||
|
||||
|
|
|
@ -107,12 +107,20 @@ class CustomUserPageTheme extends UserPageTheme {
|
|||
<input type='hidden' name='name' value='{$duser->name}'>
|
||||
<input type='hidden' name='id' value='{$duser->id}'>
|
||||
<table style='width: 300px;'>
|
||||
<tr><td colspan='2'>Change Password</td></tr>
|
||||
<tr><th colspan='2'>Change Password</th></tr>
|
||||
<tr><td>Password</td><td><input type='password' name='pass1'></td></tr>
|
||||
<tr><td>Repeat Password</td><td><input type='password' name='pass2'></td></tr>
|
||||
<tr><td colspan='2'><input type='Submit' value='Change Password'></td></tr>
|
||||
</table>
|
||||
</form>
|
||||
<p><form action='".make_link("user_admin/change_email")."' method='POST'>
|
||||
<input type='hidden' name='id' value='{$duser->id}'>
|
||||
<table style='width: 300px;'>
|
||||
<tr><th colspan='2'>Change Email</th></tr>
|
||||
<tr><td>Address</td><td><input type='text' name='address' value='".html_escape($duser->email)."'></td></tr>
|
||||
<tr><td colspan='2'><input type='Submit' value='Set'></td></tr>
|
||||
</table>
|
||||
</form></p>
|
||||
";
|
||||
|
||||
if($user->is_admin()) {
|
||||
|
|
Reference in a new issue