Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- BISMILLAAHIRRAHMAANIRRAHIIM - In the Name of Allah, Most Gracious, Most Merciful
- ================================================================================
- filename : encoder.php
- purpose : encode php file on entire specific directory
- create : 05xxxx
- last edit : 060711,070813,150719
- author : cahya dsn
- ================================================================================
- This program is free software; you can redistribute it and/or modify it under the
- terms of the GNU General Public License as published by the Free Software
- Foundation; either version 2 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 General Public License for more details.
- copyright (c) 2005-2015 by cahya dsn; [email protected]
- ================================================================================
- notes:
- - harus terinstall module zlib
- */
- if (!extension_loaded('zlib')) die('tidak ditemukan module zlib yang terpasang');
- $version="0.4";
- /********************************************************
- // function untuk memecah suatu strings dalam beberapa bagian
- // dalam bentuk array (dalam php5, sama dengan function 'str_split()'
- // the_string : string inputan yang akan dipecah
- // the_number : jumlah karakter dalam satu baris
- */
- function stringsplit($the_string, $the_length){
- $startoff_nr = 0;
- $the_output_array = array();
- for($z = 1; $z < ceil(strlen($the_string)/$the_length)+1 ; $z++){
- $startoff_nr = ($the_length*$z)-$the_length;
- $the_output_array[] = substr($the_string, $startoff_nr, $the_length);
- }
- return($the_output_array);
- }
- /********************************************************
- // function untuk mengencode suatu strings
- */
- function encode($strEncode){
- $c=rand(1,15);
- $strEncode=stripslashes($strEncode);
- if($strEncode){
- if(substr($strEncode,0,1)=="<"){
- $strEncode='?>'.$strEncode.'<?php';
- }
- for($j=0;$j<$c-1;$j++){
- if($j==$c-1){
- $strEncode=$strEncode."//".($c<10?"0".$c:$c);
- }
- $strEncode1=base64_encode(gzdeflate($strEncode));
- $strEncode="eval(gzinflate(base64_decode('".$strEncode1."')));";
- }
- }
- $strEncode="<?php \n".$strEncode."\n ?>";
- $arr=stringsplit($strEncode,70);
- $strEncode=$arr[0];
- for($i=1;$i<count($arr);$i++){
- $strEncode.="\n".$arr[$i];
- }
- $strEncode=str_replace("\n\n","\n",$strEncode);
- return $strEncode;
- }
- /********************************************************
- // function untuk mengambil daftar file2 yang akan di encode
- */
- function listFile($dir=".") {
- //--- ekstensi file2 yang akan di encode, bisa ditambah sesuai kebutuhan ---
- $ext = array("php", "inc");
- $file_list = '';
- $stack[] = $dir;
- while ($stack) {
- $current_dir = array_pop($stack);
- if ($dh = opendir($current_dir)) {
- while (($file = readdir($dh)) !== false) {
- if ($file !== '.' AND $file !== '..') {
- $current_file = "{$current_dir}/{$file}";
- if (is_file($current_file)) {
- for($i=0;$i<sizeof($ext);$i++)
- if (preg_match("/.".$ext[$i]."$/i", $current_file))
- $file_list[] = "{$current_dir}/{$file}";
- } elseif (is_dir($current_file)) {
- $stack[] = $current_file;
- }
- }
- }
- }
- }
- return $file_list;
- }
- /********************************************************
- // function utama untuk process encoding file
- */
- function process($path){
- echo "Proccessing files :<br/>\n";
- $filenya=array();
- $filenya=listFile($path);
- for($c=0;$c<count($filenya);$c++){
- $namafile=$filenya[$c];
- echo "<b>".$namafile."</b>";
- $str=file($namafile);
- $strings="";
- $n=count($str);
- for($h=0;$h<$n;$h++)
- $strings.=$str[$h];
- $hasil=encode(addslashes($strings));
- $fp0=@fopen($namafile, "w+");
- if($fp0 <= 0)
- die("Error opening data file.");
- fputs($fp0, $hasil."\n");
- fclose($fp0);
- if($_POST['chkBackup']==1){
- $fp=@fopen($namafile.".bak", "w+");
- if($fp <= 0)
- die("Error opening backup file.");
- fputs($fp, $strings."\n");
- fclose($fp);
- }
- echo " done<br />\n";
- }
- }
- if (!isset($_SERVER['DOCUMENT_ROOT']))
- $_SERVER['DOCUMENT_ROOT'] = str_replace('','/',substr($_SERVER['SCRIPT_FILENAME'],0,0-strlen($_SERVER['PHP_SELF'])));
- ?>
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title>phpEncoder v <?php echo $version;?></title>
- <style type="text/css">
- body,table {
- font-family:arial,san-serif,helvetica;
- font-size:9pt;
- color:#999999;
- }
- input{
- background-color:#EEEEEE;
- border: 1px solid #CCCCCC;
- }
- .header {
- padding-left:10px;
- background-color:#999999;
- color:#eeeeee;
- font-size:14pt;
- width:100%;
- height:25px;
- }
- a {
- text-decoration:none;
- color:#999999;
- }
- a:hover {
- text-decoration:none;
- border-bottom:dotted 1px #999999;
- color:#000099;
- }
- </style>
- </head>
- <body>
- <table align="center">
- <tr>
- <td class="header">phpEncoder v <?php echo $version;?></td>
- </tr>
- <tr>
- <td>
- <form action="<?php echo basename($_SERVER['PHP_SELF']);?>" method="post">
- <table width="550" cellpadding="2">
- <tr>
- <td>Directory name</td>
- <td><input type="text" name="txtPath" id="txtPath" style="width:200px;" value="<?php echo $_SERVER['DOCUMENT_ROOT'];?>" /></td>
- </tr>
- <tr>
- <td>File extensions will be encode (separated by comma)</td>
- <td><input type="text" name="txtExt" id="txtExt" style="width:200px;" value="php,inc" /></td>
- </tr>
- <tr>
- <td> </td>
- <td><input type="checkbox" name="chkBackup" id="chkBackup" value="1" checked /> backup file (generate .bak files)</td>
- </tr>
- </table>
- <p align=right>
- <input type="submit" name="btnSubmit" id="btnSubmit" value="process" />
- </p>
- </form>
- </td>
- </tr>
- <tr>
- <td>
- <?php
- if(isset($_POST['txtPath']))
- process($_POST['txtPath']);
- ?>
- </td>
- </tr>
- <tr bgColor="#CCCCCC">
- <td align="center">
- <small>
- <b>phpEncoder v <?php echo $version;?></b> copyright © 2005<?php echo (date("Y")>2005?"-".date("Y"):"");?> by <a href="http://adzan.16mb.com">cahya dsn</a>
- </small>
- </td>
- </tr>
- </table>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment