├── README.md ├── index.php ├── public_html ├── css │ └── main.css └── js │ └── main.js └── resources ├── config.php ├── library ├── adapt.min.js ├── jquery-ui.js ├── jquery.js └── phpthumb │ ├── GdThumb.inc.php │ ├── PhpThumb.inc.php │ ├── ThumbBase.inc.php │ ├── ThumbLib.inc.php │ └── thumb_plugins │ └── gd_reflection.inc.php └── templates ├── breadcrumbs.php ├── content.php ├── functions.php ├── header.php └── menu.php /README.md: -------------------------------------------------------------------------------- 1 | PhotoLight 2 | ========== 3 | 4 | The easiest photo gallery there is. 5 | 6 | Just edit the file "config.php" (located in resources) to specify the path to your photos, and voila ! -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | . 22 | * 23 | * @category Website 24 | * @package Photolight 25 | * @author Thibaud Rohmer 26 | * @copyright 2011 Thibaud Rohmer 27 | * @license http://www.gnu.org/licenses/ 28 | * @link http://github.com/thibaud-rohmer/PhotoLight 29 | */ 30 | 31 | // load up config file 32 | require_once("resources/config.php"); 33 | require_once(TEMPLATES_PATH . "/functions.php"); 34 | 35 | 36 | $dir = $config['path']; 37 | 38 | if(file_exists($config['thumbs_path']."/new.txt")){ 39 | $new = file($config['thumbs_path']."/new.txt"); 40 | }else{ 41 | $new = array(); 42 | } 43 | 44 | // Get image 45 | if(isset($_GET['i'])){ 46 | $i = r2a(stripslashes($_GET['i']),$config['path']); 47 | if(inGoodPlace($i,$config['path'])){ 48 | return output($i); 49 | }else{ 50 | $err = "Wrong image path"; 51 | } 52 | } 53 | 54 | // Get thumb 55 | if(isset($_GET['t'])){ 56 | $i = r2a(stripslashes($_GET['t']),$config['path']); 57 | $t = r2a(stripslashes($_GET['t']),$config['thumbs_path']); 58 | // Image in good place 59 | if(inGoodPlace($i,$config['path'])){ 60 | 61 | // No thumb yet 62 | if(!file_exists($t)){ 63 | create_thumb($i,$t,$config['thumbs_path']); 64 | } 65 | if(file_exists($t)){ 66 | return output($t); 67 | }else{ 68 | return output($i); 69 | } 70 | }else{ 71 | $err = "Wrong image path"; 72 | } 73 | } 74 | 75 | 76 | // Get folder 77 | if(isset($_GET['f'])){ 78 | $d = r2a(stripslashes($_GET['f']),$config['path']); 79 | if(inGoodPlace($d,$config['path'])){ 80 | $dir = $d; 81 | }else{ 82 | $err = "Wrong path."; 83 | } 84 | } 85 | 86 | require_once(TEMPLATES_PATH . "/header.php"); 87 | 88 | ?> 89 | 90 |
91 | $err
"; 94 | } 95 | ?> 96 | 99 |
100 | 101 |
102 | 103 |
104 |
105 |
106 |
107 |
108 | Loading... 109 |
110 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /public_html/css/main.css: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * PHP versions 3, 4 and 5 4 | * 5 | * LICENSE: 6 | * 7 | * This file is part of PhotoLight. 8 | * 9 | * PhotoLight is free software: you can redistribute it and/or modify 10 | * it under the terms of the GNU General Public License as published by 11 | * the Free Software Foundation, either version 3 of the License, or 12 | * (at your option) any later version. 13 | * 14 | * PhotoLight is distributed in the hope that it will be useful, 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 | * GNU General Public License for more details. 18 | * 19 | * You should have received a copy of the GNU General Public License 20 | * along with PhotoLight. If not, see . 21 | * 22 | * @category Website 23 | * @package Photolight 24 | * @author Thibaud Rohmer 25 | * @copyright 2011 Thibaud Rohmer 26 | * @license http://www.gnu.org/licenses/ 27 | * @link http://github.com/thibaud-rohmer/PhotoLight 28 | */ 29 | 30 | *{ 31 | border: 0; 32 | margin: 0; 33 | padding: 0; 34 | } 35 | 36 | a,a:visited{ 37 | color: white; 38 | text-decoration: none; 39 | } 40 | 41 | body{ 42 | position: relative; 43 | background: #151515; 44 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 45 | font-size: 12px; 46 | } 47 | 48 | #err{ 49 | margin: auto; 50 | width: 200px; 51 | padding: 5px; 52 | text-align: center; 53 | background: red; 54 | color: white; 55 | } 56 | 57 | #loading{ 58 | display: none; 59 | position: fixed; 60 | padding: 50px 100px 50px 100px; 61 | border: 1px solid white; 62 | background: #333; 63 | color: white; 64 | top: 100px; 65 | left: 40%; 66 | } 67 | 68 | .menu_title{ 69 | margin: 0; 70 | padding: 2px; 71 | border: 1px solid black; 72 | background: #444; 73 | color: white; 74 | text-transform: uppercase; 75 | font-size: 11px; 76 | font-weight: bold; 77 | } 78 | 79 | .menu_item a, 80 | .menu_item a:visited{ 81 | color: #bbb; 82 | font-style: none; 83 | text-decoration: none; 84 | } 85 | 86 | .menu_item 87 | { 88 | padding: 2px; 89 | margin: 5px; 90 | } 91 | 92 | .menu_item:hover 93 | { 94 | background: #666; 95 | } 96 | 97 | .menu_item:hover a, 98 | .menu_item:hover a:visited{ 99 | color: white; 100 | } 101 | 102 | .content_title{ 103 | margin: auto; 104 | padding: 20px; 105 | } 106 | 107 | .content_title, 108 | .content_title a, 109 | .content_title a:visited{ 110 | font-size: 30px; 111 | font-style: italic; 112 | color: white; 113 | } 114 | 115 | .content_title a:hover{ 116 | text-decoration: underline; 117 | } 118 | 119 | .thumb { 120 | text-align: center; 121 | position: relative; 122 | } 123 | 124 | 125 | .thumb img{ 126 | max-width: 90%; 127 | max-height: 90%; 128 | border: 2px solid black; 129 | } 130 | 131 | .thumb:hover img{ 132 | border-color: yellow; 133 | cursor: pointer; 134 | } 135 | 136 | #breadcrumbs{ 137 | background: black; 138 | position:fixed; 139 | top:0; 140 | left:0; 141 | right:0; 142 | -webkit-box-shadow: rgb(0, 0, 0) 0px 0px 8px 2px; 143 | box-shadow: 0 0 8px black; 144 | z-index:100; 145 | } 146 | 147 | 148 | #content{ 149 | margin-top: 80px; 150 | padding: 20px; 151 | overflow: auto; 152 | } 153 | 154 | #menu{ 155 | visibility: hidden; 156 | position: absolute; 157 | left: 0px; 158 | width: 200px; 159 | top: 0px; 160 | bottom: 0px; 161 | bottom: 0; 162 | background: #333; 163 | overflow: auto; 164 | } 165 | 166 | #dirs, #thumbs{ 167 | text-align: center; 168 | margin: auto; 169 | } 170 | 171 | #viewer{ 172 | display: none; 173 | position: fixed; 174 | top: 150px; 175 | left: 0; 176 | right: 0; 177 | text-align: center; 178 | height: 50%; 179 | } 180 | 181 | #viewer img{ 182 | max-height: 100%; 183 | max-width: 80%; 184 | border: 1px solid black; 185 | -webkit-box-shadow: rgb(0, 0, 0) 0px 0px 8px 2px; 186 | box-shadow: 0 0 8px black; 187 | } 188 | 189 | .thumb{ 190 | display: inline-block; 191 | width : 250px; 192 | height: 160px; 193 | text-align: center; 194 | margin: 0px 1px 10px 1px; 195 | } 196 | 197 | .thumb img{ 198 | -webkit-box-shadow: rgb(0, 0, 0) 0px 0px 8px 2px; 199 | box-shadow: 0 0 8px black; 200 | } 201 | 202 | .folder{ 203 | display: inline-block; 204 | position: relative; 205 | width: 300px; 206 | height: 160px; 207 | background: blue; 208 | margin: 20px; 209 | -webkit-box-shadow: rgb(0, 0, 0) 0px 0px 8px 2px; 210 | box-shadow: 0 0 8px black; 211 | background-size: contain; 212 | cursor: pointer; 213 | border: 2px solid black; 214 | } 215 | 216 | .folder:hover{ 217 | border: 2px solid rgb(80,140,200); 218 | } 219 | 220 | .folder .title{ 221 | position: absolute; 222 | bottom: 0; 223 | left: 0; 224 | right: 0; 225 | padding: 3px; 226 | background: rgba(0,0,0,0.5); 227 | text-align: center; 228 | } 229 | 230 | .folder .new{ 231 | position: absolute; 232 | top: 0px; 233 | right: 0px; 234 | padding: 0px; 235 | width: 0px; 236 | height: 0px; 237 | border-style: solid; 238 | border-width: 0 50px 50px 0; 239 | border-color: transparent rgba(255,255,57,0.4) transparent transparent; 240 | text-align: right; 241 | } 242 | 243 | .thumb.new a img{ 244 | border-color: rgb(255,255,57); 245 | } 246 | -------------------------------------------------------------------------------- /public_html/js/main.js: -------------------------------------------------------------------------------- 1 | function update_url(url,name){ 2 | if(typeof history.pushState == 'function') { 3 | var stateObj = { foo: "bar" }; 4 | history.pushState(stateObj, "PhotoLight - " + name, url); 5 | } 6 | } 7 | 8 | $("document").ready(function(){ 9 | $(".folder").click(function(){ 10 | $("#loading").show(); 11 | t=encodeURI($(this).children(".title").children('a').attr('href')); 12 | n=$(this).children(".title").children('a').html(); 13 | $("body").load(t); 14 | update_url(t,n); 15 | }); 16 | 17 | $(".thumb").click(function(){ 18 | t=encodeURI($(this).children('a').attr('href')); 19 | $("#imgviewer").html(''); 20 | $("#viewer").fadeIn(); 21 | return false; 22 | }); 23 | 24 | $("#container").click(function(){ 25 | $("#viewer").fadeOut(); 26 | }); 27 | 28 | 29 | }); -------------------------------------------------------------------------------- /resources/config.php: -------------------------------------------------------------------------------- 1 | . 22 | * 23 | * @category Website 24 | * @package Photolight 25 | * @author Thibaud Rohmer 26 | * @copyright 2011 Thibaud Rohmer 27 | * @license http://www.gnu.org/licenses/ 28 | * @link http://github.com/thibaud-rohmer/PhotoLight 29 | */ 30 | 31 | /* 32 | Configuration array 33 | */ 34 | $config = array( 35 | "path" => "../photos/", 36 | "thumbs_path" => "../thumbs/" 37 | ); 38 | 39 | 40 | defined("LIBRARY_PATH") 41 | or define("LIBRARY_PATH", realpath(dirname(__FILE__) . '/library')); 42 | defined("TEMPLATES_PATH") 43 | or define("TEMPLATES_PATH", realpath(dirname(__FILE__) . '/templates')); 44 | 45 | ini_set("error_reporting", "true"); 46 | error_reporting(E_ALL|E_STRCT); 47 | ?> -------------------------------------------------------------------------------- /resources/library/adapt.min.js: -------------------------------------------------------------------------------- 1 | (function(a,b,c,d){function e(){clearTimeout(i);for(var c=a.innerWidth||b.documentElement.clientWidth||b.body.clientWidth||0,e,f,o,p,q=m,u=m-1;q--;){g="",e=l[q].split("="),f=e[0],p=e[1]?e[1].replace(/\s/g,""):d,e=(o=f.match("to"))?parseInt(f.split("to")[0],10):parseInt(f,10),f=o?parseInt(f.split("to")[1],10):d;if(!f&&q===u&&c>e||c>e&&c<=f){p&&(g=k+p);break}}h?h!==g&&(h=n.href=g,j&&j(q,c)):(h=n.href=g,j&&j(q,c),k&&(b.head||b.getElementsByTagName("head")[0]).appendChild(n))}function f(){clearTimeout(i),i=setTimeout(e,16)}if(c){var g,h,i,j=typeof c.callback=="function"?c.callback:d,k=c.path?c.path:"",l=c.range,m=l.length,n=b.createElement("link");n.rel="stylesheet",n.media="screen",e(),c.dynamic&&(a.addEventListener?a.addEventListener("resize",f,!1):a.attachEvent?a.attachEvent("onresize",f):a.onresize=f)}})(this,this.document,ADAPT_CONFIG) -------------------------------------------------------------------------------- /resources/library/jquery.js: -------------------------------------------------------------------------------- 1 | /*! jQuery v1.7.1 jquery.com | jquery.org/license */ 2 | (function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);if(!cm||!cl.createElement)cm=(cl.contentWindow||cl.contentDocument).document,cm.write((c.compatMode==="CSS1Compat"?"":"")+""),cm.close();d=cm.createElement(a),cm.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cl)}ck[a]=e}return ck[a]}function cu(a,b){var c={};f.each(cq.concat.apply([],cq.slice(0,b)),function(){c[this]=a});return c}function ct(){cr=b}function cs(){setTimeout(ct,0);return cr=f.now()}function cj(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ci(){try{return new a.XMLHttpRequest}catch(b){}}function cc(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;g=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?parseFloat(d):j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return F.call(this,0)},get:function(a){return a==null?this.toArray():a<0?this[this.length+a]:this[a]},pushStack:function(a,b,c){var d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return a===-1?this.slice(a):this.slice(a,a+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},slice:function(){return this.pushStack(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,f,g,h,i=arguments[0]||{},j=1,k=arguments.length,l=!1;typeof i=="boolean"&&(l=i,i=arguments[1]||{},j=2),typeof i!="object"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},type:function(a){return a==null?String(a):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw new Error(a)},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
a",d=q.getElementsByTagName("*"),e=q.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=q.getElementsByTagName("input")[0],b={leadingWhitespace:q.firstChild.nodeType===3,tbody:!q.getElementsByTagName("tbody").length,htmlSerialize:!!q.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:q.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete q.test}catch(s){b.deleteExpando=!1}!q.addEventListener&&q.attachEvent&&q.fireEvent&&(q.attachEvent("onclick",function(){b.noCloneEvent=!1}),q.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),q.appendChild(i),k=c.createDocumentFragment(),k.appendChild(q.lastChild),b.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,k.removeChild(i),k.appendChild(q),q.innerHTML="",a.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",q.style.width="2px",q.appendChild(j),b.reliableMarginRight=(parseInt((a.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(q.attachEvent)for(o in{submit:1,change:1,focusin:1})n="on"+o,p=n in q,p||(q.setAttribute(n,"return;"),p=typeof q[n]=="function"),b[o+"Bubbles"]=p;k.removeChild(q),k=g=h=j=q=i=null,f(function(){var a,d,e,g,h,i,j,k,m,n,o,r=c.getElementsByTagName("body")[0];!r||(j=1,k="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",m="visibility:hidden;border:0;",n="style='"+k+"border:5px solid #000;padding:0;'",o="
"+""+"
",a=c.createElement("div"),a.style.cssText=m+"width:0;height:0;position:static;top:0;margin-top:"+j+"px",r.insertBefore(a,r.firstChild),q=c.createElement("div"),a.appendChild(q),q.innerHTML="
t
",l=q.getElementsByTagName("td"),p=l[0].offsetHeight===0,l[0].style.display="",l[1].style.display="none",b.reliableHiddenOffsets=p&&l[0].offsetHeight===0,q.innerHTML="",q.style.width=q.style.paddingLeft="1px",f.boxModel=b.boxModel=q.offsetWidth===2,typeof q.style.zoom!="undefined"&&(q.style.display="inline",q.style.zoom=1,b.inlineBlockNeedsLayout=q.offsetWidth===2,q.style.display="",q.innerHTML="
",b.shrinkWrapBlocks=q.offsetWidth!==2),q.style.cssText=k+m,q.innerHTML=o,d=q.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,i={doesNotAddBorder:e.offsetTop!==5,doesAddBorderForTableAndCells:h.offsetTop===5},e.style.position="fixed",e.style.top="20px",i.fixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",i.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,i.doesNotIncludeMarginInBodyOffset=r.offsetTop!==j,r.removeChild(a),q=a=null,f.extend(b,i))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.extend({valHooks:{option:{get:function(a){var b=a.attributes.value;return!b||b.specified?a.value:a.text}},select:{get:function(a){var b,c,d,e,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attr:function(a,c,d,e){var g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;h=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/\bhover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=function(a,b){var c=a.attributes||{};return(!b[1]||a.nodeName.toLowerCase()===b[1])&&(!b[2]||(c.id||{}).value===b[2])&&(!b[3]||b[3].test((c["class"]||{}).value))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")}; 3 | f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&i.push({elem:this,matches:d.slice(e)});for(j=0;j0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(j,"")},TAG:function(a,b){return a[1].replace(j,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||m.error(a[0]),a[2]=a[2].replace(/^\+|\s*/g,"");var b=/(-?)(\d*)(?:n([+\-]?\d*))?/.exec(a[2]==="even"&&"2n"||a[2]==="odd"&&"2n+1"||!/\D/.test(a[2])&&"0n+"+a[2]||a[2]);a[2]=b[1]+(b[2]||1)-0,a[3]=b[3]-0}else a[2]&&m.error(a[0]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return a}},filters:{enabled:function(a){return a.disabled===!1&&a.type!=="hidden"},disabled:function(a){return a.disabled===!0},checked:function(a){return a.checked===!0},selected:function(a){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!m(c[3],a).length},header:function(a){return/h\d/i.test(a.nodeName)},text:function(a){var b=a.getAttribute("type"),c=a.type;return a.nodeName.toLowerCase()==="input"&&"text"===c&&(b===c||b===null)},radio:function(a){return a.nodeName.toLowerCase()==="input"&&"radio"===a.type},checkbox:function(a){return a.nodeName.toLowerCase()==="input"&&"checkbox"===a.type},file:function(a){return a.nodeName.toLowerCase()==="input"&&"file"===a.type},password:function(a){return a.nodeName.toLowerCase()==="input"&&"password"===a.type},submit:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"submit"===a.type},image:function(a){return a.nodeName.toLowerCase()==="input"&&"image"===a.type},reset:function(a){var b=a.nodeName.toLowerCase();return(b==="input"||b==="button")&&"reset"===a.type},button:function(a){var b=a.nodeName.toLowerCase();return b==="input"&&"button"===a.type||b==="button"},input:function(a){return/input|select|textarea|button/i.test(a.nodeName)},focus:function(a){return a===a.ownerDocument.activeElement}},setFilters:{first:function(a,b){return b===0},last:function(a,b,c,d){return b===d.length-1},even:function(a,b){return b%2===0},odd:function(a,b){return b%2===1},lt:function(a,b,c){return bc[3]-0},nth:function(a,b,c){return c[3]-0===b},eq:function(a,b,c){return c[3]-0===b}},filter:{PSEUDO:function(a,b,c,d){var e=b[1],f=o.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||n([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||!!a.nodeName&&a.nodeName.toLowerCase()===b},CLASS:function(a,b){return(" "+(a.className||a.getAttribute("class"))+" ").indexOf(b)>-1},ATTR:function(a,b){var c=b[1],d=m.attr?m.attr(a,c):o.attrHandle[c]?o.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":!f&&m.attr?d!=null:f==="="?e===g:f==="*="?e.indexOf(g)>=0:f==="~="?(" "+e+" ").indexOf(g)>=0:g?f==="!="?e!==g:f==="^="?e.indexOf(g)===0:f==="$="?e.substr(e.length-g.length)===g:f==="|="?e===g||e.substr(0,g.length+1)===g+"-":!1:e&&d!==!1},POS:function(a,b,c,d){var e=b[2],f=o.setFilters[e];if(f)return f(a,c,b,d)}}},p=o.match.POS,q=function(a,b){return"\\"+(b-0+1)};for(var r in o.match)o.match[r]=new RegExp(o.match[r].source+/(?![^\[]*\])(?![^\(]*\))/.source),o.leftMatch[r]=new RegExp(/(^(?:.|\r|\n)*?)/.source+o.match[r].source.replace(/\\(\d+)/g,q));var s=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(t){s=function(a,b){var c=0,d=b||[];if(g.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var e=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(o.find.ID=function(a,c,d){if(typeof c.getElementById!="undefined"&&!d){var e=c.getElementById(a[1]);return e?e.id===a[1]||typeof e.getAttributeNode!="undefined"&&e.getAttributeNode("id").nodeValue===a[1]?[e]:b:[]}},o.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(o.find.TAG=function(a,b){var c=b.getElementsByTagName(a[1]);if(a[1]==="*"){var d=[];for(var e=0;c[e];e++)c[e].nodeType===1&&d.push(c[e]);c=d}return c}),a.innerHTML="",a.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;o.order.splice(1,0,"CLASS"),o.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?m.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:m.contains=function(){return!1},m.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var y=function(a,b,c){var d,e=[],f="",g=b.nodeType?[b]:b;while(d=o.match.PSEUDO.exec(a))f+=d[0],a=a.replace(o.match.PSEUDO,"");a=o.relative[a]?a+"*":a;for(var h=0,i=g.length;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[c];return e},nth:function(a,b,c,d){b=b||1;var e=0;for(;a;a=a[c])if(a.nodeType===1&&++e===b)break;return a},sibling:function(a,b){var c=[];for(;a;a=a.nextSibling)a.nodeType===1&&a!==b&&c.push(a);return c}});var V="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(a,this[0].ownerDocument).eq(0).clone(!0);this[0].parentNode&&b.insertBefore(this[0]),b.map(function(){var a=this;while(a.firstChild&&a.firstChild.nodeType===1)a=a.firstChild;return a}).append(this)}return this},wrapInner:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(this).replaceWith(this.childNodes)}).end()},append:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.appendChild(a)})},prepend:function(){return this.domManip(arguments,!0,function(a){this.nodeType===1&&this.insertBefore(a,this.firstChild)})},before:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this)});if(arguments.length){var a=f.clean(arguments);a.push.apply(a,this.toArray());return this.pushStack(a,"before",arguments)}},after:function(){if(this[0]&&this[0].parentNode)return this.domManip(arguments,!1,function(a){this.parentNode.insertBefore(a,this.nextSibling)});if(arguments.length){var a=this.pushStack(this,"after",arguments);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.cleanData([d])),d.parentNode&&d.parentNode.removeChild(d);return this},empty:function() 4 | {for(var a=0,b;(b=this[a])!=null;a++){b.nodeType===1&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||!bc.test("<"+a.nodeName)?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");b===c?bh.appendChild(o):U(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return br.test((b&&a.currentStyle?a.currentStyle.filter:a.style.filter)||"")?parseFloat(RegExp.$1)/100+"":b?"1":""},set:function(a,b){var c=a.style,d=a.currentStyle,e=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bq,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bq.test(g)?g.replace(bq,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,b){var c,d,e;b=b.replace(bs,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b)));return c}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bt.test(f)&&bu.test(f)&&(c=g.left,d=a.runtimeStyle&&a.runtimeStyle.left,d&&(a.runtimeStyle.left=a.currentStyle.left),g.left=b==="fontSize"?"1em":f||0,f=g.pixelLeft+"px",g.left=c,d&&(a.runtimeStyle.left=d));return f===""?"auto":f}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bD=/%20/g,bE=/\[\]$/,bF=/\r?\n/g,bG=/#.*$/,bH=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bI=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bJ=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bK=/^(?:GET|HEAD)$/,bL=/^\/\//,bM=/\?/,bN=/)<[^<]*)*<\/script>/gi,bO=/^(?:select|textarea)/i,bP=/\s+/,bQ=/([?&])_=[^&]*/,bR=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bS=f.fn.load,bT={},bU={},bV,bW,bX=["*/"]+["*"];try{bV=e.href}catch(bY){bV=c.createElement("a"),bV.href="",bV=bV.href}bW=bR.exec(bV.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bS)return bS.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bN,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bO.test(this.nodeName)||bI.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bF,"\r\n")}}):{name:b.name,value:c.replace(bF,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b_(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b_(a,b);return a},ajaxSettings:{url:bV,isLocal:bJ.test(bW[1]),global:!0,type:"GET",contentType:"application/x-www-form-urlencoded",processData:!0,async:!0,accepts:{xml:"application/xml, text/xml",html:"text/html",text:"text/plain",json:"application/json, text/javascript","*":bX},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bZ(bT),ajaxTransport:bZ(bU),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cb(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cc(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bG,"").replace(bL,bW[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bP),d.crossDomain==null&&(r=bR.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bW[1]&&r[2]==bW[2]&&(r[3]||(r[1]==="http:"?80:443))==(bW[3]||(bW[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bT,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bK.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bM.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bQ,"$1_="+x);d.url=y+(y===d.url?(bM.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bX+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bU,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)ca(g,a[g],c,e);return d.join("&").replace(bD,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cd=f.now(),ce=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cd++}}),f.ajaxPrefilter("json jsonp",function(b,c,d){var e=b.contentType==="application/x-www-form-urlencoded"&&typeof b.data=="string";if(b.dataTypes[0]==="jsonp"||b.jsonp!==!1&&(ce.test(b.url)||e&&ce.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ce,l),b.url===j&&(e&&(k=k.replace(ce,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cf=a.ActiveXObject?function(){for(var a in ch)ch[a](0,1)}:!1,cg=0,ch;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ci()||cj()}:ci,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cf&&delete ch[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cg,cf&&(ch||(ch={},f(a).unload(cf)),ch[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ck={},cl,cm,cn=/^(?:toggle|show|hide)$/,co=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cp,cq=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cr;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g=i.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),i.animatedProperties[this.prop]=!0;for(b in i.animatedProperties)i.animatedProperties[b]!==!0&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cy(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cy(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,d,"padding")):this[d]():null},f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,d,a?"margin":"border")):this[d]():null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}if(e.nodeType===9)return Math.max(e.documentElement["client"+c],e.body["scroll"+c],e.documentElement["scroll"+c],e.body["offset"+c],e.documentElement["offset"+c]);if(a===b){var i=f.css(e,d),j=parseFloat(i);return f.isNumeric(j)?j:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); -------------------------------------------------------------------------------- /resources/library/phpthumb/GdThumb.inc.php: -------------------------------------------------------------------------------- 1 | 9 | * Copyright (c) 2009, Ian Selby/Gen X Design 10 | * 11 | * Author(s): Ian Selby 12 | * 13 | * Licensed under the MIT License 14 | * Redistributions of files must retain the above copyright notice. 15 | * 16 | * @author Ian Selby 17 | * @copyright Copyright (c) 2009 Gen X Design 18 | * @link http://phpthumb.gxdlabs.com 19 | * @license http://www.opensource.org/licenses/mit-license.php The MIT License 20 | * @version 3.0 21 | * @package PhpThumb 22 | * @filesource 23 | */ 24 | 25 | /** 26 | * GdThumb Class Definition 27 | * 28 | * This is the GD Implementation of the PHP Thumb library. 29 | * 30 | * @package PhpThumb 31 | * @subpackage Core 32 | */ 33 | class GdThumb extends ThumbBase 34 | { 35 | /** 36 | * The prior image (before manipulation) 37 | * 38 | * @var resource 39 | */ 40 | protected $oldImage; 41 | /** 42 | * The working image (used during manipulation) 43 | * 44 | * @var resource 45 | */ 46 | protected $workingImage; 47 | /** 48 | * The current dimensions of the image 49 | * 50 | * @var array 51 | */ 52 | protected $currentDimensions; 53 | /** 54 | * The new, calculated dimensions of the image 55 | * 56 | * @var array 57 | */ 58 | protected $newDimensions; 59 | /** 60 | * The options for this class 61 | * 62 | * This array contains various options that determine the behavior in 63 | * various functions throughout the class. Functions note which specific 64 | * option key / values are used in their documentation 65 | * 66 | * @var array 67 | */ 68 | protected $options; 69 | /** 70 | * The maximum width an image can be after resizing (in pixels) 71 | * 72 | * @var int 73 | */ 74 | protected $maxWidth; 75 | /** 76 | * The maximum height an image can be after resizing (in pixels) 77 | * 78 | * @var int 79 | */ 80 | protected $maxHeight; 81 | /** 82 | * The percentage to resize the image by 83 | * 84 | * @var int 85 | */ 86 | protected $percent; 87 | 88 | /** 89 | * Class Constructor 90 | * 91 | * @return GdThumb 92 | * @param string $fileName 93 | */ 94 | public function __construct ($fileName, $options = array(), $isDataStream = false) 95 | { 96 | parent::__construct($fileName, $isDataStream); 97 | 98 | $this->determineFormat(); 99 | 100 | if ($this->isDataStream === false) 101 | { 102 | $this->verifyFormatCompatiblity(); 103 | } 104 | 105 | switch ($this->format) 106 | { 107 | case 'GIF': 108 | $this->oldImage = imagecreatefromgif($this->fileName); 109 | break; 110 | case 'JPG': 111 | $this->oldImage = imagecreatefromjpeg($this->fileName); 112 | break; 113 | case 'PNG': 114 | $this->oldImage = imagecreatefrompng($this->fileName); 115 | break; 116 | case 'STRING': 117 | $this->oldImage = imagecreatefromstring($this->fileName); 118 | break; 119 | } 120 | 121 | $this->currentDimensions = array 122 | ( 123 | 'width' => imagesx($this->oldImage), 124 | 'height' => imagesy($this->oldImage) 125 | ); 126 | 127 | $this->setOptions($options); 128 | 129 | // TODO: Port gatherImageMeta to a separate function that can be called to extract exif data 130 | } 131 | 132 | /** 133 | * Class Destructor 134 | * 135 | */ 136 | public function __destruct () 137 | { 138 | if (is_resource($this->oldImage)) 139 | { 140 | imagedestroy($this->oldImage); 141 | } 142 | 143 | if (is_resource($this->workingImage)) 144 | { 145 | imagedestroy($this->workingImage); 146 | } 147 | } 148 | 149 | ############################## 150 | # ----- API FUNCTIONS ------ # 151 | ############################## 152 | 153 | /** 154 | * Resizes an image to be no larger than $maxWidth or $maxHeight 155 | * 156 | * If either param is set to zero, then that dimension will not be considered as a part of the resize. 157 | * Additionally, if $this->options['resizeUp'] is set to true (false by default), then this function will 158 | * also scale the image up to the maximum dimensions provided. 159 | * 160 | * @param int $maxWidth The maximum width of the image in pixels 161 | * @param int $maxHeight The maximum height of the image in pixels 162 | * @return GdThumb 163 | */ 164 | public function resize ($maxWidth = 0, $maxHeight = 0) 165 | { 166 | // make sure our arguments are valid 167 | if (!is_numeric($maxWidth)) 168 | { 169 | throw new InvalidArgumentException('$maxWidth must be numeric'); 170 | } 171 | 172 | if (!is_numeric($maxHeight)) 173 | { 174 | throw new InvalidArgumentException('$maxHeight must be numeric'); 175 | } 176 | 177 | // make sure we're not exceeding our image size if we're not supposed to 178 | if ($this->options['resizeUp'] === false) 179 | { 180 | $this->maxHeight = (intval($maxHeight) > $this->currentDimensions['height']) ? $this->currentDimensions['height'] : $maxHeight; 181 | $this->maxWidth = (intval($maxWidth) > $this->currentDimensions['width']) ? $this->currentDimensions['width'] : $maxWidth; 182 | } 183 | else 184 | { 185 | $this->maxHeight = intval($maxHeight); 186 | $this->maxWidth = intval($maxWidth); 187 | } 188 | 189 | // get the new dimensions... 190 | $this->calcImageSize($this->currentDimensions['width'], $this->currentDimensions['height']); 191 | 192 | // create the working image 193 | if (function_exists('imagecreatetruecolor')) 194 | { 195 | $this->workingImage = imagecreatetruecolor($this->newDimensions['newWidth'], $this->newDimensions['newHeight']); 196 | } 197 | else 198 | { 199 | $this->workingImage = imagecreate($this->newDimensions['newWidth'], $this->newDimensions['newHeight']); 200 | } 201 | 202 | $this->preserveAlpha(); 203 | 204 | // and create the newly sized image 205 | imagecopyresampled 206 | ( 207 | $this->workingImage, 208 | $this->oldImage, 209 | 0, 210 | 0, 211 | 0, 212 | 0, 213 | $this->newDimensions['newWidth'], 214 | $this->newDimensions['newHeight'], 215 | $this->currentDimensions['width'], 216 | $this->currentDimensions['height'] 217 | ); 218 | 219 | // update all the variables and resources to be correct 220 | $this->oldImage = $this->workingImage; 221 | $this->currentDimensions['width'] = $this->newDimensions['newWidth']; 222 | $this->currentDimensions['height'] = $this->newDimensions['newHeight']; 223 | 224 | return $this; 225 | } 226 | 227 | /** 228 | * Adaptively Resizes the Image 229 | * 230 | * This function attempts to get the image to as close to the provided dimensions as possible, and then crops the 231 | * remaining overflow (from the center) to get the image to be the size specified 232 | * 233 | * @param int $maxWidth 234 | * @param int $maxHeight 235 | * @return GdThumb 236 | */ 237 | public function adaptiveResize ($width, $height) 238 | { 239 | // make sure our arguments are valid 240 | if (!is_numeric($width) || $width == 0) 241 | { 242 | throw new InvalidArgumentException('$width must be numeric and greater than zero'); 243 | } 244 | 245 | if (!is_numeric($height) || $height == 0) 246 | { 247 | throw new InvalidArgumentException('$height must be numeric and greater than zero'); 248 | } 249 | 250 | // make sure we're not exceeding our image size if we're not supposed to 251 | if ($this->options['resizeUp'] === false) 252 | { 253 | $this->maxHeight = (intval($height) > $this->currentDimensions['height']) ? $this->currentDimensions['height'] : $height; 254 | $this->maxWidth = (intval($width) > $this->currentDimensions['width']) ? $this->currentDimensions['width'] : $width; 255 | } 256 | else 257 | { 258 | $this->maxHeight = intval($height); 259 | $this->maxWidth = intval($width); 260 | } 261 | 262 | $this->calcImageSizeStrict($this->currentDimensions['width'], $this->currentDimensions['height']); 263 | 264 | // resize the image to be close to our desired dimensions 265 | $this->resize($this->newDimensions['newWidth'], $this->newDimensions['newHeight']); 266 | 267 | // reset the max dimensions... 268 | if ($this->options['resizeUp'] === false) 269 | { 270 | $this->maxHeight = (intval($height) > $this->currentDimensions['height']) ? $this->currentDimensions['height'] : $height; 271 | $this->maxWidth = (intval($width) > $this->currentDimensions['width']) ? $this->currentDimensions['width'] : $width; 272 | } 273 | else 274 | { 275 | $this->maxHeight = intval($height); 276 | $this->maxWidth = intval($width); 277 | } 278 | 279 | // create the working image 280 | if (function_exists('imagecreatetruecolor')) 281 | { 282 | $this->workingImage = imagecreatetruecolor($this->maxWidth, $this->maxHeight); 283 | } 284 | else 285 | { 286 | $this->workingImage = imagecreate($this->maxWidth, $this->maxHeight); 287 | } 288 | 289 | $this->preserveAlpha(); 290 | 291 | $cropWidth = $this->maxWidth; 292 | $cropHeight = $this->maxHeight; 293 | $cropX = 0; 294 | $cropY = 0; 295 | 296 | // now, figure out how to crop the rest of the image... 297 | if ($this->currentDimensions['width'] > $this->maxWidth) 298 | { 299 | $cropX = intval(($this->currentDimensions['width'] - $this->maxWidth) / 2); 300 | } 301 | elseif ($this->currentDimensions['height'] > $this->maxHeight) 302 | { 303 | $cropY = intval(($this->currentDimensions['height'] - $this->maxHeight) / 2); 304 | } 305 | 306 | imagecopyresampled 307 | ( 308 | $this->workingImage, 309 | $this->oldImage, 310 | 0, 311 | 0, 312 | $cropX, 313 | $cropY, 314 | $cropWidth, 315 | $cropHeight, 316 | $cropWidth, 317 | $cropHeight 318 | ); 319 | 320 | // update all the variables and resources to be correct 321 | $this->oldImage = $this->workingImage; 322 | $this->currentDimensions['width'] = $this->maxWidth; 323 | $this->currentDimensions['height'] = $this->maxHeight; 324 | 325 | return $this; 326 | } 327 | 328 | /** 329 | * Resizes an image by a given percent uniformly 330 | * 331 | * Percentage should be whole number representation (i.e. 1-100) 332 | * 333 | * @param int $percent 334 | * @return GdThumb 335 | */ 336 | public function resizePercent ($percent = 0) 337 | { 338 | if (!is_numeric($percent)) 339 | { 340 | throw new InvalidArgumentException ('$percent must be numeric'); 341 | } 342 | 343 | $this->percent = intval($percent); 344 | 345 | $this->calcImageSizePercent($this->currentDimensions['width'], $this->currentDimensions['height']); 346 | 347 | if (function_exists('imagecreatetruecolor')) 348 | { 349 | $this->workingImage = imagecreatetruecolor($this->newDimensions['newWidth'], $this->newDimensions['newHeight']); 350 | } 351 | else 352 | { 353 | $this->workingImage = imagecreate($this->newDimensions['newWidth'], $this->newDimensions['newHeight']); 354 | } 355 | 356 | $this->preserveAlpha(); 357 | 358 | ImageCopyResampled( 359 | $this->workingImage, 360 | $this->oldImage, 361 | 0, 362 | 0, 363 | 0, 364 | 0, 365 | $this->newDimensions['newWidth'], 366 | $this->newDimensions['newHeight'], 367 | $this->currentDimensions['width'], 368 | $this->currentDimensions['height'] 369 | ); 370 | 371 | $this->oldImage = $this->workingImage; 372 | $this->currentDimensions['width'] = $this->newDimensions['newWidth']; 373 | $this->currentDimensions['height'] = $this->newDimensions['newHeight']; 374 | 375 | return $this; 376 | } 377 | 378 | /** 379 | * Crops an image from the center with provided dimensions 380 | * 381 | * If no height is given, the width will be used as a height, thus creating a square crop 382 | * 383 | * @param int $cropWidth 384 | * @param int $cropHeight 385 | * @return GdThumb 386 | */ 387 | public function cropFromCenter ($cropWidth, $cropHeight = null) 388 | { 389 | if (!is_numeric($cropWidth)) 390 | { 391 | throw new InvalidArgumentException('$cropWidth must be numeric'); 392 | } 393 | 394 | if ($cropHeight !== null && !is_numeric($cropHeight)) 395 | { 396 | throw new InvalidArgumentException('$cropHeight must be numeric'); 397 | } 398 | 399 | if ($cropHeight === null) 400 | { 401 | $cropHeight = $cropWidth; 402 | } 403 | 404 | $cropWidth = ($this->currentDimensions['width'] < $cropWidth) ? $this->currentDimensions['width'] : $cropWidth; 405 | $cropHeight = ($this->currentDimensions['height'] < $cropHeight) ? $this->currentDimensions['height'] : $cropHeight; 406 | 407 | $cropX = intval(($this->currentDimensions['width'] - $cropWidth) / 2); 408 | $cropY = intval(($this->currentDimensions['height'] - $cropHeight) / 2); 409 | 410 | $this->crop($cropX, $cropY, $cropWidth, $cropHeight); 411 | 412 | return $this; 413 | } 414 | 415 | /** 416 | * Vanilla Cropping - Crops from x,y with specified width and height 417 | * 418 | * @param int $startX 419 | * @param int $startY 420 | * @param int $cropWidth 421 | * @param int $cropHeight 422 | * @return GdThumb 423 | */ 424 | public function crop ($startX, $startY, $cropWidth, $cropHeight) 425 | { 426 | // validate input 427 | if (!is_numeric($startX)) 428 | { 429 | throw new InvalidArgumentException('$startX must be numeric'); 430 | } 431 | 432 | if (!is_numeric($startY)) 433 | { 434 | throw new InvalidArgumentException('$startY must be numeric'); 435 | } 436 | 437 | if (!is_numeric($cropWidth)) 438 | { 439 | throw new InvalidArgumentException('$cropWidth must be numeric'); 440 | } 441 | 442 | if (!is_numeric($cropHeight)) 443 | { 444 | throw new InvalidArgumentException('$cropHeight must be numeric'); 445 | } 446 | 447 | // do some calculations 448 | $cropWidth = ($this->currentDimensions['width'] < $cropWidth) ? $this->currentDimensions['width'] : $cropWidth; 449 | $cropHeight = ($this->currentDimensions['height'] < $cropHeight) ? $this->currentDimensions['height'] : $cropHeight; 450 | 451 | // ensure everything's in bounds 452 | if (($startX + $cropWidth) > $this->currentDimensions['width']) 453 | { 454 | $startX = ($this->currentDimensions['width'] - $cropWidth); 455 | 456 | } 457 | 458 | if (($startY + $cropHeight) > $this->currentDimensions['height']) 459 | { 460 | $startY = ($this->currentDimensions['height'] - $cropHeight); 461 | } 462 | 463 | if ($startX < 0) 464 | { 465 | $startX = 0; 466 | } 467 | 468 | if ($startY < 0) 469 | { 470 | $startY = 0; 471 | } 472 | 473 | // create the working image 474 | if (function_exists('imagecreatetruecolor')) 475 | { 476 | $this->workingImage = imagecreatetruecolor($cropWidth, $cropHeight); 477 | } 478 | else 479 | { 480 | $this->workingImage = imagecreate($cropWidth, $cropHeight); 481 | } 482 | 483 | $this->preserveAlpha(); 484 | 485 | imagecopyresampled 486 | ( 487 | $this->workingImage, 488 | $this->oldImage, 489 | 0, 490 | 0, 491 | $startX, 492 | $startY, 493 | $cropWidth, 494 | $cropHeight, 495 | $cropWidth, 496 | $cropHeight 497 | ); 498 | 499 | $this->oldImage = $this->workingImage; 500 | $this->currentDimensions['width'] = $cropWidth; 501 | $this->currentDimensions['height'] = $cropHeight; 502 | 503 | return $this; 504 | } 505 | 506 | /** 507 | * Rotates image either 90 degrees clockwise or counter-clockwise 508 | * 509 | * @param string $direction 510 | * @retunrn GdThumb 511 | */ 512 | public function rotateImage ($direction = 'CW') 513 | { 514 | if ($direction == 'CW') 515 | { 516 | $this->rotateImageNDegrees(90); 517 | } 518 | else 519 | { 520 | $this->rotateImageNDegrees(-90); 521 | } 522 | 523 | return $this; 524 | } 525 | 526 | /** 527 | * Rotates image specified number of degrees 528 | * 529 | * @param int $degrees 530 | * @return GdThumb 531 | */ 532 | public function rotateImageNDegrees ($degrees) 533 | { 534 | if (!is_numeric($degrees)) 535 | { 536 | throw new InvalidArgumentException('$degrees must be numeric'); 537 | } 538 | 539 | if (!function_exists('imagerotate')) 540 | { 541 | throw new RuntimeException('Your version of GD does not support image rotation.'); 542 | } 543 | 544 | $this->workingImage = imagerotate($this->oldImage, $degrees, 0); 545 | 546 | $newWidth = $this->currentDimensions['height']; 547 | $newHeight = $this->currentDimensions['width']; 548 | $this->oldImage = $this->workingImage; 549 | $this->currentDimensions['width'] = $newWidth; 550 | $this->currentDimensions['height'] = $newHeight; 551 | 552 | return $this; 553 | } 554 | 555 | /** 556 | * Shows an image 557 | * 558 | * This function will show the current image by first sending the appropriate header 559 | * for the format, and then outputting the image data. If headers have already been sent, 560 | * a runtime exception will be thrown 561 | * 562 | * @param bool $rawData Whether or not the raw image stream should be output 563 | * @return GdThumb 564 | */ 565 | public function show ($rawData = false) 566 | { 567 | if (headers_sent()) 568 | { 569 | throw new RuntimeException('Cannot show image, headers have already been sent'); 570 | } 571 | 572 | switch ($this->format) 573 | { 574 | case 'GIF': 575 | if ($rawData === false) 576 | { 577 | header('Content-type: image/gif'); 578 | } 579 | imagegif($this->oldImage); 580 | break; 581 | case 'JPG': 582 | if ($rawData === false) 583 | { 584 | header('Content-type: image/jpeg'); 585 | } 586 | imagejpeg($this->oldImage, null, $this->options['jpegQuality']); 587 | break; 588 | case 'PNG': 589 | case 'STRING': 590 | if ($rawData === false) 591 | { 592 | header('Content-type: image/png'); 593 | } 594 | imagepng($this->oldImage); 595 | break; 596 | } 597 | 598 | return $this; 599 | } 600 | 601 | /** 602 | * Returns the Working Image as a String 603 | * 604 | * This function is useful for getting the raw image data as a string for storage in 605 | * a database, or other similar things. 606 | * 607 | * @return string 608 | */ 609 | public function getImageAsString () 610 | { 611 | $data = null; 612 | ob_start(); 613 | $this->show(true); 614 | $data = ob_get_contents(); 615 | ob_end_clean(); 616 | 617 | return $data; 618 | } 619 | 620 | /** 621 | * Saves an image 622 | * 623 | * This function will make sure the target directory is writeable, and then save the image. 624 | * 625 | * If the target directory is not writeable, the function will try to correct the permissions (if allowed, this 626 | * is set as an option ($this->options['correctPermissions']). If the target cannot be made writeable, then a 627 | * RuntimeException is thrown. 628 | * 629 | * TODO: Create additional paramter for color matte when saving images with alpha to non-alpha formats (i.e. PNG => JPG) 630 | * 631 | * @param string $fileName The full path and filename of the image to save 632 | * @param string $format The format to save the image in (optional, must be one of [GIF,JPG,PNG] 633 | * @return GdThumb 634 | */ 635 | public function save ($fileName, $format = null) 636 | { 637 | $validFormats = array('GIF', 'JPG', 'PNG'); 638 | $format = ($format !== null) ? strtoupper($format) : $this->format; 639 | 640 | if (!in_array($format, $validFormats)) 641 | { 642 | throw new InvalidArgumentException ('Invalid format type specified in save function: ' . $format); 643 | } 644 | 645 | // make sure the directory is writeable 646 | if (!is_writeable(dirname($fileName))) 647 | { 648 | // try to correct the permissions 649 | if ($this->options['correctPermissions'] === true) 650 | { 651 | @chmod(dirname($fileName), 0777); 652 | 653 | // throw an exception if not writeable 654 | if (!is_writeable(dirname($fileName))) 655 | { 656 | throw new RuntimeException ('File is not writeable, and could not correct permissions: ' . $fileName); 657 | } 658 | } 659 | // throw an exception if not writeable 660 | else 661 | { 662 | throw new RuntimeException ('File not writeable: ' . $fileName); 663 | } 664 | } 665 | 666 | switch ($format) 667 | { 668 | case 'GIF': 669 | imagegif($this->oldImage, $fileName); 670 | break; 671 | case 'JPG': 672 | imagejpeg($this->oldImage, $fileName, $this->options['jpegQuality']); 673 | break; 674 | case 'PNG': 675 | imagepng($this->oldImage, $fileName); 676 | break; 677 | } 678 | 679 | return $this; 680 | } 681 | 682 | ################################# 683 | # ----- GETTERS / SETTERS ----- # 684 | ################################# 685 | 686 | /** 687 | * Sets $this->options to $options 688 | * 689 | * @param array $options 690 | */ 691 | public function setOptions ($options = array()) 692 | { 693 | // make sure we've got an array for $this->options (could be null) 694 | if (!is_array($this->options)) 695 | { 696 | $this->options = array(); 697 | } 698 | 699 | // make sure we've gotten a proper argument 700 | if (!is_array($options)) 701 | { 702 | throw new InvalidArgumentException ('setOptions requires an array'); 703 | } 704 | 705 | // we've yet to init the default options, so create them here 706 | if (sizeof($this->options) == 0) 707 | { 708 | $defaultOptions = array 709 | ( 710 | 'resizeUp' => false, 711 | 'jpegQuality' => 100, 712 | 'correctPermissions' => false, 713 | 'preserveAlpha' => true, 714 | 'alphaMaskColor' => array (255, 255, 255), 715 | 'preserveTransparency' => true, 716 | 'transparencyMaskColor' => array (0, 0, 0) 717 | ); 718 | } 719 | // otherwise, let's use what we've got already 720 | else 721 | { 722 | $defaultOptions = $this->options; 723 | } 724 | 725 | $this->options = array_merge($defaultOptions, $options); 726 | } 727 | 728 | /** 729 | * Returns $currentDimensions. 730 | * 731 | * @see GdThumb::$currentDimensions 732 | */ 733 | public function getCurrentDimensions () 734 | { 735 | return $this->currentDimensions; 736 | } 737 | 738 | /** 739 | * Sets $currentDimensions. 740 | * 741 | * @param object $currentDimensions 742 | * @see GdThumb::$currentDimensions 743 | */ 744 | public function setCurrentDimensions ($currentDimensions) 745 | { 746 | $this->currentDimensions = $currentDimensions; 747 | } 748 | 749 | /** 750 | * Returns $maxHeight. 751 | * 752 | * @see GdThumb::$maxHeight 753 | */ 754 | public function getMaxHeight () 755 | { 756 | return $this->maxHeight; 757 | } 758 | 759 | /** 760 | * Sets $maxHeight. 761 | * 762 | * @param object $maxHeight 763 | * @see GdThumb::$maxHeight 764 | */ 765 | public function setMaxHeight ($maxHeight) 766 | { 767 | $this->maxHeight = $maxHeight; 768 | } 769 | 770 | /** 771 | * Returns $maxWidth. 772 | * 773 | * @see GdThumb::$maxWidth 774 | */ 775 | public function getMaxWidth () 776 | { 777 | return $this->maxWidth; 778 | } 779 | 780 | /** 781 | * Sets $maxWidth. 782 | * 783 | * @param object $maxWidth 784 | * @see GdThumb::$maxWidth 785 | */ 786 | public function setMaxWidth ($maxWidth) 787 | { 788 | $this->maxWidth = $maxWidth; 789 | } 790 | 791 | /** 792 | * Returns $newDimensions. 793 | * 794 | * @see GdThumb::$newDimensions 795 | */ 796 | public function getNewDimensions () 797 | { 798 | return $this->newDimensions; 799 | } 800 | 801 | /** 802 | * Sets $newDimensions. 803 | * 804 | * @param object $newDimensions 805 | * @see GdThumb::$newDimensions 806 | */ 807 | public function setNewDimensions ($newDimensions) 808 | { 809 | $this->newDimensions = $newDimensions; 810 | } 811 | 812 | /** 813 | * Returns $options. 814 | * 815 | * @see GdThumb::$options 816 | */ 817 | public function getOptions () 818 | { 819 | return $this->options; 820 | } 821 | 822 | /** 823 | * Returns $percent. 824 | * 825 | * @see GdThumb::$percent 826 | */ 827 | public function getPercent () 828 | { 829 | return $this->percent; 830 | } 831 | 832 | /** 833 | * Sets $percent. 834 | * 835 | * @param object $percent 836 | * @see GdThumb::$percent 837 | */ 838 | public function setPercent ($percent) 839 | { 840 | $this->percent = $percent; 841 | } 842 | 843 | /** 844 | * Returns $oldImage. 845 | * 846 | * @see GdThumb::$oldImage 847 | */ 848 | public function getOldImage () 849 | { 850 | return $this->oldImage; 851 | } 852 | 853 | /** 854 | * Sets $oldImage. 855 | * 856 | * @param object $oldImage 857 | * @see GdThumb::$oldImage 858 | */ 859 | public function setOldImage ($oldImage) 860 | { 861 | $this->oldImage = $oldImage; 862 | } 863 | 864 | /** 865 | * Returns $workingImage. 866 | * 867 | * @see GdThumb::$workingImage 868 | */ 869 | public function getWorkingImage () 870 | { 871 | return $this->workingImage; 872 | } 873 | 874 | /** 875 | * Sets $workingImage. 876 | * 877 | * @param object $workingImage 878 | * @see GdThumb::$workingImage 879 | */ 880 | public function setWorkingImage ($workingImage) 881 | { 882 | $this->workingImage = $workingImage; 883 | } 884 | 885 | 886 | ################################# 887 | # ----- UTILITY FUNCTIONS ----- # 888 | ################################# 889 | 890 | /** 891 | * Calculates a new width and height for the image based on $this->maxWidth and the provided dimensions 892 | * 893 | * @return array 894 | * @param int $width 895 | * @param int $height 896 | */ 897 | protected function calcWidth ($width, $height) 898 | { 899 | $newWidthPercentage = (100 * $this->maxWidth) / $width; 900 | $newHeight = ($height * $newWidthPercentage) / 100; 901 | 902 | return array 903 | ( 904 | 'newWidth' => intval($this->maxWidth), 905 | 'newHeight' => intval($newHeight) 906 | ); 907 | } 908 | 909 | /** 910 | * Calculates a new width and height for the image based on $this->maxWidth and the provided dimensions 911 | * 912 | * @return array 913 | * @param int $width 914 | * @param int $height 915 | */ 916 | protected function calcHeight ($width, $height) 917 | { 918 | $newHeightPercentage = (100 * $this->maxHeight) / $height; 919 | $newWidth = ($width * $newHeightPercentage) / 100; 920 | 921 | return array 922 | ( 923 | 'newWidth' => ceil($newWidth), 924 | 'newHeight' => ceil($this->maxHeight) 925 | ); 926 | } 927 | 928 | /** 929 | * Calculates a new width and height for the image based on $this->percent and the provided dimensions 930 | * 931 | * @return array 932 | * @param int $width 933 | * @param int $height 934 | */ 935 | protected function calcPercent ($width, $height) 936 | { 937 | $newWidth = ($width * $this->percent) / 100; 938 | $newHeight = ($height * $this->percent) / 100; 939 | 940 | return array 941 | ( 942 | 'newWidth' => ceil($newWidth), 943 | 'newHeight' => ceil($newHeight) 944 | ); 945 | } 946 | 947 | /** 948 | * Calculates the new image dimensions 949 | * 950 | * These calculations are based on both the provided dimensions and $this->maxWidth and $this->maxHeight 951 | * 952 | * @param int $width 953 | * @param int $height 954 | */ 955 | protected function calcImageSize ($width, $height) 956 | { 957 | $newSize = array 958 | ( 959 | 'newWidth' => $width, 960 | 'newHeight' => $height 961 | ); 962 | 963 | if ($this->maxWidth > 0) 964 | { 965 | $newSize = $this->calcWidth($width, $height); 966 | 967 | if ($this->maxHeight > 0 && $newSize['newHeight'] > $this->maxHeight) 968 | { 969 | $newSize = $this->calcHeight($newSize['newWidth'], $newSize['newHeight']); 970 | } 971 | } 972 | 973 | if ($this->maxHeight > 0) 974 | { 975 | $newSize = $this->calcHeight($width, $height); 976 | 977 | if ($this->maxWidth > 0 && $newSize['newWidth'] > $this->maxWidth) 978 | { 979 | $newSize = $this->calcWidth($newSize['newWidth'], $newSize['newHeight']); 980 | } 981 | } 982 | 983 | $this->newDimensions = $newSize; 984 | } 985 | 986 | /** 987 | * Calculates new image dimensions, not allowing the width and height to be less than either the max width or height 988 | * 989 | * @param int $width 990 | * @param int $height 991 | */ 992 | protected function calcImageSizeStrict ($width, $height) 993 | { 994 | // first, we need to determine what the longest resize dimension is.. 995 | if ($this->maxWidth >= $this->maxHeight) 996 | { 997 | // and determine the longest original dimension 998 | if ($width > $height) 999 | { 1000 | $newDimensions = $this->calcHeight($width, $height); 1001 | 1002 | if ($newDimensions['newWidth'] < $this->maxWidth) 1003 | { 1004 | $newDimensions = $this->calcWidth($width, $height); 1005 | } 1006 | } 1007 | elseif ($height >= $width) 1008 | { 1009 | $newDimensions = $this->calcWidth($width, $height); 1010 | 1011 | if ($newDimensions['newHeight'] < $this->maxHeight) 1012 | { 1013 | $newDimensions = $this->calcHeight($width, $height); 1014 | } 1015 | } 1016 | } 1017 | elseif ($this->maxHeight > $this->maxWidth) 1018 | { 1019 | if ($width >= $height) 1020 | { 1021 | $newDimensions = $this->calcWidth($width, $height); 1022 | 1023 | if ($newDimensions['newHeight'] < $this->maxHeight) 1024 | { 1025 | $newDimensions = $this->calcHeight($width, $height); 1026 | } 1027 | } 1028 | elseif ($height > $width) 1029 | { 1030 | $newDimensions = $this->calcHeight($width, $height); 1031 | 1032 | if ($newDimensions['newWidth'] < $this->maxWidth) 1033 | { 1034 | $newDimensions = $this->calcWidth($width, $height); 1035 | } 1036 | } 1037 | } 1038 | 1039 | $this->newDimensions = $newDimensions; 1040 | } 1041 | 1042 | /** 1043 | * Calculates new dimensions based on $this->percent and the provided dimensions 1044 | * 1045 | * @param int $width 1046 | * @param int $height 1047 | */ 1048 | protected function calcImageSizePercent ($width, $height) 1049 | { 1050 | if ($this->percent > 0) 1051 | { 1052 | $this->newDimensions = $this->calcPercent($width, $height); 1053 | } 1054 | } 1055 | 1056 | /** 1057 | * Determines the file format by mime-type 1058 | * 1059 | * This function will throw exceptions for invalid images / mime-types 1060 | * 1061 | */ 1062 | protected function determineFormat () 1063 | { 1064 | if ($this->isDataStream === true) 1065 | { 1066 | $this->format = 'STRING'; 1067 | return; 1068 | } 1069 | 1070 | $formatInfo = getimagesize($this->fileName); 1071 | 1072 | // non-image files will return false 1073 | if ($formatInfo === false) 1074 | { 1075 | if ($this->remoteImage) 1076 | { 1077 | $this->triggerError('Could not determine format of remote image: ' . $this->fileName); 1078 | } 1079 | else 1080 | { 1081 | $this->triggerError('File is not a valid image: ' . $this->fileName); 1082 | } 1083 | 1084 | // make sure we really stop execution 1085 | return; 1086 | } 1087 | 1088 | $mimeType = isset($formatInfo['mime']) ? $formatInfo['mime'] : null; 1089 | 1090 | switch ($mimeType) 1091 | { 1092 | case 'image/gif': 1093 | $this->format = 'GIF'; 1094 | break; 1095 | case 'image/jpeg': 1096 | $this->format = 'JPG'; 1097 | break; 1098 | case 'image/png': 1099 | $this->format = 'PNG'; 1100 | break; 1101 | default: 1102 | $this->triggerError('Image format not supported: ' . $mimeType); 1103 | } 1104 | } 1105 | 1106 | /** 1107 | * Makes sure the correct GD implementation exists for the file type 1108 | * 1109 | */ 1110 | protected function verifyFormatCompatiblity () 1111 | { 1112 | $isCompatible = true; 1113 | $gdInfo = gd_info(); 1114 | 1115 | switch ($this->format) 1116 | { 1117 | case 'GIF': 1118 | $isCompatible = $gdInfo['GIF Create Support']; 1119 | break; 1120 | case 'JPG': 1121 | $isCompatible = (isset($gdInfo['JPG Support']) || isset($gdInfo['JPEG Support'])) ? true : false; 1122 | break; 1123 | case 'PNG': 1124 | $isCompatible = $gdInfo[$this->format . ' Support']; 1125 | break; 1126 | default: 1127 | $isCompatible = false; 1128 | } 1129 | 1130 | if (!$isCompatible) 1131 | { 1132 | // one last check for "JPEG" instead 1133 | $isCompatible = $gdInfo['JPEG Support']; 1134 | 1135 | if (!$isCompatible) 1136 | { 1137 | $this->triggerError('Your GD installation does not support ' . $this->format . ' image types'); 1138 | } 1139 | } 1140 | } 1141 | 1142 | /** 1143 | * Preserves the alpha or transparency for PNG and GIF files 1144 | * 1145 | * Alpha / transparency will not be preserved if the appropriate options are set to false. 1146 | * Also, the GIF transparency is pretty skunky (the results aren't awesome), but it works like a 1147 | * champ... that's the nature of GIFs tho, so no huge surprise. 1148 | * 1149 | * This functionality was originally suggested by commenter Aimi (no links / site provided) - Thanks! :) 1150 | * 1151 | */ 1152 | protected function preserveAlpha () 1153 | { 1154 | if ($this->format == 'PNG' && $this->options['preserveAlpha'] === true) 1155 | { 1156 | imagealphablending($this->workingImage, false); 1157 | 1158 | $colorTransparent = imagecolorallocatealpha 1159 | ( 1160 | $this->workingImage, 1161 | $this->options['alphaMaskColor'][0], 1162 | $this->options['alphaMaskColor'][1], 1163 | $this->options['alphaMaskColor'][2], 1164 | 0 1165 | ); 1166 | 1167 | imagefill($this->workingImage, 0, 0, $colorTransparent); 1168 | imagesavealpha($this->workingImage, true); 1169 | } 1170 | // preserve transparency in GIFs... this is usually pretty rough tho 1171 | if ($this->format == 'GIF' && $this->options['preserveTransparency'] === true) 1172 | { 1173 | $colorTransparent = imagecolorallocate 1174 | ( 1175 | $this->workingImage, 1176 | $this->options['transparencyMaskColor'][0], 1177 | $this->options['transparencyMaskColor'][1], 1178 | $this->options['transparencyMaskColor'][2] 1179 | ); 1180 | 1181 | imagecolortransparent($this->workingImage, $colorTransparent); 1182 | imagetruecolortopalette($this->workingImage, true, 256); 1183 | } 1184 | } 1185 | } -------------------------------------------------------------------------------- /resources/library/phpthumb/PhpThumb.inc.php: -------------------------------------------------------------------------------- 1 | 9 | * Copyright (c) 2009, Ian Selby/Gen X Design 10 | * 11 | * Author(s): Ian Selby 12 | * 13 | * Licensed under the MIT License 14 | * Redistributions of files must retain the above copyright notice. 15 | * 16 | * @author Ian Selby 17 | * @copyright Copyright (c) 2009 Gen X Design 18 | * @link http://phpthumb.gxdlabs.com 19 | * @license http://www.opensource.org/licenses/mit-license.php The MIT License 20 | * @version 3.0 21 | * @package PhpThumb 22 | * @filesource 23 | */ 24 | 25 | 26 | 27 | /** 28 | * PhpThumb Object 29 | * 30 | * This singleton object is essentially a function library that helps with core validation 31 | * and loading of the core classes and plugins. There isn't really any need to access it directly, 32 | * unless you're developing a plugin and need to take advantage of any of the functionality contained 33 | * within. 34 | * 35 | * If you're not familiar with singleton patterns, here's how you get an instance of this class (since you 36 | * can't create one via the new keyword): 37 | * $pt = PhpThumb::getInstance(); 38 | * 39 | * It's that simple! Outside of that, there's no need to modify anything within this class, unless you're doing 40 | * some crazy customization... then knock yourself out! :) 41 | * 42 | * @package PhpThumb 43 | * @subpackage Core 44 | */ 45 | class PhpThumb 46 | { 47 | /** 48 | * Instance of self 49 | * 50 | * @var object PhpThumb 51 | */ 52 | protected static $_instance; 53 | /** 54 | * The plugin registry 55 | * 56 | * This is where all plugins to be loaded are stored. Data about the plugin is 57 | * provided, and currently consists of: 58 | * - loaded: true/false 59 | * - implementation: gd/imagick/both 60 | * 61 | * @var array 62 | */ 63 | protected $_registry; 64 | /** 65 | * What implementations are available 66 | * 67 | * This stores what implementations are available based on the loaded 68 | * extensions in PHP, NOT whether or not the class files are present. 69 | * 70 | * @var array 71 | */ 72 | protected $_implementations; 73 | 74 | /** 75 | * Returns an instance of self 76 | * 77 | * This is the usual singleton function that returns / instantiates the object 78 | * 79 | * @return PhpThumb 80 | */ 81 | public static function getInstance () 82 | { 83 | if(!(self::$_instance instanceof self)) 84 | { 85 | self::$_instance = new self(); 86 | } 87 | 88 | return self::$_instance; 89 | } 90 | 91 | /** 92 | * Class constructor 93 | * 94 | * Initializes all the variables, and does some preliminary validation / checking of stuff 95 | * 96 | */ 97 | private function __construct () 98 | { 99 | $this->_registry = array(); 100 | $this->_implementations = array('gd' => false, 'imagick' => false); 101 | 102 | $this->getImplementations(); 103 | } 104 | 105 | /** 106 | * Finds out what implementations are available 107 | * 108 | * This function loops over $this->_implementations and validates that the required extensions are loaded. 109 | * 110 | * I had planned on attempting to load them dynamically via dl(), but that would provide more overhead than I 111 | * was comfortable with (and would probably fail 99% of the time anyway) 112 | * 113 | */ 114 | private function getImplementations () 115 | { 116 | foreach($this->_implementations as $extension => $loaded) 117 | { 118 | if($loaded) 119 | { 120 | continue; 121 | } 122 | 123 | if(extension_loaded($extension)) 124 | { 125 | $this->_implementations[$extension] = true; 126 | } 127 | } 128 | } 129 | 130 | /** 131 | * Returns whether or not $implementation is valid (available) 132 | * 133 | * If 'all' is passed, true is only returned if ALL implementations are available. 134 | * 135 | * You can also pass 'n/a', which always returns true 136 | * 137 | * @return bool 138 | * @param string $implementation 139 | */ 140 | public function isValidImplementation ($implementation) 141 | { 142 | if ($implementation == 'n/a') 143 | { 144 | return true; 145 | } 146 | 147 | if ($implementation == 'all') 148 | { 149 | foreach ($this->_implementations as $imp => $value) 150 | { 151 | if ($value == false) 152 | { 153 | return false; 154 | } 155 | } 156 | 157 | return true; 158 | } 159 | 160 | if (array_key_exists($implementation, $this->_implementations)) 161 | { 162 | return $this->_implementations[$implementation]; 163 | } 164 | 165 | return false; 166 | } 167 | 168 | /** 169 | * Registers a plugin in the registry 170 | * 171 | * Adds a plugin to the registry if it isn't already loaded, and if the provided 172 | * implementation is valid. Note that you can pass the following special keywords 173 | * for implementation: 174 | * - all - Requires that all implementations be available 175 | * - n/a - Doesn't require any implementation 176 | * 177 | * When a plugin is added to the registry, it's added as a key on $this->_registry with the value 178 | * being an array containing the following keys: 179 | * - loaded - whether or not the plugin has been "loaded" into the core class 180 | * - implementation - what implementation this plugin is valid for 181 | * 182 | * @return bool 183 | * @param string $pluginName 184 | * @param string $implementation 185 | */ 186 | public function registerPlugin ($pluginName, $implementation) 187 | { 188 | if (!array_key_exists($pluginName, $this->_registry) && $this->isValidImplementation($implementation)) 189 | { 190 | $this->_registry[$pluginName] = array('loaded' => false, 'implementation' => $implementation); 191 | return true; 192 | } 193 | 194 | return false; 195 | } 196 | 197 | /** 198 | * Loads all the plugins in $pluginPath 199 | * 200 | * All this function does is include all files inside the $pluginPath directory. The plugins themselves 201 | * will not be added to the registry unless you've properly added the code to do so inside your plugin file. 202 | * 203 | * @param string $pluginPath 204 | */ 205 | public function loadPlugins ($pluginPath) 206 | { 207 | // strip the trailing slash if present 208 | if (substr($pluginPath, strlen($pluginPath) - 1, 1) == '/') 209 | { 210 | $pluginPath = substr($pluginPath, 0, strlen($pluginPath) - 1); 211 | } 212 | 213 | if ($handle = opendir($pluginPath)) 214 | { 215 | while (false !== ($file = readdir($handle))) 216 | { 217 | if ($file == '.' || $file == '..' || $file == '.svn') 218 | { 219 | continue; 220 | } 221 | 222 | include_once($pluginPath . '/' . $file); 223 | } 224 | } 225 | } 226 | 227 | /** 228 | * Returns the plugin registry for the supplied implementation 229 | * 230 | * @return array 231 | * @param string $implementation 232 | */ 233 | public function getPluginRegistry ($implementation) 234 | { 235 | $returnArray = array(); 236 | 237 | foreach ($this->_registry as $plugin => $meta) 238 | { 239 | if ($meta['implementation'] == 'n/a' || $meta['implementation'] == $implementation) 240 | { 241 | $returnArray[$plugin] = $meta; 242 | } 243 | } 244 | 245 | return $returnArray; 246 | } 247 | } 248 | -------------------------------------------------------------------------------- /resources/library/phpthumb/ThumbBase.inc.php: -------------------------------------------------------------------------------- 1 | 9 | * Copyright (c) 2009, Ian Selby/Gen X Design 10 | * 11 | * Author(s): Ian Selby 12 | * 13 | * Licensed under the MIT License 14 | * Redistributions of files must retain the above copyright notice. 15 | * 16 | * @author Ian Selby 17 | * @copyright Copyright (c) 2009 Gen X Design 18 | * @link http://phpthumb.gxdlabs.com 19 | * @license http://www.opensource.org/licenses/mit-license.php The MIT License 20 | * @version 3.0 21 | * @package PhpThumb 22 | * @filesource 23 | */ 24 | 25 | /** 26 | * ThumbBase Class Definition 27 | * 28 | * This is the base class that all implementations must extend. It contains the 29 | * core variables and functionality common to all implementations, as well as the functions that 30 | * allow plugins to augment those classes. 31 | * 32 | * @package PhpThumb 33 | * @subpackage Core 34 | */ 35 | abstract class ThumbBase 36 | { 37 | /** 38 | * All imported objects 39 | * 40 | * An array of imported plugin objects 41 | * 42 | * @var array 43 | */ 44 | protected $imported; 45 | /** 46 | * All imported object functions 47 | * 48 | * An array of all methods added to this class by imported plugin objects 49 | * 50 | * @var array 51 | */ 52 | protected $importedFunctions; 53 | /** 54 | * The last error message raised 55 | * 56 | * @var string 57 | */ 58 | protected $errorMessage; 59 | /** 60 | * Whether or not the current instance has any errors 61 | * 62 | * @var bool 63 | */ 64 | protected $hasError; 65 | /** 66 | * The name of the file we're manipulating 67 | * 68 | * This must include the path to the file (absolute paths recommended) 69 | * 70 | * @var string 71 | */ 72 | protected $fileName; 73 | /** 74 | * What the file format is (mime-type) 75 | * 76 | * @var string 77 | */ 78 | protected $format; 79 | /** 80 | * Whether or not the image is hosted remotely 81 | * 82 | * @var bool 83 | */ 84 | protected $remoteImage; 85 | /** 86 | * Whether or not the current image is an actual file, or the raw file data 87 | * 88 | * By "raw file data" it's meant that we're actually passing the result of something 89 | * like file_get_contents() or perhaps from a database blob 90 | * 91 | * @var bool 92 | */ 93 | protected $isDataStream; 94 | 95 | /** 96 | * Class constructor 97 | * 98 | * @return ThumbBase 99 | */ 100 | public function __construct ($fileName, $isDataStream = false) 101 | { 102 | $this->imported = array(); 103 | $this->importedFunctions = array(); 104 | $this->errorMessage = null; 105 | $this->hasError = false; 106 | $this->fileName = $fileName; 107 | $this->remoteImage = false; 108 | $this->isDataStream = $isDataStream; 109 | 110 | $this->fileExistsAndReadable(); 111 | } 112 | 113 | /** 114 | * Imports plugins in $registry to the class 115 | * 116 | * @param array $registry 117 | */ 118 | public function importPlugins ($registry) 119 | { 120 | foreach ($registry as $plugin => $meta) 121 | { 122 | $this->imports($plugin); 123 | } 124 | } 125 | 126 | /** 127 | * Imports a plugin 128 | * 129 | * This is where all the plugins magic happens! This function "loads" the plugin functions, making them available as 130 | * methods on the class. 131 | * 132 | * @param string $object The name of the object to import / "load" 133 | */ 134 | protected function imports ($object) 135 | { 136 | // the new object to import 137 | $newImport = new $object(); 138 | // the name of the new object (class name) 139 | $importName = get_class($newImport); 140 | // the new functions to import 141 | $importFunctions = get_class_methods($newImport); 142 | 143 | // add the object to the registry 144 | array_push($this->imported, array($importName, $newImport)); 145 | 146 | // add the methods to the registry 147 | foreach ($importFunctions as $key => $functionName) 148 | { 149 | $this->importedFunctions[$functionName] = &$newImport; 150 | } 151 | } 152 | 153 | /** 154 | * Checks to see if $this->fileName exists and is readable 155 | * 156 | */ 157 | protected function fileExistsAndReadable () 158 | { 159 | if ($this->isDataStream === true) 160 | { 161 | return; 162 | } 163 | 164 | if (stristr($this->fileName, 'http://') !== false) 165 | { 166 | $this->remoteImage = true; 167 | return; 168 | } 169 | 170 | if (!file_exists($this->fileName)) 171 | { 172 | $this->triggerError('Image file not found: ' . $this->fileName); 173 | } 174 | elseif (!is_readable($this->fileName)) 175 | { 176 | $this->triggerError('Image file not readable: ' . $this->fileName); 177 | } 178 | } 179 | 180 | /** 181 | * Sets $this->errorMessage to $errorMessage and throws an exception 182 | * 183 | * Also sets $this->hasError to true, so even if the exceptions are caught, we don't 184 | * attempt to proceed with any other functions 185 | * 186 | * @param string $errorMessage 187 | */ 188 | protected function triggerError ($errorMessage) 189 | { 190 | $this->hasError = true; 191 | $this->errorMessage = $errorMessage; 192 | 193 | throw new Exception ($errorMessage); 194 | } 195 | 196 | /** 197 | * Calls plugin / imported functions 198 | * 199 | * This is also where a fair amount of plugins magaic happens. This magic method is called whenever an "undefined" class 200 | * method is called in code, and we use that to call an imported function. 201 | * 202 | * You should NEVER EVER EVER invoke this function manually. The universe will implode if you do... seriously ;) 203 | * 204 | * @param string $method 205 | * @param array $args 206 | */ 207 | public function __call ($method, $args) 208 | { 209 | if( array_key_exists($method, $this->importedFunctions)) 210 | { 211 | $args[] = $this; 212 | return call_user_func_array(array($this->importedFunctions[$method], $method), $args); 213 | } 214 | 215 | throw new BadMethodCallException ('Call to undefined method/class function: ' . $method); 216 | } 217 | 218 | /** 219 | * Returns $imported. 220 | * @see ThumbBase::$imported 221 | * @return array 222 | */ 223 | public function getImported () 224 | { 225 | return $this->imported; 226 | } 227 | 228 | /** 229 | * Returns $importedFunctions. 230 | * @see ThumbBase::$importedFunctions 231 | * @return array 232 | */ 233 | public function getImportedFunctions () 234 | { 235 | return $this->importedFunctions; 236 | } 237 | 238 | /** 239 | * Returns $errorMessage. 240 | * 241 | * @see ThumbBase::$errorMessage 242 | */ 243 | public function getErrorMessage () 244 | { 245 | return $this->errorMessage; 246 | } 247 | 248 | /** 249 | * Sets $errorMessage. 250 | * 251 | * @param object $errorMessage 252 | * @see ThumbBase::$errorMessage 253 | */ 254 | public function setErrorMessage ($errorMessage) 255 | { 256 | $this->errorMessage = $errorMessage; 257 | } 258 | 259 | /** 260 | * Returns $fileName. 261 | * 262 | * @see ThumbBase::$fileName 263 | */ 264 | public function getFileName () 265 | { 266 | return $this->fileName; 267 | } 268 | 269 | /** 270 | * Sets $fileName. 271 | * 272 | * @param object $fileName 273 | * @see ThumbBase::$fileName 274 | */ 275 | public function setFileName ($fileName) 276 | { 277 | $this->fileName = $fileName; 278 | } 279 | 280 | /** 281 | * Returns $format. 282 | * 283 | * @see ThumbBase::$format 284 | */ 285 | public function getFormat () 286 | { 287 | return $this->format; 288 | } 289 | 290 | /** 291 | * Sets $format. 292 | * 293 | * @param object $format 294 | * @see ThumbBase::$format 295 | */ 296 | public function setFormat ($format) 297 | { 298 | $this->format = $format; 299 | } 300 | 301 | /** 302 | * Returns $hasError. 303 | * 304 | * @see ThumbBase::$hasError 305 | */ 306 | public function getHasError () 307 | { 308 | return $this->hasError; 309 | } 310 | 311 | /** 312 | * Sets $hasError. 313 | * 314 | * @param object $hasError 315 | * @see ThumbBase::$hasError 316 | */ 317 | public function setHasError ($hasError) 318 | { 319 | $this->hasError = $hasError; 320 | } 321 | 322 | 323 | } 324 | -------------------------------------------------------------------------------- /resources/library/phpthumb/ThumbLib.inc.php: -------------------------------------------------------------------------------- 1 | 14 | * Copyright (c) 2009, Ian Selby/Gen X Design 15 | * 16 | * Author(s): Ian Selby 17 | * 18 | * Licensed under the MIT License 19 | * Redistributions of files must retain the above copyright notice. 20 | * 21 | * @author Ian Selby 22 | * @copyright Copyright (c) 2009 Gen X Design 23 | * @link http://phpthumb.gxdlabs.com 24 | * @license http://www.opensource.org/licenses/mit-license.php The MIT License 25 | * @version 3.0 26 | * @package PhpThumb 27 | * @filesource 28 | */ 29 | 30 | // define some useful constants 31 | define('THUMBLIB_BASE_PATH', dirname(__FILE__)); 32 | define('THUMBLIB_PLUGIN_PATH', THUMBLIB_BASE_PATH . '/thumb_plugins/'); 33 | define('DEFAULT_THUMBLIB_IMPLEMENTATION', 'gd'); 34 | 35 | /** 36 | * Include the PhpThumb Class 37 | */ 38 | require_once THUMBLIB_BASE_PATH . '/PhpThumb.inc.php'; 39 | /** 40 | * Include the ThumbBase Class 41 | */ 42 | require_once THUMBLIB_BASE_PATH . '/ThumbBase.inc.php'; 43 | /** 44 | * Include the GdThumb Class 45 | */ 46 | require_once THUMBLIB_BASE_PATH . '/GdThumb.inc.php'; 47 | 48 | /** 49 | * PhpThumbFactory Object 50 | * 51 | * This class is responsible for making sure everything is set up and initialized properly, 52 | * and returning the appropriate thumbnail class instance. It is the only recommended way 53 | * of using this library, and if you try and circumvent it, the sky will fall on your head :) 54 | * 55 | * Basic use is easy enough. First, make sure all the settings meet your needs and environment... 56 | * these are the static variables defined at the beginning of the class. 57 | * 58 | * Once that's all set, usage is pretty easy. You can simply do something like: 59 | * $thumb = PhpThumbFactory::create('/path/to/file.png'); 60 | * 61 | * Refer to the documentation for the create function for more information 62 | * 63 | * @package PhpThumb 64 | * @subpackage Core 65 | */ 66 | class PhpThumbFactory 67 | { 68 | /** 69 | * Which implemenation of the class should be used by default 70 | * 71 | * Currently, valid options are: 72 | * - imagick 73 | * - gd 74 | * 75 | * These are defined in the implementation map variable, inside the create function 76 | * 77 | * @var string 78 | */ 79 | public static $defaultImplemenation = DEFAULT_THUMBLIB_IMPLEMENTATION; 80 | /** 81 | * Where the plugins can be loaded from 82 | * 83 | * Note, it's important that this path is properly defined. It is very likely that you'll 84 | * have to change this, as the assumption here is based on a relative path. 85 | * 86 | * @var string 87 | */ 88 | public static $pluginPath = THUMBLIB_PLUGIN_PATH; 89 | 90 | /** 91 | * Factory Function 92 | * 93 | * This function returns the correct thumbnail object, augmented with any appropriate plugins. 94 | * It does so by doing the following: 95 | * - Getting an instance of PhpThumb 96 | * - Loading plugins 97 | * - Validating the default implemenation 98 | * - Returning the desired default implementation if possible 99 | * - Returning the GD implemenation if the default isn't available 100 | * - Throwing an exception if no required libraries are present 101 | * 102 | * @return GdThumb 103 | * @uses PhpThumb 104 | * @param string $filename The path and file to load [optional] 105 | */ 106 | public static function create ($filename = null, $options = array(), $isDataStream = false) 107 | { 108 | // map our implementation to their class names 109 | $implementationMap = array 110 | ( 111 | 'imagick' => 'ImagickThumb', 112 | 'gd' => 'GdThumb' 113 | ); 114 | 115 | // grab an instance of PhpThumb 116 | $pt = PhpThumb::getInstance(); 117 | // load the plugins 118 | $pt->loadPlugins(self::$pluginPath); 119 | 120 | $toReturn = null; 121 | $implementation = self::$defaultImplemenation; 122 | 123 | // attempt to load the default implementation 124 | if ($pt->isValidImplementation(self::$defaultImplemenation)) 125 | { 126 | $imp = $implementationMap[self::$defaultImplemenation]; 127 | $toReturn = new $imp($filename, $options, $isDataStream); 128 | } 129 | // load the gd implementation if default failed 130 | else if ($pt->isValidImplementation('gd')) 131 | { 132 | $imp = $implementationMap['gd']; 133 | $implementation = 'gd'; 134 | $toReturn = new $imp($filename, $options, $isDataStream); 135 | } 136 | // throw an exception if we can't load 137 | else 138 | { 139 | throw new Exception('You must have either the GD or iMagick extension loaded to use this library'); 140 | } 141 | 142 | $registry = $pt->getPluginRegistry($implementation); 143 | $toReturn->importPlugins($registry); 144 | return $toReturn; 145 | } 146 | } -------------------------------------------------------------------------------- /resources/library/phpthumb/thumb_plugins/gd_reflection.inc.php: -------------------------------------------------------------------------------- 1 | 9 | * Copyright (c) 2009, Ian Selby/Gen X Design 10 | * 11 | * Author(s): Ian Selby 12 | * 13 | * Licensed under the MIT License 14 | * Redistributions of files must retain the above copyright notice. 15 | * 16 | * @author Ian Selby 17 | * @copyright Copyright (c) 2009 Gen X Design 18 | * @link http://phpthumb.gxdlabs.com 19 | * @license http://www.opensource.org/licenses/mit-license.php The MIT License 20 | * @version 3.0 21 | * @package PhpThumb 22 | * @filesource 23 | */ 24 | 25 | /** 26 | * GD Reflection Lib Plugin 27 | * 28 | * This plugin allows you to create those fun Apple(tm)-style reflections in your images 29 | * 30 | * @package PhpThumb 31 | * @subpackage Plugins 32 | */ 33 | class GdReflectionLib 34 | { 35 | /** 36 | * Instance of GdThumb passed to this class 37 | * 38 | * @var GdThumb 39 | */ 40 | protected $parentInstance; 41 | protected $currentDimensions; 42 | protected $workingImage; 43 | protected $newImage; 44 | protected $options; 45 | 46 | public function createReflection ($percent, $reflection, $white, $border, $borderColor, &$that) 47 | { 48 | // bring stuff from the parent class into this class... 49 | $this->parentInstance = $that; 50 | $this->currentDimensions = $this->parentInstance->getCurrentDimensions(); 51 | $this->workingImage = $this->parentInstance->getWorkingImage(); 52 | $this->newImage = $this->parentInstance->getOldImage(); 53 | $this->options = $this->parentInstance->getOptions(); 54 | 55 | $width = $this->currentDimensions['width']; 56 | $height = $this->currentDimensions['height']; 57 | $reflectionHeight = intval($height * ($reflection / 100)); 58 | $newHeight = $height + $reflectionHeight; 59 | $reflectedPart = $height * ($percent / 100); 60 | 61 | $this->workingImage = imagecreatetruecolor($width, $newHeight); 62 | 63 | imagealphablending($this->workingImage, true); 64 | 65 | $colorToPaint = imagecolorallocatealpha($this->workingImage,255,255,255,0); 66 | imagefilledrectangle($this->workingImage,0,0,$width,$newHeight,$colorToPaint); 67 | 68 | imagecopyresampled 69 | ( 70 | $this->workingImage, 71 | $this->newImage, 72 | 0, 73 | 0, 74 | 0, 75 | $reflectedPart, 76 | $width, 77 | $reflectionHeight, 78 | $width, 79 | ($height - $reflectedPart) 80 | ); 81 | 82 | $this->imageFlipVertical(); 83 | 84 | imagecopy($this->workingImage, $this->newImage, 0, 0, 0, 0, $width, $height); 85 | 86 | imagealphablending($this->workingImage, true); 87 | 88 | for ($i = 0; $i < $reflectionHeight; $i++) 89 | { 90 | $colorToPaint = imagecolorallocatealpha($this->workingImage, 255, 255, 255, ($i/$reflectionHeight*-1+1)*$white); 91 | 92 | imagefilledrectangle($this->workingImage, 0, $height + $i, $width, $height + $i, $colorToPaint); 93 | } 94 | 95 | if($border == true) 96 | { 97 | $rgb = $this->hex2rgb($borderColor, false); 98 | $colorToPaint = imagecolorallocate($this->workingImage, $rgb[0], $rgb[1], $rgb[2]); 99 | 100 | imageline($this->workingImage, 0, 0, $width, 0, $colorToPaint); //top line 101 | imageline($this->workingImage, 0, $height, $width, $height, $colorToPaint); //bottom line 102 | imageline($this->workingImage, 0, 0, 0, $height, $colorToPaint); //left line 103 | imageline($this->workingImage, $width-1, 0, $width-1, $height, $colorToPaint); //right line 104 | } 105 | 106 | if ($this->parentInstance->getFormat() == 'PNG') 107 | { 108 | $colorTransparent = imagecolorallocatealpha 109 | ( 110 | $this->workingImage, 111 | $this->options['alphaMaskColor'][0], 112 | $this->options['alphaMaskColor'][1], 113 | $this->options['alphaMaskColor'][2], 114 | 0 115 | ); 116 | 117 | imagefill($this->workingImage, 0, 0, $colorTransparent); 118 | imagesavealpha($this->workingImage, true); 119 | } 120 | 121 | $this->parentInstance->setOldImage($this->workingImage); 122 | $this->currentDimensions['width'] = $width; 123 | $this->currentDimensions['height'] = $newHeight; 124 | $this->parentInstance->setCurrentDimensions($this->currentDimensions); 125 | 126 | return $that; 127 | } 128 | 129 | /** 130 | * Flips the image vertically 131 | * 132 | */ 133 | protected function imageFlipVertical () 134 | { 135 | $x_i = imagesx($this->workingImage); 136 | $y_i = imagesy($this->workingImage); 137 | 138 | for ($x = 0; $x < $x_i; $x++) 139 | { 140 | for ($y = 0; $y < $y_i; $y++) 141 | { 142 | imagecopy($this->workingImage, $this->workingImage, $x, $y_i - $y - 1, $x, $y, 1, 1); 143 | } 144 | } 145 | } 146 | 147 | /** 148 | * Converts a hex color to rgb tuples 149 | * 150 | * @return mixed 151 | * @param string $hex 152 | * @param bool $asString 153 | */ 154 | protected function hex2rgb ($hex, $asString = false) 155 | { 156 | // strip off any leading # 157 | if (0 === strpos($hex, '#')) 158 | { 159 | $hex = substr($hex, 1); 160 | } 161 | elseif (0 === strpos($hex, '&H')) 162 | { 163 | $hex = substr($hex, 2); 164 | } 165 | 166 | // break into hex 3-tuple 167 | $cutpoint = ceil(strlen($hex) / 2)-1; 168 | $rgb = explode(':', wordwrap($hex, $cutpoint, ':', $cutpoint), 3); 169 | 170 | // convert each tuple to decimal 171 | $rgb[0] = (isset($rgb[0]) ? hexdec($rgb[0]) : 0); 172 | $rgb[1] = (isset($rgb[1]) ? hexdec($rgb[1]) : 0); 173 | $rgb[2] = (isset($rgb[2]) ? hexdec($rgb[2]) : 0); 174 | 175 | return ($asString ? "{$rgb[0]} {$rgb[1]} {$rgb[2]}" : $rgb); 176 | } 177 | } 178 | 179 | $pt = PhpThumb::getInstance(); 180 | $pt->registerPlugin('GdReflectionLib', 'gd'); -------------------------------------------------------------------------------- /resources/templates/breadcrumbs.php: -------------------------------------------------------------------------------- 1 | . 22 | * 23 | * @category Website 24 | * @package Photolight 25 | * @author Thibaud Rohmer 26 | * @copyright 2011 Thibaud Rohmer 27 | * @license http://www.gnu.org/licenses/ 28 | * @link http://github.com/thibaud-rohmer/PhotoLight 29 | */ 30 | 31 | $breadcrumbs = breadcrumbs(a2r($dir,$config["path"])); 32 | 33 | $url = "?f=."; 34 | echo "
"; 35 | echo "Home"; 36 | foreach ($breadcrumbs as $b){ 37 | $url = $url."/".$b; 38 | echo " > $b"; 39 | } 40 | echo "
"; 41 | ?> -------------------------------------------------------------------------------- /resources/templates/content.php: -------------------------------------------------------------------------------- 1 | . 22 | * 23 | * @category Website 24 | * @package Photolight 25 | * @author Thibaud Rohmer 26 | * @copyright 2011 Thibaud Rohmer 27 | * @license http://www.gnu.org/licenses/ 28 | * @link http://github.com/thibaud-rohmer/PhotoLight 29 | */ 30 | 31 | 32 | $folders = list_dirs($dir); 33 | $files = list_files($dir); 34 | 35 | if(count($folders) > 0){ 36 | echo "
\n"; 37 | foreach ($folders as $folder){ 38 | if(file_exists($folder."/.pshide")){ 39 | continue; 40 | } 41 | 42 | $f = a2r($folder,$config['path']); 43 | $name = nice($folder); 44 | 45 | $new_file = false; 46 | foreach($new as $n){ 47 | $a = $n; 48 | $b = realpath($folder); 49 | if(is_inside($b,$a)){ 50 | $new_file = true; 51 | break; 52 | } 53 | } 54 | 55 | $img = addslashes(a2r(list_files($folder,true,true),$config['path'])); 56 | 57 | 58 | echo "
\n"; 67 | 68 | if($new_file){ 69 | echo "
"; 70 | } 71 | 72 | echo "
\n"; 73 | } 74 | echo "
\n"; 75 | } 76 | 77 | if(count($files) > 0){ 78 | echo "
\n"; 79 | foreach ($files as $file){ 80 | $f = a2r($file,$config['path']); 81 | $name = nice($file); 82 | 83 | $new_file = ""; 84 | foreach($new as $n){ 85 | $a = $n; 86 | $b = realpath($file); 87 | if(is_inside($b,$a)){ 88 | $new_file = "new"; 89 | break; 90 | } 91 | } 92 | 93 | echo "
\n"; 94 | } 95 | echo "
\n"; 96 | } 97 | ?> 98 | -------------------------------------------------------------------------------- /resources/templates/functions.php: -------------------------------------------------------------------------------- 1 | . 22 | * 23 | * @category Website 24 | * @package Photolight 25 | * @author Thibaud Rohmer 26 | * @copyright 2011 Thibaud Rohmer 27 | * @license http://www.gnu.org/licenses/ 28 | * @link http://github.com/thibaud-rohmer/PhotoLight 29 | */ 30 | 31 | 32 | /** 33 | * List directories in $dir, omit hidden directories 34 | * 35 | * @param string $dir 36 | * @return void 37 | * @author Thibaud Rohmer 38 | */ 39 | function list_dirs($dir,$rec=false, $hidden=false){ 40 | 41 | /// Directories list 42 | $list=array(); 43 | 44 | /// Check that $dir is a directory, or throw exception 45 | if(!is_dir($dir)) 46 | throw new Exception("'".$dir."' is not a directory"); 47 | 48 | /// Directory content 49 | $dir_content = scandir($dir); 50 | 51 | if (empty($dir_content)){ 52 | // Directory is empty or no right to read 53 | return $list; 54 | } 55 | 56 | /// Check each content 57 | foreach ($dir_content as $content){ 58 | 59 | /// Content isn't hidden and is a directory 60 | if( ($content[0] != '.' || $hidden) && is_dir($path=$dir."/".$content)){ 61 | 62 | /// Add content to list 63 | $list[]=$path; 64 | 65 | if($rec){ 66 | $list = array_merge($list,list_dirs($dir."/".$content,true)); 67 | } 68 | 69 | } 70 | 71 | } 72 | 73 | /// Return directories list 74 | return $list; 75 | } 76 | 77 | /** 78 | * List files in $dir, omit hidden files 79 | * 80 | * @param string $dir 81 | * @return void 82 | * @author Thibaud Rohmer 83 | */ 84 | function list_files($dir,$rec = false, $first = false){ 85 | /// Directories list 86 | $list=array(); 87 | 88 | /// Check that $dir is a directory, or throw exception 89 | if(!is_dir($dir)) 90 | throw new Exception("'".$dir."' is not a directory"); 91 | 92 | /// Directory content 93 | $dir_content = scandir($dir); 94 | 95 | if (empty($dir_content)){ 96 | // Directory is empty or no right to read 97 | return $list; 98 | } 99 | 100 | /// Check each content 101 | foreach ($dir_content as $content){ 102 | 103 | /// Content isn't hidden and is a file 104 | if($content[0] != '.'){ 105 | if(is_file($path=$dir."/".$content)){ 106 | if($first){ 107 | return $path; 108 | } 109 | $list[]=$path; 110 | }else{ 111 | if($rec){ 112 | $list = array_merge($list,list_files($dir."/".$content,true)); 113 | } 114 | } 115 | } 116 | 117 | } 118 | 119 | /// Return files list 120 | if($first){ 121 | return $list[0]; 122 | } 123 | return $list; 124 | } 125 | 126 | 127 | function nice($t){ 128 | if(strpos($t,"/") > -1){ 129 | return substr($t,strrpos($t,"/")+1); 130 | }else{ 131 | return $t; 132 | } 133 | } 134 | 135 | function inGoodPlace($f,$path){ 136 | 137 | $rf = realpath($f); 138 | $rd = realpath($path); 139 | 140 | if($rf == $rd) return true; 141 | 142 | if( substr($rf,0,strlen($rd)) == $rd ){ 143 | return true; 144 | } 145 | return false; 146 | } 147 | 148 | function output($i){ 149 | $expires = 60*60*24*14; 150 | $last_modified_time = filemtime($i); 151 | $last_modified_time = 0; 152 | $etag = md5_file($i); 153 | 154 | header("Last-Modified: " . 0 . " GMT"); 155 | header("Pragma: public"); 156 | header("Cache-Control: max-age=360000"); 157 | header("Etag: $etag"); 158 | header("Cache-Control: maxage=".$expires); 159 | header('Expires: ' . gmdate('D, d M Y H:i:s', time()+$expires) . ' GMT'); 160 | header('Content-type: image/jpeg'); 161 | 162 | readfile($i); 163 | } 164 | 165 | 166 | /** 167 | * Check that $a is inside $b 168 | * 169 | * @param string $file 170 | * @param string $dir Directory from where the relative path will be (if NULL : photos_dir) 171 | * @return void 172 | * @author Thibaud Rohmer 173 | */ 174 | function is_inside($a,$b){ 175 | return substr($b,0,strlen($a)) == $a; 176 | } 177 | 178 | /** 179 | * Absolute path comes in, relative path goes out ! 180 | * 181 | * @param string $file 182 | * @param string $dir Directory from where the relative path will be (if NULL : photos_dir) 183 | * @return void 184 | * @author Thibaud Rohmer 185 | */ 186 | function a2r($file,$dir){ 187 | 188 | $rf = realpath($file); 189 | $rd = realpath($dir); 190 | 191 | if($rf==$rd) return ""; 192 | 193 | if( !is_inside($rd,$rf) ){ 194 | throw new Exception("This file is not inside the photos folder !
"); 195 | } 196 | 197 | return ( substr($rf,strlen($rd) + 1 ) ); 198 | } 199 | 200 | /** 201 | * Relative path comes in, absolute path goes out ! 202 | * 203 | * @param string $file 204 | * @param string $dir 205 | * @return void 206 | * @author Thibaud Rohmer 207 | */ 208 | function r2a($file,$dir){ 209 | return $dir."/".$file; 210 | } 211 | 212 | function breadcrumbs($p){ 213 | $a = array(); 214 | $pos = strpos($p,'/'); 215 | while($pos > 0){ 216 | $a[] = substr($p,0,$pos); 217 | $p = substr($p,$pos+1); 218 | $pos = strpos($p,'/'); 219 | } 220 | if($p != ""){ 221 | $a[] = $p; 222 | } 223 | return $a; 224 | } 225 | 226 | function create_thumb($source,$thumb_path,$thumbs_folder_path){ 227 | require_once("resources/library/phpthumb/ThumbLib.inc.php"); 228 | 229 | if(!file_exists($thumb_path) || filectime($source) > filectime($thumb_path) ){ 230 | 231 | /// Create directories 232 | if(!file_exists(dirname($thumb_path))){ 233 | @mkdir(dirname($thumb_path),0755,true); 234 | } 235 | 236 | /// Create thumbnail 237 | $thumb = PhpThumbFactory::create($source); 238 | $thumb->resize(200, 200); 239 | $thumb->save($thumb_path); 240 | 241 | /// New ! 242 | $new_file = fopen($thumbs_folder_path."/new.txt","a+"); 243 | fwrite($new_file,realpath($source)."\n"); 244 | 245 | // read the file in an array. 246 | $file = file($thumbs_folder_path."/new.txt"); 247 | 248 | // slice first 20 elements. 249 | $file = array_slice($file,0,20); 250 | 251 | // write back to file after joining. 252 | file_put_contents($thumbs_folder_path."/new.txt",implode("",$file)); 253 | } 254 | } 255 | 256 | 257 | ?> -------------------------------------------------------------------------------- /resources/templates/header.php: -------------------------------------------------------------------------------- 1 | . 22 | * 23 | * @category Website 24 | * @package Photolight 25 | * @author Thibaud Rohmer 26 | * @copyright 2011 Thibaud Rohmer 27 | * @license http://www.gnu.org/licenses/ 28 | * @link http://github.com/thibaud-rohmer/PhotoLight 29 | */ 30 | 31 | ?> 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | PhotoLight 45 | -------------------------------------------------------------------------------- /resources/templates/menu.php: -------------------------------------------------------------------------------- 1 | . 22 | * 23 | * @category Website 24 | * @package Photolight 25 | * @author Thibaud Rohmer 26 | * @copyright 2011 Thibaud Rohmer 27 | * @license http://www.gnu.org/licenses/ 28 | * @link http://github.com/thibaud-rohmer/PhotoLight 29 | */ 30 | 31 | 32 | $menu_items = list_dirs($dir); 33 | if( count($menu_items)>0 && $dir != $config["path"] ){ 34 | echo ""; 35 | foreach ($menu_items as $item){ 36 | $urlitem = $item; 37 | echo ""; 38 | } 39 | } 40 | 41 | echo ""; 42 | 43 | echo ""; 44 | 45 | $menu_items = list_dirs($config["path"]); 46 | foreach ($menu_items as $it){ 47 | $item = a2r($it,$config['path']); 48 | $urlitem = $item; 49 | echo ""; 50 | } 51 | 52 | 53 | 54 | ?> --------------------------------------------------------------------------------