Easy SSL Plugin for SAKURA Rental Server - Version 1.0

Version Description

=

Download this release

Release Info

Developer sakurainternet
Plugin Icon 128x128 Easy SSL Plugin for SAKURA Rental Server
Version 1.0
Comparing to
See all releases

Version 1.0

client/js/riot.min.js ADDED
@@ -0,0 +1,2 @@
 
 
1
+ /* Riot v3.2.1, @license MIT */
2
+ !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.riot=t.riot||{})}(this,function(t){"use strict";function e(t){return Dt.test(t)}function n(t){return Gt.test(t)}function r(t){return typeof t===It}function i(t){return t&&typeof t===St}function o(t){return typeof t===kt}function a(t){return typeof t===Rt}function s(t){return o(t)||null===t||""===t}function u(t){return Array.isArray(t)||t instanceof Array}function l(t,e){var n=Object.getOwnPropertyDescriptor(t,e);return o(t[e])||n&&n.writable}function c(t){return Ut.test(t)}function p(t,e){return(e||document).querySelectorAll(t)}function f(t,e){return(e||document).querySelector(t)}function h(){return document.createDocumentFragment()}function d(){return document.createTextNode("")}function g(t,e){return e?document.createElementNS("http://www.w3.org/2000/svg","svg"):document.createElement(t)}function m(t){if(t.outerHTML)return t.outerHTML;var e=g("div");return e.appendChild(t.cloneNode(!0)),e.innerHTML}function v(t,e){if(o(t.innerHTML)){var n=(new DOMParser).parseFromString(e,"application/xml"),r=t.ownerDocument.importNode(n.documentElement,!0);t.appendChild(r)}else t.innerHTML=e}function y(t,e){t.removeAttribute(e)}function x(t,e){return t.getAttribute(e)}function b(t,e,n){var r=Pt.exec(e);r&&r[1]?t.setAttributeNS(Ht,r[1],n):t.setAttribute(e,n)}function _(t,e,n){t.insertBefore(e,n.parentNode&&n)}function w(t,e){if(t)for(var n;n=zt.exec(t);)e(n[1].toLowerCase(),n[2]||n[3]||n[4])}function N(t,e,n){if(t){var r,i=e(t,n);if(i===!1)return;for(t=t.firstChild;t;)r=t.nextSibling,N(t,e,i),t=r}}function C(t,e){for(var n,r=t?t.length:0,i=0;i<r;++i)n=t[i],e(n,i)===!1&&i--;return t}function O(t,e){return!!~t.indexOf(e)}function T(t){return t.replace(/-(\w)/g,function(t,e){return e.toUpperCase()})}function E(t,e){return t.slice(0,e.length)===e}function L(t,e,n,r){return Object.defineProperty(t,e,M({value:n,enumerable:!1,writable:!1,configurable:!0},r)),t}function M(t){for(var e,n=arguments,r=1;r<n.length;++r)if(e=n[r])for(var i in e)l(t,i)&&(t[i]=e[i]);return t}function j(t,e,n){var r=this.__.parent,i=this.__.item;if(!i)for(;r&&!i;)i=r.__.item,r=r.__.parent;if(l(n,"currentTarget")&&(n.currentTarget=t),l(n,"target")&&(n.target=n.srcElement),l(n,"which")&&(n.which=n.charCode||n.keyCode),n.item=i,e.call(this,n),!n.preventUpdate){var o=st(this);o.isMounted&&o.update()}}function A(t,e,n,r){var i,o=j.bind(r,n,e);return n.addEventListener?(n[t]=null,i=t.replace(ie,""),n._riotEvents||(n._riotEvents={}),n._riotEvents[t]&&n.removeEventListener(i,n._riotEvents[t]),n._riotEvents[t]=o,void n.addEventListener(i,o,!1)):void(n[t]=o)}function R(t,e){var n,r,i,o,a=te(t.value,e);return t.tag&&t.tagName===a?void t.tag.update():(r="VIRTUAL"===t.dom.tagName,t.tag&&(r&&(i=t.tag.__.head,o=d(),i.parentNode.insertBefore(o,i)),t.tag.unmount(!0)),t.impl=wt[a],n={root:t.dom,parent:e,hasImpl:!0,tagName:a},t.tag=at(t.impl,n,t.dom.innerHTML,e),C(t.attrs,function(e){return b(t.tag.root,e.name,e.value)}),t.tagName=a,t.tag.mount(),r&&gt(t.tag,o||t.tag.root),void(e.__.onUnmount=function(){var e=t.tag.opts.dataIs,n=t.tag.parent.tags,r=t.tag.__.parent.tags;ft(n,e,t.tag),ft(r,e,t.tag),t.tag.unmount()}))}function S(t){if(!this.root||!x(this.root,"virtualized")){var e,n=t.dom,i=t.attr,a=O([jt,At],i),s=te(t.expr,this),u="riot-value"===i,l=t.root&&"VIRTUAL"===t.root.tagName,c=n&&(t.parent||n.parentNode);if(t.bool?s=!!s&&i:(o(s)||null===s)&&(s=""),t._riot_id)return void(t.isMounted?t.update():(t.mount(),l&&gt(t,t.root)));if(e=t.value,t.value=s,t.update)return void t.update();if(t.isRtag&&s)return R(t,this);if(e!==s&&(!u||n.value!==s)){if(!i)return s+="",void(c&&(t.parent=c,"TEXTAREA"===c.tagName?(c.value=s,Kt||(n.nodeValue=s)):n.nodeValue=s));if(t.isAttrRemoved&&s||(y(n,i),t.isAttrRemoved=!0),r(s))A(i,s,n,this);else if(a)i===At&&(s=!s),n.style.display=s?"":"none";else if(u)n.value=s;else if(E(i,Ct)&&i!==Tt)i=i.slice(Ct.length),Ft[i]&&(i=Ft[i]),null!=s&&b(n,i,s);else{if(t.bool&&(n[i]=s,!s))return;(0===s||s&&typeof s!==St)&&b(n,i,s)}}}}function k(t){C(t,S.bind(this))}function I(t,e,n,r){var i=r?Object.create(r):{};return i[t.key]=e,t.pos&&(i[t.pos]=n),i}function H(t,e){for(var n=e.length,r=t.length;n>r;)n--,P.apply(e[n],[e,n])}function P(t,e){t.splice(e,1),this.unmount(),ft(this.parent,this,this.__.tagName,!0)}function $(t){var e=this;C(Object.keys(this.tags),function(n){var r=e.tags[n];u(r)?C(r,function(e){ot.apply(e,[n,t])}):ot.apply(r,[n,t])})}function B(t,e,n){n?vt.apply(this,[t,e]):_(t,this.root,e.root)}function V(t,e,n){n?mt.apply(this,[t,e]):_(t,this.root,e.root)}function U(t,e){e?mt.call(this,t):t.appendChild(this.root)}function D(t,e,n){y(t,Lt);var r,i=typeof x(t,Mt)!==Rt||y(t,Mt),o=lt(t),s=wt[o],l=t.parentNode,c=d(),p=rt(t),f=x(t,Et),g=[],m=[],v=!0,b=!wt[o],_="VIRTUAL"===t.tagName;return n=te.loopKeys(n),n.isLoop=!0,f&&y(t,Et),l.insertBefore(c,t),l.removeChild(t),n.update=function(){var l=te(n.val,e),d=h(),y=!u(l)&&!a(l),x=c.parentNode;y?(r=l||!1,l=r?Object.keys(l).map(function(t){return I(n,l[t],t)}):[]):r=!1,f&&(l=l.filter(function(t,r){return n.key&&!y?!!te(f,I(n,t,r,e)):!!te(f,M(Object.create(e),t))})),C(l,function(a,u){var c=i&&typeof a===St&&!r,f=m.indexOf(a),h=!~f,y=!h&&c?f:u,w=g[y],N=u>=m.length,C=c&&h||!c&&!w;a=!r&&n.key?I(n,a,u):a,C?(w=new nt(s,{parent:e,isLoop:v,isAnonymous:b,tagName:o,root:t.cloneNode(b),item:a,index:u},t.innerHTML),w.mount(),N?U.apply(w,[d||x,_]):V.apply(w,[x,g[u],_]),N||m.splice(u,0,a),g.splice(u,0,w),p&&pt(e.tags,o,w,!0)):y!==u&&c&&(O(l,m[y])?(B.apply(w,[x,g[u],_]),g.splice(u,0,g.splice(y,1)[0]),m.splice(u,0,m.splice(y,1)[0])):(P.apply(g[u],[g,u]),m.splice(u,1)),n.pos&&(w[n.pos]=u),!p&&w.tags&&$.call(w,u)),w.__.item=a,w.__.index=u,w.__.parent=e,C||w.update(a)}),H(l,g),m=l.slice(),x.insertBefore(d,c)},n.unmount=function(){C(g,function(t){t.unmount()})},n}function z(t,e,n){var r=this,i={parent:{children:e}};return N(t,function(e,i){var o,a,s,u=e.nodeType,l=i.parent;if(!n&&e===t)return{parent:l};if(3===u&&"STYLE"!==e.parentNode.tagName&&te.hasExpr(e.nodeValue)&&l.children.push({dom:e,expr:e.nodeValue}),1!==u)return i;var c="VIRTUAL"===e.tagName;if(o=x(e,Lt))return c&&b(e,"loopVirtual",!0),l.children.push(D(e,r,o)),!1;if(o=x(e,Et))return l.children.push(Object.create(oe).init(e,r,o)),!1;if((a=x(e,Tt))&&te.hasExpr(a))return l.children.push({isRtag:!0,expr:a,dom:e,attrs:[].slice.call(e.attributes)}),!1;if(s=rt(e),c&&(x(e,"virtualized")&&e.parentElement.removeChild(e),s||x(e,"virtualized")||x(e,"loopVirtual")||(s={tmpl:e.outerHTML})),s&&(e!==t||n)){if(!c||x(e,Tt)){var p={root:e,parent:r,hasImpl:!0};return l.children.push(at(s,p,e.innerHTML,r)),!1}b(e,"virtualized",!0);var f=new nt({tmpl:e.outerHTML},{root:e,parent:r},e.innerHTML);l.children.push(f)}return F.apply(r,[e,e.attributes,function(t,e){e&&l.children.push(e)}]),{parent:l}},i),{tree:i,root:t}}function F(t,e,r){var i=this;C(e,function(e){var o,a=e.name,s=n(a);O(Ot,a)?o=Object.create(ae).init(t,i,a,e.value):te.hasExpr(e.value)&&(o={dom:t,expr:e.value,attr:e.name,bool:s}),r(e,o)})}function G(t,e,n){var r="o"===n[0],i=r?"select>":"table>";if(t.innerHTML="<"+i+e.trim()+"</"+i,i=t.firstChild,r)i.selectedIndex=-1;else{var o=pe[n];o&&1===i.childElementCount&&(i=f(o,i))}return i}function K(t,e){if(!se.test(t))return t;var n={};return e=e&&e.replace(le,function(t,e,r){return n[e]=n[e]||r,""}).trim(),t.replace(ce,function(t,e,r){return n[e]||r||""}).replace(ue,function(t,n){return e||n||""})}function q(t,n,r){var i=t&&t.match(/^\s*<([-\w]+)/),o=i&&i[1].toLowerCase(),a=g(he,r&&e(o));return t=K(t,n),fe.test(o)?a=G(a,t,o):v(a,t),a}function Z(t,e){var n=this,r=n.name,i=n.tmpl,o=n.css,a=n.attrs,s=n.onCreate;return wt[r]||(Q(r,i,o,a,s),wt[r].class=this.constructor),dt(t,r,e,this),o&&Yt.inject(),this}function Q(t,e,n,i,o){return r(i)&&(o=i,/^[\w\-]+\s?=/.test(n)?(i=n,n=""):i=""),n&&(r(n)?o=n:Yt.add(n)),t=t.toLowerCase(),wt[t]={name:t,tmpl:e,attrs:i,fn:o},t}function W(t,e,n,r,i){n&&Yt.add(n,t);var o=!!wt[t];return wt[t]={name:t,tmpl:e,attrs:r,fn:i},o&&_e.hotReloader&&_e.hotReloader(t),t}function X(t,e,n){function r(t){if(t.tagName){var i=x(t,Tt);e&&i!==e&&(i=e,b(t,Tt,e));var a=dt(t,i||t.tagName.toLowerCase(),n);a&&o.push(a)}else t.length&&C(t,r)}var o=[];Yt.inject(),i(e)&&(n=e,e=0);var s,u;if(a(t)?(t="*"===t?u=yt():t+yt(t.split(/, */)),s=t?p(t):[]):s=t,"*"===e){if(e=u||yt(),s.tagName)s=p(e,s);else{var l=[];C(s,function(t){return l.push(p(e,t))}),s=l}e=0}return r(s),o}function Y(t,e,n){if(i(t))return void Y("__unnamed_"+me++,t,!0);var a=n?ge:de;if(!e){if(o(a[t]))throw new Error("Unregistered mixin: "+t);return a[t]}a[t]=r(e)?M(e.prototype,a[t]||{})&&e:M(a[t]||{},e)}function J(){return C(_t,function(t){return t.update()})}function tt(t){delete wt[t]}function et(t,e,n,r,i){if(!t||!n){var o=!n&&t?this:e||this;C(i,function(t){t.expr&&k.call(o,[t.expr]),r[T(t.name)]=t.expr?t.expr.value:t.value})}}function nt(t,e,n){void 0===t&&(t={}),void 0===e&&(e={});var i,o=M({},e.opts),s=e.parent,u=e.isLoop,l=!!e.isAnonymous,c=re.skipAnonymousTags&&l,p=ct(e.item),f=e.index,h=[],d=[],g=[],m=e.root,v=e.tagName||lt(m),x="virtual"===v,_=[];c||ee(this),t.name&&m._tag&&m._tag.unmount(!0),this.isMounted=!1,L(this,"__",{isAnonymous:l,instAttrs:h,innerHTML:n,tagName:v,index:f,isLoop:u,virts:[],tail:null,head:null,parent:null,item:null}),L(this,"_riot_id",++ye),L(this,"root",m),M(this,{opts:o},p),L(this,"parent",s||null),L(this,"tags",{}),L(this,"refs",{}),i=u&&l?m:q(t.tmpl,n,u),L(this,"update",function(t){if(r(this.shouldUpdate)&&!this.shouldUpdate(t))return this;var e=this.isMounted&&!c;return t=ct(t),u&&l&&it.apply(this,[this.parent,_]),M(this,t),et.apply(this,[u,s,l,o,h]),e&&this.trigger("update",t),k.call(this,g),e&&this.trigger("updated"),this}.bind(this)),L(this,"mixin",function(){var t=this;return C(arguments,function(e){var n,i,o=[];e=a(e)?Y(e):e,n=r(e)?new e:e;var s=Object.getPrototypeOf(n);do o=o.concat(Object.getOwnPropertyNames(i||n));while(i=Object.getPrototypeOf(i||n));C(o,function(e){if("init"!==e){var i=Object.getOwnPropertyDescriptor(n,e)||Object.getOwnPropertyDescriptor(s,e),o=i&&(i.get||i.set);!t.hasOwnProperty(e)&&o?Object.defineProperty(t,e,i):t[e]=r(n[e])?n[e].bind(t):n[e]}}),n.init&&n.init.bind(t)()}),this}.bind(this)),L(this,"mount",function(){var e=this,n=this.__.parent;m._tag=this,F.apply(s,[m,m.attributes,function(t,n){!l&&ae.isPrototypeOf(n)&&(n.tag=e),t.expr=n,h.push(t)}]),d=[],w(t.attrs,function(t,e){d.push({name:t,value:e})}),F.apply(this,[m,d,function(t,e){e?g.push(e):b(m,t.name,t.value)}]),n&&l&&it.apply(this,[n,_]),et.apply(this,[u,s,l,o,h]);var r=Y(Nt);if(r&&!c)for(var a in r)r.hasOwnProperty(a)&&e.mixin(r[a]);if(t.fn&&t.fn.call(this,o),c||this.trigger("before-mount"),z.apply(this,[i,g,l]),this.update(p),!l)for(;i.firstChild;)m.appendChild(i.firstChild);if(L(this,"root",m),L(this,"isMounted",!0),!c){if(this.parent){var f=st(this.parent);f.one(f.isMounted?"updated":"mount",function(){e.trigger("mount")})}else this.trigger("mount");return this}}.bind(this)),L(this,"unmount",function(e){var n,r=this,i=this.root,o=i.parentNode,a=_t.indexOf(this);if(c||this.trigger("before-unmount"),w(t.attrs,function(t){E(t,Ct)&&(t=t.slice(Ct.length)),y(m,t)}),~a&&_t.splice(a,1),o||x){if(s)n=st(s),x?Object.keys(this.tags).forEach(function(t){ft(n.tags,t,r.tags[t])}):(ft(n.tags,v,this),s!==n&&ft(s.tags,v,this));else for(;i.firstChild;)i.removeChild(i.firstChild);o&&(e?y(o,Tt):o.removeChild(i))}return this.__.virts&&C(this.__.virts,function(t){t.parentNode&&t.parentNode.removeChild(t)}),ut(g),C(h,function(t){return t.expr&&t.expr.unmount&&t.expr.unmount()}),this.__.onUnmount&&this.__.onUnmount(),c||(this.trigger("unmount"),this.off("*")),L(this,"isMounted",!1),delete this.root._tag,this}.bind(this))}function rt(t){return t.tagName&&wt[x(t,Tt)||x(t,Tt)||t.tagName.toLowerCase()]}function it(t,e){var n=this;C(Object.keys(t),function(r){var i=!c(r)&&O(e,r);(o(n[r])||i)&&(i||e.push(r),n[r]=t[r])})}function ot(t,e){var n,r=this.parent;r&&(n=r.tags[t],u(n)?n.splice(e,0,n.splice(n.indexOf(this),1)[0]):pt(r.tags,t,this))}function at(t,e,n,r){var i=new nt(t,e,n),o=e.tagName||lt(e.root,!0),a=st(r);return L(i,"parent",a),i.__.parent=r,pt(a.tags,o,i),a!==r&&pt(r.tags,o,i),e.root.innerHTML="",i}function st(t){for(var e=t;e.__.isAnonymous&&e.parent;)e=e.parent;return e}function ut(t){C(t,function(t){t instanceof nt?t.unmount(!0):t.unmount&&t.unmount()})}function lt(t,e){var n=rt(t),r=!e&&x(t,Tt);return r&&!te.hasExpr(r)?r:n?n.name:t.tagName.toLowerCase()}function ct(t){if(!(t instanceof nt||t&&r(t.trigger)))return t;var e={};for(var n in t)Ut.test(n)||(e[n]=t[n]);return e}function pt(t,e,n,r,i){var a=t[e],s=u(a),l=!o(i);if(!a||a!==n)if(!a&&r)t[e]=[n];else if(a)if(s){var c=a.indexOf(n);if(c===i)return;~c&&a.splice(c,1),l?a.splice(i,0,n):a.push(n)}else t[e]=[a,n];else t[e]=n}function ft(t,e,n,r){if(u(t[e])){var i=t[e].indexOf(n);~i&&t[e].splice(i,1),t[e].length?1!==t[e].length||r||(t[e]=t[e][0]):delete t[e]}else delete t[e]}function ht(t){for(;t;){if(t.inStub)return!0;t=t.parentNode}return!1}function dt(t,e,n,r){var i=wt[e],o=wt[e].class,a=r||(o?Object.create(o.prototype):{}),s=t._innerHTML=t._innerHTML||t.innerHTML;t.innerHTML="";var u={root:t,opts:n};return n&&n.parent&&(u.parent=n.parent),i&&t&&nt.apply(a,[i,u,s]),a&&a.mount&&(a.mount(!0),O(_t,a)||_t.push(a)),a}function gt(t,e){var n=h();mt.call(t,n),e.parentNode.replaceChild(n,e)}function mt(t,e){var n,r,i=this,o=d(),a=d(),s=h();for(this.__.head=this.root.insertBefore(o,this.root.firstChild),this.__.tail=this.root.appendChild(a),r=this.__.head;r;)n=r.nextSibling,s.appendChild(r),i.__.virts.push(r),r=n;e?t.insertBefore(s,e.__.head):t.appendChild(s)}function vt(t,e){for(var n,r=this,i=this.__.head,o=h();i;)if(n=i.nextSibling,o.appendChild(i),i=n,i===r.__.tail){o.appendChild(i),t.insertBefore(o,e.__.head);break}}function yt(t){if(!t){var e=Object.keys(wt);return e+yt(e)}return t.filter(function(t){return!/[^-\w]/.test(t)}).reduce(function(t,e){var n=e.trim().toLowerCase();return t+",["+Tt+'="'+n+'"]'},"")}var xt,bt,_t=[],wt={},Nt="__global_mixin",Ct="riot-",Ot=["ref","data-ref"],Tt="data-is",Et="if",Lt="each",Mt="no-reorder",jt="show",At="hide",Rt="string",St="object",kt="undefined",It="function",Ht="http://www.w3.org/1999/xlink",Pt=/^xlink:(\w+)/,$t=typeof window===kt?void 0:window,Bt=/^(?:t(?:body|head|foot|[rhd])|caption|col(?:group)?|opt(?:ion|group))$/,Vt=/^(?:t(?:body|head|foot|[rhd])|caption|col(?:group)?)$/,Ut=/^(?:_(?:item|id|parent)|update|root|(?:un)?mount|mixin|is(?:Mounted|Loop)|tags|refs|parent|opts|trigger|o(?:n|ff|ne))$/,Dt=/^(altGlyph|animate(?:Color)?|circle|clipPath|defs|ellipse|fe(?:Blend|ColorMatrix|ComponentTransfer|Composite|ConvolveMatrix|DiffuseLighting|DisplacementMap|Flood|GaussianBlur|Image|Merge|Morphology|Offset|SpecularLighting|Tile|Turbulence)|filter|font|foreignObject|g(?:lyph)?(?:Ref)?|image|line(?:arGradient)?|ma(?:rker|sk)|missing-glyph|path|pattern|poly(?:gon|line)|radialGradient|rect|stop|svg|switch|symbol|text(?:Path)?|tref|tspan|use)$/,zt=/([-\w]+) ?= ?(?:"([^"]*)|'([^']*)|({[^}]*}))/g,Ft={viewbox:"viewBox"},Gt=/^(?:disabled|checked|readonly|required|allowfullscreen|auto(?:focus|play)|compact|controls|default|formnovalidate|hidden|ismap|itemscope|loop|multiple|muted|no(?:resize|shade|validate|wrap)?|open|reversed|seamless|selected|sortable|truespeed|typemustmatch)$/,Kt=0|($t&&$t.document||{}).documentMode,qt=Object.freeze({isSVGTag:e,isBoolAttr:n,isFunction:r,isObject:i,isUndefined:o,isString:a,isBlank:s,isArray:u,isWritable:l,isReservedName:c}),Zt=Object.freeze({$$:p,$:f,createFrag:h,createDOMPlaceholder:d,mkEl:g,getOuterHTML:m,setInnerHTML:v,remAttr:y,getAttr:x,setAttr:b,safeInsert:_,walkAttrs:w,walkNodes:N}),Qt={},Wt=[],Xt=!1;$t&&(xt=function(){var t=g("style");b(t,"type","text/css");var e=f("style[type=riot]");return e?(e.id&&(t.id=e.id),e.parentNode.replaceChild(t,e)):document.getElementsByTagName("head")[0].appendChild(t),t}(),bt=xt.styleSheet);var Yt={styleNode:xt,add:function(t,e){e?Qt[e]=t:Wt.push(t),Xt=!0},inject:function(){if($t&&Xt){Xt=!1;var t=Object.keys(Qt).map(function(t){return Qt[t]}).concat(Wt).join("\n");bt?bt.cssText=t:xt.innerHTML=t}}},Jt=function(t){function e(t){return t}function n(t,e){return e||(e=x),new RegExp(t.source.replace(/{/g,e[2]).replace(/}/g,e[3]),t.global?l:"")}function r(t){if(t===m)return v;var e=t.split(" ");if(2!==e.length||h.test(t))throw new Error('Unsupported brackets "'+t+'"');return e=e.concat(t.replace(d,"\\").split(" ")),e[4]=n(e[1].length>1?/{[\S\s]*?}/:v[4],e),e[5]=n(t.length>3?/\\({|})/g:v[5],e),e[6]=n(v[6],e),e[7]=RegExp("\\\\("+e[3]+")|([[({])|("+e[3]+")|"+f,l),e[8]=t,e}function i(t){return t instanceof RegExp?s(t):x[t]}function o(t){(t||(t=m))!==x[8]&&(x=r(t),s=t===m?e:n,x[9]=s(v[9])),y=t}function a(t){var e;t=t||{},e=t.brackets,Object.defineProperty(t,"brackets",{set:o,get:function(){return y},enumerable:!0}),u=t,o(e)}var s,u,l="g",c=/\/\*[^*]*\*+(?:[^*\/][^*]*\*+)*\//g,p=/"[^"\\]*(?:\\[\S\s][^"\\]*)*"|'[^'\\]*(?:\\[\S\s][^'\\]*)*'/g,f=p.source+"|"+/(?:\breturn\s+|(?:[$\w\)\]]|\+\+|--)\s*(\/)(?![*\/]))/.source+"|"+/\/(?=[^*\/])[^[\/\\]*(?:(?:\[(?:\\.|[^\]\\]*)*\]|\\.)[^[\/\\]*)*?(\/)[gim]*/.source,h=RegExp("[\\x00-\\x1F<>a-zA-Z0-9'\",;\\\\]"),d=/(?=[[\]()*+?.^$|])/g,g={"(":RegExp("([()])|"+f,l),"[":RegExp("([[\\]])|"+f,l),"{":RegExp("([{}])|"+f,l)},m="{ }",v=["{","}","{","}",/{[^}]*}/,/\\([{}])/g,/\\({)|{/g,RegExp("\\\\(})|([[({])|(})|"+f,l),m,/^\s*{\^?\s*([$\w]+)(?:\s*,\s*(\S+))?\s+in\s+(\S.*)\s*}/,/(^|[^\\]){=[\S\s]*?}/],y=t,x=[];return i.split=function(t,e,n){function r(t){e||a?l.push(t&&t.replace(n[5],"$1")):l.push(t)}function i(t,e,n){var r,i=g[e];for(i.lastIndex=n,n=1;(r=i.exec(t))&&(!r[1]||(r[1]===e?++n:--n)););return n?t.length:i.lastIndex}n||(n=x);var o,a,s,u,l=[],c=n[6];for(a=s=c.lastIndex=0;o=c.exec(t);){if(u=o.index,a){if(o[2]){c.lastIndex=i(t,o[2],c.lastIndex);continue}if(!o[3])continue}o[1]||(r(t.slice(s,u)),s=c.lastIndex,c=n[6+(a^=1)],c.lastIndex=s)}return t&&s<t.length&&r(t.slice(s)),l},i.hasExpr=function(t){return x[4].test(t)},i.loopKeys=function(t){var e=t.match(x[9]);return e?{key:e[1],pos:e[2],val:x[0]+e[3].trim()+x[1]}:{val:t.trim()}},i.array=function(t){return t?r(t):x},Object.defineProperty(i,"settings",{set:a,get:function(){return u}}),i.settings="undefined"!=typeof riot&&riot.settings||{},i.set=o,i.R_STRINGS=p,i.R_MLCOMMS=c,i.S_QBLOCKS=f,i}(),te=function(){function t(t,r){return t?(a[t]||(a[t]=n(t))).call(r,e):t}function e(e,n){e.riotData={tagName:n&&n.__&&n.__.tagName,_riot_id:n&&n._riot_id},t.errorHandler?t.errorHandler(e):"undefined"!=typeof console&&"function"==typeof console.error&&(e.riotData.tagName&&console.error("Riot template error thrown in the <%s> tag",e.riotData.tagName),console.error(e))}function n(t){var e=r(t);return"try{return "!==e.slice(0,11)&&(e="return "+e),new Function("E",e+";")}function r(t){var e,n=[],r=Jt.split(t.replace(c,'"'),1);if(r.length>2||r[0]){var o,a,s=[];for(o=a=0;o<r.length;++o)e=r[o],e&&(e=1&o?i(e,1,n):'"'+e.replace(/\\/g,"\\\\").replace(/\r\n?|\n/g,"\\n").replace(/"/g,'\\"')+'"')&&(s[a++]=e);e=a<2?s[0]:"["+s.join(",")+'].join("")'}else e=i(r[1],0,n);return n[0]&&(e=e.replace(p,function(t,e){return n[e].replace(/\r/g,"\\r").replace(/\n/g,"\\n")})),e}function i(t,e,n){function r(e,n){var r,i=1,o=f[e];for(o.lastIndex=n.lastIndex;r=o.exec(t);)if(r[0]===e)++i;else if(!--i)break;n.lastIndex=i?t.length:o.lastIndex}if(t=t.replace(l,function(t,e){return t.length>2&&!e?s+(n.push(t)-1)+"~":t}).replace(/\s+/g," ").trim().replace(/\ ?([[\({},?\.:])\ ?/g,"$1")){for(var i,a=[],c=0;t&&(i=t.match(u))&&!i.index;){var p,h,d=/,|([[{(])|$/g;for(t=RegExp.rightContext,p=i[2]?n[i[2]].slice(1,-1).trim().replace(/\s+/g," "):i[1];h=(i=d.exec(t))[1];)r(h,d);h=t.slice(0,i.index),t=RegExp.rightContext,a[c++]=o(h,1,p)}t=c?c>1?"["+a.join(",")+'].join(" ").trim()':a[0]:o(t,e)}return t}function o(t,e,n){var r;return t=t.replace(d,function(t,e,n,i,o){return n&&(i=r?0:i+t.length,"this"!==n&&"global"!==n&&"window"!==n?(t=e+'("'+n+h+n,i&&(r="."===(o=o[i])||"("===o||"["===o)):i&&(r=!g.test(o.slice(i)))),t}),r&&(t="try{return "+t+"}catch(e){E(e,this)}"),n?t=(r?"function(){"+t+"}.call(this)":"("+t+")")+'?"'+n+'":""':e&&(t="function(v){"+(r?t.replace("return ","v="):"v=("+t+")")+';return v||v===0?v:""}.call(this)'),t}var a={};t.hasExpr=Jt.hasExpr,t.loopKeys=Jt.loopKeys,t.clearCache=function(){a={}},t.errorHandler=null;var s=String.fromCharCode(8279),u=/^(?:(-?[_A-Za-z\xA0-\xFF][-\w\xA0-\xFF]*)|\u2057(\d+)~):/,l=RegExp(Jt.S_QBLOCKS,"g"),c=/\u2057/g,p=/\u2057(\d+)~/g,f={"(":/[()]/g,"[":/[[\]]/g,"{":/[{}]/g},h='"in this?this:'+("object"!=typeof window?"global":"window")+").",d=/[,{][\$\w]+(?=:)|(^ *|[^$\w\.{])(?!(?:typeof|true|false|null|undefined|in|instanceof|is(?:Finite|NaN)|void|NaN|new|Date|RegExp|Math)(?![$\w]))([$_A-Za-z][$\w]*)/g,g=/^(?=(\.[$\w]+))\1(?:[^.[(]|$)/;return t.version=Jt.version="v3.0.2",t}(),ee=function(t){t=t||{};var e={},n=Array.prototype.slice;return Object.defineProperties(t,{on:{value:function(n,r){return"function"==typeof r&&(e[n]=e[n]||[]).push(r),t},enumerable:!1,writable:!1,configurable:!1},off:{value:function(n,r){if("*"!=n||r)if(r)for(var i,o=e[n],a=0;i=o&&o[a];++a)i==r&&o.splice(a--,1);else delete e[n];else e={};return t},enumerable:!1,writable:!1,configurable:!1},one:{value:function(e,n){function r(){t.off(e,r),n.apply(t,arguments)}return t.on(e,r)},enumerable:!1,writable:!1,configurable:!1},trigger:{value:function(r){var i,o,a,s=arguments,u=arguments.length-1,l=new Array(u);for(a=0;a<u;a++)l[a]=s[a+1];for(i=n.call(e[r]||[],0),a=0;o=i[a];++a)o.apply(t,l);return e["*"]&&"*"!=r&&t.trigger.apply(t,["*",r].concat(l)),t},enumerable:!1,writable:!1,configurable:!1}}),t},ne=Object.freeze({each:C,contains:O,toCamel:T,startsWith:E,defineProperty:L,extend:M}),re=M(Object.create(Jt.settings),{skipAnonymousTags:!0}),ie=/^on/,oe={init:function(t,e,n){y(t,Et),this.tag=e,this.expr=n,this.stub=document.createTextNode(""),this.pristine=t;var r=t.parentNode;return r.insertBefore(this.stub,t),r.removeChild(t),this},update:function(){var t=te(this.expr,this.tag);t&&!this.current?(this.current=this.pristine.cloneNode(!0),this.stub.parentNode.insertBefore(this.current,this.stub),this.expressions=[],z.apply(this.tag,[this.current,this.expressions,!0])):!t&&this.current&&(ut(this.expressions),this.current._tag?this.current._tag.unmount():this.current.parentNode&&this.current.parentNode.removeChild(this.current),this.current=null,this.expressions=[]),t&&k.call(this.tag,this.expressions)},unmount:function(){ut(this.expressions||[]),delete this.pristine,delete this.parentNode,delete this.stub}},ae={init:function(t,e,n,r){return this.dom=t,this.attr=n,this.rawValue=r,this.parent=e,this.hasExp=te.hasExpr(r),this.firstRun=!0,this},update:function(){var t=this.rawValue;if(this.hasExp&&(t=te(this.rawValue,this.parent)),this.firstRun||t!==this.value){var e=this.parent&&st(this.parent),n=this.tag||this.dom;!s(this.value)&&e&&ft(e.refs,this.value,n),s(t)?y(this.dom,this.attr):(e&&pt(e.refs,t,n,null,this.parent.__.index),b(this.dom,this.attr,t)),this.value=t,this.firstRun=!1}},unmount:function(){var t=this.tag||this.dom,e=this.parent&&st(this.parent);!s(this.value)&&e&&ft(e.refs,this.value,t),delete this.dom,delete this.parent}},se=/<yield\b/i,ue=/<yield\s*(?:\/>|>([\S\s]*?)<\/yield\s*>|>)/gi,le=/<yield\s+to=['"]([^'">]*)['"]\s*>([\S\s]*?)<\/yield\s*>/gi,ce=/<yield\s+from=['"]?([-\w]+)['"]?\s*(?:\/>|>([\S\s]*?)<\/yield\s*>)/gi,pe={tr:"tbody",th:"tr",td:"tr",col:"colgroup"},fe=Kt&&Kt<10?Bt:Vt,he="div",de={},ge=de[Nt]={},me=0,ve=Object.freeze({Tag:Z,tag:Q,tag2:W,mount:X,mixin:Y,update:J,unregister:tt}),ye=0,xe=Object.freeze({getTag:rt,inheritFrom:it,moveChildTag:ot,initChildTag:at,getImmediateCustomParentTag:st,unmountAll:ut,getTagName:lt,cleanUpData:ct,arrayishAdd:pt,arrayishRemove:ft,isInStub:ht,mountTo:dt,makeReplaceVirtual:gt,makeVirtual:mt,moveVirtual:vt,selectTags:yt}),be=re,_e={tmpl:te,brackets:Jt,styleManager:Yt,vdom:_t,styleNode:Yt.styleNode,dom:Zt,check:qt,misc:ne,tags:xe},we=Z,Ne=Q,Ce=W,Oe=X,Te=Y,Ee=J,Le=tt,Me=ee,je=M({},ve,{observable:ee,settings:be,util:_e});t.settings=be,t.util=_e,t.Tag=we,t.tag=Ne,t.tag2=Ce,t.mount=Oe,t.mixin=Te,t.update=Ee,t.unregister=Le,t.observable=Me,t.default=je,Object.defineProperty(t,"__esModule",{value:!0})});
client/js/tags.js ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ riot.tag2('sakuraabout', '<div> <h2>プラグインについて</h2> <p> このプラグインはさくらのレンタルサーバ上のWordPressサイトの設定を変更して、常時SSL化を簡単に行えるプラグインです。<br> 実行の前に準備が必要ですので、以下のチェックリストをご確認の上、チェックボックスにチェックを入れてから「SSL化を実行する」ボタンをクリックしてください。 </p> <p>詳しいプラグインの使い方・注意事項は<a href="https://help.sakura.ad.jp/hc/ja/articles/115000047641" target="_blank">サポートサイト</a>をご確認ください。 </div>', '', '', function(opts) {
2
+ });
3
+
4
+ riot.tag2('sakurassladmin', '<div> <sakuranotice></sakuranotice> <sakuraabout></sakuraabout> <hr hide="{opts.ssl_status == \'true\'}"> <dl hide="{opts.ssl_status == \'true\'}"> <dt> <input type="checkbox" name="is_registered_ssl" id="is_registered_ssl" checked="{state.is_registered_ssl}" onclick="{toggle}"> <label for="is_registered_ssl"> <b>共有SSLを利用している、もしくはSSL証明書を購入してレンタルサーバコントロールパネルから設定した</b> </label> </dt> <dd> <p> →未設定の方はサポートサイトをご確認の上、証明書の購入と設定をお願いします。<br> さくらのSSLでRapid SSLを購入すると、設定がより簡単に行えます。<br> 購入はレンタルサーバコントロールパネルより可能です。<br> <a href="https://help.sakura.ad.jp/hc/ja/articles/206056822" target="_blank"> 【ラピッドSSL】サーバコントロールパネルからの申込み・導入手順 </a><br> </p> </dd> <dt> <p><span class="checkbox-indent" role="presentation"></span><b>利用しているSSL証明書の種類を選択してください。</b></p> </dt> <dd> <p> <label> <input type="radio" name="ssl_type" value="sni" checked="{state.ssl_type == \'sni\'}" onclick="{changeSSLType}"> SNI SSL / 共有SSL </label> <label> <input type="radio" name="ssl_type" value="no_sni" checked="{state.ssl_type == \'no_sni\'}" onclick="{changeSSLType}"> 独自SSL(IPアドレスベース) </label> </p> <ul> <li> ※レンタルサーバビジネスプロ、マネージドサーバ以外のお客様はSNI SSLを選択してください。 </li> <li> ※ビジネスプロ、マネージドサーバのお客様は独自SSLを選択されている方のみ「独自SSL」を選択してください。<br> どちらの証明書を利用しているかわからない方は、<a href="https://help.sakura.ad.jp/hc/ja/articles/115000047641" target="_blank">サポートサイト</a>をご確認ください。 </li> </ul> </dd> <dt> <input type="checkbox" name="can_access_by_ssl" id="can_access_by_ssl" checked="{state.can_access_by_ssl}" onclick="{toggle}"> <label for="can_access_by_ssl"> <b>実際にSSLを利用してサイトと管理画面へアクセスできる。</b> </label> </dt> <dd> <ul> <li><a href="{opts.home_url}" target="_blank">{opts.home_url}</a></li> <li><a href="{opts.admin_url}" target="_blank">{opts.admin_url}</a></li> </p> </dd> </dl> <hr> <sakuraupdate ssl="{state.ssl_type}"></sakuraupdate> <hr show="{opts.ssl_status == \'true\'}"> <div show="{opts.ssl_status == \'true\'}"> <h2>このサイトでは常時SSL設定が有効化されています<h2> <p>有効化後に.htaccessを直接編集した場合、予期せぬ動作を起こす可能性がありますのでご了承ください。</p> <p>なお常時SSL設定を再度実施される場合は、一度プラグインを停止後再度有効化してください。</p> </div> <p class="submit" hide="{opts.ssl_status == \'true\'}"> <input type="submit" name="submit" id="submit" class="button button-primary button-large" value="SSL化を実行する" disabled="{state.ssl_enable}"> <span show="{state.ssl_enable}">チェックリスト内容を全て確認してください。</span> </p> </div>', 'sakurassladmin .checkbox-indent,[data-is="sakurassladmin"] .checkbox-indent{ display: inline-block; width: 23px; } sakurassladmin .sakura-modal-row,[data-is="sakurassladmin"] .sakura-modal-row{ position: fixed; top: 0; left: 0; background: rgba(0,0,0,0.8); height: 100%; width: 100%; z-index: 9999; display: -webkit-box; display: -moz-box; display: box; display: -webkit-flex; display: -moz-flex; display: -ms-flexbox; display: flex; -webkit-box-align: center; -moz-box-align: center; box-align: center; -webkit-align-items: center; -moz-align-items: center; -ms-align-items: center; -o-align-items: center; align-items: center; -ms-flex-align: center; -webkit-box-orient: vertical; -moz-box-orient: vertical; box-orient: vertical; -webkit-flex-direction: column; -moz-flex-direction: column; flex-direction: column; -ms-flex-direction: column; -webkit-box-pack: center; -moz-box-pack: center; box-pack: center; -webkit-justify-content: center; -moz-justify-content: center; -ms-justify-content: center; -o-justify-content: center; justify-content: center; -ms-flex-pack: center; } sakurassladmin .sakura-modal,[data-is="sakurassladmin"] .sakura-modal{ background: #fff; padding: 20px; overflow: scroll; }', '', function(opts) {
5
+ var self = this
6
+ self.state = {
7
+ 'is_registered_ssl': false,
8
+ 'can_access_by_ssl': false,
9
+ 'ssl_type': 'sni',
10
+ 'ssl_enable': true
11
+ }
12
+ this.toggle = function (e) {
13
+ self.state[e.target.id] = e.target.checked
14
+ isEnableSsl()
15
+ return true
16
+ }.bind(this)
17
+ this.changeSSLType = function(e){
18
+ self.state[e.target.name] = e.target.value
19
+ }.bind(this)
20
+ function isEnableSsl() {
21
+ if (self.state.is_registered_ssl && self.state.can_access_by_ssl) {
22
+ self.state.ssl_enable = false
23
+ } else {
24
+ self.state.ssl_enable = true
25
+ }
26
+ }
27
+ });
28
+
29
+ riot.tag2('nosnihtaccess', '<div class="sakura-modal-row"> <div class="sakura-modal"> <h2>書き込む.htaccessソース</h2> <h3>独自SSL(IPアドレスベース)</h3> <pre>\n# BEGIN Force SSL for SAKURA\n# 常時HTTPS化(HTTPSが無効な場合リダイレクト)\n&lt;IfModule mod_rewrite.c&gt;\nRewriteEngine on\nRewriteCond %{HTTPS} !on\nRewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]\n&lt;/IfModule&gt;\n# END Force SSL for SAKURA\n </pre> <span class="button button-primary button-large" onclick="{opts.close}">閉じる</span> </div> </div>', '', '', function(opts) {
30
+ });
31
+
32
+ riot.tag2('sakuranotice', '<div class="notice-warning notice"> <p class="notice-text" style="color:red;font-weight:bold;">このプラグインはさくらのレンタルサーバ/マネージドサーバをご利用頂いているお客様専用のプラグインです。<br> さくらのレンタルサーバ以外でご利用頂いた場合、サイト閲覧ができなくなります。 </p> </div>', '', '', function(opts) {
33
+ });
34
+
35
+ riot.tag2('snihtaccess', '<div class="sakura-modal-row"> <div class="sakura-modal"> <h2>書き込む.htaccessソース</h2> <h3>SNI SSL / 共有SSL</h3> <pre>\n# BEGIN Force SSL for SAKURA\n# RewriteしてもHTTPS環境変数を有効にする\nSetEnvIf REDIRECT_HTTPS (.*) HTTPS=$1\n\n# 常時HTTPS化(HTTPSが無効な場合リダイレクト)\n&lt;IfModule mod_rewrite.c&gt;\nRewriteEngine on\nRewriteCond %{ENV:HTTPS} !on\nRewriteCond %{REQUEST_URI} !^/wp-cron.php$\nRewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]\n&lt;/IfModule&gt;\n# END Force SSL for SAKURA\n </pre> <span class="button button-primary button-large" onclick="{opts.close}">閉じる</span> </div> </div>', '', '', function(opts) {
36
+ });
37
+
38
+ riot.tag2('sakuraupdate', '<section> <h2>このプラグインにより設定される内容</h2> <ul> <li> .htaccessを編集し、httpでのリクエストを全てhttpsにリダイレクトします。<br> <a onclick="{toggle}">詳しい設定内容を見る</a> </li> <li> WordPressのサイト設定を変更し、サイトのURLをhttpからhttpsに切り替えます。<br> ※切り替え以前の画像URLや投稿URLはすべてhttpsに置換されます。 </li> </ul> <p class="sakura-notice"> チェック内容を確認し、全てのチェックボックスにチェックを入れてからボタンをクリックしてください。 </p> <hr> <h2>設定後の動作について</h2> <ul> <li>※変更した内容を取り消したい場合は、プラグインを停止してください。変更内容は全て元に戻ります。</li> <li>※プラグインを停止するとSSL化されなくなります。SSLを利用している間はこのプラグインを有効化したままでご利用ください。</li> <li> ※SSL化以降の投稿やメディアファイルのURLは全て「https」となります。httpに戻す場合は置換作業が必要です。<br> SSL化した後に、もとに戻したい場合は<a href="https://help.sakura.ad.jp/hc/ja/articles/115000047641" target="_blank">サポートサイト</a>をご確認ください。 </li> <li>※SSL化を実行すると一旦ログアウトされ、httpsのログイン画面にリダイレクトされます。同じIDとパスワードでログインできます。</li> </ul> <snihtaccess if="{showHtaccess && opts.ssl == \'sni\'}" close="{close}"></snihtaccess> <nosnihtaccess if="{showHtaccess && opts.ssl != \'sni\'}" close="{close}"></nosnihtaccess> </section>', 'sakuraupdate .sakura-notice,[data-is="sakuraupdate"] .sakura-notice{ color: red; font-weight: bold }', '', function(opts) {
39
+ var self = this
40
+ self.showHtaccess = false
41
+ this.toggle = function (e) {
42
+ if(self.showHtaccess) {
43
+ self.showHtaccess = false
44
+ } else {
45
+ self.showHtaccess = true
46
+ }
47
+ return true
48
+ }.bind(this)
49
+ this.close = function(e) {
50
+ self.showHtaccess = false
51
+ self.update()
52
+ }.bind(this)
53
+ });
modules/base.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sakura_Base Class file
4
+ *
5
+ * @author hideokamoto <hide.okamoto@digitalcube.jp>
6
+ * @package Sakura_Ssl
7
+ * @since 0.1.0
8
+ */
9
+
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit; // Exit if accessed directly.
12
+ }
13
+
14
+ /**
15
+ * Define Sakura plugin's basic function and parameters
16
+ *
17
+ * @class Sakura_Base
18
+ * @since 0.1.0
19
+ */
20
+ class Sakura_Base {
21
+ /**
22
+ * Instance class
23
+ *
24
+ * @var Object $instance instance class
25
+ **/
26
+ private static $instance;
27
+
28
+ // Panel key.
29
+ const MENU_ID = 'sakura-admin-menu';
30
+ const OPTION_NAME = 'sakura_settings';
31
+
32
+ // Action key.
33
+ const SAKURA_FORCE_SSL = 'sakura-force-ssl';
34
+
35
+ /**
36
+ * Get Plugin version
37
+ *
38
+ * @return string
39
+ * @since 0.1.0
40
+ */
41
+ public static function version() {
42
+ static $version;
43
+
44
+ if ( ! $version ) {
45
+ $data = get_file_data( SAKURA_PLUGIN_ROOT , array( 'version' => 'Version' ) );
46
+ $version = $data['version'];
47
+ }
48
+ return $version;
49
+ }
50
+
51
+ /**
52
+ * Replace http to https
53
+ *
54
+ * @return string https url
55
+ * @param string $http_url http url.
56
+ * @since 0.1.0
57
+ **/
58
+ public function replace_url_as_https( $http_url ) {
59
+ $https_url = set_url_scheme( $http_url, 'https' );
60
+ return $https_url;
61
+ }
62
+ }
modules/includes.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Load included files
4
+ *
5
+ * @author hideokamoto <hide.okamoto@digitalcube.jp>
6
+ * @package Sakura_Ssl
7
+ * @since 0.1.0
8
+ */
9
+
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit; // Exit if accessed directly.
12
+ }
13
+
14
+ require_once( 'base.php' );
15
+ require_once( 'model/force-ssl.php' );
16
+
17
+
18
+ require_once( 'view/menus.php' );
19
+ require_once( 'view/components.php' );
20
+ require_once( 'view/admin-top.php' );
modules/model/force-ssl.php ADDED
@@ -0,0 +1,265 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sakura htaccess generate class
4
+ *
5
+ * @package Sakura_Ssl
6
+ * @author wokamoto <wokamoto@digitalcube.jp>
7
+ * hideokamoto <hide.okamoto@digitalcube.jp>
8
+ **/
9
+
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit; // Exit if accessed directly.
12
+ }
13
+
14
+ /**
15
+ * Update htaccess class
16
+ *
17
+ * @class Force_ssl_sakura
18
+ **/
19
+ class Force_ssl_sakura {
20
+ const HTACCESS_MARKER = 'Force SSL for SAKURA';
21
+ const HTACCESS_REWRITE_RULE = array(
22
+ '# RewriteしてもHTTPS環境変数を有効にする',
23
+ 'SetEnvIf REDIRECT_HTTPS (.*) HTTPS=$1',
24
+ '',
25
+ '# 常時HTTPS化(HTTPSが無効な場合リダイレクト)',
26
+ '<IfModule mod_rewrite.c>',
27
+ 'RewriteEngine on',
28
+ 'RewriteCond %{ENV:HTTPS} !on',
29
+ 'RewriteCond %{REQUEST_URI} !^/wp-cron.php$',
30
+ 'RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]',
31
+ '</IfModule>',
32
+ );
33
+ const HTACCESS_REWRITE_RULE_NO_SNI = array(
34
+ '# 常時HTTPS化(HTTPSが無効な場合リダイレクト)',
35
+ '<IfModule mod_rewrite.c>',
36
+ 'RewriteEngine on',
37
+ 'RewriteCond %{HTTPS} !on',
38
+ 'RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]',
39
+ '</IfModule>',
40
+ );
41
+
42
+ /**
43
+ * Get htaccess file path
44
+ *
45
+ * @access private
46
+ * @return string|boolean htaccess file path
47
+ * @since 0.1.0
48
+ **/
49
+ private function htaccess_file() {
50
+ $home_path = get_home_path();
51
+ $htaccess_file = $home_path . '.htaccess';
52
+ if ( ( ! file_exists( $htaccess_file ) && is_writable( $home_path ) ) || is_writable( $htaccess_file ) ) {
53
+ return $htaccess_file;
54
+ } else {
55
+ return new WP_Error( 'Sakura SSL update Error', '.htaccessの書き込み権限がありません。書き込み権限を設定してから再度実行してください。' );
56
+ }
57
+ }
58
+
59
+ /**
60
+ * Remove force ssl setting into .htaccess
61
+ *
62
+ * @access public
63
+ * @param string $htaccess_file .htaccess file path.
64
+ * @param string $ssl_type ssl type.
65
+ * @since 0.1.0
66
+ **/
67
+ public function insert_htaccess_rule( $htaccess_file, $ssl_type ) {
68
+ switch ( $ssl_type ) {
69
+ case 'no_sni':
70
+ $htaccess_template = self::HTACCESS_REWRITE_RULE_NO_SNI;
71
+ break;
72
+
73
+ case 'sni':
74
+ $htaccess_template = self::HTACCESS_REWRITE_RULE;
75
+ break;
76
+
77
+ default:
78
+ return new WP_Error( 'Sakura SSL type Error', "Type:{$ssl_type} is invalid type." );
79
+ break;
80
+ }
81
+ return insert_with_markers( $htaccess_file, self::HTACCESS_MARKER, $htaccess_template );
82
+ }
83
+
84
+ /**
85
+ * Remove force ssl setting into .htaccess
86
+ *
87
+ * @access private
88
+ * @param string $htaccess_file .htaccess file path.
89
+ * @return boolean result
90
+ * @since 0.1.0
91
+ **/
92
+ private function _remove_htaccess_rule( $htaccess_file ) {
93
+ $result = false;
94
+ if ( $htaccess_rewrite_rules = extract_from_markers( $htaccess_file, self::HTACCESS_MARKER ) ) {
95
+ $start_marker = '# BEGIN ' . self::HTACCESS_MARKER;
96
+ $end_marker = '# END ' . self::HTACCESS_MARKER;
97
+ $htaccess_rewrite_rule =
98
+ $start_marker . "\n" .
99
+ implode( "\n", $htaccess_rewrite_rules ) . "\n" .
100
+ $end_marker;
101
+ if ( $fp = fopen( $htaccess_file, 'r+' ) ) {
102
+ flock( $fp, LOCK_EX );
103
+ $lines = array();
104
+ while ( ! feof( $fp ) ) {
105
+ $lines[] = rtrim( fgets( $fp ), "\r\n" );
106
+ }
107
+ $org_file_date = implode( "\n", $lines );
108
+ $new_file_data = str_replace( $htaccess_rewrite_rule, '', $org_file_date );
109
+ if ( $new_file_data !== $org_file_date ) {
110
+ fseek( $fp, 0 );
111
+ if ( $bytes = fwrite( $fp, trim( $new_file_data ) ) ) {
112
+ ftruncate( $fp, ftell( $fp ) );
113
+ }
114
+ fflush( $fp );
115
+ $result = (bool) $bytes;
116
+ }
117
+ flock( $fp, LOCK_UN );
118
+ fclose( $fp );
119
+ }
120
+ }
121
+ return $result;
122
+ }
123
+
124
+ /**
125
+ * Update WordPress settings
126
+ *
127
+ * @access public
128
+ * @param string $ssl_type ssl type.
129
+ * @since 0.1.0
130
+ **/
131
+ public function activate( $ssl_type ) {
132
+ $htaccess_file = $this->htaccess_file();
133
+ if ( is_wp_error( $htaccess_file ) ) {
134
+ return $htaccess_file;
135
+ }
136
+ if ( ! got_mod_rewrite() ) {
137
+ return new WP_Error( 'Sakura SSL update Error', '.htaccessの書き込み権限がありません。書き込み権限を設定してから再度実行してください。');
138
+ }
139
+ $this->insert_htaccess_rule( $htaccess_file, $ssl_type );
140
+ update_option( Sakura_Base::SAKURA_FORCE_SSL, true );
141
+ $login_url = wp_login_url();
142
+ $pattern = '%http://%';
143
+ $replacement = 'https://';
144
+ $login_url = preg_replace( $pattern, $replacement, $login_url );
145
+ wp_safe_redirect( $login_url );
146
+ wp_logout();
147
+ return true;
148
+ }
149
+
150
+ /**
151
+ * Replace WordPress settings
152
+ *
153
+ * @access public
154
+ * @since 0.1.0
155
+ **/
156
+ public function unforce_ssl() {
157
+ $htaccess_file = $this->htaccess_file();
158
+ if ( $htaccess_file ) {
159
+ $this->_remove_htaccess_rule( $htaccess_file );
160
+ delete_option( Sakura_Base::SAKURA_FORCE_SSL );
161
+ wp_logout();
162
+ }
163
+ }
164
+
165
+ /**
166
+ * Replace http schema as https
167
+ *
168
+ * @param string $content WordPress content.
169
+ * @return string
170
+ * @since 0.1.0
171
+ * @access public
172
+ **/
173
+ public function replace_urls( $content ) {
174
+ $options = get_option( Sakura_Base::SAKURA_FORCE_SSL );
175
+ if ( ! $options ) {
176
+ return $content;
177
+ }
178
+ if ( empty( $content ) ) {
179
+ return $content;
180
+ }
181
+ $home_url = set_url_scheme( get_home_url(), 'http' );
182
+ $pattern = "%{$home_url}%";
183
+ $replacement = set_url_scheme( $home_url, 'https' );
184
+ $content = preg_replace( $pattern, $replacement, $content );
185
+ return $content;
186
+ }
187
+
188
+ /**
189
+ * Replace home url
190
+ *
191
+ * @access public
192
+ * @since 0.1.0
193
+ * @param string $url Url.
194
+ * @return string
195
+ **/
196
+ public function replace_home_url( $url ) {
197
+ return set_url_scheme( $url, 'https' );
198
+ }
199
+
200
+ /**
201
+ * Replace home url
202
+ *
203
+ * @access public
204
+ * @since 0.1.0
205
+ **/
206
+ public function replace_options() {
207
+ $options = get_option( Sakura_Base::SAKURA_FORCE_SSL );
208
+ if ( ! $options ) {
209
+ return;
210
+ }
211
+ $options = array(
212
+ 'siteurl',
213
+ 'home',
214
+ );
215
+ foreach ( $options as $option ) {
216
+ add_filter( "option_{$option}", array( $this, 'replace_home_url' ) );
217
+ }
218
+ }
219
+
220
+ /**
221
+ * Replace link by Link Filters
222
+ * https://codex.wordpress.org/Plugin_API/Filter_Reference#Link_Filters
223
+ *
224
+ * @access public
225
+ * @since 0.1.0
226
+ **/
227
+ public function replace_link_hooks() {
228
+ $options = get_option( Sakura_Base::SAKURA_FORCE_SSL );
229
+ if ( ! $options ) {
230
+ return;
231
+ }
232
+ $hooks = array(
233
+ 'attachment_link',
234
+ 'author_feed_link',
235
+ 'author_link',
236
+ 'comment_reply_link',
237
+ 'day_link',
238
+ 'feed_link',
239
+ 'get_comment_author_link',
240
+ 'get_comment_author_url_link',
241
+ 'month_link',
242
+ 'page_link',
243
+ 'post_link',
244
+ 'post_type_link',
245
+ 'the_permalink',
246
+ 'year_link',
247
+ 'tag_link',
248
+ 'term_link',
249
+ 'bloginfo_url',
250
+ 'lostpassword_url',
251
+ 'wp_get_attachment_url',
252
+ 'wp_get_attachment_thumb_url',
253
+ 'wp_nav_menu',
254
+ 'the_excerpt',
255
+ 'the_content',
256
+ 'login_url',
257
+ 'logout_url',
258
+ 'register_url',
259
+ 'admin_url',
260
+ );
261
+ foreach ( $hooks as $hook ) {
262
+ add_filter( $hook, array( $this, 'replace_urls' ) );
263
+ }
264
+ }
265
+ }
modules/view/admin-top.php ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sakura_Admin Class file
4
+ *
5
+ * @author hideokamoto <hide.okamoto@digitalcube.jp>
6
+ * @package Sakura_Ssl
7
+ * @since 0.1.0
8
+ */
9
+
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit; // Exit if accessed directly.
12
+ }
13
+
14
+ /**
15
+ * Sakura Plugin admin page scripts
16
+ *
17
+ * @class Sakura_Admin
18
+ * @since 0.1.0
19
+ */
20
+ class Sakura_Admin extends Sakura_Components {
21
+ /**
22
+ * Instance class
23
+ *
24
+ * @var Object $instance instance class
25
+ **/
26
+ private static $instance;
27
+
28
+ /**
29
+ * Get Instance Class
30
+ *
31
+ * @return Sakura_Admin
32
+ * @since 0.1.0
33
+ * @access public
34
+ */
35
+ public static function get_instance() {
36
+ if ( ! isset( self::$instance ) ) {
37
+ $c = __CLASS__;
38
+ self::$instance = new $c();
39
+ }
40
+ return self::$instance;
41
+ }
42
+
43
+ /**
44
+ * Show admin page html
45
+ *
46
+ * @access public
47
+ * @since 0.1.0
48
+ */
49
+ public function init_panel() {
50
+ $this->show_panel_html();
51
+ }
52
+
53
+ /**
54
+ * Get admin page html content
55
+ *
56
+ * @access public
57
+ * @return string html
58
+ * @since 0.1.0
59
+ */
60
+ public function get_content_html() {
61
+ $html = '';
62
+ $html .= $this->_get_header();
63
+ $html .= $this->_get_check_form();
64
+ return $html;
65
+ }
66
+
67
+ /**
68
+ * Get SSL Checklist form
69
+ *
70
+ * @access private
71
+ * @return string html
72
+ * @since 0.1.0
73
+ **/
74
+ private function _get_check_form() {
75
+ $admin_url = $this->replace_url_as_https( get_admin_url() );
76
+ $home_url = $this->replace_url_as_https( get_home_url() );
77
+ $status = 'false';
78
+ if ( get_option( Sakura_Base::SAKURA_FORCE_SSL ) ) {
79
+ $status = 'true';
80
+ }
81
+ $options = "{ admin_url: \"{$admin_url}\", home_url: \"{$home_url}\", ssl_status: \"{$status}\"}";
82
+ $html = '';
83
+ $html .= "<form method='post' action='' >";
84
+ $html .= "<sakurassladmin></sakurassladmin>";
85
+ $html .= "<script>riot.mount('sakurassladmin', {$options})</script>";
86
+ $html .= wp_nonce_field( self::SAKURA_FORCE_SSL , self::SAKURA_FORCE_SSL , true , false );
87
+ $html .= '</form>';
88
+ return $html;
89
+ }
90
+
91
+ /**
92
+ * Get pugin root admin header HTML
93
+ *
94
+ * @access public
95
+ * @return string html
96
+ * @since 0.1.0
97
+ */
98
+ private function _get_header() {
99
+ $html = '';
100
+ $html .= '<h2>' . __( 'さくらのレンタルサーバ 簡単SSL化プラグイン' , 'sakura-ssl' ) . '</h2>';
101
+ return $html;
102
+ }
103
+ }
modules/view/components.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sakura_Components Class file
4
+ *
5
+ * @author hideokamoto <hide.okamoto@digitalcube.jp>
6
+ * @package Sakura_Ssl
7
+ * @since 0.1.0
8
+ */
9
+
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit; // Exit if accessed directly.
12
+ }
13
+
14
+ /**
15
+ * Define Sakura Plugin's common comnponents
16
+ *
17
+ * @class Sakura_Components
18
+ * @since 0.1.0
19
+ */
20
+ class Sakura_Components extends Sakura_Base {
21
+ /**
22
+ * Instance class
23
+ *
24
+ * @var Object $instance instance class
25
+ **/
26
+ private static $instance;
27
+
28
+ /**
29
+ * Get Instance Class
30
+ *
31
+ * @return Sakura_Components
32
+ * @since 0.1.0
33
+ * @access public
34
+ */
35
+ public static function get_instance() {
36
+ if ( ! isset( self::$instance ) ) {
37
+ $c = __CLASS__;
38
+ self::$instance = new $c();
39
+ }
40
+ return self::$instance;
41
+ }
42
+
43
+ /**
44
+ * Show Sakura Plugin admin page html
45
+ *
46
+ * @access public
47
+ * @since 0.1.0
48
+ */
49
+ public function show_panel_html() {
50
+ $content = $this->get_content_html();
51
+ $html = $this->get_layout_html( $content );
52
+ $html = str_replace( ']]>', ']]&gt;', $html );
53
+ echo $html;
54
+ }
55
+
56
+ /**
57
+ * Create Sakura Plugin's admin page html
58
+ *
59
+ * @access public
60
+ * @param string $content content html.
61
+ * @return string HTML
62
+ * @since 0.1.0
63
+ */
64
+ public function get_layout_html( $content ) {
65
+ $html = "<div class='wrap' id='sakura-ssl-dashboard'>";
66
+ $html .= $content;
67
+ $html .= '</div>';
68
+ return $html;
69
+ }
70
+ }
modules/view/menus.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Sakura_Menus
4
+ *
5
+ * @author hideokamoto <hide.okamoto@digitalcube.jp>
6
+ * @package Sakura_Ssl
7
+ * @since 0.1.0
8
+ */
9
+
10
+ if ( ! defined( 'ABSPATH' ) ) {
11
+ exit; // Exit if accessed directly.
12
+ }
13
+
14
+ /**
15
+ * Define Sakura Plugin's admin page menus.
16
+ *
17
+ * @class Sakura_Menus
18
+ * @since 0.1.0
19
+ */
20
+ class Sakura_Menus extends Sakura_Base {
21
+ /**
22
+ * Instance class
23
+ *
24
+ * @var Object $instance instance class
25
+ **/
26
+ private static $instance;
27
+
28
+ /**
29
+ * Get Instance Class
30
+ *
31
+ * @return Sakura_Menus
32
+ * @since 0.1.0
33
+ * @access public
34
+ */
35
+ public static function get_instance() {
36
+ if ( ! isset( self::$instance ) ) {
37
+ $c = __CLASS__;
38
+ self::$instance = new $c();
39
+ }
40
+ return self::$instance;
41
+ }
42
+
43
+ /**
44
+ * Init plugin menu.
45
+ *
46
+ * @access public
47
+ * @since 0.1.0
48
+ */
49
+ public function init() {
50
+ add_action( 'admin_menu', array( $this, 'define_menus' ) );
51
+ }
52
+
53
+ /**
54
+ * Define Sakura plugin menus
55
+ *
56
+ * @access public
57
+ * @since 0.1.0
58
+ */
59
+ public function define_menus() {
60
+ $root = Sakura_Admin::get_instance();
61
+ add_options_page(
62
+ __( 'SAKURA RS SSL', 'sakura-ssl' ),
63
+ __( 'SAKURA RS SSL', 'sakura-ssl' ),
64
+ 'manage_options',
65
+ self::MENU_ID,
66
+ array( $root, 'init_panel' )
67
+ );
68
+ }
69
+ }
readme.txt ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ === さくらのレンタルサーバ 簡単SSL化プラグイン ===
2
+ Contributors: sakurainternet
3
+ Tags: ssl
4
+ Requires at least: 4.7.0
5
+ Tested up to: 4.7.3
6
+ Stable tag: 1.0
7
+ License: GPLv2 or later
8
+ License URI: http://www.gnu.org/licenses/gpl-2.0.html
9
+
10
+ このプラグインはさくらのレンタルサーバ上のWordPressで、常時SSL化を簡単に行えるプラグインです。さくらのレンタルサーバ以外では動作しません。
11
+
12
+ == Description ==
13
+
14
+ このプラグインはさくらのレンタルサーバをご利用頂いているお客様専用のプラグインです。さくらのレンタルサーバ以外にセットアップされたWordPress上でSSLを有効化すると、サイト閲覧ができなくなります。
15
+
16
+ = プラグインについて =
17
+
18
+ このプラグインはさくらのレンタルサーバ上のWordPressサイトの設定を変更して、常時SSLを簡単に行えるプラグインです。以下の設定が自動的に行われます。
19
+ ・.htaccessを書き換えて自動的にhttpsのURLへリダイレクトします。
20
+ ・サイト内の投稿のURLをhttpからhttpsに置換します。
21
+ ・サイト設定のサイトURLをhttpからhttpsに置換します。
22
+ ※プラグインを停止すると上記設定は解除されます。
23
+
24
+ SSL証明書の購入や設定はお客様で事前に必要となりますのでご注意ください。
25
+
26
+ 詳しいプラグインの使い方・注意事項は[サポートサイト](https://help.sakura.ad.jp/hc/ja/articles/115000047641 "サポートサイト")をご確認ください。
27
+
28
+ ■ LICENSE
29
+ - ALL PHP files: GPLv2
30
+ - client/js/riot.min.js: MIT
31
+
32
+ == Installation ==
33
+
34
+ プラグインを有効化後、設定画面の案内に従ってSSL化を実行してください。
35
+
36
+ == Frequently asked questions ==
37
+
38
+ 利用方法は[サポートサイト](https://help.sakura.ad.jp/hc/ja/articles/115000047641 "サポートサイト")を、困ったときには[トラブルシューティング](https://help.sakura.ad.jp/hc/ja/articles/115000051662 "トラブルシューティング")をご確認ください。
39
+
40
+ == Screenshots ==
41
+ 1. screenshot-1.png
42
+
43
+ == Changelog ==
44
+
45
+ = 1.0 =
46
+ * リリース
47
+
48
+ == Upgrade Notice ==
49
+
50
+
51
+ = 1.0 =
52
+ * リリース
sakura-rs-ssl.php ADDED
@@ -0,0 +1,167 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Plugin Name: SAKURA RS WP SSL
4
+ * Description: このプラグインはさくらのレンタルサーバ上のWordPressで、常時SSL化を簡単に行えるプラグインです。
5
+ * Author: SAKURA Internet Inc.
6
+ * Author URI: http://www.sakura.ne.jp/
7
+ * Plugin URI: https://help.sakura.ad.jp/hc/ja/articles/115000047641
8
+ * Text Domain: sakura-rs-ssl
9
+ * Domain Path: /languages
10
+ * Version: 1.0
11
+ *
12
+ * @package Sakura_Ssl
13
+ * License:
14
+ * Released under the GPL license
15
+ * http://www.gnu.org/copyleft/gpl.html
16
+ * Copyright 2017 wokamoto (email : wokamoto@digitalcube.jp)
17
+ * This program is free software; you can redistribute it and/or modify
18
+ * it under the terms of the GNU General Public License as published by
19
+ * the Free Software Foundation; either version 2 of the License, or
20
+ * (at your option) any later version.
21
+ * This program is distributed in the hope that it will be useful,
22
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24
+ * GNU General Public License for more details.
25
+ * You should have received a copy of the GNU General Public License
26
+ * along with this program; if not, write to the Free Software
27
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
28
+ */
29
+
30
+ define( 'SAKURA_PLUGIN_PATH', plugin_dir_path( __FILE__ ) );
31
+ define( 'SAKURA_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
32
+ define( 'SAKURA_PLUGIN_ROOT', __FILE__ );
33
+
34
+ require 'modules/includes.php';
35
+
36
+ $sakura = Sakura_Ssl_Controller::get_instance();
37
+ $sakura->init();
38
+
39
+ /**
40
+ * Controller class
41
+ *
42
+ * @class Sakura_Ssl_Controller
43
+ **/
44
+ class Sakura_Ssl_Controller {
45
+ /**
46
+ * Base class
47
+ *
48
+ * @var Object $base base class
49
+ **/
50
+ private $base;
51
+
52
+ /**
53
+ * Instance class
54
+ *
55
+ * @var Object $instance instance class
56
+ **/
57
+ private static $instance;
58
+
59
+ /**
60
+ * WP_Error Class
61
+ *
62
+ * @var Object $wp_error WP_Error Class
63
+ **/
64
+ private $wp_error = '';
65
+
66
+ /**
67
+ * Get Instance Class
68
+ *
69
+ * @return Sakura_Menus
70
+ * @since 0.1.0
71
+ * @access public
72
+ */
73
+ public static function get_instance() {
74
+ if ( ! isset( self::$instance ) ) {
75
+ $c = __CLASS__;
76
+ self::$instance = new $c();
77
+ }
78
+ return self::$instance;
79
+ }
80
+
81
+ /**
82
+ * Initialize Plugin
83
+ *
84
+ * @access public
85
+ * @since 0.1.0
86
+ */
87
+ public function init() {
88
+ $this->base = new Sakura_Base();
89
+ $menu = Sakura_Menus::get_instance();
90
+ $menu->init();
91
+ $this->_enque();
92
+ add_action( 'admin_init', array( $this, 'update_settings' ) );
93
+
94
+ $sakura = new Force_ssl_sakura();
95
+ register_deactivation_hook( __FILE__, array( $sakura, 'unforce_ssl' ) );
96
+ $sakura->replace_link_hooks();
97
+ $sakura->replace_options();
98
+ }
99
+
100
+ /**
101
+ * Display custom admin notice
102
+ *
103
+ * @access public
104
+ * @since 0.1.0
105
+ **/
106
+ public function admin_alert() {
107
+ if ( ! is_wp_error( $this->wp_error ) ) {
108
+ return;
109
+ }
110
+ $errors = $this->wp_error->get_error_messages();
111
+ if ( ! is_array( $errors ) ) {
112
+ return;
113
+ }
114
+ $html = '<div class="notice notice-error is-dismissible">';
115
+ foreach ( $errors as $error ) {
116
+ $html .= "<p>{$error}</p>";
117
+ }
118
+ $html .= '</div>';
119
+ $html = str_replace( ']]>', ']]&gt;', $html );
120
+ echo $html;
121
+ }
122
+
123
+ /**
124
+ * Update admin configuration
125
+ *
126
+ * @access public
127
+ * @since 0.1.0
128
+ **/
129
+ public function update_settings() {
130
+ if ( empty( $_POST ) ) {
131
+ return;
132
+ }
133
+ $key = Sakura_Base::SAKURA_FORCE_SSL;
134
+ if ( isset( $_POST[ $key ] ) && $_POST[ $key ] ) {
135
+ if ( check_admin_referer( $key, $key ) ) {
136
+ if ( isset( $_POST['ssl_type'] ) ) {
137
+ $sakura = new Force_ssl_sakura();
138
+ $this->wp_error = $sakura->activate( $_POST['ssl_type'] );
139
+ }
140
+ if ( is_wp_error( $this->wp_error ) ) {
141
+ add_action('admin_notices', array( $this, 'admin_alert' ) );
142
+ }
143
+ }
144
+ }
145
+ }
146
+
147
+ /**
148
+ * Run enqueue scripts hook
149
+ *
150
+ * @access private
151
+ * @since 0.1.0
152
+ **/
153
+ private function _enque() {
154
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_scripts' ) );
155
+ }
156
+
157
+ /**
158
+ * Enqueue scripts
159
+ *
160
+ * @access public
161
+ * @since 0.1.0
162
+ **/
163
+ public function admin_scripts() {
164
+ wp_enqueue_script( 'sakura-riot', path_join( SAKURA_PLUGIN_URL, 'client/js/riot.min.js' ), array(), '3.2.0', false );
165
+ wp_enqueue_script( 'sakura-admin-components', path_join( SAKURA_PLUGIN_URL, 'client/js/tags.js' ), array( 'jquery', 'sakura-riot' ), '0.1.1', false );
166
+ }
167
+ }
screenshot-1.png ADDED
Binary file