index.php 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /* Hi,
  3. Thanks for downloading net2ftp!
  4. This page shows how to integrate net2ftp in a generic PHP page.
  5. It is quite easy:
  6. 1. Define the constants NET2FTP_APPLICATION_ROOTDIR and NET2FTP_APPLICATION_ROOTDIR_URL
  7. 2. Include the file main.inc.php
  8. 3. Execute 5 net2ftp() calls to send the HTTP headers, print the Javascript
  9. code, print the HTML body, etc...
  10. 4. Check if an error occured to print out an error message.
  11. Look in /integration for more elaborate examples.
  12. Enjoy,
  13. David
  14. */
  15. error_reporting(E_ALL);
  16. if(file_exists("includes/helpers.php")){
  17. require_once("includes/helpers.php");
  18. }else{
  19. if(file_exists(__DIR__ . "/../../includes/helpers.php")){
  20. require_once(__DIR__ . "/../../includes/helpers.php");
  21. }
  22. }
  23. if(function_exists("startSession")){
  24. startSession();
  25. }else{
  26. session_name("opengamepanel_web");
  27. session_start();
  28. }
  29. $settings = $_SESSION['settings'];
  30. // ------------------------------------------------------------------------
  31. // 1. Define the constants NET2FTP_APPLICATION_ROOTDIR and NET2FTP_APPLICATION_ROOTDIR_URL
  32. // ------------------------------------------------------------------------
  33. $server_protocol = "http://";
  34. // This is wrong
  35. // if (isset($_SERVER["SERVER_PROTOCOL"]) == true && stripos($_SERVER["SERVER_PROTOCOL"], "https") !== false) { $server_protocol = "https://"; }
  36. // Check HTTPS like this:
  37. if (isset($_SERVER["HTTPS"]) && !empty($_SERVER["HTTPS"])) { $server_protocol = "https://"; }
  38. $http_host = "";
  39. if (isset($_SERVER["HTTP_HOST"]) == true) { $http_host = $_SERVER["HTTP_HOST"]; }
  40. $script_name = "/index.php";
  41. if (isset($_SERVER["SCRIPT_NAME"]) == true) { $script_name = dirname($_SERVER["SCRIPT_NAME"]); }
  42. elseif (isset($_SERVER["PHP_SELF"]) == true) { $script_name = dirname($_SERVER["PHP_SELF"]); }
  43. define("NET2FTP_APPLICATION_ROOTDIR", dirname(__FILE__));
  44. define("NET2FTP_APPLICATION_ROOTDIR_URL", $server_protocol . $http_host . $script_name);
  45. // ------------------------------------------------------------------------
  46. // 2. Include the file /path/to/net2ftp/includes/main.inc.php
  47. // ------------------------------------------------------------------------
  48. require_once("./includes/main.inc.php");
  49. // ------------------------------------------------------------------------
  50. // 3. Execute net2ftp($action). Note that net2ftp("sendHttpHeaders") MUST
  51. // be called once before the other net2ftp() calls!
  52. // ------------------------------------------------------------------------
  53. net2ftp("sendHttpHeaders");
  54. if ($net2ftp_result["success"] == false) {
  55. require_once("./skins/blue/error_wrapped.template.php");
  56. exit();
  57. }
  58. ?>
  59. <!DOCTYPE html PUBLIC "XHTML 1.0 Transitional" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  60. <html xml:lang="<?php echo __("en"); ?>" dir="<?php echo __("ltr"); ?>">
  61. <head>
  62. <meta http-equiv="Content-type" content="text/html;charset=<?php echo __("iso-8859-1"); ?>" />
  63. <?php net2ftp("printJavascript"); ?>
  64. <?php net2ftp("printCss"); ?>
  65. </head>
  66. <body onload="<?php net2ftp("printBodyOnload"); ?>">
  67. <?php net2ftp("printBody"); ?>
  68. <?php
  69. // ------------------------------------------------------------------------
  70. // 4. Check the result and print out an error message. This can be done using
  71. // a template, or by accessing the $net2ftp_result variable directly.
  72. // ------------------------------------------------------------------------
  73. if ($net2ftp_result["success"] == false) {
  74. require_once($net2ftp_globals["application_rootdir"] . "/skins/" . $net2ftp_globals["skin"] . "/error.template.php");
  75. }
  76. ?>
  77. </body>
  78. </html>