Merge branch 'develop'

This commit is contained in:
Shish 2017-09-18 23:40:46 +01:00
commit aef0d15783
34 changed files with 428 additions and 255 deletions

250
composer.lock generated
View file

@ -18,23 +18,11 @@
"type": "zip",
"url": "https://api.github.com/repos/jquery/jquery-dist/zipball/3a43d7e563314bf32970b773dd31ecf2b90813dd",
"reference": "3a43d7e563314bf32970b773dd31ecf2b90813dd",
"shasum": ""
},
"type": "bower-asset-library",
"extra": {
"bower-asset-main": "dist/jquery.js",
"bower-asset-ignore": [
"package.json"
]
"shasum": null
},
"type": "bower-asset",
"license": [
"MIT"
],
"keywords": [
"browser",
"javascript",
"jquery",
"library"
]
},
{
@ -49,19 +37,12 @@
"type": "zip",
"url": "https://api.github.com/repos/rmm5t/jquery-timeago/zipball/67c11951ae9b6020341c1056a42b5406162db40c",
"reference": "67c11951ae9b6020341c1056a42b5406162db40c",
"shasum": ""
"shasum": null
},
"require": {
"bower-asset/jquery": ">=1.4"
},
"type": "bower-asset-library",
"extra": {
"bower-asset-main": "jquery.timeago.js",
"bower-asset-ignore": [
"test",
"vendor"
]
},
"type": "bower-asset",
"license": [
"MIT"
]
@ -78,25 +59,9 @@
"type": "zip",
"url": "https://api.github.com/repos/js-cookie/js-cookie/zipball/5c830fb71a2bd3acce9cb733d692e13316991891",
"reference": "5c830fb71a2bd3acce9cb733d692e13316991891",
"shasum": ""
},
"type": "bower-asset-library",
"extra": {
"bower-asset-main": [
"src/js.cookie.js"
],
"bower-asset-ignore": [
"travis.sh",
"test",
"Gruntfile.js",
"package.json",
".gitignore",
".jshintignore",
".jshintrc",
".tm_properties",
".travis.yml"
]
"shasum": null
},
"type": "bower-asset",
"license": [
"MIT"
]
@ -106,38 +71,18 @@
"version": "2.21.1",
"source": {
"type": "git",
"url": "https://github.com/johndyer/mediaelement.git",
"url": "https://github.com/mediaelement/mediaelement.git",
"reference": "6e80b260172f4ddc3b0bbee046775d2ba4c6f9b7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/johndyer/mediaelement/zipball/6e80b260172f4ddc3b0bbee046775d2ba4c6f9b7",
"url": "https://api.github.com/repos/mediaelement/mediaelement/zipball/6e80b260172f4ddc3b0bbee046775d2ba4c6f9b7",
"reference": "6e80b260172f4ddc3b0bbee046775d2ba4c6f9b7",
"shasum": ""
},
"type": "bower-asset-library",
"extra": {
"bower-asset-main": [
"./build/mediaelement-and-player.js",
"./build/mediaelementplayer.css"
],
"bower-asset-ignore": [
"**",
"!/build/**",
"!/bower.json",
"!/README*",
"!/changelog*"
]
"shasum": null
},
"type": "bower-asset",
"license": [
"MIT"
],
"description": "HTML5 <video> and <audio> made easy.",
"keywords": [
"audio",
"html5",
"shim",
"video"
]
},
{
@ -180,7 +125,7 @@
"sort",
"table"
],
"time": "2015-12-03 01:22:52"
"time": "2015-12-03T01:22:52+00:00"
},
{
"name": "dapphp/securimage",
@ -325,7 +270,7 @@
"recaptcha",
"spam"
],
"time": "2017-03-09 18:57:45"
"time": "2017-03-09T18:57:45+00:00"
},
{
"name": "ifixit/php-akismet",
@ -345,28 +290,28 @@
"source": {
"type": "git",
"url": "https://github.com/doctrine/instantiator.git",
"reference": "5acd2bd8c2b600ad5cc4c9180ebf0a930604d6a5"
"reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/5acd2bd8c2b600ad5cc4c9180ebf0a930604d6a5",
"reference": "5acd2bd8c2b600ad5cc4c9180ebf0a930604d6a5",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda",
"reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda",
"shasum": ""
},
"require": {
"php": ">=5.3,<8.0-DEV"
"php": "^7.1"
},
"require-dev": {
"athletic/athletic": "~0.1.8",
"ext-pdo": "*",
"ext-phar": "*",
"phpunit/phpunit": "~4.0",
"squizlabs/php_codesniffer": "~2.0"
"phpunit/phpunit": "^6.2.3",
"squizlabs/php_codesniffer": "^3.0.2"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.0.x-dev"
"dev-master": "1.2.x-dev"
}
},
"autoload": {
@ -391,20 +336,20 @@
"constructor",
"instantiate"
],
"time": "2017-02-16 16:15:51"
"time": "2017-07-22T11:58:36+00:00"
},
{
"name": "myclabs/deep-copy",
"version": "1.6.0",
"version": "1.x-dev",
"source": {
"type": "git",
"url": "https://github.com/myclabs/DeepCopy.git",
"reference": "5a5a9fc8025a08d8919be87d6884d5a92520cefe"
"reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/5a5a9fc8025a08d8919be87d6884d5a92520cefe",
"reference": "5a5a9fc8025a08d8919be87d6884d5a92520cefe",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/8e6e04167378abf1ddb4d3522d8755c5fd90d102",
"reference": "8e6e04167378abf1ddb4d3522d8755c5fd90d102",
"shasum": ""
},
"require": {
@ -433,7 +378,7 @@
"object",
"object graph"
],
"time": "2017-01-26T22:05:40+00:00"
"time": "2017-04-12T18:52:22+00:00"
},
{
"name": "phpdocumentor/reflection-common",
@ -441,12 +386,12 @@
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionCommon.git",
"reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c"
"reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c",
"reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6",
"reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6",
"shasum": ""
},
"require": {
@ -487,26 +432,26 @@
"reflection",
"static analysis"
],
"time": "2015-12-27 11:43:31"
"time": "2017-09-11T18:02:19+00:00"
},
{
"name": "phpdocumentor/reflection-docblock",
"version": "3.1.1",
"version": "4.1.1",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e"
"reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/8331b5efe816ae05461b7ca1e721c01b46bafb3e",
"reference": "8331b5efe816ae05461b7ca1e721c01b46bafb3e",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/2d3d238c433cf69caeb4842e97a3223a116f94b2",
"reference": "2d3d238c433cf69caeb4842e97a3223a116f94b2",
"shasum": ""
},
"require": {
"php": ">=5.5",
"php": "^7.0",
"phpdocumentor/reflection-common": "^1.0@dev",
"phpdocumentor/type-resolver": "^0.2.0",
"phpdocumentor/type-resolver": "^0.4.0",
"webmozart/assert": "^1.0"
},
"require-dev": {
@ -532,24 +477,24 @@
}
],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"time": "2016-09-30T07:12:33+00:00"
"time": "2017-08-30T18:51:59+00:00"
},
{
"name": "phpdocumentor/type-resolver",
"version": "0.2.1",
"version": "0.4.0",
"source": {
"type": "git",
"url": "https://github.com/phpDocumentor/TypeResolver.git",
"reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb"
"reference": "9c977708995954784726e25d0cd1dddf4e65b0f7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb",
"reference": "e224fb2ea2fba6d3ad6fdaef91cd09a172155ccb",
"url": "https://api.github.com/repos/phpDocumentor/TypeResolver/zipball/9c977708995954784726e25d0cd1dddf4e65b0f7",
"reference": "9c977708995954784726e25d0cd1dddf4e65b0f7",
"shasum": ""
},
"require": {
"php": ">=5.5",
"php": "^5.5 || ^7.0",
"phpdocumentor/reflection-common": "^1.0"
},
"require-dev": {
@ -579,7 +524,7 @@
"email": "me@mikevanriel.com"
}
],
"time": "2016-11-25T06:54:22+00:00"
"time": "2017-07-14T14:27:02+00:00"
},
{
"name": "phpspec/prophecy",
@ -587,18 +532,18 @@
"source": {
"type": "git",
"url": "https://github.com/phpspec/prophecy.git",
"reference": "abe41cb27f4e4207c6f54a09272969fe55e0bbff"
"reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/abe41cb27f4e4207c6f54a09272969fe55e0bbff",
"reference": "abe41cb27f4e4207c6f54a09272969fe55e0bbff",
"url": "https://api.github.com/repos/phpspec/prophecy/zipball/c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6",
"reference": "c9b8c6088acd19d769d4cc0ffa60a9fe34344bd6",
"shasum": ""
},
"require": {
"doctrine/instantiator": "^1.0.2",
"php": "^5.3|^7.0",
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2",
"phpdocumentor/reflection-docblock": "^2.0|^3.0.2|^4.0",
"sebastian/comparator": "^1.1|^2.0",
"sebastian/recursion-context": "^1.0|^2.0|^3.0"
},
@ -642,7 +587,7 @@
"spy",
"stub"
],
"time": "2017-03-03 17:09:02"
"time": "2017-09-04T11:05:03+00:00"
},
{
"name": "phpunit/php-code-coverage",
@ -650,12 +595,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "cb9dd0ea37df29fa3c6ae5ac26c3408a7609cb4f"
"reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/cb9dd0ea37df29fa3c6ae5ac26c3408a7609cb4f",
"reference": "cb9dd0ea37df29fa3c6ae5ac26c3408a7609cb4f",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/ef7b2f56815df854e66ceaee8ebe9393ae36a40d",
"reference": "ef7b2f56815df854e66ceaee8ebe9393ae36a40d",
"shasum": ""
},
"require": {
@ -705,7 +650,7 @@
"testing",
"xunit"
],
"time": "2017-03-07 10:28:00"
"time": "2017-04-02T07:44:40+00:00"
},
{
"name": "phpunit/php-file-iterator",
@ -752,7 +697,7 @@
"filesystem",
"iterator"
],
"time": "2016-10-03 07:40:28"
"time": "2016-10-03T07:40:28+00:00"
},
{
"name": "phpunit/php-text-template",
@ -842,7 +787,7 @@
"keywords": [
"timer"
],
"time": "2017-03-07 15:42:04"
"time": "2017-03-07T15:42:04+00:00"
},
{
"name": "phpunit/php-token-stream",
@ -850,20 +795,20 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
"reference": "9ddb181faa4a3841fe131c357fd01de75cbb4da9"
"reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9ddb181faa4a3841fe131c357fd01de75cbb4da9",
"reference": "9ddb181faa4a3841fe131c357fd01de75cbb4da9",
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/9a02332089ac48e704c70f6cefed30c224e3c0b0",
"reference": "9a02332089ac48e704c70f6cefed30c224e3c0b0",
"shasum": ""
},
"require": {
"ext-tokenizer": "*",
"php": "^5.6 || ^7.0"
"php": "^7.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.0"
"phpunit/phpunit": "^6.2.4"
},
"type": "library",
"extra": {
@ -891,7 +836,7 @@
"keywords": [
"tokenizer"
],
"time": "2017-03-07 07:36:57"
"time": "2017-08-20T05:47:52+00:00"
},
{
"name": "phpunit/phpunit",
@ -899,12 +844,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "d421807ce5f372ecaf0bff3a5d41f5c60a18329f"
"reference": "4eba3374803c6c0903145e8940844e6f1d665c07"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/d421807ce5f372ecaf0bff3a5d41f5c60a18329f",
"reference": "d421807ce5f372ecaf0bff3a5d41f5c60a18329f",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/4eba3374803c6c0903145e8940844e6f1d665c07",
"reference": "4eba3374803c6c0903145e8940844e6f1d665c07",
"shasum": ""
},
"require": {
@ -922,7 +867,7 @@
"phpunit/php-timer": "^1.0.6",
"phpunit/phpunit-mock-objects": "^3.2",
"sebastian/comparator": "^1.2.4",
"sebastian/diff": "~1.2",
"sebastian/diff": "^1.4.3",
"sebastian/environment": "^1.3.4 || ^2.0",
"sebastian/exporter": "~2.0",
"sebastian/global-state": "^1.1",
@ -973,7 +918,7 @@
"testing",
"xunit"
],
"time": "2017-03-09 13:47:42"
"time": "2017-09-01T08:38:37+00:00"
},
{
"name": "phpunit/phpunit-mock-objects",
@ -981,12 +926,12 @@
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "4001a301f86fc006c32f532a741ab613f2bd8990"
"reference": "a23b761686d50a560cc56233b9ecf49597cc9118"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/4001a301f86fc006c32f532a741ab613f2bd8990",
"reference": "4001a301f86fc006c32f532a741ab613f2bd8990",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/a23b761686d50a560cc56233b9ecf49597cc9118",
"reference": "a23b761686d50a560cc56233b9ecf49597cc9118",
"shasum": ""
},
"require": {
@ -1032,7 +977,7 @@
"mock",
"xunit"
],
"time": "2017-03-07 08:47:31"
"time": "2017-06-30T09:13:00+00:00"
},
{
"name": "sebastian/code-unit-reverse-lookup",
@ -1077,7 +1022,7 @@
],
"description": "Looks up which function or method a line of code belongs to",
"homepage": "https://github.com/sebastianbergmann/code-unit-reverse-lookup/",
"time": "2017-03-04 10:23:55"
"time": "2017-03-04T10:23:55+00:00"
},
{
"name": "sebastian/comparator",
@ -1141,20 +1086,20 @@
"compare",
"equality"
],
"time": "2017-03-07 10:34:43"
"time": "2017-03-07T10:34:43+00:00"
},
{
"name": "sebastian/diff",
"version": "dev-master",
"version": "1.4.x-dev",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/diff.git",
"reference": "763d7adeb8c35d2af2b04c0f6cafeee059074dfb"
"reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/763d7adeb8c35d2af2b04c0f6cafeee059074dfb",
"reference": "763d7adeb8c35d2af2b04c0f6cafeee059074dfb",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/7f066a26a962dbe58ddea9f72a4e82874a3975a4",
"reference": "7f066a26a962dbe58ddea9f72a4e82874a3975a4",
"shasum": ""
},
"require": {
@ -1193,27 +1138,27 @@
"keywords": [
"diff"
],
"time": "2017-03-07 07:26:53"
"time": "2017-05-22T07:24:03+00:00"
},
{
"name": "sebastian/environment",
"version": "dev-master",
"version": "2.0.x-dev",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/environment.git",
"reference": "144fedf9aa8e3f1c52199f3634eb699cb59741d9"
"reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/144fedf9aa8e3f1c52199f3634eb699cb59741d9",
"reference": "144fedf9aa8e3f1c52199f3634eb699cb59741d9",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/5795ffe5dc5b02460c3e34222fee8cbe245d8fac",
"reference": "5795ffe5dc5b02460c3e34222fee8cbe245d8fac",
"shasum": ""
},
"require": {
"php": "^5.6 || ^7.0"
},
"require-dev": {
"phpunit/phpunit": "^5.7 || ^6.0"
"phpunit/phpunit": "^5.0"
},
"type": "library",
"extra": {
@ -1243,7 +1188,7 @@
"environment",
"hhvm"
],
"time": "2017-03-07 12:59:58"
"time": "2016-11-26T07:53:53+00:00"
},
{
"name": "sebastian/exporter",
@ -1310,7 +1255,7 @@
"export",
"exporter"
],
"time": "2017-03-07 10:36:49"
"time": "2017-03-07T10:36:49+00:00"
},
{
"name": "sebastian/global-state",
@ -1361,7 +1306,7 @@
"keywords": [
"global state"
],
"time": "2017-02-23 14:11:06"
"time": "2017-02-23T14:11:06+00:00"
},
{
"name": "sebastian/object-enumerator",
@ -1407,7 +1352,7 @@
],
"description": "Traverses array structures and object graphs to enumerate all referenced objects",
"homepage": "https://github.com/sebastianbergmann/object-enumerator/",
"time": "2017-03-07 10:37:45"
"time": "2017-03-07T10:37:45+00:00"
},
{
"name": "sebastian/recursion-context",
@ -1460,7 +1405,7 @@
],
"description": "Provides functionality to recursively process PHP variables",
"homepage": "http://www.github.com/sebastianbergmann/recursion-context",
"time": "2017-03-08 08:21:15"
"time": "2017-03-08T08:21:15+00:00"
},
{
"name": "sebastian/resource-operations",
@ -1502,7 +1447,7 @@
],
"description": "Provides a list of PHP built-in functions that operate on resources",
"homepage": "https://www.github.com/sebastianbergmann/resource-operations",
"time": "2016-10-03 07:43:09"
"time": "2016-10-03T07:43:09+00:00"
},
{
"name": "sebastian/version",
@ -1545,27 +1490,30 @@
],
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
"homepage": "https://github.com/sebastianbergmann/version",
"time": "2016-10-03 07:35:21"
"time": "2016-10-03T07:35:21+00:00"
},
{
"name": "symfony/yaml",
"version": "dev-master",
"version": "3.4.x-dev",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "d1abb473764f82339862b114b45b3cd424b2d1a3"
"reference": "a0e15688972f012156cf1ffa076fe1203bce6bc9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/d1abb473764f82339862b114b45b3cd424b2d1a3",
"reference": "d1abb473764f82339862b114b45b3cd424b2d1a3",
"url": "https://api.github.com/repos/symfony/yaml/zipball/a0e15688972f012156cf1ffa076fe1203bce6bc9",
"reference": "a0e15688972f012156cf1ffa076fe1203bce6bc9",
"shasum": ""
},
"require": {
"php": ">=5.5.9"
"php": "^5.5.9|>=7.0.8"
},
"conflict": {
"symfony/console": "<3.4"
},
"require-dev": {
"symfony/console": "~2.8|~3.0"
"symfony/console": "~3.4|~4.0"
},
"suggest": {
"symfony/console": "For validating YAML files using the lint command"
@ -1573,7 +1521,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.3-dev"
"dev-master": "3.4-dev"
}
},
"autoload": {
@ -1600,7 +1548,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2017-03-07 16:54:31"
"time": "2017-09-17T10:10:45+00:00"
},
{
"name": "webmozart/assert",
@ -1650,7 +1598,7 @@
"check",
"validate"
],
"time": "2016-11-23 20:04:41"
"time": "2016-11-23T20:04:41+00:00"
}
],
"aliases": [],

