Changeset 1574150
- Timestamp:
- 01/13/2017 04:56:35 PM (9 years ago)
- Location:
- db-error-customizer
- Files:
-
- 16 edited
-
assets/icon-128x128.png (modified) (previous)
-
assets/icon-256x256.png (modified) (previous)
-
assets/screenshot-1.png (modified) (previous)
-
trunk/assets/js/db-error-customizer.js (modified) (7 diffs)
-
trunk/db-error-customizer.php (modified) (12 diffs)
-
trunk/readme.txt (modified) (6 diffs)
-
trunk/templates/basic.jpg (modified) (previous)
-
trunk/templates/basic.txt (modified) (1 diff)
-
trunk/templates/mystery.jpg (modified) (previous)
-
trunk/templates/mystery.txt (modified) (1 diff)
-
trunk/templates/pro.jpg (modified) (previous)
-
trunk/templates/pro.txt (modified) (1 diff)
-
trunk/templates/snow.jpg (modified) (previous)
-
trunk/templates/snow.txt (modified) (1 diff)
-
trunk/templates/video.jpg (modified) (previous)
-
trunk/templates/video.txt (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
db-error-customizer/trunk/assets/js/db-error-customizer.js
r1371180 r1574150 1 1 (function( $ ) { 2 2 3 3 $(function() { 4 4 /* 5 5 ** Add Color Picker to all inputs that have 'color-field' class 6 6 */ 7 $('.color-field').wpColorPicker( );7 $('.color-field').wpColorPicker({defaultColor: false}); 8 8 9 9 /* … … 11 11 */ 12 12 coreSelectSwitch(false); 13 coreEmailSwitch();14 15 /*16 ** BG Img upload17 */18 var file_frame_bg;19 var file_frame_logo;20 var wp_media_post_id = wp.media.model.settings.post.id; // Store the old id21 jQuery('#upload_bg_img_button').on('click', function( event ){22 event.preventDefault();23 var set_to_post_id = $(this).next().val();24 // If the media frame already exists, reopen it.25 if ( file_frame_bg ) {26 // Set the post ID to what we want27 file_frame_bg.uploader.uploader.param( 'post_id', set_to_post_id );28 // Open frame29 file_frame_bg.open();30 return;31 } else {32 // Set the wp.media post id so the uploader grabs the ID we want when initialised33 wp.media.model.settings.post.id = set_to_post_id;34 }35 // Create the media frame.36 file_frame_bg = wp.media.frames.file_frame = wp.media({37 title: 'Select a image to upload',38 button: {39 text: 'Use this image',40 },41 multiple: false // Set to true to allow multiple files to be selected42 });43 // When an image is selected, run a callback.44 file_frame_bg.on( 'select', function() {45 // We set multiple to false so only get one image from the uploader46 attachment = file_frame_bg.state().get('selection').first().toJSON();47 // Do something with attachment.id and/or attachment.url here48 $( '#template_bg_img_url' ).val( attachment.url );49 $( '#template_bg_img_attachment_id' ).val( attachment.id );50 // Restore the main post ID51 wp.media.model.settings.post.id = wp_media_post_id;52 });53 // Finally, open the modal54 file_frame_bg.open();55 });56 57 /*58 ** Logo upload59 */60 jQuery('#upload_logo_button').on('click', function( event ){61 event.preventDefault();62 var set_to_post_id = $(this).next().val();63 // If the media frame already exists, reopen it.64 if ( file_frame_logo ) {65 // Set the post ID to what we want66 file_frame_logo.uploader.uploader.param( 'post_id', set_to_post_id );67 // Open frame68 file_frame_logo.open();69 return;70 } else {71 // Set the wp.media post id so the uploader grabs the ID we want when initialised72 wp.media.model.settings.post.id = set_to_post_id;73 }74 // Create the media frame.75 file_frame_logo = wp.media.frames.file_frame = wp.media({76 title: 'Select a image to upload',77 button: {78 text: 'Use this image',79 },80 multiple: false // Set to true to allow multiple files to be selected81 });82 // When an image is selected, run a callback.83 file_frame_logo.on( 'select', function() {84 // We set multiple to false so only get one image from the uploader85 attachment = file_frame_logo.state().get('selection').first().toJSON();86 // Do something with attachment.id and/or attachment.url here87 $( '#template_logo_url' ).val( attachment.url );88 $( '#template_logo_attachment_id' ).val( attachment.id );89 // Restore the main post ID90 wp.media.model.settings.post.id = wp_media_post_id;91 });92 // Finally, open the modal93 file_frame_logo.open();94 });95 96 // Restore the main ID when the add media button is pressed97 jQuery( 'a.add_media' ).on( 'click', function() {98 wp.media.model.settings.post.id = wp_media_post_id;99 });100 13 101 14 /* 102 15 ** Core function handle when template change 103 16 */ 104 function coreSelectSwitch( is_switch) {17 function coreSelectSwitch(isSwitch) { 105 18 d = new Date(); 106 19 var selected_template = $('#template_select').val(); 107 $("#template-demo").attr("src", $("#plugin_url"). val()+"templates/"+selected_template+".jpg?"+d.getTime());20 $("#template-demo").attr("src", $("#plugin_url").text()+"templates/"+selected_template+".jpg?"+d.getTime()); 108 21 109 22 // Switcher to decide which option to enable … … 114 27 115 28 // SHOW Bg img 116 $("#upload_bg_img_button").removeAttr('disabled'); 117 $("#template_bg_img_attachment_id").removeAttr('disabled'); 118 $("#template_bg_img_url").removeAttr('disabled'); 119 $("#template_bg_img_attachment_id").attr('type','hidden'); 120 $("#template_bg_img_url").attr('readonly',true); 121 $("#template_bg_img_url").closest("tr").css("display", "table-row"); 29 $(".upload-bg-image-group").css("display", "table-row"); 122 30 123 31 // SHOW Logo 124 $("#upload_logo_button").removeAttr('disabled'); 125 $("#template_logo_attachment_id").removeAttr('disabled'); 126 $("#template_logo_url").removeAttr('disabled'); 127 $("#template_logo_attachment_id").attr('type','hidden'); 128 $("#template_logo_url").attr('readonly',true); 32 $("#logo_enabled").closest("tr").css("display", "table-row"); 129 33 $("#template_logo_url").closest("tr").css("display", "table-row"); 130 34 131 35 // HIDE Youtube ID 132 $("#template_youtube_id").attr('disabled','disabled');133 36 $("#template_youtube_id").closest("tr").css("display", "none"); 134 37 38 // Disable the rest of items 39 $("input[name=template_font_color]").attr('disabled','disabled'); 40 $("input[name=template_title]").attr('disabled','disabled'); 41 $("input[name=template_title_size]").attr('disabled','disabled'); 42 $("input[name=template_sub_title]").attr('disabled','disabled'); 43 $("input[name=template_sub_title_size]").attr('disabled','disabled'); 44 135 45 // Set default value 136 if (is_switch) { 137 $("#template_bg_img_url").val($("#plugin_url").val()+"assets/images/template-bg-1.jpg"); 46 $("#template-desc").text("Static background image with your company logo"); 47 if (isSwitch) { 48 $("#template_bg_img_url").val($("#plugin_url").text()+"assets/images/template-bg-1.jpg"); 138 49 $("#template_font_color").val("#ffffff"); 139 $("#template-desc").text("Static background image with your company logo");140 50 } 141 142 // Handling to show warning message for free version 143 $("#template-free-template").css("display", "table-row"); 144 $("#template-free-template p").html("Pro template is not included in free version. Please get the <a href='http://codecanyon.net/item/db-error-customizer-manage-database-error-professionally/14715024'>premium</a> version."); 51 $("input[name=submit_preview], input[name=submit_save]").attr('disabled','disabled'); 145 52 } else if (selected_template == "video") { 146 53 // HIDE Bg color … … 149 56 150 57 // HIDE Bg img 151 $("#upload_bg_img_button").attr('disabled','disabled'); 152 $("#template_bg_img_attachment_id").attr('disabled','disabled'); 153 $("#template_bg_img_url").attr('disabled','disabled'); 154 $("#template_bg_img_url").closest("tr").css("display", "none"); 58 $(".upload-bg-image-group").css("display", "none"); 155 59 156 60 // SHOW Logo 157 $("#upload_logo_button").removeAttr('disabled'); 158 $("#template_logo_attachment_id").removeAttr('disabled'); 159 $("#template_logo_url").removeAttr('disabled'); 160 $("#template_logo_attachment_id").attr('type','hidden'); 161 $("#template_logo_url").attr('readonly',true); 61 $("#logo_enabled").closest("tr").css("display", "table-row"); 162 62 $("#template_logo_url").closest("tr").css("display", "table-row"); 163 63 164 64 // SHOW Youtube ID 165 $("#template_youtube_id").removeAttr('disabled');166 65 $("#template_youtube_id").closest("tr").css("display", "table-row"); 167 66 67 // Disable the rest of items 68 $("input[name=template_font_color]").attr('disabled','disabled'); 69 $("input[name=template_title]").attr('disabled','disabled'); 70 $("input[name=template_title_size]").attr('disabled','disabled'); 71 $("input[name=template_sub_title]").attr('disabled','disabled'); 72 $("input[name=template_sub_title_size]").attr('disabled','disabled'); 73 168 74 // Set default value 169 if (is_switch) { 75 $("#template-desc").text("Full page Youtube video background with your company logo"); 76 if (isSwitch) { 170 77 $("#template_font_color").val("#ffffff"); 171 $("#template-desc").text("Full page Youtube video background with your company logo");172 78 } 173 174 // Handling to show warning message for free version 175 $("#template-free-template").css("display", "table-row"); 176 $("#template-free-template p").html("Video template is not included in free version. Please get the <a href='http://codecanyon.net/item/db-error-customizer-manage-database-error-professionally/14715024'>premium</a> version."); 177 } else if (selected_template == "mystery") { 79 $("input[name=submit_preview], input[name=submit_save]").attr('disabled','disabled'); 80 } else if (selected_template == "mystery" 81 || selected_template == "snow" 82 || selected_template == "bubble") { 178 83 // HIDE Bg color 179 84 $("#template_bg_color").attr('disabled','disabled'); … … 181 86 182 87 // SHOW Bg img 183 $("#upload_bg_img_button").removeAttr('disabled'); 184 $("#template_bg_img_attachment_id").removeAttr('disabled'); 185 $("#template_bg_img_url").removeAttr('disabled'); 186 $("#template_bg_img_attachment_id").attr('type','hidden'); 187 $("#template_bg_img_url").attr('readonly',true); 188 $("#template_bg_img_url").closest("tr").css("display", "table-row"); 88 $(".upload-bg-image-group").css("display", "table-row"); 189 89 190 90 // SHOW Logo 191 $("#upload_logo_button").removeAttr('disabled'); 192 $("#template_logo_attachment_id").removeAttr('disabled'); 193 $("#template_logo_url").removeAttr('disabled'); 194 $("#template_logo_attachment_id").attr('type','hidden'); 195 $("#template_logo_url").attr('readonly',true); 91 $("#logo_enabled").closest("tr").css("display", "table-row"); 196 92 $("#template_logo_url").closest("tr").css("display", "table-row"); 197 93 198 94 // HIDE Youtube ID 199 $("#template_youtube_id").attr('disabled','disabled');200 95 $("#template_youtube_id").closest("tr").css("display", "none"); 201 96 202 // Set default value 203 if (is_switch) { 204 $("#template_bg_img_url").val($("#plugin_url").val()+"assets/images/template-bg-2.jpg"); 205 $("#template_font_color").val("#ffffff"); 206 $("#template-desc").text("Interactive moving star with your company logo"); 207 } 208 209 // Handling to show warning message for free version 210 $("#template-free-template").css("display", "table-row"); 211 $("#template-free-template p").html("Mystery template is not included in free version. Please get the <a href='http://codecanyon.net/item/db-error-customizer-manage-database-error-professionally/14715024'>premium</a> version."); 212 } else if (selected_template == "snow") { 213 // HIDE Bg color 214 $("#template_bg_color").attr('disabled','disabled'); 215 $("#template_bg_color").closest("tr").css("display", "none"); 216 217 // SHOW Bg img 218 $("#upload_bg_img_button").removeAttr('disabled'); 219 $("#template_bg_img_attachment_id").removeAttr('disabled'); 220 $("#template_bg_img_url").removeAttr('disabled'); 221 $("#template_bg_img_attachment_id").attr('type','hidden'); 222 $("#template_bg_img_url").attr('readonly',true); 223 $("#template_bg_img_url").closest("tr").css("display", "table-row"); 224 225 // SHOW Logo 226 $("#upload_logo_button").removeAttr('disabled'); 227 $("#template_logo_attachment_id").removeAttr('disabled'); 228 $("#template_logo_url").removeAttr('disabled'); 229 $("#template_logo_attachment_id").attr('type','hidden'); 230 $("#template_logo_url").attr('readonly',true); 231 $("#template_logo_url").closest("tr").css("display", "table-row"); 232 233 // HIDE Youtube ID 234 $("#template_youtube_id").attr('disabled','disabled'); 235 $("#template_youtube_id").closest("tr").css("display", "none"); 97 // Disable the rest of items 98 $("input[name=template_font_color]").attr('disabled','disabled'); 99 $("input[name=template_title]").attr('disabled','disabled'); 100 $("input[name=template_title_size]").attr('disabled','disabled'); 101 $("input[name=template_sub_title]").attr('disabled','disabled'); 102 $("input[name=template_sub_title_size]").attr('disabled','disabled'); 236 103 237 104 // Set default value 238 if (is_switch) { 239 $("#template_bg_img_url").val($("#plugin_url").val()+"assets/images/template-bg-3.jpg"); 240 $("#template_font_color").val("#ffffff"); 105 if (selected_template == "mystery") { 106 $("#template-desc").text("Interactive moving star with your company logo"); 107 if (isSwitch) { 108 $("#template_bg_img_url").val($("#plugin_url").text()+"assets/images/template-bg-2.jpg"); 109 $("#template_font_color").val("#ffffff"); 110 } 111 } else if (selected_template == "snow") { 241 112 $("#template-desc").text("Interactive moving snow effect with your company logo"); 113 if (isSwitch) { 114 $("#template_bg_img_url").val($("#plugin_url").text()+"assets/images/template-bg-3.jpg"); 115 $("#template_font_color").val("#ffffff"); 116 } 117 } else if (selected_template == "bubble") { 118 $("#template-desc").text("Interactive moving bubble effect with your company logo"); 119 if (isSwitch) { 120 $("#template_bg_img_url").val($("#plugin_url").text()+"assets/images/template-bg-4.jpg"); 121 $("#template_font_color").val("#ffffff"); 122 } 242 123 } 243 244 // Handling to show warning message for free version 245 $("#template-free-template").css("display", "table-row"); 246 $("#template-free-template p").html("Snow template is not included in free version. Please get the <a href='http://codecanyon.net/item/db-error-customizer-manage-database-error-professionally/14715024'>premium</a> version."); 124 $("input[name=submit_preview], input[name=submit_save]").attr('disabled','disabled'); 247 125 } else { 248 126 // SHOW Bg color … … 251 129 252 130 // HIDE Bg img 253 $("#upload_bg_img_button").attr('disabled','disabled'); 254 $("#template_bg_img_attachment_id").attr('disabled','disabled'); 255 $("#template_bg_img_url").attr('disabled','disabled'); 256 $("#template_bg_img_url").closest("tr").css("display", "none"); 131 $(".upload-bg-image-group").css("display", "none"); 257 132 258 133 // HIDE Logo 259 $("#upload_logo_button").attr('disabled','disabled'); 260 $("#template_logo_attachment_id").attr('disabled','disabled'); 261 $("#template_logo_url").attr('disabled','disabled'); 134 $("#logo_enabled").closest("tr").css("display", "none"); 262 135 $("#template_logo_url").closest("tr").css("display", "none"); 263 136 264 137 // HIDE Youtube ID 265 $("#template_youtube_id").attr('disabled','disabled');266 138 $("#template_youtube_id").closest("tr").css("display", "none"); 267 139 140 // Disable the rest of items 141 $("input[name=template_font_color]").removeAttr('disabled'); 142 $("input[name=template_title]").removeAttr('disabled'); 143 $("input[name=template_title_size]").removeAttr('disabled'); 144 $("input[name=template_sub_title]").removeAttr('disabled'); 145 $("input[name=template_sub_title_size]").removeAttr('disabled'); 146 268 147 // Set default value 269 if (is_switch) { 148 $("#template-desc").text("Basic theme with background color"); 149 if (isSwitch) { 270 150 $("#template_bg_color").val("#15b5f7"); 271 151 $("#template_font_color").val("#ffffff"); 272 $("#template-desc").text("Basic theme with background color");273 152 } 274 275 // Handling to show warning message for free version 276 $("#template-free-template").css("display", "none"); 277 } 278 } 279 280 /* 281 ** Core function handle when email alert toggle 282 */ 283 function coreEmailSwitch() { 284 if ($("#email_enabled").is(":checked")) { 285 // Handling to show warning message for free version 286 $("#template-free-email").css("display", "table-row"); 287 $("#template-free-email p").html("Email alert is not included in free version. Please get the <a href='http://codecanyon.net/item/db-error-customizer-manage-database-error-professionally/14715024'>premium</a> version."); 288 $('#email_enabled').attr('checked', false); 289 $('#email_enabled').prop('checked', false); 290 } else { 291 $("#email_freq").attr('disabled','disabled'); 292 $("#email_target").attr('disabled','disabled'); 293 $("#email_subject").attr('disabled','disabled'); 294 $("#email_msg").attr('disabled','disabled'); 153 $("input[name=submit_preview], input[name=submit_save]").removeAttr('disabled'); 295 154 } 296 155 } … … 302 161 coreSelectSwitch(true); 303 162 }); 304 305 /*306 ** Handle when email state change307 */308 jQuery( '#email_enabled' ).on( 'change', function() {309 coreEmailSwitch();310 });311 163 }); 312 164 })( jQuery ); -
db-error-customizer/trunk/db-error-customizer.php
r1464093 r1574150 5 5 Plugin URI: https://wordpress.org/plugins/db-error-customizer/ 6 6 Description: Allow you to customise a beautiful and useful database error page 7 Version: 1.37 Version: 2.0 8 8 Author: Centil Technology 9 Author URI: http:// centil.co9 Author URI: http://dec.centil.co 10 10 License: GPL2 11 11 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 20 20 } 21 21 22 // Construct supported email freq 23 $email_all_freqs = array("15 Minutes", "1 Hour", "3 Hours", "6 Hours", "12 Hours", "1 Day"); 22 // Inlcude common class 23 include_once 'source/setting.php'; 24 include_once 'source/builder.php'; 24 25 25 26 /* … … 27 28 */ 28 29 function dec_plugin_admin_notices() { 29 if (!get_option('plugin_activate_notice_shown') && !is_plugin_active( plugin_dir_path(__FILE__).'db-error-customizer.php')) {30 if (!get_option('plugin_activate_notice_shown') && !is_plugin_active(Setting::getRootDir().'db-error-customizer.php')) { 30 31 echo "<div class='update-nag'><p>DB Error Customizer is activated but not enabled. Please goto <a href='".admin_url('options-general.php?page=db-error-customizer')."'>DB Error Customizer setting page</a> to proceed setup.</p></div>"; 31 32 update_option('plugin_activate_notice_shown', 'true'); … … 43 44 44 45 // Delete registered settings 45 unregister_setting( 'db-error-customizer-settings-group', 'template_select' ); 46 unregister_setting( 'db-error-customizer-settings-group', 'template_bg_color' ); 47 unregister_setting( 'db-error-customizer-settings-group', 'template_bg_img_url' ); 48 unregister_setting( 'db-error-customizer-settings-group', 'template_logo_url' ); 49 unregister_setting( 'db-error-customizer-settings-group', 'template_youtube_id' ); 50 unregister_setting( 'db-error-customizer-settings-group', 'template_font_color' ); 51 unregister_setting( 'db-error-customizer-settings-group', 'template_title' ); 52 unregister_setting( 'db-error-customizer-settings-group', 'template_sub_title' ); 53 unregister_setting( 'db-error-customizer-settings-group', 'email_enabled' ); 54 unregister_setting( 'db-error-customizer-settings-group', 'email_freq' ); 55 unregister_setting( 'db-error-customizer-settings-group', 'email_target' ); 56 unregister_setting( 'db-error-customizer-settings-group', 'email_subject' ); 57 unregister_setting( 'db-error-customizer-settings-group', 'email_msg' ); 46 foreach(Setting::getSettings() as $setting => $configs) { 47 if ($configs['visibility'] == 'public') { 48 delete_option( $setting ); 49 } 50 } 58 51 59 52 // Restore db-error.php to default state … … 79 72 */ 80 73 function dec_test_server( $mode ) { 74 $msgErrors = array(); 81 75 82 76 // Different condition for different scenario 83 $is_need_email = false;84 77 $is_need_preview = false; 85 78 $is_need_save = false; 86 79 $is_need_template = false; 87 88 // Different result89 $is_ready_config = false;90 $is_ready_preview = false;91 $is_ready_save = false;92 $is_ready_template = false;93 80 94 81 // Run different tests based on different test request … … 99 86 $is_need_save = true; 100 87 $is_need_template = true; 101 102 // For Save option, double check if user requested email feature103 if (isset($_POST['email_enabled'])104 && $_POST['email_enabled']!==''105 && isset($_POST['email_target'])106 && isset($_POST['email_freq'])107 && isset($_POST['email_subject'])108 && isset($_POST['email_msg'])) {109 $is_need_email = true;110 }111 88 } else { 112 89 // Default test mode to cover all (Except template) 113 $is_need_email = true;114 90 $is_need_preview = true; 115 91 $is_need_save = true; 116 92 } 117 93 118 $msg_config = ""; 119 $msg_preview = ""; 120 $msg_save = ""; 121 $msg_template = ""; 122 123 // Run test for email config file 124 if ($is_need_email) { 125 if (is_writable(plugin_dir_path(__FILE__)."config.txt")) { 126 $is_ready_config = true; 127 } else { 128 $msg_config = "Not able to write to ".plugin_dir_path(__FILE__)."config.txt. ". 94 // Run test for preview file 95 if ($is_need_preview 96 && !is_writable(Setting::getRootDir()."preview.html")) { 97 $msgErrors[] = "Not able to write to ".Setting::getRootDir()."preview.html. ". 129 98 "Please temporarily enable <a href='https://codex.wordpress.org/Changing_File_Permissions' target='_blank'>777 write permission</a> to this file to proceed."; 130 }131 }132 133 // Run test for preview file134 if ($is_need_preview) {135 if (is_writable(plugin_dir_path(__FILE__)."preview.html")) {136 $is_ready_preview = true;137 } else {138 $msg_preview = "Not able to write to ".plugin_dir_path(__FILE__)."preview.html. ".139 "Please temporarily enable <a href='https://codex.wordpress.org/Changing_File_Permissions' target='_blank'>777 write permission</a> to this file to proceed.";140 }141 99 } 142 100 143 101 // Run test for db error file 144 if ($is_need_save) { 145 if (is_writable(WP_CONTENT_DIR . "/db-error.php")) { 146 $is_ready_save = true; 147 } else { 148 $msg_save = "Not able to write to ".WP_CONTENT_DIR . "/db-error.php. ". 102 if ($is_need_save 103 && !is_writable(WP_CONTENT_DIR . "/db-error.php")) { 104 $msgErrors[] = "Not able to write to ".WP_CONTENT_DIR . "/db-error.php. ". 149 105 "Please create an empty db-error.php file and temporarily enable <a href='https://codex.wordpress.org/Changing_File_Permissions' target='_blank'>777 write permission</a> to this file to proceed."; 150 }151 106 } 152 107 … … 155 110 // Sanitize and validate all inputs 156 111 $template_select = sanitize_text_field($_POST['template_select']); 157 if ($template_select != 'basic' 158 && $template_select != 'mystery' 159 && $template_select != 'pro' 160 && $template_select != 'snow' 161 && $template_select != 'video') { 112 if (!in_array($template_select, Setting::getTemplates())) { 162 113 $template_select = 'basic'; 163 114 } 164 115 165 if (is_readable(plugin_dir_path(__FILE__)."templates/".$template_select.".txt")) { 166 $is_ready_template = true; 167 } else { 168 $msg_template = "Not able to read from ".plugin_dir_path(__FILE__)."templates/".$template_select.".txt. ". 169 "Please enable <a href='https://codex.wordpress.org/Changing_File_Permissions' target='_blank'>644 read permission</a> to this file to proceed."; 116 if (!is_readable(Setting::getRootDir()."templates/".$template_select.".txt")) { 117 $msgErrors[] = "Not able to read from ".Setting::getRootDir()."templates/".$template_select.".txt. ". 118 "Please enable <a href='https://codex.wordpress.org/Changing_File_Permissions' target='_blank'>644 read permission</a> to this file to proceed."; 170 119 } 171 120 } … … 174 123 $status = "pass"; 175 124 $msg = ""; 176 if ( $msg_config!="" || $msg_preview!="" || $msg_save!="" || $msg_template!="") {125 if (count($msgErrors) > 0) { 177 126 $status = "fail"; 178 179 127 $msg = "<ul>"; 180 if ($msg_config!="") { 181 $msg .= "<li>".$msg_config."</li>"; 182 } 183 184 if ($msg_preview!="") { 185 $msg .= "<li>".$msg_preview."</li>"; 186 } 187 188 if ($msg_save!="") { 189 $msg .= "<li>".$msg_save."</li>"; 190 } 191 192 if ($msg_template!="") { 193 $msg .= "<li>".$msg_template."</li>"; 128 foreach ($msgErrors as $msgError) { 129 $msg .= "<li>".$msgError."</li>"; 194 130 } 195 131 $msg .= "</ul>"; … … 224 160 $info = ""; 225 161 $warning = ""; 226 global $email_all_freqs;227 162 228 163 // Sanitize and validate all inputs 229 164 $input_array = array(); 230 $template_select = null; 231 if (isset($_POST['template_select'])) { 232 $template_select = sanitize_text_field($_POST['template_select']); 233 if ($template_select != 'basic' 234 && $template_select != 'mystery' 235 && $template_select != 'pro' 236 && $template_select != 'snow' 237 && $template_select != 'video') { 238 $template_select = 'basic'; 239 } 240 $input_array['template_select'] = $template_select; 241 } 242 $template_bg_color = null; 243 if (isset($_POST['template_bg_color'])) { 244 $template_bg_color = sanitize_text_field($_POST['template_bg_color']); 245 if (!preg_match("/#([a-fA-F0-9]{3}){1,2}\b/", $template_bg_color)) { 246 $template_bg_color = '#15b5f7'; 247 } 248 $input_array['template_bg_color'] = $template_bg_color; 249 } 250 $template_bg_img_attachment_id = null; 251 if (isset($_POST['template_bg_img_attachment_id'])) { 252 $template_bg_img_attachment_id = intval($_POST['template_bg_img_attachment_id']); 253 if (!$template_bg_img_attachment_id) { 254 $template_bg_img_attachment_id = ''; 255 } 256 $input_array['template_bg_img_attachment_id'] = $template_bg_img_attachment_id; 257 } 258 $template_bg_img_url = null; 259 if (isset($_POST['template_bg_img_url'])) { 260 $template_bg_img_url = esc_url_raw($_POST['template_bg_img_url']); 261 if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $template_bg_img_url)) { 262 $template_bg_img_url = plugins_url( 'assets/images/template-bg-1.jpg', __FILE__ ); 263 } 264 $input_array['template_bg_img_url'] = $template_bg_img_url; 265 } 266 $template_logo_attachment_id = null; 267 if (isset($_POST['template_logo_attachment_id'])) { 268 $template_logo_attachment_id = intval($_POST['template_logo_attachment_id']); 269 if (!$template_logo_attachment_id) { 270 $template_logo_attachment_id = ''; 271 } 272 $input_array['template_logo_attachment_id'] = $template_logo_attachment_id; 273 } 274 $template_logo_url = null; 275 if (isset($_POST['template_logo_url'])) { 276 $template_logo_url = esc_url_raw($_POST['template_logo_url']); 277 if (!preg_match("/\b(?:(?:https?|ftp):\/\/|www\.)[-a-z0-9+&@#\/%?=~_|!:,.;]*[-a-z0-9+&@#\/%=~_|]/i", $template_logo_url)) { 278 $template_logo_url = plugins_url( 'assets/images/template-logo-1.png', __FILE__ ); 279 } 280 $input_array['template_logo_url'] = $template_logo_url; 281 } 282 $template_youtube_id = null; 283 if (isset($_POST['template_youtube_id'])) { 284 $template_youtube_id = sanitize_text_field($_POST['template_youtube_id']); 285 $input_array['template_youtube_id'] = $template_youtube_id; 286 } 287 $template_font_color = null; 288 if (isset($_POST['template_font_color'])) { 289 $template_font_color = sanitize_text_field($_POST['template_font_color']); 290 if (!preg_match("/#([a-fA-F0-9]{3}){1,2}\b/", $template_font_color)) { 291 $template_font_color = '#15b5f7'; 292 } 293 $input_array['template_font_color'] = $template_font_color; 294 } 295 $template_title = null; 296 if (isset($_POST['template_title'])) { 297 $template_title = sanitize_text_field($_POST['template_title']); 298 $input_array['template_title'] = $template_title; 299 } 300 $template_sub_title = null; 301 if (isset($_POST['template_sub_title'])) { 302 $template_sub_title = sanitize_text_field($_POST['template_sub_title']); 303 $input_array['template_sub_title'] = $template_sub_title; 304 } 305 $email_enabled = null; 306 if (isset($_POST['email_enabled'])) { 307 $email_enabled = 'checked'; 308 $input_array['email_enabled'] = $email_enabled; 309 } 310 $email_freq = null; 311 if (isset($_POST['email_freq'])) { 312 $email_freq = sanitize_text_field($_POST['email_freq']); 313 if (!in_array($email_freq, $email_all_freqs)) { 314 $email_freq = "1 Hour"; 315 } 316 $input_array['email_freq'] = $email_freq; 317 } 318 $email_target = null; 319 if (isset($_POST['email_target'])) { 320 $email_target = sanitize_email($_POST['email_target']); 321 if (!is_email($email_target)) { 322 $email_target = get_option('admin_email', ''); 323 } 324 $input_array['email_target'] = $email_target; 325 } 326 $email_subject = null; 327 if (isset($_POST['email_subject'])) { 328 $email_subject = sanitize_text_field($_POST['email_subject']); 329 $input_array['email_subject'] = $email_subject; 330 } 331 $email_msg = null; 332 if (isset($_POST['email_msg'])) { 333 $email_msg = sanitize_text_field($_POST['email_msg']); 334 $input_array['email_msg'] = $email_msg; 165 166 foreach (Setting::getSettings() as $setting => $configs) { 167 $input = null; 168 if (isset($_POST[$setting])) { 169 // Sanitize input 170 switch($configs['type']) { 171 case 'text': 172 $input = sanitize_text_field($_POST[$setting]); 173 break; 174 case 'integer': 175 $input = intval($_POST[$setting]); 176 break; 177 case 'url': 178 $input = esc_url_raw($_POST[$setting]); 179 break; 180 case 'checkbox': 181 $input = 'checked'; 182 break; 183 case 'email': 184 $input = sanitize_email($_POST[$setting]); 185 break; 186 default: 187 die("INTERNAL ERROR: TYPE => ".$configs['type']); 188 } 189 190 // Validate input 191 switch($configs['validate']) { 192 case 'in_templates': 193 if (!in_array($input, Setting::getTemplates())) { 194 $input = $configs['default']; 195 } 196 break; 197 case 'in_email_freqs': 198 if (!in_array($input, Setting::getEmailFreqs())) { 199 $input = $configs['default']; 200 } 201 break; 202 case 'preg_match': 203 if (!preg_match($configs['match'], $input)) { 204 if ($configs['type'] == 'url') { 205 $input = plugins_url( $configs['default'], __FILE__ ); 206 } else { 207 $input = $configs['default']; 208 } 209 } 210 break; 211 case 'is_email': 212 if (!is_email($input)) { 213 $input = get_option($configs['default'], ''); 214 } 215 break; 216 case 'empty': 217 if (!input) { 218 $input = $configs['default']; 219 } 220 break; 221 default: 222 die("INTERNAL ERROR: VALIDATE => ".$configs['validate']); 223 } 224 225 $input_array[$setting] = $input; 226 227 if (isset($_POST['submit_save']) 228 && $configs['visibility']=='public') { 229 update_option($setting, $input); 230 } 231 } else if ($_POST && $configs['type'] == 'checkbox') { 232 $input_array[$setting] = ''; 233 234 if (isset($_POST['submit_save']) 235 && $configs['visibility']=='public') { 236 update_option($setting, $input); 237 } 238 } 335 239 } 336 240 … … 347 251 check_admin_referer( 'submit_preview_save_'.get_current_user_id() ); 348 252 349 // Save all options350 if (isset($template_select)) {351 update_option('template_select', $template_select);352 }353 if (isset($template_bg_color)) {354 update_option('template_bg_color', $template_bg_color);355 }356 if (isset($template_bg_img_url)) {357 update_option('template_bg_img_url', $template_bg_img_url);358 }359 if (isset($template_logo_url)) {360 update_option('template_logo_url', $template_logo_url);361 }362 if (isset($template_youtube_id)) {363 update_option('template_youtube_id', $template_youtube_id);364 }365 if (isset($template_font_color)) {366 update_option('template_font_color', $template_font_color);367 }368 if (isset($template_title)) {369 update_option('template_title', $template_title);370 }371 if (isset($template_sub_title)) {372 update_option('template_sub_title', $template_sub_title);373 }374 if (isset($email_enabled)) {375 update_option('email_enabled', $email_enabled);376 } else {377 update_option('email_enabled', '');378 }379 if (isset($email_freq)) {380 update_option('email_freq', $email_freq);381 }382 if (isset($email_target)) {383 update_option('email_target', $email_target);384 }385 if (isset($email_subject)) {386 update_option('email_subject', $email_subject);387 }388 if (isset($email_msg)) {389 update_option('email_msg', $email_msg);390 }391 392 253 // Run testing for save 393 254 $result = dec_test_server( "save" ); 394 255 if ($result['status'] == "pass") { 395 256 // Proceed to write to db-error.php 396 $result = dec_template_generator(false, $input_array);257 $result = Builder::dec_template_generator(false, $input_array); 397 258 } 398 259 } else if (isset($_POST['submit_preview'])) { … … 404 265 if ($result['status'] == "pass") { 405 266 // Proceed to preview 406 $result = dec_template_generator(true, $input_array);267 $result = Builder::dec_template_generator(true, $input_array); 407 268 } 408 269 } … … 415 276 416 277 // Load supported template 417 $templates = glob(plugin_dir_path(__FILE__)."templates/*.txt"); 418 419 include 'admin-menu.php'; 420 } 421 422 /* 423 * Templating - Header 424 */ 425 function dec_template_header() { 426 $header = "<?php\n"; 427 $header .= "// DB Error Customizer - By Centil.co\n"; 428 $header .= "\$protocol = \$_SERVER['SERVER_PROTOCOL'];\n"; 429 $header .= "if ( 'HTTP/1.1' != \$protocol && 'HTTP/1.0' != \$protocol ) \$protocol = 'HTTP/1.0';\n"; 430 $header .= "header( \"\$protocol 503 Service Unavailable\", true, 503 );\n"; 431 $header .= "header( 'Content-Type: text/html; charset=utf-8' );\n"; 432 $header .= "header( 'Retry-After: 600' );\n\n"; 433 $header .= "if ( !function_exists( 'add_action' ) ) {\n"; 434 $header .= "\techo 'Hi there! I\'m just a plugin, not much I can do when called directly.';\n"; 435 $header .= "\texit;\n"; 436 $header .= "}\n"; 437 $header .= "?>\n"; 438 439 return $header; 440 } 441 442 /* 443 * Templating Generator 444 */ 445 function dec_template_generator($is_preview = false, $fields) { 446 447 // Special handling for free version to avoid processing other template 448 if ($fields['template_select'] != "basic") { 449 return array( 450 "status"=>"fail", 451 "msg"=>ucwords($fields['template_select'])." template is not supported in free version. Please get the <a href='http://codecanyon.net/item/db-error-customizer-manage-database-error-professionally/14715024'>Premium version</a> to proceed." 452 ); 453 } 454 455 // Special handling when it is in not in preview mode. Where email alert may send 456 $header = ""; 457 if (! $is_preview) { 458 $header = dec_template_header(); 459 } 460 461 $fh = fopen(plugin_dir_path(__FILE__)."templates/".$fields['template_select'].".txt", 'r'); 462 $content = fread($fh, filesize(plugin_dir_path(__FILE__)."templates/".$fields['template_select'].".txt")); 463 fclose($fh); 464 465 $content = str_replace("{{SITE_NAME}}", get_bloginfo("name"), $content); 466 $content = str_replace("{{PLUGIN_URL}}", plugins_url( '/', __FILE__ ), $content); 467 if (array_key_exists('template_bg_color', $fields)) { 468 $content = str_replace("{{BG_COLOR}}", $fields['template_bg_color'], $content); 469 } 470 if (array_key_exists('template_bg_img_url', $fields)) { 471 $content = str_replace("{{BG_IMG_URL}}", $fields['template_bg_img_url'], $content); 472 } 473 if (array_key_exists('template_logo_url', $fields)) { 474 $content = str_replace("{{LOGO_URL}}", $fields['template_logo_url'], $content); 475 } 476 if (array_key_exists('template_youtube_id', $fields)) { 477 $content = str_replace("{{YOUTUBE_ID}}", $fields['template_youtube_id'], $content); 478 } 479 if (array_key_exists('template_font_color', $fields)) { 480 $content = str_replace("{{FONT_COLOR}}", $fields['template_font_color'], $content); 481 } 482 if (array_key_exists('template_title', $fields)) { 483 $content = str_replace("{{TITLE}}", $fields['template_title'], $content); 484 } 485 if (array_key_exists('template_sub_title', $fields)) { 486 $content = str_replace("{{SUB_TITLE}}", $fields['template_sub_title'], $content); 487 } 488 if (array_key_exists('email_enabled', $fields) && $fields['email_enabled']!=='' && array_key_exists('email_target', $fields)) { 489 $content = str_replace("{{EMAIL_TARGET}}", $fields['email_target'], $content); 490 } 491 492 // If preview, target write into internal preview php file 493 $file_target = WP_CONTENT_DIR . "/db-error.php"; 494 if ( $is_preview ) { 495 $file_target = plugin_dir_path(__FILE__)."preview.html"; 496 } 497 498 // Write content to target file 499 $fh = fopen($file_target, 'w'); 500 fputs($fh, $header . $content); 501 fclose($fh); 502 503 // Write success. Show status message 504 if ( $is_preview ) { 505 return array( 506 "status"=>"pass", 507 "msg"=>"Preview page generated successfully! Click <a href='".plugins_url( 'preview.html', __FILE__ )."' target='_blank'>Preview</a> to proceed." 508 ); 509 } else { 510 return array( 511 "status"=>"pass", 512 "msg"=>"DB error page created/updated successfully!<br><i>Note: If you modified db-error.php file permission earlier, please remember to restore it to 644.</i>" 513 ); 514 } 515 } 516 517 /* 518 * Plugin settings registration 519 */ 520 function dec_plugin_settings() { 521 register_setting( 'db-error-customizer-settings-group', 'template_select' ); 522 register_setting( 'db-error-customizer-settings-group', 'template_bg_color' ); 523 register_setting( 'db-error-customizer-settings-group', 'template_bg_img_url' ); 524 register_setting( 'db-error-customizer-settings-group', 'template_logo_url' ); 525 register_setting( 'db-error-customizer-settings-group', 'template_youtube_id' ); 526 register_setting( 'db-error-customizer-settings-group', 'template_font_color' ); 527 register_setting( 'db-error-customizer-settings-group', 'template_title' ); 528 register_setting( 'db-error-customizer-settings-group', 'template_sub_title' ); 529 register_setting( 'db-error-customizer-settings-group', 'email_enabled' ); 530 register_setting( 'db-error-customizer-settings-group', 'email_freq' ); 531 register_setting( 'db-error-customizer-settings-group', 'email_target' ); 532 register_setting( 'db-error-customizer-settings-group', 'email_subject' ); 533 register_setting( 'db-error-customizer-settings-group', 'email_msg' ); 534 } 535 add_action( 'admin_init', 'dec_plugin_settings' ); 278 $templates = glob(Setting::getRootDir()."templates/*.txt"); 279 280 include 'source/admin-menu.php'; 281 } 536 282 ?> -
db-error-customizer/trunk/readme.txt
r1464093 r1574150 4 4 Tags: alert, connection error, customization, database down, database error, email alert, monitor, responsive, template, website down 5 5 Requires at least: 3.0.1 6 Tested up to: 4. 5.37 Stable tag: trunk6 Tested up to: 4.7.1 7 Stable tag: 2.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 15 15 Database not responding is a very common issue in hosting a WordPress website. Instead of showing a blank page with an error message **Error establishing a database connection**, DB Error Customizer helps you to handle it professionally. Not only you can easily customize a beautifully designed database error page using our predefined templates, it tells your visitors that everything is under control. 16 16 17 > ### Premium Support 18 > Our team does not always provide active support for the DB Error Customizer plugin on the WordPress.org. One-on-one email support is available to people who bought the [DB Error Customizer Premium](http://dec.centil.co) plugin only. 19 > 20 > Note that the DB Error Customizer Premium plugin has many extra features too, including beautifully designed templates, animation effects and auto email alert. It might be well worth your investment! 21 17 22 Below are the features of DB Error Customizer: 18 23 19 * Comes with 5 predefined templates:20 * [Basic](http://demo.centil.co/db-error-customizer/basic.html) (Customizable error message, background & font color)21 * Pro (Customizable error message, logo and background image & font color. Premium version only)22 * Mystery (Customizable error message, logo, background image & font color. Premium version only)23 * Snow (Customizable error message, logo, background image & font color. Premium version only)24 * Video (Customizable error message, logo, background video & font color. Premium version only)24 * Comes with basic templates and allows you to customize: 25 * Main message to show your visitor, instead of standard error 26 * Sub message below main message 27 * Font size adjustment 28 * Font color adjustment 29 * Background color 25 30 * Preview customized output before saving 26 31 * Inform search engine that the error page is temporarily (HTTP 500 Internal Server Error header) and it should not cache it 27 * Auto send email alert to your admin when a visitor sees this error (Premium version only)28 * Customizable email alert (Email target, subject, content. Premium version only)29 * Email alert spam prevention by allowing you to set how often you should receive an email alert. (Premium version only)30 32 31 33 == Installation == … … 33 35 Please refer the official [WordPress Plugin Installation Guide](https://codex.wordpress.org/Managing_Plugins#Installing_Plugins) to proceed. After you've installed and enabled DB Error Customizer, you shall goto **Settings->DB Error Customizer** to customize and setup the error page. 34 36 35 *Note: If you installed an older version earlier, please disable the plugin and remove it before installing a newer version.*37 *Note: If you installed an older/premium version earlier, please disable the plugin and remove it before installing a newer version.* 36 38 37 39 == Customize DB Error Page == … … 42 44 * **Background Color:** Change background color via color picker. 43 45 * **Font Color:** Change main/sub title color via color picker. 44 * **Background Image:** Not available in free version.45 * **Logo:** Change company logo. Recommend to use PNG with width around 200px and height around 200px. You can upload a new image or select an existing one from WordPress Media.46 * **Youtube ID:** Not available in free version.47 46 * **Main Title:** The main title of database error page. 47 * **Main Title Size:** The size of main title. 48 48 * **Sub Title:** The sub title of database error page. 49 * **Sub Title Size:** The size of sub title. 49 50 50 51 **Preview:** When you press Preview button at the bottom of dashboard, a message box will apear at the top of dashboard with message Preview page generated successfully! Click Preview to proceed. You can press the Preview link to launch the preview page. … … 58 59 59 60 = How can I check if DB Error Customizer can work on my server? = 60 In latest release, we've introduced a newfeature to allow user to test their server compatibility. You can run the test by pressing Check Compatibility button at the admin page.61 There is a feature to allow user to test their server compatibility. You can run the test by pressing Check Compatibility button at the admin page. 61 62 62 63 = There is an error when I try to preview or setup database error page = … … 69 70 * Manually set invalid database configuration in your wp-config.php. Please remember to revert to original setting once you are done. 70 71 71 = I've enabled email alert feature. However there is no email alert when my database is down =72 There are a few possibilities causing this:73 74 * First, please [check if your website PHP mail() function is working](https://easyengine.io/tutorials/php/test-email-sending/). If your server is using SMTP to send email, please let us know and we'll enhance the plugin to support SMTP email sending.75 * Second, make sure your [plugin path]/config.txt file is with [777 permission](https://codex.wordpress.org/Changing_File_Permissions).76 * Lastly, it might just because nobody visits your site to trigger the email alert during database down(The plugin requires a user visit to trigger email sending).77 78 72 == Support == 79 73 Please refer the developer's site at [Centil Technology](http://centil.co). If you would like to provide feedback/contact or just drop us an email, please feel free to contact us at info[at]centil[dot]co 80 74 81 75 == Changelog == 76 77 = 2.0 = 78 * Major refactoring and bug fixes 79 * Tested with WordPress 4.7.1 82 80 83 81 = 1.3 = -
db-error-customizer/trunk/templates/basic.txt
r1371180 r1574150 42 42 43 43 .title { 44 font-size: 96px;44 font-size: {{TITLE_SIZE}}px; 45 45 } 46 46 47 47 .sub-title { 48 font-size: 36px;48 font-size: {{SUB_TITLE_SIZE}}px; 49 49 } 50 50 -
db-error-customizer/trunk/templates/mystery.txt
r1371180 r1574150 1 FREE VERSION 1 --- NA --- -
db-error-customizer/trunk/templates/pro.txt
r1371180 r1574150 1 FREE VERSION 1 --- NA --- -
db-error-customizer/trunk/templates/snow.txt
r1371180 r1574150 1 FREE VERSION 1 --- NA --- -
db-error-customizer/trunk/templates/video.txt
r1371180 r1574150 1 FREE VERSION 1 --- NA ---
Note: See TracChangeset
for help on using the changeset viewer.