📄 ioncube-loader-helper.php
字号:
function query_self($text, $query)
{
global $HTTP_SERVER_VARS;
if (use_html()) {
return '<a target=_blank href="'.@$HTTP_SERVER_VARS['PHP_SELF']."?page=install-assistant&q=$query\">$text</a>";
} else {
return $text;
}
}
function use_html()
{
return (php_sapi_name() != 'cli');
}
function para($text)
{
return ($text . (use_html() ? '<p>' : "\n\n"));
}
function code($text)
{
return (use_html() ? "<code>$text</code>" : $text);
}
function table($contents)
{
if (use_html()) {
$res = '<table class="analysis" cellpadding=5 cellspacing=1 border=0>';
foreach ($contents as $row) {
$res .= "<tr>\n";
foreach ($row as $cell) {
$res .= "<td>$cell</td>\n";
}
$res .= "</tr>\n";
}
$res .= "</table>\n";
} else {
$colwidths = array();
foreach ($contents as $row) {
$cv = 0;
foreach ($row as $cell) {
$l = @$colwidths[$cv];
$cl = strlen($cell);
if ($cl > $l) {
$colwidths[$cv] = $cl;
}
$cv++;
}
}
$tw = 0;
foreach ($colwidths as $cw) { $tw += ($cw + 2); }
$tw2 = $tw + count($colwidths) - 1 + 2;
$res = '+' . str_repeat('-',$tw2 - 2) . "+\n";
foreach ($contents as $row) {
$cv = 0;
foreach ($row as $cell) {
$res .= '| ' . str_pad($cell, $colwidths[$cv]) . ' ';
$cv++;
}
$res .= "|\n";
}
$res .= '+' . str_repeat('-',$tw2 - 2) . "+\n";
}
return $res;
}
function ilia_header()
{
if (!use_html()) {
return "\n"
. "ionCube Loader Install Assistant\n"
. "--------------------------------\n"
. "\n"
. "\n";
}
else
{
return "<center><h2>php.ini Installation Instructions</h2></center>"
. "<h3>Analysis</h3>";;
}
}
function heading($text)
{
if (use_html()) {
return para("<font face=\"helvetica,verdana\"><b>$text</b></font>");
} else {
return para($text . "\n" . str_repeat('-', strlen($text)));
}
}
function ilia_analysis()
{
global $php_version, $php_flavour, $os_name, $thread_safe, $php_ini_path, $required_loader,$os_code, $cli;
$res = para('Analysis of your system configuration shows:')
. table(array(array("PHP Version",$php_version),
array("Operating System",$os_name),
array("Threaded PHP",($thread_safe ? 'Yes' : 'No')),
array("php.ini file", ($php_ini_path ? $php_ini_path : query_self("Check phpinfo() output for\n" .'location','phpinfo'))),
array("Required Loader",$required_loader)
))
. para('');
if (!$cli)
$res .= "<h3>Instructions</h3>";
if ($php_ini_path)
{
$res .= para('To install the Loader in your '.code('php.ini')." file, edit or create the file\n\n"
. code($php_ini_path) . "\n\n"
. "and add the following line before any other ".code('zend_extension').' lines:');
}
else
{
$res .= para( 'To install the loader in your '.code('php.ini')." file, first check the location of the\n"
. "php.ini file from phpinfo output. Then edit or create the file, and add the\n"
. "following line before any other ".code('zend_extension').' lines:');
}
if ($os_code == 'win') {
if (use_html()) {
$path = '<drive>:\\<path>\\';
} else {
$path = '<drive>:\\<path>\\';
}
$ini = "zend_extension_ts = $path$required_loader";
} else {
if (use_html()) {
$path = '/<path>/';
} else {
$path = '/<path>/';
}
if ($thread_safe) {
$ini = "zend_extension_ts = $path$required_loader";
} else {
$ini = "zend_extension = $path$required_loader";
}
}
if (use_html()) {
$res .= "<table class=\"ini_line\" cellpadding=4 cellspacing=1 border=0><tr><td><code>$ini</code></td></tr></table><p>";
} else {
$res .= para(" $ini");
}
if ($os_code == 'win') {
$res .= para('where '.code($path).' is where you\'ve installed the loader.');
} else {
$res .= para('where '.code($path).' is where you\'ve installed the loader, e.g. '.code('/usr/local/ioncube/'));
}
$res .= para("If there are no zend_extension lines already, you can put the
line at any point in the file.");
$res .= para("Finally, stop and restart your web server software for the changes to\n"
. "take effect.");
if (!check_safe_mode() && ($os_code != 'win')) {
$res .= heading('Installing the Loader for run-time loading');
$res .= para( "To install for runtime loading, create a directory called ".code('ioncube') . "\n"
. "at or above the top level of your encoded files, and ensure that the directory\n"
. "contains the ".code($required_loader) . " loader. If run-time install of\n"
. "the Loader is possible on your system then encoded files should automatically\n"
. "install the loader when needed.");
}
return $res;
}
function ilia_debug_builds_unsupported()
{
return para( "IMPORTANT NOTE: Your PHP installation may be incorrect\n"
. "------------------------------------------------------\n"
. "\n"
. "Your PHP installation appears to be built with debugging\n"
. "support enabled, and extensions cannot be installed in this case.")
.para( "Debugging support in PHP produces slower execution, is not recommended for\n"
. "production builds, and was probably a mistake.")
.para( "Debugging support may sometimes be incorrectly detected, and so please\n"
. "continue to follow the installation instructions and try the Loader.\n"
. "However do contact the ionCube helpdesk if the Loader fails to\n"
. "install, and include a web link to either this script or a page that\n"
. "calls phpinfo() so that we can help.");
}
function install_assistant()
{
global $php_version, $php_flavour, $os_name, $thread_safe, $php_ini_path, $required_loader,$os_code, $php_info,$dll_sfix,$HTTP_GET_VARS;
if ($q = @$HTTP_GET_VARS['q']) {
if ($q == 'phpinfo') {
phpinfo(INFO_GENERAL);
}
exit(0);
}
foreach (split("\n",$php_info) as $line) {
if (eregi('command',$line)) {
continue;
}
if (preg_match('/thread safety.*(enabled|yes)/Ui',$line)) {
$thread_safe = true;
}
if (preg_match('/debug.*(enabled|yes)/Ui',$line)) {
$debug_build = true;
}
if (eregi("configuration file.*(</B></td><TD ALIGN=\"left\">| => |v\">)([^ <]*)(.*</td.*)?",$line,$match)) {
$php_ini_path = $match[2];
//
// If we can't access the php.ini file then we probably lost on the match
//
if (@!file_exists($php_ini_path)) {
$php_ini_path = '';
}
}
}
//
// We now know enough to give guidance
//
$ts = ((($os_code != 'win') && $thread_safe) ? '_ts' : '');
$required_loader = "ioncube_loader_${os_code}_${php_flavour}${ts}${dll_sfix}";
//
// Create the output
//
$out = "";
$out.=ilia_header();
$out.=ilia_analysis();
if ($debug_build) {
$out.=ilia_debug_builds_unsupported();
}
return $out;
}
function getInstructions()
{
global $nl;
global $cli;
if ($cli)
{
return "\nAn ionCube Loader file is required by PHP to read files encoded with the\n"
. "ionCube Encoder. This page will determine how you can install Loaders\n"
. "on this particular server.$nl$nl";
}
else
{
return "Please read the ".weblink("http://www.ioncube.com/loader_installation.php", "online documentation", true).", or review the file readme.txt enclosed with the Loader bundle, for more help with Loader installation.$nl$nl";
}
}
//main page
function index()
{
global $HTTP_SERVER_VARS;
global $nl;
global $already_loaded;
$self = @$HTTP_SERVER_VARS['PHP_SELF'];
$host = @$HTTP_SERVER_VARS['HTTP_HOST'];
ob_start();
$success = include dirname(__FILE__).'/ioncube-encoded-file.php';
$php_info = ob_get_contents();
ob_end_clean();
$body = "";
$body.="An ionCube Loader file is required by PHP to read files encoded with the ionCube Encoder. This page will determine how you can install Loaders on this particular server.$nl$nl";
$dir = dirname($self);
$rtl = "<a href=\"$self?page=rtl-tester\">run-time loading installation instructions</a>";
$sys = "<a href=\"$self?page=sysinfo\">Server System Information</a>";
$ass = "<a href=\"$self?page=install-assistant\">php.ini installation instructions</a>";
if ($success)
{
$body.= "An ionCube encoded file has been loaded <b><font color=green>successfully</font></b>.<br>"
. "Encoded files should now function correctly.<br><br>";
if (!$already_loaded)
{
$body.="If you have permission to edit the php.ini configuration file for this server you can increase performance by following the $ass.<br><br>";
}
$body.="If you have a problem with your PHP application, please contact the application provider.";
}
else
{
$body.= "The loading of ionCube encoded files is not currently working correctly on this server.<br><br>\n";
$body.= "If you have permission to edit the php.ini configuration file for this server, please follow the "
. "$ass.<br><br>";
$body.= "If you do not access to the php.ini file, please follow the "
. "$rtl.<br><br>";
$body.=getInstructions();
}
return $body;
}
function read($fp) {
$input = rtrim(fgets($fp, 1024));
return $input;
}
function doMenu($fp)
{
echo("\n>> Please choose an option followed by Return, or 0 to exit this script.\n\n");
echo("0. Exit this script\n");
echo("1. php.ini installation instructions\n");
echo("2. Run-time loading installation instructions\n");
echo("\n");
echo(">> ");
do
{
$command = read($fp);
}
while(strlen($command)==0);
return $command;
}
if ($cli)
{
$fp=fopen('php://stdin', 'r');
echo(getInstructions());
$success = include dirname(__FILE__).'/ioncube-encoded-file.php';
if ($success)
{
echo "An ionCube encoded file has been loaded successfully.\n"
. "Encoded files should now function correctly.\n\n";
if (!$already_loaded)
{
echo "If you have permission to edit the php.ini configuration file for this server you can increase performance by choosing option 1 below.\n\n";
}
echo "If you have a problem with your PHP application, please contact the application provider.";
}
else
{
echo "The loading of ionCube encoded files is not currently working correctly\n"
. "on this server.\n\n";
echo "If you have permission to edit the php.ini configuration file for this server,\n"
. "please choose option 1 below.\n\n";
echo "If you do not access to the php.ini file, please choose option 2 below.\n\n";
$body.=getInstructions();
}
while(true)
{
$command = doMenu($fp);
if ($command==0)
exit(0);
elseif ($command==2)
echo(rtl_tester());
elseif ($command==10)
phpinfo();
elseif ($command==1)
echo(install_assistant());
}
fclose($fp);
}
else
{
global $HTTP_SERVER_VARS,$HTTP_GET_VARS;
$us = @$HTTP_SERVER_VARS['PHP_SELF'];
$page = @$HTTP_GET_VARS['page'];
$css = getCSS();
$out = "<html>\n"
. "<head>\n"
. "<style>$css</style>\n"
. "<title>ionCube Loader Installation Tool</title>"
. "</head>\n"
. "<body>\n"
;
$body = "";
$body.="<div align=center><div class=\"main\">\n";
$body.="<img src=\"$us?page=logo\"><br><br>\n";
if ($page=="rtl-tester")
$body.= rtl_tester();
else if($page=="sysinfo")
return phpinfo();
else if($page=="install-assistant")
{
$body.= install_assistant();
}
else if($page=="logo")
{
displayLogo();
exit(1);
}
else
$body.= index();
$body.="</div></div>\n";
$out.=$body;
$out.= "</body></html>\n";
echo($out);
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -