Changeset 3371018
- Timestamp:
- 10/01/2025 09:50:41 AM (2 months ago)
- Location:
- code-profiler/trunk
- Files:
-
- 1 added
- 11 edited
-
index.php (modified) (6 diffs)
-
lib/ajax.php (modified) (21 diffs)
-
lib/class-cli.php (modified) (2 diffs)
-
lib/class-profiler.php (modified) (3 diffs)
-
lib/class-report.php (modified) (2 diffs)
-
lib/class-table-profiles.php (modified) (6 diffs)
-
lib/class-wp-cron.php (added)
-
lib/helper.php (modified) (3 diffs)
-
lib/i18n-extra.php (modified) (1 diff)
-
lib/menu_profiler.php (modified) (7 diffs)
-
readme.txt (modified) (2 diffs)
-
static/code-profiler.js (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
code-profiler/trunk/index.php
r3316061 r3371018 6 6 Author: Jerome Bruandet ~ NinTechNet Ltd. 7 7 Author URI: https://nintechnet.com/ 8 Version: 1. 7.78 Version: 1.8 9 9 Network: true 10 10 License: GPLv3 or later … … 13 13 */ 14 14 15 define('CODE_PROFILER_VERSION', '1. 7.7');15 define('CODE_PROFILER_VERSION', '1.8'); 16 16 /** 17 17 +=====================================================================+ … … 30 30 } 31 31 32 // ===================================================================== 2023-08-2032 // ===================================================================== 33 33 // Menu functions 34 34 require __DIR__ .'/lib/menu.php'; … … 37 37 // AJAX calls 38 38 require __DIR__ .'/lib/ajax.php'; 39 // ===================================================================== 2023-06-17 39 // Scheduled tasks 40 require_once __DIR__ .'/lib/class-wp-cron.php'; 41 // ===================================================================== 40 42 // Activation: make sure the blog meets the requirements. 41 43 … … 79 81 code_profiler_default_options(); 80 82 } 83 84 /** 85 * Install scheduled tasks on the main site only. 86 */ 87 if ( is_main_site() ) { 88 CodeProfiler_WPCron::install(); 89 } 81 90 } 82 91 … … 96 105 unlink( WPMU_PLUGIN_DIR .'/'. CODE_PROFILER_MUPLUGIN ); 97 106 } 107 108 /** 109 * Uninstall scheduled tasks. 110 */ 111 CodeProfiler_WPCron::uninstall(); 98 112 } 99 113 -
code-profiler/trunk/lib/ajax.php
r3314519 r3371018 28 28 29 29 $cp_options = get_option('code-profiler'); 30 if (! empty( $cp_options['mem'] ) ) { 31 $mem = $cp_options['mem']; 32 } else { 33 $mem = []; 34 } 30 35 31 36 code_profiler_log_debug( … … 78 83 79 84 // Frontend or backend 80 if ( empty( $_POST[' where'] ) ||81 ! in_array( $_POST[' where'], ['frontend', 'backend', 'custom'] ) ) {85 if ( empty( $_POST['x_end'] ) || 86 ! in_array( $_POST['x_end'], ['frontend', 'backend', 'custom'] ) ) { 82 87 83 88 $msg = sprintf( 84 esc_html__('Missing or incorrect parameter (%s)', 'code-profiler'), ' where'89 esc_html__('Missing or incorrect parameter (%s)', 'code-profiler'), 'x_end' 85 90 ); 86 91 $response['message'] = $msg; … … 88 93 code_profiler_wp_send_json( $response ); 89 94 } 90 $ cp_options['mem_where'] = $_POST['where'];95 $mem['x_end'] = $_POST['x_end']; 91 96 92 97 code_profiler_log_debug( … … 100 105 code_profiler_wp_send_json( $response ); 101 106 } 102 $ cp_options['mem_post'] = $_POST['post'];107 $mem['post'] = $_POST['post']; 103 108 104 109 // Make sure we have no more that 4 decimals, because when returning … … 111 116 112 117 // Authentication 113 if ( empty( $_POST[' user'] ) || $_POST['user'] != 'authenticated' ) {114 $_POST[' user'] = 'unauthenticated';115 } 116 $ cp_options['mem_user'] = $_POST['user'];118 if ( empty( $_POST['x_auth'] ) || $_POST['x_auth'] != 'authenticated' ) { 119 $_POST['x_auth'] = 'unauthenticated'; 120 } 121 $mem['x_auth'] = $_POST['x_auth']; 117 122 118 123 code_profiler_log_debug( … … 143 148 144 149 // User-agent 145 if ( empty( $_POST['u a'] ) ) {146 $u a= 'Firefox';150 if ( empty( $_POST['user_agent'] ) ) { 151 $user_agent = 'Firefox'; 147 152 } else { 148 $u a = sanitize_text_field( $_POST['ua'] );153 $user_agent = sanitize_text_field( $_POST['user_agent'] ); 149 154 } 150 155 foreach( CODE_PROFILER_UA as $types => $types_array ) { 151 156 foreach( $types_array as $name => $value ) { 152 if ( $u a== $name ) {157 if ( $user_agent == $name ) { 153 158 $ua_signature = $value; 154 159 break; … … 159 164 $ua_signature = CODE_PROFILER_UA['Desktop']['Firefox']; 160 165 } 161 $ cp_options['ua'] = $ua;166 $mem['user_agent'] = $user_agent; 162 167 163 168 // Theme … … 165 170 if ( empty( $_POST['theme'] ) || empty( $themes[ $_POST['theme'] ] ) ) { 166 171 $theme = ''; 167 unset( $ cp_options['mem_theme'] );172 unset( $mem['theme'] ); 168 173 } else { 169 174 code_profiler_log_debug( … … 171 176 ); 172 177 $theme = $_POST['theme']; 173 $ cp_options['mem_theme'] = $theme;178 $mem['theme'] = $theme; 174 179 // Append the template to the stylesheet 175 180 if (! empty( $themes[ $theme ]['t'] ) ) { … … 246 251 } 247 252 if (! empty( $is_custom_headers ) ) { 248 $ cp_options['custom_headers'] = json_encode( $is_custom_headers );253 $mem['custom_headers'] = json_encode( $is_custom_headers ); 249 254 } else { 250 unset( $ cp_options['custom_headers'] );255 unset( $mem['custom_headers'] ); 251 256 } 252 257 … … 266 271 } 267 272 268 if ( $_POST[' user'] == 'authenticated') {273 if ( $_POST['x_auth'] == 'authenticated') { 269 274 270 275 code_profiler_log_debug( … … 297 302 code_profiler_wp_send_json( $response ); 298 303 } 299 $ cp_options['mem_username'] = strtolower( $username );304 $mem['username'] = strtolower( $username ); 300 305 $headers['cookies'][ $cookie_auth ] = wp_generate_auth_cookie( 301 306 $user_object->ID, … … 363 368 if (! empty( $_POST['method'] ) && $_POST['method'] == 'post') { 364 369 $safe_method = 'wp_safe_remote_post'; 365 $ cp_options['mem_method'] = 'post';370 $mem['method'] = 'post'; 366 371 367 372 // Content-type … … 374 379 ! in_array( $_POST['content_type'], [ 1, 2, 3 ] ) ) { 375 380 376 $ cp_options['mem_content_type'] = 1;381 $mem['content_type'] = 1; 377 382 } else { 378 $ cp_options['mem_content_type'] = (int) $_POST['content_type'];379 } 380 $headers['headers']['content-type'] = $content_type[ $ cp_options['mem_content_type'] ];383 $mem['content_type'] = (int) $_POST['content_type']; 384 } 385 $headers['headers']['content-type'] = $content_type[ $mem['content_type'] ]; 381 386 382 387 // Optional POST payload … … 390 395 * application/x-www-form-urlencoded (formatted) 391 396 */ 392 if ( $ cp_options['mem_content_type'] == 1 ) {397 if ( $mem['content_type'] == 1 ) { 393 398 $payload_array = explode( PHP_EOL, $_payload ); 394 399 foreach( $payload_array as $item ) { … … 403 408 * application/x-www-form-urlencoded (raw) 404 409 */ 405 } elseif ( $ cp_options['mem_content_type'] == 3 ) {410 } elseif ( $mem['content_type'] == 3 ) { 406 411 parse_str( $_payload , $payload_array ); 407 412 foreach( $payload_array as $key => $item ) { … … 414 419 $headers['body'] = $_payload; 415 420 } 416 $ cp_options['payload'] = json_encode( $_payload );421 $mem['payload'] = json_encode( $_payload ); 417 422 418 423 } else { 419 424 // POST request without a payload 420 unset( $ cp_options['payload'] );425 unset( $mem['payload'] ); 421 426 } 422 427 423 428 } else { 424 429 $safe_method = 'wp_safe_remote_get'; 425 $ cp_options['mem_method'] = 'get';430 $mem['method'] = 'get'; 426 431 } 427 432 … … 442 447 } 443 448 } 444 $ cp_options['cookies'] = json_encode( $_POST['cookies'] );449 $mem['cookies'] = json_encode( $_POST['cookies'] ); 445 450 } else { 446 unset( $ cp_options['cookies'] );451 unset( $mem['cookies'] ); 447 452 } 448 453 … … 466 471 467 472 if ( $exclusions) { 468 $ cp_options['exclusions'] = json_encode( $exclusions );473 $mem['exclusions'] = json_encode( $exclusions ); 469 474 } else { 470 unset( $cp_options['exclusions'] ); 471 } 472 475 unset( $mem['exclusions'] ); 476 } 477 478 $cp_options['mem'] = $mem; 473 479 update_option('code-profiler', $cp_options ); 480 481 /** 482 * Save the profile configuration into a temporary file (used by the re-run feature). 483 */ 484 file_put_contents( 485 CODE_PROFILER_UPLOAD_DIR ."/$microtime.". CODE_PROFILER_TMP_RERUN_LOG, 486 json_encode( $mem ) 487 ); 474 488 475 489 code_profiler_log_debug( … … 548 562 549 563 $contents .= __('Post payload:', 'code-profiler') ."\n\n"; 550 if ( $ cp_options['mem_content_type'] == 2 ) {564 if ( $mem['content_type'] == 2 ) { 551 565 /** 552 566 * application/json: must be decoded. … … 812 826 } 813 827 828 /** 829 * Rename the profile in the summary file, 830 * so that it can be used by the re-run feature. 831 */ 832 if (! empty( $match[1] ) && 833 is_file( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.$new_name.summary.profile" ) ) { 834 835 $data = json_decode( 836 file_get_contents( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.$new_name.summary.profile" ), 837 true 838 ); 839 if (! empty( $data['rerun']['profile'] ) ) { 840 $data['rerun']['profile'] = $new_name; 841 file_put_contents( 842 CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.$new_name.summary.profile", json_encode( $data ) 843 ); 844 } 845 } 846 814 847 $response['status'] = 'success'; 815 848 $response['newname'] = $new_name; -
code-profiler/trunk/lib/class-cli.php
r3316061 r3371018 38 38 } 39 39 40 $_POST[' where'] = 'frontend';40 $_POST['x_end'] = 'frontend'; 41 41 // Detect if we're authenticated or not 42 42 if ( is_user_logged_in() === true ) { 43 $_POST[' user'] = 'authenticated';43 $_POST['x_auth'] = 'authenticated'; 44 44 } else { 45 $_POST[' user'] = 'unauthenticated';46 } 47 $_POST['profile'] = 'WP-CLI_' . time();48 $_POST['u a']= 'Firefox';45 $_POST['x_auth'] = 'unauthenticated'; 46 } 47 $_POST['profile'] = 'WP-CLI_' . time(); 48 $_POST['user_agent'] = 'Firefox'; 49 49 50 50 if (! empty( $assoc_args['dest'] ) ) { … … 172 172 173 173 // Display name, time and % 174 if ( $cp_options['display_name'] == 'slug' ) {174 if ( isset( $cp_options['display_name'] ) && $cp_options['display_name'] == 'slug' ) { 175 175 $name = $v[0]; 176 176 } else { -
code-profiler/trunk/lib/class-profiler.php
r3288391 r3371018 30 30 private $tmp_calls; 31 31 private $tmp_connections; 32 private $tmp_rerun; 32 33 33 34 /** … … 48 49 $this->tmp_connections = CODE_PROFILER_UPLOAD_DIR ."/$microtime." . 49 50 CODE_PROFILER_TMP_CONNECTIONS_LOG; 51 $this->tmp_rerun = CODE_PROFILER_UPLOAD_DIR ."/$microtime." . 52 CODE_PROFILER_TMP_RERUN_LOG; 50 53 51 54 if ( function_exists('hrtime') ) { … … 150 153 fclose( self::$fh ); 151 154 155 // Summary file (metadata) 156 $summary = []; 157 if ( is_file( $this->tmp_rerun ) ) { 158 $summary['rerun'] = json_decode( file_get_contents( $this->tmp_rerun ), true ); 159 unlink( $this->tmp_rerun ); 160 } 152 161 $summary['memory'] = memory_get_peak_usage(); 153 162 $summary['queries'] = get_num_queries() - 2; -
code-profiler/trunk/lib/class-report.php
r3158496 r3371018 212 212 $this->summary_list['time'] = number_format( $this->summary_list['time'], 4 ); 213 213 214 // Re-run options 215 if (! empty( $s['rerun'] ) ) { 216 $this->summary_list['rerun'] = $s['rerun']; 217 $this->summary_list['rerun']['profile'] = $this->profile_name; 218 } 219 214 220 // Save Code Profiler, PHP and WordPress' versions 215 221 global $wp_version; … … 221 227 222 228 file_put_contents( $summary_json, json_encode( $this->summary_list ) ); 223 224 229 } 225 230 -
code-profiler/trunk/lib/class-table-profiles.php
r3314519 r3371018 158 158 $order = (! empty( $_GET['order'] ) ) ? sanitize_key( $_GET['order'] ) : 'asc'; 159 159 160 /** 161 * The option to re-run a profile is only available with profiles created with v1.8. 162 */ 163 if (! empty( $item['rerun'] ) ) { 164 $rerun = sprintf( 165 '<a href="?page=code-profiler&cptab=profiler&action=rerun&profiles[]=%1$s" title="'. 166 esc_attr__('Re-run the profile with the same options and parameters.', 'code-profiler') . 167 '">%2$s</a>', 168 esc_attr( $item['ID'] ), 169 esc_html__('Re-run', 'code-profiler') 170 ); 171 } else { 172 $rerun = '<font style="cursor:not-allowed" title="'. 173 esc_attr__('This feature is only available with profiles created with Code Profiler v1.8+', 174 'code-profiler') .'">'. esc_html__('Re-run', 'code-profiler') .'</font>'; 175 } 176 160 177 $actions = array( 161 178 'view' => sprintf( … … 170 187 esc_html__('Quick Edit') 171 188 ), 189 'rerun' => $rerun, 172 190 'delete' => sprintf( 173 191 '<a href="?page=code-profiler&cptab=profiles_list&action=%s&profiles[]=%s'. … … 278 296 // Ignore these ones, there aren't mandatory 279 297 if ( in_array( $pname, [ 'composer', 'summary' ] ) ) { continue; } 280 if ( file_exists( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" ) ) {298 if ( is_file( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" ) ) { 281 299 $fsize += filesize( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" ); 282 300 } else { … … 288 306 if ( $error ) { 289 307 foreach( $this->default_files as $pname ) { 290 if ( file_exists( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" ) ) {308 if ( is_file( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" ) ) { 291 309 unlink( CODE_PROFILER_UPLOAD_DIR ."/{$match[1]}.{$match[2]}.$pname.profile" ); 292 310 } … … 326 344 if ( empty( $summary['io'] ) ) { $summary['io'] = '-'; } 327 345 346 /** 347 * Check if we can re-run the profile (v1.8+). 348 */ 349 if (! empty( $summary['rerun'] ) ) { 350 $profiles[$count]['rerun'] = true; 351 } 328 352 $fsize += filesize( $path ); 329 353 $profiles[$count]['ID'] = $match[1]; … … 385 409 } 386 410 foreach( $this->default_files as $pname ) { 387 if ( file_exists( "$profile_name.$pname.profile") ) {388 unlink( "$profile_name.$pname.profile" );411 if ( is_file( "$profile_name.$pname.profile") ) { 412 unlink( "$profile_name.$pname.profile"); 389 413 } 390 414 } -
code-profiler/trunk/lib/helper.php
r3314519 r3371018 34 34 define('CODE_PROFILER_TMP_IOSTATS_LOG', 'iostats.tmp'); 35 35 define('CODE_PROFILER_TMP_SUMMARY_LOG', 'summary.tmp'); 36 define('CODE_PROFILER_TMP_RERUN_LOG', 'rerun.tmp'); 36 37 define('CODE_PROFILER_TMP_CALLS_LOG', 'calls.tmp'); 37 38 define('CODE_PROFILER_TMP_DISKIO_LOG', 'diskio.tmp'); … … 129 130 function code_profiler_init_update() { 130 131 131 $cp_options = get_option('code-profiler'); 132 if ( ( $cp_options = get_option('code-profiler') ) == false ) { 133 /** 134 * "Automatic conversion of false to array is deprecated" since PHP 8.1 135 */ 136 $cp_options = []; 137 } 138 132 139 if ( empty( $cp_options['version'] ) || 133 140 version_compare( $cp_options['version'], CODE_PROFILER_VERSION, '<') ) { … … 158 165 if (! isset( $cp_options['php_error'] ) ) { 159 166 $cp_options['php_error'] = 1; 167 } 168 169 // Version 1.8 170 if ( isset( $cp_options['mem_where'] ) ) { 171 $cp_options['mem']['x_end'] = $cp_options['mem_where']; 172 unset( $cp_options['mem_where'] ); 173 } 174 if ( isset( $cp_options['mem_post'] ) ) { 175 $cp_options['mem']['post'] = $cp_options['mem_post']; 176 unset( $cp_options['mem_post'] ); 177 } 178 if ( isset( $cp_options['mem_user'] ) ) { 179 $cp_options['mem']['x_auth'] = $cp_options['mem_user']; 180 unset( $cp_options['mem_user'] ); 181 } 182 if ( isset( $cp_options['mem_username'] ) ) { 183 $cp_options['mem']['username'] = $cp_options['mem_username']; 184 unset( $cp_options['mem_username'] ); 185 } 186 if ( isset( $cp_options['mem_method'] ) ) { 187 $cp_options['mem']['method'] = $cp_options['mem_method']; 188 unset( $cp_options['mem_method'] ); 189 } 190 if ( isset( $cp_options['mem_theme'] ) ) { 191 $cp_options['mem']['theme'] = $cp_options['mem_theme']; 192 unset( $cp_options['mem_theme'] ); 193 } 194 if ( isset( $cp_options['ua'] ) ) { 195 $cp_options['mem']['user_agent'] = $cp_options['ua']; 196 unset( $cp_options['ua'] ); 197 } 198 if ( isset( $cp_options['cookies'] ) ) { 199 $cp_options['mem']['cookies'] = $cp_options['cookies']; 200 unset( $cp_options['cookies'] ); 201 } 202 if ( isset( $cp_options['mem_content_type'] ) ) { 203 $cp_options['mem']['content_type'] = $cp_options['mem_content_type']; 204 unset( $cp_options['mem_content_type'] ); 205 } 206 if ( isset( $cp_options['payload'] ) ) { 207 $cp_options['mem']['payload'] = $cp_options['payload']; 208 unset( $cp_options['payload'] ); 209 } 210 if ( isset( $cp_options['custom_headers'] ) ) { 211 $cp_options['mem']['custom_headers'] = $cp_options['custom_headers']; 212 unset( $cp_options['custom_headers'] ); 213 } 214 if ( isset( $cp_options['exclusions'] ) ) { 215 $cp_options['mem']['exclusions'] = $cp_options['exclusions']; 216 unset( $cp_options['exclusions'] ); 160 217 } 161 218 -
code-profiler/trunk/lib/i18n-extra.php
r3240958 r3371018 152 152 __('Run the profiler', 'code-profiler'); 153 153 __('Enter your license', 'code-profiler'); 154 __('Profile your blog with Code Profiler Pro.', 'code-profiler');155 154 __('The MU plugin isn\'t loaded, please check the log', 'code-profiler'); 156 155 __('Initializing Code Profiler Pro v%s on %s. Profile: %s - %s', 'code-profiler'); -
code-profiler/trunk/lib/menu_profiler.php
r3314519 r3371018 49 49 $home = home_url('/'); // Frontend 50 50 $site = site_url('/'); // Backend 51 51 52 // Get user login name 52 53 $current_user = wp_get_current_user(); 54 55 $cp_options = get_option('code-profiler'); 56 /** 57 * Check if we've been asked to re-run a profile. 58 */ 59 if (! empty( $_REQUEST['action'] ) && $_REQUEST['action'] == 'rerun' && 60 ! empty( $_REQUEST['profiles'][0] ) ) { 61 /** 62 * Make sure the profile exists and get its full path. 63 */ 64 $profile_path = code_profiler_get_profile_path( $_REQUEST['profiles'][0] ); 65 if ( $profile_path !== false ) { 66 67 $cp_data = json_decode( file_get_contents("$profile_path.summary.profile"), true ); 68 if (! empty( $cp_data['rerun'] ) ) { 69 $cp_options['mem'] = $cp_data['rerun']; 70 $rerun = true; 71 } 72 } 73 } 53 74 // Profile's name 54 $profile = code_profiler_profile_name(); 55 56 $cp_options = get_option('code-profiler'); 57 // Memorized options 58 if ( empty( $cp_options['mem_where'] ) ) { 59 $cp_options['mem_where'] = 'frontend'; 60 } 61 if ( empty( $cp_options['mem_post'] ) ) { 62 $cp_options['mem_post'] = ''; 63 } 64 if ( empty( $cp_options['mem_user'] ) ) { 65 $cp_options['mem_user'] = 'unauthenticated'; 66 } 67 if ( $cp_options['mem_where'] == 'backend') { 68 $cp_options['mem_user'] = 'authenticated'; 69 } 70 if ( empty( $cp_options['mem_method'] ) ) { 71 $cp_options['mem_method'] = 'get'; 75 if (! empty( $cp_options['mem']['profile'] ) ) { 76 $profile = $cp_options['mem']['profile']; 77 } else { 78 $profile = code_profiler_profile_name(); 79 } 80 /** 81 * Memorized options from last run. 82 */ 83 if ( empty( $cp_options['mem']['x_end'] ) ) { 84 $cp_options['mem']['x_end'] = 'frontend'; 85 } 86 if ( empty( $cp_options['mem']['post'] ) ) { 87 $cp_options['mem']['post'] = ''; 88 } 89 if ( empty( $cp_options['mem']['x_auth'] ) ) { 90 $cp_options['mem']['x_auth'] = 'unauthenticated'; 91 } 92 if ( $cp_options['mem']['x_end'] == 'backend') { 93 $cp_options['mem']['x_auth'] = 'authenticated'; 94 } 95 if ( empty( $cp_options['mem']['method'] ) ) { 96 $cp_options['mem']['method'] = 'get'; 72 97 } 73 98 $default_theme = get_option('stylesheet'); 74 if ( empty( $cp_options['mem_theme'] ) ) { 75 $cp_options['mem_theme'] = $default_theme; 76 } 77 if ( empty( $cp_options['ua'] ) ) { 78 $cp_options['ua'] = 'Firefox'; 79 } 80 $cookies = ''; 81 $payload = ''; 82 $custom_headers = ''; 83 $exclusions = []; 84 85 if ( isset( $cp_options['cookies'] ) ) { 99 if ( empty( $cp_options['mem']['theme'] ) ) { 100 $cp_options['mem']['theme'] = $default_theme; 101 } 102 if ( empty( $cp_options['mem']['user_agent'] ) ) { 103 $cp_options['mem']['user_agent'] = 'Firefox'; 104 } 105 if ( isset( $cp_options['mem']['cookies'] ) ) { 86 106 // stripslashes is only needed for cookies 87 $cookies = trim( stripslashes( json_decode( $cp_options['cookies'] ) ) ); 88 } 89 if ( empty( $cp_options['mem_content_type'] ) || 90 ! in_array( $cp_options['mem_content_type'], [ 1, 2, 3 ] ) ) { 91 92 $cp_options['mem_content_type'] = 1; 93 } 94 if ( isset( $cp_options['payload'] ) ) { 95 $payload = trim( json_decode( $cp_options['payload'] ) ); 96 } 97 if ( isset( $cp_options['custom_headers'] ) ) { 98 $custom_headers = trim( json_decode( $cp_options['custom_headers'] ) ); 99 } 100 if ( isset( $cp_options['exclusions'] ) ) { 101 $exclusions = json_decode( $cp_options['exclusions'] ); 102 } 107 $cookies = trim( stripslashes( json_decode( $cp_options['mem']['cookies'] ) ) ); 108 } else { 109 $cookies = ''; 110 } 111 if ( empty( $cp_options['mem']['content_type'] ) || 112 ! in_array( $cp_options['mem']['content_type'], [ 1, 2, 3 ] ) ) { 113 114 $cp_options['mem']['content_type'] = 1; 115 } 116 if ( isset( $cp_options['mem']['payload'] ) ) { 117 $payload = trim( json_decode( $cp_options['mem']['payload'] ) ); 118 } else { 119 $payload = ''; 120 } 121 if ( isset( $cp_options['mem']['custom_headers'] ) ) { 122 $custom_headers = trim( json_decode( $cp_options['mem']['custom_headers'] ) ); 123 } else { 124 $custom_headers = ''; 125 } 126 if ( isset( $cp_options['mem']['exclusions'] ) ) { 127 $exclusions = json_decode( $cp_options['mem']['exclusions'] ); 128 } else { 129 $exclusions = []; 130 } 131 103 132 ?> 104 <table class="form-table"> 133 134 <table style="width:100%"> 105 135 <tr> 106 <th scope="row"><?php esc_html_e('Page to profile', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Select the page you want the profiler to analyze. It can be in the frontend of the site, in the admin backend or a custom URL.', 'code-profiler') ?>"></span></th>107 136 <td> 108 <p><label><input type="radio" name="where" value="frontend" onclick="cpjs_front_or_backend(1);"<?php checked( $cp_options['mem_where'], 'frontend') ?> /> <?php esc_html_e('Website frontend', 'code-profiler') ?></label> 109 110 <label><input type="radio" name="where" value="custom" onclick="cpjs_front_or_backend(3);"<?php checked( $cp_options['mem_where'], 'custom') ?> /> <?php esc_html_e('Custom post/URL', 'code-profiler') ?></label> 111 112 <label><input type="radio" name="where" value="backend" onclick="cpjs_front_or_backend(2);"<?php checked( $cp_options['mem_where'], 'backend') ?> /> <?php esc_html_e('Admin backend', 'code-profiler') ?></label> 113 </p> 114 <br /> 115 <?php 116 if ( $cp_options['mem_where'] == 'frontend') { 117 echo '<p id="p-frontend">'; 118 } else { 119 echo '<p id="p-frontend" style="display:none">'; 120 } 121 ?> 122 <?php esc_html_e('Select a page:', 'code-profiler') ?> 123 <select name="frontend" id="id-frontend"> 124 <?php echo code_profiler_fetch_pages( $home, $cp_options ); ?> 125 </select> 126 </p> 127 <?php 128 if ( $cp_options['mem_where'] == 'custom') { 129 $value = $cp_options['mem_post']; 130 echo '<p id="p-custom">'; 131 } else { 132 $value = ''; 133 echo '<p id="p-custom" style="display:none">'; 134 } 135 ?> 136 <input name="custom" id="id-custom" type="text" value="<?php echo esc_attr( $value ) ?>" size="70" placeholder="<?php 137 echo esc_attr( 138 sprintf( 139 __('e.g., %s', 'code-profiler'), 140 "{$home}foo/bar/" 141 ) 142 ) ?>" /> 143 </p> 144 <?php 145 if ( $cp_options['mem_where'] == 'backend') { 146 echo '<p id="p-backend">'; 147 } else { 148 echo '<p id="p-backend" style="display:none">'; 149 } 150 if (! empty( $cp_options['mem_username'] ) ) { 151 $username = $cp_options['mem_username']; 152 } else { 153 $username = $current_user->user_login; 154 } 155 ?> 156 <?php esc_html_e('Select a page:', 'code-profiler') ?> 157 <select name="backend" id="id-backend"><?php echo code_profiler_fetch_admin_pages( $site, $cp_options ) ?></select> 158 </p> 137 <table class="form-table"> 138 <tr> 139 <th scope="row"><?php esc_html_e('Page to profile', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Select the page you want the profiler to analyze. It can be in the frontend of the site, in the admin backend or a custom URL.', 'code-profiler') ?>"></span></th> 140 <td> 141 <p><label><input type="radio" name="x_end" value="frontend" onclick="cpjs_front_or_backend(1);"<?php checked( $cp_options['mem']['x_end'], 'frontend') ?> /> <?php esc_html_e('Website frontend', 'code-profiler') ?></label> 142 143 <label><input type="radio" name="x_end" value="custom" onclick="cpjs_front_or_backend(3);"<?php checked( $cp_options['mem']['x_end'], 'custom') ?> /> <?php esc_html_e('Custom post/URL', 'code-profiler') ?></label> 144 145 <label><input type="radio" name="x_end" value="backend" onclick="cpjs_front_or_backend(2);"<?php checked( $cp_options['mem']['x_end'], 'backend') ?> /> <?php esc_html_e('Admin backend', 'code-profiler') ?></label> 146 </p> 147 <br /> 148 <?php 149 if ( $cp_options['mem']['x_end'] == 'frontend') { 150 echo '<p id="p-frontend">'; 151 } else { 152 echo '<p id="p-frontend" style="display:none">'; 153 } 154 ?> 155 <?php esc_html_e('Select a page:', 'code-profiler') ?> 156 <select name="frontend" id="id-frontend"> 157 <?php echo code_profiler_fetch_pages( $home, $cp_options ); ?> 158 </select> 159 </p> 160 <?php 161 if ( $cp_options['mem']['x_end'] == 'custom') { 162 $value = $cp_options['mem']['post']; 163 echo '<p id="p-custom">'; 164 } else { 165 $value = ''; 166 echo '<p id="p-custom" style="display:none">'; 167 } 168 ?> 169 <input name="custom" id="id-custom" type="text" value="<?php echo esc_attr( $value ) ?>" size="70" placeholder="<?php 170 echo esc_attr( 171 sprintf( 172 __('e.g., %s', 'code-profiler'), 173 "{$home}foo/bar/" 174 ) 175 ) ?>" /> 176 </p> 177 <?php 178 if ( $cp_options['mem']['x_end'] == 'backend') { 179 echo '<p id="p-backend">'; 180 } else { 181 echo '<p id="p-backend" style="display:none">'; 182 } 183 if (! empty( $cp_options['mem']['username'] ) ) { 184 $username = $cp_options['mem']['username']; 185 } else { 186 $username = $current_user->user_login; 187 } 188 ?> 189 <?php esc_html_e('Select a page:', 'code-profiler') ?> 190 <select name="backend" id="id-backend"><?php echo code_profiler_fetch_admin_pages( $site, $cp_options ) ?></select> 191 </p> 192 </td> 193 </tr> 194 <tr> 195 <th scope="row"><?php esc_html_e('Run profiler as', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('The profiler can access the requested page as an unauthenticated user (frontend only) or as an authenticated user (frontend and backend). You can enter the login name of any registered user, but make sure that the user has the required capability to access the page you are going to profile, otherwise Code Profiler will return an error if the user isn\'t allowed to access it.', 'code-profiler') ?>"></span></th> 196 <td> 197 <p><label><input type="radio" onclick="cpjs_authenticated(0);" name="x_auth" value="unauthenticated" id="user-unauthenticated"<?php checked( $cp_options['mem']['x_auth'], 'unauthenticated'); disabled( $cp_options['mem']['x_end'], 'backend'); ?> /> <?php esc_html_e('Unauthenticated user', 'code-profiler') ?></label></p> 198 <p><label><input type="radio" onclick="cpjs_authenticated(1);" name="x_auth" value="authenticated" id="user-authenticated"<?php checked( $cp_options['mem']['x_auth'], 'authenticated') ?> /> <?php esc_html_e('Authenticated user', 'code-profiler') ?></label></p> 199 <p><label><?php esc_html_e('User:', 'code-profiler') ?> <input type="text" name="username" id="user-name" value ="<?php esc_attr_e( $username ) ?>"<?php disabled( $cp_options['mem']['x_auth'], 'unauthenticated') ?> /></label></p> 200 </td> 201 </tr> 202 <tr> 203 <th scope="row"><?php esc_html_e('Theme', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('If you want to profile different themes, you can use this option so that you don\'t need to modify your WordPress settings. The change will not affect your visitors, but only the profiler when it is running.', 'code-profiler') ?>"></span></th> 204 <td> 205 <select name="theme" id="id-theme"> 206 <?php 207 $themes = code_profiler_get_themes(); 208 foreach( $themes as $slug => $name ) { 209 if ( $slug == $default_theme ) { 210 echo '<option value=""'. selected( $cp_options['mem']['theme'], $slug, false ) .'>'. 211 esc_html( $name['n'] ) .' '. __('(active theme)', 'code-profiler') .'</option>'; 212 } else { 213 echo '<option value="'. esc_attr( $slug ) .'"'. selected( $cp_options['mem']['theme'], $slug, false ) .'>'. 214 esc_html( $name['n'] ) .'</option>'; 215 } 216 } 217 ?> 218 </select> 219 </td> 220 </tr> 221 <tr> 222 <th scope="row"><?php esc_html_e('User agent', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Some themes and plugins may execute different code depending on the type of device used to visit the website (e.g., a desktop computer, a mobile phone, a search engine bot etc). This option lets you change the User-Agent request header used by Code Profiler.', 'code-profiler') ?>"></span></th> 223 <td> 224 <select name="user_agent" id="ua-id"> 225 <?php 226 foreach( CODE_PROFILER_UA as $types => $types_array ) { 227 echo '<optgroup label="'. esc_attr( $types ) .'">'; 228 foreach( $types_array as $name => $value ) { 229 echo '<option value="'. esc_attr( $name ) .'"'. selected( $cp_options['mem']['user_agent'], $name, false ) .'>'. esc_html( $name ) .'</option>'; 230 } 231 echo '</optgroup>'; 232 } 233 ?> 234 </select> 235 </td> 236 </tr> 237 <tr> 238 <th scope="row"><?php esc_html_e('Name of the profile', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Enter the name for this profile. It will be saved to the "Profiles List" page, with all other profiles.', 'code-profiler') ?>"></span></th> 239 <td> 240 <p><label><input type="text" class="regular-text" name="profile" maxlength="100" value="<?php echo esc_attr( $profile ) ?>" id="profile-name" /></label></p> 241 <p class="description"><?php esc_html_e('Max 100 characters', 'code-profiler') ?></p> 242 </td> 243 </tr> 244 </table> 159 245 </td> 160 </tr> 161 <tr> 162 <th scope="row"><?php esc_html_e('Run profiler as', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('The profiler can access the requested page as an unauthenticated user (frontend only) or as an authenticated user (frontend and backend). You can enter the login name of any registered user, but make sure that the user has the required capability to access the page you are going to profile, otherwise Code Profiler will return an error if the user isn\'t allowed to access it.', 'code-profiler') ?>"></span></th> 163 <td> 164 <p><label><input type="radio" onclick="cpjs_authenticated(0);" name="user" value="unauthenticated" id="user-unauthenticated"<?php checked( $cp_options['mem_user'], 'unauthenticated'); disabled( $cp_options['mem_where'], 'backend'); ?> /> <?php esc_html_e('Unauthenticated user', 'code-profiler') ?></label></p> 165 <p><label><input type="radio" onclick="cpjs_authenticated(1);" name="user" value="authenticated" id="user-authenticated"<?php checked( $cp_options['mem_user'], 'authenticated') ?> /> <?php esc_html_e('Authenticated user', 'code-profiler') ?></label></p> 166 <p><label><?php esc_html_e('User:', 'code-profiler') ?> <input type="text" name="username" id="user-name" value ="<?php esc_attr_e( $username ) ?>"<?php disabled( $cp_options['mem_user'], 'unauthenticated') ?> /></label></p> 167 </td> 168 </tr> 169 <tr> 170 <th scope="row"><?php esc_html_e('Theme', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('If you want to profile different themes, you can use this option so that you don\'t need to modify your WordPress settings. The change will not affect your visitors, but only the profiler when it is running.', 'code-profiler') ?>"></span></th> 171 <td> 172 <select name="theme" id="id-theme"> 173 <?php 174 $themes = code_profiler_get_themes(); 175 foreach( $themes as $slug => $name ) { 176 if ( $slug == $default_theme ) { 177 echo '<option value=""'. selected( $cp_options['mem_theme'], $slug, false ) .'>'. 178 esc_html( $name['n'] ) .' '. __('(active theme)', 'code-profiler') .'</option>'; 179 } else { 180 echo '<option value="'. esc_attr( $slug ) .'"'. selected( $cp_options['mem_theme'], $slug, false ) .'>'. 181 esc_html( $name['n'] ) .'</option>'; 182 } 183 } 184 ?> 185 </select> 186 </td> 187 </tr> 188 <tr> 189 <th scope="row"><?php esc_html_e('User agent', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Some themes and plugins may execute different code depending on the type of device used to visit the website (e.g., a desktop computer, a mobile phone, a search engine bot etc). This option lets you change the User-Agent request header used by Code Profiler.', 'code-profiler') ?>"></span></th> 190 <td> 191 <select name="ua" id="ua-id"> 192 <?php 193 foreach( CODE_PROFILER_UA as $types => $types_array ) { 194 echo '<optgroup label="'. esc_attr( $types ) .'">'; 195 foreach( $types_array as $name => $value ) { 196 echo '<option value="'. esc_attr( $name ) .'"'. selected( $cp_options['ua'], $name, false ) .'>'. esc_html( $name ) .'</option>'; 197 } 198 echo '</optgroup>'; 199 } 200 ?> 201 </select> 202 </td> 203 </tr> 204 <tr> 205 <th scope="row"><?php esc_html_e('Name of the profile', 'code-profiler') ?> <span class="code-profiler-tip" data-tip="<?php esc_attr_e('Enter the name for this profile. It will be saved to the "Profiles List" page, with all other profiles.', 'code-profiler') ?>"></span></th> 206 <td> 207 <p><label><input type="text" class="regular-text" name="profile" maxlength="100" value="<?php echo esc_attr( $profile ) ?>" id="profile-name" /></label></p> 208 <p class="description"><?php esc_html_e('Max 100 characters', 'code-profiler') ?></p> 246 <td style="vertical-align:top;text-align: center"> 247 <?php 248 /** 249 * Display any available discount coupon. 250 */ 251 CodeProfiler_WPCron::display_coupon(); 252 ?> 209 253 </td> 210 254 </tr> 211 255 </table> 212 256 <?php 213 if (! empty( $cookies ) || ! empty( $custom_headers ) || $cp_options['mem_method'] == 'post' || ! empty( $exclusions ) ) { 257 258 if (! empty( $cookies ) || ! empty( $custom_headers ) || $cp_options['mem']['method'] == 'post' || ! empty( $exclusions ) ) { 214 259 echo '<div id="cp-advanced-settings">'; 215 260 $disabled_button = ' disabled'; … … 225 270 <p> 226 271 <label> 227 <input onclick="cpjs_get_post(0);" type="radio" name="method" value="get" id="get-method"<?php checked( $cp_options['mem _method'], 'get') ?> /> GET(<?php esc_html_e('default', 'code-profiler') ?>)272 <input onclick="cpjs_get_post(0);" type="radio" name="method" value="get" id="get-method"<?php checked( $cp_options['mem']['method'], 'get') ?> /> GET(<?php esc_html_e('default', 'code-profiler') ?>) 228 273 </label> 229 274 </p> 230 275 <p> 231 276 <label> 232 <input onclick="cpjs_get_post(1);" type="radio" name="method" value="post" id="post-method"<?php checked( $cp_options['mem _method'], 'post') ?> /> POST277 <input onclick="cpjs_get_post(1);" type="radio" name="method" value="post" id="post-method"<?php checked( $cp_options['mem']['method'], 'post') ?> /> POST 233 278 </label> 234 279 </p> 235 280 <p> 236 281 <?php esc_html_e('Content-type:', 'code-profiler') ?> 237 <select name="cp-content-type" id="id-content-type"<?php disabled( $cp_options['mem _method'], 'get') ?> onChange="cpjs_content_type(this.value);">238 <option value="1"<?php selected( $cp_options['mem _content_type'], 1 )?>>application/x-www-form-urlencoded (<?php esc_html_e('formatted', 'code-profiler') ?>)</option>239 <option value="3"<?php selected( $cp_options['mem _content_type'], 3 )?>>application/x-www-form-urlencoded (<?php esc_html_e('raw', 'code-profiler') ?>)</option>240 <option value="2"<?php selected( $cp_options['mem _content_type'], 2 )?>>application/json</option>282 <select name="cp-content-type" id="id-content-type"<?php disabled( $cp_options['mem']['method'], 'get') ?> onChange="cpjs_content_type(this.value);"> 283 <option value="1"<?php selected( $cp_options['mem']['content_type'], 1 )?>>application/x-www-form-urlencoded (<?php esc_html_e('formatted', 'code-profiler') ?>)</option> 284 <option value="3"<?php selected( $cp_options['mem']['content_type'], 3 )?>>application/x-www-form-urlencoded (<?php esc_html_e('raw', 'code-profiler') ?>)</option> 285 <option value="2"<?php selected( $cp_options['mem']['content_type'], 2 )?>>application/json</option> 241 286 </select> 242 287 </p> 243 288 <p> 244 <textarea name="post-value" id="post-value" class="regular-text code"<?php disabled( $cp_options['mem _method'], 'get') ?> maxlength="4000" rows="6"><?php echo esc_textarea( $payload ) ?></textarea>245 </p> 246 <p class="description" id="ct-1"<?php echo code_profiler_showhide( $cp_options['mem _content_type'], 1 ) ?>>289 <textarea name="post-value" id="post-value" class="regular-text code"<?php disabled( $cp_options['mem']['method'], 'get') ?> maxlength="4000" rows="6"><?php echo esc_textarea( $payload ) ?></textarea> 290 </p> 291 <p class="description" id="ct-1"<?php echo code_profiler_showhide( $cp_options['mem']['content_type'], 1 ) ?>> 247 292 <?php printf( esc_html__('Optional POST payload in %s format, one item per line.', 'code-profiler'), '<code>name=value</code>') ?> <?php printf( esc_html__('%sView example%s', 'code-profiler'), '<a href="'. plugins_url('/static/help/http_method-1.png', dirname( __FILE__ ) ) .'" target="_blank" rel="noopener noreferrer">', '</a>') ?> 248 293 </p> 249 <p class="description" id="ct-3"<?php echo code_profiler_showhide( $cp_options['mem _content_type'], 3 ) ?>>294 <p class="description" id="ct-3"<?php echo code_profiler_showhide( $cp_options['mem']['content_type'], 3 ) ?>> 250 295 <?php printf( esc_html__('Optional raw POST payload, on a single line.', 'code-profiler'), '<code>name=value</code>') ?> <?php printf( esc_html__('%sView example%s', 'code-profiler'), '<a href="'. plugins_url('/static/help/http_method-3.png', dirname( __FILE__ ) ) .'" target="_blank" rel="noopener noreferrer">', '</a>') ?> 251 296 </p> 252 <p class="description" id="ct-2"<?php echo code_profiler_showhide( $cp_options['mem _content_type'], 2 ) ?>>297 <p class="description" id="ct-2"<?php echo code_profiler_showhide( $cp_options['mem']['content_type'], 2 ) ?>> 253 298 <?php printf( esc_html__('Optional JSON-encoded payload, on a single line.', 'code-profiler'), '<code>name=value</code>') ?> <?php printf( esc_html__('%sView example%s', 'code-profiler'), '<a href="'. plugins_url('/static/help/http_method-2.png', dirname( __FILE__ ) ) .'" target="_blank" rel="noopener noreferrer">', '</a>') ?> 254 299 </p> … … 294 339 <img style="vertical-align:middle;display:none" id="progress-gif" src="<?php echo plugins_url('/static/progress.gif', dirname (__FILE__ ) ) ?>" /> <font id="progress-text" style="display:none"><?php esc_html_e('Starting the profiler...', 'code-profiler') ?></font> 295 340 </div> 296 297 341 <?php 342 343 /** 344 * Re-run a profile. 345 */ 346 if (! empty( $rerun ) ) { 347 echo '<script>window.addEventListener("load", cpjs_start_profiler);</script>'; 348 } 298 349 299 350 // ===================================================================== … … 304 355 $posts = ''; 305 356 306 if ( empty( $cp_options['mem _post'] ) ) {307 $cp_options['mem _post'] = $home;308 } 309 310 if ( $cp_options['mem _post'] == $home ) {357 if ( empty( $cp_options['mem']['post'] ) ) { 358 $cp_options['mem']['post'] = $home; 359 } 360 361 if ( $cp_options['mem']['post'] == $home ) { 311 362 $pages = sprintf( 312 363 '<option value="%1$s" title="%1$s" selected>%2$s</option>', … … 338 389 $permalink = get_permalink( $item->ID ); 339 390 340 if ( $cp_options['mem _post'] == $permalink ) {391 if ( $cp_options['mem']['post'] == $permalink ) { 341 392 $pages .= sprintf( 342 393 '<option value="%1$s" title="%1$s" selected>%2$s</option>', … … 367 418 $backend = ''; 368 419 369 if ( empty( $cp_options['mem _post'] ) ) {370 $cp_options['mem _post'] = $home;420 if ( empty( $cp_options['mem']['post'] ) ) { 421 $cp_options['mem']['post'] = $home; 371 422 } 372 423 … … 377 428 $value[0] = trim( preg_replace('/\s*<.+$/', '', $value[0] ) ); 378 429 379 if ( $cp_options['mem _post'] == "{$home}wp-admin/{$value[2]}" ) {430 if ( $cp_options['mem']['post'] == "{$home}wp-admin/{$value[2]}" ) { 380 431 $backend .= sprintf( 381 432 '<option value="%1$s" title="%1$s" selected>%2$s</option>', -
code-profiler/trunk/readme.txt
r3316061 r3371018 4 4 Requires at least: 5.0 5 5 Tested up to: 6.8 6 Stable tag: 1. 7.76 Stable tag: 1.8 7 7 License: GPLv3 or later 8 8 Requires PHP: 7.1 … … 94 94 == Changelog == 95 95 96 = 1.8 (1st October, 2025) = 97 98 * This version introduces a new feature requested by many users: the possibility to re-run an existing profile. In the "Profiles List" table, click on the "Re-run" row action link and Code Profiler will run again the profile with the same options and parameters. 99 * Fixed an "Automatic conversion of false to array is deprecated" message in PHP 8.1+. 100 * Small fixes and adjustments. 101 96 102 = 1.7.7 (23 June, 2025) = 97 103 -
code-profiler/trunk/static/code-profiler.js
r3314519 r3371018 197 197 198 198 function cpjs_start_profiler() { 199 'use strict'; 199 200 'use strict'; 201 202 jQuery('html, body').animate( { 203 scrollTop: jQuery('#button-adv-settings').offset().top 204 }, 1000 ); 205 200 206 // Get the nonce 201 207 var cp_nonce = jQuery('#cp_nonce').val(); … … 207 213 // Get the scan type (frontend/backend) 208 214 var post; 209 var where = jQuery('input[name="where"]:checked').val();210 if ( where== 'frontend') {215 var x_end = jQuery('input[name="x_end"]:checked').val(); 216 if ( x_end == 'frontend') { 211 217 post = jQuery('#id-frontend').val(); 212 218 213 } else if ( where== 'backend') {219 } else if ( x_end == 'backend') { 214 220 post = jQuery('#id-backend').val(); 215 221 216 } else if ( where== 'custom') {222 } else if ( x_end == 'custom') { 217 223 post = jQuery('#id-custom').val().trim(); // Trim user input 218 224 … … 234 240 } 235 241 236 var user = jQuery('input[name="user"]:checked').val();237 if ( user== '') {242 var x_auth = jQuery('input[name="x_auth"]:checked').val(); 243 if ( x_auth == '') { 238 244 alert( cpi18n.missing_userauth ); 239 245 return; … … 241 247 242 248 var username = jQuery('#user-name').val().trim(); // Trim user input 243 if ( user== 'authenticated') {249 if ( x_auth == 'authenticated') { 244 250 if ( username == '') { 245 251 alert( cpi18n.missing_username ); … … 249 255 } 250 256 251 var u a= jQuery('#ua-id').val();252 if ( u a== 'undefined') {253 u a= 'FireFox';257 var user_agent = jQuery('#ua-id').val(); 258 if ( user_agent == 'undefined') { 259 user_agent = 'FireFox'; 254 260 } 255 261 … … 299 305 'action': 'codeprofiler_start_profiler', 300 306 'cp_nonce': cp_nonce, 301 ' where': where,307 'x_end': x_end, 302 308 'post': post, 303 309 'content_type': ct, 304 310 'profile': profile, 305 ' user': user,311 'x_auth': x_auth, 306 312 'username': username, 307 313 'cookies': cookies, … … 310 316 'method': method, 311 317 'payload': payload, 312 'u a': ua,318 'user_agent': user_agent, 313 319 'theme': theme 314 320 };
Note: See TracChangeset
for help on using the changeset viewer.