Server : Apache System : Linux pod-100823:apache2_74:v0.5.7 5.4.0-1138-gcp #147~18.04.1-Ubuntu SMP Mon Oct 7 21:46:26 UTC 2024 x86_64 User : www-data ( 33) PHP Version : 7.4.33.7 Disable Function : apache_child_terminate,apache_get_modules,apache_get_version,apache_getenv,apache_note,apache_setenv,disk_free_space,disk_total_space,diskfreespace,dl,exec,fastcgi_finish_request,link,opcache_compile_file,opcache_get_configuration,opcache_invalidate,opcache_is_script_cached,opcache_reset,passthru,pclose,pcntl_exec,popen,posix_getpid,posix_getppid,posix_getpwuid,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,realpath_cache_get,shell_exec,show_source,symlink,system Directory : /nas/content/live/attorneyexperi/wp-content/plugins/redirection/fileio/ |
<?php class Red_Json_File extends Red_FileIO { public function force_download() { parent::force_download(); header( 'Content-Type: application/json' ); header( 'Content-Disposition: attachment; filename="' . $this->export_filename( 'json' ) . '"' ); } public function get_data( array $items, array $groups ) { $version = red_get_plugin_data( dirname( dirname( __FILE__ ) ) . '/redirection.php' ); $items = array( 'plugin' => array( 'version' => trim( $version['Version'] ), 'date' => date( 'r' ), ), 'groups' => $groups, 'redirects' => array_map( function( $item ) { return $item->to_json(); }, $items ), ); return wp_json_encode( $items, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES ) . PHP_EOL; } public function load( $group, $filename, $data ) { global $wpdb; $count = 0; $json = @json_decode( $data, true ); if ( $json === false ) { return 0; } // Import groups $groups = array(); $group_map = array(); if ( isset( $json['groups'] ) ) { foreach ( $json['groups'] as $group ) { $old_group_id = $group['id']; unset( $group['id'] ); $group = Red_Group::create( $group['name'], $group['module_id'], $group['enabled'] ? true : false ); if ( $group ) { $group_map[ $old_group_id ] = $group->get_id(); } } } unset( $json['groups'] ); // Import redirects if ( isset( $json['redirects'] ) ) { foreach ( $json['redirects'] as $pos => $redirect ) { unset( $redirect['id'] ); if ( ! isset( $group_map[ $redirect['group_id'] ] ) ) { $new_group = Red_Group::create( 'Group', 1 ); $group_map[ $redirect['group_id'] ] = $new_group->get_id(); } if ( $redirect['match_type'] === 'url' && isset( $redirect['action_data'] ) && ! is_array( $redirect['action_data'] ) ) { $redirect['action_data'] = array( 'url' => $redirect['action_data'] ); } $redirect['group_id'] = $group_map[ $redirect['group_id'] ]; Red_Item::create( $redirect ); $count++; // Helps reduce memory usage unset( $json['redirects'][ $pos ] ); $wpdb->queries = array(); $wpdb->num_queries = 0; } } return $count; } }