[ Index ]
 

Code source de FCKeditor 2.4

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

title

Body

[fermer]

/_samples/perl/ -> sample03.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: sample03.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/sample03.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( 'cmbToolbars' ) ;
  96      oCombo.value = editorInstance.ToolbarSet.Name ;
  97      oCombo.style.visibility = '' ;
  98  }
  99  
 100  function ChangeToolbar( toolbarName )
 101  {
 102      window.location.href = window.location.pathname + "?Toolbar=" + toolbarName ;
 103  }
 104  
 105          </script>
 106      </head>
 107      <body>
 108          <h1>FCKeditor - Perl - Sample 3</h1>
 109          This sample shows how to change the editor toolbar.
 110          <hr>
 111          <table cellpadding="0" cellspacing="0" border="0">
 112              <tr>
 113                  <td>
 114                      Select the toolbar to load:&nbsp;
 115                  </td>
 116                  <td>
 117                      <select id="cmbToolbars" onchange="ChangeToolbar(this.value);" style="VISIBILITY: hidden">
 118                          <option value="Default" selected>Default</option>
 119                          <option value="Basic">Basic</option>
 120                      </select>
 121                  </td>
 122              </tr>
 123          </table>
 124          <br>
 125          <form action="sampleposteddata.cgi" method="post" target="_blank">
 126  _HTML_TAG_
 127  
 128      #// Automatically calculates the editor base path based on the _samples directory.
 129      #// This is usefull only for these samples. A real application should use something like this:
 130      #// $oFCKeditor->BasePath = '/fckeditor/' ;    // '/fckeditor/' is the default value.
 131  
 132      $sBasePath = $ServerPath;
 133      $sBasePath = substr($sBasePath, 0, index( $sBasePath, "_samples" ));
 134  
 135      &FCKeditor('FCKeditor1') ;
 136      $BasePath = $sBasePath ;
 137  
 138      if($FORM{'Toolbar'} ne "") {
 139          $ToolbarSet = &specialchar_cnv( $FORM{'Toolbar'} );
 140      }
 141      $Value = 'This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.' ;
 142      &Create();
 143  
 144      print <<"_HTML_TAG_";
 145              <br>
 146              <input type="submit" value="Submit">
 147          </form>
 148      </body>
 149  </html>
 150  _HTML_TAG_
 151  
 152  ################
 153  #Please use this function, rewriting it depending on a server's environment.
 154  ################
 155  sub GetServerPath
 156  {
 157  my $dir;
 158  
 159      if($DefServerPath) {
 160          $dir = $DefServerPath;
 161      } else {
 162          if($ENV{'PATH_INFO'}) {
 163              $dir  = $ENV{'PATH_INFO'};
 164          } elsif($ENV{'FILEPATH_INFO'}) {
 165              $dir  = $ENV{'FILEPATH_INFO'};
 166          }
 167      }
 168      return($dir);
 169  }


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