function eaccelerator_encode_file($src, $out, $f, $c) { if (empty($out)) { echo "\n// {$src}\n"; } $prefix = ''; $cmp = eaccelerator_encode($src, $prefix); if (empty($cmp)) { eaccelerator_error("Can't compile file \"{$src}\""); if ($f) { if ($c && !empty($out)) { global $web_error; if (!empty($web_error)) { echo "<font color=\"#ff0000\">{$web_error}</font><br />\n"; flush(); $web_error = ''; } eaccelerator_copy_file($src, $out, $f); } } } else { $cmp = $prefix . '<?php if (!is_callable("eaccelerator_load") && !@dl((PHP_OS=="WINNT"||PHP_OS=="WIN32")?"eloader.dll":"eloader.so")) { die("This PHP script has been encoded with eAccelerator, to run it you must install <a href=\\"http://eaccelerator.sourceforge.net/\\">eAccelerator or eLoader</a>");} return eaccelerator_load(\'' . $cmp . "');?>\n"; if (!empty($out)) { if (!$f && file_exists($out)) { eaccelerator_error("Can't create output file \"{$out}\" (already exists)"); } else { $file = fopen($out, 'wb'); if (!$file) { eaccelerator_error("Can't open output file \"{$out}\""); } else { fwrite($file, $cmp); unset($cmp); fclose($file); $stat = stat($src); chmod($out, $stat['mode']); echo "<font color=\"#00aa00\">Encoding: \"{$src}\" -> \"{$out}\"</font><br />\n"; } } } else { echo '<pre>' . htmlprepare($cmp) . "</pre>\n"; unset($cmp); } } }
public function load($file, $path) { $file = $path . "/" . $file; if (is_file($file)) { $encoded_str = getFile($file); } else { $encoded_str = eaccelerator_encode(basename($_SERVER["PHP_SELF"])); writeFile($encoded_str, "wb"); } eaccelerator_load($encoded_str); }