View file

@ -10,6 +10,7 @@ require_once "core/sys_config.inc.php";
require_once "core/util.inc.php";
require_once "lib/context.php";
require_once "vendor/autoload.php";
require_once "core/imageboard.pack.php";
// set up and purify the environment
_version_check();
@ -17,17 +18,17 @@ _sanitise_environment();
// load base files
ctx_log_start("Opening files");
$files = array_merge(
$_shm_files = array_merge(
zglob("core/*.php"),
zglob("ext/{".ENABLED_EXTS."}/main.php")
);
foreach($files as $filename) {
if(basename($filename)[0] != "_") {
require_once $filename;
foreach($_shm_files as $_shm_filename) {
if(basename($_shm_filename)[0] != "_") {
require_once $_shm_filename;
}
}
unset($files);
unset($filename);
unset($_shm_files);
unset($_shm_filename);
ctx_log_endok();
// connect to the database

View file

@ -44,6 +44,14 @@ class Block {
*/
public $id;
/**
* Should this block count as content for the sake of
* the 404 handler
*
* @var boolean
*/
public $is_content = true;
/**
* Construct a block.
*
@ -58,7 +66,11 @@ class Block {
$this->body = $body;
$this->section = $section;
$this->position = $position;
$this->id = preg_replace('/[^\w]/', '',str_replace(' ', '_', is_null($id) ? (is_null($header) ? md5($body) : $header) . $section : $id));
if(is_null($id)) {
$id = (empty($header) ? md5($body) : $header) . $section;
}
$this->id = preg_replace('/[^\w]/', '',str_replace(' ', '_', $id));
}
/**

View file

@ -314,13 +314,8 @@ class MemcacheCache implements CacheEngine {
*/
public function __construct($args) {
$hp = explode(":", $args);
if(class_exists("Memcache")) {
$this->memcache = new Memcache;
@$this->memcache->pconnect($hp[0], $hp[1]);
}
else {
print "no memcache"; exit;
}
$this->memcache = new Memcache;
@$this->memcache->pconnect($hp[0], $hp[1]);
}
/**
@ -378,6 +373,100 @@ class MemcacheCache implements CacheEngine {
*/
public function get_misses() {return $this->misses;}
}
class MemcachedCache implements CacheEngine {
/** @var \Memcached|null */
public $memcache=null;
/** @var int */
private $hits=0;
/** @var int */
private $misses=0;
/**
* @param string $args
*/
public function __construct($args) {
$hp = explode(":", $args);
$this->memcache = new Memcached;
#$this->memcache->setOption(Memcached::OPT_COMPRESSION, False);
#$this->memcache->setOption(Memcached::OPT_SERIALIZER, Memcached::SERIALIZER_PHP);
#$this->memcache->setOption(Memcached::OPT_PREFIX_KEY, phpversion());
$this->memcache->addServer($hp[0], $hp[1]);
}
/**
* @param string $key
* @return array|bool|string
*/
public function get($key) {
assert('!is_null($key)');
$key = urlencode($key);
$val = $this->memcache->get($key);
$res = $this->memcache->getResultCode();
if((DEBUG_CACHE === true) || (is_null(DEBUG_CACHE) && @$_GET['DEBUG_CACHE'])) {
$hit = $res == Memcached::RES_SUCCESS ? "hit" : "miss";
file_put_contents("data/cache.log", "Cache $hit: $key\n", FILE_APPEND);
}
if($res == Memcached::RES_SUCCESS) {
$this->hits++;
return $val;
}
else if($res == Memcached::RES_NOTFOUND) {
$this->misses++;
return false;
}
else {
error_log("Memcached error during get($key): $res");
}
}
/**
* @param string $key
* @param mixed $val
* @param int $time
*/
public function set($key, $val, $time=0) {
assert('!is_null($key)');
$key = urlencode($key);
$this->memcache->set($key, $val, $time);
$res = $this->memcache->getResultCode();
if((DEBUG_CACHE === true) || (is_null(DEBUG_CACHE) && @$_GET['DEBUG_CACHE'])) {
file_put_contents("data/cache.log", "Cache set: $key ($time)\n", FILE_APPEND);
}
if($res != Memcached::RES_SUCCESS) {
error_log("Memcached error during set($key): $res");
}
}
/**
* @param string $key
*/
public function delete($key) {
assert('!is_null($key)');
$key = urlencode($key);
$this->memcache->delete($key);
$res = $this->memcache->getResultCode();
if((DEBUG_CACHE === true) || (is_null(DEBUG_CACHE) && @$_GET['DEBUG_CACHE'])) {
file_put_contents("data/cache.log", "Cache delete: $key\n", FILE_APPEND);
}
if($res != Memcached::RES_SUCCESS && $res != Memcached::RES_NOTFOUND) {
error_log("Memcached error during delete($key): $res");
}
}
/**
* @return int
*/
public function get_hits() {return $this->hits;}
/**
* @return int
*/
public function get_misses() {return $this->misses;}
}
class APCCache implements CacheEngine {
public $hits=0, $misses=0;
@ -466,10 +555,13 @@ class Database {
private function connect_cache() {
$matches = array();
if(defined("CACHE_DSN") && CACHE_DSN && preg_match("#(memcache|apc)://(.*)#", CACHE_DSN, $matches)) {
if(defined("CACHE_DSN") && CACHE_DSN && preg_match("#(memcache|memcached|apc)://(.*)#", CACHE_DSN, $matches)) {
if($matches[1] == "memcache") {
$this->cache = new MemcacheCache($matches[2]);
}
else if($matches[1] == "memcached") {
$this->cache = new MemcachedCache($matches[2]);
}
else if($matches[1] == "apc") {
$this->cache = new APCCache($matches[2]);
}
@ -598,18 +690,15 @@ class Database {
* @param string $sql
*/
private function count_execs($db, $sql, $inputarray) {
if ((defined('DEBUG_SQL') && DEBUG_SQL === true) || (!defined('DEBUG_SQL') && @$_GET['DEBUG_SQL'])) {
$fp = @fopen("data/sql.log", "a");
if($fp) {
$sql = trim(preg_replace('/\s+/msi', ' ', $sql));
if(isset($inputarray) && is_array($inputarray) && !empty($inputarray)) {
fwrite($fp, $sql." -- ".join(", ", $inputarray)."\n");
}
else {
fwrite($fp, $sql."\n");
}
fclose($fp);
if((DEBUG_SQL === true) || (is_null(DEBUG_SQL) && @$_GET['DEBUG_SQL'])) {
$sql = trim(preg_replace('/\s+/msi', ' ', $sql));
if(isset($inputarray) && is_array($inputarray) && !empty($inputarray)) {
$text = $sql." -- ".join(", ", $inputarray)."\n";
}
else {
$text = $sql."\n";
}
file_put_contents("data/sql.log", $text, FILE_APPEND);
}
if(!is_array($inputarray)) $this->query_count++;
# handle 2-dimensional input arrays
@ -617,6 +706,14 @@ class Database {
else $this->query_count++;
}
private function count_time($method, $start) {
if((DEBUG_SQL === true) || (is_null(DEBUG_SQL) && @$_GET['DEBUG_SQL'])) {
$text = $method.":".(microtime(true) - $start)."\n";
file_put_contents("data/sql.log", $text, FILE_APPEND);
}
$this->dbtime += microtime(true) - $start;
}
/**
* Execute an SQL query and return an PDO result-set.
*
@ -661,7 +758,7 @@ class Database {
public function get_all($query, $args=array()) {
$_start = microtime(true);
$data = $this->execute($query, $args)->fetchAll();
$this->dbtime += microtime(true) - $_start;
$this->count_time("get_all", $_start);
return $data;
}
@ -675,7 +772,7 @@ class Database {
public function get_row($query, $args=array()) {
$_start = microtime(true);
$row = $this->execute($query, $args)->fetch();
$this->dbtime += microtime(true) - $_start;
$this->count_time("get_row", $_start);
return $row ? $row : null;
}
@ -693,7 +790,7 @@ class Database {
foreach($stmt as $row) {
$res[] = $row[0];
}
$this->dbtime += microtime(true) - $_start;
$this->count_time("get_col", $_start);
return $res;
}
@ -711,7 +808,7 @@ class Database {
foreach($stmt as $row) {
$res[$row[0]] = $row[1];
}
$this->dbtime += microtime(true) - $_start;
$this->count_time("get_pairs", $_start);
return $res;
}
@ -725,7 +822,7 @@ class Database {
public function get_one($query, $args=array()) {
$_start = microtime(true);
$row = $this->execute($query, $args)->fetch();
$this->dbtime += microtime(true) - $_start;
$this->count_time("get_one", $_start);
return $row[0];
}

View file

@ -189,7 +189,7 @@ class Image {
* @param string[] $tags
* @return boolean
*/
public function validate_accel($tags) {
public static function validate_accel($tags) {
$yays = 0;
$nays = 0;
foreach($tags as $tag) {
@ -209,7 +209,7 @@ class Image {
* @return null|PDOStatement
* @throws SCoreException
*/
public function get_accelerated_result($tags, $offset, $limit) {
public static function get_accelerated_result($tags, $offset, $limit) {
global $database;
if(!Image::validate_accel($tags)) {
@ -282,8 +282,7 @@ class Image {
}
else {
$querylet = Image::build_search_querylet($tags);
$result = $database->execute($querylet->sql, $querylet->variables);
return $result->rowCount();
return $database->get_one("SELECT COUNT(*) AS cnt FROM ($querylet->sql) AS tbl", $querylet->variables);
}
}
@ -967,7 +966,7 @@ class Image {
}
}
assert('$positive_tag_id_array || $negative_tag_id_array');
assert('$positive_tag_id_array || $negative_tag_id_array', @$_GET['q']);
$wheres = array();
if (!empty($positive_tag_id_array)) {
$positive_tag_id_list = join(', ', $positive_tag_id_array);
@ -1210,7 +1209,7 @@ function move_upload_to_archive(DataUploadEvent $event) {
* Add a directory full of images
*
* @param $base string
* @return array
* @return array|string[]
*/
function add_dir($base) {
$results = array();
@ -1250,7 +1249,7 @@ function add_image($tmpname, $filename, $tags) {
$metadata = array();
$metadata['filename'] = $pathinfo['basename'];
$metadata['extension'] = $pathinfo['extension'];
$metadata['tags'] = $tags;
$metadata['tags'] = Tag::explode($tags);
$metadata['source'] = null;
$event = new DataUploadEvent($tmpname, $metadata);
send_event($event);

View file

@ -36,7 +36,7 @@ _d("COMPILE_ELS", false); // boolean pre-build the list of event listeners
_d("NICE_URLS", false); // boolean force niceurl mode
_d("SEARCH_ACCEL", false); // boolean use search accelerator
_d("WH_SPLITS", 1); // int how many levels of subfolders to put in the warehouse
_d("VERSION", '2.6.0'); // string shimmie version
_d("VERSION", '2.6.0+'); // string shimmie version
_d("TIMEZONE", null); // string timezone
_d("CORE_EXTS", "bbcode,user,mail,upload,image,view,handle_pixel,ext_manager,setup,upgrade,handle_404,comment,tag_list,index,tag_edit,alias_editor"); // extensions to always enable
_d("EXTRA_EXTS", ""); // string optional extra extensions

View file

@ -140,19 +140,6 @@ class User {
}
}
/**
* @param int $offset
* @param int $limit
* @return array
*/
public static function by_list(/*int*/ $offset, /*int*/ $limit=50) {
assert('is_numeric($offset)', var_export($offset, true));
assert('is_numeric($limit)', var_export($limit, true));
global $database;
$rows = $database->get_all("SELECT * FROM users WHERE id >= :start AND id < :end", array("start"=>$offset, "end"=>$offset+$limit));
return array_map("_new_user", $rows);
}
/* useful user object functions start here */

View file

@ -555,7 +555,15 @@ function make_http(/*string*/ $link) {
*/
function make_form($target, $method="POST", $multipart=False, $form_id="", $onsubmit="") {
global $user;
$auth = $user->get_auth_html();
if($method == "GET") {
$link = html_escape($target);
$target = make_link($target);
$extra_inputs = "<input type='hidden' name='q' value='$link'>";
}
else {
$extra_inputs = $user->get_auth_html();
}
$extra = empty($form_id) ? '' : 'id="'. $form_id .'"';
if($multipart) {
$extra .= " enctype='multipart/form-data'";
@ -563,7 +571,7 @@ function make_form($target, $method="POST", $multipart=False, $form_id="", $onsu
if($onsubmit) {
$extra .= ' onsubmit="'.$onsubmit.'"';
}
return '<form action="'.$target.'" method="'.$method.'" '.$extra.'>'.$auth;
return '<form action="'.$target.'" method="'.$method.'" '.$extra.'>'.$extra_inputs;
}
/**
@ -958,6 +966,17 @@ function data_path($filename) {
return $filename;
}
if (!function_exists('mb_strlen')) {
// TODO: we should warn the admin that they are missing multibyte support
function mb_strlen($str, $encoding) {
return strlen($str);
}
function mb_internal_encoding($encoding) {}
function mb_strtolower($str) {
return strtolower($str);
}
}
/**
* @param string $url
* @param string $mfile

View file

@ -42,7 +42,9 @@ class Blocks extends Extension {
foreach($blocks as $block) {
$path = implode("/", $event->args);
if(strlen($path) < 4000 && fnmatch($block['pages'], $path)) {
$page->add_block(new Block($block['title'], $block['content'], $block['area'], $block['priority']));
$b = new Block($block['title'], $block['content'], $block['area'], $block['priority']);
$b->is_content = false;
$page->add_block($b);
}
}

View file

@ -73,7 +73,7 @@ class BulkAddCSV extends Extension {
$metadata = array();
$metadata['filename'] = $pathinfo['basename'];
$metadata['extension'] = $pathinfo['extension'];
$metadata['tags'] = $tags;
$metadata['tags'] = Tag::explode($tags);
$metadata['source'] = $source;
$event = new DataUploadEvent($tmpname, $metadata);
send_event($event);

View file

@ -30,6 +30,7 @@ class Chatbox extends Extension {
// loads the chatbox at the set location
$html = "<div id=\"yshout\"></div>";
$chatblock = new Block("Chatbox", $html, "main", 97);
$chatblock->is_content = false;
$page->add_block($chatblock);
}
}

View file

@ -304,9 +304,14 @@ class CronUploader extends Extension {
/**
* Generate the necessary DataUploadEvent for a given image and tags.
*
* @param string $tmpname
* @param string $filename
* @param string $tags
*/
private function add_image($tmpname, $filename, $tags) {
assert ( file_exists ( $tmpname ) );
assert('is_string($tags)');
$pathinfo = pathinfo ( $filename );
if (! array_key_exists ( 'extension', $pathinfo )) {
@ -315,7 +320,7 @@ class CronUploader extends Extension {
$metadata = array();
$metadata ['filename'] = $pathinfo ['basename'];
$metadata ['extension'] = $pathinfo ['extension'];
$metadata ['tags'] = ""; // = $tags; doesn't work when not logged in here
$metadata ['tags'] = array(); // = $tags; doesn't work when not logged in here
$metadata ['source'] = null;
$event = new DataUploadEvent ( $tmpname, $metadata );
send_event ( $event );
@ -329,7 +334,7 @@ class CronUploader extends Extension {
// Set tags
$img = Image::by_id($event->image_id);
$img->set_tags($tags);
$img->set_tags(Tag::explode($tags));
}
private function generate_image_queue($base = "", $subdir = "") {

View file

@ -43,10 +43,7 @@ class Handle404 extends Extension {
private function count_main($blocks) {
$n = 0;
foreach($blocks as $block) {
if($block->section == "main") $n++; // more hax.
}
if(ext_is_live("Chatbox")) {
$n--; // even more hax.
if($block->section == "main" && $block->is_content) $n++; // more hax.
}
return $n;
}

View file

@ -35,8 +35,10 @@ class ArchiveFileHandler extends Extension {
exec($cmd);
$results = add_dir($tmpdir);
if(count($results) > 0) {
// FIXME no theme?
$this->theme->add_status("Adding files", $results);
// Not all themes have the add_status() method, so need to check before calling.
if (method_exists($this->theme, "add_status")) {
$this->theme->add_status("Adding files", $results);
}
}
deltree($tmpdir);
$event->image_id = -2; // default -1 = upload wasn't handled

View file

@ -37,7 +37,7 @@ class FlashFileHandler extends DataHandlerExtension {
$image->hash = $metadata['hash'];
$image->filename = $metadata['filename'];
$image->ext = $metadata['extension'];
$image->tag_array = $metadata['tags'];
$image->tag_array = is_array($metadata['tags']) ? $metadata['tags'] : Tag::explode($metadata['tags']);
$image->source = $metadata['source'];
$info = getimagesize($filename);

View file

@ -67,7 +67,7 @@ class IcoFileHandler extends Extension {
$image->hash = $metadata['hash'];
$image->filename = $metadata['filename'];
$image->ext = $metadata['extension'];
$image->tag_array = $metadata['tags'];
$image->tag_array = is_array($metadata['tags']) ? $metadata['tags'] : Tag::explode($metadata['tags']);
$image->source = $metadata['source'];
return $image;

View file

@ -43,7 +43,7 @@ class MP3FileHandler extends DataHandlerExtension {
$image->filename = $metadata['filename'];
$image->ext = $metadata['extension'];
$image->tag_array = $metadata['tags'];
$image->tag_array = is_array($metadata['tags']) ? $metadata['tags'] : Tag::explode($metadata['tags']);
$image->source = $metadata['source'];
return $image;

View file

@ -35,7 +35,7 @@ class PixelFileHandler extends DataHandlerExtension {
$image->hash = $metadata['hash'];
$image->filename = (($pos = strpos($metadata['filename'],'?')) !== false) ? substr($metadata['filename'],0,$pos) : $metadata['filename'];
$image->ext = (($pos = strpos($metadata['extension'],'?')) !== false) ? substr($metadata['extension'],0,$pos) : $metadata['extension'];
$image->tag_array = $metadata['tags'];
$image->tag_array = is_array($metadata['tags']) ? $metadata['tags'] : Tag::explode($metadata['tags']);
$image->source = $metadata['source'];
return $image;

View file

@ -75,7 +75,7 @@ class SVGFileHandler extends Extension {
$image->hash = $metadata['hash'];
$image->filename = $metadata['filename'];
$image->ext = $metadata['extension'];
$image->tag_array = $metadata['tags'];
$image->tag_array = is_array($metadata['tags']) ? $metadata['tags'] : Tag::explode($metadata['tags']);
$image->source = $metadata['source'];
return $image;

View file

@ -170,7 +170,7 @@ class VideoFileHandler extends DataHandlerExtension {
$image->filesize = $metadata['size'];
$image->hash = $metadata['hash'];
$image->filename = $metadata['filename'];
$image->tag_array = $metadata['tags'];
$image->tag_array = is_array($metadata['tags']) ? $metadata['tags'] : Tag::explode($metadata['tags']);
$image->source = $metadata['source'];
return $image;

View file

@ -9,8 +9,9 @@ class VideoFileHandlerTheme extends Themelet {
$full_url = make_http($ilink);
$autoplay = $config->get_bool("video_playback_autoplay");
$loop = $config->get_bool("video_playback_loop");
$player = make_link('lib/vendor/swf/flashmediaelement.swf');
$html = "Video not playing? <a href='" . $image->parse_link_template(make_link('image/$id/$id%20-%20$tags.$ext')) . "'>Click here</a> to download the file.<br/>";
$html = "Video not playing? <a href='$ilink'>Click here</a> to download the file.<br/>";
//Browser media format support: https://developer.mozilla.org/en-US/docs/Web/HTML/Supported_media_formats
$supportedExts = ['mp4' => 'video/mp4', 'm4v' => 'video/mp4', 'ogv' => 'video/ogg', 'webm' => 'video/webm', 'flv' => 'video/flv'];
@ -22,8 +23,8 @@ class VideoFileHandlerTheme extends Themelet {
}
$html_fallback = "
<object width=\"100%\" height=\"480px\" type=\"application/x-shockwave-flash\" data=\"lib/vendor/swf/flashmediaelement.swf\">
<param name=\"movie\" value=\"lib/vendor/swf/flashmediaelement.swf\" />
<object width=\"100%\" height=\"480px\" type=\"application/x-shockwave-flash\" data=\"$player\">
<param name=\"movie\" value=\"$player\" />
<param name=\"allowFullScreen\" value=\"true\" />
<param name=\"wmode\" value=\"opaque\" />

View file

@ -265,7 +265,7 @@ class Index extends Extension {
$images = $database->cache->get("post-list:$page_number");
if(!$images) {
$images = Image::find_images(($page_number-1)*$page_size, $page_size, $search_terms);
$database->cache->set("post-list:$page_number", $images, 600);
$database->cache->set("post-list:$page_number", $images, 60);
}
}
else {

View file

@ -31,7 +31,7 @@ class Oekaki extends Extension {
$metadata = array();
$metadata['filename'] = 'oekaki.png';
$metadata['extension'] = $pathinfo['extension'];
$metadata['tags'] = 'oekaki tagme';
$metadata['tags'] = Tag::explode('oekaki tagme');
$metadata['source'] = null;
$duev = new DataUploadEvent($tmpname, $metadata);
send_event($duev);

View file

@ -500,7 +500,7 @@ class OuroborosAPI extends Extension
}
}
$meta = array();
$meta['tags'] = $post->tags;
$meta['tags'] = is_array($post->tags) ? $post->tags : Tag::explode($post->tags);
$meta['source'] = $post->source;
if (defined('ENABLED_EXTS')) {
if (strstr(ENABLED_EXTS, 'rating') !== false) {
@ -536,7 +536,8 @@ class OuroborosAPI extends Extension
if (!is_null($img)) {
$handler = $config->get_string("upload_collision_handler");
if($handler == "merge") {
$merged = array_merge(Tag::explode($post->tags), $img->get_tag_array());
$postTags = is_array($post->tags) ? $post->tags : Tag::explode($post->tags);
$merged = array_merge($postTags, $img->get_tag_array());
send_event(new TagSetEvent($img, $merged));
// This is really the only thing besides tags we should care

View file

@ -15,13 +15,24 @@
class RegenThumb extends Extension {
public function onPageRequest(PageRequestEvent $event) {
global $page, $user;
global $database, $page, $user;
if($event->page_matches("regen_thumb") && $user->can("delete_image") && isset($_POST['image_id'])) {
if($event->page_matches("regen_thumb/one") && $user->can("delete_image") && isset($_POST['image_id'])) {
$image = Image::by_id(int_escape($_POST['image_id']));
send_event(new ThumbnailGenerationEvent($image->hash, $image->ext, true));
$this->theme->display_results($page, $image);
}
if($event->page_matches("regen_thumb/mass") && $user->can("delete_image") && isset($_POST['tags'])) {
$tags = Tag::explode(strtolower($_POST['tags']), false);
$images = Image::find_images(0, 10000, $tags);
foreach($images as $image) {
send_event(new ThumbnailGenerationEvent($image->hash, $image->ext, true));
}
$page->set_mode("redirect");
$page->set_redirect(make_link("post/list"));
}
}
public function onImageAdminBlockBuilding(ImageAdminBlockBuildingEvent $event) {
@ -30,5 +41,12 @@ class RegenThumb extends Extension {
$event->add_part($this->theme->get_buttons_html($event->image->id));
}
}
public function onPostListBuilding(PostListBuildingEvent $event) {
global $user;
if($user->can("delete_image") && !empty($event->search_terms)) {
$event->add_control($this->theme->mtr_html(implode(" ", $event->search_terms)));
}
}
}

View file

@ -6,7 +6,7 @@ class RegenThumbTest extends ShimmiePHPUnitTestCase {
$this->get_page("post/view/$image_id");
$_POST['image_id'] = $image_id;
$this->get_page("regen_thumb");
$this->get_page("regen_thumb/one");
$this->assert_title("Thumbnail Regenerated");
# FIXME: test that the thumb's modified time has been updated

View file

@ -9,7 +9,7 @@ class RegenThumbTheme extends Themelet {
*/
public function get_buttons_html($image_id) {
return "
".make_form(make_link("regen_thumb"))."
".make_form(make_link("regen_thumb/one"))."
<input type='hidden' name='image_id' value='$image_id'>
<input type='submit' value='Regenerate Thumbnail'>
</form>
@ -29,5 +29,15 @@ class RegenThumbTheme extends Themelet {
$page->add_block(new NavBlock());
$page->add_block(new Block("Thumbnail", $this->build_thumb_html($image)));
}
public function mtr_html($terms) {
$h_terms = html_escape($terms);
$html = make_form(make_link("regen_thumb/mass"), "POST") . "
<input type='hidden' name='tags' value='$h_terms'>
<input type='submit' value='Regen all thumbs' onclick='return confirm(\"This can use a lot of CPU time.\\nAre you sure you want to do this?\")'>
</form>
";
return $html;
}
}

19
ext/resize/script.js Normal file
View file

@ -0,0 +1,19 @@
$(function() {
var original_width = $("#original_width").val();
var original_height = $("#original_height").val();
$("#resize_width").change(function() {
if($("#resize_aspect").prop("checked")) {
$("#resize_height").val(
Math.round($("#resize_width").val() / original_width * original_height)
);
}
});
$("#resize_height").change(function() {
if($("#resize_aspect").prop("checked")) {
$("#resize_width").val(
Math.round($("#resize_height").val() / original_height * original_width)
);
}
});
});

View file

@ -46,7 +46,7 @@ class TagList extends Extension {
$this->theme->display_page($page);
}
else if($event->page_matches("api/internal/tag_list/complete")) {
if(!isset($_GET["s"])) return;
if(!isset($_GET["s"]) || $_GET["s"] == "" || $_GET["s"] == "_") return;
//$limit = 0;
$cache_key = "autocomplete-" . strtolower($_GET["s"]);
@ -269,7 +269,7 @@ class TagList extends Extension {
$cache_key = data_path("cache/tag_alpha-" . md5("ta" . $tags_min . $starts_with) . ".html");
if(file_exists($cache_key)) {return file_get_contents($cache_key);}
$tag_data = $database->get_all($database->scoreql_to_sql("
$tag_data = $database->get_pairs($database->scoreql_to_sql("
SELECT tag, count
FROM tags
WHERE count >= :tags_min
@ -296,8 +296,10 @@ class TagList extends Extension {
mb_internal_encoding('UTF-8');
$lastLetter = "";
foreach($tag_data as $row) {
$tag = $row['tag'];
# postres utf8 string sort ignores punctuation, so we get "aza, a-zb, azc"
# which breaks down into "az, a-, az" :(
ksort($tag_data, SORT_STRING | SORT_FLAG_CASE);
foreach($tag_data as $tag => $count) {
if($lastLetter != mb_strtolower(substr($tag, 0, count($starts_with)+1))) {
$lastLetter = mb_strtolower(substr($tag, 0, count($starts_with)+1));
$h_lastLetter = html_escape($lastLetter);
@ -305,7 +307,6 @@ class TagList extends Extension {
}
$link = $this->tag_link($tag);
$h_tag = html_escape($tag);
$count = $row['count'];
$html .= "<a href='$link'>$h_tag&nbsp;($count)</a>\n";
}

View file

@ -95,7 +95,7 @@ class UserPage extends Extension {
}
public function onPageRequest(PageRequestEvent $event) {
global $config, $page, $user;
global $config, $database, $page, $user;
$this->show_user_info();
@ -115,15 +115,32 @@ class UserPage extends Extension {
$this->page_create();
}
else if($event->get_arg(0) == "list") {
// select users.id,name,joindate,admin,
// (select count(*) from images where images.owner_id=users.id) as images,
// (select count(*) from comments where comments.owner_id=users.id) as comments from users;
$offset = 0;
$limit = 50;
// select users.id,name,joindate,admin,image_count,comment_count
// from users
// join (select owner_id,count(*) as image_count from images group by owner_id) as _images on _images.owner_id=users.id
// join (select owner_id,count(*) as comment_count from comments group by owner_id) as _comments on _comments.owner_id=users.id;
$this->theme->display_user_list($page, User::by_list(0), $user);
$q = "SELECT * FROM users WHERE 1=1";
$a = array("offset"=>$offset, "limit"=>$limit);
if(@$_GET['username']) {
$q .= " AND SCORE_STRNORM(name) LIKE SCORE_STRNORM(:name)";
$a["name"] = '%' . $_GET['username'] . '%';
}
if($user->can('delete_user') && @$_GET['email']) {
$q .= " AND SCORE_STRNORM(name) LIKE SCORE_STRNORM(:email)";
$a["email"] = '%' . $_GET['email'] . '%';
}
if(@$_GET['class']) {
$q .= " AND class LIKE :class";
$a["class"] = $_GET['class'];
}
$q .= " LIMIT :limit OFFSET :offset";
$rows = $database->get_all($database->scoreql_to_sql($q), $a);
$users = array_map("_new_user", $rows);
$this->theme->display_user_list($page, $users, $user);
}
else if($event->get_arg(0) == "logout") {
$this->page_logout();

View file

@ -9,18 +9,56 @@ class UserPageTheme extends Themelet {
"There should be a login box to the left"));
}
/**
* @param Page $page
* @param User[] $users
* @param User $user
*/
public function display_user_list(Page $page, $users, User $user) {
$page->set_title("User List");
$page->set_heading("User List");
$page->add_block(new NavBlock());
$html = "<table>";
$html .= "<tr><td>Name</td></tr>";
$html = "<table class='zebra'>";
$html .= "<tr>";
$html .= "<td>Name</td>";
if($user->can('delete_user'))
$html .= "<td>Email</td>";
$html .= "<td>Class</td>";
$html .= "<td>Action</td>";
$html .= "</tr>";
$h_username = html_escape(@$_GET['username']);
$h_email = html_escape(@$_GET['email']);
$h_class = html_escape(@$_GET['class']);
$html .= "<tr>" . make_form("user_admin/list", "GET");
$html .= "<td><input type='text' name='username' value='$h_username'/></td>";
if($user->can('delete_user'))
$html .= "<td><input type='email' name='email' value='$h_email'/></td>";
$html .= "<td><input type='text' name='class' value='$h_class'/></td>";
$html .= "<td><input type='submit' value='Search'/></td>";
$html .= "</form></tr>";
foreach($users as $duser) {
$h_name = html_escape($duser->name);
$h_email = html_escape($duser->email);
$h_class = html_escape($duser->class->name);
$u_link = make_link("user/" . url_escape($duser->name));
$u_posts = make_link("post/list/user_id=" . url_escape($duser->id) . "/1");
$html .= "<tr>";
$html .= "<td><a href='".make_link("user/".url_escape($duser->name))."'>".html_escape($duser->name)."</a></td>";
$html .= "<td><a href='$u_link'>$h_name</a></td>";
if($user->can('delete_user'))
$html .= "<td>$h_email</td>";
$html .= "<td>$h_class</td>";
$html .= "<td><a href='$u_posts'>Show Posts</a></td>";
$html .= "</tr>";
}
$html .= "</table>";
$page->add_block(new Block("Users", $html));
}

View file

@ -30,11 +30,9 @@ class ViewImageTheme extends Themelet {
protected function build_pin(Image $image) {
if(isset($_GET['search'])) {
$search_terms = explode(' ', $_GET['search']);
$query = "search=".url_escape($_GET['search']);
}
else {
$search_terms = array();
$query = null;
}

View file

@ -132,7 +132,7 @@ abstract class ShimmiePHPUnitTestCase extends \PHPUnit_Framework_TestCase {
// post things
/**
* @param string $filename
* @param string|string[] $tags
* @param string $tags
* @return int
*/
protected function post_image($filename, $tags) {

View file

@ -1,9 +1,9 @@
#!/bin/sh
php \
-d extension.dir=/usr/lib/php/extensions/no-debug-non-zts-20121212/ \
-d extension=xdebug.so \
-d xdebug.profiler_output_dir=./data/prof/ \
-d xdebug.profiler_enable=1 \
./phpunit.phar \
./vendor/bin/phpunit \
--config tests/phpunit.xml \
--coverage-clover data/coverage.clover
# -d extension.dir=/usr/local/Cellar/php71-xdebug/2.5.5/ \
# -d extension=xdebug.so \