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# Sample page. 24##### 25 26## START: Hack for Windows (Not important to understand the editor code... Perl specific). 27if(Windows_check()) { 28 chdir(GetScriptPath($0)); 29} 30 31sub Windows_check 32{ 33 # IIS,PWS(NT/95) 34 $www_server_os = $^O; 35 # Win98 & NT(SP4) 36 if($www_server_os eq "") { $www_server_os= $ENV{'OS'}; } 37 # AnHTTPd/Omni/IIS 38 if($ENV{'SERVER_SOFTWARE'} =~ /AnWeb|Omni|IIS\//i) { $www_server_os= 'win'; } 39 # Win Apache 40 if($ENV{'WINDIR'} ne "") { $www_server_os= 'win'; } 41 if($www_server_os=~ /win/i) { return(1); } 42 return(0); 43} 44 45sub GetScriptPath { 46 local($path) = @_; 47 if($path =~ /[\:\/\\]/) { $path =~ s/(.*?)[\/\\][^\/\\]+$/$1/; } else { $path = '.'; } 48 $path; 49} 50## END: Hack for IIS 51 52require '../../fckeditor.pl'; 53 54# When $ENV{'PATH_INFO'} cannot be used by perl. 55# $DefRootPath = "/XXXXX/_samples/perl/sample01.cgi"; Please write in script. 56 57my $DefServerPath = ""; 58my $ServerPath; 59 60 $ServerPath = &GetServerPath(); 61 print "Content-type: text/html\n\n"; 62 print <<"_HTML_TAG_"; 63<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> 64<html> 65 <head> 66 <title>FCKeditor - Sample</title> 67 <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> 68 <meta name="robots" content="noindex, nofollow"> 69 <link href="../sample.css" rel="stylesheet" type="text/css" /> 70 </head> 71 <body> 72 <h1>FCKeditor - Perl - Sample 1</h1> 73 This sample displays a normal HTML form with an FCKeditor with full features 74 enabled. 75 <hr> 76 <form action="sampleposteddata.cgi" method="post" target="_blank"> 77_HTML_TAG_ 78 79 #// Automatically calculates the editor base path based on the _samples directory. 80 #// This is usefull only for these samples. A real application should use something like this: 81 #// $oFCKeditor->BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value. 82 83 $sBasePath = $ServerPath; 84 $sBasePath = substr($sBasePath,0,index($sBasePath,"_samples")); 85 &FCKeditor('FCKeditor1'); 86 $BasePath = $sBasePath; 87 $Value = '<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>'; 88 &Create(); 89 90 print <<"_HTML_TAG_"; 91 <br> 92 <input type="submit" value="Submit"> 93 </form> 94 </body> 95</html> 96_HTML_TAG_ 97 98################ 99#Please use this function, rewriting it depending on a server's environment. 100################ 101sub GetServerPath 102{ 103my $dir; 104 105 if($DefServerPath) { 106 $dir = $DefServerPath; 107 } else { 108 if($ENV{'PATH_INFO'}) { 109 $dir = $ENV{'PATH_INFO'}; 110 } elsif($ENV{'FILEPATH_INFO'}) { 111 $dir = $ENV{'FILEPATH_INFO'}; 112 } 113 } 114 return($dir); 115} 116