اذهب إلى المحتوى
  • 0

كيف يمكنني تشفير ملف PHP يحتوي على كود HTML باستخدام phpBolt؟

Abdelrahman Mostafa10

السؤال

أحاول تشفير ملف بامتداد .php باستخدام phpBolt، وينجح الأمر عند تشفير ملفات PHP فقط، ولكن عندما يحتوي الملف على مزيج من HTML و PHP، لا يعمل التشفير.

<?php 

/**
 * src : source folder 
 * encrypted : Output folder
 */

$src      = 'src';
$php_blot_key = "kyc7fh";


/**
 * No need to edit following code 
 */

$excludes = array('vendor');

foreach($excludes as $key => $file){
    $excludes[ $key ] = $src.'/'.$file;
}

// $rec = new RecursiveIteratorIterator(new RecursiveDirectoryIterator( $src ));
$rec  = new DirectoryIterator($src);
$require_funcs = array('include_once', 'include', 'require', 'require_once'); 


foreach ($rec as $file) {

    if ($file->isDir()) {
        $newDir  = str_replace( 'src', 'encrypted', $file->getPath() );
        if( !is_dir( $newDir ) ) mkdir( $newDir );
        continue;
    };

    $filePath = $file->getPathname();

    if( pathinfo($filePath, PATHINFO_EXTENSION) != 'php'  ||
        in_array( $filePath, $excludes ) ) {  
        $newFile  = str_replace('src', 'encrypted', $filePath );
        copy( $filePath, $newFile );
        continue;
    }

    $contents = file_get_contents( $filePath );
    $preppand = '<?php define("PHP_BOLT_KEY", "kyc7fh"); bolt_decrypt( __FILE__ , PHP_BOLT_KEY); return 0;
    ##!!!##';
    $re = '/\<\?php/m';
    preg_match($re, $contents, $matches ); 
    if(!empty($matches[0]) ){
       $contents = preg_replace( $re, '', $contents );
       ##!!!##';
    }
    /*$cipher   = bolt_encrypt( "?> ".$contents, $php_blot_key );*/
    $cipher   = bolt_encrypt( $contents, $php_blot_key );
    $newFile  = str_replace('src', 'encrypted', $filePath );
    $fp = fopen( $newFile, 'w');
    fwrite($fp, $preppand.$cipher);
    fclose($fp);

    unset( $cipher );
    unset( $contents );
}

$out_str       = substr_replace($src, '', 0, 4);
$file_location = __DIR__."/encrypted/".$out_str;
echo "Successfully Encrypted... Please check in <b>" .$file_location."</a></b> folder.";

لكن لا يعمل هنا:

<html>
    <body>
        <h1>
            <?php 
                echo "Hello Sarbaz Ali !!!";
            ?>
        </h1>
    </body>
</html>

وعندما يكون الملف بالشكل التالي يعمل بشكل سليم:

<?php 
echo "<h1> Hello Sarbaz Ali !!! </h1>";
?>

هل يمكنني تشفير الملف الأول (الذي يحتوي على علامات HTML) باستخدام phpBolt؟

رابط هذا التعليق
شارك على الشبكات الإجتماعية

Recommended Posts

لا توجد أي إجابات على هذا السؤال بعد

انضم إلى النقاش

يمكنك أن تنشر الآن وتسجل لاحقًا. إذا كان لديك حساب، فسجل الدخول الآن لتنشر باسم حسابك.

زائر
أجب على هذا السؤال...

×   لقد أضفت محتوى بخط أو تنسيق مختلف.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   جرى استعادة المحتوى السابق..   امسح المحرر

×   You cannot paste images directly. Upload or insert images from URL.

  • إعلانات

  • تابعنا على



×
×
  • أضف...