@@ -15,6 +15,7 @@ example for configuration:
1515 <script type="text/javascript">
1616 var validateHttpsUrl = "<?=$httpsUrl?>";
1717 var validateHttps = "<?=$validateHttps?>";
18+ var allowOnlyHttps = '<?=$account_settings->ONLY_HTTPS_CONNECTION?>';
1819 </script>
1920 <script type="text/javascript" src="validatehttps.js"></script>
2021
@@ -23,12 +24,14 @@ example for configuration:
2324 <script type="text/javascript" src="validatehttps.js"></script>
2425
2526*/
26-
27+
2728var dynamicUrl = ( typeof validateHttpsUrl == 'undefined' || validateHttpsUrl === "" ) ? 'https://www.metodika.com/valid.php' : validateHttpsUrl ;
2829var runValidation = ( typeof validateHttps == 'undefined' || validateHttps === "" ) ? '1' : validateHttps ;
30+ var allowOnlyHttps = ( typeof allowOnlyHttps == 'undefined' || allowOnlyHttps === "" ) ? '0' : allowOnlyHttps ;
31+ var warningText = ( typeof warningText == 'undefined' || warningText === "" ) ? "Unsecure SSL connection. Please update your browser. " : warningText + " " ;
32+ var moreInfo = ( typeof moreInfo == 'undefined' || moreInfo === "" ) ? "More info" : moreInfo ;
2933
30-
31- function loadJSON ( callback ) {
34+ function loadJSON ( callback ) {
3235 var xobj = new XMLHttpRequest ( ) ;
3336 xobj . overrideMimeType ( "application/json" ) ;
3437
@@ -59,13 +62,13 @@ xobj.send(null);
5962}
6063
6164
62- var warningText = "Unsecure SSL connection. Please update your browser. " ;
6365
6466
65- var validateWarning = '<div id="validateWrapper">' ;
6667
68+ var validateWarning = '<div id="validateWrapper">' ;
6769
68- validateWarning += '<p>' + warningText + '<a href="http://www.macworld.com/article/2099987/what-you-need-to-know-about-apples-ssl-bug.html" target="_blank">More info</a></p>' ;
70+
71+ validateWarning += '<p>' + warningText + '<a href="http://www.macworld.com/article/2099987/what-you-need-to-know-about-apples-ssl-bug.html" target="_blank">' + moreInfo + '</a></p>' ;
6972
7073
7174 validateWarning += '</div>' ; //validateWrapper
@@ -76,7 +79,7 @@ xobj.send(null);
7679 document . getElementById ( 'validateWrapper' ) . style . width = "100%" ;
7780 document . getElementById ( 'validateWrapper' ) . style . position = "absolute" ;
7881 document . getElementById ( 'validateWrapper' ) . style . top = "0" ;
79- document . getElementById ( 'validateWrapper' ) . style . paddingTop = "10px" ;
82+ document . getElementById ( 'validateWrapper' ) . style . paddingTop = "10px" ;
8083 document . getElementById ( 'validateWrapper' ) . style . textAlign = "center" ;
8184 document . getElementById ( 'validateWrapper' ) . style . backgroundColor = "rgb(236,236,236)" ;
8285
@@ -86,6 +89,60 @@ xobj.send(null);
8689
8790
8891
92+
93+
94+ var httpWarning = '<div id="httpBlock">' ;
95+ httpWarning += '<div>' ;
96+ httpWarning += '<p>' + warningText + '<a href="http://www.macworld.com/article/2099987/what-you-need-to-know-about-apples-ssl-bug.html" target="_blank">' + moreInfo + '</a></p>' ;
97+ httpWarning += '</div>' ;
98+
99+ httpWarning += '</div>' ;
100+ document . body . innerHTML += httpWarning ;
101+
102+ document . getElementById ( 'httpBlock' ) . style . visibility = 'hidden' ;
103+ document . getElementById ( 'httpBlock' ) . style . position = 'fixed' ;
104+ document . getElementById ( 'httpBlock' ) . style . left = '0px' ;
105+ document . getElementById ( 'httpBlock' ) . style . top = '0' ;
106+ document . getElementById ( 'httpBlock' ) . style . width = '100%' ;
107+ document . getElementById ( 'httpBlock' ) . style . height = '100%' ;
108+ document . getElementById ( 'httpBlock' ) . style . textAlign = 'center' ;
109+ document . getElementById ( 'httpBlock' ) . style . zIndex = '99999' ;
110+ document . getElementById ( 'httpBlock' ) . style . backgroundColor = 'rgba(0, 0, 0, 0.75)' ;
111+
112+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . border = '1px solid #999' ;
113+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . border = '1px solid rgba(0,0,0,0.3)' ;
114+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . webkitBorderRadius = '6px' ;
115+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . mozBorderRadius = '6px' ;
116+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . borderRadius = '6px' ;
117+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . outline = 0 ;
118+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . webkitBoxShadow = '0 3px 7px rgba(0,0,0,0.3)' ;
119+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . mozBoxShadow = '0 3px 7px rgba(0,0,0,0.3)' ;
120+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . boxShadow = '0 3px 7px rgba(0,0,0,0.3)' ;
121+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . webkitBackgroundClip = 'padding-box' ;
122+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . mozBackgroundClip = 'padding-box' ;
123+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . backgroundClip = 'padding-box' ;
124+
125+
126+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . position = 'fixed' ;
127+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . backgroundColor = '#fff' ;
128+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . border = '1px solid #000' ;
129+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . padding = '15px' ;
130+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . textAlign = 'center' ;
131+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . top = '10%' ;
132+
133+ //Small screen
134+ var w = Math . max ( document . documentElement . clientWidth , window . innerWidth || 0 ) ;
135+ if ( w > 767 ) {
136+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . width = '560px' ;
137+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . left = '50%' ;
138+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . marginLeft = '-280px' ;
139+ } else {
140+ document . getElementById ( 'httpBlock' ) . childNodes [ 0 ] . style . width = 'auto' ;
141+ }
142+
143+
144+
145+
89146var fullUrl = window . location . href ;
90147var http = fullUrl . split ( '://' ) ;
91148
@@ -107,9 +164,30 @@ var http = fullUrl.split('//');
107164
108165 //Warning box at the top
109166
167+ if ( allowOnlyHttps == 1 ) {
168+
169+ document . getElementById ( 'httpBlock' ) . style . visibility = 'visible' ;
170+
171+
172+ //Prevent DOM manipulation
173+ var MutationObserver = window . MutationObserver || window . WebKitMutationObserver || window . MozMutationObserver ;
174+ var target = document . querySelector ( '#httpBlock' ) ;
175+ var targetChild = document . querySelector ( '#httpBlock' ) . childNodes [ 0 ] ;
176+
177+ var observer = new MutationObserver ( function ( mutations ) {
178+ mutations . forEach ( function ( mutation ) {
179+ location . reload ( ) ;
180+ } ) ;
181+ } ) ;
110182
111- document . getElementById ( 'validateWrapper' ) . style . display = "block" ;
183+ var config = { attributes : true , childList : true , characterData : true , attributeOldValue : true }
112184
185+ observer . observe ( target , config ) ;
186+ observer . observe ( targetChild , config ) ;
187+
188+ } else {
189+ document . getElementById ( 'validateWrapper' ) . style . display = "block" ;
190+ }
113191
114192
115193 //console.log("Not safe");
0 commit comments