Last active
January 14, 2024 08:06
-
-
Save andifahruddinakas/49ca5e6a63802944c8d2ab21cad0b4ab to your computer and use it in GitHub Desktop.
Obfuscate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
if (!file_exists('Obfuscator.php')) { | |
file_put_contents('Obfuscator.php', file_get_contents('https://raw.githubusercontent.com/pH-7/Obfuscator-Class/master/src/Obfuscator.php')); | |
} | |
require 'Obfuscator.php'; | |
$onlyDirectory = [ | |
'app', | |
'donjo-app/core', | |
'donjo-app/helpers', | |
'donjo-app/controllers', | |
'donjo-app/models', | |
'donjo-app/third_party/pelanggan/libraries/pelanggan', | |
]; | |
$exceptDirectory = [ | |
'Providers', | |
'migrations', | |
'views', | |
'DevelBar', | |
'security', | |
'pelanggan', | |
'pendaftaran_kerjasama', | |
]; | |
$onlyFile = [ | |
// 'general_helper.php', | |
]; | |
$exceptFile = [ | |
'general_helper.php', | |
'install.php', | |
'ViewServiceProvider.php', | |
]; | |
foreach ($onlyDirectory as $list) { | |
cekFile($list, $exceptDirectory, $onlyFile, $exceptFile); | |
} | |
function cekFile($onlyDirectory, $exceptDirectory, $onlyFile, $exceptFile) | |
{ | |
if ($onlyDirectory) { | |
foreach (glob($onlyDirectory . '/*') as $cek) { | |
if (is_file($cek) && pathinfo($cek)['extension'] === 'php') { | |
// Only File | |
if ($onlyFile && ! (in_array($cek, $onlyFile) || preg_match('/' . implode('|', $onlyFile) . '/', basename($cek)))) { | |
continue; | |
} | |
// Except File | |
if ($exceptFile && (in_array($cek, $exceptFile) || preg_match('/' . implode('|', $exceptFile) . '/', basename($cek)))) { | |
continue; | |
} | |
if (file_exists($cek)) { | |
$sData = file_get_contents($cek); | |
$sData = str_replace(['<?php', '<?', '?>'], '', $sData); // We strip the open/close PHP tags | |
$sObfusationData = new Obfuscator($sData, $cek); | |
file_put_contents($cek, '<?php ' . "\r\n" . $sObfusationData); | |
} | |
} else { | |
// Except Directory | |
// contoh 1 : donjo-app/models/migrasi | |
// contoh 2 : migrasi | |
if ($exceptDirectory && (in_array($cek, $exceptDirectory) || preg_match('/' . implode('|', $exceptDirectory) . '/', basename($cek)))) { | |
continue; | |
} | |
cekFile($cek, $exceptDirectory, $onlyFile, $exceptFile); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment