Version Description
Download this release
Release Info
Developer | MotoPress |
Plugin | Timetable and Event Schedule by MotoPress |
Version | 2.3.10 |
Comparing to | |
See all releases |
Code changes from version 2.3.9 to 2.3.10
- classes/class-hooks.php +12 -6
- classes/class-preprocessor.php +1 -35
- classes/controllers/class-controller-events.php +3 -3
- classes/controllers/class-controller-popup.php +1 -4
- classes/controllers/class-controller-settings.php +9 -13
- classes/libs/FirePHPCore/FirePHP.class.php +0 -1785
- classes/libs/FirePHPCore/FirePHP.class.php4 +0 -1363
- classes/libs/FirePHPCore/fb.php +0 -287
- classes/libs/FirePHPCore/fb.php4 +0 -251
- classes/models/class-events.php +5 -2
- classes/models/class-settings.php +7 -10
- classes/modules/class-post.php +6 -2
- mp-timetable.php +1 -5
- readme.txt +4 -0
classes/class-hooks.php
CHANGED
@@ -31,28 +31,34 @@ class Hooks extends Core {
|
|
31 |
* Install hooks
|
32 |
*/
|
33 |
public function install_hooks() {
|
|
|
34 |
// register custom post type and taxonomies
|
35 |
-
add_action( 'init', array( $this,
|
36 |
-
add_action( 'wp_enqueue_scripts', array( Core::get_instance(),
|
37 |
-
add_action( 'wp_head', array( $this,
|
38 |
|
39 |
add_action( 'admin_init', array( $this->get_controller( 'settings' ), 'action_save' ) );
|
40 |
-
add_action(
|
41 |
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
42 |
add_action( 'manage_posts_custom_column', array( $this->get( 'events' ), 'get_event_taxonomy' ) );
|
43 |
add_action( 'manage_posts_custom_column', array( $this->get( 'column' ), 'get_column_columns' ) );
|
44 |
add_action( 'current_screen', array( Core::get_instance(), 'current_screen' ) );
|
45 |
add_action( 'pre_get_posts', array( $this->get( 'column' ), 'clientarea_default_order' ), 9 );
|
|
|
46 |
//add media in frontend WP
|
47 |
-
add_action( 'wp_enqueue_scripts', array( Core::get_instance(),
|
|
|
48 |
//add media in admin WP
|
49 |
-
add_action( 'admin_enqueue_scripts', array( Core::get_instance(),
|
50 |
add_action( 'widgets_init', array( $this, 'register_widgets' ) );
|
|
|
51 |
// Manage event/column columns
|
52 |
add_filter( 'manage_edit-mp-event_columns', array( $this->get( 'events' ), 'set_event_columns' ) );
|
53 |
add_filter( 'manage_edit-mp-column_columns', array( $this->get( 'column' ), 'set_column_columns' ) );
|
|
|
54 |
// post_class filter
|
55 |
add_filter( 'post_class', 'mptt_post_class', 15, 3 );
|
|
|
56 |
// to display events with other posts on author page
|
57 |
add_filter( 'pre_get_posts', array( Post::get_instance(), 'pre_get_posts' ), 9 );
|
58 |
add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 );
|
31 |
* Install hooks
|
32 |
*/
|
33 |
public function install_hooks() {
|
34 |
+
|
35 |
// register custom post type and taxonomies
|
36 |
+
add_action( 'init', array( $this, 'init' ) );
|
37 |
+
add_action( 'wp_enqueue_scripts', array( Core::get_instance(), 'add_plugin_css' ) );
|
38 |
+
add_action( 'wp_head', array( $this, 'set_html_js_class' ) );
|
39 |
|
40 |
add_action( 'admin_init', array( $this->get_controller( 'settings' ), 'action_save' ) );
|
41 |
+
add_action( 'admin_init', array( $this, 'admin_init' ) );
|
42 |
add_action( 'admin_menu', array( $this, 'admin_menu' ) );
|
43 |
add_action( 'manage_posts_custom_column', array( $this->get( 'events' ), 'get_event_taxonomy' ) );
|
44 |
add_action( 'manage_posts_custom_column', array( $this->get( 'column' ), 'get_column_columns' ) );
|
45 |
add_action( 'current_screen', array( Core::get_instance(), 'current_screen' ) );
|
46 |
add_action( 'pre_get_posts', array( $this->get( 'column' ), 'clientarea_default_order' ), 9 );
|
47 |
+
|
48 |
//add media in frontend WP
|
49 |
+
add_action( 'wp_enqueue_scripts', array( Core::get_instance(), 'wp_enqueue_scripts' ) );
|
50 |
+
|
51 |
//add media in admin WP
|
52 |
+
add_action( 'admin_enqueue_scripts', array( Core::get_instance(), 'admin_enqueue_scripts' ) );
|
53 |
add_action( 'widgets_init', array( $this, 'register_widgets' ) );
|
54 |
+
|
55 |
// Manage event/column columns
|
56 |
add_filter( 'manage_edit-mp-event_columns', array( $this->get( 'events' ), 'set_event_columns' ) );
|
57 |
add_filter( 'manage_edit-mp-column_columns', array( $this->get( 'column' ), 'set_column_columns' ) );
|
58 |
+
|
59 |
// post_class filter
|
60 |
add_filter( 'post_class', 'mptt_post_class', 15, 3 );
|
61 |
+
|
62 |
// to display events with other posts on author page
|
63 |
add_filter( 'pre_get_posts', array( Post::get_instance(), 'pre_get_posts' ), 9 );
|
64 |
add_filter( 'plugin_row_meta', array( __CLASS__, 'plugin_row_meta' ), 10, 2 );
|
classes/class-preprocessor.php
CHANGED
@@ -2,7 +2,6 @@
|
|
2 |
|
3 |
namespace mp_timetable\plugin_core\classes;
|
4 |
|
5 |
-
use mp_timetable\classes\libs\FirePHPCore\FB;
|
6 |
use mp_timetable\classes\libs\GUMP;
|
7 |
use \Mp_Time_Table;
|
8 |
|
@@ -21,40 +20,7 @@ class Preprocessor extends GUMP {
|
|
21 |
* Install Preprocessors
|
22 |
*/
|
23 |
static function install() {
|
24 |
-
Core::include_all(Mp_Time_Table::get_plugin_part_path('classes/preprocessors'));
|
25 |
-
}
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Fatal error handler
|
29 |
-
*
|
30 |
-
* @param $buffer
|
31 |
-
*
|
32 |
-
* @return mixed
|
33 |
-
*/
|
34 |
-
static function fatal_error_handler($buffer) {
|
35 |
-
$error = error_get_last();
|
36 |
-
if (!empty($error)) {
|
37 |
-
switch ($error['type']) {
|
38 |
-
case E_WARNING:
|
39 |
-
$type = 'warning';
|
40 |
-
break;
|
41 |
-
case E_NOTICE:
|
42 |
-
$type = 'notice';
|
43 |
-
break;
|
44 |
-
case E_ERROR:
|
45 |
-
$type = 'fatal error';
|
46 |
-
break;
|
47 |
-
case E_USER_NOTICE:
|
48 |
-
$type = 'core error';
|
49 |
-
break;
|
50 |
-
default :
|
51 |
-
$type = 'error';
|
52 |
-
break;
|
53 |
-
}
|
54 |
-
FB::error($_REQUEST, "$type REQUEST");
|
55 |
-
FB::error($error, $type);
|
56 |
-
}
|
57 |
-
return $buffer;
|
58 |
}
|
59 |
|
60 |
/**
|
2 |
|
3 |
namespace mp_timetable\plugin_core\classes;
|
4 |
|
|
|
5 |
use mp_timetable\classes\libs\GUMP;
|
6 |
use \Mp_Time_Table;
|
7 |
|
20 |
* Install Preprocessors
|
21 |
*/
|
22 |
static function install() {
|
23 |
+
Core::include_all( Mp_Time_Table::get_plugin_part_path('classes/preprocessors') );
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
/**
|
classes/controllers/class-controller-events.php
CHANGED
@@ -50,7 +50,7 @@ class Controller_Events extends Controller {
|
|
50 |
wp_send_json_success(array('status' => $result));
|
51 |
}
|
52 |
} else {
|
53 |
-
wp_die('Access denied');
|
54 |
}
|
55 |
}
|
56 |
|
@@ -70,7 +70,7 @@ class Controller_Events extends Controller {
|
|
70 |
wp_send_json_error(array('status' => false));
|
71 |
}
|
72 |
} else {
|
73 |
-
wp_die('Access denied');
|
74 |
}
|
75 |
}
|
76 |
|
@@ -107,7 +107,7 @@ class Controller_Events extends Controller {
|
|
107 |
wp_send_json_success(array('data' => $result));
|
108 |
}
|
109 |
} else {
|
110 |
-
wp_die('Access denied');
|
111 |
}
|
112 |
}
|
113 |
}
|
50 |
wp_send_json_success(array('status' => $result));
|
51 |
}
|
52 |
} else {
|
53 |
+
wp_die( sprintf( 'Access denied, %s, %s', __FUNCTION__, basename( __FILE__ ) ) );
|
54 |
}
|
55 |
}
|
56 |
|
70 |
wp_send_json_error(array('status' => false));
|
71 |
}
|
72 |
} else {
|
73 |
+
wp_die( sprintf( 'Access denied, %s, %s', __FUNCTION__, basename( __FILE__ ) ) );
|
74 |
}
|
75 |
}
|
76 |
|
107 |
wp_send_json_success(array('data' => $result));
|
108 |
}
|
109 |
} else {
|
110 |
+
wp_die( sprintf( 'Access denied, %s, %s', __FUNCTION__, basename( __FILE__ ) ) );
|
111 |
}
|
112 |
}
|
113 |
}
|
classes/controllers/class-controller-popup.php
CHANGED
@@ -26,17 +26,14 @@ class Controller_Popup extends Controller {
|
|
26 |
*/
|
27 |
public function action_get_popup_html_content() {
|
28 |
|
29 |
-
if (
|
30 |
|
31 |
$this->data['column'] = $this->get('column')->get_all_column();
|
32 |
$this->data['events'] = $this->get('events')->get_all_events();
|
33 |
$this->data['category'] = get_terms('mp-event_category', 'orderby=count&hide_empty=0');
|
34 |
$data["html"] = $this->get_view()->render_html("popup/index", $this->data, false);
|
35 |
$this->send_json(Model::get_instance()->get_arr($data, true));
|
36 |
-
} else {
|
37 |
-
wp_die('Access denied');
|
38 |
}
|
39 |
}
|
40 |
|
41 |
-
|
42 |
}
|
26 |
*/
|
27 |
public function action_get_popup_html_content() {
|
28 |
|
29 |
+
if ( is_user_logged_in() ) {
|
30 |
|
31 |
$this->data['column'] = $this->get('column')->get_all_column();
|
32 |
$this->data['events'] = $this->get('events')->get_all_events();
|
33 |
$this->data['category'] = get_terms('mp-event_category', 'orderby=count&hide_empty=0');
|
34 |
$data["html"] = $this->get_view()->render_html("popup/index", $this->data, false);
|
35 |
$this->send_json(Model::get_instance()->get_arr($data, true));
|
|
|
|
|
36 |
}
|
37 |
}
|
38 |
|
|
|
39 |
}
|
classes/controllers/class-controller-settings.php
CHANGED
@@ -35,8 +35,9 @@ class Controller_Settings extends Controller {
|
|
35 |
$theme_supports = $this->get('Settings')->is_theme_supports();
|
36 |
|
37 |
View::get_instance()->render_html('../templates/settings/general', array('settings' => $data, 'theme_supports' => $theme_supports));
|
|
|
38 |
} else {
|
39 |
-
wp_die('Access denied');
|
40 |
}
|
41 |
}
|
42 |
|
@@ -45,32 +46,27 @@ class Controller_Settings extends Controller {
|
|
45 |
*/
|
46 |
public function action_save() {
|
47 |
|
48 |
-
$
|
|
|
49 |
|
50 |
-
if ( current_user_can('manage_options') ) {
|
51 |
$redirect = Settings::get_instance()->save_settings();
|
52 |
-
} else {
|
53 |
-
wp_die('Access denied');
|
54 |
-
}
|
55 |
|
56 |
-
|
57 |
-
wp_redirect(
|
58 |
add_query_arg(
|
59 |
array(
|
60 |
'page' => $_GET['page'],
|
61 |
'settings-updated' => 'true'
|
62 |
-
)
|
|
|
63 |
)
|
64 |
);
|
65 |
-
|
66 |
-
die();
|
67 |
}
|
68 |
|
69 |
/**
|
70 |
* Show success message
|
71 |
*/
|
72 |
-
if (isset($_GET['settings-updated']) && ($_GET['settings-updated'] == TRUE)) {
|
73 |
-
$_GET['settings-updated'] = false;
|
74 |
add_settings_error('mpTimetableSettings', esc_attr('settings_updated'), __('Settings saved.', 'mp-timetable'), 'updated');
|
75 |
}
|
76 |
}
|
35 |
$theme_supports = $this->get('Settings')->is_theme_supports();
|
36 |
|
37 |
View::get_instance()->render_html('../templates/settings/general', array('settings' => $data, 'theme_supports' => $theme_supports));
|
38 |
+
|
39 |
} else {
|
40 |
+
wp_die( sprintf( 'Access denied, %s, %s', __FUNCTION__, basename( __FILE__ ) ) );
|
41 |
}
|
42 |
}
|
43 |
|
46 |
*/
|
47 |
public function action_save() {
|
48 |
|
49 |
+
if ( isset( $_POST['mp-timetable-save-settings'] ) &&
|
50 |
+
wp_verify_nonce( $_POST['mp-timetable-save-settings'], 'mp_timetable_nonce_settings') ) {
|
51 |
|
|
|
52 |
$redirect = Settings::get_instance()->save_settings();
|
|
|
|
|
|
|
53 |
|
54 |
+
wp_safe_redirect(
|
|
|
55 |
add_query_arg(
|
56 |
array(
|
57 |
'page' => $_GET['page'],
|
58 |
'settings-updated' => 'true'
|
59 |
+
),
|
60 |
+
admin_url( 'edit.php?post_type=mp-event')
|
61 |
)
|
62 |
);
|
63 |
+
exit;
|
|
|
64 |
}
|
65 |
|
66 |
/**
|
67 |
* Show success message
|
68 |
*/
|
69 |
+
if ( isset( $_GET['settings-updated'] ) && ( $_GET['settings-updated'] == TRUE ) ) {
|
|
|
70 |
add_settings_error('mpTimetableSettings', esc_attr('settings_updated'), __('Settings saved.', 'mp-timetable'), 'updated');
|
71 |
}
|
72 |
}
|
classes/libs/FirePHPCore/FirePHP.class.php
DELETED
@@ -1,1785 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
namespace mp_timetable\classes\libs\FirePHPCore;
|
3 |
-
/**
|
4 |
-
* *** BEGIN LICENSE BLOCK *****
|
5 |
-
*
|
6 |
-
* This file is part of FirePHP (http://www.firephp.org/).
|
7 |
-
*
|
8 |
-
* Software License Agreement (New BSD License)
|
9 |
-
*
|
10 |
-
* Copyright (c) 2006-2010, Christoph Dorn
|
11 |
-
* All rights reserved.
|
12 |
-
*
|
13 |
-
* Redistribution and use in source and binary forms, with or without modification,
|
14 |
-
* are permitted provided that the following conditions are met:
|
15 |
-
*
|
16 |
-
* * Redistributions of source code must retain the above copyright notice,
|
17 |
-
* this list of conditions and the following disclaimer.
|
18 |
-
*
|
19 |
-
* * Redistributions in binary form must reproduce the above copyright notice,
|
20 |
-
* this list of conditions and the following disclaimer in the documentation
|
21 |
-
* and/or other materials provided with the distribution.
|
22 |
-
*
|
23 |
-
* * Neither the name of Christoph Dorn nor the names of its
|
24 |
-
* contributors may be used to endorse or promote products derived from this
|
25 |
-
* software without specific prior written permission.
|
26 |
-
*
|
27 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
28 |
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
29 |
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
30 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
31 |
-
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
32 |
-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
33 |
-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
34 |
-
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
35 |
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
36 |
-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
37 |
-
*
|
38 |
-
* ***** END LICENSE BLOCK *****
|
39 |
-
*
|
40 |
-
* @copyright Copyright (C) 2007-2009 Christoph Dorn
|
41 |
-
* @author Christoph Dorn <christoph@christophdorn.com>
|
42 |
-
* @license http://www.opensource.org/licenses/bsd-license.php
|
43 |
-
* @package FirePHPCore
|
44 |
-
*/
|
45 |
-
|
46 |
-
/**
|
47 |
-
* @see http://code.google.com/p/firephp/issues/detail?id=112
|
48 |
-
*/
|
49 |
-
if (!defined('E_STRICT')) {
|
50 |
-
define('E_STRICT', 2048);
|
51 |
-
}
|
52 |
-
if (!defined('E_RECOVERABLE_ERROR')) {
|
53 |
-
define('E_RECOVERABLE_ERROR', 4096);
|
54 |
-
}
|
55 |
-
if (!defined('E_DEPRECATED')) {
|
56 |
-
define('E_DEPRECATED', 8192);
|
57 |
-
}
|
58 |
-
if (!defined('E_USER_DEPRECATED')) {
|
59 |
-
define('E_USER_DEPRECATED', 16384);
|
60 |
-
}
|
61 |
-
|
62 |
-
/**
|
63 |
-
* Sends the given data to the FirePHP Firefox Extension.
|
64 |
-
* The data can be displayed in the Firebug Console or in the
|
65 |
-
* "Server" request tab.
|
66 |
-
*
|
67 |
-
* For more information see: http://www.firephp.org/
|
68 |
-
*
|
69 |
-
* @copyright Copyright (C) 2007-2009 Christoph Dorn
|
70 |
-
* @author Christoph Dorn <christoph@christophdorn.com>
|
71 |
-
* @license http://www.opensource.org/licenses/bsd-license.php
|
72 |
-
* @package FirePHPCore
|
73 |
-
*/
|
74 |
-
class FirePHP {
|
75 |
-
|
76 |
-
/**
|
77 |
-
* FirePHP version
|
78 |
-
*
|
79 |
-
* @var string
|
80 |
-
*/
|
81 |
-
const VERSION = '0.3'; // @pinf replace '0.3' with '%%package.version%%'
|
82 |
-
|
83 |
-
/**
|
84 |
-
* Firebug LOG level
|
85 |
-
*
|
86 |
-
* Logs a message to firebug console.
|
87 |
-
*
|
88 |
-
* @var string
|
89 |
-
*/
|
90 |
-
const LOG = 'LOG';
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Firebug INFO level
|
94 |
-
*
|
95 |
-
* Logs a message to firebug console and displays an info icon before the message.
|
96 |
-
*
|
97 |
-
* @var string
|
98 |
-
*/
|
99 |
-
const INFO = 'INFO';
|
100 |
-
|
101 |
-
/**
|
102 |
-
* Firebug WARN level
|
103 |
-
*
|
104 |
-
* Logs a message to firebug console, displays an warning icon before the message and colors the line turquoise.
|
105 |
-
*
|
106 |
-
* @var string
|
107 |
-
*/
|
108 |
-
const WARN = 'WARN';
|
109 |
-
|
110 |
-
/**
|
111 |
-
* Firebug ERROR level
|
112 |
-
*
|
113 |
-
* Logs a message to firebug console, displays an error icon before the message and colors the line yellow. Also increments the firebug error count.
|
114 |
-
*
|
115 |
-
* @var string
|
116 |
-
*/
|
117 |
-
const ERROR = 'ERROR';
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Dumps a variable to firebug's server panel
|
121 |
-
*
|
122 |
-
* @var string
|
123 |
-
*/
|
124 |
-
const DUMP = 'DUMP';
|
125 |
-
|
126 |
-
/**
|
127 |
-
* Displays a stack trace in firebug console
|
128 |
-
*
|
129 |
-
* @var string
|
130 |
-
*/
|
131 |
-
const TRACE = 'TRACE';
|
132 |
-
|
133 |
-
/**
|
134 |
-
* Displays an exception in firebug console
|
135 |
-
*
|
136 |
-
* Increments the firebug error count.
|
137 |
-
*
|
138 |
-
* @var string
|
139 |
-
*/
|
140 |
-
const EXCEPTION = 'EXCEPTION';
|
141 |
-
|
142 |
-
/**
|
143 |
-
* Displays an table in firebug console
|
144 |
-
*
|
145 |
-
* @var string
|
146 |
-
*/
|
147 |
-
const TABLE = 'TABLE';
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Starts a group in firebug console
|
151 |
-
*
|
152 |
-
* @var string
|
153 |
-
*/
|
154 |
-
const GROUP_START = 'GROUP_START';
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Ends a group in firebug console
|
158 |
-
*
|
159 |
-
* @var string
|
160 |
-
*/
|
161 |
-
const GROUP_END = 'GROUP_END';
|
162 |
-
|
163 |
-
/**
|
164 |
-
* Singleton instance of FirePHP
|
165 |
-
*
|
166 |
-
* @var FirePHP
|
167 |
-
*/
|
168 |
-
protected static $instance = null;
|
169 |
-
|
170 |
-
/**
|
171 |
-
* Flag whether we are logging from within the exception handler
|
172 |
-
*
|
173 |
-
* @var boolean
|
174 |
-
*/
|
175 |
-
protected $inExceptionHandler = false;
|
176 |
-
|
177 |
-
/**
|
178 |
-
* Flag whether to throw PHP errors that have been converted to ErrorExceptions
|
179 |
-
*
|
180 |
-
* @var boolean
|
181 |
-
*/
|
182 |
-
protected $throwErrorExceptions = true;
|
183 |
-
|
184 |
-
/**
|
185 |
-
* Flag whether to convert PHP assertion errors to Exceptions
|
186 |
-
*
|
187 |
-
* @var boolean
|
188 |
-
*/
|
189 |
-
protected $convertAssertionErrorsToExceptions = true;
|
190 |
-
|
191 |
-
/**
|
192 |
-
* Flag whether to throw PHP assertion errors that have been converted to Exceptions
|
193 |
-
*
|
194 |
-
* @var boolean
|
195 |
-
*/
|
196 |
-
protected $throwAssertionExceptions = false;
|
197 |
-
|
198 |
-
/**
|
199 |
-
* Wildfire protocol message index
|
200 |
-
*
|
201 |
-
* @var int
|
202 |
-
*/
|
203 |
-
protected $messageIndex = 1;
|
204 |
-
|
205 |
-
/**
|
206 |
-
* Options for the library
|
207 |
-
*
|
208 |
-
* @var array
|
209 |
-
*/
|
210 |
-
protected $options = array('maxDepth' => 10,
|
211 |
-
'maxObjectDepth' => 5,
|
212 |
-
'maxArrayDepth' => 5,
|
213 |
-
'useNativeJsonEncode' => true,
|
214 |
-
'includeLineNumbers' => true);
|
215 |
-
|
216 |
-
/**
|
217 |
-
* Filters used to exclude object members when encoding
|
218 |
-
*
|
219 |
-
* @var array
|
220 |
-
*/
|
221 |
-
protected $objectFilters = array(
|
222 |
-
'firephp' => array('objectStack', 'instance', 'json_objectStack'),
|
223 |
-
'firephp_test_class' => array('objectStack', 'instance', 'json_objectStack')
|
224 |
-
);
|
225 |
-
|
226 |
-
/**
|
227 |
-
* A stack of objects used to detect recursion during object encoding
|
228 |
-
*
|
229 |
-
* @var object
|
230 |
-
*/
|
231 |
-
protected $objectStack = array();
|
232 |
-
|
233 |
-
/**
|
234 |
-
* Flag to enable/disable logging
|
235 |
-
*
|
236 |
-
* @var boolean
|
237 |
-
*/
|
238 |
-
protected $enabled = true;
|
239 |
-
|
240 |
-
/**
|
241 |
-
* The insight console to log to if applicable
|
242 |
-
*
|
243 |
-
* @var object
|
244 |
-
*/
|
245 |
-
protected $logToInsightConsole = null;
|
246 |
-
|
247 |
-
/**
|
248 |
-
* When the object gets serialized only include specific object members.
|
249 |
-
*
|
250 |
-
* @return array
|
251 |
-
*/
|
252 |
-
public function __sleep()
|
253 |
-
{
|
254 |
-
return array('options','objectFilters','enabled');
|
255 |
-
}
|
256 |
-
|
257 |
-
/**
|
258 |
-
* Gets singleton instance of FirePHP
|
259 |
-
*
|
260 |
-
* @param boolean $AutoCreate
|
261 |
-
* @return FirePHP
|
262 |
-
*/
|
263 |
-
public static function getInstance($AutoCreate = false)
|
264 |
-
{
|
265 |
-
if ($AutoCreate===true && !self::$instance) {
|
266 |
-
self::init();
|
267 |
-
}
|
268 |
-
return self::$instance;
|
269 |
-
}
|
270 |
-
|
271 |
-
/**
|
272 |
-
* Creates FirePHP object and stores it for singleton access
|
273 |
-
*
|
274 |
-
* @return FirePHP
|
275 |
-
*/
|
276 |
-
public static function init()
|
277 |
-
{
|
278 |
-
return self::setInstance(new self());
|
279 |
-
}
|
280 |
-
|
281 |
-
/**
|
282 |
-
* Set the instance of the FirePHP singleton
|
283 |
-
*
|
284 |
-
* @param FirePHP $instance The FirePHP object instance
|
285 |
-
* @return FirePHP
|
286 |
-
*/
|
287 |
-
public static function setInstance($instance)
|
288 |
-
{
|
289 |
-
return self::$instance = $instance;
|
290 |
-
}
|
291 |
-
|
292 |
-
/**
|
293 |
-
* Set an Insight console to direct all logging calls to
|
294 |
-
*
|
295 |
-
* @param object $console The console object to log to
|
296 |
-
* @return void
|
297 |
-
*/
|
298 |
-
public function setLogToInsightConsole($console)
|
299 |
-
{
|
300 |
-
if(is_string($console)) {
|
301 |
-
if(get_class($this)!='FirePHP_Insight' && !is_subclass_of($this, 'FirePHP_Insight')) {
|
302 |
-
throw new Exception('FirePHP instance not an instance or subclass of FirePHP_Insight!');
|
303 |
-
}
|
304 |
-
$this->logToInsightConsole = $this->to('request')->console($console);
|
305 |
-
} else {
|
306 |
-
$this->logToInsightConsole = $console;
|
307 |
-
}
|
308 |
-
}
|
309 |
-
|
310 |
-
/**
|
311 |
-
* Enable and disable logging to Firebug
|
312 |
-
*
|
313 |
-
* @param boolean $Enabled TRUE to enable, FALSE to disable
|
314 |
-
* @return void
|
315 |
-
*/
|
316 |
-
public function setEnabled($Enabled)
|
317 |
-
{
|
318 |
-
$this->enabled = $Enabled;
|
319 |
-
}
|
320 |
-
|
321 |
-
/**
|
322 |
-
* Check if logging is enabled
|
323 |
-
*
|
324 |
-
* @return boolean TRUE if enabled
|
325 |
-
*/
|
326 |
-
public function getEnabled()
|
327 |
-
{
|
328 |
-
return $this->enabled;
|
329 |
-
}
|
330 |
-
|
331 |
-
/**
|
332 |
-
* Specify a filter to be used when encoding an object
|
333 |
-
*
|
334 |
-
* Filters are used to exclude object members.
|
335 |
-
*
|
336 |
-
* @param string $Class The class name of the object
|
337 |
-
* @param array $Filter An array of members to exclude
|
338 |
-
* @return void
|
339 |
-
*/
|
340 |
-
public function setObjectFilter($Class, $Filter)
|
341 |
-
{
|
342 |
-
$this->objectFilters[strtolower($Class)] = $Filter;
|
343 |
-
}
|
344 |
-
|
345 |
-
/**
|
346 |
-
* Set some options for the library
|
347 |
-
*
|
348 |
-
* Options:
|
349 |
-
* - maxDepth: The maximum depth to traverse (default: 10)
|
350 |
-
* - maxObjectDepth: The maximum depth to traverse objects (default: 5)
|
351 |
-
* - maxArrayDepth: The maximum depth to traverse arrays (default: 5)
|
352 |
-
* - useNativeJsonEncode: If true will use json_encode() (default: true)
|
353 |
-
* - includeLineNumbers: If true will include line numbers and filenames (default: true)
|
354 |
-
*
|
355 |
-
* @param array $Options The options to be set
|
356 |
-
* @return void
|
357 |
-
*/
|
358 |
-
public function setOptions($Options)
|
359 |
-
{
|
360 |
-
$this->options = array_merge($this->options,$Options);
|
361 |
-
}
|
362 |
-
|
363 |
-
/**
|
364 |
-
* Get options from the library
|
365 |
-
*
|
366 |
-
* @return array The currently set options
|
367 |
-
*/
|
368 |
-
public function getOptions()
|
369 |
-
{
|
370 |
-
return $this->options;
|
371 |
-
}
|
372 |
-
|
373 |
-
/**
|
374 |
-
* Set an option for the library
|
375 |
-
*
|
376 |
-
* @param string $Name
|
377 |
-
* @param mixed $Value
|
378 |
-
* @throws Exception
|
379 |
-
* @return void
|
380 |
-
*/
|
381 |
-
public function setOption($Name, $Value)
|
382 |
-
{
|
383 |
-
if (!isset($this->options[$Name])) {
|
384 |
-
throw $this->newException('Unknown option: ' . $Name);
|
385 |
-
}
|
386 |
-
$this->options[$Name] = $Value;
|
387 |
-
}
|
388 |
-
|
389 |
-
/**
|
390 |
-
* Get an option from the library
|
391 |
-
*
|
392 |
-
* @param string $Name
|
393 |
-
* @throws Exception
|
394 |
-
* @return mixed
|
395 |
-
*/
|
396 |
-
public function getOption($Name)
|
397 |
-
{
|
398 |
-
if (!isset($this->options[$Name])) {
|
399 |
-
throw $this->newException('Unknown option: ' . $Name);
|
400 |
-
}
|
401 |
-
return $this->options[$Name];
|
402 |
-
}
|
403 |
-
|
404 |
-
/**
|
405 |
-
* Register FirePHP as your error handler
|
406 |
-
*
|
407 |
-
* Will throw exceptions for each php error.
|
408 |
-
*
|
409 |
-
* @return mixed Returns a string containing the previously defined error handler (if any)
|
410 |
-
*/
|
411 |
-
public function registerErrorHandler($throwErrorExceptions = false)
|
412 |
-
{
|
413 |
-
//NOTE: The following errors will not be caught by this error handler:
|
414 |
-
// E_ERROR, E_PARSE, E_CORE_ERROR,
|
415 |
-
// E_CORE_WARNING, E_COMPILE_ERROR,
|
416 |
-
// E_COMPILE_WARNING, E_STRICT
|
417 |
-
|
418 |
-
$this->throwErrorExceptions = $throwErrorExceptions;
|
419 |
-
|
420 |
-
return set_error_handler(array($this,'errorHandler'));
|
421 |
-
}
|
422 |
-
|
423 |
-
/**
|
424 |
-
* FirePHP's error handler
|
425 |
-
*
|
426 |
-
* Throws exception for each php error that will occur.
|
427 |
-
*
|
428 |
-
* @param int $errno
|
429 |
-
* @param string $errstr
|
430 |
-
* @param string $errfile
|
431 |
-
* @param int $errline
|
432 |
-
* @param array $errcontext
|
433 |
-
*/
|
434 |
-
public function errorHandler($errno, $errstr, $errfile, $errline, $errcontext)
|
435 |
-
{
|
436 |
-
// Don't throw exception if error reporting is switched off
|
437 |
-
if (error_reporting() == 0) {
|
438 |
-
return;
|
439 |
-
}
|
440 |
-
// Only throw exceptions for errors we are asking for
|
441 |
-
if (error_reporting() & $errno) {
|
442 |
-
|
443 |
-
$exception = new ErrorException($errstr, 0, $errno, $errfile, $errline);
|
444 |
-
if ($this->throwErrorExceptions) {
|
445 |
-
throw $exception;
|
446 |
-
} else {
|
447 |
-
$this->fb($exception);
|
448 |
-
}
|
449 |
-
}
|
450 |
-
}
|
451 |
-
|
452 |
-
/**
|
453 |
-
* Register FirePHP as your exception handler
|
454 |
-
*
|
455 |
-
* @return mixed Returns the name of the previously defined exception handler,
|
456 |
-
* or NULL on error.
|
457 |
-
* If no previous handler was defined, NULL is also returned.
|
458 |
-
*/
|
459 |
-
public function registerExceptionHandler()
|
460 |
-
{
|
461 |
-
return set_exception_handler(array($this,'exceptionHandler'));
|
462 |
-
}
|
463 |
-
|
464 |
-
/**
|
465 |
-
* FirePHP's exception handler
|
466 |
-
*
|
467 |
-
* Logs all exceptions to your firebug console and then stops the script.
|
468 |
-
*
|
469 |
-
* @param Exception $Exception
|
470 |
-
* @throws Exception
|
471 |
-
*/
|
472 |
-
function exceptionHandler($Exception)
|
473 |
-
{
|
474 |
-
|
475 |
-
$this->inExceptionHandler = true;
|
476 |
-
|
477 |
-
header('HTTP/1.1 500 Internal Server Error');
|
478 |
-
|
479 |
-
try {
|
480 |
-
$this->fb($Exception);
|
481 |
-
} catch (Exception $e) {
|
482 |
-
echo 'We had an exception: ' . $e;
|
483 |
-
}
|
484 |
-
$this->inExceptionHandler = false;
|
485 |
-
}
|
486 |
-
|
487 |
-
/**
|
488 |
-
* Register FirePHP driver as your assert callback
|
489 |
-
*
|
490 |
-
* @param boolean $convertAssertionErrorsToExceptions
|
491 |
-
* @param boolean $throwAssertionExceptions
|
492 |
-
* @return mixed Returns the original setting or FALSE on errors
|
493 |
-
*/
|
494 |
-
public function registerAssertionHandler($convertAssertionErrorsToExceptions = true, $throwAssertionExceptions = false)
|
495 |
-
{
|
496 |
-
$this->convertAssertionErrorsToExceptions = $convertAssertionErrorsToExceptions;
|
497 |
-
$this->throwAssertionExceptions = $throwAssertionExceptions;
|
498 |
-
|
499 |
-
if ($throwAssertionExceptions && !$convertAssertionErrorsToExceptions) {
|
500 |
-
throw $this->newException('Cannot throw assertion exceptions as assertion errors are not being converted to exceptions!');
|
501 |
-
}
|
502 |
-
|
503 |
-
return assert_options(ASSERT_CALLBACK, array($this, 'assertionHandler'));
|
504 |
-
}
|
505 |
-
|
506 |
-
/**
|
507 |
-
* FirePHP's assertion handler
|
508 |
-
*
|
509 |
-
* Logs all assertions to your firebug console and then stops the script.
|
510 |
-
*
|
511 |
-
* @param string $file File source of assertion
|
512 |
-
* @param int $line Line source of assertion
|
513 |
-
* @param mixed $code Assertion code
|
514 |
-
*/
|
515 |
-
public function assertionHandler($file, $line, $code)
|
516 |
-
{
|
517 |
-
if ($this->convertAssertionErrorsToExceptions) {
|
518 |
-
|
519 |
-
$exception = new ErrorException('Assertion Failed - Code[ '.$code.' ]', 0, null, $file, $line);
|
520 |
-
|
521 |
-
if ($this->throwAssertionExceptions) {
|
522 |
-
throw $exception;
|
523 |
-
} else {
|
524 |
-
$this->fb($exception);
|
525 |
-
}
|
526 |
-
|
527 |
-
} else {
|
528 |
-
$this->fb($code, 'Assertion Failed', FirePHP::ERROR, array('File'=>$file,'Line'=>$line));
|
529 |
-
}
|
530 |
-
}
|
531 |
-
|
532 |
-
/**
|
533 |
-
* Start a group for following messages.
|
534 |
-
*
|
535 |
-
* Options:
|
536 |
-
* Collapsed: [true|false]
|
537 |
-
* Color: [#RRGGBB|ColorName]
|
538 |
-
*
|
539 |
-
* @param string $Name
|
540 |
-
* @param array $Options OPTIONAL Instructions on how to log the group
|
541 |
-
* @return true
|
542 |
-
* @throws Exception
|
543 |
-
*/
|
544 |
-
public function group($Name, $Options = null)
|
545 |
-
{
|
546 |
-
|
547 |
-
if (!$Name) {
|
548 |
-
throw $this->newException('You must specify a label for the group!');
|
549 |
-
}
|
550 |
-
|
551 |
-
if ($Options) {
|
552 |
-
if (!is_array($Options)) {
|
553 |
-
throw $this->newException('Options must be defined as an array!');
|
554 |
-
}
|
555 |
-
if (array_key_exists('Collapsed', $Options)) {
|
556 |
-
$Options['Collapsed'] = ($Options['Collapsed'])?'true':'false';
|
557 |
-
}
|
558 |
-
}
|
559 |
-
|
560 |
-
return $this->fb(null, $Name, FirePHP::GROUP_START, $Options);
|
561 |
-
}
|
562 |
-
|
563 |
-
/**
|
564 |
-
* Ends a group you have started before
|
565 |
-
*
|
566 |
-
* @return true
|
567 |
-
* @throws Exception
|
568 |
-
*/
|
569 |
-
public function groupEnd()
|
570 |
-
{
|
571 |
-
return $this->fb(null, null, FirePHP::GROUP_END);
|
572 |
-
}
|
573 |
-
|
574 |
-
/**
|
575 |
-
* Log object with label to firebug console
|
576 |
-
*
|
577 |
-
* @see FirePHP::LOG
|
578 |
-
* @param mixes $Object
|
579 |
-
* @param string $Label
|
580 |
-
* @return true
|
581 |
-
* @throws Exception
|
582 |
-
*/
|
583 |
-
public function log($Object, $Label = null, $Options = array())
|
584 |
-
{
|
585 |
-
return $this->fb($Object, $Label, FirePHP::LOG, $Options);
|
586 |
-
}
|
587 |
-
|
588 |
-
/**
|
589 |
-
* Log object with label to firebug console
|
590 |
-
*
|
591 |
-
* @see FirePHP::INFO
|
592 |
-
* @param mixes $Object
|
593 |
-
* @param string $Label
|
594 |
-
* @return true
|
595 |
-
* @throws Exception
|
596 |
-
*/
|
597 |
-
public function info($Object, $Label = null, $Options = array())
|
598 |
-
{
|
599 |
-
return $this->fb($Object, $Label, FirePHP::INFO, $Options);
|
600 |
-
}
|
601 |
-
|
602 |
-
/**
|
603 |
-
* Log object with label to firebug console
|
604 |
-
*
|
605 |
-
* @see FirePHP::WARN
|
606 |
-
* @param mixes $Object
|
607 |
-
* @param string $Label
|
608 |
-
* @return true
|
609 |
-
* @throws Exception
|
610 |
-
*/
|
611 |
-
public function warn($Object, $Label = null, $Options = array())
|
612 |
-
{
|
613 |
-
return $this->fb($Object, $Label, FirePHP::WARN, $Options);
|
614 |
-
}
|
615 |
-
|
616 |
-
/**
|
617 |
-
* Log object with label to firebug console
|
618 |
-
*
|
619 |
-
* @see FirePHP::ERROR
|
620 |
-
* @param mixes $Object
|
621 |
-
* @param string $Label
|
622 |
-
* @return true
|
623 |
-
* @throws Exception
|
624 |
-
*/
|
625 |
-
public function error($Object, $Label = null, $Options = array())
|
626 |
-
{
|
627 |
-
return $this->fb($Object, $Label, FirePHP::ERROR, $Options);
|
628 |
-
}
|
629 |
-
|
630 |
-
/**
|
631 |
-
* Dumps key and variable to firebug server panel
|
632 |
-
*
|
633 |
-
* @see FirePHP::DUMP
|
634 |
-
* @param string $Key
|
635 |
-
* @param mixed $Variable
|
636 |
-
* @return true
|
637 |
-
* @throws Exception
|
638 |
-
*/
|
639 |
-
public function dump($Key, $Variable, $Options = array())
|
640 |
-
{
|
641 |
-
if (!is_string($Key)) {
|
642 |
-
throw $this->newException('Key passed to dump() is not a string');
|
643 |
-
}
|
644 |
-
if (strlen($Key)>100) {
|
645 |
-
throw $this->newException('Key passed to dump() is longer than 100 characters');
|
646 |
-
}
|
647 |
-
if (!preg_match_all('/^[a-zA-Z0-9-_\.:]*$/', $Key, $m)) {
|
648 |
-
throw $this->newException('Key passed to dump() contains invalid characters [a-zA-Z0-9-_\.:]');
|
649 |
-
}
|
650 |
-
return $this->fb($Variable, $Key, FirePHP::DUMP, $Options);
|
651 |
-
}
|
652 |
-
|
653 |
-
/**
|
654 |
-
* Log a trace in the firebug console
|
655 |
-
*
|
656 |
-
* @see FirePHP::TRACE
|
657 |
-
* @param string $Label
|
658 |
-
* @return true
|
659 |
-
* @throws Exception
|
660 |
-
*/
|
661 |
-
public function trace($Label)
|
662 |
-
{
|
663 |
-
return $this->fb($Label, FirePHP::TRACE);
|
664 |
-
}
|
665 |
-
|
666 |
-
/**
|
667 |
-
* Log a table in the firebug console
|
668 |
-
*
|
669 |
-
* @see FirePHP::TABLE
|
670 |
-
* @param string $Label
|
671 |
-
* @param string $Table
|
672 |
-
* @return true
|
673 |
-
* @throws Exception
|
674 |
-
*/
|
675 |
-
public function table($Label, $Table, $Options = array())
|
676 |
-
{
|
677 |
-
return $this->fb($Table, $Label, FirePHP::TABLE, $Options);
|
678 |
-
}
|
679 |
-
|
680 |
-
/**
|
681 |
-
* Insight API wrapper
|
682 |
-
*
|
683 |
-
* @see Insight_Helper::to()
|
684 |
-
*/
|
685 |
-
public static function to()
|
686 |
-
{
|
687 |
-
$instance = self::getInstance();
|
688 |
-
if (!method_exists($instance, "_to")) {
|
689 |
-
throw new Exception("FirePHP::to() implementation not loaded");
|
690 |
-
}
|
691 |
-
$args = func_get_args();
|
692 |
-
return call_user_func_array(array($instance, '_to'), $args);
|
693 |
-
}
|
694 |
-
|
695 |
-
/**
|
696 |
-
* Insight API wrapper
|
697 |
-
*
|
698 |
-
* @see Insight_Helper::plugin()
|
699 |
-
*/
|
700 |
-
public static function plugin()
|
701 |
-
{
|
702 |
-
$instance = self::getInstance();
|
703 |
-
if (!method_exists($instance, "_plugin")) {
|
704 |
-
throw new Exception("FirePHP::plugin() implementation not loaded");
|
705 |
-
}
|
706 |
-
$args = func_get_args();
|
707 |
-
return call_user_func_array(array($instance, '_plugin'), $args);
|
708 |
-
}
|
709 |
-
|
710 |
-
/**
|
711 |
-
* Check if FirePHP is installed on client
|
712 |
-
*
|
713 |
-
* @return boolean
|
714 |
-
*/
|
715 |
-
public function detectClientExtension()
|
716 |
-
{
|
717 |
-
// Check if FirePHP is installed on client via User-Agent header
|
718 |
-
if (@preg_match_all('/\sFirePHP\/([\.\d]*)\s?/si',$this->getUserAgent(),$m) &&
|
719 |
-
version_compare($m[1][0],'0.0.6','>=')) {
|
720 |
-
return true;
|
721 |
-
} else
|
722 |
-
// Check if FirePHP is installed on client via X-FirePHP-Version header
|
723 |
-
if (@preg_match_all('/^([\.\d]*)$/si',$this->getRequestHeader("X-FirePHP-Version"),$m) &&
|
724 |
-
version_compare($m[1][0],'0.0.6','>=')) {
|
725 |
-
return true;
|
726 |
-
}
|
727 |
-
return false;
|
728 |
-
}
|
729 |
-
|
730 |
-
/**
|
731 |
-
* Log varible to Firebug
|
732 |
-
*
|
733 |
-
* @see http://www.firephp.org/Wiki/Reference/Fb
|
734 |
-
* @param mixed $Object The variable to be logged
|
735 |
-
* @return true Return TRUE if message was added to headers, FALSE otherwise
|
736 |
-
* @throws Exception
|
737 |
-
*/
|
738 |
-
public function fb($Object)
|
739 |
-
{
|
740 |
-
if($this instanceof FirePHP_Insight && method_exists($this, '_logUpgradeClientMessage')) {
|
741 |
-
if(!FirePHP_Insight::$upgradeClientMessageLogged) { // avoid infinite recursion as _logUpgradeClientMessage() logs a message
|
742 |
-
$this->_logUpgradeClientMessage();
|
743 |
-
}
|
744 |
-
}
|
745 |
-
|
746 |
-
static $insightGroupStack = array();
|
747 |
-
|
748 |
-
if (!$this->getEnabled()) {
|
749 |
-
return false;
|
750 |
-
}
|
751 |
-
|
752 |
-
if ($this->headersSent($filename, $linenum)) {
|
753 |
-
// If we are logging from within the exception handler we cannot throw another exception
|
754 |
-
if ($this->inExceptionHandler) {
|
755 |
-
// Simply echo the error out to the page
|
756 |
-
echo '<div style="border: 2px solid red; font-family: Arial; font-size: 12px; background-color: lightgray; padding: 5px;"><span style="color: red; font-weight: bold;">FirePHP ERROR:</span> Headers already sent in <b>'.$filename.'</b> on line <b>'.$linenum.'</b>. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.</div>';
|
757 |
-
} else {
|
758 |
-
throw $this->newException('Headers already sent in '.$filename.' on line '.$linenum.'. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.');
|
759 |
-
}
|
760 |
-
}
|
761 |
-
|
762 |
-
$Type = null;
|
763 |
-
$Label = null;
|
764 |
-
$Options = array();
|
765 |
-
|
766 |
-
if (func_num_args()==1) {
|
767 |
-
} else
|
768 |
-
if (func_num_args()==2) {
|
769 |
-
switch(func_get_arg(1)) {
|
770 |
-
case self::LOG:
|
771 |
-
case self::INFO:
|
772 |
-
case self::WARN:
|
773 |
-
case self::ERROR:
|
774 |
-
case self::DUMP:
|
775 |
-
case self::TRACE:
|
776 |
-
case self::EXCEPTION:
|
777 |
-
case self::TABLE:
|
778 |
-
case self::GROUP_START:
|
779 |
-
case self::GROUP_END:
|
780 |
-
$Type = func_get_arg(1);
|
781 |
-
break;
|
782 |
-
default:
|
783 |
-
$Label = func_get_arg(1);
|
784 |
-
break;
|
785 |
-
}
|
786 |
-
} else
|
787 |
-
if (func_num_args()==3) {
|
788 |
-
$Type = func_get_arg(2);
|
789 |
-
$Label = func_get_arg(1);
|
790 |
-
} else
|
791 |
-
if (func_num_args()==4) {
|
792 |
-
$Type = func_get_arg(2);
|
793 |
-
$Label = func_get_arg(1);
|
794 |
-
$Options = func_get_arg(3);
|
795 |
-
} else {
|
796 |
-
throw $this->newException('Wrong number of arguments to fb() function!');
|
797 |
-
}
|
798 |
-
|
799 |
-
if($this->logToInsightConsole!==null && (get_class($this)=='FirePHP_Insight' || is_subclass_of($this, 'FirePHP_Insight'))) {
|
800 |
-
$msg = $this->logToInsightConsole;
|
801 |
-
if ($Object instanceof Exception) {
|
802 |
-
$Type = self::EXCEPTION;
|
803 |
-
}
|
804 |
-
if($Label && $Type!=self::TABLE && $Type!=self::GROUP_START) {
|
805 |
-
$msg = $msg->label($Label);
|
806 |
-
}
|
807 |
-
switch($Type) {
|
808 |
-
case self::DUMP:
|
809 |
-
case self::LOG:
|
810 |
-
return $msg->log($Object);
|
811 |
-
case self::INFO:
|
812 |
-
return $msg->info($Object);
|
813 |
-
case self::WARN:
|
814 |
-
return $msg->warn($Object);
|
815 |
-
case self::ERROR:
|
816 |
-
return $msg->error($Object);
|
817 |
-
case self::TRACE:
|
818 |
-
return $msg->trace($Object);
|
819 |
-
case self::EXCEPTION:
|
820 |
-
return $this->plugin('engine')->handleException($Object, $msg);
|
821 |
-
case self::TABLE:
|
822 |
-
if (isset($Object[0]) && !is_string($Object[0]) && $Label) {
|
823 |
-
$Object = array($Label, $Object);
|
824 |
-
}
|
825 |
-
return $msg->table($Object[0], array_slice($Object[1],1), $Object[1][0]);
|
826 |
-
case self::GROUP_START:
|
827 |
-
$insightGroupStack[] = $msg->group(md5($Label))->open();
|
828 |
-
return $msg->log($Label);
|
829 |
-
case self::GROUP_END:
|
830 |
-
if(count($insightGroupStack)==0) {
|
831 |
-
throw new Error('Too many groupEnd() as opposed to group() calls!');
|
832 |
-
}
|
833 |
-
$group = array_pop($insightGroupStack);
|
834 |
-
return $group->close();
|
835 |
-
default:
|
836 |
-
return $msg->log($Object);
|
837 |
-
}
|
838 |
-
}
|
839 |
-
|
840 |
-
if (!$this->detectClientExtension()) {
|
841 |
-
return false;
|
842 |
-
}
|
843 |
-
|
844 |
-
$meta = array();
|
845 |
-
$skipFinalObjectEncode = false;
|
846 |
-
|
847 |
-
if ($Object instanceof Exception) {
|
848 |
-
|
849 |
-
$meta['file'] = $this->_escapeTraceFile($Object->getFile());
|
850 |
-
$meta['line'] = $Object->getLine();
|
851 |
-
|
852 |
-
$trace = $Object->getTrace();
|
853 |
-
if ($Object instanceof ErrorException
|
854 |
-
&& isset($trace[0]['function'])
|
855 |
-
&& $trace[0]['function']=='errorHandler'
|
856 |
-
&& isset($trace[0]['class'])
|
857 |
-
&& $trace[0]['class']=='FirePHP') {
|
858 |
-
|
859 |
-
$severity = false;
|
860 |
-
switch($Object->getSeverity()) {
|
861 |
-
case E_WARNING: $severity = 'E_WARNING'; break;
|
862 |
-
case E_NOTICE: $severity = 'E_NOTICE'; break;
|
863 |
-
case E_USER_ERROR: $severity = 'E_USER_ERROR'; break;
|
864 |
-
case E_USER_WARNING: $severity = 'E_USER_WARNING'; break;
|
865 |
-
case E_USER_NOTICE: $severity = 'E_USER_NOTICE'; break;
|
866 |
-
case E_STRICT: $severity = 'E_STRICT'; break;
|
867 |
-
case E_RECOVERABLE_ERROR: $severity = 'E_RECOVERABLE_ERROR'; break;
|
868 |
-
case E_DEPRECATED: $severity = 'E_DEPRECATED'; break;
|
869 |
-
case E_USER_DEPRECATED: $severity = 'E_USER_DEPRECATED'; break;
|
870 |
-
}
|
871 |
-
|
872 |
-
$Object = array('Class'=>get_class($Object),
|
873 |
-
'Message'=>$severity.': '.$Object->getMessage(),
|
874 |
-
'File'=>$this->_escapeTraceFile($Object->getFile()),
|
875 |
-
'Line'=>$Object->getLine(),
|
876 |
-
'Type'=>'trigger',
|
877 |
-
'Trace'=>$this->_escapeTrace(array_splice($trace,2)));
|
878 |
-
$skipFinalObjectEncode = true;
|
879 |
-
} else {
|
880 |
-
$Object = array('Class'=>get_class($Object),
|
881 |
-
'Message'=>$Object->getMessage(),
|
882 |
-
'File'=>$this->_escapeTraceFile($Object->getFile()),
|
883 |
-
'Line'=>$Object->getLine(),
|
884 |
-
'Type'=>'throw',
|
885 |
-
'Trace'=>$this->_escapeTrace($trace));
|
886 |
-
$skipFinalObjectEncode = true;
|
887 |
-
}
|
888 |
-
$Type = self::EXCEPTION;
|
889 |
-
|
890 |
-
} else
|
891 |
-
if ($Type==self::TRACE) {
|
892 |
-
|
893 |
-
$trace = debug_backtrace();
|
894 |
-
if (!$trace) return false;
|
895 |
-
for( $i=0 ; $i<sizeof($trace) ; $i++ ) {
|
896 |
-
|
897 |
-
if (isset($trace[$i]['class'])
|
898 |
-
&& isset($trace[$i]['file'])
|
899 |
-
&& ($trace[$i]['class']=='FirePHP'
|
900 |
-
|| $trace[$i]['class']=='FB')
|
901 |
-
&& (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php'
|
902 |
-
|| substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) {
|
903 |
-
/* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */
|
904 |
-
} else
|
905 |
-
if (isset($trace[$i]['class'])
|
906 |
-
&& isset($trace[$i+1]['file'])
|
907 |
-
&& $trace[$i]['class']=='FirePHP'
|
908 |
-
&& substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') {
|
909 |
-
/* Skip fb() */
|
910 |
-
} else
|
911 |
-
if ($trace[$i]['function']=='fb'
|
912 |
-
|| $trace[$i]['function']=='trace'
|
913 |
-
|| $trace[$i]['function']=='send') {
|
914 |
-
|
915 |
-
$Object = array('Class'=>isset($trace[$i]['class'])?$trace[$i]['class']:'',
|
916 |
-
'Type'=>isset($trace[$i]['type'])?$trace[$i]['type']:'',
|
917 |
-
'Function'=>isset($trace[$i]['function'])?$trace[$i]['function']:'',
|
918 |
-
'Message'=>$trace[$i]['args'][0],
|
919 |
-
'File'=>isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'',
|
920 |
-
'Line'=>isset($trace[$i]['line'])?$trace[$i]['line']:'',
|
921 |
-
'Args'=>isset($trace[$i]['args'])?$this->encodeObject($trace[$i]['args']):'',
|
922 |
-
'Trace'=>$this->_escapeTrace(array_splice($trace,$i+1)));
|
923 |
-
|
924 |
-
$skipFinalObjectEncode = true;
|
925 |
-
$meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'';
|
926 |
-
$meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:'';
|
927 |
-
break;
|
928 |
-
}
|
929 |
-
}
|
930 |
-
|
931 |
-
} else
|
932 |
-
if ($Type==self::TABLE) {
|
933 |
-
|
934 |
-
if (isset($Object[0]) && is_string($Object[0])) {
|
935 |
-
$Object[1] = $this->encodeTable($Object[1]);
|
936 |
-
} else {
|
937 |
-
$Object = $this->encodeTable($Object);
|
938 |
-
}
|
939 |
-
|
940 |
-
$skipFinalObjectEncode = true;
|
941 |
-
|
942 |
-
} else
|
943 |
-
if ($Type==self::GROUP_START) {
|
944 |
-
|
945 |
-
if (!$Label) {
|
946 |
-
throw $this->newException('You must specify a label for the group!');
|
947 |
-
}
|
948 |
-
|
949 |
-
} else {
|
950 |
-
if ($Type===null) {
|
951 |
-
$Type = self::LOG;
|
952 |
-
}
|
953 |
-
}
|
954 |
-
|
955 |
-
if ($this->options['includeLineNumbers']) {
|
956 |
-
if (!isset($meta['file']) || !isset($meta['line'])) {
|
957 |
-
|
958 |
-
$trace = debug_backtrace();
|
959 |
-
for( $i=0 ; $trace && $i<sizeof($trace) ; $i++ ) {
|
960 |
-
|
961 |
-
if (isset($trace[$i]['class'])
|
962 |
-
&& isset($trace[$i]['file'])
|
963 |
-
&& ($trace[$i]['class']=='FirePHP'
|
964 |
-
|| $trace[$i]['class']=='FB')
|
965 |
-
&& (substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php'
|
966 |
-
|| substr($this->_standardizePath($trace[$i]['file']),-29,29)=='FirePHPCore/FirePHP.class.php')) {
|
967 |
-
/* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */
|
968 |
-
} else
|
969 |
-
if (isset($trace[$i]['class'])
|
970 |
-
&& isset($trace[$i+1]['file'])
|
971 |
-
&& $trace[$i]['class']=='FirePHP'
|
972 |
-
&& substr($this->_standardizePath($trace[$i+1]['file']),-18,18)=='FirePHPCore/fb.php') {
|
973 |
-
/* Skip fb() */
|
974 |
-
} else
|
975 |
-
if (isset($trace[$i]['file'])
|
976 |
-
&& substr($this->_standardizePath($trace[$i]['file']),-18,18)=='FirePHPCore/fb.php') {
|
977 |
-
/* Skip FB::fb() */
|
978 |
-
} else {
|
979 |
-
$meta['file'] = isset($trace[$i]['file'])?$this->_escapeTraceFile($trace[$i]['file']):'';
|
980 |
-
$meta['line'] = isset($trace[$i]['line'])?$trace[$i]['line']:'';
|
981 |
-
break;
|
982 |
-
}
|
983 |
-
}
|
984 |
-
}
|
985 |
-
} else {
|
986 |
-
unset($meta['file']);
|
987 |
-
unset($meta['line']);
|
988 |
-
}
|
989 |
-
|
990 |
-
$this->setHeader('X-Wf-Protocol-1','http://meta.wildfirehq.org/Protocol/JsonStream/0.2');
|
991 |
-
$this->setHeader('X-Wf-1-Plugin-1','http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/'.self::VERSION);
|
992 |
-
|
993 |
-
$structure_index = 1;
|
994 |
-
if ($Type==self::DUMP) {
|
995 |
-
$structure_index = 2;
|
996 |
-
$this->setHeader('X-Wf-1-Structure-2','http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1');
|
997 |
-
} else {
|
998 |
-
$this->setHeader('X-Wf-1-Structure-1','http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1');
|
999 |
-
}
|
1000 |
-
|
1001 |
-
if ($Type==self::DUMP) {
|
1002 |
-
$msg = '{"'.$Label.'":'.$this->jsonEncode($Object, $skipFinalObjectEncode).'}';
|
1003 |
-
} else {
|
1004 |
-
$msg_meta = $Options;
|
1005 |
-
$msg_meta['Type'] = $Type;
|
1006 |
-
if ($Label!==null) {
|
1007 |
-
$msg_meta['Label'] = $Label;
|
1008 |
-
}
|
1009 |
-
if (isset($meta['file']) && !isset($msg_meta['File'])) {
|
1010 |
-
$msg_meta['File'] = $meta['file'];
|
1011 |
-
}
|
1012 |
-
if (isset($meta['line']) && !isset($msg_meta['Line'])) {
|
1013 |
-
$msg_meta['Line'] = $meta['line'];
|
1014 |
-
}
|
1015 |
-
$msg = '['.$this->jsonEncode($msg_meta).','.$this->jsonEncode($Object, $skipFinalObjectEncode).']';
|
1016 |
-
}
|
1017 |
-
|
1018 |
-
$parts = explode("\n",chunk_split($msg, 5000, "\n"));
|
1019 |
-
|
1020 |
-
for( $i=0 ; $i<count($parts) ; $i++) {
|
1021 |
-
|
1022 |
-
$part = $parts[$i];
|
1023 |
-
if ($part) {
|
1024 |
-
|
1025 |
-
if (count($parts)>2) {
|
1026 |
-
// Message needs to be split into multiple parts
|
1027 |
-
$this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex,
|
1028 |
-
(($i==0)?strlen($msg):'')
|
1029 |
-
. '|' . $part . '|'
|
1030 |
-
. (($i<count($parts)-2)?'\\':''));
|
1031 |
-
} else {
|
1032 |
-
$this->setHeader('X-Wf-1-'.$structure_index.'-'.'1-'.$this->messageIndex,
|
1033 |
-
strlen($part) . '|' . $part . '|');
|
1034 |
-
}
|
1035 |
-
|
1036 |
-
$this->messageIndex++;
|
1037 |
-
|
1038 |
-
if ($this->messageIndex > 99999) {
|
1039 |
-
throw $this->newException('Maximum number (99,999) of messages reached!');
|
1040 |
-
}
|
1041 |
-
}
|
1042 |
-
}
|
1043 |
-
|
1044 |
-
$this->setHeader('X-Wf-1-Index',$this->messageIndex-1);
|
1045 |
-
|
1046 |
-
return true;
|
1047 |
-
}
|
1048 |
-
|
1049 |
-
/**
|
1050 |
-
* Standardizes path for windows systems.
|
1051 |
-
*
|
1052 |
-
* @param string $Path
|
1053 |
-
* @return string
|
1054 |
-
*/
|
1055 |
-
protected function _standardizePath($Path)
|
1056 |
-
{
|
1057 |
-
return preg_replace('/\\\\+/','/',$Path);
|
1058 |
-
}
|
1059 |
-
|
1060 |
-
/**
|
1061 |
-
* Escape trace path for windows systems
|
1062 |
-
*
|
1063 |
-
* @param array $Trace
|
1064 |
-
* @return array
|
1065 |
-
*/
|
1066 |
-
protected function _escapeTrace($Trace)
|
1067 |
-
{
|
1068 |
-
if (!$Trace) return $Trace;
|
1069 |
-
for( $i=0 ; $i<sizeof($Trace) ; $i++ ) {
|
1070 |
-
if (isset($Trace[$i]['file'])) {
|
1071 |
-
$Trace[$i]['file'] = $this->_escapeTraceFile($Trace[$i]['file']);
|
1072 |
-
}
|
1073 |
-
if (isset($Trace[$i]['args'])) {
|
1074 |
-
$Trace[$i]['args'] = $this->encodeObject($Trace[$i]['args']);
|
1075 |
-
}
|
1076 |
-
}
|
1077 |
-
return $Trace;
|
1078 |
-
}
|
1079 |
-
|
1080 |
-
/**
|
1081 |
-
* Escape file information of trace for windows systems
|
1082 |
-
*
|
1083 |
-
* @param string $File
|
1084 |
-
* @return string
|
1085 |
-
*/
|
1086 |
-
protected function _escapeTraceFile($File)
|
1087 |
-
{
|
1088 |
-
/* Check if we have a windows filepath */
|
1089 |
-
if (strpos($File,'\\')) {
|
1090 |
-
/* First strip down to single \ */
|
1091 |
-
|
1092 |
-
$file = preg_replace('/\\\\+/','\\',$File);
|
1093 |
-
|
1094 |
-
return $file;
|
1095 |
-
}
|
1096 |
-
return $File;
|
1097 |
-
}
|
1098 |
-
|
1099 |
-
/**
|
1100 |
-
* Check if headers have already been sent
|
1101 |
-
*
|
1102 |
-
* @param string $Filename
|
1103 |
-
* @param integer $Linenum
|
1104 |
-
*/
|
1105 |
-
protected function headersSent(&$Filename, &$Linenum)
|
1106 |
-
{
|
1107 |
-
return headers_sent($Filename, $Linenum);
|
1108 |
-
}
|
1109 |
-
|
1110 |
-
/**
|
1111 |
-
* Send header
|
1112 |
-
*
|
1113 |
-
* @param string $Name
|
1114 |
-
* @param string $Value
|
1115 |
-
*/
|
1116 |
-
protected function setHeader($Name, $Value)
|
1117 |
-
{
|
1118 |
-
return header($Name.': '.$Value);
|
1119 |
-
}
|
1120 |
-
|
1121 |
-
/**
|
1122 |
-
* Get user agent
|
1123 |
-
*
|
1124 |
-
* @return string|false
|
1125 |
-
*/
|
1126 |
-
protected function getUserAgent()
|
1127 |
-
{
|
1128 |
-
if (!isset($_SERVER['HTTP_USER_AGENT'])) return false;
|
1129 |
-
return $_SERVER['HTTP_USER_AGENT'];
|
1130 |
-
}
|
1131 |
-
|
1132 |
-
/**
|
1133 |
-
* Get all request headers
|
1134 |
-
*
|
1135 |
-
* @return array
|
1136 |
-
*/
|
1137 |
-
public static function getAllRequestHeaders() {
|
1138 |
-
static $_cached_headers = false;
|
1139 |
-
if($_cached_headers!==false) {
|
1140 |
-
return $_cached_headers;
|
1141 |
-
}
|
1142 |
-
$headers = array();
|
1143 |
-
if(function_exists('getallheaders')) {
|
1144 |
-
foreach( getallheaders() as $name => $value ) {
|
1145 |
-
$headers[strtolower($name)] = $value;
|
1146 |
-
}
|
1147 |
-
} else {
|
1148 |
-
foreach($_SERVER as $name => $value) {
|
1149 |
-
if(substr($name, 0, 5) == 'HTTP_') {
|
1150 |
-
$headers[strtolower(str_replace(' ', '-', str_replace('_', ' ', substr($name, 5))))] = $value;
|
1151 |
-
}
|
1152 |
-
}
|
1153 |
-
}
|
1154 |
-
return $_cached_headers = $headers;
|
1155 |
-
}
|
1156 |
-
|
1157 |
-
/**
|
1158 |
-
* Get a request header
|
1159 |
-
*
|
1160 |
-
* @return string|false
|
1161 |
-
*/
|
1162 |
-
protected function getRequestHeader($Name)
|
1163 |
-
{
|
1164 |
-
$headers = self::getAllRequestHeaders();
|
1165 |
-
if (isset($headers[strtolower($Name)])) {
|
1166 |
-
return $headers[strtolower($Name)];
|
1167 |
-
}
|
1168 |
-
return false;
|
1169 |
-
}
|
1170 |
-
|
1171 |
-
/**
|
1172 |
-
* Returns a new exception
|
1173 |
-
*
|
1174 |
-
* @param string $Message
|
1175 |
-
* @return Exception
|
1176 |
-
*/
|
1177 |
-
protected function newException($Message)
|
1178 |
-
{
|
1179 |
-
return new Exception($Message);
|
1180 |
-
}
|
1181 |
-
|
1182 |
-
/**
|
1183 |
-
* Encode an object into a JSON string
|
1184 |
-
*
|
1185 |
-
* Uses PHP's jeson_encode() if available
|
1186 |
-
*
|
1187 |
-
* @param object $Object The object to be encoded
|
1188 |
-
* @return string The JSON string
|
1189 |
-
*/
|
1190 |
-
public function jsonEncode($Object, $skipObjectEncode = false)
|
1191 |
-
{
|
1192 |
-
if (!$skipObjectEncode) {
|
1193 |
-
$Object = $this->encodeObject($Object);
|
1194 |
-
}
|
1195 |
-
|
1196 |
-
if (function_exists('json_encode')
|
1197 |
-
&& $this->options['useNativeJsonEncode']!=false) {
|
1198 |
-
|
1199 |
-
return json_encode($Object);
|
1200 |
-
} else {
|
1201 |
-
return $this->json_encode($Object);
|
1202 |
-
}
|
1203 |
-
}
|
1204 |
-
|
1205 |
-
/**
|
1206 |
-
* Encodes a table by encoding each row and column with encodeObject()
|
1207 |
-
*
|
1208 |
-
* @param array $Table The table to be encoded
|
1209 |
-
* @return array
|
1210 |
-
*/
|
1211 |
-
protected function encodeTable($Table)
|
1212 |
-
{
|
1213 |
-
|
1214 |
-
if (!$Table) return $Table;
|
1215 |
-
|
1216 |
-
$new_table = array();
|
1217 |
-
foreach($Table as $row) {
|
1218 |
-
|
1219 |
-
if (is_array($row)) {
|
1220 |
-
$new_row = array();
|
1221 |
-
|
1222 |
-
foreach($row as $item) {
|
1223 |
-
$new_row[] = $this->encodeObject($item);
|
1224 |
-
}
|
1225 |
-
|
1226 |
-
$new_table[] = $new_row;
|
1227 |
-
}
|
1228 |
-
}
|
1229 |
-
|
1230 |
-
return $new_table;
|
1231 |
-
}
|
1232 |
-
|
1233 |
-
/**
|
1234 |
-
* Encodes an object including members with
|
1235 |
-
* protected and private visibility
|
1236 |
-
*
|
1237 |
-
* @param Object $Object The object to be encoded
|
1238 |
-
* @param int $Depth The current traversal depth
|
1239 |
-
* @return array All members of the object
|
1240 |
-
*/
|
1241 |
-
protected function encodeObject($Object, $ObjectDepth = 1, $ArrayDepth = 1, $MaxDepth = 1)
|
1242 |
-
{
|
1243 |
-
if ($MaxDepth > $this->options['maxDepth']) {
|
1244 |
-
return '** Max Depth ('.$this->options['maxDepth'].') **';
|
1245 |
-
}
|
1246 |
-
|
1247 |
-
$return = array();
|
1248 |
-
|
1249 |
-
if (is_resource($Object)) {
|
1250 |
-
|
1251 |
-
return '** '.(string)$Object.' **';
|
1252 |
-
|
1253 |
-
} else
|
1254 |
-
if (is_object($Object)) {
|
1255 |
-
|
1256 |
-
if ($ObjectDepth > $this->options['maxObjectDepth']) {
|
1257 |
-
return '** Max Object Depth ('.$this->options['maxObjectDepth'].') **';
|
1258 |
-
}
|
1259 |
-
|
1260 |
-
foreach ($this->objectStack as $refVal) {
|
1261 |
-
if ($refVal === $Object) {
|
1262 |
-
return '** Recursion ('.get_class($Object).') **';
|
1263 |
-
}
|
1264 |
-
}
|
1265 |
-
array_push($this->objectStack, $Object);
|
1266 |
-
|
1267 |
-
$return['__className'] = $class = get_class($Object);
|
1268 |
-
$class_lower = strtolower($class);
|
1269 |
-
|
1270 |
-
$reflectionClass = new ReflectionClass($class);
|
1271 |
-
$properties = array();
|
1272 |
-
foreach( $reflectionClass->getProperties() as $property) {
|
1273 |
-
$properties[$property->getName()] = $property;
|
1274 |
-
}
|
1275 |
-
|
1276 |
-
$members = (array)$Object;
|
1277 |
-
|
1278 |
-
foreach( $properties as $plain_name => $property ) {
|
1279 |
-
|
1280 |
-
$name = $raw_name = $plain_name;
|
1281 |
-
if ($property->isStatic()) {
|
1282 |
-
$name = 'static:'.$name;
|
1283 |
-
}
|
1284 |
-
if ($property->isPublic()) {
|
1285 |
-
$name = 'public:'.$name;
|
1286 |
-
} else
|
1287 |
-
if ($property->isPrivate()) {
|
1288 |
-
$name = 'private:'.$name;
|
1289 |
-
$raw_name = "\0".$class."\0".$raw_name;
|
1290 |
-
} else
|
1291 |
-
if ($property->isProtected()) {
|
1292 |
-
$name = 'protected:'.$name;
|
1293 |
-
$raw_name = "\0".'*'."\0".$raw_name;
|
1294 |
-
}
|
1295 |
-
|
1296 |
-
if (!(isset($this->objectFilters[$class_lower])
|
1297 |
-
&& is_array($this->objectFilters[$class_lower])
|
1298 |
-
&& in_array($plain_name,$this->objectFilters[$class_lower]))) {
|
1299 |
-
|
1300 |
-
if (array_key_exists($raw_name,$members)
|
1301 |
-
&& !$property->isStatic()) {
|
1302 |
-
|
1303 |
-
$return[$name] = $this->encodeObject($members[$raw_name], $ObjectDepth + 1, 1, $MaxDepth + 1);
|
1304 |
-
|
1305 |
-
} else {
|
1306 |
-
if (method_exists($property,'setAccessible')) {
|
1307 |
-
$property->setAccessible(true);
|
1308 |
-
$return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1, $MaxDepth + 1);
|
1309 |
-
} else
|
1310 |
-
if ($property->isPublic()) {
|
1311 |
-
$return[$name] = $this->encodeObject($property->getValue($Object), $ObjectDepth + 1, 1, $MaxDepth + 1);
|
1312 |
-
} else {
|
1313 |
-
$return[$name] = '** Need PHP 5.3 to get value **';
|
1314 |
-
}
|
1315 |
-
}
|
1316 |
-
} else {
|
1317 |
-
$return[$name] = '** Excluded by Filter **';
|
1318 |
-
}
|
1319 |
-
}
|
1320 |
-
|
1321 |
-
// Include all members that are not defined in the class
|
1322 |
-
// but exist in the object
|
1323 |
-
foreach( $members as $raw_name => $value ) {
|
1324 |
-
|
1325 |
-
$name = $raw_name;
|
1326 |
-
|
1327 |
-
if ($name{0} == "\0") {
|
1328 |
-
$parts = explode("\0", $name);
|
1329 |
-
$name = $parts[2];
|
1330 |
-
}
|
1331 |
-
|
1332 |
-
$plain_name = $name;
|
1333 |
-
|
1334 |
-
if (!isset($properties[$name])) {
|
1335 |
-
$name = 'undeclared:'.$name;
|
1336 |
-
|
1337 |
-
if (!(isset($this->objectFilters[$class_lower])
|
1338 |
-
&& is_array($this->objectFilters[$class_lower])
|
1339 |
-
&& in_array($plain_name,$this->objectFilters[$class_lower]))) {
|
1340 |
-
|
1341 |
-
$return[$name] = $this->encodeObject($value, $ObjectDepth + 1, 1, $MaxDepth + 1);
|
1342 |
-
} else {
|
1343 |
-
$return[$name] = '** Excluded by Filter **';
|
1344 |
-
}
|
1345 |
-
}
|
1346 |
-
}
|
1347 |
-
|
1348 |
-
array_pop($this->objectStack);
|
1349 |
-
|
1350 |
-
} elseif (is_array($Object)) {
|
1351 |
-
|
1352 |
-
if ($ArrayDepth > $this->options['maxArrayDepth']) {
|
1353 |
-
return '** Max Array Depth ('.$this->options['maxArrayDepth'].') **';
|
1354 |
-
}
|
1355 |
-
|
1356 |
-
foreach ($Object as $key => $val) {
|
1357 |
-
|
1358 |
-
// Encoding the $GLOBALS PHP array causes an infinite loop
|
1359 |
-
// if the recursion is not reset here as it contains
|
1360 |
-
// a reference to itself. This is the only way I have come up
|
1361 |
-
// with to stop infinite recursion in this case.
|
1362 |
-
if ($key=='GLOBALS'
|
1363 |
-
&& is_array($val)
|
1364 |
-
&& array_key_exists('GLOBALS',$val)) {
|
1365 |
-
$val['GLOBALS'] = '** Recursion (GLOBALS) **';
|
1366 |
-
}
|
1367 |
-
|
1368 |
-
$return[$key] = $this->encodeObject($val, 1, $ArrayDepth + 1, $MaxDepth + 1);
|
1369 |
-
}
|
1370 |
-
} else {
|
1371 |
-
if (self::is_utf8($Object)) {
|
1372 |
-
return $Object;
|
1373 |
-
} else {
|
1374 |
-
return utf8_encode($Object);
|
1375 |
-
}
|
1376 |
-
}
|
1377 |
-
return $return;
|
1378 |
-
}
|
1379 |
-
|
1380 |
-
/**
|
1381 |
-
* Returns true if $string is valid UTF-8 and false otherwise.
|
1382 |
-
*
|
1383 |
-
* @param mixed $str String to be tested
|
1384 |
-
* @return boolean
|
1385 |
-
*/
|
1386 |
-
protected static function is_utf8($str)
|
1387 |
-
{
|
1388 |
-
if(function_exists('mb_detect_encoding')) {
|
1389 |
-
return (mb_detect_encoding($str) == 'UTF-8');
|
1390 |
-
}
|
1391 |
-
$c=0; $b=0;
|
1392 |
-
$bits=0;
|
1393 |
-
$len=strlen($str);
|
1394 |
-
for($i=0; $i<$len; $i++){
|
1395 |
-
$c=ord($str[$i]);
|
1396 |
-
if ($c > 128){
|
1397 |
-
if (($c >= 254)) return false;
|
1398 |
-
elseif ($c >= 252) $bits=6;
|
1399 |
-
elseif ($c >= 248) $bits=5;
|
1400 |
-
elseif ($c >= 240) $bits=4;
|
1401 |
-
elseif ($c >= 224) $bits=3;
|
1402 |
-
elseif ($c >= 192) $bits=2;
|
1403 |
-
else return false;
|
1404 |
-
if (($i+$bits) > $len) return false;
|
1405 |
-
while($bits > 1){
|
1406 |
-
$i++;
|
1407 |
-
$b=ord($str[$i]);
|
1408 |
-
if ($b < 128 || $b > 191) return false;
|
1409 |
-
$bits--;
|
1410 |
-
}
|
1411 |
-
}
|
1412 |
-
}
|
1413 |
-
return true;
|
1414 |
-
}
|
1415 |
-
|
1416 |
-
/**
|
1417 |
-
* Converts to and from JSON format.
|
1418 |
-
*
|
1419 |
-
* JSON (JavaScript Object Notation) is a lightweight data-interchange
|
1420 |
-
* format. It is easy for humans to read and write. It is easy for machines
|
1421 |
-
* to parse and generate. It is based on a subset of the JavaScript
|
1422 |
-
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
|
1423 |
-
* This feature can also be found in Python. JSON is a text format that is
|
1424 |
-
* completely language independent but uses conventions that are familiar
|
1425 |
-
* to programmers of the C-family of languages, including C, C++, C#, Java,
|
1426 |
-
* JavaScript, Perl, TCL, and many others. These properties make JSON an
|
1427 |
-
* ideal data-interchange language.
|
1428 |
-
*
|
1429 |
-
* This package provides a simple encoder and decoder for JSON notation. It
|
1430 |
-
* is intended for use with client-side Javascript applications that make
|
1431 |
-
* use of HTTPRequest to perform server communication functions - data can
|
1432 |
-
* be encoded into JSON notation for use in a client-side javascript, or
|
1433 |
-
* decoded from incoming Javascript requests. JSON format is native to
|
1434 |
-
* Javascript, and can be directly eval()'ed with no further parsing
|
1435 |
-
* overhead
|
1436 |
-
*
|
1437 |
-
* All strings should be in ASCII or UTF-8 format!
|
1438 |
-
*
|
1439 |
-
* LICENSE: Redistribution and use in source and binary forms, with or
|
1440 |
-
* without modification, are permitted provided that the following
|
1441 |
-
* conditions are met: Redistributions of source code must retain the
|
1442 |
-
* above copyright notice, this list of conditions and the following
|
1443 |
-
* disclaimer. Redistributions in binary form must reproduce the above
|
1444 |
-
* copyright notice, this list of conditions and the following disclaimer
|
1445 |
-
* in the documentation and/or other materials provided with the
|
1446 |
-
* distribution.
|
1447 |
-
*
|
1448 |
-
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
1449 |
-
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
1450 |
-
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
1451 |
-
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
1452 |
-
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
1453 |
-
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
1454 |
-
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
1455 |
-
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
1456 |
-
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
1457 |
-
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
1458 |
-
* DAMAGE.
|
1459 |
-
*
|
1460 |
-
* @category
|
1461 |
-
* @package Services_JSON
|
1462 |
-
* @author Michal Migurski <mike-json@teczno.com>
|
1463 |
-
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
|
1464 |
-
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
|
1465 |
-
* @author Christoph Dorn <christoph@christophdorn.com>
|
1466 |
-
* @copyright 2005 Michal Migurski
|
1467 |
-
* @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
|
1468 |
-
* @license http://www.opensource.org/licenses/bsd-license.php
|
1469 |
-
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
|
1470 |
-
*/
|
1471 |
-
|
1472 |
-
|
1473 |
-
/**
|
1474 |
-
* Keep a list of objects as we descend into the array so we can detect recursion.
|
1475 |
-
*/
|
1476 |
-
private $json_objectStack = array();
|
1477 |
-
|
1478 |
-
|
1479 |
-
/**
|
1480 |
-
* convert a string from one UTF-8 char to one UTF-16 char
|
1481 |
-
*
|
1482 |
-
* Normally should be handled by mb_convert_encoding, but
|
1483 |
-
* provides a slower PHP-only method for installations
|
1484 |
-
* that lack the multibye string extension.
|
1485 |
-
*
|
1486 |
-
* @param string $utf8 UTF-8 character
|
1487 |
-
* @return string UTF-16 character
|
1488 |
-
* @access private
|
1489 |
-
*/
|
1490 |
-
private function json_utf82utf16($utf8)
|
1491 |
-
{
|
1492 |
-
// oh please oh please oh please oh please oh please
|
1493 |
-
if (function_exists('mb_convert_encoding')) {
|
1494 |
-
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
|
1495 |
-
}
|
1496 |
-
|
1497 |
-
switch(strlen($utf8)) {
|
1498 |
-
case 1:
|
1499 |
-
// this case should never be reached, because we are in ASCII range
|
1500 |
-
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
1501 |
-
return $utf8;
|
1502 |
-
|
1503 |
-
case 2:
|
1504 |
-
// return a UTF-16 character from a 2-byte UTF-8 char
|
1505 |
-
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
1506 |
-
return chr(0x07 & (ord($utf8{0}) >> 2))
|
1507 |
-
. chr((0xC0 & (ord($utf8{0}) << 6))
|
1508 |
-
| (0x3F & ord($utf8{1})));
|
1509 |
-
|
1510 |
-
case 3:
|
1511 |
-
// return a UTF-16 character from a 3-byte UTF-8 char
|
1512 |
-
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
1513 |
-
return chr((0xF0 & (ord($utf8{0}) << 4))
|
1514 |
-
| (0x0F & (ord($utf8{1}) >> 2)))
|
1515 |
-
. chr((0xC0 & (ord($utf8{1}) << 6))
|
1516 |
-
| (0x7F & ord($utf8{2})));
|
1517 |
-
}
|
1518 |
-
|
1519 |
-
// ignoring UTF-32 for now, sorry
|
1520 |
-
return '';
|
1521 |
-
}
|
1522 |
-
|
1523 |
-
/**
|
1524 |
-
* encodes an arbitrary variable into JSON format
|
1525 |
-
*
|
1526 |
-
* @param mixed $var any number, boolean, string, array, or object to be encoded.
|
1527 |
-
* see argument 1 to Services_JSON() above for array-parsing behavior.
|
1528 |
-
* if var is a strng, note that encode() always expects it
|
1529 |
-
* to be in ASCII or UTF-8 format!
|
1530 |
-
*
|
1531 |
-
* @return mixed JSON string representation of input var or an error if a problem occurs
|
1532 |
-
* @access public
|
1533 |
-
*/
|
1534 |
-
private function json_encode($var)
|
1535 |
-
{
|
1536 |
-
|
1537 |
-
if (is_object($var)) {
|
1538 |
-
if (in_array($var,$this->json_objectStack)) {
|
1539 |
-
return '"** Recursion **"';
|
1540 |
-
}
|
1541 |
-
}
|
1542 |
-
|
1543 |
-
switch (gettype($var)) {
|
1544 |
-
case 'boolean':
|
1545 |
-
return $var ? 'true' : 'false';
|
1546 |
-
|
1547 |
-
case 'NULL':
|
1548 |
-
return 'null';
|
1549 |
-
|
1550 |
-
case 'integer':
|
1551 |
-
return (int) $var;
|
1552 |
-
|
1553 |
-
case 'double':
|
1554 |
-
case 'float':
|
1555 |
-
return (float) $var;
|
1556 |
-
|
1557 |
-
case 'string':
|
1558 |
-
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
|
1559 |
-
$ascii = '';
|
1560 |
-
$strlen_var = strlen($var);
|
1561 |
-
|
1562 |
-
/*
|
1563 |
-
* Iterate over every character in the string,
|
1564 |
-
* escaping with a slash or encoding to UTF-8 where necessary
|
1565 |
-
*/
|
1566 |
-
for ($c = 0; $c < $strlen_var; ++$c) {
|
1567 |
-
|
1568 |
-
$ord_var_c = ord($var{$c});
|
1569 |
-
|
1570 |
-
switch (true) {
|
1571 |
-
case $ord_var_c == 0x08:
|
1572 |
-
$ascii .= '\b';
|
1573 |
-
break;
|
1574 |
-
case $ord_var_c == 0x09:
|
1575 |
-
$ascii .= '\t';
|
1576 |
-
break;
|
1577 |
-
case $ord_var_c == 0x0A:
|
1578 |
-
$ascii .= '\n';
|
1579 |
-
break;
|
1580 |
-
case $ord_var_c == 0x0C:
|
1581 |
-
$ascii .= '\f';
|
1582 |
-
break;
|
1583 |
-
case $ord_var_c == 0x0D:
|
1584 |
-
$ascii .= '\r';
|
1585 |
-
break;
|
1586 |
-
|
1587 |
-
case $ord_var_c == 0x22:
|
1588 |
-
case $ord_var_c == 0x2F:
|
1589 |
-
case $ord_var_c == 0x5C:
|
1590 |
-
// double quote, slash, slosh
|
1591 |
-
$ascii .= '\\'.$var{$c};
|
1592 |
-
break;
|
1593 |
-
|
1594 |
-
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
|
1595 |
-
// characters U-00000000 - U-0000007F (same as ASCII)
|
1596 |
-
$ascii .= $var{$c};
|
1597 |
-
break;
|
1598 |
-
|
1599 |
-
case (($ord_var_c & 0xE0) == 0xC0):
|
1600 |
-
// characters U-00000080 - U-000007FF, mask 110XXXXX
|
1601 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
1602 |
-
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
|
1603 |
-
$c += 1;
|
1604 |
-
$utf16 = $this->json_utf82utf16($char);
|
1605 |
-
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
1606 |
-
break;
|
1607 |
-
|
1608 |
-
case (($ord_var_c & 0xF0) == 0xE0):
|
1609 |
-
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
|
1610 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
1611 |
-
$char = pack('C*', $ord_var_c,
|
1612 |
-
ord($var{$c + 1}),
|
1613 |
-
ord($var{$c + 2}));
|
1614 |
-
$c += 2;
|
1615 |
-
$utf16 = $this->json_utf82utf16($char);
|
1616 |
-
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
1617 |
-
break;
|
1618 |
-
|
1619 |
-
case (($ord_var_c & 0xF8) == 0xF0):
|
1620 |
-
// characters U-00010000 - U-001FFFFF, mask 11110XXX
|
1621 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
1622 |
-
$char = pack('C*', $ord_var_c,
|
1623 |
-
ord($var{$c + 1}),
|
1624 |
-
ord($var{$c + 2}),
|
1625 |
-
ord($var{$c + 3}));
|
1626 |
-
$c += 3;
|
1627 |
-
$utf16 = $this->json_utf82utf16($char);
|
1628 |
-
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
1629 |
-
break;
|
1630 |
-
|
1631 |
-
case (($ord_var_c & 0xFC) == 0xF8):
|
1632 |
-
// characters U-00200000 - U-03FFFFFF, mask 111110XX
|
1633 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
1634 |
-
$char = pack('C*', $ord_var_c,
|
1635 |
-
ord($var{$c + 1}),
|
1636 |
-
ord($var{$c + 2}),
|
1637 |
-
ord($var{$c + 3}),
|
1638 |
-
ord($var{$c + 4}));
|
1639 |
-
$c += 4;
|
1640 |
-
$utf16 = $this->json_utf82utf16($char);
|
1641 |
-
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
1642 |
-
break;
|
1643 |
-
|
1644 |
-
case (($ord_var_c & 0xFE) == 0xFC):
|
1645 |
-
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
|
1646 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
1647 |
-
$char = pack('C*', $ord_var_c,
|
1648 |
-
ord($var{$c + 1}),
|
1649 |
-
ord($var{$c + 2}),
|
1650 |
-
ord($var{$c + 3}),
|
1651 |
-
ord($var{$c + 4}),
|
1652 |
-
ord($var{$c + 5}));
|
1653 |
-
$c += 5;
|
1654 |
-
$utf16 = $this->json_utf82utf16($char);
|
1655 |
-
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
1656 |
-
break;
|
1657 |
-
}
|
1658 |
-
}
|
1659 |
-
|
1660 |
-
return '"'.$ascii.'"';
|
1661 |
-
|
1662 |
-
case 'array':
|
1663 |
-
/*
|
1664 |
-
* As per JSON spec if any array key is not an integer
|
1665 |
-
* we must treat the the whole array as an object. We
|
1666 |
-
* also try to catch a sparsely populated associative
|
1667 |
-
* array with numeric keys here because some JS engines
|
1668 |
-
* will create an array with empty indexes up to
|
1669 |
-
* max_index which can cause memory issues and because
|
1670 |
-
* the keys, which may be relevant, will be remapped
|
1671 |
-
* otherwise.
|
1672 |
-
*
|
1673 |
-
* As per the ECMA and JSON specification an object may
|
1674 |
-
* have any string as a property. Unfortunately due to
|
1675 |
-
* a hole in the ECMA specification if the key is a
|
1676 |
-
* ECMA reserved word or starts with a digit the
|
1677 |
-
* parameter is only accessible using ECMAScript's
|
1678 |
-
* bracket notation.
|
1679 |
-
*/
|
1680 |
-
|
1681 |
-
// treat as a JSON object
|
1682 |
-
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
|
1683 |
-
|
1684 |
-
$this->json_objectStack[] = $var;
|
1685 |
-
|
1686 |
-
$properties = array_map(array($this, 'json_name_value'),
|
1687 |
-
array_keys($var),
|
1688 |
-
array_values($var));
|
1689 |
-
|
1690 |
-
array_pop($this->json_objectStack);
|
1691 |
-
|
1692 |
-
foreach($properties as $property) {
|
1693 |
-
if ($property instanceof Exception) {
|
1694 |
-
return $property;
|
1695 |
-
}
|
1696 |
-
}
|
1697 |
-
|
1698 |
-
return '{' . join(',', $properties) . '}';
|
1699 |
-
}
|
1700 |
-
|
1701 |
-
$this->json_objectStack[] = $var;
|
1702 |
-
|
1703 |
-
// treat it like a regular array
|
1704 |
-
$elements = array_map(array($this, 'json_encode'), $var);
|
1705 |
-
|
1706 |
-
array_pop($this->json_objectStack);
|
1707 |
-
|
1708 |
-
foreach($elements as $element) {
|
1709 |
-
if ($element instanceof Exception) {
|
1710 |
-
return $element;
|
1711 |
-
}
|
1712 |
-
}
|
1713 |
-
|
1714 |
-
return '[' . join(',', $elements) . ']';
|
1715 |
-
|
1716 |
-
case 'object':
|
1717 |
-
$vars = self::encodeObject($var);
|
1718 |
-
|
1719 |
-
$this->json_objectStack[] = $var;
|
1720 |
-
|
1721 |
-
$properties = array_map(array($this, 'json_name_value'),
|
1722 |
-
array_keys($vars),
|
1723 |
-
array_values($vars));
|
1724 |
-
|
1725 |
-
array_pop($this->json_objectStack);
|
1726 |
-
|
1727 |
-
foreach($properties as $property) {
|
1728 |
-
if ($property instanceof Exception) {
|
1729 |
-
return $property;
|
1730 |
-
}
|
1731 |
-
}
|
1732 |
-
|
1733 |
-
return '{' . join(',', $properties) . '}';
|
1734 |
-
|
1735 |
-
default:
|
1736 |
-
return null;
|
1737 |
-
}
|
1738 |
-
}
|
1739 |
-
|
1740 |
-
/**
|
1741 |
-
* array-walking function for use in generating JSON-formatted name-value pairs
|
1742 |
-
*
|
1743 |
-
* @param string $name name of key to use
|
1744 |
-
* @param mixed $value reference to an array element to be encoded
|
1745 |
-
*
|
1746 |
-
* @return string JSON-formatted name-value pair, like '"name":value'
|
1747 |
-
* @access private
|
1748 |
-
*/
|
1749 |
-
private function json_name_value($name, $value)
|
1750 |
-
{
|
1751 |
-
// Encoding the $GLOBALS PHP array causes an infinite loop
|
1752 |
-
// if the recursion is not reset here as it contains
|
1753 |
-
// a reference to itself. This is the only way I have come up
|
1754 |
-
// with to stop infinite recursion in this case.
|
1755 |
-
if ($name=='GLOBALS'
|
1756 |
-
&& is_array($value)
|
1757 |
-
&& array_key_exists('GLOBALS',$value)) {
|
1758 |
-
$value['GLOBALS'] = '** Recursion **';
|
1759 |
-
}
|
1760 |
-
|
1761 |
-
$encoded_value = $this->json_encode($value);
|
1762 |
-
|
1763 |
-
if ($encoded_value instanceof Exception) {
|
1764 |
-
return $encoded_value;
|
1765 |
-
}
|
1766 |
-
|
1767 |
-
return $this->json_encode(strval($name)) . ':' . $encoded_value;
|
1768 |
-
}
|
1769 |
-
|
1770 |
-
/**
|
1771 |
-
* @deprecated
|
1772 |
-
*/
|
1773 |
-
public function setProcessorUrl($URL)
|
1774 |
-
{
|
1775 |
-
trigger_error("The FirePHP::setProcessorUrl() method is no longer supported", E_USER_DEPRECATED);
|
1776 |
-
}
|
1777 |
-
|
1778 |
-
/**
|
1779 |
-
* @deprecated
|
1780 |
-
*/
|
1781 |
-
public function setRendererUrl($URL)
|
1782 |
-
{
|
1783 |
-
trigger_error("The FirePHP::setRendererUrl() method is no longer supported", E_USER_DEPRECATED);
|
1784 |
-
}
|
1785 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/libs/FirePHPCore/FirePHP.class.php4
DELETED
@@ -1,1363 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
namespace mp_timetable\classes\libs\FirePHPCore;
|
3 |
-
/**
|
4 |
-
* *** BEGIN LICENSE BLOCK *****
|
5 |
-
*
|
6 |
-
* This file is part of FirePHP (http://www.firephp.org/).
|
7 |
-
*
|
8 |
-
* Software License Agreement (New BSD License)
|
9 |
-
*
|
10 |
-
* Copyright (c) 2006-2010, Christoph Dorn
|
11 |
-
* All rights reserved.
|
12 |
-
*
|
13 |
-
* Redistribution and use in source and binary forms, with or without modification,
|
14 |
-
* are permitted provided that the following conditions are met:
|
15 |
-
*
|
16 |
-
* * Redistributions of source code must retain the above copyright notice,
|
17 |
-
* this list of conditions and the following disclaimer.
|
18 |
-
*
|
19 |
-
* * Redistributions in binary form must reproduce the above copyright notice,
|
20 |
-
* this list of conditions and the following disclaimer in the documentation
|
21 |
-
* and/or other materials provided with the distribution.
|
22 |
-
*
|
23 |
-
* * Neither the name of Christoph Dorn nor the names of its
|
24 |
-
* contributors may be used to endorse or promote products derived from this
|
25 |
-
* software without specific prior written permission.
|
26 |
-
*
|
27 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
28 |
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
29 |
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
30 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
31 |
-
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
32 |
-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
33 |
-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
34 |
-
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
35 |
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
36 |
-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
37 |
-
*
|
38 |
-
* ***** END LICENSE BLOCK *****
|
39 |
-
*
|
40 |
-
* This verion of FirePHPCore is for use with PHP4. If you do not require PHP4
|
41 |
-
* compatibility, it is suggested you use FirePHPCore.class.php instead.
|
42 |
-
*
|
43 |
-
* @copyright Copyright (C) 2007-2009 Christoph Dorn
|
44 |
-
* @author Christoph Dorn <christoph@christophdorn.com>
|
45 |
-
* @author Michael Day <manveru.alma@gmail.com>
|
46 |
-
* @license http://www.opensource.org/licenses/bsd-license.php
|
47 |
-
* @package FirePHPCore
|
48 |
-
*/
|
49 |
-
|
50 |
-
/**
|
51 |
-
* FirePHP version
|
52 |
-
*
|
53 |
-
* @var string
|
54 |
-
*/
|
55 |
-
define('FirePHP_VERSION', '0.3'); // @pinf replace '0.3' with '%%package.version%%'
|
56 |
-
|
57 |
-
/**
|
58 |
-
* Firebug LOG level
|
59 |
-
*
|
60 |
-
* Logs a message to firebug console
|
61 |
-
*
|
62 |
-
* @var string
|
63 |
-
*/
|
64 |
-
define('FirePHP_LOG', 'LOG');
|
65 |
-
|
66 |
-
/**
|
67 |
-
* Firebug INFO level
|
68 |
-
*
|
69 |
-
* Logs a message to firebug console and displays an info icon before the message
|
70 |
-
*
|
71 |
-
* @var string
|
72 |
-
*/
|
73 |
-
define('FirePHP_INFO', 'INFO');
|
74 |
-
|
75 |
-
/**
|
76 |
-
* Firebug WARN level
|
77 |
-
*
|
78 |
-
* Logs a message to firebug console, displays a warning icon before the message and colors the line turquoise
|
79 |
-
*
|
80 |
-
* @var string
|
81 |
-
*/
|
82 |
-
define('FirePHP_WARN', 'WARN');
|
83 |
-
|
84 |
-
/**
|
85 |
-
* Firebug ERROR level
|
86 |
-
*
|
87 |
-
* Logs a message to firebug console, displays an error icon before the message and colors the line yellow. Also increments the firebug error count.
|
88 |
-
*
|
89 |
-
* @var string
|
90 |
-
*/
|
91 |
-
define('FirePHP_ERROR', 'ERROR');
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Dumps a variable to firebug's server panel
|
95 |
-
*
|
96 |
-
* @var string
|
97 |
-
*/
|
98 |
-
define('FirePHP_DUMP', 'DUMP');
|
99 |
-
|
100 |
-
/**
|
101 |
-
* Displays a stack trace in firebug console
|
102 |
-
*
|
103 |
-
* @var string
|
104 |
-
*/
|
105 |
-
define('FirePHP_TRACE', 'TRACE');
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Displays a table in firebug console
|
109 |
-
*
|
110 |
-
* @var string
|
111 |
-
*/
|
112 |
-
define('FirePHP_TABLE', 'TABLE');
|
113 |
-
|
114 |
-
/**
|
115 |
-
* Starts a group in firebug console
|
116 |
-
*
|
117 |
-
* @var string
|
118 |
-
*/
|
119 |
-
define('FirePHP_GROUP_START', 'GROUP_START');
|
120 |
-
|
121 |
-
/**
|
122 |
-
* Ends a group in firebug console
|
123 |
-
*
|
124 |
-
* @var string
|
125 |
-
*/
|
126 |
-
define('FirePHP_GROUP_END', 'GROUP_END');
|
127 |
-
|
128 |
-
/**
|
129 |
-
* Sends the given data to the FirePHP Firefox Extension.
|
130 |
-
* The data can be displayed in the Firebug Console or in the
|
131 |
-
* "Server" request tab.
|
132 |
-
*
|
133 |
-
* For more information see: http://www.firephp.org/
|
134 |
-
*
|
135 |
-
* @copyright Copyright (C) 2007-2009 Christoph Dorn
|
136 |
-
* @author Christoph Dorn <christoph@christophdorn.com>
|
137 |
-
* @author Michael Day <manveru.alma@gmail.com>
|
138 |
-
* @license http://www.opensource.org/licenses/bsd-license.php
|
139 |
-
* @package FirePHPCore
|
140 |
-
*/
|
141 |
-
class FirePHP {
|
142 |
-
/**
|
143 |
-
* Wildfire protocol message index
|
144 |
-
*
|
145 |
-
* @var int
|
146 |
-
*/
|
147 |
-
var $messageIndex = 1;
|
148 |
-
|
149 |
-
/**
|
150 |
-
* Options for the library
|
151 |
-
*
|
152 |
-
* @var array
|
153 |
-
*/
|
154 |
-
var $options = array('maxObjectDepth' => 5,
|
155 |
-
'maxArrayDepth' => 5,
|
156 |
-
'useNativeJsonEncode' => true,
|
157 |
-
'includeLineNumbers' => true);
|
158 |
-
|
159 |
-
/**
|
160 |
-
* Filters used to exclude object members when encoding
|
161 |
-
*
|
162 |
-
* @var array
|
163 |
-
*/
|
164 |
-
var $objectFilters = array();
|
165 |
-
|
166 |
-
/**
|
167 |
-
* A stack of objects used to detect recursion during object encoding
|
168 |
-
*
|
169 |
-
* @var object
|
170 |
-
*/
|
171 |
-
var $objectStack = array();
|
172 |
-
|
173 |
-
/**
|
174 |
-
* Flag to enable/disable logging
|
175 |
-
*
|
176 |
-
* @var boolean
|
177 |
-
*/
|
178 |
-
var $enabled = true;
|
179 |
-
|
180 |
-
/**
|
181 |
-
* The object constructor
|
182 |
-
*/
|
183 |
-
function FirePHP() {
|
184 |
-
}
|
185 |
-
|
186 |
-
|
187 |
-
/**
|
188 |
-
* When the object gets serialized only include specific object members.
|
189 |
-
*
|
190 |
-
* @return array
|
191 |
-
*/
|
192 |
-
function __sleep() {
|
193 |
-
return array('options', 'objectFilters', 'enabled');
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* Gets singleton instance of FirePHP
|
198 |
-
*
|
199 |
-
* @param boolean $AutoCreate
|
200 |
-
*
|
201 |
-
* @return FirePHP
|
202 |
-
*/
|
203 |
-
function &getInstance($AutoCreate = false) {
|
204 |
-
global $FirePHP_Instance;
|
205 |
-
|
206 |
-
if ($AutoCreate === true && !$FirePHP_Instance) {
|
207 |
-
$FirePHP_Instance = new FirePHP();
|
208 |
-
}
|
209 |
-
|
210 |
-
return $FirePHP_Instance;
|
211 |
-
}
|
212 |
-
|
213 |
-
/**
|
214 |
-
* Enable and disable logging to Firebug
|
215 |
-
*
|
216 |
-
* @param boolean $Enabled TRUE to enable, FALSE to disable
|
217 |
-
*
|
218 |
-
* @return void
|
219 |
-
*/
|
220 |
-
function setEnabled($Enabled) {
|
221 |
-
$this->enabled = $Enabled;
|
222 |
-
}
|
223 |
-
|
224 |
-
/**
|
225 |
-
* Check if logging is enabled
|
226 |
-
*
|
227 |
-
* @return boolean TRUE if enabled
|
228 |
-
*/
|
229 |
-
function getEnabled() {
|
230 |
-
return $this->enabled;
|
231 |
-
}
|
232 |
-
|
233 |
-
/**
|
234 |
-
* Specify a filter to be used when encoding an object
|
235 |
-
*
|
236 |
-
* Filters are used to exclude object members.
|
237 |
-
*
|
238 |
-
* @param string $Class The class name of the object
|
239 |
-
* @param array $Filter An array of members to exclude
|
240 |
-
*
|
241 |
-
* @return void
|
242 |
-
*/
|
243 |
-
function setObjectFilter($Class, $Filter) {
|
244 |
-
$this->objectFilters[strtolower($Class)] = $Filter;
|
245 |
-
}
|
246 |
-
|
247 |
-
/**
|
248 |
-
* Set some options for the library
|
249 |
-
*
|
250 |
-
* Options:
|
251 |
-
* - maxObjectDepth: The maximum depth to traverse objects (default: 5)
|
252 |
-
* - maxArrayDepth: The maximum depth to traverse arrays (default: 5)
|
253 |
-
* - useNativeJsonEncode: If true will use json_encode() (default: true)
|
254 |
-
* - includeLineNumbers: If true will include line numbers and filenames (default: true)
|
255 |
-
*
|
256 |
-
* @param array $Options The options to be set
|
257 |
-
*
|
258 |
-
* @return void
|
259 |
-
*/
|
260 |
-
function setOptions($Options) {
|
261 |
-
$this->options = array_merge($this->options, $Options);
|
262 |
-
}
|
263 |
-
|
264 |
-
/**
|
265 |
-
* Get options from the library
|
266 |
-
*
|
267 |
-
* @return array The currently set options
|
268 |
-
*/
|
269 |
-
function getOptions() {
|
270 |
-
return $this->options;
|
271 |
-
}
|
272 |
-
|
273 |
-
/**
|
274 |
-
* Register FirePHP as your error handler
|
275 |
-
*
|
276 |
-
* Will use FirePHP to log each php error.
|
277 |
-
*
|
278 |
-
* @return mixed Returns a string containing the previously defined error handler (if any)
|
279 |
-
*/
|
280 |
-
function registerErrorHandler() {
|
281 |
-
//NOTE: The following errors will not be caught by this error handler:
|
282 |
-
// E_ERROR, E_PARSE, E_CORE_ERROR,
|
283 |
-
// E_CORE_WARNING, E_COMPILE_ERROR,
|
284 |
-
// E_COMPILE_WARNING, E_STRICT
|
285 |
-
|
286 |
-
return set_error_handler(array($this, 'errorHandler'));
|
287 |
-
}
|
288 |
-
|
289 |
-
/**
|
290 |
-
* FirePHP's error handler
|
291 |
-
*
|
292 |
-
* Logs each php error that will occur.
|
293 |
-
*
|
294 |
-
* @param int $errno
|
295 |
-
* @param string $errstr
|
296 |
-
* @param string $errfile
|
297 |
-
* @param int $errline
|
298 |
-
* @param array $errcontext
|
299 |
-
*/
|
300 |
-
function errorHandler($errno, $errstr, $errfile, $errline, $errcontext) {
|
301 |
-
global $FirePHP_Instance;
|
302 |
-
// Don't log error if error reporting is switched off
|
303 |
-
if (error_reporting() == 0) {
|
304 |
-
return;
|
305 |
-
}
|
306 |
-
// Only log error for errors we are asking for
|
307 |
-
if (error_reporting() & $errno) {
|
308 |
-
$FirePHP_Instance->group($errstr);
|
309 |
-
$FirePHP_Instance->error("{$errfile}, line $errline");
|
310 |
-
$FirePHP_Instance->groupEnd();
|
311 |
-
}
|
312 |
-
}
|
313 |
-
|
314 |
-
/**
|
315 |
-
* Register FirePHP driver as your assert callback
|
316 |
-
*
|
317 |
-
* @return mixed Returns the original setting
|
318 |
-
*/
|
319 |
-
function registerAssertionHandler() {
|
320 |
-
return assert_options(ASSERT_CALLBACK, array($this, 'assertionHandler'));
|
321 |
-
}
|
322 |
-
|
323 |
-
/**
|
324 |
-
* FirePHP's assertion handler
|
325 |
-
*
|
326 |
-
* Logs all assertions to your firebug console and then stops the script.
|
327 |
-
*
|
328 |
-
* @param string $file File source of assertion
|
329 |
-
* @param int $line Line source of assertion
|
330 |
-
* @param mixed $code Assertion code
|
331 |
-
*/
|
332 |
-
function assertionHandler($file, $line, $code) {
|
333 |
-
$this->fb($code, 'Assertion Failed', FirePHP_ERROR, array('File' => $file, 'Line' => $line));
|
334 |
-
}
|
335 |
-
|
336 |
-
/**
|
337 |
-
* Set custom processor url for FirePHP
|
338 |
-
*
|
339 |
-
* @param string $URL
|
340 |
-
*/
|
341 |
-
function setProcessorUrl($URL) {
|
342 |
-
$this->setHeader('X-FirePHP-ProcessorURL', $URL);
|
343 |
-
}
|
344 |
-
|
345 |
-
/**
|
346 |
-
* Set custom renderer url for FirePHP
|
347 |
-
*
|
348 |
-
* @param string $URL
|
349 |
-
*/
|
350 |
-
function setRendererUrl($URL) {
|
351 |
-
$this->setHeader('X-FirePHP-RendererURL', $URL);
|
352 |
-
}
|
353 |
-
|
354 |
-
/**
|
355 |
-
* Start a group for following messages.
|
356 |
-
*
|
357 |
-
* Options:
|
358 |
-
* Collapsed: [true|false]
|
359 |
-
* Color: [#RRGGBB|ColorName]
|
360 |
-
*
|
361 |
-
* @param string $Name
|
362 |
-
* @param array $Options OPTIONAL Instructions on how to log the group
|
363 |
-
*
|
364 |
-
* @return true
|
365 |
-
* @throws Exception
|
366 |
-
*/
|
367 |
-
function group($Name, $Options = null) {
|
368 |
-
|
369 |
-
if (!$Name) {
|
370 |
-
trigger_error('You must specify a label for the group!');
|
371 |
-
}
|
372 |
-
|
373 |
-
if ($Options) {
|
374 |
-
if (!is_array($Options)) {
|
375 |
-
trigger_error('Options must be defined as an array!');
|
376 |
-
}
|
377 |
-
if (array_key_exists('Collapsed', $Options)) {
|
378 |
-
$Options['Collapsed'] = ($Options['Collapsed']) ? 'true' : 'false';
|
379 |
-
}
|
380 |
-
}
|
381 |
-
|
382 |
-
return $this->fb(null, $Name, FirePHP_GROUP_START, $Options);
|
383 |
-
}
|
384 |
-
|
385 |
-
/**
|
386 |
-
* Ends a group you have started before
|
387 |
-
*
|
388 |
-
* @return true
|
389 |
-
* @throws Exception
|
390 |
-
*/
|
391 |
-
function groupEnd() {
|
392 |
-
return $this->fb(null, null, FirePHP_GROUP_END);
|
393 |
-
}
|
394 |
-
|
395 |
-
/**
|
396 |
-
* Log object with label to firebug console
|
397 |
-
*
|
398 |
-
* @see FirePHP::LOG
|
399 |
-
*
|
400 |
-
* @param mixes $Object
|
401 |
-
* @param string $Label
|
402 |
-
*
|
403 |
-
* @return true
|
404 |
-
* @throws Exception
|
405 |
-
*/
|
406 |
-
function log($Object, $Label = null) {
|
407 |
-
return $this->fb($Object, $Label, FirePHP_LOG);
|
408 |
-
}
|
409 |
-
|
410 |
-
/**
|
411 |
-
* Log object with label to firebug console
|
412 |
-
*
|
413 |
-
* @see FirePHP::INFO
|
414 |
-
*
|
415 |
-
* @param mixes $Object
|
416 |
-
* @param string $Label
|
417 |
-
*
|
418 |
-
* @return true
|
419 |
-
* @throws Exception
|
420 |
-
*/
|
421 |
-
function info($Object, $Label = null) {
|
422 |
-
return $this->fb($Object, $Label, FirePHP_INFO);
|
423 |
-
}
|
424 |
-
|
425 |
-
/**
|
426 |
-
* Log object with label to firebug console
|
427 |
-
*
|
428 |
-
* @see FirePHP::WARN
|
429 |
-
*
|
430 |
-
* @param mixes $Object
|
431 |
-
* @param string $Label
|
432 |
-
*
|
433 |
-
* @return true
|
434 |
-
* @throws Exception
|
435 |
-
*/
|
436 |
-
function warn($Object, $Label = null) {
|
437 |
-
return $this->fb($Object, $Label, FirePHP_WARN);
|
438 |
-
}
|
439 |
-
|
440 |
-
/**
|
441 |
-
* Log object with label to firebug console
|
442 |
-
*
|
443 |
-
* @see FirePHP::ERROR
|
444 |
-
*
|
445 |
-
* @param mixes $Object
|
446 |
-
* @param string $Label
|
447 |
-
*
|
448 |
-
* @return true
|
449 |
-
* @throws Exception
|
450 |
-
*/
|
451 |
-
function error($Object, $Label = null) {
|
452 |
-
return $this->fb($Object, $Label, FirePHP_ERROR);
|
453 |
-
}
|
454 |
-
|
455 |
-
/**
|
456 |
-
* Dumps key and variable to firebug server panel
|
457 |
-
*
|
458 |
-
* @see FirePHP::DUMP
|
459 |
-
*
|
460 |
-
* @param string $Key
|
461 |
-
* @param mixed $Variable
|
462 |
-
*
|
463 |
-
* @return true
|
464 |
-
* @throws Exception
|
465 |
-
*/
|
466 |
-
function dump($Key, $Variable) {
|
467 |
-
return $this->fb($Variable, $Key, FirePHP_DUMP);
|
468 |
-
}
|
469 |
-
|
470 |
-
/**
|
471 |
-
* Log a trace in the firebug console
|
472 |
-
*
|
473 |
-
* @see FirePHP::TRACE
|
474 |
-
*
|
475 |
-
* @param string $Label
|
476 |
-
*
|
477 |
-
* @return true
|
478 |
-
* @throws Exception
|
479 |
-
*/
|
480 |
-
function trace($Label) {
|
481 |
-
return $this->fb($Label, FirePHP_TRACE);
|
482 |
-
}
|
483 |
-
|
484 |
-
/**
|
485 |
-
* Log a table in the firebug console
|
486 |
-
*
|
487 |
-
* @see FirePHP::TABLE
|
488 |
-
*
|
489 |
-
* @param string $Label
|
490 |
-
* @param string $Table
|
491 |
-
*
|
492 |
-
* @return true
|
493 |
-
* @throws Exception
|
494 |
-
*/
|
495 |
-
function table($Label, $Table) {
|
496 |
-
return $this->fb($Table, $Label, FirePHP_TABLE);
|
497 |
-
}
|
498 |
-
|
499 |
-
/**
|
500 |
-
* Check if FirePHP is installed on client
|
501 |
-
*
|
502 |
-
* @return boolean
|
503 |
-
*/
|
504 |
-
function detectClientExtension() {
|
505 |
-
// Check if FirePHP is installed on client via User-Agent header
|
506 |
-
if (@preg_match_all('/\sFirePHP\/([\.\d]*)\s?/si', $this->getUserAgent(), $m) &&
|
507 |
-
version_compare($m[1][0], '0.0.6', '>=')
|
508 |
-
) {
|
509 |
-
return true;
|
510 |
-
} else
|
511 |
-
// Check if FirePHP is installed on client via X-FirePHP-Version header
|
512 |
-
if (@preg_match_all('/^([\.\d]*)$/si', $this->getRequestHeader("X-FirePHP-Version"), $m) &&
|
513 |
-
version_compare($m[1][0], '0.0.6', '>=')
|
514 |
-
) {
|
515 |
-
return true;
|
516 |
-
}
|
517 |
-
return false;
|
518 |
-
}
|
519 |
-
|
520 |
-
/**
|
521 |
-
* Log varible to Firebug
|
522 |
-
*
|
523 |
-
* @see http://www.firephp.org/Wiki/Reference/Fb
|
524 |
-
*
|
525 |
-
* @param mixed $Object The variable to be logged
|
526 |
-
*
|
527 |
-
* @return true Return TRUE if message was added to headers, FALSE otherwise
|
528 |
-
* @throws Exception
|
529 |
-
*/
|
530 |
-
function fb($Object) {
|
531 |
-
|
532 |
-
if (!$this->enabled) {
|
533 |
-
return false;
|
534 |
-
}
|
535 |
-
|
536 |
-
if (headers_sent($filename, $linenum)) {
|
537 |
-
trigger_error('Headers already sent in ' . $filename . ' on line ' . $linenum . '. Cannot send log data to FirePHP. You must have Output Buffering enabled via ob_start() or output_buffering ini directive.');
|
538 |
-
}
|
539 |
-
|
540 |
-
$Type = null;
|
541 |
-
$Label = null;
|
542 |
-
$Options = array();
|
543 |
-
|
544 |
-
if (func_num_args() == 1) {
|
545 |
-
} else
|
546 |
-
if (func_num_args() == 2) {
|
547 |
-
switch (func_get_arg(1)) {
|
548 |
-
case FirePHP_LOG:
|
549 |
-
case FirePHP_INFO:
|
550 |
-
case FirePHP_WARN:
|
551 |
-
case FirePHP_ERROR:
|
552 |
-
case FirePHP_DUMP:
|
553 |
-
case FirePHP_TRACE:
|
554 |
-
case FirePHP_TABLE:
|
555 |
-
case FirePHP_GROUP_START:
|
556 |
-
case FirePHP_GROUP_END:
|
557 |
-
$Type = func_get_arg(1);
|
558 |
-
break;
|
559 |
-
default:
|
560 |
-
$Label = func_get_arg(1);
|
561 |
-
break;
|
562 |
-
}
|
563 |
-
} else
|
564 |
-
if (func_num_args() == 3) {
|
565 |
-
$Type = func_get_arg(2);
|
566 |
-
$Label = func_get_arg(1);
|
567 |
-
} else
|
568 |
-
if (func_num_args() == 4) {
|
569 |
-
$Type = func_get_arg(2);
|
570 |
-
$Label = func_get_arg(1);
|
571 |
-
$Options = func_get_arg(3);
|
572 |
-
} else {
|
573 |
-
trigger_error('Wrong number of arguments to fb() function!');
|
574 |
-
}
|
575 |
-
|
576 |
-
|
577 |
-
if (!$this->detectClientExtension()) {
|
578 |
-
return false;
|
579 |
-
}
|
580 |
-
|
581 |
-
$meta = array();
|
582 |
-
$skipFinalObjectEncode = false;
|
583 |
-
|
584 |
-
if ($Type == FirePHP_TRACE) {
|
585 |
-
|
586 |
-
$trace = debug_backtrace();
|
587 |
-
if (!$trace) return false;
|
588 |
-
for ($i = 0; $i < sizeof($trace); $i++) {
|
589 |
-
|
590 |
-
if (isset($trace[$i]['class'])
|
591 |
-
&& isset($trace[$i]['file'])
|
592 |
-
&& ($trace[$i]['class'] == 'FirePHP'
|
593 |
-
|| $trace[$i]['class'] == 'FB')
|
594 |
-
&& (substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php'
|
595 |
-
|| substr($this->_standardizePath($trace[$i]['file']), -29, 29) == 'FirePHPCore/FirePHP.class.php')
|
596 |
-
) {
|
597 |
-
/* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */
|
598 |
-
} else
|
599 |
-
if (isset($trace[$i]['class'])
|
600 |
-
&& isset($trace[$i + 1]['file'])
|
601 |
-
&& $trace[$i]['class'] == 'FirePHP'
|
602 |
-
&& substr($this->_standardizePath($trace[$i + 1]['file']), -18, 18) == 'FirePHPCore/fb.php'
|
603 |
-
) {
|
604 |
-
/* Skip fb() */
|
605 |
-
} else
|
606 |
-
if ($trace[$i]['function'] == 'fb'
|
607 |
-
|| $trace[$i]['function'] == 'trace'
|
608 |
-
|| $trace[$i]['function'] == 'send'
|
609 |
-
) {
|
610 |
-
$Object = array('Class' => isset($trace[$i]['class']) ? $trace[$i]['class'] : '',
|
611 |
-
'Type' => isset($trace[$i]['type']) ? $trace[$i]['type'] : '',
|
612 |
-
'Function' => isset($trace[$i]['function']) ? $trace[$i]['function'] : '',
|
613 |
-
'Message' => $trace[$i]['args'][0],
|
614 |
-
'File' => isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : '',
|
615 |
-
'Line' => isset($trace[$i]['line']) ? $trace[$i]['line'] : '',
|
616 |
-
'Args' => isset($trace[$i]['args']) ? $this->encodeObject($trace[$i]['args']) : '',
|
617 |
-
'Trace' => $this->_escapeTrace(array_splice($trace, $i + 1)));
|
618 |
-
|
619 |
-
$skipFinalObjectEncode = true;
|
620 |
-
$meta['file'] = isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : '';
|
621 |
-
$meta['line'] = isset($trace[$i]['line']) ? $trace[$i]['line'] : '';
|
622 |
-
break;
|
623 |
-
}
|
624 |
-
}
|
625 |
-
|
626 |
-
} else
|
627 |
-
if ($Type == FirePHP_TABLE) {
|
628 |
-
|
629 |
-
if (isset($Object[0]) && is_string($Object[0])) {
|
630 |
-
$Object[1] = $this->encodeTable($Object[1]);
|
631 |
-
} else {
|
632 |
-
$Object = $this->encodeTable($Object);
|
633 |
-
}
|
634 |
-
|
635 |
-
$skipFinalObjectEncode = true;
|
636 |
-
|
637 |
-
} else
|
638 |
-
if ($Type == FirePHP_GROUP_START) {
|
639 |
-
|
640 |
-
if (!$Label) {
|
641 |
-
trigger_error('You must specify a label for the group!');
|
642 |
-
}
|
643 |
-
} else {
|
644 |
-
if ($Type === null) {
|
645 |
-
$Type = FirePHP_LOG;
|
646 |
-
}
|
647 |
-
}
|
648 |
-
|
649 |
-
if ($this->options['includeLineNumbers']) {
|
650 |
-
if (!isset($meta['file']) || !isset($meta['line'])) {
|
651 |
-
|
652 |
-
$trace = debug_backtrace();
|
653 |
-
for ($i = 0; $trace && $i < sizeof($trace); $i++) {
|
654 |
-
|
655 |
-
if (isset($trace[$i]['class'])
|
656 |
-
&& isset($trace[$i]['file'])
|
657 |
-
&& ($trace[$i]['class'] == 'FirePHP'
|
658 |
-
|| $trace[$i]['class'] == 'FB')
|
659 |
-
&& (substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php'
|
660 |
-
|| substr($this->_standardizePath($trace[$i]['file']), -29, 29) == 'FirePHPCore/FirePHP.class.php')
|
661 |
-
) {
|
662 |
-
/* Skip - FB::trace(), FB::send(), $firephp->trace(), $firephp->fb() */
|
663 |
-
} else
|
664 |
-
if (isset($trace[$i]['class'])
|
665 |
-
&& isset($trace[$i + 1]['file'])
|
666 |
-
&& $trace[$i]['class'] == 'FirePHP'
|
667 |
-
&& substr($this->_standardizePath($trace[$i + 1]['file']), -18, 18) == 'FirePHPCore/fb.php'
|
668 |
-
) {
|
669 |
-
/* Skip fb() */
|
670 |
-
} else
|
671 |
-
if (isset($trace[$i]['file'])
|
672 |
-
&& substr($this->_standardizePath($trace[$i]['file']), -18, 18) == 'FirePHPCore/fb.php'
|
673 |
-
) {
|
674 |
-
/* Skip FB::fb() */
|
675 |
-
} else {
|
676 |
-
$meta['file'] = isset($trace[$i]['file']) ? $this->_escapeTraceFile($trace[$i]['file']) : '';
|
677 |
-
$meta['line'] = isset($trace[$i]['line']) ? $trace[$i]['line'] : '';
|
678 |
-
break;
|
679 |
-
}
|
680 |
-
}
|
681 |
-
|
682 |
-
}
|
683 |
-
} else {
|
684 |
-
unset($meta['file']);
|
685 |
-
unset($meta['line']);
|
686 |
-
}
|
687 |
-
|
688 |
-
$this->setHeader('X-Wf-Protocol-1', 'http://meta.wildfirehq.org/Protocol/JsonStream/0.2');
|
689 |
-
$this->setHeader('X-Wf-1-Plugin-1', 'http://meta.firephp.org/Wildfire/Plugin/FirePHP/Library-FirePHPCore/' . FirePHP_VERSION);
|
690 |
-
|
691 |
-
$structure_index = 1;
|
692 |
-
if ($Type == FirePHP_DUMP) {
|
693 |
-
$structure_index = 2;
|
694 |
-
$this->setHeader('X-Wf-1-Structure-2', 'http://meta.firephp.org/Wildfire/Structure/FirePHP/Dump/0.1');
|
695 |
-
} else {
|
696 |
-
$this->setHeader('X-Wf-1-Structure-1', 'http://meta.firephp.org/Wildfire/Structure/FirePHP/FirebugConsole/0.1');
|
697 |
-
}
|
698 |
-
|
699 |
-
if ($Type == FirePHP_DUMP) {
|
700 |
-
$msg = '{"' . $Label . '":' . $this->jsonEncode($Object, $skipFinalObjectEncode) . '}';
|
701 |
-
} else {
|
702 |
-
$msg_meta = $Options;
|
703 |
-
$msg_meta['Type'] = $Type;
|
704 |
-
if ($Label !== null) {
|
705 |
-
$msg_meta['Label'] = $Label;
|
706 |
-
}
|
707 |
-
if (isset($meta['file']) && !isset($msg_meta['File'])) {
|
708 |
-
$msg_meta['File'] = $meta['file'];
|
709 |
-
}
|
710 |
-
if (isset($meta['line']) && !isset($msg_meta['Line'])) {
|
711 |
-
$msg_meta['Line'] = $meta['line'];
|
712 |
-
}
|
713 |
-
$msg = '[' . $this->jsonEncode($msg_meta) . ',' . $this->jsonEncode($Object, $skipFinalObjectEncode) . ']';
|
714 |
-
}
|
715 |
-
|
716 |
-
$parts = explode("\n", chunk_split($msg, 5000, "\n"));
|
717 |
-
|
718 |
-
for ($i = 0; $i < count($parts); $i++) {
|
719 |
-
|
720 |
-
$part = $parts[$i];
|
721 |
-
if ($part) {
|
722 |
-
|
723 |
-
if (count($parts) > 2) {
|
724 |
-
// Message needs to be split into multiple parts
|
725 |
-
$this->setHeader('X-Wf-1-' . $structure_index . '-' . '1-' . $this->messageIndex,
|
726 |
-
(($i == 0) ? strlen($msg) : '')
|
727 |
-
. '|' . $part . '|'
|
728 |
-
. (($i < count($parts) - 2) ? '\\' : ''));
|
729 |
-
} else {
|
730 |
-
$this->setHeader('X-Wf-1-' . $structure_index . '-' . '1-' . $this->messageIndex,
|
731 |
-
strlen($part) . '|' . $part . '|');
|
732 |
-
}
|
733 |
-
|
734 |
-
$this->messageIndex++;
|
735 |
-
|
736 |
-
if ($this->messageIndex > 99999) {
|
737 |
-
trigger_error('Maximum number (99,999) of messages reached!');
|
738 |
-
}
|
739 |
-
}
|
740 |
-
}
|
741 |
-
|
742 |
-
$this->setHeader('X-Wf-1-Index', $this->messageIndex - 1);
|
743 |
-
|
744 |
-
return true;
|
745 |
-
}
|
746 |
-
|
747 |
-
|
748 |
-
/**
|
749 |
-
* Standardizes path for windows systems.
|
750 |
-
*
|
751 |
-
* @param string $Path
|
752 |
-
*
|
753 |
-
* @return string
|
754 |
-
*/
|
755 |
-
function _standardizePath($Path) {
|
756 |
-
return preg_replace('/\\\\+/', '/', $Path);
|
757 |
-
}
|
758 |
-
|
759 |
-
/**
|
760 |
-
* Escape trace path for windows systems
|
761 |
-
*
|
762 |
-
* @param array $Trace
|
763 |
-
*
|
764 |
-
* @return array
|
765 |
-
*/
|
766 |
-
function _escapeTrace($Trace) {
|
767 |
-
if (!$Trace) return $Trace;
|
768 |
-
for ($i = 0; $i < sizeof($Trace); $i++) {
|
769 |
-
if (isset($Trace[$i]['file'])) {
|
770 |
-
$Trace[$i]['file'] = $this->_escapeTraceFile($Trace[$i]['file']);
|
771 |
-
}
|
772 |
-
if (isset($Trace[$i]['args'])) {
|
773 |
-
$Trace[$i]['args'] = $this->encodeObject($Trace[$i]['args']);
|
774 |
-
}
|
775 |
-
}
|
776 |
-
return $Trace;
|
777 |
-
}
|
778 |
-
|
779 |
-
/**
|
780 |
-
* Escape file information of trace for windows systems
|
781 |
-
*
|
782 |
-
* @param string $File
|
783 |
-
*
|
784 |
-
* @return string
|
785 |
-
*/
|
786 |
-
function _escapeTraceFile($File) {
|
787 |
-
/* Check if we have a windows filepath */
|
788 |
-
if (strpos($File, '\\')) {
|
789 |
-
/* First strip down to single \ */
|
790 |
-
|
791 |
-
$file = preg_replace('/\\\\+/', '\\', $File);
|
792 |
-
|
793 |
-
return $file;
|
794 |
-
}
|
795 |
-
return $File;
|
796 |
-
}
|
797 |
-
|
798 |
-
/**
|
799 |
-
* Send header
|
800 |
-
*
|
801 |
-
* @param string $Name
|
802 |
-
* @param string_type $Value
|
803 |
-
*/
|
804 |
-
function setHeader($Name, $Value) {
|
805 |
-
return header($Name . ': ' . $Value);
|
806 |
-
}
|
807 |
-
|
808 |
-
/**
|
809 |
-
* Get user agent
|
810 |
-
*
|
811 |
-
* @return string|false
|
812 |
-
*/
|
813 |
-
function getUserAgent() {
|
814 |
-
if (!isset($_SERVER['HTTP_USER_AGENT'])) return false;
|
815 |
-
return $_SERVER['HTTP_USER_AGENT'];
|
816 |
-
}
|
817 |
-
|
818 |
-
/**
|
819 |
-
* Get all request headers
|
820 |
-
*
|
821 |
-
* @return array
|
822 |
-
*/
|
823 |
-
function getAllRequestHeaders() {
|
824 |
-
$headers = array();
|
825 |
-
if (function_exists('getallheaders')) {
|
826 |
-
foreach (getallheaders() as $name => $value) {
|
827 |
-
$headers[strtolower($name)] = $value;
|
828 |
-
}
|
829 |
-
} else {
|
830 |
-
foreach ($_SERVER as $name => $value) {
|
831 |
-
if (substr($name, 0, 5) == 'HTTP_') {
|
832 |
-
$headers[strtolower(str_replace(' ', '-', str_replace('_', ' ', substr($name, 5))))] = $value;
|
833 |
-
}
|
834 |
-
}
|
835 |
-
}
|
836 |
-
return $headers;
|
837 |
-
}
|
838 |
-
|
839 |
-
/**
|
840 |
-
* Get a request header
|
841 |
-
*
|
842 |
-
* @return string|false
|
843 |
-
*/
|
844 |
-
function getRequestHeader($Name) {
|
845 |
-
$headers = $this->getAllRequestHeaders();
|
846 |
-
if (isset($headers[strtolower($Name)])) {
|
847 |
-
return $headers[strtolower($Name)];
|
848 |
-
}
|
849 |
-
return false;
|
850 |
-
}
|
851 |
-
|
852 |
-
/**
|
853 |
-
* Encode an object into a JSON string
|
854 |
-
*
|
855 |
-
* Uses PHP's jeson_encode() if available
|
856 |
-
*
|
857 |
-
* @param object $Object The object to be encoded
|
858 |
-
*
|
859 |
-
* @return string The JSON string
|
860 |
-
*/
|
861 |
-
function jsonEncode($Object, $skipObjectEncode = false) {
|
862 |
-
if (!$skipObjectEncode) {
|
863 |
-
$Object = $this->encodeObject($Object);
|
864 |
-
}
|
865 |
-
|
866 |
-
if (function_exists('json_encode')
|
867 |
-
&& $this->options['useNativeJsonEncode'] != false
|
868 |
-
) {
|
869 |
-
|
870 |
-
return json_encode($Object);
|
871 |
-
} else {
|
872 |
-
return $this->json_encode($Object);
|
873 |
-
}
|
874 |
-
}
|
875 |
-
|
876 |
-
/**
|
877 |
-
* Encodes a table by encoding each row and column with encodeObject()
|
878 |
-
*
|
879 |
-
* @param array $Table The table to be encoded
|
880 |
-
*
|
881 |
-
* @return array
|
882 |
-
*/
|
883 |
-
function encodeTable($Table) {
|
884 |
-
|
885 |
-
if (!$Table) return $Table;
|
886 |
-
|
887 |
-
$new_table = array();
|
888 |
-
foreach ($Table as $row) {
|
889 |
-
|
890 |
-
if (is_array($row)) {
|
891 |
-
$new_row = array();
|
892 |
-
|
893 |
-
foreach ($row as $item) {
|
894 |
-
$new_row[] = $this->encodeObject($item);
|
895 |
-
}
|
896 |
-
|
897 |
-
$new_table[] = $new_row;
|
898 |
-
}
|
899 |
-
}
|
900 |
-
|
901 |
-
return $new_table;
|
902 |
-
}
|
903 |
-
|
904 |
-
/**
|
905 |
-
* Encodes an object
|
906 |
-
*
|
907 |
-
* @param Object $Object The object to be encoded
|
908 |
-
* @param int $Depth The current traversal depth
|
909 |
-
*
|
910 |
-
* @return array All members of the object
|
911 |
-
*/
|
912 |
-
function encodeObject($Object, $ObjectDepth = 1, $ArrayDepth = 1) {
|
913 |
-
$return = array();
|
914 |
-
|
915 |
-
if (is_resource($Object)) {
|
916 |
-
|
917 |
-
return '** ' . (string)$Object . ' **';
|
918 |
-
|
919 |
-
} else
|
920 |
-
if (is_object($Object)) {
|
921 |
-
|
922 |
-
if ($ObjectDepth > $this->options['maxObjectDepth']) {
|
923 |
-
return '** Max Object Depth (' . $this->options['maxObjectDepth'] . ') **';
|
924 |
-
}
|
925 |
-
|
926 |
-
foreach ($this->objectStack as $refVal) {
|
927 |
-
if ($refVal === $Object) {
|
928 |
-
return '** Recursion (' . get_class($Object) . ') **';
|
929 |
-
}
|
930 |
-
}
|
931 |
-
array_push($this->objectStack, $Object);
|
932 |
-
|
933 |
-
$return['__className'] = $class = get_class($Object);
|
934 |
-
$class_lower = strtolower($class);
|
935 |
-
|
936 |
-
$members = (array)$Object;
|
937 |
-
|
938 |
-
// Include all members that are not defined in the class
|
939 |
-
// but exist in the object
|
940 |
-
foreach ($members as $raw_name => $value) {
|
941 |
-
|
942 |
-
$name = $raw_name;
|
943 |
-
|
944 |
-
if ($name{0} == "\0") {
|
945 |
-
$parts = explode("\0", $name);
|
946 |
-
$name = $parts[2];
|
947 |
-
}
|
948 |
-
|
949 |
-
if (!isset($properties[$name])) {
|
950 |
-
$name = 'undeclared:' . $name;
|
951 |
-
|
952 |
-
if (!(isset($this->objectFilters[$class_lower])
|
953 |
-
&& is_array($this->objectFilters[$class_lower])
|
954 |
-
&& in_array($raw_name, $this->objectFilters[$class_lower]))
|
955 |
-
) {
|
956 |
-
|
957 |
-
$return[$name] = $this->encodeObject($value, $ObjectDepth + 1, 1);
|
958 |
-
} else {
|
959 |
-
$return[$name] = '** Excluded by Filter **';
|
960 |
-
}
|
961 |
-
}
|
962 |
-
}
|
963 |
-
|
964 |
-
array_pop($this->objectStack);
|
965 |
-
|
966 |
-
} elseif (is_array($Object)) {
|
967 |
-
|
968 |
-
if ($ArrayDepth > $this->options['maxArrayDepth']) {
|
969 |
-
return '** Max Array Depth (' . $this->options['maxArrayDepth'] . ') **';
|
970 |
-
}
|
971 |
-
|
972 |
-
foreach ($Object as $key => $val) {
|
973 |
-
|
974 |
-
// Encoding the $GLOBALS PHP array causes an infinite loop
|
975 |
-
// if the recursion is not reset here as it contains
|
976 |
-
// a reference to itself. This is the only way I have come up
|
977 |
-
// with to stop infinite recursion in this case.
|
978 |
-
if ($key == 'GLOBALS'
|
979 |
-
&& is_array($val)
|
980 |
-
&& array_key_exists('GLOBALS', $val)
|
981 |
-
) {
|
982 |
-
$val['GLOBALS'] = '** Recursion (GLOBALS) **';
|
983 |
-
}
|
984 |
-
|
985 |
-
$return[$key] = $this->encodeObject($val, 1, $ArrayDepth + 1);
|
986 |
-
}
|
987 |
-
} else {
|
988 |
-
if ($this->is_utf8($Object)) {
|
989 |
-
return $Object;
|
990 |
-
} else {
|
991 |
-
return utf8_encode($Object);
|
992 |
-
}
|
993 |
-
}
|
994 |
-
return $return;
|
995 |
-
|
996 |
-
}
|
997 |
-
|
998 |
-
/**
|
999 |
-
* Returns true if $string is valid UTF-8 and false otherwise.
|
1000 |
-
*
|
1001 |
-
* @param mixed $str String to be tested
|
1002 |
-
*
|
1003 |
-
* @return boolean
|
1004 |
-
*/
|
1005 |
-
function is_utf8($str) {
|
1006 |
-
$c = 0;
|
1007 |
-
$b = 0;
|
1008 |
-
$bits = 0;
|
1009 |
-
$len = strlen($str);
|
1010 |
-
for ($i = 0; $i < $len; $i++) {
|
1011 |
-
$c = ord($str[$i]);
|
1012 |
-
if ($c > 128) {
|
1013 |
-
if (($c >= 254)) return false;
|
1014 |
-
elseif ($c >= 252) $bits = 6;
|
1015 |
-
elseif ($c >= 248) $bits = 5;
|
1016 |
-
elseif ($c >= 240) $bits = 4;
|
1017 |
-
elseif ($c >= 224) $bits = 3;
|
1018 |
-
elseif ($c >= 192) $bits = 2;
|
1019 |
-
else return false;
|
1020 |
-
if (($i + $bits) > $len) return false;
|
1021 |
-
while ($bits > 1) {
|
1022 |
-
$i++;
|
1023 |
-
$b = ord($str[$i]);
|
1024 |
-
if ($b < 128 || $b > 191) return false;
|
1025 |
-
$bits--;
|
1026 |
-
}
|
1027 |
-
}
|
1028 |
-
}
|
1029 |
-
return true;
|
1030 |
-
}
|
1031 |
-
|
1032 |
-
/**
|
1033 |
-
* Converts to and from JSON format.
|
1034 |
-
*
|
1035 |
-
* JSON (JavaScript Object Notation) is a lightweight data-interchange
|
1036 |
-
* format. It is easy for humans to read and write. It is easy for machines
|
1037 |
-
* to parse and generate. It is based on a subset of the JavaScript
|
1038 |
-
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
|
1039 |
-
* This feature can also be found in Python. JSON is a text format that is
|
1040 |
-
* completely language independent but uses conventions that are familiar
|
1041 |
-
* to programmers of the C-family of languages, including C, C++, C#, Java,
|
1042 |
-
* JavaScript, Perl, TCL, and many others. These properties make JSON an
|
1043 |
-
* ideal data-interchange language.
|
1044 |
-
*
|
1045 |
-
* This package provides a simple encoder and decoder for JSON notation. It
|
1046 |
-
* is intended for use with client-side Javascript applications that make
|
1047 |
-
* use of HTTPRequest to perform server communication functions - data can
|
1048 |
-
* be encoded into JSON notation for use in a client-side javascript, or
|
1049 |
-
* decoded from incoming Javascript requests. JSON format is native to
|
1050 |
-
* Javascript, and can be directly eval()'ed with no further parsing
|
1051 |
-
* overhead
|
1052 |
-
*
|
1053 |
-
* All strings should be in ASCII or UTF-8 format!
|
1054 |
-
*
|
1055 |
-
* LICENSE: Redistribution and use in source and binary forms, with or
|
1056 |
-
* without modification, are permitted provided that the following
|
1057 |
-
* conditions are met: Redistributions of source code must retain the
|
1058 |
-
* above copyright notice, this list of conditions and the following
|
1059 |
-
* disclaimer. Redistributions in binary form must reproduce the above
|
1060 |
-
* copyright notice, this list of conditions and the following disclaimer
|
1061 |
-
* in the documentation and/or other materials provided with the
|
1062 |
-
* distribution.
|
1063 |
-
*
|
1064 |
-
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
1065 |
-
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
1066 |
-
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
1067 |
-
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
1068 |
-
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
1069 |
-
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
1070 |
-
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
1071 |
-
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
1072 |
-
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
1073 |
-
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
1074 |
-
* DAMAGE.
|
1075 |
-
*
|
1076 |
-
* @category
|
1077 |
-
* @package Services_JSON
|
1078 |
-
* @author Michal Migurski <mike-json@teczno.com>
|
1079 |
-
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
|
1080 |
-
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
|
1081 |
-
* @author Christoph Dorn <christoph@christophdorn.com>
|
1082 |
-
* @copyright 2005 Michal Migurski
|
1083 |
-
* @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
|
1084 |
-
* @license http://www.opensource.org/licenses/bsd-license.php
|
1085 |
-
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
|
1086 |
-
*/
|
1087 |
-
|
1088 |
-
|
1089 |
-
/**
|
1090 |
-
* Keep a list of objects as we descend into the array so we can detect recursion.
|
1091 |
-
*/
|
1092 |
-
var $json_objectStack = array();
|
1093 |
-
|
1094 |
-
|
1095 |
-
/**
|
1096 |
-
* convert a string from one UTF-8 char to one UTF-16 char
|
1097 |
-
*
|
1098 |
-
* Normally should be handled by mb_convert_encoding, but
|
1099 |
-
* provides a slower PHP-only method for installations
|
1100 |
-
* that lack the multibye string extension.
|
1101 |
-
*
|
1102 |
-
* @param string $utf8 UTF-8 character
|
1103 |
-
*
|
1104 |
-
* @return string UTF-16 character
|
1105 |
-
* @access private
|
1106 |
-
*/
|
1107 |
-
function json_utf82utf16($utf8) {
|
1108 |
-
// oh please oh please oh please oh please oh please
|
1109 |
-
if (function_exists('mb_convert_encoding')) {
|
1110 |
-
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
|
1111 |
-
}
|
1112 |
-
|
1113 |
-
switch (strlen($utf8)) {
|
1114 |
-
case 1:
|
1115 |
-
// this case should never be reached, because we are in ASCII range
|
1116 |
-
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
1117 |
-
return $utf8;
|
1118 |
-
|
1119 |
-
case 2:
|
1120 |
-
// return a UTF-16 character from a 2-byte UTF-8 char
|
1121 |
-
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
1122 |
-
return chr(0x07 & (ord($utf8{0}) >> 2))
|
1123 |
-
. chr((0xC0 & (ord($utf8{0}) << 6))
|
1124 |
-
| (0x3F & ord($utf8{1})));
|
1125 |
-
|
1126 |
-
case 3:
|
1127 |
-
// return a UTF-16 character from a 3-byte UTF-8 char
|
1128 |
-
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
1129 |
-
return chr((0xF0 & (ord($utf8{0}) << 4))
|
1130 |
-
| (0x0F & (ord($utf8{1}) >> 2)))
|
1131 |
-
. chr((0xC0 & (ord($utf8{1}) << 6))
|
1132 |
-
| (0x7F & ord($utf8{2})));
|
1133 |
-
}
|
1134 |
-
|
1135 |
-
// ignoring UTF-32 for now, sorry
|
1136 |
-
return '';
|
1137 |
-
}
|
1138 |
-
|
1139 |
-
/**
|
1140 |
-
* encodes an arbitrary variable into JSON format
|
1141 |
-
*
|
1142 |
-
* @param mixed $var any number, boolean, string, array, or object to be encoded.
|
1143 |
-
* see argument 1 to Services_JSON() above for array-parsing behavior.
|
1144 |
-
* if var is a strng, note that encode() always expects it
|
1145 |
-
* to be in ASCII or UTF-8 format!
|
1146 |
-
*
|
1147 |
-
* @return mixed JSON string representation of input var or an error if a problem occurs
|
1148 |
-
* @access public
|
1149 |
-
*/
|
1150 |
-
function json_encode($var) {
|
1151 |
-
|
1152 |
-
if (is_object($var)) {
|
1153 |
-
if (in_array($var, $this->json_objectStack)) {
|
1154 |
-
return '"** Recursion **"';
|
1155 |
-
}
|
1156 |
-
}
|
1157 |
-
|
1158 |
-
switch (gettype($var)) {
|
1159 |
-
case 'boolean':
|
1160 |
-
return $var ? 'true' : 'false';
|
1161 |
-
|
1162 |
-
case 'NULL':
|
1163 |
-
return 'null';
|
1164 |
-
|
1165 |
-
case 'integer':
|
1166 |
-
return (int)$var;
|
1167 |
-
|
1168 |
-
case 'double':
|
1169 |
-
case 'float':
|
1170 |
-
return (float)$var;
|
1171 |
-
|
1172 |
-
case 'string':
|
1173 |
-
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
|
1174 |
-
$ascii = '';
|
1175 |
-
$strlen_var = strlen($var);
|
1176 |
-
|
1177 |
-
/*
|
1178 |
-
* Iterate over every character in the string,
|
1179 |
-
* escaping with a slash or encoding to UTF-8 where necessary
|
1180 |
-
*/
|
1181 |
-
for ($c = 0; $c < $strlen_var; ++$c) {
|
1182 |
-
|
1183 |
-
$ord_var_c = ord($var{$c});
|
1184 |
-
|
1185 |
-
switch (true) {
|
1186 |
-
case $ord_var_c == 0x08:
|
1187 |
-
$ascii .= '\b';
|
1188 |
-
break;
|
1189 |
-
case $ord_var_c == 0x09:
|
1190 |
-
$ascii .= '\t';
|
1191 |
-
break;
|
1192 |
-
case $ord_var_c == 0x0A:
|
1193 |
-
$ascii .= '\n';
|
1194 |
-
break;
|
1195 |
-
case $ord_var_c == 0x0C:
|
1196 |
-
$ascii .= '\f';
|
1197 |
-
break;
|
1198 |
-
case $ord_var_c == 0x0D:
|
1199 |
-
$ascii .= '\r';
|
1200 |
-
break;
|
1201 |
-
|
1202 |
-
case $ord_var_c == 0x22:
|
1203 |
-
case $ord_var_c == 0x2F:
|
1204 |
-
case $ord_var_c == 0x5C:
|
1205 |
-
// double quote, slash, slosh
|
1206 |
-
$ascii .= '\\' . $var{$c};
|
1207 |
-
break;
|
1208 |
-
|
1209 |
-
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
|
1210 |
-
// characters U-00000000 - U-0000007F (same as ASCII)
|
1211 |
-
$ascii .= $var{$c};
|
1212 |
-
break;
|
1213 |
-
|
1214 |
-
case (($ord_var_c & 0xE0) == 0xC0):
|
1215 |
-
// characters U-00000080 - U-000007FF, mask 110XXXXX
|
1216 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
1217 |
-
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
|
1218 |
-
$c += 1;
|
1219 |
-
$utf16 = $this->json_utf82utf16($char);
|
1220 |
-
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
1221 |
-
break;
|
1222 |
-
|
1223 |
-
case (($ord_var_c & 0xF0) == 0xE0):
|
1224 |
-
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
|
1225 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
1226 |
-
$char = pack('C*', $ord_var_c,
|
1227 |
-
ord($var{$c + 1}),
|
1228 |
-
ord($var{$c + 2}));
|
1229 |
-
$c += 2;
|
1230 |
-
$utf16 = $this->json_utf82utf16($char);
|
1231 |
-
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
1232 |
-
break;
|
1233 |
-
|
1234 |
-
case (($ord_var_c & 0xF8) == 0xF0):
|
1235 |
-
// characters U-00010000 - U-001FFFFF, mask 11110XXX
|
1236 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
1237 |
-
$char = pack('C*', $ord_var_c,
|
1238 |
-
ord($var{$c + 1}),
|
1239 |
-
ord($var{$c + 2}),
|
1240 |
-
ord($var{$c + 3}));
|
1241 |
-
$c += 3;
|
1242 |
-
$utf16 = $this->json_utf82utf16($char);
|
1243 |
-
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
1244 |
-
break;
|
1245 |
-
|
1246 |
-
case (($ord_var_c & 0xFC) == 0xF8):
|
1247 |
-
// characters U-00200000 - U-03FFFFFF, mask 111110XX
|
1248 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
1249 |
-
$char = pack('C*', $ord_var_c,
|
1250 |
-
ord($var{$c + 1}),
|
1251 |
-
ord($var{$c + 2}),
|
1252 |
-
ord($var{$c + 3}),
|
1253 |
-
ord($var{$c + 4}));
|
1254 |
-
$c += 4;
|
1255 |
-
$utf16 = $this->json_utf82utf16($char);
|
1256 |
-
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
1257 |
-
break;
|
1258 |
-
|
1259 |
-
case (($ord_var_c & 0xFE) == 0xFC):
|
1260 |
-
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
|
1261 |
-
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
1262 |
-
$char = pack('C*', $ord_var_c,
|
1263 |
-
ord($var{$c + 1}),
|
1264 |
-
ord($var{$c + 2}),
|
1265 |
-
ord($var{$c + 3}),
|
1266 |
-
ord($var{$c + 4}),
|
1267 |
-
ord($var{$c + 5}));
|
1268 |
-
$c += 5;
|
1269 |
-
$utf16 = $this->json_utf82utf16($char);
|
1270 |
-
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
1271 |
-
break;
|
1272 |
-
}
|
1273 |
-
}
|
1274 |
-
|
1275 |
-
return '"' . $ascii . '"';
|
1276 |
-
|
1277 |
-
case 'array':
|
1278 |
-
/*
|
1279 |
-
* As per JSON spec if any array key is not an integer
|
1280 |
-
* we must treat the the whole array as an object. We
|
1281 |
-
* also try to catch a sparsely populated associative
|
1282 |
-
* array with numeric keys here because some JS engines
|
1283 |
-
* will create an array with empty indexes up to
|
1284 |
-
* max_index which can cause memory issues and because
|
1285 |
-
* the keys, which may be relevant, will be remapped
|
1286 |
-
* otherwise.
|
1287 |
-
*
|
1288 |
-
* As per the ECMA and JSON specification an object may
|
1289 |
-
* have any string as a property. Unfortunately due to
|
1290 |
-
* a hole in the ECMA specification if the key is a
|
1291 |
-
* ECMA reserved word or starts with a digit the
|
1292 |
-
* parameter is only accessible using ECMAScript's
|
1293 |
-
* bracket notation.
|
1294 |
-
*/
|
1295 |
-
|
1296 |
-
// treat as a JSON object
|
1297 |
-
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
|
1298 |
-
|
1299 |
-
$this->json_objectStack[] = $var;
|
1300 |
-
|
1301 |
-
$properties = array_map(array($this, 'json_name_value'),
|
1302 |
-
array_keys($var),
|
1303 |
-
array_values($var));
|
1304 |
-
|
1305 |
-
array_pop($this->json_objectStack);
|
1306 |
-
|
1307 |
-
return '{' . join(',', $properties) . '}';
|
1308 |
-
}
|
1309 |
-
|
1310 |
-
$this->json_objectStack[] = $var;
|
1311 |
-
|
1312 |
-
// treat it like a regular array
|
1313 |
-
$elements = array_map(array($this, 'json_encode'), $var);
|
1314 |
-
|
1315 |
-
array_pop($this->json_objectStack);
|
1316 |
-
|
1317 |
-
return '[' . join(',', $elements) . ']';
|
1318 |
-
|
1319 |
-
case 'object':
|
1320 |
-
$vars = FirePHP::encodeObject($var);
|
1321 |
-
|
1322 |
-
$this->json_objectStack[] = $var;
|
1323 |
-
|
1324 |
-
$properties = array_map(array($this, 'json_name_value'),
|
1325 |
-
array_keys($vars),
|
1326 |
-
array_values($vars));
|
1327 |
-
|
1328 |
-
array_pop($this->json_objectStack);
|
1329 |
-
|
1330 |
-
return '{' . join(',', $properties) . '}';
|
1331 |
-
|
1332 |
-
default:
|
1333 |
-
return null;
|
1334 |
-
}
|
1335 |
-
}
|
1336 |
-
|
1337 |
-
/**
|
1338 |
-
* array-walking function for use in generating JSON-formatted name-value pairs
|
1339 |
-
*
|
1340 |
-
* @param string $name name of key to use
|
1341 |
-
* @param mixed $value reference to an array element to be encoded
|
1342 |
-
*
|
1343 |
-
* @return string JSON-formatted name-value pair, like '"name":value'
|
1344 |
-
* @access private
|
1345 |
-
*/
|
1346 |
-
function json_name_value($name, $value) {
|
1347 |
-
// Encoding the $GLOBALS PHP array causes an infinite loop
|
1348 |
-
// if the recursion is not reset here as it contains
|
1349 |
-
// a reference to itself. This is the only way I have come up
|
1350 |
-
// with to stop infinite recursion in this case.
|
1351 |
-
if ($name == 'GLOBALS'
|
1352 |
-
&& is_array($value)
|
1353 |
-
&& array_key_exists('GLOBALS', $value)
|
1354 |
-
) {
|
1355 |
-
$value['GLOBALS'] = '** Recursion **';
|
1356 |
-
}
|
1357 |
-
|
1358 |
-
$encoded_value = $this->json_encode($value);
|
1359 |
-
|
1360 |
-
return $this->json_encode(strval($name)) . ':' . $encoded_value;
|
1361 |
-
}
|
1362 |
-
}
|
1363 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/libs/FirePHPCore/fb.php
DELETED
@@ -1,287 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
namespace mp_timetable\classes\libs\FirePHPCore;
|
3 |
-
|
4 |
-
use mp_timetable\classes\libs\FirePHPCore\FirePHP;
|
5 |
-
|
6 |
-
/* ***** BEGIN LICENSE BLOCK *****
|
7 |
-
*
|
8 |
-
* This file is part of FirePHP (http://www.firephp.org/).
|
9 |
-
*
|
10 |
-
* Software License Agreement (New BSD License)
|
11 |
-
*
|
12 |
-
* Copyright (c) 2006-2010, Christoph Dorn
|
13 |
-
* All rights reserved.
|
14 |
-
*
|
15 |
-
* Redistribution and use in source and binary forms, with or without modification,
|
16 |
-
* are permitted provided that the following conditions are met:
|
17 |
-
*
|
18 |
-
* * Redistributions of source code must retain the above copyright notice,
|
19 |
-
* this list of conditions and the following disclaimer.
|
20 |
-
*
|
21 |
-
* * Redistributions in binary form must reproduce the above copyright notice,
|
22 |
-
* this list of conditions and the following disclaimer in the documentation
|
23 |
-
* and/or other materials provided with the distribution.
|
24 |
-
*
|
25 |
-
* * Neither the name of Christoph Dorn nor the names of its
|
26 |
-
* contributors may be used to endorse or promote products derived from this
|
27 |
-
* software without specific prior written permission.
|
28 |
-
*
|
29 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
30 |
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
31 |
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
32 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
33 |
-
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
34 |
-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
35 |
-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
36 |
-
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
37 |
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
38 |
-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
39 |
-
*
|
40 |
-
* ***** END LICENSE BLOCK *****
|
41 |
-
*
|
42 |
-
* @copyright Copyright (C) 2007-2009 Christoph Dorn
|
43 |
-
* @author Christoph Dorn <christoph@christophdorn.com>
|
44 |
-
* @license http://www.opensource.org/licenses/bsd-license.php
|
45 |
-
* @package FirePHPCore
|
46 |
-
*/
|
47 |
-
|
48 |
-
if (!class_exists('FirePHP')) {
|
49 |
-
require_once dirname(__FILE__) . DIRECTORY_SEPARATOR . 'FirePHP.class.php';
|
50 |
-
}
|
51 |
-
|
52 |
-
/**
|
53 |
-
* Sends the given data to the FirePHP Firefox Extension.
|
54 |
-
* The data can be displayed in the Firebug Console or in the
|
55 |
-
* "Server" request tab.
|
56 |
-
*
|
57 |
-
* @see http://www.firephp.org/Wiki/Reference/Fb
|
58 |
-
*
|
59 |
-
* @param mixed $Object
|
60 |
-
*
|
61 |
-
* @return true
|
62 |
-
* @throws Exception
|
63 |
-
*/
|
64 |
-
function fb() {
|
65 |
-
$instance = FirePHP::getInstance(true);
|
66 |
-
|
67 |
-
$args = func_get_args();
|
68 |
-
return call_user_func_array(array($instance, 'fb'), $args);
|
69 |
-
}
|
70 |
-
|
71 |
-
|
72 |
-
class FB {
|
73 |
-
/**
|
74 |
-
* Enable and disable logging to Firebug
|
75 |
-
*
|
76 |
-
* @see FirePHP->setEnabled()
|
77 |
-
*
|
78 |
-
* @param boolean $Enabled TRUE to enable, FALSE to disable
|
79 |
-
*
|
80 |
-
* @return void
|
81 |
-
*/
|
82 |
-
public static function setEnabled($Enabled) {
|
83 |
-
$instance = FirePHP::getInstance(true);
|
84 |
-
$instance->setEnabled($Enabled);
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Check if logging is enabled
|
89 |
-
*
|
90 |
-
* @see FirePHP->getEnabled()
|
91 |
-
* @return boolean TRUE if enabled
|
92 |
-
*/
|
93 |
-
public static function getEnabled() {
|
94 |
-
$instance = FirePHP::getInstance(true);
|
95 |
-
return $instance->getEnabled();
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* Specify a filter to be used when encoding an object
|
100 |
-
*
|
101 |
-
* Filters are used to exclude object members.
|
102 |
-
*
|
103 |
-
* @see FirePHP->setObjectFilter()
|
104 |
-
*
|
105 |
-
* @param string $Class The class name of the object
|
106 |
-
* @param array $Filter An array or members to exclude
|
107 |
-
*
|
108 |
-
* @return void
|
109 |
-
*/
|
110 |
-
public static function setObjectFilter($Class, $Filter) {
|
111 |
-
$instance = FirePHP::getInstance(true);
|
112 |
-
$instance->setObjectFilter($Class, $Filter);
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* Set some options for the library
|
117 |
-
*
|
118 |
-
* @see FirePHP->setOptions()
|
119 |
-
*
|
120 |
-
* @param array $Options The options to be set
|
121 |
-
*
|
122 |
-
* @return void
|
123 |
-
*/
|
124 |
-
public static function setOptions($Options) {
|
125 |
-
$instance = FirePHP::getInstance(true);
|
126 |
-
$instance->setOptions($Options);
|
127 |
-
}
|
128 |
-
|
129 |
-
/**
|
130 |
-
* Get options for the library
|
131 |
-
*
|
132 |
-
* @see FirePHP->getOptions()
|
133 |
-
* @return array The options
|
134 |
-
*/
|
135 |
-
public static function getOptions() {
|
136 |
-
$instance = FirePHP::getInstance(true);
|
137 |
-
return $instance->getOptions();
|
138 |
-
}
|
139 |
-
|
140 |
-
/**
|
141 |
-
* Log object to firebug
|
142 |
-
*
|
143 |
-
* @see http://www.firephp.org/Wiki/Reference/Fb
|
144 |
-
*
|
145 |
-
* @param mixed $Object
|
146 |
-
*
|
147 |
-
* @return true
|
148 |
-
* @throws Exception
|
149 |
-
*/
|
150 |
-
public static function send() {
|
151 |
-
$instance = FirePHP::getInstance(true);
|
152 |
-
$args = func_get_args();
|
153 |
-
return call_user_func_array(array($instance, 'fb'), $args);
|
154 |
-
}
|
155 |
-
|
156 |
-
/**
|
157 |
-
* Start a group for following messages
|
158 |
-
*
|
159 |
-
* Options:
|
160 |
-
* Collapsed: [true|false]
|
161 |
-
* Color: [#RRGGBB|ColorName]
|
162 |
-
*
|
163 |
-
* @param string $Name
|
164 |
-
* @param array $Options OPTIONAL Instructions on how to log the group
|
165 |
-
*
|
166 |
-
* @return true
|
167 |
-
*/
|
168 |
-
public static function group($Name, $Options = null) {
|
169 |
-
$instance = FirePHP::getInstance(true);
|
170 |
-
return $instance->group($Name, $Options);
|
171 |
-
}
|
172 |
-
|
173 |
-
/**
|
174 |
-
* Ends a group you have started before
|
175 |
-
*
|
176 |
-
* @return true
|
177 |
-
* @throws Exception
|
178 |
-
*/
|
179 |
-
public static function groupEnd() {
|
180 |
-
return self::send(null, null, FirePHP::GROUP_END);
|
181 |
-
}
|
182 |
-
|
183 |
-
/**
|
184 |
-
* Log object with label to firebug console
|
185 |
-
*
|
186 |
-
* @see FirePHP::LOG
|
187 |
-
*
|
188 |
-
* @param mixes $Object
|
189 |
-
* @param string $Label
|
190 |
-
*
|
191 |
-
* @return true
|
192 |
-
* @throws Exception
|
193 |
-
*/
|
194 |
-
public static function log($Object, $Label = null) {
|
195 |
-
return self::send($Object, $Label, FirePHP::LOG);
|
196 |
-
}
|
197 |
-
|
198 |
-
/**
|
199 |
-
* Log object with label to firebug console
|
200 |
-
*
|
201 |
-
* @see FirePHP::INFO
|
202 |
-
*
|
203 |
-
* @param mixes $Object
|
204 |
-
* @param string $Label
|
205 |
-
*
|
206 |
-
* @return true
|
207 |
-
* @throws Exception
|
208 |
-
*/
|
209 |
-
public static function info($Object, $Label = null) {
|
210 |
-
return self::send($Object, $Label, FirePHP::INFO);
|
211 |
-
}
|
212 |
-
|
213 |
-
/**
|
214 |
-
* Log object with label to firebug console
|
215 |
-
*
|
216 |
-
* @see FirePHP::WARN
|
217 |
-
*
|
218 |
-
* @param mixes $Object
|
219 |
-
* @param string $Label
|
220 |
-
*
|
221 |
-
* @return true
|
222 |
-
* @throws Exception
|
223 |
-
*/
|
224 |
-
public static function warn($Object, $Label = null) {
|
225 |
-
return self::send($Object, $Label, FirePHP::WARN);
|
226 |
-
}
|
227 |
-
|
228 |
-
/**
|
229 |
-
* Log object with label to firebug console
|
230 |
-
*
|
231 |
-
* @see FirePHP::ERROR
|
232 |
-
*
|
233 |
-
* @param mixes $Object
|
234 |
-
* @param string $Label
|
235 |
-
*
|
236 |
-
* @return true
|
237 |
-
* @throws Exception
|
238 |
-
*/
|
239 |
-
public static function error($Object, $Label = null) {
|
240 |
-
return self::send($Object, $Label, FirePHP::ERROR);
|
241 |
-
}
|
242 |
-
|
243 |
-
/**
|
244 |
-
* Dumps key and variable to firebug server panel
|
245 |
-
*
|
246 |
-
* @see FirePHP::DUMP
|
247 |
-
*
|
248 |
-
* @param string $Key
|
249 |
-
* @param mixed $Variable
|
250 |
-
*
|
251 |
-
* @return true
|
252 |
-
* @throws Exception
|
253 |
-
*/
|
254 |
-
public static function dump($Key, $Variable) {
|
255 |
-
return self::send($Variable, $Key, FirePHP::DUMP);
|
256 |
-
}
|
257 |
-
|
258 |
-
/**
|
259 |
-
* Log a trace in the firebug console
|
260 |
-
*
|
261 |
-
* @see FirePHP::TRACE
|
262 |
-
*
|
263 |
-
* @param string $Label
|
264 |
-
*
|
265 |
-
* @return true
|
266 |
-
* @throws Exception
|
267 |
-
*/
|
268 |
-
public static function trace($Label) {
|
269 |
-
return self::send($Label, FirePHP::TRACE);
|
270 |
-
}
|
271 |
-
|
272 |
-
/**
|
273 |
-
* Log a table in the firebug console
|
274 |
-
*
|
275 |
-
* @see FirePHP::TABLE
|
276 |
-
*
|
277 |
-
* @param string $Label
|
278 |
-
* @param string $Table
|
279 |
-
*
|
280 |
-
* @return true
|
281 |
-
* @throws Exception
|
282 |
-
*/
|
283 |
-
public static function table($Label, $Table) {
|
284 |
-
return self::send($Table, $Label, FirePHP::TABLE);
|
285 |
-
}
|
286 |
-
|
287 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/libs/FirePHPCore/fb.php4
DELETED
@@ -1,251 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
namespace mp_timetable\classes\libs\FirePHPCore;
|
3 |
-
/* ***** BEGIN LICENSE BLOCK *****
|
4 |
-
*
|
5 |
-
* This file is part of FirePHP (http://www.firephp.org/).
|
6 |
-
*
|
7 |
-
* Software License Agreement (New BSD License)
|
8 |
-
*
|
9 |
-
* Copyright (c) 2006-2010, Christoph Dorn
|
10 |
-
* All rights reserved.
|
11 |
-
*
|
12 |
-
* Redistribution and use in source and binary forms, with or without modification,
|
13 |
-
* are permitted provided that the following conditions are met:
|
14 |
-
*
|
15 |
-
* * Redistributions of source code must retain the above copyright notice,
|
16 |
-
* this list of conditions and the following disclaimer.
|
17 |
-
*
|
18 |
-
* * Redistributions in binary form must reproduce the above copyright notice,
|
19 |
-
* this list of conditions and the following disclaimer in the documentation
|
20 |
-
* and/or other materials provided with the distribution.
|
21 |
-
*
|
22 |
-
* * Neither the name of Christoph Dorn nor the names of its
|
23 |
-
* contributors may be used to endorse or promote products derived from this
|
24 |
-
* software without specific prior written permission.
|
25 |
-
*
|
26 |
-
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
27 |
-
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
28 |
-
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
29 |
-
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
30 |
-
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
31 |
-
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
32 |
-
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
33 |
-
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
34 |
-
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
35 |
-
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
36 |
-
*
|
37 |
-
* ***** END LICENSE BLOCK *****
|
38 |
-
*
|
39 |
-
* @copyright Copyright (C) 2007-2009 Christoph Dorn
|
40 |
-
* @author Christoph Dorn <christoph@christophdorn.com>
|
41 |
-
* @author Michael Day <manveru.alma@gmail.com>
|
42 |
-
* @license http://www.opensource.org/licenses/bsd-license.php
|
43 |
-
* @package FirePHPCore
|
44 |
-
*/
|
45 |
-
|
46 |
-
require_once dirname(__FILE__).'/FirePHP.class.php4';
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Sends the given data to the FirePHP Firefox Extension.
|
50 |
-
* The data can be displayed in the Firebug Console or in the
|
51 |
-
* "Server" request tab.
|
52 |
-
*
|
53 |
-
* @see http://www.firephp.org/Wiki/Reference/Fb
|
54 |
-
* @param mixed $Object
|
55 |
-
* @return true
|
56 |
-
* @throws Exception
|
57 |
-
*/
|
58 |
-
function fb()
|
59 |
-
{
|
60 |
-
$instance =& FirePHP::getInstance(true);
|
61 |
-
|
62 |
-
$args = func_get_args();
|
63 |
-
return call_user_func_array(array(&$instance,'fb'),$args);
|
64 |
-
}
|
65 |
-
|
66 |
-
|
67 |
-
class FB
|
68 |
-
{
|
69 |
-
/**
|
70 |
-
* Enable and disable logging to Firebug
|
71 |
-
*
|
72 |
-
* @see FirePHP->setEnabled()
|
73 |
-
* @param boolean $Enabled TRUE to enable, FALSE to disable
|
74 |
-
* @return void
|
75 |
-
*/
|
76 |
-
function setEnabled($Enabled) {
|
77 |
-
$instance =& FirePHP::getInstance(true);
|
78 |
-
$instance->setEnabled($Enabled);
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* Check if logging is enabled
|
83 |
-
*
|
84 |
-
* @see FirePHP->getEnabled()
|
85 |
-
* @return boolean TRUE if enabled
|
86 |
-
*/
|
87 |
-
function getEnabled() {
|
88 |
-
$instance =& FirePHP::getInstance(true);
|
89 |
-
return $instance->getEnabled();
|
90 |
-
}
|
91 |
-
|
92 |
-
/**
|
93 |
-
* Specify a filter to be used when encoding an object
|
94 |
-
*
|
95 |
-
* Filters are used to exclude object members.
|
96 |
-
*
|
97 |
-
* @see FirePHP->setObjectFilter()
|
98 |
-
* @param string $Class The class name of the object
|
99 |
-
* @param array $Filter An array or members to exclude
|
100 |
-
* @return void
|
101 |
-
*/
|
102 |
-
function setObjectFilter($Class, $Filter) {
|
103 |
-
$instance =& FirePHP::getInstance(true);
|
104 |
-
$instance->setObjectFilter($Class, $Filter);
|
105 |
-
}
|
106 |
-
|
107 |
-
/**
|
108 |
-
* Set some options for the library
|
109 |
-
*
|
110 |
-
* @see FirePHP->setOptions()
|
111 |
-
* @param array $Options The options to be set
|
112 |
-
* @return void
|
113 |
-
*/
|
114 |
-
function setOptions($Options) {
|
115 |
-
$instance =& FirePHP::getInstance(true);
|
116 |
-
$instance->setOptions($Options);
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* Get options for the library
|
121 |
-
*
|
122 |
-
* @see FirePHP->getOptions()
|
123 |
-
* @return array The options
|
124 |
-
*/
|
125 |
-
function getOptions() {
|
126 |
-
$instance =& FirePHP::getInstance(true);
|
127 |
-
return $instance->getOptions();
|
128 |
-
}
|
129 |
-
|
130 |
-
/**
|
131 |
-
* Log object to firebug
|
132 |
-
*
|
133 |
-
* @see http://www.firephp.org/Wiki/Reference/Fb
|
134 |
-
* @param mixed $Object
|
135 |
-
* @return true
|
136 |
-
*/
|
137 |
-
function send()
|
138 |
-
{
|
139 |
-
$instance =& FirePHP::getInstance(true);
|
140 |
-
$args = func_get_args();
|
141 |
-
return call_user_func_array(array(&$instance,'fb'),$args);
|
142 |
-
}
|
143 |
-
|
144 |
-
/**
|
145 |
-
* Start a group for following messages
|
146 |
-
*
|
147 |
-
* Options:
|
148 |
-
* Collapsed: [true|false]
|
149 |
-
* Color: [#RRGGBB|ColorName]
|
150 |
-
*
|
151 |
-
* @param string $Name
|
152 |
-
* @param array $Options OPTIONAL Instructions on how to log the group
|
153 |
-
* @return true
|
154 |
-
*/
|
155 |
-
function group($Name, $Options=null) {
|
156 |
-
$instance =& FirePHP::getInstance(true);
|
157 |
-
return $instance->group($Name, $Options);
|
158 |
-
}
|
159 |
-
|
160 |
-
/**
|
161 |
-
* Ends a group you have started before
|
162 |
-
*
|
163 |
-
* @return true
|
164 |
-
*/
|
165 |
-
function groupEnd() {
|
166 |
-
return FB::send(null, null, FirePHP_GROUP_END);
|
167 |
-
}
|
168 |
-
|
169 |
-
/**
|
170 |
-
* Log object with label to firebug console
|
171 |
-
*
|
172 |
-
* @see FirePHP::LOG
|
173 |
-
* @param mixes $Object
|
174 |
-
* @param string $Label
|
175 |
-
* @return true
|
176 |
-
*/
|
177 |
-
function log($Object, $Label=null) {
|
178 |
-
return FB::send($Object, $Label, FirePHP_LOG);
|
179 |
-
}
|
180 |
-
|
181 |
-
/**
|
182 |
-
* Log object with label to firebug console
|
183 |
-
*
|
184 |
-
* @see FirePHP::INFO
|
185 |
-
* @param mixes $Object
|
186 |
-
* @param string $Label
|
187 |
-
* @return true
|
188 |
-
*/
|
189 |
-
function info($Object, $Label=null) {
|
190 |
-
return FB::send($Object, $Label, FirePHP_INFO);
|
191 |
-
}
|
192 |
-
|
193 |
-
/**
|
194 |
-
* Log object with label to firebug console
|
195 |
-
*
|
196 |
-
* @see FirePHP::WARN
|
197 |
-
* @param mixes $Object
|
198 |
-
* @param string $Label
|
199 |
-
* @return true
|
200 |
-
*/
|
201 |
-
function warn($Object, $Label=null) {
|
202 |
-
return FB::send($Object, $Label, FirePHP_WARN);
|
203 |
-
}
|
204 |
-
|
205 |
-
/**
|
206 |
-
* Log object with label to firebug console
|
207 |
-
*
|
208 |
-
* @see FirePHP::ERROR
|
209 |
-
* @param mixes $Object
|
210 |
-
* @param string $Label
|
211 |
-
* @return true
|
212 |
-
*/
|
213 |
-
function error($Object, $Label=null) {
|
214 |
-
return FB::send($Object, $Label, FirePHP_ERROR);
|
215 |
-
}
|
216 |
-
|
217 |
-
/**
|
218 |
-
* Dumps key and variable to firebug server panel
|
219 |
-
*
|
220 |
-
* @see FirePHP::DUMP
|
221 |
-
* @param string $Key
|
222 |
-
* @param mixed $Variable
|
223 |
-
* @return true
|
224 |
-
*/
|
225 |
-
function dump($Key, $Variable) {
|
226 |
-
return FB::send($Variable, $Key, FirePHP_DUMP);
|
227 |
-
}
|
228 |
-
|
229 |
-
/**
|
230 |
-
* Log a trace in the firebug console
|
231 |
-
*
|
232 |
-
* @see FirePHP::TRACE
|
233 |
-
* @param string $Label
|
234 |
-
* @return true
|
235 |
-
*/
|
236 |
-
function trace($Label) {
|
237 |
-
return FB::send($Label, FirePHP_TRACE);
|
238 |
-
}
|
239 |
-
|
240 |
-
/**
|
241 |
-
* Log a table in the firebug console
|
242 |
-
*
|
243 |
-
* @see FirePHP::TABLE
|
244 |
-
* @param string $Label
|
245 |
-
* @param string $Table
|
246 |
-
* @return true
|
247 |
-
*/
|
248 |
-
function table($Label, $Table) {
|
249 |
-
return FB::send($Table, $Label, FirePHP_TABLE);
|
250 |
-
}
|
251 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
classes/models/class-events.php
CHANGED
@@ -72,8 +72,8 @@ class Events extends Model {
|
|
72 |
* @param $metabox
|
73 |
*/
|
74 |
public function render_event_data( $post, $metabox ) {
|
|
|
75 |
$time_format = get_option( 'time_format' );
|
76 |
-
$data[ 'columns' ] = $this->get( 'column' )->get_all_column();
|
77 |
if ( $time_format === 'H:i' ) {
|
78 |
$time_format_array = array( 'hours' => '0,23', 'am_pm' => false );
|
79 |
} elseif ( $time_format === 'g:i A' ) {
|
@@ -81,9 +81,12 @@ class Events extends Model {
|
|
81 |
} else {
|
82 |
$time_format_array = array( 'hours' => '0,23', 'am_pm' => false );
|
83 |
}
|
|
|
|
|
84 |
$event_data = $this->get_event_data( array( 'field' => 'event_id', 'id' => $post->ID ), 'event_start', false );
|
85 |
|
86 |
-
$this->get_view()->render_html( "events/metabox-event-data", array( 'event_data' => $event_data, 'args' => $metabox[ 'args' ],
|
|
|
87 |
}
|
88 |
|
89 |
/**
|
72 |
* @param $metabox
|
73 |
*/
|
74 |
public function render_event_data( $post, $metabox ) {
|
75 |
+
|
76 |
$time_format = get_option( 'time_format' );
|
|
|
77 |
if ( $time_format === 'H:i' ) {
|
78 |
$time_format_array = array( 'hours' => '0,23', 'am_pm' => false );
|
79 |
} elseif ( $time_format === 'g:i A' ) {
|
81 |
} else {
|
82 |
$time_format_array = array( 'hours' => '0,23', 'am_pm' => false );
|
83 |
}
|
84 |
+
|
85 |
+
$data[ 'columns' ] = $this->get( 'column' )->get_all_column();
|
86 |
$event_data = $this->get_event_data( array( 'field' => 'event_id', 'id' => $post->ID ), 'event_start', false );
|
87 |
|
88 |
+
$this->get_view()->render_html( "events/metabox-event-data", array( 'event_data' => $event_data, 'args' => $metabox[ 'args' ],
|
89 |
+
'columns' => $data[ 'columns' ], 'date' => array( 'time_format' => $time_format_array ) ), true );
|
90 |
}
|
91 |
|
92 |
/**
|
classes/models/class-settings.php
CHANGED
@@ -74,17 +74,14 @@ class Settings extends Model {
|
|
74 |
*
|
75 |
*/
|
76 |
public function save_settings() {
|
77 |
-
$saved = false;
|
78 |
-
$options = array();
|
79 |
-
|
80 |
-
if (isset($_POST['mp-timetable-save-settings']) && wp_verify_nonce($_POST['mp-timetable-save-settings'], 'mp_timetable_nonce_settings')) {
|
81 |
-
if (!empty($_POST['theme_mode'])) {
|
82 |
-
$options['theme_mode'] = $_POST['theme_mode'];
|
83 |
-
$saved = update_option('mp_timetable_general', $options);
|
84 |
-
}
|
85 |
-
}
|
86 |
|
87 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
88 |
}
|
89 |
|
90 |
/**
|
74 |
*
|
75 |
*/
|
76 |
public function save_settings() {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
77 |
|
78 |
+
if ( current_user_can('manage_options') && !empty( $_POST['theme_mode'] ) ) {
|
79 |
+
|
80 |
+
$options = array();
|
81 |
+
$options['theme_mode'] = $_POST['theme_mode'];
|
82 |
+
|
83 |
+
update_option('mp_timetable_general', $options);
|
84 |
+
}
|
85 |
}
|
86 |
|
87 |
/**
|
classes/modules/class-post.php
CHANGED
@@ -49,10 +49,14 @@ class Post extends Module {
|
|
49 |
* @param $post
|
50 |
*/
|
51 |
public function save_custom_post($post_id, $post) {
|
|
|
52 |
$request = $_REQUEST;
|
53 |
-
|
|
|
|
|
54 |
$post_type = $request['post_type'];
|
55 |
-
|
|
|
56 |
return $post->ID;
|
57 |
}
|
58 |
|
49 |
* @param $post
|
50 |
*/
|
51 |
public function save_custom_post($post_id, $post) {
|
52 |
+
|
53 |
$request = $_REQUEST;
|
54 |
+
|
55 |
+
if ( !empty( $request[Mp_Time_Table::get_plugin_name() . '_noncename'] ) ) {
|
56 |
+
|
57 |
$post_type = $request['post_type'];
|
58 |
+
|
59 |
+
if ( !wp_verify_nonce($request[Mp_Time_Table::get_plugin_name() . '_noncename'], Mp_Time_Table::get_plugin_path())) {
|
60 |
return $post->ID;
|
61 |
}
|
62 |
|
mp-timetable.php
CHANGED
@@ -4,7 +4,7 @@
|
|
4 |
* Plugin Name: Timetable and Event Schedule
|
5 |
* Plugin URI: https://motopress.com/products/timetable-event-schedule/
|
6 |
* Description: Smart time-management tool with a clean minimalist design for featuring your timetables and upcoming events.
|
7 |
-
* Version: 2.3.
|
8 |
* Author: MotoPress
|
9 |
* Author URI: https://motopress.com
|
10 |
* License: GPLv2 or later
|
@@ -74,10 +74,6 @@ class Mp_Time_Table {
|
|
74 |
* Include Gump
|
75 |
*/
|
76 |
require_once self::get_plugin_path() . 'classes/libs/class-gump.php';
|
77 |
-
/**
|
78 |
-
* Install Fire bug
|
79 |
-
*/
|
80 |
-
require_once self::get_plugin_path() . 'classes/libs/FirePHPCore/fb.php';
|
81 |
/**
|
82 |
* Install Parsers
|
83 |
*/
|
4 |
* Plugin Name: Timetable and Event Schedule
|
5 |
* Plugin URI: https://motopress.com/products/timetable-event-schedule/
|
6 |
* Description: Smart time-management tool with a clean minimalist design for featuring your timetables and upcoming events.
|
7 |
+
* Version: 2.3.10
|
8 |
* Author: MotoPress
|
9 |
* Author URI: https://motopress.com
|
10 |
* License: GPLv2 or later
|
74 |
* Include Gump
|
75 |
*/
|
76 |
require_once self::get_plugin_path() . 'classes/libs/class-gump.php';
|
|
|
|
|
|
|
|
|
77 |
/**
|
78 |
* Install Parsers
|
79 |
*/
|
readme.txt
CHANGED
@@ -79,6 +79,10 @@ Plugin bundles the following third-party resources:
|
|
79 |
|
80 |
== Changelog ==
|
81 |
|
|
|
|
|
|
|
|
|
82 |
= 2.3.9, Apr 21 2020 =
|
83 |
* Added the ability to sort events in the dropdown list or tabs.
|
84 |
* Improved user capability check.
|
79 |
|
80 |
== Changelog ==
|
81 |
|
82 |
+
= 2.3.10, Apr 24 2020 =
|
83 |
+
* Bug fix: fixed an issue when a user with the Editor role could not access the administration area.
|
84 |
+
* Improved compatibility with PHP 7.4.
|
85 |
+
|
86 |
= 2.3.9, Apr 21 2020 =
|
87 |
* Added the ability to sort events in the dropdown list or tabs.
|
88 |
* Improved user capability check.
|