function BLENCiT() { $files = MagicalHelpers::findit('*.{php}', GLOB_BRACE, TARGET_DIR . '/'); /** * BLENC blowfish unencrypted key * blenc.key * @link http://giuseppechiesa.it/_dropplets/php-blenc-quick-start-guide */ if (Input::has('unencrypted_key')) { $unencrypted_key = Input::get('unencrypted_key'); } else { $unencrypted_key = md5(time()); } //$key = md5(time()); $html = ""; foreach ($files as $file) { $file_name = basename($file); $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); if (!is_dir(TARGET_DIR . '/blenc')) { mkdir(TARGET_DIR . '/blenc', 0777); } $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"); } return $html; }
/** * function to find */ public static function findit($pattern = '*', $flags = 0, $path = '') { $paths = glob($path . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT); $files = glob($path . $pattern, $flags); foreach ($paths as $path) { $files = array_merge($files, MagicalHelpers::findit($pattern, $flags, $path)); } return $files; }