PluginProbe ʕ •ᴥ•ʔ
LightStart – Maintenance Mode, Coming Soon and Landing Page Builder / 1.8.2
LightStart – Maintenance Mode, Coming Soon and Landing Page Builder v1.8.2
2.6.22 trunk 1.3 1.5.3 1.6.10 1.6.5 1.6.6 1.6.7 1.6.8 1.6.9 1.7.0 1.7.1 1.8.0 1.8.1 1.8.10 1.8.11 1.8.2 1.8.3 1.8.4 1.8.5 1.8.6 1.8.7 1.8.8 1.8.9 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.0.9 2.1.0 2.1.1 2.1.2 2.2 2.2.2 2.2.3 2.2.4 2.3.0 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 2.6.0 2.6.1 2.6.10 2.6.11 2.6.12 2.6.13 2.6.14 2.6.15 2.6.16 2.6.17 2.6.18 2.6.19 2.6.2 2.6.20 2.6.21 2.6.3 2.6.4 2.6.5 2.6.6 2.6.7 2.6.8 2.6.9
wp-maintenance-mode / wp-maintenance-mode.php
wp-maintenance-mode Last commit date
css 13 years ago inc 13 years ago js 13 years ago languages 13 years ago styles 13 years ago WP Maintenance Mode-da_DK.txt 13 years ago index.php 13 years ago license.txt 13 years ago readme.md 13 years ago readme.txt 13 years ago site.php 13 years ago uninstall.php 13 years ago wp-maintenance-mode.php 13 years ago
wp-maintenance-mode.php
892 lines
1 <?php
2 /**
3 * Plugin Name: WP Maintenance Mode
4 * Plugin URI: http://wordpress.org/extend/plugins/wp-maintenance-mode/
5 * Text Domain: wp-maintenance-mode
6 * Domain Path: /languages
7 * Description: The plugin adds a splash page to your blog that lets visitors know your blog is down for maintenance. Logged in users get full access to the blog including the front-end, depends of the settings.
8 * Author: Frank B&uuml;ltge
9 * Author URI: http://bueltge.de/
10 * Donate URI: http://bueltge.de/wunschliste/
11 * Version: 1.8.2
12 * Last change: 11/13/2012
13 * Licence: GPLv3
14 *
15 *
16 * License:
17 * ==============================================================================
18 * Copyright 2009-2012 Frank Bueltge (email : frank@bueltge.de)
19 *
20 * This program is free software; you can redistribute it and/or modify
21 * it under the terms of the GNU General Public License as published by
22 * the Free Software Foundation; either version 2 of the License, or
23 * (at your option) any later version.
24 *
25 * This program is distributed in the hope that it will be useful,
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
28 * GNU General Public License for more details.
29 *
30 * You should have received a copy of the GNU General Public License
31 * along with this program; if not, write to the Free Software
32 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
33 *
34 * Requirements:
35 * ==============================================================================
36 * This plugin requires WordPress >= 2.6 and tested with PHP Interpreter >= 5.3
37 */
38
39 //avoid direct calls to this file, because now WP core and framework has been used
40 if ( ! function_exists( 'add_filter' ) ) {
41 header('Status: 403 Forbidden');
42 header('HTTP/1.1 403 Forbidden');
43 exit();
44 }
45
46 if ( ! class_exists('WPMaintenanceMode') ) {
47
48 if ( ! defined('WP_CONTENT_URL') )
49 define('WP_CONTENT_URL', site_url() . '/wp-content');
50 if ( ! defined('WP_PLUGIN_URL') )
51 define( 'WP_PLUGIN_URL', WP_CONTENT_URL . '/plugins' );
52
53 define( 'FB_WM_BASENAME', plugin_basename(__FILE__) );
54 define( 'FB_WM_BASEDIR', dirname( plugin_basename(__FILE__) ) );
55 define( 'FB_WM_BASE', rtrim(dirname (__FILE__), '/') );
56 define( 'FB_WM_TEXTDOMAIN', 'wp-maintenance-mode' );
57
58 class WPMaintenanceMode {
59
60 function WPMaintenanceMode() {
61
62 $this->load_classes();
63
64 register_activation_hook( __FILE__, array( $this, 'add_config' ) );
65 add_action( 'admin_print_scripts-plugins.php', array( $this, 'add_scripts' ) );
66 //add_action( 'load-plugins.php', array(&$this, 'add_scripts') );
67 add_action( 'init', array( $this, 'on_init'), 1 );
68 add_action( 'admin_init', array( $this, 'admin_init') );
69 add_action( 'admin_menu', array( $this, 'redirect' ) );
70
71 add_action( 'wp_ajax_wm_config-update', array( $this, 'save_config' ) );
72 add_action( 'wp_ajax_wm_config-active', array( $this, 'save_active' ) );
73 }
74
75
76 /**
77 * Returns array of features, also
78 * Scans the plugins subfolder "/classes"
79 *
80 * @since 0.1
81 * @return void
82 */
83 protected function load_classes() {
84
85 // load all files with the pattern *.php from the directory inc
86 foreach( glob( dirname( __FILE__ ) . '/inc/*.php' ) as $class )
87 require_once $class;
88 }
89
90 /**
91 * Function to escape strings
92 * Use WP default, if exists
93 *
94 * @param String
95 * @return String
96 */
97 function esc_attr( $text ) {
98
99 if ( function_exists('esc_attr') )
100 $text = esc_attr($text);
101 else
102 $text = attribute_escape($text);
103
104 return $text;
105 }
106
107
108 // function for WP < 2.8
109 function get_plugins_url( $path = '', $plugin = '' ) {
110
111 if ( function_exists('plugin_url') )
112 return plugins_url($path, $plugin);
113
114 if ( function_exists('is_ssl') )
115 $scheme = ( is_ssl() ? 'https' : 'http' );
116 else
117 $scheme = 'http';
118 if ( function_exists('plugins_url') )
119 $url = plugins_url();
120 else
121 $url = WP_PLUGIN_URL;
122 if ( 0 === strpos($url, 'http') ) {
123 if ( function_exists('is_ssl') && is_ssl() )
124 $url = str_replace( 'http://', "{$scheme}://", $url );
125 }
126
127 if ( !empty($plugin) && is_string($plugin) ) {
128 $folder = dirname(plugin_basename($plugin));
129 if ('.' != $folder)
130 $url .= '/' . ltrim($folder, '/');
131 }
132
133 if ( !empty($path) && is_string($path) && ( FALSE === strpos($path, '..') ) )
134 $url .= '/' . ltrim($path, '/');
135
136 return apply_filters('plugins_url', $url, $path, $plugin);
137 }
138
139
140 function on_init() {
141
142 load_plugin_textdomain( FB_WM_TEXTDOMAIN, FALSE, FB_WM_BASEDIR . '/languages' );
143
144 if ( is_multisite() && ! function_exists( 'is_plugin_active_for_network' ) )
145 require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
146
147 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
148 $valuemsqld = get_site_option( FB_WM_TEXTDOMAIN . '-msqld' );
149 else
150 $valuemsqld = (int) get_option( FB_WM_TEXTDOMAIN . '-msqld' );
151
152 if ( 1 === $valuemsqld || '1' === $valuemsqld ) {
153 $this->on_active();
154 add_action( 'admin_bar_menu', array( $this, 'add_admin_bar_alert' ), 9999 );
155 }
156 }
157
158
159 function add_scripts() {
160
161 $locale = get_locale();
162 $i18n = substr($locale, 0, 2);
163
164 wp_register_script( 'wp-maintenance-mode', $this->get_plugins_url( 'js/wp-maintenance-mode.js', __FILE__ ), array('jquery-ui-datepicker') , '', TRUE );
165 wp_enqueue_script( 'wp-maintenance-mode' );
166
167 // translations for datepicker
168 if ( ! empty( $i18n ) &&
169 @file_exists( WP_PLUGIN_DIR . '/' . dirname( plugin_basename(__FILE__) ) . '/js/i18n/jquery.ui.datepicker-' . $i18n . '.js' )
170 ) {
171 wp_register_script( 'jquery-ui-datepicker-' . $i18n, $this->get_plugins_url( 'js/i18n/jquery.ui.datepicker-' . $i18n . '.js', __FILE__ ), array('jquery-ui-datepicker') , '', TRUE );
172 wp_enqueue_script( 'jquery-ui-datepicker-' . $i18n );
173 }
174
175 // include styles for datepicker
176 wp_enqueue_style( 'jquery-ui-datepicker' );
177 wp_enqueue_style( 'jquery-ui-datepicker-overcast', $this->get_plugins_url( 'css/overcast/jquery-ui-1.8.21.custom.css', __FILE__ ) );
178
179 // for preview
180 add_thickbox();
181 }
182
183
184 function admin_init() {
185
186 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) {
187 // multisite install
188 add_filter( 'network_admin_plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 );
189 add_action( 'after_plugin_row_' . FB_WM_BASENAME, array( 'WPMaintenanceMode_Settings', 'add_config_form'), 10, 3 );
190 } else {
191 // Single mode install of WP
192 if ( version_compare( $GLOBALS['wp_version'], '2.7alpha', '>' ) ) {
193 add_action( 'after_plugin_row_' . FB_WM_BASENAME, array( 'WPMaintenanceMode_Settings', 'add_config_form'), 10, 3 );
194 add_filter( 'plugin_action_links_' . FB_WM_BASENAME, array( $this, 'add_settings_link' ), 10, 2 );
195 } else {
196 add_action( 'after_plugin_row', array( 'WPMaintenanceMode_Settings', 'add_config_form'), 10, 3 );
197 add_filter( 'plugin_action_links', array( $this, 'add_settings_link' ), 10, 2 );
198 }
199 }
200
201 wp_enqueue_style( 'wp-maintenance-mode-options', $this->get_plugins_url( 'css/style.css', __FILE__ ) );
202 }
203
204
205 function add_settings_link( $links, $file ) {
206 if ( plugin_basename( __FILE__ ) == $file )
207 array_unshift(
208 $links,
209 sprintf( '<a id="wm-pluginconflink" href="javascript:void(0)" title="Configure this plugin">%s</a>', __('Settings') )
210 );
211
212 return $links;
213 }
214
215
216 function network_admin_add_settings_link( $links, $file ) {
217
218 if ( plugin_basename( __FILE__ ) == $file )
219 $links[] = '<a id="wm-pluginconflink" href="javascript:void(0)" title="Configure this plugin">' . __('Settings') . '</a>';
220
221 return $links;
222 }
223
224
225 function add_config() {
226
227 $this->data = array(
228 'active' => 0,
229 'radio' => 0,
230 'time' => 60,
231 'link' => 1,
232 'admin_link' => 1,
233 'theme' => 1,
234 'role' => 'administrator',
235 'unit' => 1,
236 'title' => __( 'Maintenance mode', FB_WM_TEXTDOMAIN ),
237 'text' => __( '<p>Sorry for the inconvenience.<br />Our website is currently undergoing scheduled maintenance.<br /><strong>Please try back in %1$s %2$s</strong><br />Thank you for your understanding.</p>', FB_WM_TEXTDOMAIN ),
238 'exclude' => 'wp-cron, feed, wp-admin'
239 );
240 // if is active in network of multisite
241 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) {
242 add_site_option( FB_WM_TEXTDOMAIN, $this->data );
243 add_site_option( FB_WM_TEXTDOMAIN . '-msqld', $this->data['active'] );
244 } else {
245 add_option( FB_WM_TEXTDOMAIN, $this->data );
246 add_option( FB_WM_TEXTDOMAIN . '-msqld', $this->data['active'] );
247 }
248
249 $old_check = get_option( 'wartungsmodus' );
250 if ($old_check)
251 delete_option( 'wartungsmodus' );
252 }
253
254
255 function save_active() {
256
257 $this->data = array();
258 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) {
259 $this->data = get_site_option( FB_WM_TEXTDOMAIN );
260 $this->datamsqld = get_site_option( FB_WM_TEXTDOMAIN . '-msqld' );
261 } else {
262 $this->data = get_option( FB_WM_TEXTDOMAIN );
263 $this->datamsqld = get_option( FB_WM_TEXTDOMAIN . '-msqld' );
264 }
265
266 if ( isset($_POST['wm_config-active']) )
267 $this->data['active'] = (int) $_POST['wm_config-active'];
268
269 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) {
270 update_site_option( FB_WM_TEXTDOMAIN, $this->data );
271 update_site_option( FB_WM_TEXTDOMAIN . '-msqld', $this->data['active'] );
272 } else {
273 update_option( FB_WM_TEXTDOMAIN, $this->data );
274 update_option( FB_WM_TEXTDOMAIN . '-msqld', $this->data['active'] );
275 }
276
277 die( __( 'Updated', FB_WM_TEXTDOMAIN ) );
278 }
279
280
281 function save_config() {
282
283 $this->data = array();
284 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
285 $this->data = get_site_option( FB_WM_TEXTDOMAIN );
286 else
287 $this->data = get_option( FB_WM_TEXTDOMAIN );
288
289 if ( isset($_POST['wm_config-time']) )
290 $this->data['time'] = (int) $_POST['wm_config-time'];
291 if ( isset($_POST['wm_config-unit']) )
292 $this->data['unit'] = (int) $_POST['wm_config-unit'];
293 if ( isset($_POST['wm_config-link']) )
294 $this->data['link'] = (int) $_POST['wm_config-link'];
295 if ( isset($_POST['wm_config-admin_link']) )
296 $this->data['admin_link'] = (int) $_POST['wm_config-admin_link'];
297 if ( isset($_POST['wm_config-rewrite']) ) {
298 if ( function_exists('esc_url') ) {
299 $this->data['rewrite'] = esc_url( $_POST['wm_config-rewrite'] );
300 } else {
301 $this->data['rewrite'] = clean_url( $_POST['wm_config-rewrite'] );
302 }
303 }
304 if ( isset($_POST['wm_config-theme']) )
305 $this->data['theme'] = (int) $_POST['wm_config-theme'];
306 if ( isset($_POST['wm_config-styleurl']) ) {
307 if ( function_exists('esc_url') ) {
308 $this->data['styleurl'] = esc_url( $_POST['wm_config-styleurl'] );
309 } else {
310 $this->data['styleurl'] = clean_url( $_POST['wm_config-styleurl'] );
311 }
312 }
313 if ( isset($_POST['wm_config-index']) )
314 $this->data['index'] = (int) $_POST['wm_config-index'];
315 if ( isset($_POST['wm_config-title']) )
316 $this->data['title'] = stripslashes_deep( $_POST['wm_config-title'] );
317 if ( isset($_POST['wm_config-header']) )
318 $this->data['header'] = stripslashes_deep( $_POST['wm_config-header'] );
319 if ( isset($_POST['wm_config-heading']) )
320 $this->data['heading'] = stripslashes_deep( $_POST['wm_config-heading'] );
321 if ( isset($_POST['wm_config-text']) )
322 $this->data['text'] = stripslashes_deep( $_POST['wm_config-text'] );
323 if ( isset($_POST['wm_config-exclude']) )
324 $this->data['exclude'] = preg_split("/[\s,]+/", $this->esc_attr( $_POST['wm_config-exclude'] ) );
325 if ( isset($_POST['wm_config-role']) )
326 $this->data['role'] = preg_split("/[\s,]+/", $this->esc_attr( $_POST['wm_config-role'] ) );
327 if ( isset($_POST['wm_config-role_frontend']) )
328 $this->data['role_frontend'] = preg_split("/[\s,]+/", $this->esc_attr( $_POST['wm_config-role_frontend'] ) );
329 if ( isset($_POST['wm_config-radio']) )
330 $this->data['radio'] = (int) $_POST['wm_config-radio'];
331 if ( isset($_POST['wm_config-date']) )
332 $this->data['date'] = $this->esc_attr( $_POST['wm_config-date'] );
333
334 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
335 update_site_option( FB_WM_TEXTDOMAIN, $this->data );
336 else
337 update_option( FB_WM_TEXTDOMAIN, $this->data );
338
339 die( __( 'Updated', FB_WM_TEXTDOMAIN ) );
340 }
341
342
343 function del_config() {
344
345 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) {
346 delete_site_option( FB_WM_TEXTDOMAIN );
347 delete_site_option( FB_WM_TEXTDOMAIN . '-msqld' );
348 } else {
349 delete_option( FB_WM_TEXTDOMAIN );
350 delete_option( FB_WM_TEXTDOMAIN . '-msqld' );
351 }
352 }
353
354
355 function check_version() {
356 global $wp_version;
357
358 if ( version_compare($wp_version, '2.1-dev', '<') ) {
359 require (ABSPATH . WPINC . '/pluggable-functions.php'); // < WP 2.1
360 } else {
361 require (ABSPATH . WPINC . '/pluggable.php'); // >= WP 2.1
362 }
363 }
364
365 /**
366 * Rewrite for Frontend Login
367 *
368 * @return void
369 */
370 function redirect() {
371
372 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
373 $value = get_site_option( FB_WM_TEXTDOMAIN );
374 else
375 $value = get_option( FB_WM_TEXTDOMAIN );
376
377 // if the redirect active
378 if ( ! isset($value['rewrite']) )
379 return NULL;
380
381 // check, is the maintenance mode active
382 if ( 0 === $value['active'] )
383 return NULL;
384
385 // check, Access to backend
386 if ( current_user_can( $value['role'][0] ) )
387 return NULL;
388
389 // redirect for wp-admin
390 // only Dashboard: #wp-admin/?(index.php)?$#
391 if ( preg_match( '#wp-admin/#', $_SERVER['REQUEST_URI'] ) )
392 wp_redirect( $value['rewrite'] );
393 }
394
395
396 function check_exclude() {
397
398 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
399 $value = get_site_option( FB_WM_TEXTDOMAIN );
400 else
401 $value = get_option( FB_WM_TEXTDOMAIN );
402
403 if ( ! isset($value['exclude']) )
404 return FALSE;
405
406 foreach ( (array) $value['exclude'] as $exclude ) {
407 // check for IP
408 if ( strstr( $_SERVER['REMOTE_ADDR'], $exclude ) )
409 return TRUE;
410
411 if ( $exclude && strstr( $_SERVER['REQUEST_URI'], $exclude ) )
412 return TRUE;
413 }
414
415 return FALSE;
416 }
417
418
419 function check_role() {
420
421 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
422 $value = get_site_option( FB_WM_TEXTDOMAIN );
423 else
424 $value = get_option( FB_WM_TEXTDOMAIN );
425
426 if ( is_super_admin() )
427 return TRUE;
428
429 if ( ! isset( $value['role'][0] ) || ( '' != $value['role'][0] ) )
430 $role = 'manage_options';
431
432 if ( is_admin() )
433 $current = $value['role'][0];
434 else
435 $current = $value['role_frontend'][0];
436
437 $defaultroles = array('administrator', 'editor', 'author', 'contributor', 'subscriber');
438
439 if ( isset( $current ) ) {
440 if ( 'administrator' == $current )
441 $role = 'manage_options';
442
443 elseif ( 'editor' == $current )
444 $role = 'manage_categories';
445
446 elseif ( 'author' == $current )
447 $role = 'publish_posts';
448
449 elseif ( 'contributor' == $current )
450 $role = 'edit_posts';
451
452 elseif ( 'subscriber' == $current )
453 $role = 'read';
454
455 elseif ( ! in_array( $current, $defaultroles ) )
456 $role = 'manage_options';
457 } else {
458 $role = 'manage_options';
459 }
460
461 if ( current_user_can( $role ) )
462 return TRUE;
463 else if ( current_user_can( $value['role_frontend'][0] ) )
464 return TRUE;
465
466 return FALSE;
467 }
468
469
470 function case_unit($unitvalue) {
471
472 $value['unit'] = $unitvalue;
473 $unitvalues = array();
474
475 switch( $value['unit'] ) {
476 case 0:
477 $unitvalues['unit'] = __( 'seconds', FB_WM_TEXTDOMAIN );
478 $unitvalues['multiplier'] = 1;
479 break;
480 case 1:
481 $unitvalues['unit'] = __( 'minutes', FB_WM_TEXTDOMAIN );
482 $unitvalues['multiplier'] = 60;
483 break;
484 case 2:
485 $unitvalues['unit'] = __( 'hours', FB_WM_TEXTDOMAIN );
486 $unitvalues['multiplier'] = 3600;
487 break;
488 case 3:
489 $unitvalues['unit'] = __( 'days', FB_WM_TEXTDOMAIN );
490 $unitvalues['multiplier'] = 86400;
491 break;
492 case 4:
493 $unitvalues['unit'] = __( 'weeks', FB_WM_TEXTDOMAIN );
494 $unitvalues['multiplier'] = 604800;
495 break;
496 case 5:
497 $unitvalues['unit'] = __( 'months', FB_WM_TEXTDOMAIN );
498 $unitvalues['multiplier'] = 2592000; // 30 days
499 break;
500 case 6:
501 $unitvalues['unit'] = __( 'years', FB_WM_TEXTDOMAIN );
502 $unitvalues['multiplier'] = 31556952;
503 break;
504 }
505
506 return $unitvalues;
507 }
508
509
510 function check_datetime() {
511
512 $datetime = NULL;
513 $time = NULL;
514 $date = NULL;
515 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
516 $value = get_site_option( FB_WM_TEXTDOMAIN );
517 else
518 $value = get_option( FB_WM_TEXTDOMAIN );
519
520 if ( isset($value['radio']) && 1 === $value['radio'] ) {
521 $datetime = explode( ' ', $value['date'] );
522 $date = explode( '-', $datetime[0] );
523 if ( isset($datetime[1]) )
524 $time = explode( ':', $datetime[1] );
525 else $time = 0;
526 if (count($date) < 3) {
527 $date = 0; //ausschalten wegen datum is nicht
528 } else {
529 $date[1] = $date[1] - 1;
530 if (count($time) < 3)
531 $time = 0;
532 if ( isset($time) && 0 !== $time ) {
533 // 'Years', 'Months', 'Weeks', 'Days', 'Hours', 'Minutes', 'Seconds'
534 $date = $date[2].', '.$date[1].', '.$date[0].', '.$time[0].', '.$time[1].', '.$time[2];
535 } else {
536 $date = $date[2].', '.$date[1].', '.$date[0];
537 }
538 }
539 }
540
541 return array( $datetime, $time, $date );
542 }
543
544
545 function on_active() {
546 global $current_user;
547
548 if ( is_multisite() && ! function_exists( 'is_plugin_active_for_network' ) ) {
549 require_once( ABSPATH . '/wp-admin/includes/plugin.php' );
550 }
551
552 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) ) {
553 $value = get_site_option( FB_WM_TEXTDOMAIN );
554 $settings_link = network_admin_url() . 'plugins.php#wm-pluginconflink';
555 } else {
556 $value = get_option( FB_WM_TEXTDOMAIN );
557 $settings_link = admin_url() . 'plugins.php#wm-pluginconflink';
558 }
559
560 $scmsg = '';
561 // Super Cache Plugin; clear cache on activation of maintance mode
562 if ( function_exists( 'wp_cache_clear_cache' ) ) {
563 ob_end_clean();
564 wp_cache_clear_cache();
565 $scmsg .= __( ' &amp; WP Super Cache flushed.', FB_WM_TEXTDOMAIN );
566 }
567
568 // W3 Total Cache Support
569 if ( function_exists( 'w3tc_pgcache_flush' ) ) {
570 ob_end_clean();
571 w3tc_pgcache_flush();
572 $scmsg .= __( ' &amp; W3 Total Cache for pages flushed.', FB_WM_TEXTDOMAIN );
573 }
574
575 $message = __( 'Caution: Maintenance mode is <strong>active</strong>!', FB_WM_TEXTDOMAIN );
576 add_filter( 'login_message', create_function( '', "return '<div id=\"login_error\">$message</div>';" ) );
577 $admin_notices = '<div id="message" class="error fade" style="background-color: #FFEBE8 !important;"><p>' . $message . $scmsg . ' <a href="plugins.php#wm-pluginconflink">' . __( 'Deactivate or change Settings', FB_WM_TEXTDOMAIN ) . '</a></p></div>';
578 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
579 add_action( 'network_admin_notices', create_function( '', "echo '$admin_notices';" ) );
580 add_action( 'admin_notices', create_function( '', "echo '$admin_notices';" ) );
581 $in_admin_header = '<a id="mm_in_admin_header" href="' . $settings_link . '" title="' . __( 'Deactivate or change Settings', FB_WM_TEXTDOMAIN ) . '">' . $message . '</a>';
582 //add_action( 'in_admin_header', create_function( '', "echo '$in_admin_header';" ) );
583 /**
584 // actual a ticket in trac #14126
585 // @link http://core.trac.wordpress.org/ticket/14126
586 $in_admin_header = '<a class="privacy-on-link" href="plugins.php#wm-pluginconflink" title="' . __( 'Deactivate or change Settings', FB_WM_TEXTDOMAIN ) . '">' . $message . '</a>';
587 add_action( 'in_admin_site_heading', create_function( '', "echo '$in_admin_header';" ) );
588 */
589
590 add_action( 'wm_head', array(&$this, 'add_theme') );
591 add_action( 'wm_content', array(&$this, 'add_flash') );
592 add_action( 'wm_content', array( &$this, 'add_content' ) );
593 if ( isset($value['link']) && 1 === $value['link'] )
594 add_action( 'wm_footer', array(&$this, 'add_link') );
595
596 $locale = get_locale();
597
598 if ( isset($value['unit']) )
599 $unitvalues = $this->case_unit($value['unit']);
600
601 // set backtime for header status
602 if ( isset($value['time']) )
603 $backtime = $value['time'] * $unitvalues['multiplier'];
604 else
605 $backtime = NULL;
606 if ( ( ! $this->check_role() )
607 && ! strstr($_SERVER['PHP_SELF'], 'wp-login.php' )
608 && ! strstr($_SERVER['PHP_SELF'], 'async-upload.php')
609 && ! strstr($_SERVER['PHP_SELF'], '/plugins/')
610 && ! $this->check_exclude()
611 ) {
612 $rolestatus = 'norights';
613 nocache_headers();
614 header("HTTP/1.0 503 Service Unavailable");
615 header("Retry-After: $backtime");
616 include('site.php');
617 exit();
618 }
619
620 //$this->check_version();
621 if ( ! strstr($_SERVER['PHP_SELF'], 'feed/')
622 && ! strstr($_SERVER['PHP_SELF'], 'wp-admin/')
623 && ! strstr($_SERVER['PHP_SELF'], 'wp-login.php')
624 && ! strstr($_SERVER['PHP_SELF'], 'async-upload.php')
625 && ! ( strstr($_SERVER['PHP_SELF'], 'upgrade.php') && $this->check_role() )
626 && ! strstr($_SERVER['PHP_SELF'], 'trackback/')
627 && ! strstr($_SERVER['PHP_SELF'], '/plugins/')
628 && ! $this->check_exclude()
629 && ! $this->check_role()
630 ) {
631 include('site.php');
632 exit();
633 } else if ( strstr($_SERVER['PHP_SELF'], 'feed/') || strstr($_SERVER['PHP_SELF'], 'trackback/') ) {
634 nocache_headers();
635 header("HTTP/1.0 503 Service Unavailable");
636 header("Retry-After: $backtime");
637 exit();
638 }
639
640 }
641
642
643 function add_link() {
644
645 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
646 $value = get_site_option( FB_WM_TEXTDOMAIN );
647 else
648 $value = get_option( FB_WM_TEXTDOMAIN );
649 ?>
650 <div id="footer">
651 <p><a href="http://bueltge.de/"><?php _e( 'Plugin by:', FB_WM_TEXTDOMAIN ); ?> <img src="http://bueltge.de/favicon.ico" alt="bueltge.de" width="16" height="16" /></a>
652 <?php if ( 2 === $value['theme'] ) { ?>
653 &nbsp;<a href="http://davidhellmann.com/"><?php _e( 'Design by:', FB_WM_TEXTDOMAIN ); ?> <img src="http://davidhellmann.com/favicon.ico" alt="davidhellmann.com" width="16" height="16" /></a>
654 <?php } elseif ( 3 === $value['theme'] ) { ?>
655 &nbsp;<a href="http://www.mynicki.net"><?php _e( 'Design by:', FB_WM_TEXTDOMAIN ); ?> <img src="http://www.mynicki.net/favicon.ico" alt="mynicki.net" width="16" height="16" /></a>
656 <?php } elseif ( 4 === $value['theme'] ) { ?>
657 &nbsp;<a href="http://www.lokalnetz.com"><?php _e( 'Design by:', FB_WM_TEXTDOMAIN ); ?> <img src="http://www.lokalnetz.com/images/favicon.ico" alt="lokalnetz.com" width="16" height="16" /></a>
658 <?php } elseif ( 5 === $value['theme'] ) { ?>
659 &nbsp;<a href="http://www.distractedbysquirrels.com"><?php _e( 'Design by:', FB_WM_TEXTDOMAIN ); ?> <img src="http://www.distractedbysquirrels.com/favicon.ico" alt="distractedbysquirrels.com" width="16" height="16" /></a>
660 <?php } elseif ( 6 === $value['theme'] ) { ?>
661 &nbsp;<a href="http://fv-web.de/"><?php _e( 'Design by:', FB_WM_TEXTDOMAIN ); ?> <img src="http://fv-web.de/favicon.ico" alt="fv-web.de" width="16" height="16" /></a>
662 <?php } elseif ( 7 === $value['theme'] ) { ?>
663 &nbsp;<a href="http://krautsuppe.de/"><?php _e( 'Design by:', FB_WM_TEXTDOMAIN ); ?> <img src="http://krautsuppe.de/favicon.ico" alt="krautsuppe.de" width="16" height="16" /></a>
664 <?php } elseif ( 8 === $value['theme'] ) { ?>
665 &nbsp;<a href="http://www.bugeyes.de/"><?php _e( 'Design by:', FB_WM_TEXTDOMAIN ); ?> <img src="http://www.bugeyes.de/favicon.ico" alt="www.bugeyes.de" width="16" height="16" /></a>
666 <?php } elseif ( 9 === $value['theme'] ) { ?>
667 &nbsp;<a href="http://www.cayou-media.de/"><?php _e( 'Design by:', FB_WM_TEXTDOMAIN ); ?> <img src="http://www.cayou-media.de/favicon.ico" alt="www.cayou-media.de" width="16" height="16" /></a>
668 <?php } elseif ( 10 === $value['theme'] ) { ?>
669 &nbsp;<a href="http://fabianletscher.de/"><?php _e( 'Design by:', FB_WM_TEXTDOMAIN ); ?> <img src="http://fabianletscher.de/favicon.ico" alt="fabianletscher.de" width="16" height="16" /></a>
670 <?php } elseif ( 11 === $value['theme'] ) { ?>
671 &nbsp;<a href="http://www.blogdrauf.de/"><?php _e( 'Design by:', FB_WM_TEXTDOMAIN ); ?> <img src="http://www.blogdrauf.de/favicon.ico" alt="www.blogdrauf.de" width="16" height="16" /></a>
672 <?php } elseif ( 12 === $value['theme'] ) { ?>
673 &nbsp;<a href="http://www.elmastudio.de/"><?php _e( 'Design by:', FB_WM_TEXTDOMAIN ); ?> <img src="http://www.elmastudio.de/favicon.ico" alt="www.elmastudio.de" width="16" height="16" /></a>
674 <?php } ?>
675 </p>
676 </div>
677 <?php
678 }
679
680
681 function add_theme() {
682
683 $locale = get_locale();
684 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
685 $value = get_site_option( FB_WM_TEXTDOMAIN );
686 else
687 $value = get_option( FB_WM_TEXTDOMAIN );
688
689 $theme = '';
690 $link = '';
691 $style = '';
692 // default theme
693 if ( !isset($value['theme']) )
694 $value['theme'] = 1;
695
696 switch( $value['theme'] ) {
697 case 0:
698 if ( $value['styleurl'] )
699 $style = '<link rel="stylesheet" href="' . $value['styleurl'] . '" type="text/css" media="all" />' ."\n";
700 break;
701 case 1:
702 $theme = 'txt.css';
703 break;
704 case 2:
705 $theme = 'dh.css';
706 $style .= ' <style type="text/css">' . "\n" . '<!--';
707 $style .= ' #content h1 { text-indent: -99999px; background: url(\'' . $this->get_plugins_url( '/styles/images/headline-' . $locale . '.jpg', __FILE__) . '\') no-repeat; }' . "\n";
708 $style .= ' -->' . "\n";
709 $style .= ' </style>';
710 break;
711 case 3:
712 $theme = 'nicki.css';
713 break;
714 case 4:
715 $theme = 'ln.css';
716 break;
717 case 5:
718 $theme = 'monster.css';
719 break;
720 case 6:
721 $theme = 'fv.css';
722 break;
723 case 7:
724 $theme = 'ks.css';
725 break;
726 case 8:
727 $theme = 'be.css';
728 break;
729 case 9:
730 $theme = 'cm.css';
731 break;
732 case 10:
733 $theme = 'fl.css';
734 break;
735 case 11:
736 $theme = 'af.css';
737 $style .= ' <style type="text/css">' . "\n" . '<!--';
738 $style .= ' #content h1 { text-indent: -99999px; background: url(\'' . $this->get_plugins_url( 'styles/images/headline-af-' . $locale . '.jpg\') no-repeat; }', __FILE__ ) . "\n";
739 $style .= ' -->' . "\n";
740 $style .= ' </style>';
741 break;
742 case 12:
743 $theme = 'es.css';
744 break;
745 }
746 if ( ! empty($theme) )
747 $link = '<link rel="stylesheet" href="' . $this->get_plugins_url( 'styles/', __FILE__ ) . $theme . '" type="text/css" media="all" />' ."\n";
748 echo $link . $style;
749 }
750
751
752 function add_flash() {
753
754 $locale = get_locale();
755 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
756 $value = get_site_option( FB_WM_TEXTDOMAIN );
757 else
758 $value = get_option( FB_WM_TEXTDOMAIN );
759
760 $flash = '';
761 $object = '';
762 // default theme
763 if ( !isset($value['theme']) )
764 $value['theme'] = 1;
765
766 switch( $value['theme'] ) {
767 case 9:
768 $flash = FB_WM_BASE . '/styles/wartung-' . $locale . '.swf';
769 if ( file_exists($flash) ) {
770 $flash = $flash;
771 } else {
772 $flash = $this->get_plugins_url( 'styles/', __FILE__ ) . 'wartung.swf';
773 }
774
775 $object = '
776 <object type="application/x-shockwave-flash" data="' . $flash . '" width="800" height="600" id="galerie" style="outline:none;">
777 <param name="wmode" value="transparent" />
778 <param name="movie" value="' . $flash . '" />
779 </object>';
780 break;
781 }
782 echo $object;
783 }
784
785
786 function add_content() {
787
788 $locale = get_locale();
789 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
790 $value = get_site_option( FB_WM_TEXTDOMAIN );
791 else
792 $value = get_option( FB_WM_TEXTDOMAIN );
793 $echo = NULL;
794 // default for unit
795 if ( ! isset($value['unit']) )
796 $value['unit'] = NULL;
797
798 $unitvalues = $this->case_unit($value['unit']);
799 $td = $this->check_datetime();
800
801 if ( isset($value['radio']) && 1 === $value['radio'] && 0 !== $td[2] ) {
802 $echo = wp_sprintf(
803 stripslashes_deep( $value['text']),
804 '<br /><span id="countdown"></span>',
805 date_i18n( get_option('date_format'), strtotime( $td[0][0] ) )
806 );
807 } elseif ( isset($value['text']) ) {
808 if ( ! isset($value['time']) || 0 == $value['time'] )
809 $value['time'] = FALSE;
810 if ( ! isset($unitvalues['unit']) )
811 $unitvalues['unit'] = FALSE;
812 $echo = wp_sprintf( stripslashes_deep( $value['text'] ), $value['time'], $unitvalues['unit'] );
813 }
814
815 echo do_shortcode($echo);
816 }
817
818
819 function check_file($url) {
820
821 $url = parse_url($url);
822 $fp = fsockopen($url['host'], 80, $errno, $errstr, 30);
823
824 if (!$fp) {
825 echo $errstr . ' (' . $errno . ')<br />'. "\n";
826 } else {
827 $httpRequest = 'HEAD ' . $url['path'] . ' HTTP/1.1' . "\r\n"
828 . 'Host: ' . $url['host'] ."\r\n"
829 . 'Connection: close'. "\r\n\r\n";
830
831 fputs($fp, $httpRequest);
832 $zeileeins = fgets($fp, 1024);
833 fclose($fp);
834
835 if ( eregi('200 OK', $zeileeins) ) {
836 return TRUE;
837 } else {
838 return FALSE;
839 }
840 }
841 }
842
843 function add_admin_bar_alert() {
844
845 if ( is_multisite() && is_plugin_active_for_network( plugin_basename( __FILE__ ) ) )
846 $settings_link = network_admin_url() . 'plugins.php#wm-pluginconflink';
847 else
848 $settings_link = admin_url() . 'plugins.php#wm-pluginconflink';
849
850 $GLOBALS['wp_admin_bar'] -> add_menu(
851 array(
852 'id' => 'mm_alert',
853 'title' => __( 'Caution: Maintenance mode is <strong>active</strong>!', FB_WM_TEXTDOMAIN ),
854 'href' => $settings_link
855 )
856 );
857 }
858
859
860 function url_exists($url) {
861 if ( (strpos($url, "http")) === FALSE ) $url = "http://" . $url;
862 if ( is_array(@get_headers($url)) )
863 return TRUE;
864 else
865 return FALSE;
866 }
867
868 } // end class
869
870 /**
871 * Template tag to use in site-template
872 */
873 function wm_head() {
874
875 do_action('wm_head');
876 }
877
878 function wm_content() {
879
880 do_action('wm_content');
881 }
882
883 function wm_footer() {
884
885 do_action('wm_footer');
886 }
887
888 $GLOBALS['WPMaintenanceMode'] = new WPMaintenanceMode();
889 }
890
891 ?>
892