-
-
Save andifahruddinakas/825e01efcdb3e50a4e713b3d0e327941 to your computer and use it in GitHub Desktop.
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 | |
// https://github.com/pH-7/Obfuscator-Class | |
if (! file_exists('Obfuscator.php')) { | |
$content = file_get_contents('https://raw.githubusercontent.com/pH-7/Obfuscator-Class/master/src/Obfuscator.php'); | |
$fp = fopen("Obfuscator.php", "wb"); | |
fwrite($fp, $content); | |
fclose($fp); | |
} | |
require 'Obfuscator.php'; | |
$onlyDirectory = [ | |
// 'app', | |
// 'donjo-app/core', | |
'donjo-app/helpers', | |
'donjo-app/controllers', | |
// 'donjo-app/libraries', | |
// 'donjo-app/models', | |
]; | |
$exceptDirectory = [ | |
// 'donjo-app/models/migrasi', | |
]; | |
$onlyFile = [ | |
// 'donjo-app/helpers/cek_helper.php', | |
'donjo-app/controllers/Anjungan.php', | |
'donjo-app/controllers/Anjungan_menu.php', | |
'donjo-app/controllers/Anjungan_pengaturan.php', | |
'donjo-app/controllers/Buku_keperluan.php', | |
'donjo-app/controllers/Buku_kepuasan.php', | |
'donjo-app/controllers/Buku_pertanyaan.php', | |
'donjo-app/controllers/Buku_tamu.php', | |
]; | |
$exceptFile = [ | |
// 'donjo-app/helpers/general_helper.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)) { | |
continue; | |
} | |
// Except File | |
if ($exceptFile && in_array($cek, $exceptFile)) { | |
continue; | |
} | |
if (file_exists($cek)) { | |
$sData = file_get_contents($cek); | |
$sData = str_replace(array('<?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 | |
if ($exceptDirectory && in_array($cek, $exceptDirectory)) { | |
continue; | |
} | |
cekFile($cek, $exceptDirectory, $onlyFile, $exceptFile); | |
} | |
} | |
} else { | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment