#!/usr/bin/env python
"""
FCKeditor - The text editor for Internet - http://www.fckeditor.net
Copyright (C) 2003-2007 Frederico Caldeira Knabben
== BEGIN LICENSE ==
Licensed under the terms of any of the following licenses at your
choice:
- GNU General Public License Version 2 or later (the "GPL")
http://www.gnu.org/licenses/gpl.html
- GNU Lesser General Public License Version 2.1 or later (the "LGPL")
http://www.gnu.org/licenses/lgpl.html
- Mozilla Public License Version 1.1 or later (the "MPL")
http://www.mozilla.org/MPL/MPL-1.1.html
== END LICENSE ==
Connector for Python.
Tested With:
Standard:
Python 2.3.3
Zope:
Zope Version: (Zope 2.8.1-final, python 2.3.5, linux2)
Python Version: 2.3.5 (#4, Mar 10 2005, 01:40:25)
[GCC 3.3.3 20040412 (Red Hat Linux 3.3.3-7)]
System Platform: linux2
"""
"""
Author Notes (04 December 2005):
This module has gone through quite a few phases of change. Obviously,
I am only supporting that part of the code that I use. Initially
I had the upload directory as a part of zope (ie. uploading files
directly into Zope), before realising that there were too many
complex intricacies within Zope to deal with. Zope is one ugly piece
of code. So I decided to complement Zope by an Apache server (which
I had running anyway, and doing nothing). So I mapped all uploads
from an arbitrary server directory to an arbitrary web directory.
All the FCKeditor uploading occurred this way, and I didn't have to
stuff around with fiddling with Zope objects and the like (which are
terribly complex and something you don't want to do - trust me).
Maybe a Zope expert can touch up the Zope components. In the end,
I had FCKeditor loaded in Zope (probably a bad idea as well), and
I replaced the connector.py with an alias to a server module.
Right now, all Zope components will simple remain as is because
I've had enough of Zope.
See notes right at the end of this file for how I aliased out of Zope.
Anyway, most of you probably wont use Zope, so things are pretty
simple in that regard.
Typically, SERVER_DIR is the root of WEB_DIR (not necessarily).
Most definitely, SERVER_USERFILES_DIR points to WEB_USERFILES_DIR.
"""
import cgi
import re
import os
import string
"""
escape
Converts the special characters '<', '>', and '&'.
RFC 1866 specifies that these characters be represented
in HTML as < > and & respectively. In Python
1.5 we use the new string.replace() function for speed.
"""
def escape(text, replace=string.replace):
text = replace(text, '&', '&') # must be done 1st
text = replace(text, '<', '<')
text = replace(text, '>', '>')
text = replace(text, '"', '"')
return text
"""
getFCKeditorConnector
Creates a new instance of an FCKeditorConnector, and runs it
"""
def getFCKeditorConnector(context=None):
# Called from Zope. Passes the context through
connector = FCKeditorConnector(context=context)
return connector.run()
"""
FCKeditorRequest
A wrapper around the request object
Can handle normal CGI request, or a Zope request
Extend as required
"""
class FCKeditorRequest(object):
def __init__(self, context=None):
if (context is not None):
r = context.REQUEST
else:
r = cgi.FieldStorage()
self.context = context
self.request = r
def isZope(self):
if (self.context is not None):
return True
return False
def has_key(self, key):
return self.request.has_key(key)
def get(self, key, default=None):
value = None
if (self.isZope()):
value = self.request.get(key, default)
else:
if key in self.request.keys():
value = self.request[key].value
else:
value = default
return value
"""
FCKeditorConnector
The connector class
"""
class FCKeditorConnector(object):
# Configuration for FCKEditor
# can point to another server here, if linked correctly
#WEB_HOST = "http://127.0.0.1/"
WEB_HOST = ""
SERVER_DIR = "/var/www/html/"
WEB_USERFILES_FOLDER = WEB_HOST + "upload/"
SERVER_USERFILES_FOLDER = SERVER_DIR + "upload/"
# Allow access (Zope)
__allow_access_to_unprotected_subobjects__ = 1
# Class Attributes
parentFolderRe = re.compile("[\/][^\/]+[\/]?$")
"""
Constructor
"""
def __init__(self, context=None):
# The given root path will NOT be shown to the user
# Only the userFilesPath will be shown
# Instance Attributes
self.context = context
self.request = FCKeditorRequest(context=context)
self.rootPath = self.SERVER_DIR
self.userFilesFolder = self.SERVER_USERFILES_FOLDER
self.webUserFilesFolder = self.WEB_USERFILES_FOLDER
# Enables / Disables the connector
self.enabled = False # Set to True to enable this connector
# These are instance variables
self.zopeRootContext = None
self.zopeUploadContext = None
# Copied from php module =)
self.allowedExtensions = {
"File": None,
"Image": None,
"Flash": None,
"Media": None
}
self.deniedExtensions = {
"File": [ "html","htm","php","php2","php3","php4","php5","phtml","pwml","inc","asp","aspx","ascx","jsp","cfm","cfc","pl","bat","exe","com","dll","vbs","js","reg","cgi","htaccess","asis","sh","shtml","shtm","phtm" ],
"Image": [ "html","htm","php","php2","php3","php4","php5","phtml","pwml","inc","asp","aspx","ascx","jsp","cfm","cfc","pl","bat","exe","com","dll","vbs","js","reg","cgi","htaccess","asis","sh","shtml","shtm","phtm" ],
"Flash": [ "html","htm","php","php2","php3","php4","php5","phtml","pwml","inc","asp","aspx","ascx","jsp","cfm","cfc","pl","bat","exe","com","dll","vbs","js","reg","cgi","htaccess","asis","sh","shtml","shtm","phtm" ],
"Media": [ "html","htm","php","php2","php3","php4","php5","phtml","pwml","inc","asp","aspx","ascx","jsp","cfm","cfc","pl","bat","exe","com","dll","vbs","js","reg","cgi","htaccess","asis","sh","shtml","shtm","phtm" ]
}
"""
Zope specific functions
"""
def isZope(self):
# The context object is the zope object
if (self.context is not None):
return True
return False
def getZopeRootContext(self):
if self.zopeRootContext is None:
self.zopeRootContext = self.context.getPhysicalRoot()
return self.zopeRootContext
def getZopeUploadContext(self):
if self.zopeUploadContext is None:
folderNames = self.userFilesFolder.split("/")
c = self.getZopeRootContext()
for folderName in folderNames:
if (folderName <> ""):
c = c[folderName]
self.zopeUploadContext = c
return self.zopeUploadContext
"""
Generic manipulation functions
"""
def getUserFilesFolder(self):
return self.userFilesFolder
def getWebUserFilesFolder(self):
return self.webUserFilesFolder
def getAllowedExtensions(self, resourceType):
return self.allowedExtensions[resourceType]
def getDeniedExtensions(self, resourceType):
return self.deniedExtensions[resourceType]
def removeFromStart(self, string, char):
return string.lstrip(char)
def removeFromEnd(self, string, char):
return string.rstrip(char)
def convertToXmlAttribute(self, value):
if (value is None):
value = ""
return escape(value)
def convertToPath(self, path):
if (path[-1] <> "/"):
return path + "/"
else:
return path
def getUrlFromPath(self, resourceType, path):
if (resourceType is None) or (resourceType == ''):
url = "%s%s" % (
self.removeFromEnd(self.getUserFilesFolder(), '/'),
path
)
else:
url = "%s%s%s" % (
self.getUserFilesFolder(),
resourceType,
path
)
return url
def getWebUrlFromPath(self, resourceType, path):
if (resourceType is None) or (resourceType == ''):
url = "%s%s" % (
self.removeFromEnd(self.getWebUserFilesFolder(), '/'),
path
)
else:
url = "%s%s%s" % (
self.getWebUserFilesFolder(),
resourceType,
path
)
retur
没有合适的资源?快使用搜索试试~ 我知道了~
毕业设计 计算机基础课程教学平台 源代码
共721个文件
gif:221个
js:175个
jsp:89个
5星 · 超过95%的资源 需积分: 16 66 下载量 35 浏览量
2009-05-31
13:12:19
上传
评论 5
收藏 2.62MB RAR 举报
温馨提示
系统实现了系统用户登陆,不同的用户有不同的权限,网络精品课程展示,在线论坛交流,在线资源课件下载,在线考试,留言簿等功能,达到了预期的效果。其中在线考试系统,采用随即从题库中抽取题目的方式生成试卷,难度教师可以设定,每个学生拿到的试卷都是难度一样但是题目不同的随即试卷,这样可以有效的防止学生作弊,教师可以准确的掌握到学生的考试和学习情况。系统采用了html、css、javascript、jsp、servlet等技术,
资源推荐
资源详情
资源评论
收起资源包目录
毕业设计 计算机基础课程教学平台 源代码 (721个子文件)
class_upload.asp 7KB
class_upload.asp 7KB
commands.asp 5KB
upload.asp 3KB
connector.asp 3KB
io.asp 2KB
basexml.asp 2KB
config.asp 2KB
config.asp 2KB
util.asp 1KB
io.asp 836B
connector.aspx 1KB
upload.aspx 1KB
connector.cfm 11KB
spellchecker.cfm 6KB
upload.cfm 6KB
config.cfm 3KB
config.cfm 3KB
connector.cgi 4KB
DB.class 3KB
DB1.class 3KB
TestPaper.class 3KB
Article.class 3KB
Student.class 3KB
ChoiceQuestion.class 3KB
Course.class 2KB
Notice.class 2KB
News.class 2KB
Teacher.class 2KB
SourceFile.class 2KB
Score.class 2KB
Message.class 2KB
User.class 2KB
ScoreSimple.class 2KB
SimpleQuestion.class 2KB
StudentScore.class 1KB
.classpath 600B
org.eclipse.wst.jsdt.ui.superType.container 49B
style.css 40KB
style.css 40KB
fck_editor.css 8KB
fck_editor.css 8KB
fck_editor.css 8KB
index_guest.css 5KB
default.css 5KB
fck_internal.css 2KB
fck_dialog.css 2KB
fck_dialog.css 2KB
fck_dialog.css 2KB
fck_editorarea.css 2KB
browser.css 2KB
fck_dialog_common.css 2KB
fck_showtableborders_gecko.css 1KB
v3_index.css 1KB
sample.css 1KB
spellerStyle.css 888B
Thumbs.db 165KB
Thumbs.db 41KB
03sx.gif 45KB
bgpic003.gif 25KB
fck_strip.gif 9KB
top_bg.gif 5KB
jc.gif 5KB
fck_strip.gif 4KB
fck_strip.gif 4KB
rj.gif 4KB
dmt.gif 4KB
c.gif 4KB
vfp.gif 4KB
header-left.gif 3KB
xueshengguanli.gif 3KB
gerenxinxi.gif 3KB
jiaoliushequ.gif 3KB
youqinglianjie.gif 3KB
kaoshiguanli.gif 3KB
zaixiankaoshi.gif 3KB
xinxiguanli.gif 3KB
ziyuanguanli.gif 3KB
xinwenguanli.gif 3KB
xiazaizhongxin.gif 3KB
tongzhiguanli.gif 3KB
jiaoshiguanli.gif 3KB
bgpic001.gif 2KB
link0.gif 2KB
header-right.gif 2KB
logo_fckeditor.gif 2KB
link1.gif 2KB
login.gif 2KB
htm.gif 1KB
html.gif 1KB
rdp.gif 1KB
ai.gif 1KB
zy.gif 1KB
embaressed_smile.gif 1KB
question-pts-available-16x16.gif 1KB
question-pts-available-16x16.gif 1KB
teeth_smile.gif 1KB
sub2_21.gif 1KB
shades_smile.gif 1KB
tounge_smile.gif 1KB
共 721 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
资源评论
- another_dl2013-05-27代码不错,但是分值有点高。有用!JSP的!
- superjiee2014-08-18很感谢,帮助很大
- sai199287922015-06-29代码不错,感谢
- BlessChina_c2013-03-24很感谢 代码很完整
ouyangkevin
- 粉丝: 2
- 资源: 1
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功