diff --git a/core/database.class.php b/core/database.class.php
index 42f8dd20..0d19c9e0 100644
--- a/core/database.class.php
+++ b/core/database.class.php
@@ -680,6 +680,7 @@ class Database {
*/
public function create_table($name, $data) {
if(is_null($this->engine)) { $this->connect_engine(); }
+ $data = trim($data, ", \t\n\r\0\x0B"); // mysql doesn't like trailing commas
$this->execute($this->engine->create_table_sql($name, $data));
}
diff --git a/core/util.inc.php b/core/util.inc.php
index 04c23078..10730bd1 100644
--- a/core/util.inc.php
+++ b/core/util.inc.php
@@ -960,11 +960,6 @@ function transload($url, $mfile) {
fwrite($fp, $data);
fclose($fp);
- //
- // Scrutinizer-ci complains that $http_response_header does not exist,
- // however, $http_response_header is actually a super-global.
- // I have filed a bug with PHP-Analyzer here: https://github.com/scrutinizer-ci/php-analyzer/issues/212
- //
$headers = http_parse_headers(implode("\n", $http_response_header));
return $headers;
@@ -996,17 +991,29 @@ if (!function_exists('http_parse_headers')) { #http://www.php.net/manual/en/func
}
}
-function findHeader ($headers, $name){
- //HTTP Headers can sometimes be lowercase which will cause issues.
- //In cases like these, we need to make sure to check for them if the camelcase version does not exist.
- $header = FALSE;
+/**
+ * HTTP Headers can sometimes be lowercase which will cause issues.
+ * In cases like these, we need to make sure to check for them if the camelcase version does not exist.
+ *
+ * @param array $headers
+ * @param mixed $key
+ * @return mixed
+ */
+function findHeader ($headers, $name) {
+ if (!is_array($headers)) {
+ return false;
+ }
+
+ $header = false;
- if(array_key_exists($name, $headers)){
+ if(array_key_exists($name, $headers)) {
$header = $headers[$name];
- }else{
- $headers = array_change_key_case($headers);
- if(array_key_exists(strtolower($name), $headers)){
- $header = $headers[strtolower($name)];
+ } else {
+ $headers = array_change_key_case($headers); // convert all to lower case.
+ $lc_name = strtolower($name);
+
+ if(array_key_exists($lc_name, $headers)) {
+ $header = $headers[$lc_name];
}
}
diff --git a/ext/handle_pixel/script.js b/ext/handle_pixel/script.js
index 8c3a50dd..83bd56ac 100644
--- a/ext/handle_pixel/script.js
+++ b/ext/handle_pixel/script.js
@@ -1,4 +1,29 @@
$(function() {
+ function zoom(zoom_type) {
+ var img = $('.shm-main-image');
+
+ if(zoom_type == "full") {
+ img.css('max-width', img.data('width') + 'px');
+ img.css('max-height', img.data('height') + 'px');
+ }
+ if(zoom_type == "width") {
+ img.css('max-width', '95%');
+ img.css('max-height', img.data('height') + 'px');
+ }
+ if(zoom_type == "height") {
+ img.css('max-width', img.data('width') + 'px');
+ img.css('max-height', (window.innerHeight * 0.95) + 'px');
+ }
+ if(zoom_type == "both") {
+ img.css('max-width', '95%');
+ img.css('max-height', (window.innerHeight * 0.95) + 'px');
+ }
+
+ $(".shm-zoomer").val(zoom_type);
+
+ $.cookie("ui-image-zoom", zoom_type, {path: '/', expires: 365});
+ }
+
$(".shm-zoomer").change(function(e) {
zoom(this.options[this.selectedIndex].value);
});
@@ -14,27 +39,3 @@ $(function() {
zoom($.cookie("ui-image-zoom"));
}
});
-
-function zoom(zoom_type) {
- var img = $('.shm-main-image');
- if(zoom_type == "full") {
- img.css('max-width', img.data('width') + 'px');
- img.css('max-height', img.data('height') + 'px');
- }
- if(zoom_type == "width") {
- img.css('max-width', '95%');
- img.css('max-height', img.data('height') + 'px');
- }
- if(zoom_type == "height") {
- img.css('max-width', img.data('width') + 'px');
- img.css('max-height', (window.innerHeight * 0.95) + 'px');
- }
- if(zoom_type == "both") {
- img.css('max-width', '95%');
- img.css('max-height', (window.innerHeight * 0.95) + 'px');
- }
-
- $(".shm-zoomer").val(zoom_type);
-
- $.cookie("ui-image-zoom", zoom_type, {path: '/', expires: 365});
-}
diff --git a/ext/tag_edit/theme.php b/ext/tag_edit/theme.php
index 1e9bf021..5536a8bf 100644
--- a/ext/tag_edit/theme.php
+++ b/ext/tag_edit/theme.php
@@ -49,7 +49,7 @@ class TagEditTheme extends Themelet {
".($user->can("edit_image_tag") ? "
$h_tag_links
-
+
" : "
$h_tag_links
")."
diff --git a/ext/upload/main.php b/ext/upload/main.php
index f0166008..c63af261 100644
--- a/ext/upload/main.php
+++ b/ext/upload/main.php
@@ -364,9 +364,10 @@ class Upload extends Extension {
$tmp_filename = tempnam(ini_get('upload_tmp_dir'), "shimmie_transload");
+ // transload() returns Array or Bool, depending on the transload_engine.
$headers = transload($url, $tmp_filename);
-
- $s_filename = findHeader($headers, 'Content-Disposition');
+
+ $s_filename = is_array($headers) ? findHeader($headers, 'Content-Disposition') : null;
$h_filename = ($s_filename ? preg_replace('/^.*filename="([^ ]+)"/i', '$1', $s_filename) : null);
$filename = $h_filename ?: basename($url);
@@ -384,10 +385,15 @@ class Upload extends Extension {
$pathinfo = pathinfo($url);
$metadata = array();
$metadata['filename'] = $filename;
- $metadata['extension'] = getExtension(findHeader($headers, 'Content-Type')) ?: $pathinfo['extension'];
$metadata['tags'] = $tags;
$metadata['source'] = (($url == $source) && !$config->get_bool('upload_tlsource') ? "" : $source);
+ if (is_array($headers)) {
+ $metadata['extension'] = getExtension(findHeader($headers, 'Content-Type'));
+ } else {
+ $metadata['extension'] = $pathinfo['extension'];
+ }
+
/* check for locked > adds to metadata if it has */
if(!empty($locked)){
$metadata['locked'] = $locked ? "on" : "";
diff --git a/lib/jquery.timeago-1.3.1.min.js b/lib/jquery.timeago-1.3.1.min.js
index 913b431d..6c4b2238 100644
--- a/lib/jquery.timeago-1.3.1.min.js
+++ b/lib/jquery.timeago-1.3.1.min.js
@@ -14,4 +14,4 @@
* Copyright (c) 2008-2013, Ryan McGeary (ryan -[at]- mcgeary [*dot*] org)
*/
-(function(e){if(typeof define==="function"&&define.amd){define(["jquery"],e)}else{e(jQuery)}})(function(e){function r(){var n=i(this);var r=t.settings;if(!isNaN(n.datetime)){if(r.cutoff==0||o(n.datetime)0&&!(t.isTime(n)&&n.attr("title"))){n.attr("title",r)}}return n.data("timeago")}function s(e){return t.inWords(o(e))}function o(e){return(new Date).getTime()-e.getTime()}e.timeago=function(t){if(t instanceof Date){return s(t)}else if(typeof t==="string"){return s(e.timeago.parse(t))}else if(typeof t==="number"){return s(new Date(t))}else{return s(e.timeago.datetime(t))}};var t=e.timeago;e.extend(e.timeago,{settings:{refreshMillis:6e4,allowFuture:false,localeTitle:false,cutoff:0,strings:{prefixAgo:null,prefixFromNow:null,suffixAgo:"ago",suffixFromNow:"from now",seconds:"less than a minute",minute:"about a minute",minutes:"%d minutes",hour:"about an hour",hours:"about %d hours",day:"a day",days:"%d days",month:"about a month",months:"%d months",year:"about a year",years:"%d years",wordSeparator:" ",numbers:[]}},inWords:function(t){function l(r,i){var s=e.isFunction(r)?r(i,t):r;var o=n.numbers&&n.numbers[i]||i;return s.replace(/%d/i,o)}var n=this.settings.strings;var r=n.prefixAgo;var i=n.suffixAgo;if(this.settings.allowFuture){if(t<0){r=n.prefixFromNow;i=n.suffixFromNow}}var s=Math.abs(t)/1e3;var o=s/60;var u=o/60;var a=u/24;var f=a/365;var c=s<45&&l(n.seconds,Math.round(s))||s<90&&l(n.minute,1)||o<45&&l(n.minutes,Math.round(o))||o<90&&l(n.hour,1)||u<24&&l(n.hours,Math.round(u))||u<42&&l(n.day,1)||a<30&&l(n.days,Math.round(a))||a<45&&l(n.month,1)||a<365&&l(n.months,Math.round(a/30))||f<1.5&&l(n.year,1)||l(n.years,Math.round(f));var h=n.wordSeparator||"";if(n.wordSeparator===undefined){h=" "}return e.trim([r,c,i].join(h))},parse:function(t){var n=e.trim(t);n=n.replace(/\.\d+/,"");n=n.replace(/-/,"/").replace(/-/,"/");n=n.replace(/T/," ").replace(/Z/," UTC");n=n.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2");return new Date(n)},datetime:function(n){var r=t.isTime(n)?e(n).attr("datetime"):e(n).attr("title");return t.parse(r)},isTime:function(t){return e(t).get(0).tagName.toLowerCase()==="time"}});var n={init:function(){var n=e.proxy(r,this);n();var i=t.settings;if(i.refreshMillis>0){setInterval(n,i.refreshMillis)}},update:function(n){e(this).data("timeago",{datetime:t.parse(n)});r.apply(this)}};e.fn.timeago=function(e,t){var r=e?n[e]:n.init;if(!r){throw new Error("Unknown function name '"+e+"' for timeago")}this.each(function(){r.call(this,t)});return this};document.createElement("abbr");document.createElement("time")})
+(function(e){if(typeof define==="function"&&define.amd){define(["jquery"],e)}else{e(jQuery)}})(function(e){function r(){var n=i(this);var r=t.settings;if(!isNaN(n.datetime)){if(r.cutoff==0||o(n.datetime)0&&!(t.isTime(n)&&n.attr("title"))){n.attr("title",r)}}return n.data("timeago")}function s(e){return t.inWords(o(e))}function o(e){return(new Date).getTime()-e.getTime()}e.timeago=function(t){if(t instanceof Date){return s(t)}else if(typeof t==="string"){return s(e.timeago.parse(t))}else if(typeof t==="number"){return s(new Date(t))}else{return s(e.timeago.datetime(t))}};var t=e.timeago;e.extend(e.timeago,{settings:{refreshMillis:6e4,allowFuture:false,localeTitle:false,cutoff:0,strings:{prefixAgo:null,prefixFromNow:null,suffixAgo:"ago",suffixFromNow:"from now",seconds:"less than a minute",minute:"about a minute",minutes:"%d minutes",hour:"about an hour",hours:"about %d hours",day:"a day",days:"%d days",month:"about a month",months:"%d months",year:"about a year",years:"%d years",wordSeparator:" ",numbers:[]}},inWords:function(t){function l(r,i){var s=e.isFunction(r)?r(i,t):r;var o=n.numbers&&n.numbers[i]||i;return s.replace(/%d/i,o)}var n=this.settings.strings;var r=n.prefixAgo;var i=n.suffixAgo;if(this.settings.allowFuture){if(t<0){r=n.prefixFromNow;i=n.suffixFromNow}}var s=Math.abs(t)/1e3;var o=s/60;var u=o/60;var a=u/24;var f=a/365;var c=s<45&&l(n.seconds,Math.round(s))||s<90&&l(n.minute,1)||o<45&&l(n.minutes,Math.round(o))||o<90&&l(n.hour,1)||u<24&&l(n.hours,Math.round(u))||u<42&&l(n.day,1)||a<30&&l(n.days,Math.round(a))||a<45&&l(n.month,1)||a<365&&l(n.months,Math.round(a/30))||f<1.5&&l(n.year,1)||l(n.years,Math.round(f));var h=n.wordSeparator||"";if(n.wordSeparator===undefined){h=" "}return e.trim([r,c,i].join(h))},parse:function(t){var n=e.trim(t);n=n.replace(/\.\d+/,"");n=n.replace(/-/,"/").replace(/-/,"/");n=n.replace(/T/," ").replace(/Z/," UTC");n=n.replace(/([\+\-]\d\d)\:?(\d\d)/," $1$2");return new Date(n)},datetime:function(n){var r=t.isTime(n)?e(n).attr("datetime"):e(n).attr("title");return t.parse(r)},isTime:function(t){return e(t).get(0).tagName.toLowerCase()==="time"}});var n={init:function(){var n=e.proxy(r,this);n();var i=t.settings;if(i.refreshMillis>0){setInterval(n,i.refreshMillis)}},update:function(n){e(this).data("timeago",{datetime:t.parse(n)});r.apply(this)}};e.fn.timeago=function(e,t){var r=e?n[e]:n.init;if(!r){throw new Error("Unknown function name '"+e+"' for timeago")}this.each(function(){r.call(this,t)});return this};document.createElement("abbr");document.createElement("time")});
|