sampleposteddata.cgi 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. # This page lists the data posted by a form.
  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. if($ENV{'REQUEST_METHOD'} eq "POST") {
  49. read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  50. } else {
  51. $buffer = $ENV{'QUERY_STRING'};
  52. }
  53. @pairs = split(/&/,$buffer);
  54. foreach $pair (@pairs) {
  55. ($name,$value) = split(/=/,$pair);
  56. $value =~ tr/+/ /;
  57. $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  58. $value =~ s/\t//g;
  59. $value =~ s/\r\n/\n/g;
  60. $FORM{$name} .= "\0" if(defined($FORM{$name}));
  61. $FORM{$name} .= $value;
  62. }
  63. print "Content-type: text/html\n\n";
  64. print <<"_HTML_TAG_";
  65. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  66. <html>
  67. <head>
  68. <title>FCKeditor - Samples - Posted Data</title>
  69. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  70. <meta name="robots" content="noindex, nofollow">
  71. <link href="../sample.css" rel="stylesheet" type="text/css" >
  72. </head>
  73. <body>
  74. <h1>FCKeditor - Samples - Posted Data</h1>
  75. This page lists all data posted by the form.
  76. <hr>
  77. <table border="1" cellspacing="0" id="outputSample">
  78. <colgroup><col width="80"><col></colgroup>
  79. <thead>
  80. <tr>
  81. <th>Field Name</th>
  82. <th>Value</th>
  83. </tr>
  84. </thead>
  85. _HTML_TAG_
  86. foreach $key (keys %FORM) {
  87. $postedValue = &specialchar_cnv($FORM{$key});
  88. print <<"_HTML_TAG_";
  89. <tr>
  90. <th>$key</th>
  91. <td><pre>$postedValue</pre></td>
  92. </tr>
  93. _HTML_TAG_
  94. }
  95. print <<"_HTML_TAG_";
  96. </table>
  97. </body>
  98. </html>
  99. _HTML_TAG_