<?php // -*- c++ -*-
/**
* ionCube Loader install Wizard
*
* ionCube is a registered trademark of ionCube Ltd.
*
* Copyright (c) ionCube Ltd. 2002-2011
*/
require ("install_var.php");
require ("install_lang.php");
define ('ERROR_UNKNOWN_OS',1);
define ('ERROR_UNSUPPORTED_OS',2);
define ('ERROR_UNKNOWN_ARCH',3);
define ('ERROR_UNSUPPORTED_ARCH',4);
define ('ERROR_UNSUPPORTED_ARCH_OS',5);
define ('ERROR_WINDOWS_64_BIT',6);
define ('ERROR_PHP_UNSUPPORTED',7);
define ('ERROR_PHP_DEBUG_BUILD',8);
define ('ERROR_RUNTIME_EXT_DIR_NOT_FOUND',101);
define ('ERROR_RUNTIME_LOADER_FILE_NOT_FOUND',102);
define ('ERROR_INI_NOT_FIRST_ZE',201);
define ('ERROR_INI_WRONG_ZE_START',202);
define ('ERROR_INI_ZE_LINE_NOT_FOUND',203);
define ('ERROR_INI_LOADER_FILE_NOT_FOUND',204);
define ('ERROR_INI_NOT_FULL_PATH',205);
define ('ERROR_INI_NO_PATH',206);
define ('ERROR_INI_NOT_FOUND',207);
define ('ERROR_INI_NOT_READABLE',208);
define ('ERROR_INI_MULTIPLE_IC_LOADER_LINES',209);
define ('ERROR_INI_USER_INI_NOT_FOUND',210);
define ('ERROR_INI_USER_CANNOT_CREATE',211);
define ('ERROR_LOADER_UNEXPECTED_NAME',301);
define ('ERROR_LOADER_NOT_READABLE',302);
define ('ERROR_LOADER_PHP_MISMATCH',303);
define ('ERROR_LOADER_NONTS_PHP_TS',304);
define ('ERROR_LOADER_TS_PHP_NONTS',305);
define ('ERROR_LOADER_WRONG_OS',306);
define ('ERROR_LOADER_WRONG_ARCH',307);
define ('ERROR_LOADER_WIN_SERVER_NONWIN',321);
define ('ERROR_LOADER_WIN_NONTS_PHP_TS',322);
define ('ERROR_LOADER_WIN_TS_PHP_NONTS',323);
define ('ERROR_LOADER_WIN_PHP_MISMATCH',324);
define ('ERROR_LOADER_WIN_COMPILER_MISMATCH',325);
define ('ERROR_LOADER_NOT_FOUND',380);
define ('ERROR_LOADER_PHP_VERSION_UNKNOWN',390);
define ('SERVER_UNKNOWN',0);
define ('HAS_PHP_INI',1);
define ('SERVER_SHARED',2);
define ('SERVER_VPS',5);
define ('SERVER_DEDICATED',7);
define ('SERVER_LOCAL',9);
define ('LOADERS_PAGE',
'http://loaders.ioncube.com/');
define ('SUPPORT_SITE',
'http://www.orivon.com/contact/');
define ('LOADER_FORUM_URL',
'http://forum.ioncube.com/viewforum.php?f=4');
define ('LOADERS_FAQ_URL',
'http://www.ioncube.com/faqs/loaders.php');
define ('UNIX_ERRORS_URL',
'http://www.ioncube.com/loaders/unix_startup_errors.php');
define ('LOADER_WIZARD_URL',
LOADERS_PAGE);
define ('ENCODER_URL',
'http://www.ioncube.com/sa_encoder.php');
define ('LOADER_VERSION_URL',
'http://www.ioncube.com/feeds/product_info/versions.php');
define ('WIZARD_LATEST_VERSION_URL',
LOADER_VERSION_URL . '?item=loader-wizard');
define ('PHP_COMPILERS_URL',
LOADER_VERSION_URL . '?item=php-compilers');
define ('LOADER_PLATFORM_URL',
LOADER_VERSION_URL . '?item=loader-platforms');
define ('LOADER_LATEST_VERSIONS_URL',
LOADER_VERSION_URL . '?item=loader-versions');
define ('IONCUBE_DOWNLOADS_SERVER',
'http://downloads2.ioncube.com/loader_downloads');
define ('IONCUBE_CONNECT_TIMEOUT',4);
define ('DEFAULT_SELF','/ioncube/loader-wizard.php');
define ('LOADER_NAME_CHECK',true);
define ('LOADER_EXTENSION_NAME','ionCube Loader');
define ('LOADER_SUBDIR','ioncube');
define ('WINDOWS_IIS_LOADER_DIR', 'system32');
define ('ADDITIONAL_INI_FILE_NAME','20ioncube.ini');
define ('UNIX_SYSTEM_LOADER_DIR','/usr/local/ioncube');
define ('RECENT_LOADER_VERSION','3.1.24');
define ('LATEST_LOADER_MAJOR_VERSION',4);
define ('LOADERS_PACKAGE_PREFIX','ioncube_loaders_');
define ('SESSION_LIFETIME_MINUTES',360);
define ('WIZARD_EXPIRY_MINUTES',10080);
define ('MIN_INITIALISE_TIME',4);
run();
function script_version()
{
return "2.28";
}
function retrieve_latest_wizard_version()
{
$v = false;
$s = trim(remote_file_contents(WIZARD_LATEST_VERSION_URL));
if (preg_match('/^\d+([.]\d+)*$/', $s)) {
$v = $s;
}
return $v;
}
function latest_wizard_version()
{
if (!isset($_SESSION['latest_wizard_version'])) {
$_SESSION['latest_wizard_version'] = retrieve_latest_wizard_version();
}
return $_SESSION['latest_wizard_version'];
}
function update_is_available($lv)
{
if (is_numeric($lv)) {
$lv_parts = explode('.',$lv);
$script_parts = explode('.',script_version());
return ($lv_parts[0] > $script_parts[0] || ($lv_parts[0] == $script_parts[0] && $lv_parts[1] > $script_parts[1]));
} else {
return null;
}
}
function check_for_wizard_update($echo_message = false)
{
$latest_version = latest_wizard_version();
$update_available = update_is_available($latest_version);
if ($update_available) {
if ($echo_message) {
echo '<p class="alert">An updated version of this Wizard script is available <a href="' . LOADER_WIZARD_URL . '">here</a>.</p>';
}
return $latest_version;
} else {
return $update_available;
}
}
function remote_file_contents($url)
{
$remote_file_opening = ini_get('allow_url_fopen');
$contents = false;
if (isset($_SESSION['timing_out']) && $_SESSION['timing_out']) {
return false;
}
@session_write_close();
$timing_out = 0;
if ($remote_file_opening) {
$fh = @fopen($url,'rb');
if ($fh) {
stream_set_blocking($fh,0);
stream_set_timeout($fh,IONCUBE_CONNECT_TIMEOUT);
while (!feof($fh)) {
$result = fgets($fh, 4096);
$info = stream_get_meta_data($fh);
$timing_out = $info['timed_out']?1:0;
if ($timing_out) {
break;
}
if ($result !== false) {
$contents .= $result;
} else {
break;
}
}
fclose($fh);
} else {
$timing_out = 1;
}
} elseif (extension_loaded('curl')) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,IONCUBE_CONNECT_TIMEOUT);
$output = curl_exec($ch);
$info = curl_getinfo($ch);
$timing_out = ($info['http_code'] >= 400)?1:0;
curl_close($ch);
if (is_string($output)) {
$contents = $output;
}
} else {
$timing_out = 1;
}
@session_start();
$_SESSION['timing_out'] = $timing_out;
return $contents;
}
function php_version()
{
$v = explode('.',PHP_VERSION);
return array(
'major' => $v[0],
'minor' => $v[1],
'release' => $v[2]);
}
function is_supported_php_version()
{
$v = php_version();
return ((($v['major'] == 4) && ($v['minor'] >= 1)) ||
(($v['major'] == 5) && (($v['minor'] >= 1) || ($v['release'] >= 3))));
}
function is_php_version_or_greater($major,$minor,$release = 0)
{
$version = php_version();
return ($version['major'] > $major ||
($version['major'] == $major && $version['minor'] > $minor) ||
($version['major'] == $major && $version['minor'] == $minor && $version['release'] >= $release));
}
function ini_file_name()
{
$sysinfo = get_sysinfo();
return (!empty($sysinfo['PHP_INI'])?$sysinfo['PHP_INI_BASENAME']:'php.ini');
}
function get_remote_session_value($session_var,$remote_url,$default_function)
{
if (!isset($_SESSION[$session_var])) {
$serialised_res = remote_file_contents($remote_url);
$unserialised_res = @unserialize($serialised_res);
if (empty($unserialised_res)) {
$unserialised_res = call_user_func($default_function);
}
if (false === $unserialised_res) {