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 namespace Clockwork\Web; // Helper class for serving app assets class Web { // Ret..

Decoded Output download

<?php namespace Clockwork\Web;

// Helper class for serving app assets
class Web
{
	// Return the absolute path and a mime type of an asset, protects from accessing files outside Clockwork public dir
	public function asset($path)
	{
		$path = $this->resolveAssetPath($path);

		if (! $path) return;

		switch (pathinfo($path, PATHINFO_EXTENSION)) {
			case 'css': $mime = 'text/css'; break;
			case 'js': $mime = 'application/javascript'; break;
			case 'json': $mime = 'application/json'; break;
			case 'png': $mime = 'image/png'; break;
			default: $mime = 'text/html'; break;
		}

		return [
			'path' => $path,
			'mime' => $mime
		];
	}

	// Resolves absolute path of the asset, protects from accessing files outside Clockwork public dir
	protected function resolveAssetPath($path)
	{
		$publicPath = realpath(__DIR__ . '/public');

		$path = realpath("$publicPath/{$path}");

		return strpos($path, $publicPath) === 0 ? $path : false;
	}
}
 ?>

Did this file decode correctly?

Original Code

<?php namespace Clockwork\Web;

// Helper class for serving app assets
class Web
{
	// Return the absolute path and a mime type of an asset, protects from accessing files outside Clockwork public dir
	public function asset($path)
	{
		$path = $this->resolveAssetPath($path);

		if (! $path) return;

		switch (pathinfo($path, PATHINFO_EXTENSION)) {
			case 'css': $mime = 'text/css'; break;
			case 'js': $mime = 'application/javascript'; break;
			case 'json': $mime = 'application/json'; break;
			case 'png': $mime = 'image/png'; break;
			default: $mime = 'text/html'; break;
		}

		return [
			'path' => $path,
			'mime' => $mime
		];
	}

	// Resolves absolute path of the asset, protects from accessing files outside Clockwork public dir
	protected function resolveAssetPath($path)
	{
		$publicPath = realpath(__DIR__ . '/public');

		$path = realpath("$publicPath/{$path}");

		return strpos($path, $publicPath) === 0 ? $path : false;
	}
}

Function Calls

None

Variables

None

Stats

MD5 82a89cf6a39a9a7090b3c08c9628e22d
Eval Count 0
Decode Time 76 ms