简体   繁体   English

验证编码的脚本时出错

[英]Error validation the encoded script

I'm trying this 我正在尝试

<?php
    /* read the PHP source code */
    $source_code = file_get_contents("hello.php");

    $source_code = preg_replace('#^<\?php\s+#', '', $source_code);
    $source_code = preg_replace('#\s+\?>\s*$#', '', $source_code);

    /* create the encrypted version */
    $redistributable_key = blenc_encrypt($source_code, "encrypt.php", "my_fixed_password");

    $key_file = __DIR__ ."\keys"; 

    file_put_contents($key_file, $redistributable_key . "\n", FILE_APPEND);

    include 'encrypt.php';
    echo $hello;
?>

hello.php hello.php

<?php 

$hello = "Ciao";

I got this error 我得到这个错误

PHP Fatal error:  blenc_compile: Validation of script 
'encrypt.php' failed, cannot execute.

Please note that: 请注意:

  1. The key file is created, I'm already using the '\\n' fix 密钥文件已创建,我已经在使用'\\ n'修复程序
  2. I replaced <?php and ?> because another Stack Overflow question told me that it's a problem 我替换了<?php?>因为另一个堆栈溢出问题告诉我这是一个问题
<?php
    $file_name = basename($file);

    $unencrypted_key = = md5(time());

    $source_code = file_get_contents($file);

    //This covers old-asp tags, php short-tags, php echo tags, and normal php tags.
    $contents = preg_replace(array('/^<(\?|\%)\=?(php)?/', '/(\%|\?)>$/'), array('',''), $source_code);

    $html .= "<br> BLENC blowfish unencrypted key: $unencrypted_key" . PHP_EOL;
    $html .= "<br> BLENC file to encode: " . $file_name . PHP_EOL;

    //file_put_contents('blencode-log', "---\nFILE: $file_name\nSIZE: ".strlen($contents)."\nMD5: ".md5($contents)."\n", FILE_APPEND);

    $redistributable_key = blenc_encrypt($contents, TARGET_DIR . '/blenc/' . $file_name, $unencrypted_key);
    $html .= "<br> BLENC size of content: " . strlen($contents) . PHP_EOL;

    /**
    * Server key
    * key_file.blenc
    */
    file_put_contents(TARGET_DIR . '/blenc/' . 'key_file.blenc', $redistributable_key . PHP_EOL);
    $html .= "<br> BLENC redistributable key file key_file.blenc updated." . PHP_EOL;
    exec("cat key_file.blenc >> /usr/local/etc/blenckeys");
?>

https://github.com/codex-corp/ncryptd/blob/master/app/controllers/MagicalController.php#L479 https://github.com/codex-corp/ncryptd/blob/master/app/controllers/MagicalController.php#L479

you should put the key to 你应该把钥匙

blenckeys blenckeys

file on your server 服务器上的文件

Note: Sometimes you need to reload the apache, if you have "Validation of script" issues 注意:如果您遇到“脚本验证”问题,有时需要重新加载apache

How to use BLENC in PHP? 如何在PHP中使用BLENC?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM