--- /dev/null
+#!/usr/bin/env perl\r
+\r
+#####\r
+# FCKeditor - The text editor for Internet - http://www.fckeditor.net\r
+# Copyright (C) 2003-2008 Frederico Caldeira Knabben\r
+#\r
+# == BEGIN LICENSE ==\r
+#\r
+# Licensed under the terms of any of the following licenses at your\r
+# choice:\r
+#\r
+# - GNU General Public License Version 2 or later (the "GPL")\r
+# http://www.gnu.org/licenses/gpl.html\r
+#\r
+# - GNU Lesser General Public License Version 2.1 or later (the "LGPL")\r
+# http://www.gnu.org/licenses/lgpl.html\r
+#\r
+# - Mozilla Public License Version 1.1 or later (the "MPL")\r
+# http://www.mozilla.org/MPL/MPL-1.1.html\r
+#\r
+# == END LICENSE ==\r
+#\r
+# Sample page.\r
+#####\r
+\r
+## START: Hack for Windows (Not important to understand the editor code... Perl specific).\r
+if(Windows_check()) {\r
+ chdir(GetScriptPath($0));\r
+}\r
+\r
+sub Windows_check\r
+{\r
+ # IIS,PWS(NT/95)\r
+ $www_server_os = $^O;\r
+ # Win98 & NT(SP4)\r
+ if($www_server_os eq "") { $www_server_os= $ENV{'OS'}; }\r
+ # AnHTTPd/Omni/IIS\r
+ if($ENV{'SERVER_SOFTWARE'} =~ /AnWeb|Omni|IIS\//i) { $www_server_os= 'win'; }\r
+ # Win Apache\r
+ if($ENV{'WINDIR'} ne "") { $www_server_os= 'win'; }\r
+ if($www_server_os=~ /win/i) { return(1); }\r
+ return(0);\r
+}\r
+\r
+sub GetScriptPath {\r
+ local($path) = @_;\r
+ if($path =~ /[\:\/\\]/) { $path =~ s/(.*?)[\/\\][^\/\\]+$/$1/; } else { $path = '.'; }\r
+ $path;\r
+}\r
+## END: Hack for IIS\r
+\r
+require '../../fckeditor.pl';\r
+\r
+# When $ENV{'PATH_INFO'} cannot be used by perl.\r
+# $DefRootPath = "/XXXXX/_samples/perl/sample04.cgi"; Please write in script.\r
+\r
+my $DefServerPath = "";\r
+my $ServerPath;\r
+\r
+ $ServerPath = &GetServerPath();\r
+\r
+ if($ENV{'REQUEST_METHOD'} eq "POST") {\r
+ read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});\r
+ } else {\r
+ $buffer = $ENV{'QUERY_STRING'};\r
+ }\r
+ @pairs = split(/&/,$buffer);\r
+ foreach $pair (@pairs) {\r
+ ($name,$value) = split(/=/,$pair);\r
+ $value =~ tr/+/ /;\r
+ $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;\r
+ $value =~ s/\t//g;\r
+ $value =~ s/\r\n/\n/g;\r
+ $FORM{$name} .= "\0" if(defined($FORM{$name}));\r
+ $FORM{$name} .= $value;\r
+ }\r
+\r
+#!!Caution javascript \ Quart\r
+\r
+ print "Content-type: text/html\n\n";\r
+ print <<"_HTML_TAG_";\r
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">\r
+<html>\r
+ <head>\r
+ <title>FCKeditor - Sample</title>\r
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">\r
+ <meta name="robots" content="noindex, nofollow">\r
+ <link href="../sample.css" rel="stylesheet" type="text/css" />\r
+ <script type="text/javascript">\r
+\r
+function FCKeditor_OnComplete( editorInstance )\r
+{\r
+ var oCombo = document.getElementById( 'cmbSkins' ) ;\r
+\r
+ // Get the active skin.\r
+ var sSkin = editorInstance.Config['SkinPath'] ;\r
+ sSkin = sSkin.match(/[^\\/]+(?=\\/\$)/g) ;\r
+\r
+ oCombo.value = sSkin ;\r
+ oCombo.style.visibility = '' ;\r
+}\r
+\r
+function ChangeSkin( skinName )\r
+{\r
+ window.location.href = window.location.pathname + "?Skin=" + skinName ;\r
+}\r
+\r
+ </script>\r
+ </head>\r
+ <body>\r
+ <h1>FCKeditor - Perl - Sample 4</h1>\r
+ This sample shows how to change the editor skin.\r
+ <hr>\r
+ <table cellpadding="0" cellspacing="0" border="0">\r
+ <tr>\r
+ <td>\r
+ Select the skin to load: \r
+ </td>\r
+ <td>\r
+ <select id="cmbSkins" onchange="ChangeSkin(this.value);" style="VISIBILITY: hidden">\r
+ <option value="default" selected>Default</option>\r
+ <option value="office2003">Office 2003</option>\r
+ <option value="silver">Silver</option>\r
+ </select>\r
+ </td>\r
+ </tr>\r
+ </table>\r
+ <br>\r
+ <form action="sampleposteddata.cgi" method="post" target="_blank">\r
+_HTML_TAG_\r
+\r
+ #// Automatically calculates the editor base path based on the _samples directory.\r
+ #// This is usefull only for these samples. A real application should use something like this:\r
+ #// $oFCKeditor->BasePath = '/fckeditor/' ; // '/fckeditor/' is the default value.\r
+ $sBasePath = $ServerPath;\r
+ $sBasePath = substr( $sBasePath, 0, index( $sBasePath, "_samples" ) ) ;\r
+\r
+ &FCKeditor('FCKeditor1');\r
+ $BasePath = $sBasePath;\r
+\r
+ if($FORM{'Skin'} ne "") {\r
+ $Config{'SkinPath'} = $sBasePath . 'editor/skins/' . &specialchar_cnv( $FORM{'Skin'} ) . '/' ;\r
+ }\r
+ $Value = '<p>This is some <strong>sample text</strong>. You are using <a href="http://www.fckeditor.net/">FCKeditor</a>.</p>' ;\r
+ &Create() ;\r
+\r
+ print <<"_HTML_TAG_";\r
+ <br>\r
+ <input type="submit" value="Submit">\r
+ </form>\r
+ </body>\r
+</html>\r
+_HTML_TAG_\r
+\r
+################\r
+#Please use this function, rewriting it depending on a server's environment.\r
+################\r
+sub GetServerPath\r
+{\r
+my $dir;\r
+\r
+ if($DefServerPath) {\r
+ $dir = $DefServerPath;\r
+ } else {\r
+ if($ENV{'PATH_INFO'}) {\r
+ $dir = $ENV{'PATH_INFO'};\r
+ } elsif($ENV{'FILEPATH_INFO'}) {\r
+ $dir = $ENV{'FILEPATH_INFO'};\r
+ } elsif($ENV{'REQUEST_URI'}) {\r
+ $dir = $ENV{'REQUEST_URI'};\r
+ }\r
+ }\r
+ return($dir);\r
+}\r