PageRenderTime 45ms CodeModel.GetById 12ms RepoModel.GetById 0ms app.codeStats 0ms

/install/ioncube-loader-helper.php

https://bitbucket.org/tduarte/atmailopen
PHP | 921 lines | 817 code | 83 blank | 21 comment | 47 complexity | ed771ae2c0eea382ebb8968c0577b191 MD5 | raw file
  1. <?php
  2. //globals used by rtl tester
  3. $working = "";
  4. $status = "";
  5. $instructions = "";
  6. $already_loaded = extension_loaded('ionCube Loader');
  7. if (!isset($HTTP_SERVER_VARS))
  8. $HTTP_SERVER_VARS = &$_SERVER;
  9. if (!isset($HTTP_GET_VARS))
  10. $HTTP_GET_VARS = &$_GET;
  11. //install assistant globals
  12. ini_set('error_reporting', E_ALL & ~E_NOTICE);
  13. ini_set('display_errors', 'On');
  14. ini_set('log_errors','Off');
  15. //
  16. // Determine PHP flavour
  17. //
  18. $php_version = phpversion();
  19. $php_flavour = substr($php_version,0,3);
  20. //
  21. // Get the full name and short name for the OS
  22. //
  23. $os_name = substr(php_uname(),0,strpos(php_uname(),' '));
  24. $os_code = strtolower(substr($os_name,0,3));
  25. $dll_sfix = (($os_code == 'win') ? '.dll' : '.so');
  26. //
  27. // Analyse the PHP build
  28. //
  29. ob_start();
  30. phpinfo(INFO_GENERAL);
  31. $php_info = ob_get_contents();
  32. ob_end_clean();
  33. $thread_safe = false;
  34. $debug_build = false;
  35. $php_ini_path = '';
  36. //
  37. // Text or HTML output?
  38. //
  39. $cli = (php_sapi_name() == 'cli');
  40. $nl = ($cli ? "\n" : '<br>');
  41. function check_safe_mode()
  42. {
  43. $sm = ini_get('safe_mode');
  44. return ($sm=='1');
  45. }
  46. function getCSS()
  47. {
  48. $css = "
  49. body, td
  50. {
  51. font-size:70%;
  52. font-family:verdana, helvetica, arial;
  53. line-height:200%;
  54. }
  55. div.main
  56. {
  57. width:80%;
  58. text-align:left;
  59. top:20px;
  60. position:relative;
  61. border:2px solid #F0F0F0;
  62. padding:20px;
  63. }
  64. code
  65. {
  66. font-family:courier, helvetica, arial;
  67. }
  68. table.ini_line
  69. {
  70. border:2px solid #c8e8c8;
  71. background-color:white;
  72. }
  73. table.ini_line tr td
  74. {
  75. background-color:#c8e8c8;
  76. }
  77. table.analysis
  78. {
  79. border:2px solid #e0e0ff;
  80. background-color:white;
  81. }
  82. table.analysis tr td
  83. {
  84. background-color: #e0e0ff;
  85. }
  86. ";
  87. return $css;
  88. }
  89. function displayLogo()
  90. {
  91. $img_encoded="R0lGODlhtAA9AMYAAN7e3ri4uBAQEMzMzKKiogAAALCwsOeope9SVvQaHPUsKfUiIvUnHPY8SeRYcsLCwuSenfNhYfMwP/ZASvU3RvUvO/ZLaOdbfI6Ojujo6Nl9eet/kuyQpuuHnOmHoOyNpemKpuGHjvHV1PDPzvDV0O/b1OScl+pnYPFFQ/BJSPRMSfVRTOBleOi9u+tmZe4JDO4TGu8aGvcQEOBHbgoKCkNDQygoKPB0ee8gJ/VEWORSeFlZWezIye9vde8dGeJRdunJyPJBVHJyckxMTGZmZu8gIvEXFNbW1iAgIO3IyvImJPQcIfQ/U+VGc35+fr6+vvFHWvBOYu9SadlYcfIoMu9kgeGcqu/V3vLQ3BgYGPn37ffo4Pjr5vfe3vjo5fFEWfFSSfBIRe9SY+BcbTMzM+NSdoaGhvFxc5mZmenV0O58duwODfE8S+ulpfBmZ/Q1RvA4RPVXbsc4Q/ZhjPFdkfFdjfRmlNRMYFJSUv///zo6Ov///////////////////yH5BAEUAH8ALAAAAAC0AD0AAAf+gH+Cg4SFhoeIiYqLjI2Oj5CRkpOUlZaXmJmam5ydnp+goaKjpKWmp6ipqqusra6vsLGymwC1ALOlAwS7BLieAQLBAgO+okQFyAVHxZsEyQXEuBm6GEREGAbLmMfJ2syYBs/RsQFDAs/PWQGX3MjerQcICQoKC/b3+PgKDA0OiuHJHsQCQAadwQJo2D17xwpCBAkTJlCYSLGixQoWLigCgKEjhgywntA4aNCAwm6wNGzg0MHDh5cwY8LkAALEhxDfDg0YiU6PGQMBqp0TaKmdMlgiRohYSqKpUxIioDotQYJq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3uTsmLodd+tgPs7i0DCUDdq2qWxLTtsfZ9e1dQkvUz054umutaowTC1y9tnawtZVylfc61v6uVbSNypdPHXtmIRuiw0WWKVxTetLfYtmuDdwoWxNS58xKWRJNZbFxl2ZWneS0t0BVkv3++dFELyLQNy00KBg9VkmXVtKOFvRAX8lXtG7605XAaWtBTepSm/rUqE61qlfN6la7+tWwjrWsZ03rWtv61rjOta53LYlAAAA7";
  92. header("Content-type: image/gif");
  93. header("Cache-control: public");
  94. echo base64_decode($img_encoded);
  95. }
  96. function weblink($url, $display, $new_window=false)
  97. {
  98. if (use_html()) {
  99. $extra = "";
  100. if ($new_window)
  101. $extra = 'target="_blank"';
  102. return "<a href=\"$url\" $extra>$display</a>";
  103. } else {
  104. return $url;
  105. }
  106. }
  107. //
  108. // Where are we?
  109. //
  110. $here = dirname(__FILE__);
  111. //rtl tester specific functions
  112. function echo_working($msg)
  113. {
  114. global $working;
  115. $working.=$msg;
  116. }
  117. function echo_status($msg)
  118. {
  119. global $status;
  120. $status.=$msg;
  121. }
  122. function echo_instructions($msg)
  123. {
  124. global $instructions;
  125. $instructions.=$msg;
  126. }
  127. //
  128. // Detect some system parameters
  129. //
  130. function ic_system_info()
  131. {
  132. $thread_safe = false;
  133. $debug_build = false;
  134. $cgi_cli = false;
  135. $php_ini_path = '';
  136. ob_start();
  137. phpinfo(INFO_GENERAL);
  138. $php_info = ob_get_contents();
  139. ob_end_clean();
  140. foreach (split("\n",$php_info) as $line) {
  141. if (eregi('command',$line)) {
  142. continue;
  143. }
  144. if (preg_match('/thread safety.*(enabled|yes)/Ui',$line)) {
  145. $thread_safe = true;
  146. }
  147. if (preg_match('/debug.*(enabled|yes)/Ui',$line)) {
  148. $debug_build = true;
  149. }
  150. if (eregi("configuration file.*(</B></td><TD ALIGN=\"left\">| => |v\">)([^ <]*)(.*</td.*)?",$line,$match)) {
  151. $php_ini_path = $match[2];
  152. //
  153. // If we can't access the php.ini file then we probably lost on the match
  154. //
  155. if (!@file_exists($php_ini_path)) {
  156. $php_ini_path = '';
  157. }
  158. }
  159. $cgi_cli = ((strpos(php_sapi_name(),'cgi') !== false) ||
  160. (strpos(php_sapi_name(),'cli') !== false));
  161. }
  162. return array('THREAD_SAFE' => $thread_safe,
  163. 'DEBUG_BUILD' => $debug_build,
  164. 'PHP_INI' => $php_ini_path,
  165. 'CGI_CLI' => $cgi_cli);
  166. }
  167. function rtl_tester()
  168. {
  169. global $cli;
  170. global $nl;
  171. global $working;
  172. global $instructions;
  173. global $status;
  174. global $already_loaded;
  175. $working = "";
  176. $status = "";
  177. $instructions = "";
  178. $ok = true;
  179. $already_installed = false;
  180. echo_working("\n");
  181. //
  182. // Is the loader already installed?
  183. //
  184. if ($already_loaded) {
  185. echo_status("An ionCube Loader is already installed and run-time loading is unnecessary.\n"
  186. . "Encoded files should load without problems.$nl");
  187. echo_instructions("If you have problems running encoded files, make sure that you select binary\n"
  188. . "mode if using FTP. If unpacking files with WinZIP you must also disable the\n"
  189. . "'TAR Smart CR/LF conversion' feature.$nl$nl");
  190. $already_installed = true;
  191. } else {
  192. //
  193. // Intro
  194. //
  195. echo_working("Testing whether your system supports run-time loading...$nl$nl");
  196. }
  197. //
  198. // Test some system info
  199. //
  200. $sys_info = ic_system_info();
  201. if (!$already_installed) {
  202. if ($sys_info['THREAD_SAFE'] && !$sys_info['CGI_CLI']) {
  203. echo_status("Your PHP install appears to have threading support and run-time Loading\n"
  204. ."is only possible on threaded web servers if using the CGI, FastCGI or\n"
  205. ."CLI interface.$nl");
  206. echo_instructions("To run encoded files please install the Loader in the php.ini file.");
  207. $ok = false;
  208. }
  209. if ($sys_info['DEBUG_BUILD']) {
  210. echo_status("Your PHP installation appears to be built with debugging support\n"
  211. . "enabled and this is incompatible with ionCube Loaders.$nl${nl}Debugging support in PHP produces slower execution, is\n"
  212. . "not recommended for production builds and was probably a mistake.$nl");
  213. echo_instructions("You should rebuild PHP without the --enable-debug option.$nl");
  214. $ok = false;
  215. }
  216. //
  217. // Check safe mode and for a valid extensions directory
  218. //
  219. if (check_safe_mode()) {
  220. echo_status("PHP safe mode is enabled and run time loading will not be possible.");
  221. echo_instructions( "To run encoded files please install the Loader in the php.ini file.\n"
  222. . "Alternatively contact your hosting provider or system administrator,\n"
  223. . "and ask them to disable safe mode for your account.");
  224. $ok = false;
  225. }
  226. /*
  227. elseif (!is_dir(realpath(ini_get('extension_dir')))) {
  228. echo "The setting of extension_dir in the php.ini file is not a directory
  229. or may not exist and run time loading will not be possible. You do not need
  230. write permissions on the extension_dir but for run-time loading to work
  231. a path from the extensions directory to wherever the Loader is installed
  232. must exist.$nl";
  233. $ok = false;
  234. }
  235. */
  236. // If ok to try and find a Loader
  237. if ($ok) {
  238. //
  239. // Look for a Loader
  240. //
  241. // Old style naming should be long gone now
  242. $test_old_name = false;
  243. $_u = php_uname();
  244. $_os = substr($_u,0,strpos($_u,' '));
  245. $_os_key = strtolower(substr($_u,0,3));
  246. $_php_version = phpversion();
  247. $_php_family = substr($_php_version,0,3);
  248. $_loader_sfix = (($_os_key == 'win') ? '.dll' : '.so');
  249. $_ln_old="ioncube_loader.$_loader_sfix";
  250. $_ln_old_loc="/ioncube/$_ln_old";
  251. $_ln_new="ioncube_loader_${_os_key}_${_php_family}${_loader_sfix}";
  252. $_ln_new_loc="/ioncube/$_ln_new";
  253. echo_working("${nl}Looking for Loader '$_ln_new'");
  254. if ($test_old_name) {
  255. echo_working(" or '$_ln_old'");
  256. }
  257. echo_working($nl.$nl);
  258. $_extdir = ini_get('extension_dir');
  259. if ($_extdir == './') {
  260. $_extdir = '.';
  261. }
  262. $_oid = $_id = realpath($_extdir);
  263. $_here = dirname(__FILE__);
  264. if ((@$_id[1]) == ':') {
  265. $_id = str_replace('\\','/',substr($_id,2));
  266. $_here = str_replace('\\','/',substr($_here,2));
  267. }
  268. $_rd=str_repeat('/..',substr_count($_id,'/')).$_here.'/';
  269. if ($_oid !== false) {
  270. echo_working("Extensions Dir: $_extdir ($_id)$nl");
  271. echo_working("Relative Path: $_rd$nl");
  272. } else {
  273. echo_working("Extensions Dir: $_extdir (NOT FOUND)$nl$nl");
  274. echo_status("The directory set for the extension_dir entry in the\n"
  275. . "php.ini file may not exist, and run time loading will not be possible.$nl");
  276. echo_instructions( "Please ask your hosting provider or system administrator to create the\n"
  277. . "directory$nl$nl"
  278. . "$_extdir$nl$nl"
  279. . "ensuring that it is accessible by the web server software. They do not\n"
  280. . "need to restart the server. Then rerun this script. As an alternative,\n"
  281. . "your host could install the Loader in the php.ini file.$nl");
  282. $ok = false;
  283. }
  284. if ($ok) {
  285. $_ln = '';
  286. $_i=strlen($_rd);
  287. while($_i--) {
  288. if($_rd[$_i]=='/') {
  289. if ($test_old_name) {
  290. // Try the old style Loader name
  291. $_lp=substr($_rd,0,$_i).$_ln_old_loc;
  292. $_fqlp=$_oid.$_lp;
  293. if(@file_exists($_fqlp)) {
  294. echo_working("Found Loader: $_fqlp$nl");
  295. $_ln=$_lp;
  296. break;
  297. }
  298. }
  299. // Try the new style Loader name
  300. $_lp=substr($_rd,0,$_i).$_ln_new_loc;
  301. $_fqlp=$_oid.$_lp;
  302. if(@file_exists($_fqlp)) {
  303. echo_working("Found Loader: $_fqlp$nl");
  304. $_ln=$_lp;
  305. break;
  306. }
  307. }
  308. }
  309. //
  310. // If Loader not found, try the fallback of in the extensions directory
  311. //
  312. if (!$_ln) {
  313. if ($test_old_name) {
  314. if (@file_exists($_id.$_ln_old_loc)) {
  315. $_ln = $_ln_old_loc;
  316. }
  317. }
  318. if (@file_exists($_id.$_ln_new_loc)) {
  319. $_ln = $_ln_new_loc;
  320. }
  321. if ($_ln) {
  322. echo_working("Found Loader $_ln in extensions directory.$nl");
  323. }
  324. }
  325. echo_working($nl);
  326. if ($_ln) {
  327. echo_working("Trying to install Loader - this may produce an error...$nl$nl");
  328. dl($_ln);
  329. if(extension_loaded('ionCube Loader')) {
  330. echo_status( "The Loader was successfully installed and encoded files should be able to\n"
  331. . "automatically install the Loader when needed.$nl");
  332. echo_instructions( "No changes to your php.ini file\n"
  333. . "are required to use encoded files on this system.${nl}");
  334. } else {
  335. echo_status("The Loader was not installed.$nl");
  336. }
  337. } else {
  338. echo_status( "Run-time loading should be possible on your system but no suitable Loader\n"
  339. . "was found.$nl$nl");
  340. echo_instructions( "The $_os Loader for PHP $_php_family releases is required.$nl"
  341. . "Loaders can be downloaded from " . weblink("http://www.ioncube.com/loaders.php","www.ioncube.com"));
  342. }
  343. }
  344. }
  345. }
  346. //$instructions should never be empty.
  347. //if it is, then put default:
  348. if (empty($instructions))
  349. {
  350. $instructions = "Run-time loading is not currently possible.$nl"
  351. . "If you require further assistance, please contact ionCube support providing${nl}a link to this script.";
  352. }
  353. if ($cli)
  354. {
  355. return "$working$status$instructions\n";
  356. }
  357. else
  358. {
  359. //echo "${nl}Please send the output of this script to $email if you have questions or require further assistance.$nl$nl";
  360. $body = "<center><h2>Run-Time Loading Installation Instructions</h2></center>"
  361. . "<h3>Testing Server</h3>"
  362. . "$working"
  363. . "<h3>Results</h3>"
  364. . "$status"
  365. . "<h3>Instructions</h3>"
  366. . $instructions;
  367. return $body;
  368. }
  369. }
  370. //END OF RTL-TESTER FUNCTIONS
  371. //BEGIN INSTALL ASSISTANT RELATED FUNCTIONS
  372. function query_self($text, $query)
  373. {
  374. global $HTTP_SERVER_VARS;
  375. if (use_html()) {
  376. return '<a target=_blank href="'.@$HTTP_SERVER_VARS['PHP_SELF']."?page=install-assistant&q=$query\">$text</a>";
  377. } else {
  378. return $text;
  379. }
  380. }
  381. function use_html()
  382. {
  383. return (php_sapi_name() != 'cli');
  384. }
  385. function para($text)
  386. {
  387. return ($text . (use_html() ? '<p>' : "\n\n"));
  388. }
  389. function code($text)
  390. {
  391. return (use_html() ? "<code>$text</code>" : $text);
  392. }
  393. function table($contents)
  394. {
  395. if (use_html()) {
  396. $res = '<table class="analysis" cellpadding=5 cellspacing=1 border=0>';
  397. foreach ($contents as $row) {
  398. $res .= "<tr>\n";
  399. foreach ($row as $cell) {
  400. $res .= "<td>$cell</td>\n";
  401. }
  402. $res .= "</tr>\n";
  403. }
  404. $res .= "</table>\n";
  405. } else {
  406. $colwidths = array();
  407. foreach ($contents as $row) {
  408. $cv = 0;
  409. foreach ($row as $cell) {
  410. $l = @$colwidths[$cv];
  411. $cl = strlen($cell);
  412. if ($cl > $l) {
  413. $colwidths[$cv] = $cl;
  414. }
  415. $cv++;
  416. }
  417. }
  418. $tw = 0;
  419. foreach ($colwidths as $cw) { $tw += ($cw + 2); }
  420. $tw2 = $tw + count($colwidths) - 1 + 2;
  421. $res = '+' . str_repeat('-',$tw2 - 2) . "+\n";
  422. foreach ($contents as $row) {
  423. $cv = 0;
  424. foreach ($row as $cell) {
  425. $res .= '| ' . str_pad($cell, $colwidths[$cv]) . ' ';
  426. $cv++;
  427. }
  428. $res .= "|\n";
  429. }
  430. $res .= '+' . str_repeat('-',$tw2 - 2) . "+\n";
  431. }
  432. return $res;
  433. }
  434. function ilia_header()
  435. {
  436. if (!use_html()) {
  437. return "\n"
  438. . "ionCube Loader Install Assistant\n"
  439. . "--------------------------------\n"
  440. . "\n"
  441. . "\n";
  442. }
  443. else
  444. {
  445. return "<center><h2>php.ini Installation Instructions</h2></center>"
  446. . "<h3>Analysis</h3>";;
  447. }
  448. }
  449. function heading($text)
  450. {
  451. if (use_html()) {
  452. return para("<font face=\"helvetica,verdana\"><b>$text</b></font>");
  453. } else {
  454. return para($text . "\n" . str_repeat('-', strlen($text)));
  455. }
  456. }
  457. function ilia_analysis()
  458. {
  459. global $php_version, $php_flavour, $os_name, $thread_safe, $php_ini_path, $required_loader,$os_code, $cli;
  460. $res = para('Analysis of your system configuration shows:')
  461. . table(array(array("PHP Version",$php_version),
  462. array("Operating System",$os_name),
  463. array("Threaded PHP",($thread_safe ? 'Yes' : 'No')),
  464. array("php.ini file", ($php_ini_path ? $php_ini_path : query_self("Check phpinfo() output for\n" .'location','phpinfo'))),
  465. array("Required Loader",$required_loader)
  466. ))
  467. . para('');
  468. if (!$cli)
  469. $res .= "<h3>Instructions</h3>";
  470. if ($php_ini_path)
  471. {
  472. $res .= para('To install the Loader in your '.code('php.ini')." file, edit or create the file\n\n"
  473. . code($php_ini_path) . "\n\n"
  474. . "and add the following line before any other ".code('zend_extension').' lines:');
  475. }
  476. else
  477. {
  478. $res .= para( 'To install the loader in your '.code('php.ini')." file, first check the location of the\n"
  479. . "php.ini file from phpinfo output. Then edit or create the file, and add the\n"
  480. . "following line before any other ".code('zend_extension').' lines:');
  481. }
  482. if ($os_code == 'win') {
  483. if (use_html()) {
  484. $path = '&lt;drive&gt;:\\&lt;path&gt;\\';
  485. } else {
  486. $path = '<drive>:\\<path>\\';
  487. }
  488. $ini = "zend_extension_ts = $path$required_loader";
  489. } else {
  490. if (use_html()) {
  491. $path = '/&lt;path&gt;/';
  492. } else {
  493. $path = '/<path>/';
  494. }
  495. if ($thread_safe) {
  496. $ini = "zend_extension_ts = $path$required_loader";
  497. } else {
  498. $ini = "zend_extension = $path$required_loader";
  499. }
  500. }
  501. if (use_html()) {
  502. $res .= "<table class=\"ini_line\" cellpadding=4 cellspacing=1 border=0><tr><td><code>$ini</code></td></tr></table><p>";
  503. } else {
  504. $res .= para(" $ini");
  505. }
  506. if ($os_code == 'win') {
  507. $res .= para('where '.code($path).' is where you\'ve installed the loader.');
  508. } else {
  509. $res .= para('where '.code($path).' is where you\'ve installed the loader, e.g. '.code('/usr/local/ioncube/'));
  510. }
  511. $res .= para("If there are no zend_extension lines already, you can put the
  512. line at any point in the file.");
  513. $res .= para("Finally, stop and restart your web server software for the changes to\n"
  514. . "take effect.");
  515. if (!check_safe_mode() && ($os_code != 'win')) {
  516. $res .= heading('Installing the Loader for run-time loading');
  517. $res .= para( "To install for runtime loading, create a directory called ".code('ioncube') . "\n"
  518. . "at or above the top level of your encoded files, and ensure that the directory\n"
  519. . "contains the ".code($required_loader) . " loader. If run-time install of\n"
  520. . "the Loader is possible on your system then encoded files should automatically\n"
  521. . "install the loader when needed.");
  522. }
  523. return $res;
  524. }
  525. function ilia_debug_builds_unsupported()
  526. {
  527. return para( "IMPORTANT NOTE: Your PHP installation may be incorrect\n"
  528. . "------------------------------------------------------\n"
  529. . "\n"
  530. . "Your PHP installation appears to be built with debugging\n"
  531. . "support enabled, and extensions cannot be installed in this case.")
  532. .para( "Debugging support in PHP produces slower execution, is not recommended for\n"
  533. . "production builds, and was probably a mistake.")
  534. .para( "Debugging support may sometimes be incorrectly detected, and so please\n"
  535. . "continue to follow the installation instructions and try the Loader.\n"
  536. . "However do contact the ionCube helpdesk if the Loader fails to\n"
  537. . "install, and include a web link to either this script or a page that\n"
  538. . "calls phpinfo() so that we can help.");
  539. }
  540. function install_assistant()
  541. {
  542. global $php_version, $php_flavour, $os_name, $thread_safe, $php_ini_path, $required_loader,$os_code, $php_info,$dll_sfix,$debug_build,$HTTP_GET_VARS;
  543. if ($q = @$HTTP_GET_VARS['q']) {
  544. if ($q == 'phpinfo') {
  545. phpinfo(INFO_GENERAL);
  546. }
  547. exit(0);
  548. }
  549. foreach (split("\n",$php_info) as $line) {
  550. if (eregi('command',$line)) {
  551. continue;
  552. }
  553. if (preg_match('/thread safety.*(enabled|yes)/Ui',$line)) {
  554. $thread_safe = true;
  555. }
  556. if (preg_match('/debug.*(enabled|yes)/Ui',$line)) {
  557. $debug_build = true;
  558. }
  559. if (eregi("configuration file.*(</B></td><TD ALIGN=\"left\">| => |v\">)([^ <]*)(.*</td.*)?",$line,$match)) {
  560. $php_ini_path = $match[2];
  561. //
  562. // If we can't access the php.ini file then we probably lost on the match
  563. //
  564. if (@!file_exists($php_ini_path)) {
  565. $php_ini_path = '';
  566. }
  567. }
  568. }
  569. //
  570. // We now know enough to give guidance
  571. //
  572. $ts = ((($os_code != 'win') && $thread_safe) ? '_ts' : '');
  573. $required_loader = "ioncube_loader_${os_code}_${php_flavour}${ts}${dll_sfix}";
  574. //
  575. // Create the output
  576. //
  577. $out = "";
  578. $out.=ilia_header();
  579. $out.=ilia_analysis();
  580. if ($debug_build) {
  581. $out.=ilia_debug_builds_unsupported();
  582. }
  583. return $out;
  584. }
  585. function getInstructions()
  586. {
  587. global $nl;
  588. global $cli;
  589. if ($cli)
  590. {
  591. return "\nAn ionCube Loader file is required by PHP to read files encoded with the\n"
  592. . "ionCube Encoder. This page will determine how you can install Loaders\n"
  593. . "on this particular server.$nl$nl";
  594. }
  595. else
  596. {
  597. 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";
  598. }
  599. }
  600. //main page
  601. function index()
  602. {
  603. global $HTTP_SERVER_VARS;
  604. global $nl;
  605. global $already_loaded;
  606. $self = @$HTTP_SERVER_VARS['PHP_SELF'];
  607. $host = @$HTTP_SERVER_VARS['HTTP_HOST'];
  608. ob_start();
  609. $success = include dirname(__FILE__).'/ioncube-encoded-file.php';
  610. $php_info = ob_get_contents();
  611. ob_end_clean();
  612. $body = "";
  613. $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";
  614. $dir = dirname($self);
  615. $rtl = "<a href=\"$self?page=rtl-tester\">run-time loading installation instructions</a>";
  616. $sys = "<a href=\"$self?page=sysinfo\">Server System Information</a>";
  617. $ass = "<a href=\"$self?page=install-assistant\">php.ini installation instructions</a>";
  618. if ($success)
  619. {
  620. $body.= "An ionCube encoded file has been loaded <b><font color=green>successfully</font></b>.<br>"
  621. . "Encoded files should now function correctly.<br><br>";
  622. if (!$already_loaded)
  623. {
  624. $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>";
  625. }
  626. $body.="If you have a problem with your PHP application, please contact the application provider.";
  627. }
  628. else
  629. {
  630. $body.= "The loading of ionCube encoded files is not currently working correctly on this server.<br><br>\n";
  631. $body.= "If you have permission to edit the php.ini configuration file for this server, please follow the "
  632. . "$ass.<br><br>";
  633. $body.= "If you do not access to the php.ini file, please follow the "
  634. . "$rtl.<br><br>";
  635. $body.=getInstructions();
  636. }
  637. return $body;
  638. }
  639. function read($fp) {
  640. $input = rtrim(fgets($fp, 1024));
  641. return $input;
  642. }
  643. function doMenu($fp)
  644. {
  645. echo("\n>> Please choose an option followed by Return, or 0 to exit this script.\n\n");
  646. echo("0. Exit this script\n");
  647. echo("1. php.ini installation instructions\n");
  648. echo("2. Run-time loading installation instructions\n");
  649. echo("\n");
  650. echo(">> ");
  651. do
  652. {
  653. $command = read($fp);
  654. }
  655. while(strlen($command)==0);
  656. return $command;
  657. }
  658. if ($cli)
  659. {
  660. $fp=fopen('php://stdin', 'r');
  661. echo(getInstructions());
  662. ob_start();
  663. $success = include dirname(__FILE__).'/ioncube-encoded-file.php';
  664. ob_end_clean();
  665. if ($success)
  666. {
  667. echo "An ionCube encoded file has been loaded successfully.\n"
  668. . "Encoded files should now function correctly.\n\n";
  669. if (!$already_loaded)
  670. {
  671. 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";
  672. }
  673. echo "If you have a problem with your PHP application, please contact the application provider.";
  674. }
  675. else
  676. {
  677. echo "The loading of ionCube encoded files is not currently working correctly\n"
  678. . "on this server.\n\n";
  679. echo "If you have permission to edit the php.ini configuration file for this server,\n"
  680. . "please choose option 1 below.\n\n";
  681. echo "If you do not access to the php.ini file, please choose option 2 below.\n\n";
  682. $body.=getInstructions();
  683. }
  684. while(true)
  685. {
  686. $command = doMenu($fp);
  687. if ($command==0)
  688. exit(0);
  689. elseif ($command==2)
  690. echo(rtl_tester());
  691. elseif ($command==10)
  692. phpinfo();
  693. elseif ($command==1)
  694. echo(install_assistant());
  695. }
  696. fclose($fp);
  697. }
  698. else
  699. {
  700. global $HTTP_SERVER_VARS,$HTTP_GET_VARS;
  701. $us = @$HTTP_SERVER_VARS['PHP_SELF'];
  702. $page = @$HTTP_GET_VARS['page'];
  703. $css = getCSS();
  704. $out = "<html>\n"
  705. . "<head>\n"
  706. . "<style>$css</style>\n"
  707. . "<title>ionCube Loader Installation Tool</title>"
  708. . "</head>\n"
  709. . "<body>\n"
  710. ;
  711. $body = "";
  712. $body.="<div align=center><div class=\"main\">\n";
  713. $body.="<img src=\"$us?page=logo\"><br><br>\n";
  714. if ($page=="rtl-tester")
  715. $body.= rtl_tester();
  716. else if($page=="sysinfo")
  717. return phpinfo();
  718. else if($page=="install-assistant")
  719. {
  720. $body.= install_assistant();
  721. }
  722. else if($page=="logo")
  723. {
  724. displayLogo();
  725. exit(1);
  726. }
  727. else
  728. $body.= index();
  729. $body.="</div></div>\n";
  730. $out.=$body;
  731. $out.= "</body></html>\n";
  732. echo($out);
  733. }
  734. ?>