[ Index ]
 

Code source de FCKeditor 2.4

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/_samples/perl/ -> sample02.cgi (source)

   1  #!/usr/bin/env perl 
   2  
   3  #####
   4  #  FCKeditor - The text editor for Internet - http://www.fckeditor.net
   5  #  Copyright (C) 2003-2007 Frederico Caldeira Knabben
   6  #  
   7  #  == BEGIN LICENSE ==
   8  #  
   9  #  Licensed under the terms of any of the following licenses at your
  10  #  choice:
  11  #  
  12  #   - GNU General Public License Version 2 or later (the "GPL")
  13  #     http://www.gnu.org/licenses/gpl.html
  14  #  
  15  #   - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
  16  #     http://www.gnu.org/licenses/lgpl.html
  17  #  
  18  #   - Mozilla Public License Version 1.1 or later (the "MPL")
  19  #     http://www.mozilla.org/MPL/MPL-1.1.html
  20  #  
  21  #  == END LICENSE ==
  22  #  
  23  #  File Name: sample02.cgi
  24  #      Sample page.
  25  #  
  26  #  File Authors:
  27  #          Takashi Yamaguchi (jack@omakase.net)
  28  #####
  29  
  30  ## START: Hack for Windows (Not important to understand the editor code... Perl specific).
  31  if(Windows_check()) {
  32      chdir(GetScriptPath($0));
  33  }
  34  
  35  sub Windows_check
  36  {
  37      # IIS,PWS(NT/95)
  38      $www_server_os = $^O;
  39      # Win98 & NT(SP4)
  40      if($www_server_os eq "") { $www_server_os= $ENV{'OS'}; }
  41      # AnHTTPd/Omni/IIS
  42      if($ENV{'SERVER_SOFTWARE'} =~ /AnWeb|Omni|IIS\//i) { $www_server_os= 'win'; }
  43      # Win Apache
  44      if($ENV{'WINDIR'} ne "") { $www_server_os= 'win'; }
  45      if($www_server_os=~ /win/i) { return(1); }
  46      return(0);
  47  }
  48  
  49  sub GetScriptPath {
  50      local($path) = @_;
  51      if($path =~ /[\:\/\\]/) { $path =~ s/(.*?)[\/\\][^\/\\]+$/$1/; } else { $path = '.'; }
  52      $path;
  53  }
  54  ## END: Hack for IIS
  55  
  56  require  '../../fckeditor.pl';
  57  
  58  # When $ENV{'PATH_INFO'} cannot be used by perl.
  59  # $DefRootPath = "/XXXXX/_samples/perl/sample02.cgi"; Please write in script.
  60  
  61  my $DefServerPath = "";
  62  my $ServerPath;
  63  
  64      $ServerPath = &GetServerPath();
  65  
  66      if($ENV{'REQUEST_METHOD'} eq "POST") {
  67          read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
  68      } else {
  69          $buffer = $ENV{'QUERY_STRING'};
  70      }
  71      @pairs = split(/&/,$buffer);
  72      foreach $pair (@pairs) {
  73          ($name,$value) = split(/=/,$pair);
  74          $value =~ tr/+/ /;
  75          $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  76          $value =~ s/\t//g;
  77          $value =~ s/\r\n/\n/g;
  78          $FORM{$name} .= "\0"            if(defined($FORM{$name}));
  79          $FORM{$name} .= $value;
  80      }
  81  
  82      print "Content-type: text/html\n\n";
  83      print <<"_HTML_TAG_";
  84  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  85  <html>
  86      <head>
  87          <title>FCKeditor - Sample</title>
  88          <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  89          <meta name="robots" content="noindex, nofollow">
  90          <link href="../sample.css" rel="stylesheet" type="text/css" />
  91          <script type="text/javascript">
  92  
  93  function FCKeditor_OnComplete( editorInstance )
  94  {
  95      var oCombo = document.getElementById( 'cmbLanguages' ) ;
  96      for ( code in editorInstance.Language.AvailableLanguages )
  97      {
  98          AddComboOption( oCombo, editorInstance.Language.AvailableLanguages[code] + ' (' + code + ')', code ) ;
  99      }
 100      oCombo.value = editorInstance.Language.ActiveLanguage.Code ;
 101  }    
 102  
 103  function AddComboOption(combo, optionText, optionValue)
 104  {
 105      var oOption = document.createElement("OPTION") ;
 106  
 107      combo.options.add(oOption) ;
 108  
 109      oOption.innerHTML = optionText ;
 110      oOption.value      = optionValue ;
 111      
 112      return oOption ;
 113  }
 114  
 115  function ChangeLanguage( languageCode )
 116  {
 117      window.location.href = window.location.pathname + "?Lang=" + languageCode ;
 118  }
 119          </script>
 120      </head>
 121      <body>
 122          <h1>FCKeditor - Perl - Sample 2</h1>
 123          This sample shows the editor in all its available languages.
 124          <hr>
 125          <table cellpadding="0" cellspacing="0" border="0">
 126              <tr>
 127                  <td>
 128                      Select a language:&nbsp;
 129                  </td>
 130                  <td>
 131                      <select id="cmbLanguages" onchange="ChangeLanguage(this.value);">
 132                      </select>
 133                  </td>
 134              </tr>
 135          </table>
 136          <br>
 137          <form action="sampleposteddata.cgi" method="post" target="_blank">
 138  _HTML_TAG_
 139  
 140      #// Automatically calculates the editor base path based on the _samples directory.
 141      #// This is usefull only for these samples. A real application should use something like this:
 142      #// $oFCKeditor->BasePath = '/fckeditor/' ;    // '/fckeditor/' is the default value.
 143      $sBasePath = $ServerPath;
 144      $sBasePath = substr( $sBasePath, 0, index($sBasePath,"_samples"));
 145  
 146      &FCKeditor('FCKeditor1');
 147      $BasePath = $sBasePath;
 148  
 149      if($FORM{'Lang'} ne "") {
 150          $Config{'AutoDetectLanguage'}    = "false";
 151          $Config{'DefaultLanguage'}        = $FORM{'Lang'};
 152      } else {
 153          $Config{'AutoDetectLanguage'}    = "true";
 154          $Config{'DefaultLanguage'}        = 'en' ;
 155      }
 156      $Value = 'This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.' ;
 157      &Create();
 158  
 159      print <<"_HTML_TAG_";
 160              <br>
 161              <input type="submit" value="Submit">
 162          </form>
 163      </body>
 164  </html>
 165  _HTML_TAG_
 166  
 167  ################
 168  #Please use this function, rewriting it depending on a server's environment.
 169  ################
 170  sub GetServerPath
 171  {
 172  my $dir;
 173  
 174      if($DefServerPath) {
 175          $dir = $DefServerPath;
 176      } else {
 177          if($ENV{'PATH_INFO'}) {
 178              $dir  = $ENV{'PATH_INFO'};
 179          } elsif($ENV{'FILEPATH_INFO'}) {
 180              $dir  = $ENV{'FILEPATH_INFO'};
 181          }
 182      }
 183      return($dir);
 184  }


Généré le : Sun Feb 25 15:28:05 2007 par Balluche grâce à PHPXref 0.7