PageRenderTime 38ms CodeModel.GetById 13ms RepoModel.GetById 0ms app.codeStats 1ms

/ajax_savecolor_deleteicon.php

https://gitlab.com/pablo.sapoznik/s42transfer
PHP | 381 lines | 288 code | 67 blank | 26 comment | 40 complexity | 480543339f1f429b03896c45db926c78 MD5 | raw file
  1. <?php
  2. @error_reporting(0);
  3. define ('JIRAFEAU_ROOT', dirname (__FILE__) . '/');
  4. require (JIRAFEAU_ROOT . 'lib/config.original.php');
  5. require (JIRAFEAU_ROOT . 'lib/settings.php');
  6. require (JIRAFEAU_ROOT . 'lib/functions.php');
  7. require (JIRAFEAU_ROOT . 'lib/lang.php');
  8. if(isset($_POST['ids']) && $_POST['ids']=='delete_logo'){ //Delete logo from admin side
  9. $cfg['logo'] = "";
  10. jirafeau_export_cfg_custom($cfg);
  11. echo "delete_logo";
  12. }
  13. elseif(isset($_POST['ids']) && $_POST['ids']=='delete_retina'){ //Delete logo retina from admin side
  14. $cfg['logo_resolation'] = "";
  15. jirafeau_export_cfg_custom($cfg);
  16. echo "delete_retina";
  17. }
  18. elseif(isset($_POST['ids']) && $_POST['ids']=='delete_favicon'){ //Delete favicon from admin side
  19. $cfg['favicon'] = "";
  20. jirafeau_export_cfg_custom($cfg);
  21. echo "delete_favicon";
  22. }
  23. elseif(isset($_POST['ids']) && $_POST['ids']=='delete_touchicon'){ //Delete touchicon from admin side
  24. $cfg['touchicon'] = "";
  25. jirafeau_export_cfg_custom($cfg);
  26. echo "delete_touchicon";
  27. }
  28. elseif(isset($_POST['color_action']) && $_POST['color_action']=='Save'){ //Design tab(update main color and background color)
  29. if(!empty($_POST['main_color'])){
  30. $cfg['main_color'] = $_POST['main_color'];
  31. }
  32. if(!empty($_POST['main_color_light'])){
  33. $cfg['main_color_light'] = $_POST['main_color_light'];
  34. }
  35. if(!empty($_POST['bg_gradient_color1'])){
  36. $cfg['bg_gradient_color1'] = $_POST['bg_gradient_color1'];
  37. }
  38. if(!empty($_POST['bg_gradient_color2'])){
  39. $cfg['bg_gradient_color2'] = $_POST['bg_gradient_color2'];
  40. }
  41. jirafeau_export_cfg_custom($cfg);
  42. //echo "savedone";
  43. echo $cfg['web_root'];
  44. }
  45. elseif(isset($_POST['ad_typekit_chk']) && $_POST['ad_typekit_chk'] !=""){ //Enable disable Typekit fontreplacement
  46. $cfg['typekit_fontreplacement'] = $_POST['ad_typekit_chk'];
  47. jirafeau_export_cfg_custom($cfg);
  48. //echo "typekit dd";
  49. echo s42_remove_ending_slash($cfg['web_root']);
  50. }
  51. elseif(isset($_POST['typekit_action']) && $_POST['typekit_action'] !=""){ //TypeKit update
  52. if(!empty($_POST['typekit_code'])){
  53. $typekit_code = $_POST['typekit_code'];
  54. $typekit_code = str_replace("sf_@_#","<script",$typekit_code);
  55. $typekit_code = str_replace("ss_@_#","</script>",$typekit_code);
  56. $typekit_code = str_replace("st_@_#","<script>",$typekit_code);
  57. $typekit_code = str_replace("ss_@_#","</script>",$typekit_code);
  58. /*
  59. var str = $('#typekiteCode').val().replace('<script','sf_@_#');
  60. str = str.replace('</script>','ss_@_#');
  61. str = str.replace('<script>','st_@_#');
  62. str = str.replace('</script>','ss_@_#');
  63. */
  64. $cfg['typekit_code'] = $typekit_code;
  65. }
  66. if(!empty($_POST['typekit_normal'])){
  67. $cfg['typekit_normal'] = $_POST['typekit_normal'];
  68. }
  69. if(!empty($_POST['typekit_bold'])){
  70. $cfg['typekit_bold'] = $_POST['typekit_bold'];
  71. }
  72. if(!empty($_POST['typekit_optional'])){
  73. $cfg['typekit_optional'] = $_POST['typekit_optional'];
  74. }
  75. jirafeau_export_cfg_custom($cfg);
  76. echo "typekit_done";
  77. }
  78. elseif(isset($_POST['ad_shr_chkVal']) && $_POST['ad_shr_chkVal'] !=""){ //Enable disable Sharing Email service
  79. $cfg['sharing_enable'] = $_POST['ad_shr_chkVal'];
  80. jirafeau_export_cfg_custom($cfg);
  81. echo "sharing";
  82. }
  83. elseif(isset($_POST['share_action']) && $_POST['share_action'] !=""){ //Sharing Email service data update
  84. if(!empty($_POST['sender_email'])){
  85. $cfg['sender_email'] = $_POST['sender_email'];
  86. }
  87. if(!empty($_POST['sender_name'])){
  88. $cfg['sender_name'] = $_POST['sender_name'];
  89. }
  90. jirafeau_export_cfg_custom($cfg);
  91. echo "sharing_done";
  92. }
  93. elseif(isset($_POST['setting_action']) && $_POST['setting_action'] !=""){ // Files limit into config files
  94. if(!empty($_POST['file_limit'])){
  95. $cfg['temp1'] = $_POST['file_limit'];
  96. }
  97. jirafeau_export_cfg_custom($cfg);
  98. echo "setting_done";
  99. }
  100. elseif(isset($_POST['ad_http_chkVal']) && $_POST['ad_http_chkVal'] !=""){ // Enable disable https and www prefix
  101. $cfg['temp2'] = $_POST['ad_http_chkVal'];
  102. $cfg['temp3'] = $_POST['ad_domain_chkval'];
  103. if($_POST['ad_http_chkVal'] == 1 && $_POST['ad_domain_chkval'] ==1 ){
  104. //echo both 1
  105. $parsedUrl = parse_url($cfg['web_root']);
  106. parse_str($parsedUrl['query'], $parsedQuery);
  107. if(!empty($parsedUrl['path'])){
  108. $url = 'https://www.'.$_SERVER['HTTP_HOST'].$parsedUrl['path'];
  109. }else{
  110. $url = 'https://www.'.$_SERVER['HTTP_HOST'].'/';
  111. }
  112. $content = '<IfModule mod_rewrite.c>
  113. RewriteEngine on
  114. ErrorDocument 404 '.$cfg['web_root'].'404.php
  115. # Set "protossl" to "s" if we were accessed via https://. This is used later
  116. # if you enable "www." stripping or enforcement, in order to ensure that
  117. # you don\'t bounce between http and https.
  118. #RewriteCond %{HTTPS} on
  119. #RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  120. RewriteCond %{HTTPS} off
  121. RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
  122. RewriteRule ^ - [E=protossl]
  123. RewriteCond %{HTTPS} on
  124. RewriteRule ^ - [E=protossl:s]
  125. # To redirect all users to access the site WITH the \'www.\' prefix,
  126. # (http://example.com/... will be redirected to http://www.example.com/...)
  127. # uncomment the following:
  128. RewriteCond %{HTTP_HOST} .
  129. RewriteCond %{HTTP_HOST} !^www\. [NC]
  130. RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  131. #
  132. # To redirect all users to access the site WITHOUT the \'www.\' prefix,
  133. # (http://www.example.com/... will be redirected to http://example.com/...)
  134. # uncomment the following:
  135. # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  136. # RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
  137. </IfModule>
  138. ';
  139. }
  140. elseif($_POST['ad_http_chkVal'] == 1 && $_POST['ad_domain_chkval'] ==0 ){
  141. //echo "http 1 and domain 0";
  142. $parsedUrl = parse_url($cfg['web_root']);
  143. parse_str($parsedUrl['query'], $parsedQuery);
  144. if(!empty($parsedUrl['path'])){
  145. $url = 'https://'.$_SERVER['HTTP_HOST'].$parsedUrl['path'];
  146. }else{
  147. $url = 'https://'.$_SERVER['HTTP_HOST'].'/';
  148. }
  149. $content = '<IfModule mod_rewrite.c>
  150. RewriteEngine on
  151. ErrorDocument 404 '.$cfg['web_root'].'404.php
  152. # Set "protossl" to "s" if we were accessed via https://. This is used later
  153. # if you enable "www." stripping or enforcement, in order to ensure that
  154. # you don\'t bounce between http and https.
  155. #RewriteCond %{HTTPS} on
  156. #RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  157. RewriteCond %{HTTPS} off
  158. RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
  159. RewriteRule ^ - [E=protossl]
  160. RewriteCond %{HTTPS} on
  161. RewriteRule ^ - [E=protossl:s]
  162. # To redirect all users to access the site WITH the \'www.\' prefix,
  163. # (http://example.com/... will be redirected to http://www.example.com/...)
  164. # uncomment the following:
  165. # RewriteCond %{HTTP_HOST} .
  166. # RewriteCond %{HTTP_HOST} !^www\. [NC]
  167. # RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  168. #
  169. # To redirect all users to access the site WITHOUT the \'www.\' prefix,
  170. # (http://www.example.com/... will be redirected to http://example.com/...)
  171. # uncomment the following:
  172. # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  173. # RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
  174. </IfModule>
  175. ';
  176. }
  177. elseif($_POST['ad_http_chkVal'] == 0 && $_POST['ad_domain_chkval'] ==1 ){
  178. //echo "http 0 and domain 1";
  179. $parsedUrl = parse_url($cfg['web_root']);
  180. parse_str($parsedUrl['query'], $parsedQuery);
  181. $host = str_replace('www.', '',$_SERVER['HTTP_HOST'] );
  182. if(!empty($parsedUrl['path'])){
  183. $url = 'http://www.'.$host.$parsedUrl['path'];
  184. }else{
  185. $url = 'http://www.'.$host.'/';
  186. }
  187. $content = '<IfModule mod_rewrite.c>
  188. RewriteEngine on
  189. ErrorDocument 404 '.$cfg['web_root'].'404.php
  190. # Set "protossl" to "s" if we were accessed via https://. This is used later
  191. # if you enable "www." stripping or enforcement, in order to ensure that
  192. # you don\'t bounce between http and https.
  193. RewriteCond %{HTTPS} on
  194. RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  195. #RewriteCond %{HTTPS} off
  196. #RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
  197. RewriteRule ^ - [E=protossl]
  198. RewriteCond %{HTTPS} on
  199. RewriteRule ^ - [E=protossl:s]
  200. # To redirect all users to access the site WITH the \'www.\' prefix,
  201. # (http://example.com/... will be redirected to http://www.example.com/...)
  202. # uncomment the following:
  203. RewriteCond %{HTTP_HOST} .
  204. RewriteCond %{HTTP_HOST} !^www\. [NC]
  205. RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  206. #
  207. # To redirect all users to access the site WITHOUT the \'www.\' prefix,
  208. # (http://www.example.com/... will be redirected to http://example.com/...)
  209. # uncomment the following:
  210. # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  211. # RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
  212. </IfModule>
  213. ';
  214. }
  215. elseif($_POST['ad_http_chkVal'] == 0 && $_POST['ad_domain_chkval'] ==0 ){
  216. //echo "http 0 and domain 0";
  217. $parsedUrl = parse_url($cfg['web_root']);
  218. parse_str($parsedUrl['query'], $parsedQuery);
  219. if(!empty($parsedUrl['path'])){
  220. $url = 'http://'.$_SERVER['HTTP_HOST'].$parsedUrl['path'];
  221. }else{
  222. $url = 'http://'.$_SERVER['HTTP_HOST'].'/';
  223. }
  224. $url = str_replace('www.', '', $url );
  225. /*$url = $cfg['web_root']; // example http url ##
  226. $url = str_replace('https://', 'http://', $url );
  227. $url = str_replace('https://www.', 'http://', $url );
  228. $url = str_replace('http://www.', 'http://', $url );
  229. */
  230. $content = '<IfModule mod_rewrite.c>
  231. RewriteEngine on
  232. ErrorDocument 404 '.$cfg['web_root'].'404.php
  233. # Set "protossl" to "s" if we were accessed via https://. This is used later
  234. # if you enable "www." stripping or enforcement, in order to ensure that
  235. # you don\'t bounce between http and https.
  236. RewriteCond %{HTTPS} on
  237. RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
  238. #RewriteCond %{HTTPS} off
  239. #RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
  240. RewriteRule ^ - [E=protossl]
  241. RewriteCond %{HTTPS} on
  242. RewriteRule ^ - [E=protossl:s]
  243. # To redirect all users to access the site WITH the \'www.\' prefix,
  244. # (http://example.com/... will be redirected to http://www.example.com/...)
  245. # uncomment the following:
  246. # RewriteCond %{HTTP_HOST} .
  247. # RewriteCond %{HTTP_HOST} !^www\. [NC]
  248. # RewriteRule ^ http%{ENV:protossl}://www.%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
  249. #
  250. # To redirect all users to access the site WITHOUT the \'www.\' prefix,
  251. # (http://www.example.com/... will be redirected to http://example.com/...)
  252. # uncomment the following:
  253. RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
  254. RewriteRule ^ http%{ENV:protossl}://%1%{REQUEST_URI} [L,R=301]
  255. </IfModule>
  256. ';
  257. }else{
  258. $url = $cfg['web_root'];
  259. $content ="";
  260. }
  261. $cfg['web_root'] = $url;
  262. /****Update image url***/
  263. $web_rootUrl = s42_remove_ending_slash($cfg['web_root']);
  264. //logo
  265. $iconPathlogo = (parse_url($cfg['logo'], PHP_URL_PATH));
  266. $cfg['logo'] = $web_rootUrl.$iconPathlogo;
  267. //logo_resolation
  268. $iconPathlogo_resolation = (parse_url($cfg['logo_resolation'], PHP_URL_PATH));
  269. $cfg['logo_resolation'] = $web_rootUrl.$iconPathlogo_resolation;
  270. //favicon
  271. //$iconPathfavicon = (parse_url($cfg['favicon'], PHP_URL_PATH));
  272. //$cfg['favicon'] = $web_rootUrl.$iconPathfavicon;
  273. //touchicon
  274. $iconPathtouchicon = (parse_url($cfg['touchicon'], PHP_URL_PATH));
  275. $cfg['touchicon'] = $web_rootUrl.$iconPathtouchicon;
  276. /****Update image url***/
  277. jirafeau_export_cfg_custom($cfg);
  278. $f = fopen(".htaccess", "r+");
  279. fwrite($f, $content);
  280. fclose($f);
  281. echo $cfg['web_root']; //Return via ajax
  282. }
  283. elseif(isset($_POST['ad_security_chkVal']) && $_POST['ad_security_chkVal'] !=""){ //Security password disable,enable service
  284. $cfg['security_enable'] = $_POST['ad_security_chkVal'];
  285. jirafeau_export_cfg_custom($cfg);
  286. echo "security";
  287. }
  288. elseif(isset($_POST['security_action']) && $_POST['security_action'] !=""){ //Security user password data update
  289. $arr = array();
  290. if(!empty($_POST['sec_user'])){
  291. $cfg['sec_user'] = $_POST['sec_user'];
  292. $arr['sec_user'] = $_POST['sec_user']; //return
  293. }
  294. if(!empty($_POST['sec_pwd'])){
  295. $cfg['sec_pwd'] = md5($_POST['sec_pwd']);
  296. $arr['sec_pwd'] = $_POST['sec_pwd']; //return
  297. }
  298. jirafeau_export_cfg_custom($cfg);
  299. echo json_encode($arr);
  300. }
  301. ?>