/EQT_V2/EQT/EQTWebApp/fckeditor/_samples/perl/sample01.cgi

http://sgsoft-las.googlecode.com/ · Perl · 117 lines · 67 code · 13 blank · 37 comment · 10 complexity · bc09f57cef42533bed9b17f7abe9b7e1 MD5 · raw file

  1. #!/usr/bin/env perl
  2. #####
  3. # FCKeditor - The text editor for Internet - http://www.fckeditor.net
  4. # Copyright (C) 2003-2009 Frederico Caldeira Knabben
  5. #
  6. # == BEGIN LICENSE ==
  7. #
  8. # Licensed under the terms of any of the following licenses at your
  9. # choice:
  10. #
  11. # - GNU General Public License Version 2 or later (the "GPL")
  12. # http://www.gnu.org/licenses/gpl.html
  13. #
  14. # - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  15. # http://www.gnu.org/licenses/lgpl.html
  16. #
  17. # - Mozilla Public License Version 1.1 or later (the "MPL")
  18. # http://www.mozilla.org/MPL/MPL-1.1.html
  19. #
  20. # == END LICENSE ==
  21. #
  22. # Sample page.
  23. #####
  24. ## START: Hack for Windows (Not important to understand the editor code... Perl specific).
  25. if(Windows_check()) {
  26. chdir(GetScriptPath($0));
  27. }
  28. sub Windows_check
  29. {
  30. # IIS,PWS(NT/95)
  31. $www_server_os = $^O;
  32. # Win98 & NT(SP4)
  33. if($www_server_os eq "") { $www_server_os= $ENV{'OS'}; }
  34. # AnHTTPd/Omni/IIS
  35. if($ENV{'SERVER_SOFTWARE'} =~ /AnWeb|Omni|IIS\//i) { $www_server_os= 'win'; }
  36. # Win Apache
  37. if($ENV{'WINDIR'} ne "") { $www_server_os= 'win'; }
  38. if($www_server_os=~ /win/i) { return(1); }
  39. return(0);
  40. }
  41. sub GetScriptPath {
  42. local($path) = @_;
  43. if($path =~ /[\:\/\\]/) { $path =~ s/(.*?)[\/\\][^\/\\]+$/$1/; } else { $path = '.'; }
  44. $path;
  45. }
  46. ## END: Hack for IIS
  47. require '../../fckeditor.pl';
  48. # When $ENV{'PATH_INFO'} cannot be used by perl.
  49. # $DefRootPath = "/XXXXX/_samples/perl/sample01.cgi"; Please write in script.
  50. my $DefServerPath = "";
  51. my $ServerPath;
  52. $ServerPath = &GetServerPath();
  53. print "Content-type: text/html\n\n";
  54. print <<"_HTML_TAG_";
  55. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  56. <html>
  57. <head>
  58. <title>FCKeditor - Sample</title>
  59. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  60. <meta name="robots" content="noindex, nofollow">
  61. <link href="../sample.css" rel="stylesheet" type="text/css" />
  62. </head>
  63. <body>
  64. <h1>FCKeditor - Perl - Sample 1</h1>
  65. This sample displays a normal HTML form with an FCKeditor with full features
  66. enabled.
  67. <hr>
  68. <form action="sampleposteddata.cgi" method="post" target="_blank">
  69. _HTML_TAG_
  70. #// Automatically calculates the editor base path based on the _samples directory.
  71. #// This is usefull only for these samples. A real application should use something like this:
  72. #// $oFCKeditor->BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value.
  73. $sBasePath = $ServerPath;
  74. $sBasePath = substr($sBasePath,0,index($sBasePath,"_samples"));
  75. &FCKeditor('FCKeditor1');
  76. $BasePath = $sBasePath;
  77. $Value = '<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>';
  78. &Create();
  79. print <<"_HTML_TAG_";
  80. <br>
  81. <input type="submit" value="Submit">
  82. </form>
  83. </body>
  84. </html>
  85. _HTML_TAG_
  86. ################
  87. #Please use this function, rewriting it depending on a server's environment.
  88. ################
  89. sub GetServerPath
  90. {
  91. my $dir;
  92. if($DefServerPath) {
  93. $dir = $DefServerPath;
  94. } else {
  95. if($ENV{'PATH_INFO'}) {
  96. $dir = $ENV{'PATH_INFO'};
  97. } elsif($ENV{'FILEPATH_INFO'}) {
  98. $dir = $ENV{'FILEPATH_INFO'};
  99. } elsif($ENV{'REQUEST_URI'}) {
  100. $dir = $ENV{'REQUEST_URI'};
  101. }
  102. }
  103. return($dir);
  104. }