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; }
/** * @param $file */ protected function fetchExcluded($file) { if (is_array(Session::get('excluded'))) { $excluded = Session::get('excluded'); $this->UdExcVarArray = MagicalHelpers::find_position($excluded, "{$file}", 'vars'); $this->UdExcFuncArray = MagicalHelpers::find_position($excluded, "{$file}", 'functions'); } }
function check() { $data['FolderID'] = Input::get('FolderID'); $data['FileID'] = Input::get('FileID'); $myfile = base_path() . "/tmp/" . $data['FolderID'] . "/" . $data['FileID']; $data['result'] = \MagicalHelpers::CheckSyntax($myfile); $body = View::make('admin.project.check')->with($data)->render(); return $body; }
public function ShowArrays() { $html = '<br> <br><hr color="#000000" height=1 noshade><h3>Replaced elements :</h3>'; $html .= MagicalHelpers::DisplayArray($this->ClassArray, "Found classes that will be replaced", $BgColor = "FFF0D0"); $html .= MagicalHelpers::DisplayArray($this->getFuncPack(), "Found functions that will be replaced", $BgColor = "FFF0D0"); if (Input::has('ReplaceRoutes')) { $html .= MagicalHelpers::DisplayArray($this->ClassArray, "Write New routes from replaced functions in classes", $BgColor = "FFF0D0"); } if (Input::has('ReplaceConstants')) { $html .= MagicalHelpers::DisplayArray($this->ConstArray, "Found constants that will be replaced", $BgColor = "8DCFF4"); } ksort($this->VarArray); $html .= MagicalHelpers::DisplayArray($this->getVarPack(), "Found variables that will be replaced", $BgColor = "89CA9D"); //$html .= MagicalHelpers::DisplayArray( $this->UdExcVarArray, "User Defined Exclude Variables", $BgColor="BFBFBF"); //$html .= MagicalHelpers::DisplayArray( $this->FileArray, "Scanned Files", $BgColor="FA8B68"); $html .= '<br><hr color="#000000" height=1 noshade>'; $html .= '<b>Download The Project</b> : <a class="button red" href="' . URL::to('/get/' . WORKS_SPACE_ID . '/project.zip') . '">Download !</a>'; $html .= '<h3>Number of userdefined elements to be replaced :</h3>' . 'Classes: ' . sizeof($this->ClassArray) . '<br>' . 'Functions: ' . sizeof($this->getFuncPack()) . '<br>' . 'Variables: ' . sizeof($this->getVarPack()) . '<br>' . 'Constants: ' . sizeof($this->ConstArray) . '<br>'; //'<br>Scanned Files: '.sizeof( $this->FileArray ).'<br>'. $this->resetAllPack(); $this->resetExcluded(); return $html; }