code stringlengths 1 2.01M | repo_name stringlengths 3 62 | path stringlengths 1 267 | language stringclasses 231
values | license stringclasses 13
values | size int64 1 2.01M |
|---|---|---|---|---|---|
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* Sample custom configuration settings used by the BBCode plugin. It simply
* loads the plugin. All the rest is done by the plugin itself.
*/
// Add the BBCode plugin.
FCKConfig.Plugins.Add( 'bbcode' ) ;
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/plugins/bbcode/_sample/sample.config.js | JavaScript | asf20 | 843 |
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* This plugin register the required Toolbar items to be able to insert the
* table commands in the toolbar.
*/
FCKToolbarItems.RegisterItem( 'TableInsertRowAfter' , new FCKToolbarButton( 'TableInsertRowAfter' , FCKLang.InsertRowAfter, null, null, null, true, 62 ) ) ;
FCKToolbarItems.RegisterItem( 'TableDeleteRows' , new FCKToolbarButton( 'TableDeleteRows' , FCKLang.DeleteRows, null, null, null, true, 63 ) ) ;
FCKToolbarItems.RegisterItem( 'TableInsertColumnAfter' , new FCKToolbarButton( 'TableInsertColumnAfter' , FCKLang.InsertColumnAfter, null, null, null, true, 64 ) ) ;
FCKToolbarItems.RegisterItem( 'TableDeleteColumns' , new FCKToolbarButton( 'TableDeleteColumns', FCKLang.DeleteColumns, null, null, null, true, 65 ) ) ;
FCKToolbarItems.RegisterItem( 'TableInsertCellAfter' , new FCKToolbarButton( 'TableInsertCellAfter' , FCKLang.InsertCellAfter, null, null, null, true, 58 ) ) ;
FCKToolbarItems.RegisterItem( 'TableDeleteCells' , new FCKToolbarButton( 'TableDeleteCells' , FCKLang.DeleteCells, null, null, null, true, 59 ) ) ;
FCKToolbarItems.RegisterItem( 'TableMergeCells' , new FCKToolbarButton( 'TableMergeCells' , FCKLang.MergeCells, null, null, null, true, 60 ) ) ;
FCKToolbarItems.RegisterItem( 'TableHorizontalSplitCell' , new FCKToolbarButton( 'TableHorizontalSplitCell' , FCKLang.SplitCell, null, null, null, true, 61 ) ) ;
FCKToolbarItems.RegisterItem( 'TableCellProp' , new FCKToolbarButton( 'TableCellProp' , FCKLang.CellProperties, null, null, null, true, 57 ) ) ;
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/plugins/tablecommands/fckplugin.js | JavaScript | asf20 | 2,144 |
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* This plugin register Toolbar items for the combos modifying the style to
* not show the box.
*/
FCKToolbarItems.RegisterItem( 'SourceSimple' , new FCKToolbarButton( 'Source', FCKLang.Source, null, FCK_TOOLBARITEM_ONLYICON, true, true, 1 ) ) ;
FCKToolbarItems.RegisterItem( 'StyleSimple' , new FCKToolbarStyleCombo( null, FCK_TOOLBARITEM_ONLYTEXT ) ) ;
FCKToolbarItems.RegisterItem( 'FontNameSimple' , new FCKToolbarFontsCombo( null, FCK_TOOLBARITEM_ONLYTEXT ) ) ;
FCKToolbarItems.RegisterItem( 'FontSizeSimple' , new FCKToolbarFontSizeCombo( null, FCK_TOOLBARITEM_ONLYTEXT ) ) ;
FCKToolbarItems.RegisterItem( 'FontFormatSimple', new FCKToolbarFontFormatCombo( null, FCK_TOOLBARITEM_ONLYTEXT ) ) ;
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/plugins/simplecommands/fckplugin.js | JavaScript | asf20 | 1,342 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* Main page that holds the editor.
-->
<html>
<head>
<title>FCKeditor</title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<!-- @Packager.RemoveLine
<meta http-equiv="Cache-Control" content="public">
@Packager.RemoveLine -->
<script type="text/javascript">
// #1645: Alert the user if opening FCKeditor in FF3 from local filesystem
// without security.fileuri.strict_origin_policy disabled.
if ( document.location.protocol == 'file:' )
{
try
{
window.parent.document.domain ;
}
catch ( e )
{
window.addEventListener( 'load', function()
{
document.body.innerHTML = '\
<div style="border: 1px red solid; font-family: arial; font-size: 12px; color: red; padding:10px;">\
<p>\
<b>Your browser security settings don\'t allow FCKeditor to be opened from\
the local filesystem.<\/b>\
<\/p>\
<p>\
Please open the <b>about:config<\/b> page and disable the\
"security.fileuri.strict_origin_policy" option; then load this page again.\
<\/p>\
<p>\
Check our <a href="http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/FAQ#ff3perms">FAQ<\/a>\
for more information.\
<\/p>\
<\/div>' ;
}, false ) ;
}
}
// Save a reference to the default domain.
var FCK_ORIGINAL_DOMAIN ;
// Automatically detect the correct document.domain (#123).
(function()
{
var d = FCK_ORIGINAL_DOMAIN = document.domain ;
while ( true )
{
// Test if we can access a parent property.
try
{
var test = window.parent.document.domain ;
break ;
}
catch( e ) {}
// Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
d = d.replace( /.*?(?:\.|$)/, '' ) ;
if ( d.length == 0 )
break ; // It was not able to detect the domain.
try
{
document.domain = d ;
}
catch (e)
{
break ;
}
}
})() ;
// Save a reference to the detected runtime domain.
var FCK_RUNTIME_DOMAIN = document.domain ;
var FCK_IS_CUSTOM_DOMAIN = ( FCK_ORIGINAL_DOMAIN != FCK_RUNTIME_DOMAIN ) ;
// Instead of loading scripts and CSSs using inline tags, all scripts are
// loaded by code. In this way we can guarantee the correct processing order,
// otherwise external scripts and inline scripts could be executed in an
// unwanted order (IE).
function LoadScript( url )
{
document.write( '<scr' + 'ipt type="text/javascript" src="' + url + '"><\/scr' + 'ipt>' ) ;
}
// Main editor scripts.
var sSuffix = ( /*@cc_on!@*/false ) ? 'ie' : 'gecko' ;
/* @Packager.RemoveLine
LoadScript( 'js/fckeditorcode_' + sSuffix + '.js' ) ;
@Packager.RemoveLine */
// @Packager.Remove.Start
LoadScript( '_source/fckconstants.js' ) ;
LoadScript( '_source/fckjscoreextensions.js' ) ;
if ( sSuffix == 'ie' )
LoadScript( '_source/classes/fckiecleanup.js' ) ;
LoadScript( '_source/internals/fckbrowserinfo.js' ) ;
LoadScript( '_source/internals/fckurlparams.js' ) ;
LoadScript( '_source/classes/fckevents.js' ) ;
LoadScript( '_source/classes/fckdataprocessor.js' ) ;
LoadScript( '_source/internals/fck.js' ) ;
LoadScript( '_source/internals/fck_' + sSuffix + '.js' ) ;
LoadScript( '_source/internals/fckconfig.js' ) ;
LoadScript( '_source/internals/fckdebug_empty.js' ) ;
LoadScript( '_source/internals/fckdomtools.js' ) ;
LoadScript( '_source/internals/fcktools.js' ) ;
LoadScript( '_source/internals/fcktools_' + sSuffix + '.js' ) ;
LoadScript( '_source/fckeditorapi.js' ) ;
LoadScript( '_source/classes/fckimagepreloader.js' ) ;
LoadScript( '_source/internals/fckregexlib.js' ) ;
LoadScript( '_source/internals/fcklistslib.js' ) ;
LoadScript( '_source/internals/fcklanguagemanager.js' ) ;
LoadScript( '_source/internals/fckxhtmlentities.js' ) ;
LoadScript( '_source/internals/fckxhtml.js' ) ;
LoadScript( '_source/internals/fckxhtml_' + sSuffix + '.js' ) ;
LoadScript( '_source/internals/fckcodeformatter.js' ) ;
LoadScript( '_source/internals/fckundo.js' ) ;
LoadScript( '_source/classes/fckeditingarea.js' ) ;
LoadScript( '_source/classes/fckkeystrokehandler.js' ) ;
LoadScript( 'dtd/fck_xhtml10transitional.js' ) ;
LoadScript( '_source/classes/fckstyle.js' ) ;
LoadScript( '_source/internals/fckstyles.js' ) ;
LoadScript( '_source/internals/fcklisthandler.js' ) ;
LoadScript( '_source/classes/fckelementpath.js' ) ;
LoadScript( '_source/classes/fckdomrange.js' ) ;
LoadScript( '_source/classes/fckdocumentfragment_' + sSuffix + '.js' ) ;
LoadScript( '_source/classes/fckw3crange.js' ) ;
LoadScript( '_source/classes/fckdomrange_' + sSuffix + '.js' ) ;
LoadScript( '_source/classes/fckdomrangeiterator.js' ) ;
LoadScript( '_source/classes/fckenterkey.js' ) ;
LoadScript( '_source/internals/fckdocumentprocessor.js' ) ;
LoadScript( '_source/internals/fckselection.js' ) ;
LoadScript( '_source/internals/fckselection_' + sSuffix + '.js' ) ;
LoadScript( '_source/internals/fcktablehandler.js' ) ;
LoadScript( '_source/internals/fcktablehandler_' + sSuffix + '.js' ) ;
LoadScript( '_source/classes/fckxml.js' ) ;
LoadScript( '_source/classes/fckxml_' + sSuffix + '.js' ) ;
LoadScript( '_source/commandclasses/fcknamedcommand.js' ) ;
LoadScript( '_source/commandclasses/fckstylecommand.js' ) ;
LoadScript( '_source/commandclasses/fck_othercommands.js' ) ;
LoadScript( '_source/commandclasses/fckshowblocks.js' ) ;
LoadScript( '_source/commandclasses/fckspellcheckcommand_' + sSuffix + '.js' ) ;
LoadScript( '_source/commandclasses/fcktextcolorcommand.js' ) ;
LoadScript( '_source/commandclasses/fckpasteplaintextcommand.js' ) ;
LoadScript( '_source/commandclasses/fckpastewordcommand.js' ) ;
LoadScript( '_source/commandclasses/fcktablecommand.js' ) ;
LoadScript( '_source/commandclasses/fckfitwindow.js' ) ;
LoadScript( '_source/commandclasses/fcklistcommands.js' ) ;
LoadScript( '_source/commandclasses/fckjustifycommands.js' ) ;
LoadScript( '_source/commandclasses/fckindentcommands.js' ) ;
LoadScript( '_source/commandclasses/fckblockquotecommand.js' ) ;
LoadScript( '_source/commandclasses/fckcorestylecommand.js' ) ;
LoadScript( '_source/commandclasses/fckremoveformatcommand.js' ) ;
LoadScript( '_source/internals/fckcommands.js' ) ;
LoadScript( '_source/classes/fckpanel.js' ) ;
LoadScript( '_source/classes/fckicon.js' ) ;
LoadScript( '_source/classes/fcktoolbarbuttonui.js' ) ;
LoadScript( '_source/classes/fcktoolbarbutton.js' ) ;
LoadScript( '_source/classes/fckspecialcombo.js' ) ;
LoadScript( '_source/classes/fcktoolbarspecialcombo.js' ) ;
LoadScript( '_source/classes/fcktoolbarstylecombo.js' ) ;
LoadScript( '_source/classes/fcktoolbarfontformatcombo.js' ) ;
LoadScript( '_source/classes/fcktoolbarfontscombo.js' ) ;
LoadScript( '_source/classes/fcktoolbarfontsizecombo.js' ) ;
LoadScript( '_source/classes/fcktoolbarpanelbutton.js' ) ;
LoadScript( '_source/internals/fcktoolbaritems.js' ) ;
LoadScript( '_source/classes/fcktoolbar.js' ) ;
LoadScript( '_source/classes/fcktoolbarbreak_' + sSuffix + '.js' ) ;
LoadScript( '_source/internals/fcktoolbarset.js' ) ;
LoadScript( '_source/internals/fckdialog.js' ) ;
LoadScript( '_source/classes/fckmenuitem.js' ) ;
LoadScript( '_source/classes/fckmenublock.js' ) ;
LoadScript( '_source/classes/fckmenublockpanel.js' ) ;
LoadScript( '_source/classes/fckcontextmenu.js' ) ;
LoadScript( '_source/internals/fck_contextmenu.js' ) ;
LoadScript( '_source/classes/fckhtmliterator.js' ) ;
LoadScript( '_source/classes/fckplugin.js' ) ;
LoadScript( '_source/internals/fckplugins.js' ) ;
// @Packager.Remove.End
// Base configuration file.
LoadScript( '../fckconfig.js' ) ;
</script>
<script type="text/javascript">
// Adobe AIR compatibility file.
if ( FCKBrowserInfo.IsAIR )
LoadScript( 'js/fckadobeair.js' ) ;
if ( FCKBrowserInfo.IsIE )
{
// Remove IE mouse flickering.
try
{
document.execCommand( 'BackgroundImageCache', false, true ) ;
}
catch (e)
{
// We have been reported about loading problems caused by the above
// line. For safety, let's just ignore errors.
}
// Create the default cleanup object used by the editor.
FCK.IECleanup = new FCKIECleanup( window ) ;
FCK.IECleanup.AddItem( FCKTempBin, FCKTempBin.Reset ) ;
FCK.IECleanup.AddItem( FCK, FCK_Cleanup ) ;
}
// The first function to be called on selection change must the the styles
// change checker, because the result of its processing may be used by another
// functions listening to the same event.
FCK.Events.AttachEvent( 'OnSelectionChange', function() { FCKStyles.CheckSelectionChanges() ; } ) ;
// The config hidden field is processed immediately, because
// CustomConfigurationsPath may be set in the page.
FCKConfig.ProcessHiddenField() ;
// Load the custom configurations file (if defined).
if ( FCKConfig.CustomConfigurationsPath.length > 0 )
LoadScript( FCKConfig.CustomConfigurationsPath ) ;
</script>
<script type="text/javascript">
// Load configurations defined at page level.
FCKConfig_LoadPageConfig() ;
FCKConfig_PreProcess() ;
// Load the full debug script.
if ( FCKConfig.Debug )
LoadScript( '_source/internals/fckdebug.js' ) ;
</script>
<script type="text/javascript">
var FCK_InternalCSS = FCKConfig.BasePath + 'css/fck_internal.css' ; // @Packager.RemoveLine
var FCK_ShowTableBordersCSS = FCKConfig.BasePath + 'css/fck_showtableborders_gecko.css' ; // @Packager.RemoveLine
/* @Packager.RemoveLine
// CSS minified by http://iceyboard.no-ip.org/projects/css_compressor (see _dev/css_compression.txt).
var FCK_InternalCSS = FCKTools.FixCssUrls( FCKConfig.BasePath + 'css/', 'html{min-height:100%}table.FCK__ShowTableBorders,table.FCK__ShowTableBorders td,table.FCK__ShowTableBorders th{border:#d3d3d3 1px solid}form{border:1px dotted #F00;padding:2px}.FCK__Flash{border:#a9a9a9 1px solid;background-position:center center;background-image:url(images/fck_flashlogo.gif);background-repeat:no-repeat;width:80px;height:80px}.FCK__UnknownObject{border:#a9a9a9 1px solid;background-position:center center;background-image:url(images/fck_plugin.gif);background-repeat:no-repeat;width:80px;height:80px}.FCK__Anchor{border:1px dotted #00F;background-position:center center;background-image:url(images/fck_anchor.gif);background-repeat:no-repeat;width:16px;height:15px;vertical-align:middle}.FCK__AnchorC{border:1px dotted #00F;background-position:1px center;background-image:url(images/fck_anchor.gif);background-repeat:no-repeat;padding-left:18px}a[name]{border:1px dotted #00F;background-position:0 center;background-image:url(images/fck_anchor.gif);background-repeat:no-repeat;padding-left:18px}.FCK__PageBreak{background-position:center center;background-image:url(images/fck_pagebreak.gif);background-repeat:no-repeat;clear:both;display:block;float:none;width:100%;border-top:#999 1px dotted;border-bottom:#999 1px dotted;border-right:0;border-left:0;height:5px}.FCK__InputHidden{width:19px;height:18px;background-image:url(images/fck_hiddenfield.gif);background-repeat:no-repeat;vertical-align:text-bottom;background-position:center center}.FCK__ShowBlocks p,.FCK__ShowBlocks div,.FCK__ShowBlocks pre,.FCK__ShowBlocks address,.FCK__ShowBlocks blockquote,.FCK__ShowBlocks h1,.FCK__ShowBlocks h2,.FCK__ShowBlocks h3,.FCK__ShowBlocks h4,.FCK__ShowBlocks h5,.FCK__ShowBlocks h6{background-repeat:no-repeat;border:1px dotted gray;padding-top:8px;padding-left:8px}.FCK__ShowBlocks p{background-image:url(images/block_p.png)}.FCK__ShowBlocks div{background-image:url(images/block_div.png)}.FCK__ShowBlocks pre{background-image:url(images/block_pre.png)}.FCK__ShowBlocks address{background-image:url(images/block_address.png)}.FCK__ShowBlocks blockquote{background-image:url(images/block_blockquote.png)}.FCK__ShowBlocks h1{background-image:url(images/block_h1.png)}.FCK__ShowBlocks h2{background-image:url(images/block_h2.png)}.FCK__ShowBlocks h3{background-image:url(images/block_h3.png)}.FCK__ShowBlocks h4{background-image:url(images/block_h4.png)}.FCK__ShowBlocks h5{background-image:url(images/block_h5.png)}.FCK__ShowBlocks h6{background-image:url(images/block_h6.png)}' ) ;
var FCK_ShowTableBordersCSS = FCKTools.FixCssUrls( FCKConfig.BasePath + 'css/', 'table:not([border]),table:not([border]) > tr > td,table:not([border]) > tr > th,table:not([border]) > tbody > tr > td,table:not([border]) > tbody > tr > th,table:not([border]) > thead > tr > td,table:not([border]) > thead > tr > th,table:not([border]) > tfoot > tr > td,table:not([border]) > tfoot > tr > th,table[border=\"0\"],table[border=\"0\"] > tr > td,table[border=\"0\"] > tr > th,table[border=\"0\"] > tbody > tr > td,table[border=\"0\"] > tbody > tr > th,table[border=\"0\"] > thead > tr > td,table[border=\"0\"] > thead > tr > th,table[border=\"0\"] > tfoot > tr > td,table[border=\"0\"] > tfoot > tr > th{border:#d3d3d3 1px dotted}' ) ;
@Packager.RemoveLine */
// Popup the debug window if debug mode is set to true. It guarantees that the
// first debug message will not be lost.
if ( FCKConfig.Debug )
FCKDebug._GetWindow() ;
// Load the active skin CSS.
document.write( FCKTools.GetStyleHtml( FCKConfig.SkinEditorCSS ) ) ;
// Load the language file.
FCKLanguageManager.Initialize() ;
LoadScript( 'lang/' + FCKLanguageManager.ActiveLanguage.Code + '.js' ) ;
</script>
<script type="text/javascript">
// Initialize the editing area context menu.
FCK_ContextMenu_Init() ;
FCKPlugins.Load() ;
</script>
<script type="text/javascript">
// Set the editor interface direction.
window.document.dir = FCKLang.Dir ;
</script>
<script type="text/javascript">
window.onload = function()
{
InitializeAPI() ;
if ( FCKBrowserInfo.IsIE )
FCK_PreloadImages() ;
else
LoadToolbarSetup() ;
}
function LoadToolbarSetup()
{
FCKeditorAPI._FunctionQueue.Add( LoadToolbar ) ;
}
function LoadToolbar()
{
var oToolbarSet = FCK.ToolbarSet = FCKToolbarSet_Create() ;
if ( oToolbarSet.IsLoaded )
StartEditor() ;
else
{
oToolbarSet.OnLoad = StartEditor ;
oToolbarSet.Load( FCKURLParams['Toolbar'] || 'Default' ) ;
}
}
function StartEditor()
{
// Remove the onload listener.
FCK.ToolbarSet.OnLoad = null ;
FCKeditorAPI._FunctionQueue.Remove( LoadToolbar ) ;
FCK.Events.AttachEvent( 'OnStatusChange', WaitForActive ) ;
// Start the editor.
FCK.StartEditor() ;
}
function WaitForActive( editorInstance, newStatus )
{
if ( newStatus == FCK_STATUS_ACTIVE )
{
if ( FCKBrowserInfo.IsGecko )
FCKTools.RunFunction( window.onresize ) ;
if ( !FCKConfig.PreventSubmitHandler )
_AttachFormSubmitToAPI() ;
FCK.SetStatus( FCK_STATUS_COMPLETE ) ;
// Call the special "FCKeditor_OnComplete" function that should be present in
// the HTML page where the editor is located.
if ( typeof( window.parent.FCKeditor_OnComplete ) == 'function' )
window.parent.FCKeditor_OnComplete( FCK ) ;
}
}
// Gecko browsers doesn't calculate well the IFRAME size so we must
// recalculate it every time the window size changes.
if ( FCKBrowserInfo.IsGecko && !FCKBrowserInfo.IsOpera )
{
window.onresize = function( e )
{
// Running in Chrome makes the window receive the event including subframes.
// we care only about this window. Ticket #1642.
// #2002: The originalTarget from the event can be the current document, the window, or the editing area.
if ( e && e.originalTarget !== document && e.originalTarget !== window && (!e.originalTarget.ownerDocument || e.originalTarget.ownerDocument != document ))
return ;
var oCell = document.getElementById( 'xEditingArea' ) ;
var eInnerElement = oCell.firstChild ;
if ( eInnerElement )
{
eInnerElement.style.height = '0px' ;
eInnerElement.style.height = ( oCell.scrollHeight - 2 ) + 'px' ;
}
}
}
</script>
</head>
<body>
<table width="100%" cellpadding="0" cellspacing="0" style="height: 100%; table-layout: fixed">
<tr id="xToolbarRow" style="display: none">
<td id="xToolbarSpace" style="overflow: hidden">
<table width="100%" cellpadding="0" cellspacing="0">
<tr id="xCollapsed" style="display: none">
<td id="xExpandHandle" class="TB_Expand" colspan="3">
<img class="TB_ExpandImg" alt="" src="images/spacer.gif" width="8" height="4" /></td>
</tr>
<tr id="xExpanded" style="display: none">
<td id="xTBLeftBorder" class="TB_SideBorder" style="width: 1px; display: none;"></td>
<td id="xCollapseHandle" style="display: none" class="TB_Collapse" valign="bottom">
<img class="TB_CollapseImg" alt="" src="images/spacer.gif" width="8" height="4" /></td>
<td id="xToolbar" class="TB_ToolbarSet"></td>
<td class="TB_SideBorder" style="width: 1px"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="xEditingArea" valign="top" style="height: 100%"></td>
</tr>
</table>
</body>
</html>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/fckeditor.original.html | HTML | asf20 | 17,712 |
<?php
if ( !isset( $_SERVER ) ) {
$_SERVER = $HTTP_SERVER_VARS ;
}
if ( !isset( $_GET ) ) {
$_GET = $HTTP_GET_VARS ;
}
if ( !isset( $_FILES ) ) {
$_FILES = $HTTP_POST_FILES ;
}
if ( !defined( 'DIRECTORY_SEPARATOR' ) ) {
define( 'DIRECTORY_SEPARATOR',
strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ? '\\' : '/'
) ;
}
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/connectors/php/phpcompat.php | PHP | asf20 | 359 |
<?php
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* Utility functions for the File Manager Connector for PHP.
*/
function RemoveFromStart( $sourceString, $charToRemove )
{
$sPattern = '|^' . $charToRemove . '+|' ;
return preg_replace( $sPattern, '', $sourceString ) ;
}
function RemoveFromEnd( $sourceString, $charToRemove )
{
$sPattern = '|' . $charToRemove . '+$|' ;
return preg_replace( $sPattern, '', $sourceString ) ;
}
function FindBadUtf8( $string )
{
$regex =
'([\x00-\x7F]'.
'|[\xC2-\xDF][\x80-\xBF]'.
'|\xE0[\xA0-\xBF][\x80-\xBF]'.
'|[\xE1-\xEC\xEE\xEF][\x80-\xBF]{2}'.
'|\xED[\x80-\x9F][\x80-\xBF]'.
'|\xF0[\x90-\xBF][\x80-\xBF]{2}'.
'|[\xF1-\xF3][\x80-\xBF]{3}'.
'|\xF4[\x80-\x8F][\x80-\xBF]{2}'.
'|(.{1}))';
while (preg_match('/'.$regex.'/S', $string, $matches)) {
if ( isset($matches[2])) {
return true;
}
$string = substr($string, strlen($matches[0]));
}
return false;
}
function ConvertToXmlAttribute( $value )
{
if ( defined( 'PHP_OS' ) )
{
$os = PHP_OS ;
}
else
{
$os = php_uname() ;
}
if ( strtoupper( substr( $os, 0, 3 ) ) === 'WIN' || FindBadUtf8( $value ) )
{
return ( utf8_encode( htmlspecialchars( $value ) ) ) ;
}
else
{
return ( htmlspecialchars( $value ) ) ;
}
}
/**
* Check whether given extension is in html etensions list
*
* @param string $ext
* @param array $htmlExtensions
* @return boolean
*/
function IsHtmlExtension( $ext, $htmlExtensions )
{
if ( !$htmlExtensions || !is_array( $htmlExtensions ) )
{
return false ;
}
$lcaseHtmlExtensions = array() ;
foreach ( $htmlExtensions as $key => $val )
{
$lcaseHtmlExtensions[$key] = strtolower( $val ) ;
}
return in_array( $ext, $lcaseHtmlExtensions ) ;
}
/**
* Detect HTML in the first KB to prevent against potential security issue with
* IE/Safari/Opera file type auto detection bug.
* Returns true if file contain insecure HTML code at the beginning.
*
* @param string $filePath absolute path to file
* @return boolean
*/
function DetectHtml( $filePath )
{
$fp = @fopen( $filePath, 'rb' ) ;
//open_basedir restriction, see #1906
if ( $fp === false || !flock( $fp, LOCK_SH ) )
{
return -1 ;
}
$chunk = fread( $fp, 1024 ) ;
flock( $fp, LOCK_UN ) ;
fclose( $fp ) ;
$chunk = strtolower( $chunk ) ;
if (!$chunk)
{
return false ;
}
$chunk = trim( $chunk ) ;
if ( preg_match( "/<!DOCTYPE\W*X?HTML/sim", $chunk ) )
{
return true;
}
$tags = array( '<body', '<head', '<html', '<img', '<pre', '<script', '<table', '<title' ) ;
foreach( $tags as $tag )
{
if( false !== strpos( $chunk, $tag ) )
{
return true ;
}
}
//type = javascript
if ( preg_match( '!type\s*=\s*[\'"]?\s*(?:\w*/)?(?:ecma|java)!sim', $chunk ) )
{
return true ;
}
//href = javascript
//src = javascript
//data = javascript
if ( preg_match( '!(?:href|src|data)\s*=\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk ) )
{
return true ;
}
//url(javascript
if ( preg_match( '!url\s*\(\s*[\'"]?\s*(?:ecma|java)script:!sim', $chunk ) )
{
return true ;
}
return false ;
}
/**
* Check file content.
* Currently this function validates only image files.
* Returns false if file is invalid.
*
* @param string $filePath absolute path to file
* @param string $extension file extension
* @param integer $detectionLevel 0 = none, 1 = use getimagesize for images, 2 = use DetectHtml for images
* @return boolean
*/
function IsImageValid( $filePath, $extension )
{
if (!@is_readable($filePath)) {
return -1;
}
$imageCheckExtensions = array('gif', 'jpeg', 'jpg', 'png', 'swf', 'psd', 'bmp', 'iff');
// version_compare is available since PHP4 >= 4.0.7
if ( function_exists( 'version_compare' ) ) {
$sCurrentVersion = phpversion();
if ( version_compare( $sCurrentVersion, "4.2.0" ) >= 0 ) {
$imageCheckExtensions[] = "tiff";
$imageCheckExtensions[] = "tif";
}
if ( version_compare( $sCurrentVersion, "4.3.0" ) >= 0 ) {
$imageCheckExtensions[] = "swc";
}
if ( version_compare( $sCurrentVersion, "4.3.2" ) >= 0 ) {
$imageCheckExtensions[] = "jpc";
$imageCheckExtensions[] = "jp2";
$imageCheckExtensions[] = "jpx";
$imageCheckExtensions[] = "jb2";
$imageCheckExtensions[] = "xbm";
$imageCheckExtensions[] = "wbmp";
}
}
if ( !in_array( $extension, $imageCheckExtensions ) ) {
return true;
}
if ( @getimagesize( $filePath ) === false ) {
return false ;
}
return true;
}
?>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/connectors/php/util.php | PHP | asf20 | 5,188 |
<?php
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* These functions define the base of the XML response sent by the PHP
* connector.
*/
function SetXmlHeaders()
{
ob_end_clean() ;
// Prevent the browser from caching the result.
// Date in the past
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT') ;
// always modified
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT') ;
// HTTP/1.1
header('Cache-Control: no-store, no-cache, must-revalidate') ;
header('Cache-Control: post-check=0, pre-check=0', false) ;
// HTTP/1.0
header('Pragma: no-cache') ;
// Set the response format.
header( 'Content-Type: text/xml; charset=utf-8' ) ;
}
function CreateXmlHeader( $command, $resourceType, $currentFolder )
{
SetXmlHeaders() ;
// Create the XML document header.
echo '<?xml version="1.0" encoding="utf-8" ?>' ;
// Create the main "Connector" node.
echo '<Connector command="' . $command . '" resourceType="' . $resourceType . '">' ;
// Add the current folder node.
echo '<CurrentFolder path="' . ConvertToXmlAttribute( $currentFolder ) . '" url="' . ConvertToXmlAttribute( GetUrlFromPath( $resourceType, $currentFolder, $command ) ) . '" />' ;
$GLOBALS['HeaderSent'] = true ;
}
function CreateXmlFooter()
{
echo '</Connector>' ;
}
function SendError( $number, $text )
{
if ( isset( $GLOBALS['HeaderSent'] ) && $GLOBALS['HeaderSent'] )
{
SendErrorNode( $number, $text ) ;
CreateXmlFooter() ;
}
else
{
SetXmlHeaders() ;
// Create the XML document header
echo '<?xml version="1.0" encoding="utf-8" ?>' ;
echo '<Connector>' ;
SendErrorNode( $number, $text ) ;
echo '</Connector>' ;
}
exit ;
}
function SendErrorNode( $number, $text )
{
echo '<Error number="' . $number . '" text="' . htmlspecialchars( $text ) . '" />' ;
}
?>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/connectors/php/basexml.php | PHP | asf20 | 2,443 |
<?php
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* Configuration file for the File Manager Connector for PHP.
*/
global $Config ;
// SECURITY: You must explicitly enable this "connector". (Set it to "true").
// WARNING: don't just set "$Config['Enabled'] = true ;", you must be sure that only
// authenticated users can access this file or use some kind of session checking.
$Config['Enabled'] = true ;
// Path to user files relative to the document root.
$Config['UserFilesPath'] = '/public/upload/'.date('Y').'/'.date('m').'/'.date('d') .'/' ;
// Fill the following value it you prefer to specify the absolute path for the
// user files directory. Useful if you are using a virtual directory, symbolic
// link or alias. Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
// Attention: The above 'UserFilesPath' must point to the same directory.
$Config['UserFilesAbsolutePath'] = '' ;
// Due to security issues with Apache modules, it is recommended to leave the
// following setting enabled.
$Config['ForceSingleExtension'] = true ;
// Perform additional checks for image files.
// If set to true, validate image size (using getimagesize).
$Config['SecureImageUploads'] = true;
// What the user can do with this connector.
$Config['ConfigAllowedCommands'] = array('QuickUpload', 'FileUpload', 'GetFolders', 'GetFoldersAndFiles', 'CreateFolder') ;
// Allowed Resource Types.
$Config['ConfigAllowedTypes'] = array('File', 'Image', 'Flash', 'Media') ;
// For security, HTML is allowed in the first Kb of data for files having the
// following extensions only.
$Config['HtmlExtensions'] = array("html", "htm", "xml", "xsd", "txt", "js") ;
// After file is uploaded, sometimes it is required to change its permissions
// so that it was possible to access it at the later time.
// If possible, it is recommended to set more restrictive permissions, like 0755.
// Set to 0 to disable this feature.
// Note: not needed on Windows-based servers.
$Config['ChmodOnUpload'] = 0777 ;
// See comments above.
// Used when creating folders that does not exist.
$Config['ChmodOnFolderCreate'] = 0777 ;
/*
Configuration settings for each Resource Type
- AllowedExtensions: the possible extensions that can be allowed.
If it is empty then any file type can be uploaded.
- DeniedExtensions: The extensions that won't be allowed.
If it is empty then no restrictions are done here.
For a file to be uploaded it has to fulfill both the AllowedExtensions
and DeniedExtensions (that's it: not being denied) conditions.
- FileTypesPath: the virtual folder relative to the document root where
these resources will be located.
Attention: It must start and end with a slash: '/'
- FileTypesAbsolutePath: the physical path to the above folder. It must be
an absolute path.
If it's an empty string then it will be autocalculated.
Useful if you are using a virtual directory, symbolic link or alias.
Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
Attention: The above 'FileTypesPath' must point to the same directory.
Attention: It must end with a slash: '/'
- QuickUploadPath: the virtual folder relative to the document root where
these resources will be uploaded using the Upload tab in the resources
dialogs.
Attention: It must start and end with a slash: '/'
- QuickUploadAbsolutePath: the physical path to the above folder. It must be
an absolute path.
If it's an empty string then it will be autocalculated.
Useful if you are using a virtual directory, symbolic link or alias.
Examples: 'C:\\MySite\\userfiles\\' or '/root/mysite/userfiles/'.
Attention: The above 'QuickUploadPath' must point to the same directory.
Attention: It must end with a slash: '/'
NOTE: by default, QuickUploadPath and QuickUploadAbsolutePath point to
"userfiles" directory to maintain backwards compatibility with older versions of FCKeditor.
This is fine, but you in some cases you will be not able to browse uploaded files using file browser.
Example: if you click on "image button", select "Upload" tab and send image
to the server, image will appear in FCKeditor correctly, but because it is placed
directly in /userfiles/ directory, you'll be not able to see it in built-in file browser.
The more expected behaviour would be to send images directly to "image" subfolder.
To achieve that, simply change
$Config['QuickUploadPath']['Image'] = $Config['UserFilesPath'] ;
$Config['QuickUploadAbsolutePath']['Image'] = $Config['UserFilesAbsolutePath'] ;
into:
$Config['QuickUploadPath']['Image'] = $Config['FileTypesPath']['Image'] ;
$Config['QuickUploadAbsolutePath']['Image'] = $Config['FileTypesAbsolutePath']['Image'] ;
*/
$Config['AllowedExtensions']['File'] = array('7z', 'aiff', 'asf', 'avi', 'bmp', 'csv', 'doc', 'fla', 'flv', 'gif', 'gz', 'gzip', 'jpeg', 'jpg', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'ods', 'odt', 'pdf', 'png', 'ppt', 'pxd', 'qt', 'ram', 'rar', 'rm', 'rmi', 'rmvb', 'rtf', 'sdc', 'sitd', 'swf', 'sxc', 'sxw', 'tar', 'tgz', 'tif', 'tiff', 'txt', 'vsd', 'wav', 'wma', 'wmv', 'xls', 'xml', 'zip') ;
$Config['DeniedExtensions']['File'] = array() ;
$Config['FileTypesPath']['File'] = $Config['UserFilesPath'] . 'file/' ;
$Config['FileTypesAbsolutePath']['File']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'file/' ;
$Config['QuickUploadPath']['File'] = $Config['UserFilesPath'] ;
$Config['QuickUploadAbsolutePath']['File']= $Config['UserFilesAbsolutePath'] ;
$Config['AllowedExtensions']['Image'] = array('bmp','gif','jpeg','jpg','png') ;
$Config['DeniedExtensions']['Image'] = array() ;
$Config['FileTypesPath']['Image'] = $Config['UserFilesPath'] . 'image/' ;
$Config['FileTypesAbsolutePath']['Image']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'image/' ;
$Config['QuickUploadPath']['Image'] = $Config['UserFilesPath'] ;
$Config['QuickUploadAbsolutePath']['Image']= $Config['UserFilesAbsolutePath'] ;
$Config['AllowedExtensions']['Flash'] = array('swf','flv') ;
$Config['DeniedExtensions']['Flash'] = array() ;
$Config['FileTypesPath']['Flash'] = $Config['UserFilesPath'] . 'flash/' ;
$Config['FileTypesAbsolutePath']['Flash']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'flash/' ;
$Config['QuickUploadPath']['Flash'] = $Config['UserFilesPath'] ;
$Config['QuickUploadAbsolutePath']['Flash']= $Config['UserFilesAbsolutePath'] ;
$Config['AllowedExtensions']['Media'] = array('aiff', 'asf', 'avi', 'bmp', 'fla', 'flv', 'gif', 'jpeg', 'jpg', 'mid', 'mov', 'mp3', 'mp4', 'mpc', 'mpeg', 'mpg', 'png', 'qt', 'ram', 'rm', 'rmi', 'rmvb', 'swf', 'tif', 'tiff', 'wav', 'wma', 'wmv') ;
$Config['DeniedExtensions']['Media'] = array() ;
$Config['FileTypesPath']['Media'] = $Config['UserFilesPath'] . 'media/' ;
$Config['FileTypesAbsolutePath']['Media']= ($Config['UserFilesAbsolutePath'] == '') ? '' : $Config['UserFilesAbsolutePath'].'media/' ;
$Config['QuickUploadPath']['Media'] = $Config['UserFilesPath'] ;
$Config['QuickUploadAbsolutePath']['Media']= $Config['UserFilesAbsolutePath'] ;
?>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/connectors/php/config.php | PHP | asf20 | 7,864 |
<?php
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* This is the File Manager Connector for PHP.
*/
ob_start() ;
require('./config.php') ;
require('./util.php') ;
require('./io.php') ;
require('./basexml.php') ;
require('./commands.php') ;
require('./phpcompat.php') ;
if ( !$Config['Enabled'] )
SendError( 1, 'This connector is disabled. Please check the "editor/filemanager/connectors/php/config.php" file' ) ;
DoResponse() ;
function DoResponse()
{
if (!isset($_GET)) {
global $_GET;
}
if ( !isset( $_GET['Command'] ) || !isset( $_GET['Type'] ) || !isset( $_GET['CurrentFolder'] ) )
return ;
// Get the main request informaiton.
$sCommand = $_GET['Command'] ;
$sResourceType = $_GET['Type'] ;
$sCurrentFolder = GetCurrentFolder() ;
// Check if it is an allowed command
if ( ! IsAllowedCommand( $sCommand ) )
SendError( 1, 'The "' . $sCommand . '" command isn\'t allowed' ) ;
// Check if it is an allowed type.
if ( !IsAllowedType( $sResourceType ) )
SendError( 1, 'Invalid type specified' ) ;
// File Upload doesn't have to Return XML, so it must be intercepted before anything.
if ( $sCommand == 'FileUpload' )
{
FileUpload( $sResourceType, $sCurrentFolder, $sCommand ) ;
return ;
}
CreateXmlHeader( $sCommand, $sResourceType, $sCurrentFolder ) ;
// Execute the required command.
switch ( $sCommand )
{
case 'GetFolders' :
GetFolders( $sResourceType, $sCurrentFolder ) ;
break ;
case 'GetFoldersAndFiles' :
GetFoldersAndFiles( $sResourceType, $sCurrentFolder ) ;
break ;
case 'CreateFolder' :
CreateFolder( $sResourceType, $sCurrentFolder ) ;
break ;
}
CreateXmlFooter() ;
exit ;
}
?>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/connectors/php/connector.php | PHP | asf20 | 2,324 |
<?php
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* This is the File Manager Connector for PHP.
*/
function CombinePaths( $sBasePath, $sFolder )
{
return RemoveFromEnd( $sBasePath, '/' ) . '/' . RemoveFromStart( $sFolder, '/' ) ;
}
function GetResourceTypePath( $resourceType, $sCommand )
{
global $Config ;
if ( $sCommand == "QuickUpload")
return $Config['QuickUploadPath'][$resourceType] ;
else
return $Config['FileTypesPath'][$resourceType] ;
}
function GetResourceTypeDirectory( $resourceType, $sCommand )
{
global $Config ;
if ( $sCommand == "QuickUpload")
{
if ( strlen( $Config['QuickUploadAbsolutePath'][$resourceType] ) > 0 )
return $Config['QuickUploadAbsolutePath'][$resourceType] ;
// Map the "UserFiles" path to a local directory.
return Server_MapPath( $Config['QuickUploadPath'][$resourceType] ) ;
}
else
{
if ( strlen( $Config['FileTypesAbsolutePath'][$resourceType] ) > 0 )
return $Config['FileTypesAbsolutePath'][$resourceType] ;
// Map the "UserFiles" path to a local directory.
return Server_MapPath( $Config['FileTypesPath'][$resourceType] ) ;
}
}
function GetUrlFromPath( $resourceType, $folderPath, $sCommand )
{
return CombinePaths( GetResourceTypePath( $resourceType, $sCommand ), $folderPath ) ;
}
function RemoveExtension( $fileName )
{
return substr( $fileName, 0, strrpos( $fileName, '.' ) ) ;
}
function ServerMapFolder( $resourceType, $folderPath, $sCommand )
{
// Get the resource type directory.
$sResourceTypePath = GetResourceTypeDirectory( $resourceType, $sCommand ) ;
// Ensure that the directory exists.
$sErrorMsg = CreateServerFolder( $sResourceTypePath ) ;
if ( $sErrorMsg != '' )
SendError( 1, "Error creating folder \"{$sResourceTypePath}\" ({$sErrorMsg})" ) ;
// Return the resource type directory combined with the required path.
return CombinePaths( $sResourceTypePath , $folderPath ) ;
}
function GetParentFolder( $folderPath )
{
$sPattern = "-[/\\\\][^/\\\\]+[/\\\\]?$-" ;
return preg_replace( $sPattern, '', $folderPath ) ;
}
function CreateServerFolder( $folderPath, $lastFolder = null )
{
global $Config ;
$sParent = GetParentFolder( $folderPath ) ;
// Ensure the folder path has no double-slashes, or mkdir may fail on certain platforms
while ( strpos($folderPath, '//') !== false )
{
$folderPath = str_replace( '//', '/', $folderPath ) ;
}
// Check if the parent exists, or create it.
if ( !file_exists( $sParent ) )
{
//prevents agains infinite loop when we can't create root folder
if ( !is_null( $lastFolder ) && $lastFolder === $sParent) {
return "Can't create $folderPath directory" ;
}
$sErrorMsg = CreateServerFolder( $sParent, $folderPath ) ;
if ( $sErrorMsg != '' )
return $sErrorMsg ;
}
if ( !file_exists( $folderPath ) )
{
// Turn off all error reporting.
error_reporting( 0 ) ;
$php_errormsg = '' ;
// Enable error tracking to catch the error.
ini_set( 'track_errors', '1' ) ;
if ( isset( $Config['ChmodOnFolderCreate'] ) && !$Config['ChmodOnFolderCreate'] )
{
mkdir( $folderPath ) ;
}
else
{
$permissions = 0777 ;
if ( isset( $Config['ChmodOnFolderCreate'] ) )
{
$permissions = $Config['ChmodOnFolderCreate'] ;
}
// To create the folder with 0777 permissions, we need to set umask to zero.
$oldumask = umask(0) ;
mkdir( $folderPath, $permissions ) ;
umask( $oldumask ) ;
}
$sErrorMsg = $php_errormsg ;
// Restore the configurations.
ini_restore( 'track_errors' ) ;
ini_restore( 'error_reporting' ) ;
return $sErrorMsg ;
}
else
return '' ;
}
function GetRootPath()
{
if (!isset($_SERVER)) {
global $_SERVER;
}
$sRealPath = realpath( './' ) ;
// #2124 ensure that no slash is at the end
$sRealPath = rtrim($sRealPath,"\\/");
$sSelfPath = $_SERVER['PHP_SELF'] ;
$sSelfPath = substr( $sSelfPath, 0, strrpos( $sSelfPath, '/' ) ) ;
$sSelfPath = str_replace( '/', DIRECTORY_SEPARATOR, $sSelfPath ) ;
$position = strpos( $sRealPath, $sSelfPath ) ;
// This can check only that this script isn't run from a virtual dir
// But it avoids the problems that arise if it isn't checked
if ( $position === false || $position <> strlen( $sRealPath ) - strlen( $sSelfPath ) )
SendError( 1, 'Sorry, can\'t map "UserFilesPath" to a physical path. You must set the "UserFilesAbsolutePath" value in "editor/filemanager/connectors/php/config.php".' ) ;
return substr( $sRealPath, 0, $position ) ;
}
// Emulate the asp Server.mapPath function.
// given an url path return the physical directory that it corresponds to
function Server_MapPath( $path )
{
// This function is available only for Apache
if ( function_exists( 'apache_lookup_uri' ) )
{
$info = apache_lookup_uri( $path ) ;
return $info->filename . $info->path_info ;
}
// This isn't correct but for the moment there's no other solution
// If this script is under a virtual directory or symlink it will detect the problem and stop
return GetRootPath() . $path ;
}
function IsAllowedExt( $sExtension, $resourceType )
{
global $Config ;
// Get the allowed and denied extensions arrays.
$arAllowed = $Config['AllowedExtensions'][$resourceType] ;
$arDenied = $Config['DeniedExtensions'][$resourceType] ;
if ( count($arAllowed) > 0 && !in_array( $sExtension, $arAllowed ) )
return false ;
if ( count($arDenied) > 0 && in_array( $sExtension, $arDenied ) )
return false ;
return true ;
}
function IsAllowedType( $resourceType )
{
global $Config ;
if ( !in_array( $resourceType, $Config['ConfigAllowedTypes'] ) )
return false ;
return true ;
}
function IsAllowedCommand( $sCommand )
{
global $Config ;
if ( !in_array( $sCommand, $Config['ConfigAllowedCommands'] ) )
return false ;
return true ;
}
function GetCurrentFolder()
{
if (!isset($_GET)) {
global $_GET;
}
$sCurrentFolder = isset( $_GET['CurrentFolder'] ) ? $_GET['CurrentFolder'] : '/' ;
// Check the current folder syntax (must begin and start with a slash).
if ( !preg_match( '|/$|', $sCurrentFolder ) )
$sCurrentFolder .= '/' ;
if ( strpos( $sCurrentFolder, '/' ) !== 0 )
$sCurrentFolder = '/' . $sCurrentFolder ;
// Ensure the folder path has no double-slashes
while ( strpos ($sCurrentFolder, '//') !== false ) {
$sCurrentFolder = str_replace ('//', '/', $sCurrentFolder) ;
}
// Check for invalid folder paths (..)
if ( strpos( $sCurrentFolder, '..' ) || strpos( $sCurrentFolder, "\\" ))
SendError( 102, '' ) ;
return $sCurrentFolder ;
}
// Do a cleanup of the folder name to avoid possible problems
function SanitizeFolderName( $sNewFolderName )
{
$sNewFolderName = stripslashes( $sNewFolderName ) ;
// Remove . \ / | : ? * " < >
$sNewFolderName = preg_replace( '/\\.|\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFolderName ) ;
return $sNewFolderName ;
}
// Do a cleanup of the file name to avoid possible problems
function SanitizeFileName( $sNewFileName )
{
global $Config ;
$sNewFileName = stripslashes( $sNewFileName ) ;
// Replace dots in the name with underscores (only one dot can be there... security issue).
if ( $Config['ForceSingleExtension'] )
$sNewFileName = preg_replace( '/\\.(?![^.]*$)/', '_', $sNewFileName ) ;
// Remove \ / | : ? * " < >
$sNewFileName = preg_replace( '/\\\\|\\/|\\||\\:|\\?|\\*|"|<|>|[[:cntrl:]]/', '_', $sNewFileName ) ;
return $sNewFileName ;
}
// This is the function that sends the results of the uploading process.
function SendUploadResults( $errorNumber, $fileUrl = '', $fileName = '', $customMsg = '' )
{
// Minified version of the document.domain automatic fix script (#1919).
// The original script can be found at _dev/domain_fix_template.js
echo <<<EOF
<script type="text/javascript">
(function(){var d=document.domain;while (true){try{var A=window.parent.document.domain;break;}catch(e) {};d=d.replace(/.*?(?:\.|$)/,'');if (d.length==0) break;try{document.domain=d;}catch (e){break;}}})();
EOF;
$rpl = array( '\\' => '\\\\', '"' => '\\"' ) ;
echo 'window.parent.OnUploadCompleted(' . $errorNumber . ',"' . strtr( $fileUrl, $rpl ) . '","' . strtr( $fileName, $rpl ) . '", "' . strtr( $customMsg, $rpl ) . '") ;' ;
echo '</script>' ;
exit ;
}
?>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/connectors/php/io.php | PHP | asf20 | 9,007 |
<?php
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* This is the File Manager Connector for PHP.
*/
function GetFolders( $resourceType, $currentFolder )
{
// Map the virtual path to the local server path.
$sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'GetFolders' ) ;
// Array that will hold the folders names.
$aFolders = array() ;
$oCurrentFolder = opendir( $sServerDir ) ;
while ( $sFile = readdir( $oCurrentFolder ) )
{
if ( $sFile != '.' && $sFile != '..' && is_dir( $sServerDir . $sFile ) )
$aFolders[] = '<Folder name="' . ConvertToXmlAttribute( $sFile ) . '" />' ;
}
closedir( $oCurrentFolder ) ;
// Open the "Folders" node.
echo "<Folders>" ;
natcasesort( $aFolders ) ;
foreach ( $aFolders as $sFolder )
echo $sFolder ;
// Close the "Folders" node.
echo "</Folders>" ;
}
function GetFoldersAndFiles( $resourceType, $currentFolder )
{
// Map the virtual path to the local server path.
$sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'GetFoldersAndFiles' ) ;
// Arrays that will hold the folders and files names.
$aFolders = array() ;
$aFiles = array() ;
$oCurrentFolder = opendir( $sServerDir ) ;
while ( $sFile = readdir( $oCurrentFolder ) )
{
if ( $sFile != '.' && $sFile != '..' )
{
if ( is_dir( $sServerDir . $sFile ) )
$aFolders[] = '<Folder name="' . ConvertToXmlAttribute( $sFile ) . '" />' ;
else
{
$iFileSize = @filesize( $sServerDir . $sFile ) ;
if ( !$iFileSize ) {
$iFileSize = 0 ;
}
if ( $iFileSize > 0 )
{
$iFileSize = round( $iFileSize / 1024 ) ;
if ( $iFileSize < 1 ) $iFileSize = 1 ;
}
$aFiles[] = '<File name="' . ConvertToXmlAttribute( $sFile ) . '" size="' . $iFileSize . '" />' ;
}
}
}
// Send the folders
natcasesort( $aFolders ) ;
echo '<Folders>' ;
foreach ( $aFolders as $sFolder )
echo $sFolder ;
echo '</Folders>' ;
// Send the files
natcasesort( $aFiles ) ;
echo '<Files>' ;
foreach ( $aFiles as $sFiles )
echo $sFiles ;
echo '</Files>' ;
}
function CreateFolder( $resourceType, $currentFolder )
{
if (!isset($_GET)) {
global $_GET;
}
$sErrorNumber = '0' ;
$sErrorMsg = '' ;
if ( isset( $_GET['NewFolderName'] ) )
{
$sNewFolderName = $_GET['NewFolderName'] ;
$sNewFolderName = SanitizeFolderName( $sNewFolderName ) ;
if ( strpos( $sNewFolderName, '..' ) !== FALSE )
$sErrorNumber = '102' ; // Invalid folder name.
else
{
// Map the virtual path to the local server path of the current folder.
$sServerDir = ServerMapFolder( $resourceType, $currentFolder, 'CreateFolder' ) ;
if ( is_writable( $sServerDir ) )
{
$sServerDir .= $sNewFolderName ;
$sErrorMsg = CreateServerFolder( $sServerDir ) ;
switch ( $sErrorMsg )
{
case '' :
$sErrorNumber = '0' ;
break ;
case 'Invalid argument' :
case 'No such file or directory' :
$sErrorNumber = '102' ; // Path too long.
break ;
default :
$sErrorNumber = '110' ;
break ;
}
}
else
$sErrorNumber = '103' ;
}
}
else
$sErrorNumber = '102' ;
// Create the "Error" node.
echo '<Error number="' . $sErrorNumber . '" originalDescription="' . ConvertToXmlAttribute( $sErrorMsg ) . '" />' ;
}
function FileUpload( $resourceType, $currentFolder, $sCommand )
{
if (!isset($_FILES)) {
global $_FILES;
}
$sErrorNumber = '0' ;
$sFileName = '' ;
if ( isset( $_FILES['NewFile'] ) && !is_null( $_FILES['NewFile']['tmp_name'] ) )
{
global $Config ;
$oFile = $_FILES['NewFile'] ;
// Map the virtual path to the local server path.
$sServerDir = ServerMapFolder( $resourceType, $currentFolder, $sCommand ) ;
// Get the uploaded file name.
//$sFileName = $oFile['name'] ;
$sFileName = date('His').'01'.substr( $oFile['name'], ( strrpos($oFile['name'], '.') ) ) ;
$sFileName = SanitizeFileName( $sFileName ) ;
$sOriginalFileName = $sFileName ;
// Get the extension.
$sExtension = substr( $sFileName, ( strrpos($sFileName, '.') + 1 ) ) ;
$sExtension = strtolower( $sExtension ) ;
if ( isset( $Config['SecureImageUploads'] ) )
{
if ( ( $isImageValid = IsImageValid( $oFile['tmp_name'], $sExtension ) ) === false )
{
$sErrorNumber = '202' ;
}
}
if ( isset( $Config['HtmlExtensions'] ) )
{
if ( !IsHtmlExtension( $sExtension, $Config['HtmlExtensions'] ) &&
( $detectHtml = DetectHtml( $oFile['tmp_name'] ) ) === true )
{
$sErrorNumber = '202' ;
}
}
// Check if it is an allowed extension.
if ( !$sErrorNumber && IsAllowedExt( $sExtension, $resourceType ) )
{
$iCounter = 0 ;
while ( true )
{
$sFilePath = $sServerDir . $sFileName ;
if ( is_file( $sFilePath ) )
{
$iCounter++ ;
//$sFileName = RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension ;
$sFileName = RemoveExtension( $sOriginalFileName ) . '(' . $iCounter . ').' . $sExtension ;
$sErrorNumber = '201' ;
}
else
{
move_uploaded_file( $oFile['tmp_name'], $sFilePath ) ;
if ( is_file( $sFilePath ) )
{
if ( isset( $Config['ChmodOnUpload'] ) && !$Config['ChmodOnUpload'] )
{
break ;
}
$permissions = 0777;
if ( isset( $Config['ChmodOnUpload'] ) && $Config['ChmodOnUpload'] )
{
$permissions = $Config['ChmodOnUpload'] ;
}
$oldumask = umask(0) ;
chmod( $sFilePath, $permissions ) ;
umask( $oldumask ) ;
}
break ;
}
}
if ( file_exists( $sFilePath ) )
{
//previous checks failed, try once again
if ( isset( $isImageValid ) && $isImageValid === -1 && IsImageValid( $sFilePath, $sExtension ) === false )
{
@unlink( $sFilePath ) ;
$sErrorNumber = '202' ;
}
else if ( isset( $detectHtml ) && $detectHtml === -1 && DetectHtml( $sFilePath ) === true )
{
@unlink( $sFilePath ) ;
$sErrorNumber = '202' ;
}
}
}
else
$sErrorNumber = '202' ;
}
else
$sErrorNumber = '202' ;
$sFileUrl = CombinePaths( GetResourceTypePath( $resourceType, $sCommand ) , $currentFolder ) ;
$sFileUrl = CombinePaths( $sFileUrl, $sFileName ) ;
SendUploadResults( $sErrorNumber, $sFileUrl, $sFileName ) ;
exit ;
}
?>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/connectors/php/commands.php | PHP | asf20 | 7,077 |
<?php
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* This is the "File Uploader" for PHP.
*/
require('./config.php') ;
require('./util.php') ;
require('./io.php') ;
require('./commands.php') ;
require('./phpcompat.php') ;
function SendError( $number, $text )
{
SendUploadResults( $number, '', '', $text ) ;
}
// Check if this uploader has been enabled.
if ( !$Config['Enabled'] )
SendUploadResults( '1', '', '', 'This file uploader is disabled. Please check the "editor/filemanager/connectors/php/config.php" file' ) ;
$sCommand = 'QuickUpload' ;
// The file type (from the QueryString, by default 'File').
$sType = isset( $_GET['Type'] ) ? $_GET['Type'] : 'File' ;
$sCurrentFolder = GetCurrentFolder() ;
// Is enabled the upload?
if ( ! IsAllowedCommand( $sCommand ) )
SendUploadResults( '1', '', '', 'The ""' . $sCommand . '"" command isn\'t allowed' ) ;
// Check if it is an allowed type.
if ( !IsAllowedType( $sType ) )
SendUploadResults( 1, '', '', 'Invalid type specified' ) ;
FileUpload( $sType, $sCurrentFolder, $sCommand )
?>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/connectors/php/upload.php | PHP | asf20 | 1,676 |
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* Test page for the "File Uploaders".
-->
<html>
<head>
<title>FCKeditor - Uploaders Tests</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
// Automatically detect the correct document.domain (#1919).
(function()
{
var d = document.domain ;
while ( true )
{
// Test if we can access a parent property.
try
{
var test = window.opener.document.domain ;
break ;
}
catch( e ) {}
// Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
d = d.replace( /.*?(?:\.|$)/, '' ) ;
if ( d.length == 0 )
break ; // It was not able to detect the domain.
try
{
document.domain = d ;
}
catch (e)
{
break ;
}
}
})() ;
function SendFile()
{
var sUploaderUrl = cmbUploaderUrl.value ;
if ( sUploaderUrl.length == 0 )
sUploaderUrl = txtCustomUrl.value ;
if ( sUploaderUrl.length == 0 )
{
alert( 'Please provide your custom URL or select a default one' ) ;
return ;
}
eURL.innerHTML = sUploaderUrl ;
txtUrl.value = '' ;
var date = new Date()
frmUpload.action = sUploaderUrl + '?time=' + date.getTime();
if (document.getElementById('cmbType').value) {
frmUpload.action = frmUpload.action + '&Type='+document.getElementById('cmbType').value;
}
if (document.getElementById('CurrentFolder').value) {
frmUpload.action = frmUpload.action + '&CurrentFolder='+document.getElementById('CurrentFolder').value;
}
frmUpload.submit() ;
}
function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
{
switch ( errorNumber )
{
case 0 : // No errors
txtUrl.value = fileUrl ;
alert( 'File uploaded with no errors' ) ;
break ;
case 1 : // Custom error
alert( customMsg ) ;
break ;
case 10 : // Custom warning
txtUrl.value = fileUrl ;
alert( customMsg ) ;
break ;
case 201 :
txtUrl.value = fileUrl ;
alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
break ;
case 202 :
alert( 'Invalid file' ) ;
break ;
case 203 :
alert( "Security error. You probably don't have enough permissions to upload. Please check your server." ) ;
break ;
default :
alert( 'Error on file upload. Error number: ' + errorNumber ) ;
break ;
}
}
</script>
</head>
<body>
<table cellSpacing="0" cellPadding="0" width="100%" border="0" height="100%">
<tr>
<td>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td nowrap>
Select the "File Uploader" to use: <br>
<select id="cmbUploaderUrl">
<option selected value="asp/upload.asp">ASP</option>
<option value="aspx/upload.aspx">ASP.Net</option>
<option value="cfm/upload.cfm">ColdFusion</option>
<option value="lasso/upload.lasso">Lasso</option>
<option value="perl/upload.cgi">Perl</option>
<option value="php/upload.php">PHP</option>
<option value="py/upload.py">Python</option>
<option value="">(Custom)</option>
</select>
</td>
<td>
Resource Type<br />
<select id="cmbType" name="cmbType">
<option value="">None</option>
<option value="File">File</option>
<option value="Image">Image</option>
<option value="Flash">Flash</option>
<option value="Media">Media</option>
<option value="Invalid">Invalid Type (for testing)</option>
</select>
</td>
<td>
Current Folder: <br>
<input type="text" name="CurrentFolder" id="CurrentFolder" value="/">
</td>
<td nowrap> </td>
<td width="100%">
Custom Uploader URL:<BR>
<input id="txtCustomUrl" style="WIDTH: 100%; BACKGROUND-COLOR: #dcdcdc" disabled type="text">
</td>
</tr>
</table>
<br>
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td noWrap>
<form id="frmUpload" target="UploadWindow" enctype="multipart/form-data" action="" method="post">
Upload a new file:<br>
<input type="file" name="NewFile"><br>
<input type="button" value="Send it to the Server" onclick="SendFile();">
</form>
</td>
<td style="WIDTH: 16px"> </td>
<td vAlign="top" width="100%">
Uploaded File URL:<br>
<INPUT id="txtUrl" style="WIDTH: 100%" readonly type="text">
</td>
</tr>
</table>
<br>
Post URL: <span id="eURL"> </span>
</td>
</tr>
<tr>
<td height="100%">
<iframe name="UploadWindow" width="100%" height="100%" src="javascript:void(0)"></iframe>
</td>
</tr>
</table>
</body>
</html>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/connectors/uploadtest.html | HTML | asf20 | 5,580 |
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* Test page for the File Browser connectors.
-->
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>FCKeditor - Connectors Tests</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
// Automatically detect the correct document.domain (#1919).
(function()
{
var d = document.domain ;
while ( true )
{
// Test if we can access a parent property.
try
{
var test = window.opener.document.domain ;
break ;
}
catch( e ) {}
// Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
d = d.replace( /.*?(?:\.|$)/, '' ) ;
if ( d.length == 0 )
break ; // It was not able to detect the domain.
try
{
document.domain = d ;
}
catch (e)
{
break ;
}
}
})() ;
function BuildBaseUrl( command )
{
var sUrl =
document.getElementById('cmbConnector').value +
'?Command=' + command +
'&Type=' + document.getElementById('cmbType').value +
'&CurrentFolder=' + encodeURIComponent(document.getElementById('txtFolder').value) ;
return sUrl ;
}
function SetFrameUrl( url )
{
document.getElementById('eRunningFrame').src = url ;
document.getElementById('eUrl').innerHTML = url ;
}
function GetFolders()
{
SetFrameUrl( BuildBaseUrl( 'GetFolders' ) ) ;
return false ;
}
function GetFoldersAndFiles()
{
SetFrameUrl( BuildBaseUrl( 'GetFoldersAndFiles' ) ) ;
return false ;
}
function CreateFolder()
{
var sFolder = prompt( 'Type the folder name:', 'Test Folder' ) ;
if ( ! sFolder )
return false ;
var sUrl = BuildBaseUrl( 'CreateFolder' ) ;
sUrl += '&NewFolderName=' + encodeURIComponent( sFolder ) ;
SetFrameUrl( sUrl ) ;
return false ;
}
function OnUploadCompleted( errorNumber, fileName )
{
switch ( errorNumber )
{
case 0 :
alert( 'File uploaded with no errors' ) ;
break ;
case 201 :
GetFoldersAndFiles() ;
alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + fileName + '"' ) ;
break ;
case 202 :
alert( 'Invalid file' ) ;
break ;
default :
alert( 'Error on file upload. Error number: ' + errorNumber ) ;
break ;
}
}
this.frames.frmUpload = this ;
function SetAction()
{
var sUrl = BuildBaseUrl( 'FileUpload' ) ;
document.getElementById('eUrl').innerHTML = sUrl ;
document.getElementById('frmUpload').action = sUrl ;
}
</script>
</head>
<body>
<table height="100%" cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td>
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td>
Connector:<br />
<select id="cmbConnector" name="cmbConnector">
<option value="asp/connector.asp" selected="selected">ASP</option>
<option value="aspx/connector.aspx">ASP.Net</option>
<option value="cfm/connector.cfm">ColdFusion</option>
<option value="lasso/connector.lasso">Lasso</option>
<option value="perl/connector.cgi">Perl</option>
<option value="php/connector.php">PHP</option>
<option value="py/connector.py">Python</option>
</select>
</td>
<td>
</td>
<td>
Current Folder<br />
<input id="txtFolder" type="text" value="/" name="txtFolder" /></td>
<td>
</td>
<td>
Resource Type<br />
<select id="cmbType" name="cmbType">
<option value="File" selected="selected">File</option>
<option value="Image">Image</option>
<option value="Flash">Flash</option>
<option value="Media">Media</option>
<option value="Invalid">Invalid Type (for testing)</option>
</select>
</td>
</tr>
</table>
<br />
<table cellspacing="0" cellpadding="0" border="0">
<tr>
<td valign="top">
<a href="#" onClick="GetFolders();">Get Folders</a></td>
<td>
</td>
<td valign="top">
<a href="#" onClick="GetFoldersAndFiles();">Get Folders and Files</a></td>
<td>
</td>
<td valign="top">
<a href="#" onClick="CreateFolder();">Create Folder</a></td>
<td>
</td>
<td valign="top">
<form id="frmUpload" action="" target="eRunningFrame" method="post" enctype="multipart/form-data">
File Upload<br />
<input id="txtFileUpload" type="file" name="NewFile" />
<input type="submit" value="Upload" onClick="SetAction();" />
</form>
</td>
</tr>
</table>
<br />
URL: <span id="eUrl"></span>
</td>
</tr>
<tr>
<td height="100%" valign="top">
<iframe id="eRunningFrame" src="javascript:void(0)" name="eRunningFrame" width="100%"
height="100%"></iframe>
</td>
</tr>
</table>
</body>
</html>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/connectors/test.html | HTML | asf20 | 5,672 |
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* Common objects and functions shared by all pages that compose the
* File Browser dialog window.
*/
// Automatically detect the correct document.domain (#1919).
(function()
{
var d = document.domain ;
while ( true )
{
// Test if we can access a parent property.
try
{
var test = window.top.opener.document.domain ;
break ;
}
catch( e )
{}
// Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
d = d.replace( /.*?(?:\.|$)/, '' ) ;
if ( d.length == 0 )
break ; // It was not able to detect the domain.
try
{
document.domain = d ;
}
catch (e)
{
break ;
}
}
})() ;
function AddSelectOption( selectElement, optionText, optionValue )
{
var oOption = document.createElement("OPTION") ;
oOption.text = optionText ;
oOption.value = optionValue ;
selectElement.options.add(oOption) ;
return oOption ;
}
var oConnector = window.parent.oConnector ;
var oIcons = window.parent.oIcons ;
function StringBuilder( value )
{
this._Strings = new Array( value || '' ) ;
}
StringBuilder.prototype.Append = function( value )
{
if ( value )
this._Strings.push( value ) ;
}
StringBuilder.prototype.ToString = function()
{
return this._Strings.join( '' ) ;
}
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/browser/default/js/common.js | JavaScript | asf20 | 1,960 |
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* Defines the FCKXml object that is used for XML data calls
* and XML processing.
*
* This script is shared by almost all pages that compose the
* File Browser frameset.
*/
var FCKXml = function()
{}
FCKXml.prototype.GetHttpRequest = function()
{
// Gecko / IE7
try { return new XMLHttpRequest(); }
catch(e) {}
// IE6
try { return new ActiveXObject( 'Msxml2.XMLHTTP' ) ; }
catch(e) {}
// IE5
try { return new ActiveXObject( 'Microsoft.XMLHTTP' ) ; }
catch(e) {}
return null ;
}
FCKXml.prototype.LoadUrl = function( urlToCall, asyncFunctionPointer )
{
var oFCKXml = this ;
var bAsync = ( typeof(asyncFunctionPointer) == 'function' ) ;
var oXmlHttp = this.GetHttpRequest() ;
oXmlHttp.open( "GET", urlToCall, bAsync ) ;
if ( bAsync )
{
oXmlHttp.onreadystatechange = function()
{
if ( oXmlHttp.readyState == 4 )
{
var oXml ;
try
{
// this is the same test for an FF2 bug as in fckxml_gecko.js
// but we've moved the responseXML assignment into the try{}
// so we don't even have to check the return status codes.
var test = oXmlHttp.responseXML.firstChild ;
oXml = oXmlHttp.responseXML ;
}
catch ( e )
{
try
{
oXml = (new DOMParser()).parseFromString( oXmlHttp.responseText, 'text/xml' ) ;
}
catch ( e ) {}
}
if ( !oXml || !oXml.firstChild || oXml.firstChild.nodeName == 'parsererror' )
{
alert( 'The server didn\'t send back a proper XML response. Please contact your system administrator.\n\n' +
'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')\n\n' +
'Requested URL:\n' + urlToCall + '\n\n' +
'Response text:\n' + oXmlHttp.responseText ) ;
return ;
}
oFCKXml.DOMDocument = oXml ;
asyncFunctionPointer( oFCKXml ) ;
}
}
}
oXmlHttp.send( null ) ;
if ( ! bAsync )
{
if ( oXmlHttp.status == 200 || oXmlHttp.status == 304 )
this.DOMDocument = oXmlHttp.responseXML ;
else
{
alert( 'XML request error: ' + oXmlHttp.statusText + ' (' + oXmlHttp.status + ')' ) ;
}
}
}
FCKXml.prototype.SelectNodes = function( xpath )
{
if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE
return this.DOMDocument.selectNodes( xpath ) ;
else // Gecko
{
var aNodeArray = new Array();
var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), XPathResult.ORDERED_NODE_ITERATOR_TYPE, null) ;
if ( xPathResult )
{
var oNode = xPathResult.iterateNext() ;
while( oNode )
{
aNodeArray[aNodeArray.length] = oNode ;
oNode = xPathResult.iterateNext();
}
}
return aNodeArray ;
}
}
FCKXml.prototype.SelectSingleNode = function( xpath )
{
if ( navigator.userAgent.indexOf('MSIE') >= 0 ) // IE
return this.DOMDocument.selectSingleNode( xpath ) ;
else // Gecko
{
var xPathResult = this.DOMDocument.evaluate( xpath, this.DOMDocument,
this.DOMDocument.createNSResolver(this.DOMDocument.documentElement), 9, null);
if ( xPathResult && xPathResult.singleNodeValue )
return xPathResult.singleNodeValue ;
else
return null ;
}
}
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/browser/default/js/fckxml.js | JavaScript | asf20 | 3,925 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* This page shows the actual folder path.
-->
<html>
<head>
<title>Folder path</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="browser.css" type="text/css" rel="stylesheet">
<script type="text/javascript">
// Automatically detect the correct document.domain (#1919).
(function()
{
var d = document.domain ;
while ( true )
{
// Test if we can access a parent property.
try
{
var test = window.top.opener.document.domain ;
break ;
}
catch( e )
{}
// Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
d = d.replace( /.*?(?:\.|$)/, '' ) ;
if ( d.length == 0 )
break ; // It was not able to detect the domain.
try
{
document.domain = d ;
}
catch (e)
{
break ;
}
}
})() ;
function SetCurrentFolder( resourceType, folderPath )
{
document.getElementById('tdName').innerHTML = folderPath ;
}
window.onload = function()
{
window.top.IsLoadedActualFolder = true ;
}
</script>
</head>
<body>
<table class="fullHeight" cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td>
<button style="WIDTH: 100%" type="button">
<table cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td><img height="32" alt="" src="images/FolderOpened32.gif" width="32"></td>
<td> </td>
<td id="tdName" width="100%" nowrap class="ActualFolder">/</td>
<td> </td>
<td><img height="8" src="images/ButtonArrow.gif" width="12" alt=""></td>
<td> </td>
</tr>
</table>
</button>
</td>
</tr>
</table>
</body>
</html>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/browser/default/frmactualfolder.html | HTML | asf20 | 2,427 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* This page shows all resources available in a folder in the File Browser.
-->
<html>
<head>
<title>Resources</title>
<link href="browser.css" type="text/css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript">
var oListManager = new Object() ;
oListManager.Clear = function()
{
document.body.innerHTML = '' ;
}
function ProtectPath(path)
{
path = path.replace( /\\/g, '\\\\') ;
path = path.replace( /'/g, '\\\'') ;
return path ;
}
oListManager.GetFolderRowHtml = function( folderName, folderPath )
{
// Build the link to view the folder.
var sLink = '<a href="#" onclick="OpenFolder(\'' + ProtectPath( folderPath ) + '\');return false;">' ;
return '<tr>' +
'<td width="16">' +
sLink +
'<img alt="" src="images/Folder.gif" width="16" height="16" border="0"><\/a>' +
'<\/td><td nowrap colspan="2"> ' +
sLink +
folderName +
'<\/a>' +
'<\/td><\/tr>' ;
}
oListManager.GetFileRowHtml = function( fileName, fileUrl, fileSize )
{
// Build the link to view the folder.
var sLink = '<a href="#" onclick="OpenFile(\'' + ProtectPath( fileUrl ) + '\');return false;">' ;
// Get the file icon.
var sIcon = oIcons.GetIcon( fileName ) ;
return '<tr>' +
'<td width="16">' +
sLink +
'<img alt="" src="images/icons/' + sIcon + '.gif" width="16" height="16" border="0"><\/a>' +
'<\/td><td> ' +
sLink +
fileName +
'<\/a>' +
'<\/td><td align="right" nowrap> ' +
fileSize +
' KB' +
'<\/td><\/tr>' ;
}
function OpenFolder( folderPath )
{
// Load the resources list for this folder.
window.parent.frames['frmFolders'].LoadFolders( folderPath ) ;
}
function OpenFile( fileUrl )
{
window.top.opener.SetUrl( encodeURI( fileUrl ).replace( '#', '%23' ) ) ;
window.top.close() ;
window.top.opener.focus() ;
}
function LoadResources( resourceType, folderPath )
{
oListManager.Clear() ;
oConnector.ResourceType = resourceType ;
oConnector.CurrentFolder = folderPath ;
oConnector.SendCommand( 'GetFoldersAndFiles', null, GetFoldersAndFilesCallBack ) ;
}
function Refresh()
{
LoadResources( oConnector.ResourceType, oConnector.CurrentFolder ) ;
}
function GetFoldersAndFilesCallBack( fckXml )
{
if ( oConnector.CheckError( fckXml ) != 0 )
return ;
// Get the current folder path.
var oFolderNode = fckXml.SelectSingleNode( 'Connector/CurrentFolder' ) ;
if ( oFolderNode == null )
{
alert( 'The server didn\'t reply with a proper XML data. Please check your configuration.' ) ;
return ;
}
var sCurrentFolderPath = oFolderNode.attributes.getNamedItem('path').value ;
var sCurrentFolderUrl = oFolderNode.attributes.getNamedItem('url').value ;
// var dTimer = new Date() ;
var oHtml = new StringBuilder( '<table id="tableFiles" cellspacing="1" cellpadding="0" width="100%" border="0">' ) ;
// Add the Folders.
var oNodes ;
oNodes = fckXml.SelectNodes( 'Connector/Folders/Folder' ) ;
for ( var i = 0 ; i < oNodes.length ; i++ )
{
var sFolderName = oNodes[i].attributes.getNamedItem('name').value ;
oHtml.Append( oListManager.GetFolderRowHtml( sFolderName, sCurrentFolderPath + sFolderName + "/" ) ) ;
}
// Add the Files.
oNodes = fckXml.SelectNodes( 'Connector/Files/File' ) ;
for ( var j = 0 ; j < oNodes.length ; j++ )
{
var oNode = oNodes[j] ;
var sFileName = oNode.attributes.getNamedItem('name').value ;
var sFileSize = oNode.attributes.getNamedItem('size').value ;
// Get the optional "url" attribute. If not available, build the url.
var oFileUrlAtt = oNodes[j].attributes.getNamedItem('url') ;
var sFileUrl = oFileUrlAtt != null ? oFileUrlAtt.value : sCurrentFolderUrl + sFileName ;
oHtml.Append( oListManager.GetFileRowHtml( sFileName, sFileUrl, sFileSize ) ) ;
}
oHtml.Append( '<\/table>' ) ;
document.body.innerHTML = oHtml.ToString() ;
// window.top.document.title = 'Finished processing in ' + ( ( ( new Date() ) - dTimer ) / 1000 ) + ' seconds' ;
}
window.onload = function()
{
window.top.IsLoadedResourcesList = true ;
}
</script>
</head>
<body class="FileArea">
</body>
</html>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/browser/default/frmresourceslist.html | HTML | asf20 | 5,004 |
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* CSS styles used by all pages that compose the File Browser.
*/
body
{
background-color: #f1f1e3;
margin-top:0;
margin-bottom:0;
}
form
{
margin: 0;
padding: 0;
}
.Frame
{
background-color: #f1f1e3;
border: thin inset #f1f1e3;
}
body.FileArea
{
background-color: #ffffff;
margin: 10px;
}
body, td, input, select
{
font-size: 11px;
font-family: 'Microsoft Sans Serif' , Arial, Helvetica, Verdana;
}
.ActualFolder
{
font-weight: bold;
font-size: 14px;
}
.PopupButtons
{
border-top: #d5d59d 1px solid;
background-color: #e3e3c7;
padding: 7px 10px 7px 10px;
}
.Button, button
{
color: #3b3b1f;
border: #737357 1px solid;
background-color: #c7c78f;
}
.FolderListCurrentFolder img
{
background-image: url(images/FolderOpened.gif);
}
.FolderListFolder img
{
background-image: url(images/Folder.gif);
}
.fullHeight {
height: 100%;
}
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/browser/default/browser.css | CSS | asf20 | 1,554 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* This page shows the list of available resource types.
-->
<html>
<head>
<title>Available types</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="browser.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript">
function SetResourceType( type )
{
window.parent.frames["frmFolders"].SetResourceType( type ) ;
}
var aTypes = [
['File','File'],
['Image','Image'],
['Flash','Flash'],
['Media','Media']
] ;
window.onload = function()
{
var oCombo = document.getElementById('cmbType') ;
oCombo.innerHTML = '' ;
for ( var i = 0 ; i < aTypes.length ; i++ )
{
if ( oConnector.ShowAllTypes || aTypes[i][0] == oConnector.ResourceType )
AddSelectOption( oCombo, aTypes[i][1], aTypes[i][0] ) ;
}
}
</script>
</head>
<body>
<table class="fullHeight" cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td nowrap>
Resource Type<BR>
<select id="cmbType" style="WIDTH: 100%" onchange="SetResourceType(this.value);">
<option>
</select>
</td>
</tr>
</table>
</body>
</html>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/browser/default/frmresourcetype.html | HTML | asf20 | 1,899 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* This page compose the File Browser dialog frameset.
-->
<html>
<head>
<title>FCKeditor - Resources Browser</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="browser.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="js/fckxml.js"></script>
<script type="text/javascript">
// Automatically detect the correct document.domain (#1919).
(function()
{
var d = document.domain ;
while ( true )
{
// Test if we can access a parent property.
try
{
var test = window.opener.document.domain ;
break ;
}
catch( e )
{}
// Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
d = d.replace( /.*?(?:\.|$)/, '' ) ;
if ( d.length == 0 )
break ; // It was not able to detect the domain.
try
{
document.domain = d ;
}
catch (e)
{
break ;
}
}
})() ;
function GetUrlParam( paramName )
{
var oRegex = new RegExp( '[\?&]' + paramName + '=([^&]+)', 'i' ) ;
var oMatch = oRegex.exec( window.top.location.search ) ;
if ( oMatch && oMatch.length > 1 )
return decodeURIComponent( oMatch[1] ) ;
else
return '' ;
}
var oConnector = new Object() ;
oConnector.CurrentFolder = '/' ;
var sConnUrl = GetUrlParam( 'Connector' ) ;
// Gecko has some problems when using relative URLs (not starting with slash).
if ( sConnUrl.substr(0,1) != '/' && sConnUrl.indexOf( '://' ) < 0 )
sConnUrl = window.location.href.replace( /browser.html.*$/, '' ) + sConnUrl ;
oConnector.ConnectorUrl = sConnUrl + ( sConnUrl.indexOf('?') != -1 ? '&' : '?' ) ;
var sServerPath = GetUrlParam( 'ServerPath' ) ;
if ( sServerPath.length > 0 )
oConnector.ConnectorUrl += 'ServerPath=' + encodeURIComponent( sServerPath ) + '&' ;
oConnector.ResourceType = GetUrlParam( 'Type' ) ;
oConnector.ShowAllTypes = ( oConnector.ResourceType.length == 0 ) ;
if ( oConnector.ShowAllTypes )
oConnector.ResourceType = 'File' ;
oConnector.SendCommand = function( command, params, callBackFunction )
{
var sUrl = this.ConnectorUrl + 'Command=' + command ;
sUrl += '&Type=' + this.ResourceType ;
sUrl += '&CurrentFolder=' + encodeURIComponent( this.CurrentFolder ) ;
if ( params ) sUrl += '&' + params ;
// Add a random salt to avoid getting a cached version of the command execution
sUrl += '&uuid=' + new Date().getTime() ;
var oXML = new FCKXml() ;
if ( callBackFunction )
oXML.LoadUrl( sUrl, callBackFunction ) ; // Asynchronous load.
else
return oXML.LoadUrl( sUrl ) ;
return null ;
}
oConnector.CheckError = function( responseXml )
{
var iErrorNumber = 0 ;
var oErrorNode = responseXml.SelectSingleNode( 'Connector/Error' ) ;
if ( oErrorNode )
{
iErrorNumber = parseInt( oErrorNode.attributes.getNamedItem('number').value, 10 ) ;
switch ( iErrorNumber )
{
case 0 :
break ;
case 1 : // Custom error. Message placed in the "text" attribute.
alert( oErrorNode.attributes.getNamedItem('text').value ) ;
break ;
case 101 :
alert( 'Folder already exists' ) ;
break ;
case 102 :
alert( 'Invalid folder name' ) ;
break ;
case 103 :
alert( 'You have no permissions to create the folder' ) ;
break ;
case 110 :
alert( 'Unknown error creating folder' ) ;
break ;
default :
alert( 'Error on your request. Error number: ' + iErrorNumber ) ;
break ;
}
}
return iErrorNumber ;
}
var oIcons = new Object() ;
oIcons.AvailableIconsArray = [
'ai','avi','bmp','cs','dll','doc','exe','fla','gif','htm','html','jpg','js',
'mdb','mp3','pdf','png','ppt','rdp','swf','swt','txt','vsd','xls','xml','zip' ] ;
oIcons.AvailableIcons = new Object() ;
for ( var i = 0 ; i < oIcons.AvailableIconsArray.length ; i++ )
oIcons.AvailableIcons[ oIcons.AvailableIconsArray[i] ] = true ;
oIcons.GetIcon = function( fileName )
{
var sExtension = fileName.substr( fileName.lastIndexOf('.') + 1 ).toLowerCase() ;
if ( this.AvailableIcons[ sExtension ] == true )
return sExtension ;
else
return 'default.icon' ;
}
function OnUploadCompleted( errorNumber, fileUrl, fileName, customMsg )
{
if (errorNumber == "1")
window.frames['frmUpload'].OnUploadCompleted( errorNumber, customMsg ) ;
else
window.frames['frmUpload'].OnUploadCompleted( errorNumber, fileName ) ;
}
</script>
</head>
<frameset cols="150,*" class="Frame" framespacing="3" bordercolor="#f1f1e3" frameborder="1">
<frameset rows="50,*" framespacing="0">
<frame src="frmresourcetype.html" scrolling="no" frameborder="0">
<frame name="frmFolders" src="frmfolders.html" scrolling="auto" frameborder="1">
</frameset>
<frameset rows="50,*,50" framespacing="0">
<frame name="frmActualFolder" src="frmactualfolder.html" scrolling="no" frameborder="0">
<frame name="frmResourcesList" src="frmresourceslist.html" scrolling="auto" frameborder="1">
<frameset cols="150,*,0" framespacing="0" frameborder="0">
<frame name="frmCreateFolder" src="frmcreatefolder.html" scrolling="no" frameborder="0">
<frame name="frmUpload" src="frmupload.html" scrolling="no" frameborder="0">
<frame name="frmUploadWorker" src="javascript:void(0)" scrolling="no" frameborder="0">
</frameset>
</frameset>
</frameset>
</html>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/browser/default/browser.html | HTML | asf20 | 6,113 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* This page shows the list of folders available in the parent folder
* of the current folder.
-->
<html>
<head>
<title>Folders</title>
<link href="browser.css" type="text/css" rel="stylesheet">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript">
var sActiveFolder ;
var bIsLoaded = false ;
var iIntervalId ;
var oListManager = new Object() ;
oListManager.Init = function()
{
this.Table = document.getElementById('tableFiles') ;
this.UpRow = document.getElementById('trUp') ;
this.TableRows = new Object() ;
}
oListManager.Clear = function()
{
// Remove all other rows available.
while ( this.Table.rows.length > 1 )
this.Table.deleteRow(1) ;
// Reset the TableRows collection.
this.TableRows = new Object() ;
}
oListManager.AddItem = function( folderName, folderPath )
{
// Create the new row.
var oRow = this.Table.insertRow(-1) ;
oRow.className = 'FolderListFolder' ;
// Build the link to view the folder.
var sLink = '<a href="#" onclick="OpenFolder(\'' + folderPath + '\');return false;">' ;
// Add the folder icon cell.
var oCell = oRow.insertCell(-1) ;
oCell.width = 16 ;
oCell.innerHTML = sLink + '<img alt="" src="images/spacer.gif" width="16" height="16" border="0"><\/a>' ;
// Add the folder name cell.
oCell = oRow.insertCell(-1) ;
oCell.noWrap = true ;
oCell.innerHTML = ' ' + sLink + folderName + '<\/a>' ;
this.TableRows[ folderPath ] = oRow ;
}
oListManager.ShowUpFolder = function( upFolderPath )
{
this.UpRow.style.display = ( upFolderPath != null ? '' : 'none' ) ;
if ( upFolderPath != null )
{
document.getElementById('linkUpIcon').onclick = document.getElementById('linkUp').onclick = function()
{
LoadFolders( upFolderPath ) ;
return false ;
}
}
}
function CheckLoaded()
{
if ( window.top.IsLoadedActualFolder
&& window.top.IsLoadedCreateFolder
&& window.top.IsLoadedUpload
&& window.top.IsLoadedResourcesList )
{
window.clearInterval( iIntervalId ) ;
bIsLoaded = true ;
OpenFolder( sActiveFolder ) ;
}
}
function OpenFolder( folderPath )
{
sActiveFolder = folderPath ;
if ( ! bIsLoaded )
{
if ( ! iIntervalId )
iIntervalId = window.setInterval( CheckLoaded, 100 ) ;
return ;
}
// Change the style for the select row (to show the opened folder).
for ( var sFolderPath in oListManager.TableRows )
{
oListManager.TableRows[ sFolderPath ].className =
( sFolderPath == folderPath ? 'FolderListCurrentFolder' : 'FolderListFolder' ) ;
}
// Set the current folder in all frames.
window.parent.frames['frmActualFolder'].SetCurrentFolder( oConnector.ResourceType, folderPath ) ;
window.parent.frames['frmCreateFolder'].SetCurrentFolder( oConnector.ResourceType, folderPath ) ;
window.parent.frames['frmUpload'].SetCurrentFolder( oConnector.ResourceType, folderPath ) ;
// Load the resources list for this folder.
window.parent.frames['frmResourcesList'].LoadResources( oConnector.ResourceType, folderPath ) ;
}
function LoadFolders( folderPath )
{
// Clear the folders list.
oListManager.Clear() ;
// Get the parent folder path.
var sParentFolderPath ;
if ( folderPath != '/' )
sParentFolderPath = folderPath.substring( 0, folderPath.lastIndexOf( '/', folderPath.length - 2 ) + 1 ) ;
// Show/Hide the Up Folder.
oListManager.ShowUpFolder( sParentFolderPath ) ;
if ( folderPath != '/' )
{
sActiveFolder = folderPath ;
oConnector.CurrentFolder = sParentFolderPath ;
oConnector.SendCommand( 'GetFolders', null, GetFoldersCallBack ) ;
}
else
OpenFolder( '/' ) ;
}
function GetFoldersCallBack( fckXml )
{
if ( oConnector.CheckError( fckXml ) != 0 )
return ;
// Get the current folder path.
var oNode = fckXml.SelectSingleNode( 'Connector/CurrentFolder' ) ;
var sCurrentFolderPath = oNode.attributes.getNamedItem('path').value ;
var oNodes = fckXml.SelectNodes( 'Connector/Folders/Folder' ) ;
for ( var i = 0 ; i < oNodes.length ; i++ )
{
var sFolderName = oNodes[i].attributes.getNamedItem('name').value ;
oListManager.AddItem( sFolderName, sCurrentFolderPath + sFolderName + '/' ) ;
}
OpenFolder( sActiveFolder ) ;
}
function SetResourceType( type )
{
oConnector.ResourceType = type ;
LoadFolders( '/' ) ;
}
window.onload = function()
{
oListManager.Init() ;
LoadFolders( '/' ) ;
}
</script>
</head>
<body class="FileArea">
<table id="tableFiles" cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr id="trUp" style="DISPLAY: none">
<td width="16"><a id="linkUpIcon" href="#"><img alt="" src="images/FolderUp.gif" width="16" height="16" border="0"></a></td>
<td nowrap width="100%"> <a id="linkUp" href="#">..</a></td>
</tr>
</table>
</body>
</html>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/browser/default/frmfolders.html | HTML | asf20 | 5,640 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* Page used to create new folders in the current folder.
-->
<html>
<head>
<title>Create Folder</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="browser.css" type="text/css" rel="stylesheet">
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript">
function SetCurrentFolder( resourceType, folderPath )
{
oConnector.ResourceType = resourceType ;
oConnector.CurrentFolder = folderPath ;
}
function CreateFolder()
{
var sFolderName ;
while ( true )
{
sFolderName = prompt( 'Type the name of the new folder:', '' ) ;
if ( sFolderName == null )
return ;
else if ( sFolderName.length == 0 )
alert( 'Please type the folder name' ) ;
else
break ;
}
oConnector.SendCommand( 'CreateFolder', 'NewFolderName=' + encodeURIComponent( sFolderName) , CreateFolderCallBack ) ;
}
function CreateFolderCallBack( fckXml )
{
if ( oConnector.CheckError( fckXml ) == 0 )
window.parent.frames['frmResourcesList'].Refresh() ;
/*
// Get the current folder path.
var oNode = fckXml.SelectSingleNode( 'Connector/Error' ) ;
var iErrorNumber = parseInt( oNode.attributes.getNamedItem('number').value ) ;
switch ( iErrorNumber )
{
case 0 :
window.parent.frames['frmResourcesList'].Refresh() ;
break ;
case 101 :
alert( 'Folder already exists' ) ;
break ;
case 102 :
alert( 'Invalid folder name' ) ;
break ;
case 103 :
alert( 'You have no permissions to create the folder' ) ;
break ;
case 110 :
alert( 'Unknown error creating folder' ) ;
break ;
default :
alert( 'Error creating folder. Error number: ' + iErrorNumber ) ;
break ;
}
*/
}
window.onload = function()
{
window.top.IsLoadedCreateFolder = true ;
}
</script>
</head>
<body>
<table class="fullHeight" cellSpacing="0" cellPadding="0" width="100%" border="0">
<tr>
<td>
<button type="button" style="WIDTH: 100%" onclick="CreateFolder();">
<table cellSpacing="0" cellPadding="0" border="0">
<tr>
<td><img height="16" alt="" src="images/Folder.gif" width="16"></td>
<td> </td>
<td nowrap>Create New Folder</td>
</tr>
</table>
</button>
</td>
</tr>
</table>
</body>
</html>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/browser/default/frmcreatefolder.html | HTML | asf20 | 3,050 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* Page used to upload new files in the current folder.
-->
<html>
<head>
<title>File Upload</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link href="browser.css" type="text/css" rel="stylesheet" >
<script type="text/javascript" src="js/common.js"></script>
<script type="text/javascript">
function SetCurrentFolder( resourceType, folderPath )
{
var sUrl = oConnector.ConnectorUrl + 'Command=FileUpload' ;
sUrl += '&Type=' + resourceType ;
sUrl += '&CurrentFolder=' + encodeURIComponent( folderPath ) ;
document.getElementById('frmUpload').action = sUrl ;
}
function OnSubmit()
{
if ( document.getElementById('NewFile').value.length == 0 )
{
alert( 'Please select a file from your computer' ) ;
return false ;
}
// Set the interface elements.
document.getElementById('eUploadMessage').innerHTML = 'Upload a new file in this folder (Upload in progress, please wait...)' ;
document.getElementById('btnUpload').disabled = true ;
return true ;
}
function OnUploadCompleted( errorNumber, data )
{
// Reset the Upload Worker Frame.
window.parent.frames['frmUploadWorker'].location = 'javascript:void(0)' ;
// Reset the upload form (On IE we must do a little trick to avoid problems).
if ( document.all )
document.getElementById('NewFile').outerHTML = '<input id="NewFile" name="NewFile" style="WIDTH: 100%" type="file">' ;
else
document.getElementById('frmUpload').reset() ;
// Reset the interface elements.
document.getElementById('eUploadMessage').innerHTML = 'Upload a new file in this folder' ;
document.getElementById('btnUpload').disabled = false ;
switch ( errorNumber )
{
case 0 :
window.parent.frames['frmResourcesList'].Refresh() ;
break ;
case 1 : // Custom error.
alert( data ) ;
break ;
case 201 :
window.parent.frames['frmResourcesList'].Refresh() ;
alert( 'A file with the same name is already available. The uploaded file has been renamed to "' + data + '"' ) ;
break ;
case 202 :
alert( 'Invalid file' ) ;
break ;
default :
alert( 'Error on file upload. Error number: ' + errorNumber ) ;
break ;
}
}
window.onload = function()
{
window.top.IsLoadedUpload = true ;
}
</script>
</head>
<body>
<form id="frmUpload" action="" target="frmUploadWorker" method="post" enctype="multipart/form-data" onsubmit="return OnSubmit();">
<table class="fullHeight" cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td nowrap="nowrap">
<span id="eUploadMessage">Upload a new file in this folder</span><br>
<table cellspacing="0" cellpadding="0" width="100%" border="0">
<tr>
<td width="100%"><input id="NewFile" name="NewFile" style="WIDTH: 100%" type="file"></td>
<td nowrap="nowrap"> <input id="btnUpload" type="submit" value="Upload"></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/filemanager/browser/default/frmupload.html | HTML | asf20 | 3,707 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
-->
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
function doLoadScript( url )
{
if ( !url )
return false ;
var s = document.createElement( "script" ) ;
s.type = "text/javascript" ;
s.src = url ;
document.getElementsByTagName( "head" )[ 0 ].appendChild( s ) ;
return true ;
}
function tryLoad ()
{
if ( typeof( opener ) == 'undefined' || !opener )
opener = parent ;
// get access to global parameters
oParams = opener.oldFramesetPageParams ;
// make frameset rows string prepare
sFramesetRows = ( parseInt( oParams.firstframeh, 10 ) || '30') + ",*," + ( parseInt( oParams.thirdframeh, 10 ) || '150' ) + ',0' ;
document.getElementById( 'itFrameset' ).rows = sFramesetRows ;
// dynamic including init frames and crossdomain transport code
// from config sproxy_js_frameset url
var addScriptUrl = oParams.sproxy_js_frameset ;
doLoadScript( addScriptUrl ) ;
}
</script>
</head>
<frameset id="itFrameset" onload="tryLoad();" border="0" rows="30,*,*,0">
<frame scrolling="no" framespacing="0" frameborder="0" noresize="noresize" marginheight="0" marginwidth="2" src="" name="navbar"></frame>
<frame scrolling="auto" framespacing="0" frameborder="0" noresize="noresize" marginheight="0" marginwidth="0" src="" name="mid"></frame>
<frame scrolling="no" framespacing="0" frameborder="0" noresize="noresize" marginheight="1" marginwidth="1" src="" name="bot"></frame>
<frame scrolling="no" framespacing="0" frameborder="0" noresize="noresize" marginheight="1" marginwidth="1" src="" name="spellsuggestall"></frame>
</frameset>
</html>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/wsc/tmpFrameset.html | HTML | asf20 | 2,467 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
-->
<html>
<head>
<title></title>
<style>
#wsc_frames , #errorMessage{
position:absolute;
top:0px;
left:0px;
width:500px;
height:395px;
margin:0px;
padding:0px;
border:0px;
display:block;
overflow: hidden;
}
#wsc_frames { z-index:10;}
#errorMessage {
color:red;
display:none;
font-size:16px;
font-weight:bold;
padding-top:160px;
text-align:center;
z-index:11;
}
#errorMessage p {
color:#000;
font-size:11px;
text-align:left;
font-weight: normal;
padding-left:80px;
}
</style>
<script type="text/javascript">
var oEditor = window.parent.InnerDialogLoaded() ;
var FCKConfig = oEditor.FCKConfig;
function doLoadScript(url)
{
if (!url)
return false ;
var s = document.createElement('script') ;
s.type = 'text/javascript' ;
s.src = url ;
document.getElementsByTagName('head')[0].appendChild(s) ;
return true ;
}
function Ok()
{
return window.parent.Cancel() ;
}
function _callOnCancel( dT )
{
window.parent.Cancel() ;
}
function _callOnFinish( dT )
{
oEditor.FCK.SetData( dT.value ) ;
window.parent.CloseDialog( true ) ;
}
function _cancelOnError(m)
{
var _conId = 'errorMessage' ;
var message = m || 'Sorry, but service is unavailable now.' ;
if ( typeof( WSC_Error ) == 'undefined' )
{
var _con = document.createElement( 'div' ) ;
_con.setAttribute( 'id', _conId ) ;
document.body.appendChild( _con ) ;
dom_con = document.getElementById( _conId ) ;
dom_con.innerHTML = message ;
dom_con.style.display = 'block' ;
}
//return Ok() ;
}
function URL_abs2full( uri )
{
return uri.match( 'http' )
? uri
: document.location.protocol + '//' + document.location.host + uri ;
}
function clearErrorUsermessage()
{
// empty error container
var _con = document.getElementById( 'errorMessage' ) ;
if ( !_con )
return ;
_con.innerHTML = '' ;
_con.style.display = 'none' ;
}
var gInterval ;
function onLoad()
{
clearErrorUsermessage() ;
var _errorMessage = 'The SpellChecker Service is currently unavailable.' ;
if ( 'undefined' != typeof( oEditor.FCK.Config.WSChLoaderScript ) )
_errorMessage = '<div>The SpellChecker Service is currently unavailable.</div><p>Error loading application<br>service host: ' + oEditor.FCK.Config.WSChLoaderScript + '</p>';
var burnSpelling = function( oName, _eMessage )
{
var i = 0 ;
return function ()
{
if ( typeof( window[oName] ) == 'function' )
initAndSpell() ;
else if ( i++ == 180 )
_cancelOnError( _eMessage ) ;
}
}
gInterval = window.setInterval( burnSpelling( 'doSpell', _errorMessage ), 250 ) ;
// WSC CORE init section
var protocol = document.location.protocol || 'http:' ;
var baseUrl = protocol + '//loader.spellchecker.net/sproxy_fck/sproxy.php' ;
var plugin = "fck2" ;
var customerid = oEditor.FCK.Config.WSCnCustomerId
|| "1:ua3xw1-2XyGJ3-GWruD3-6OFNT1-oXcuB1-nR6Bp4-hgQHc-EcYng3-sdRXG3-NOfFk" ;
var wscCoreUrl = oEditor.FCK.Config.WSChLoaderScript
|| ( baseUrl + '?'
+ 'plugin=' + plugin + '&'
+ 'customerid='+ customerid + '&'
+ 'cmd=script&doc=wsc&schema=22' ) ;
// load WSC core
doLoadScript( wscCoreUrl ) ;
}
function initAndSpell()
{
//xall from window.setInteval expected at once
if ( typeof( gInterval ) == 'undefined' )
return null ;
window.clearInterval( gInterval ) ;
// global var is used in FCK specific core
// change on equal var used in fckplugin.js
gFCKPluginName = 'wsc' ;
// get the data to be checked
var sData = oEditor.FCK.GetData() ;
// prepare content
var ctrlId = 'myEditor' ;
var dCurT = document.getElementById( ctrlId ) ;
dCurT.value = sData ;
// service paths corecting/preparing
var sPath2Scin = URL_abs2full( oEditor.FCK.Config.SkinDialogCSS ) ;
var sPathCiframe = FCKConfig.BasePath + 'wsc/ciframe.html' ;
var sPathFrameset = FCKConfig.BasePath + 'wsc/tmpFrameset.html' ;
// language abbr standarts comparer
var LangComparer = new _SP_FCK_LangCompare() ;
LangComparer.setDefaulLangCode( oEditor.FCK.Language.DefaultLanguage ) ;
// clear user message console (if application was loaded more then after 2 seconds)
clearErrorUsermessage() ;
doSpell( {
ctrl : ctrlId,
lang : LangComparer.getSPLangCode( oEditor.FCK.Language.GetActiveLanguage() ),
winType : 'wsc_frames',// if not defined app will run on winpopup
// callback binding section
onCancel :window._callOnCancel,
onFinish :window._callOnFinish,
// @TODO: basePath assingning
// some manipulations with client static pages
framesetPath : sPathFrameset,
iframePath : sPathCiframe,
// styles defining
schemaURI : sPath2Scin
} ) ;
return true ;
}
</script>
</head>
<body onload="onLoad()" style="padding: 0px; overflow: hidden;">
<textarea style="display: none;" id="myEditor" rows="10" cols="40"></textarea>
<iframe src="" name="wsc_frames" id="wsc_frames"></iframe>
</body>
</html>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/wsc/w.html | HTML | asf20 | 5,769 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
-->
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript">
function gup( name )
{
name = name.replace( /[\[]/, '\\\[' ).replace( /[\]]/, '\\\]' ) ;
var regexS = '[\\?&]' + name + '=([^&#]*)' ;
var regex = new RegExp( regexS ) ;
var results = regex.exec( window.location.href ) ;
if( results == null )
return '' ;
else
return results[ 1 ] ;
}
function sendData2Master()
{
var destination = parent.parent ;
try
{
if ( destination.XDTMaster )
{
var t = destination.XDTMaster.read( [ gup( 'cmd' ), gup( 'data' ) ] ) ;
window.clearInterval( interval ) ;
}
}
catch (e) {}
}
function onLoad()
{
interval = window.setInterval( sendData2Master, 100 );
}
</script>
</head>
<body onload="onLoad()">
<p></p>
</body>
</html>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/wsc/ciframe.html | HTML | asf20 | 1,593 |
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* This CSS Style Sheet defines rules used by the editor for its internal use.
*/
/* #########
* WARNING
* #########
* When changing this file, the minified version of it must be updated in the
* fckeditor.html file (see FCK_InternalCSS).
*/
/* Fix to allow putting the caret at the end of the content in Firefox if
clicking below the content. */
html
{
min-height: 100%;
}
table.FCK__ShowTableBorders, table.FCK__ShowTableBorders td, table.FCK__ShowTableBorders th
{
border: #d3d3d3 1px solid;
}
form
{
border: 1px dotted #FF0000;
padding: 2px;
}
.FCK__Flash
{
border: #a9a9a9 1px solid;
background-position: center center;
background-image: url(images/fck_flashlogo.gif);
background-repeat: no-repeat;
width: 80px;
height: 80px;
}
.FCK__UnknownObject
{
border: #a9a9a9 1px solid;
background-position: center center;
background-image: url(images/fck_plugin.gif);
background-repeat: no-repeat;
width: 80px;
height: 80px;
}
/* Empty anchors images */
.FCK__Anchor
{
border: 1px dotted #00F;
background-position: center center;
background-image: url(images/fck_anchor.gif);
background-repeat: no-repeat;
width: 16px;
height: 15px;
vertical-align: middle;
}
/* Anchors with content */
.FCK__AnchorC
{
border: 1px dotted #00F;
background-position: 1px center;
background-image: url(images/fck_anchor.gif);
background-repeat: no-repeat;
padding-left: 18px;
}
/* Any anchor for non-IE, if we combine it with the previous rule IE ignores all. */
a[name]
{
border: 1px dotted #00F;
background-position: 0 center;
background-image: url(images/fck_anchor.gif);
background-repeat: no-repeat;
padding-left: 18px;
}
.FCK__PageBreak
{
background-position: center center;
background-image: url(images/fck_pagebreak.gif);
background-repeat: no-repeat;
clear: both;
display: block;
float: none;
width: 100%;
border-top: #999999 1px dotted;
border-bottom: #999999 1px dotted;
border-right: 0px;
border-left: 0px;
height: 5px;
}
/* Hidden fields */
.FCK__InputHidden
{
width: 19px;
height: 18px;
background-image: url(images/fck_hiddenfield.gif);
background-repeat: no-repeat;
vertical-align: text-bottom;
background-position: center center;
}
.FCK__ShowBlocks p,
.FCK__ShowBlocks div,
.FCK__ShowBlocks pre,
.FCK__ShowBlocks address,
.FCK__ShowBlocks blockquote,
.FCK__ShowBlocks h1,
.FCK__ShowBlocks h2,
.FCK__ShowBlocks h3,
.FCK__ShowBlocks h4,
.FCK__ShowBlocks h5,
.FCK__ShowBlocks h6
{
background-repeat: no-repeat;
border: 1px dotted gray;
padding-top: 8px;
padding-left: 8px;
}
.FCK__ShowBlocks p
{
background-image: url(images/block_p.png);
}
.FCK__ShowBlocks div
{
background-image: url(images/block_div.png);
}
.FCK__ShowBlocks pre
{
background-image: url(images/block_pre.png);
}
.FCK__ShowBlocks address
{
background-image: url(images/block_address.png);
}
.FCK__ShowBlocks blockquote
{
background-image: url(images/block_blockquote.png);
}
.FCK__ShowBlocks h1
{
background-image: url(images/block_h1.png);
}
.FCK__ShowBlocks h2
{
background-image: url(images/block_h2.png);
}
.FCK__ShowBlocks h3
{
background-image: url(images/block_h3.png);
}
.FCK__ShowBlocks h4
{
background-image: url(images/block_h4.png);
}
.FCK__ShowBlocks h5
{
background-image: url(images/block_h5.png);
}
.FCK__ShowBlocks h6
{
background-image: url(images/block_h6.png);
}
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/css/fck_internal.css | CSS | asf20 | 4,145 |
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* This is the default CSS file used by the editor area. It defines the
* initial font of the editor and background color.
*
* A user can configure the editor to use another CSS file. Just change
* the value of the FCKConfig.EditorAreaCSS key in the configuration
* file.
*/
/**
* The "body" styles should match your editor web site, mainly regarding
* background color and font family and size.
*/
body
{
background-color: #ffffff;
padding: 5px 5px 5px 5px;
margin: 0px;
}
body, td
{
font-family: Arial, Verdana, sans-serif;
font-size: 12px;
}
a[href]
{
color: -moz-hyperlinktext !important; /* For Firefox... mark as important, otherwise it becomes black */
text-decoration: -moz-anchor-decoration; /* For Firefox 3, otherwise no underline will be used */
}
/**
* Just uncomment the following block if you want to avoid spaces between
* paragraphs. Remember to apply the same style in your output front end page.
*/
/*
p, ul, li
{
margin-top: 0px;
margin-bottom: 0px;
}
*/
/**
* Uncomment the following block, or only selected lines if appropriate,
* if you have some style items that would break the styles combo box.
* You can also write other CSS overrides inside the style block below
* as needed and they will be applied to inside the style combo only.
*/
/*
.SC_Item *, .SC_ItemSelected *
{
margin: 0px !important;
padding: 0px !important;
text-indent: 0px !important;
clip: auto !important;
position: static !important;
}
*/
/**
* The following are some sample styles used in the "Styles" toolbar command.
* You should instead remove them, and include the styles used by the site
* you are using the editor in.
*/
.Bold
{
font-weight: bold;
}
.Title
{
font-weight: bold;
font-size: 18px;
color: #cc3300;
}
.Code
{
border: #8b4513 1px solid;
padding-right: 5px;
padding-left: 5px;
color: #000066;
font-family: 'Courier New' , Monospace;
background-color: #ff9933;
}
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/css/fck_editorarea.css | CSS | asf20 | 2,648 |
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* This CSS Style Sheet defines the rules to show table borders on Gecko.
*/
/* #########
* WARNING
* #########
* When changing this file, the minified version of it must be updated in the
* fckeditor.html file (see FCK_ShowTableBordersCSS).
*/
/* For tables with the "border" attribute set to "0" */
table[border="0"],
table[border="0"] > tr > td, table[border="0"] > tr > th,
table[border="0"] > tbody > tr > td, table[border="0"] > tbody > tr > th,
table[border="0"] > thead > tr > td, table[border="0"] > thead > tr > th,
table[border="0"] > tfoot > tr > td, table[border="0"] > tfoot > tr > th
{
border: #d3d3d3 1px dotted ;
}
/* For tables with no "border" attribute set */
table:not([border]),
table:not([border]) > tr > td, table:not([border]) > tr > th,
table:not([border]) > tbody > tr > td, table:not([border]) > tbody > tr > th,
table:not([border]) > thead > tr > td, table:not([border]) > thead > tr > th,
table:not([border]) > tfoot > tr > td, table:not([border]) > tfoot > tr > th
{
border: #d3d3d3 1px dotted ;
}
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/css/fck_showtableborders_gecko.css | CSS | asf20 | 1,696 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* This page is used by all dialog box as the container.
-->
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="robots" content="noindex, nofollow" />
<script type="text/javascript">
// <![CDATA[
// Domain relaxation logic.
(function()
{
var d = document.domain ;
while ( true )
{
// Test if we can access a parent property.
try
{
var parentDomain = ( Args().TopWindow || E ).document.domain ;
if ( document.domain != parentDomain )
document.domain = parentDomain ;
break ;
}
catch( e ) {}
// Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
d = d.replace( /.*?(?:\.|$)/, '' ) ;
if ( d.length == 0 )
break ; // It was not able to detect the domain.
document.domain = d ;
}
})() ;
var E = frameElement._DialogArguments.Editor ;
// It seems referencing to frameElement._DialogArguments directly would lead to memory leaks in IE.
// So let's use functions to access its members instead.
function Args()
{
return frameElement._DialogArguments ;
}
function ParentDialog( dialog )
{
return dialog ? dialog._ParentDialog : frameElement._ParentDialog ;
}
var FCK = E.FCK ;
var FCKTools = E.FCKTools ;
var FCKDomTools = E.FCKDomTools ;
var FCKDialog = E.FCKDialog ;
var FCKBrowserInfo = E.FCKBrowserInfo ;
var FCKConfig = E.FCKConfig ;
// Steal the focus so that the caret would no longer stay in the editor iframe.
window.focus() ;
// Sets the Skin CSS
document.write( FCKTools.GetStyleHtml( FCKConfig.SkinDialogCSS ) ) ;
// Sets the language direction.
var langDir = E.FCKLang.Dir ;
// For IE6-, the fck_dialog_ie6.js is loaded, used to fix limitations in the browser.
if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
document.write( '<' + 'script type="text/javascript" src="' + FCKConfig.SkinPath + 'fck_dialog_ie6.js"><' + '\/script>' ) ;
FCKTools.RegisterDollarFunction( window ) ;
// Resize related functions.
var Sizer = function()
{
var bAutoSize = false ;
var retval = {
// Sets whether the dialog should auto-resize according to its content's height.
SetAutoSize : function( autoSize )
{
bAutoSize = autoSize ;
this.RefreshSize() ;
},
// Fit the dialog container's layout to the inner iframe's external size.
RefreshContainerSize : function()
{
var frmMain = $( 'frmMain' ) ;
if ( frmMain )
{
// Get the container size.
var height = $( 'contents' ).offsetHeight ;
// Subtract the size of other elements.
height -= $( 'TitleArea' ).offsetHeight ;
height -= $( 'TabsRow' ).offsetHeight ;
height -= $( 'PopupButtons' ).offsetHeight ;
frmMain.style.height = Math.max( height, 0 ) + 'px' ;
}
},
// Resize and re-layout the dialog.
// Triggers the onresize event for the layout logic.
ResizeDialog : function( width, height )
{
FCKDomTools.SetElementStyles( window.frameElement,
{
'width' : width + 'px',
'height' : height + 'px'
} ) ;
// If the skin have defined a function for resize fixes, call it now.
if ( typeof window.DoResizeFixes == 'function' )
window.DoResizeFixes() ;
},
// if bAutoSize is true, automatically fit the dialog size and layout to
// accomodate the inner iframe's internal height.
// if bAutoSize is false, then only the layout logic for the dialog decorations
// is run to accomodate the inner iframe's external height.
RefreshSize : function()
{
if ( bAutoSize )
{
var frmMain = $( 'frmMain' ) ;
var innerDoc = frmMain.contentWindow.document ;
var isStrict = FCKTools.IsStrictMode( innerDoc ) ;
// Get the size of the frame contents.
var innerWidth = isStrict ? innerDoc.documentElement.scrollWidth : innerDoc.body.scrollWidth ;
var innerHeight = isStrict ? innerDoc.documentElement.scrollHeight : innerDoc.body.scrollHeight ;
// Get the current frame size.
var frameSize = FCKTools.GetViewPaneSize( frmMain.contentWindow ) ;
var deltaWidth = innerWidth - frameSize.Width ;
var deltaHeight = innerHeight - frameSize.Height ;
// If the contents fits the current size.
if ( deltaWidth <= 0 && deltaHeight <= 0 )
return ;
var dialogWidth = frameElement.offsetWidth + Math.max( deltaWidth, 0 ) ;
var dialogHeight = frameElement.offsetHeight + Math.max( deltaHeight, 0 ) ;
this.ResizeDialog( dialogWidth, dialogHeight ) ;
}
this.RefreshContainerSize() ;
}
}
/**
* Safari seems to have a bug with the time when RefreshSize() is executed - it
* thinks frmMain's innerHeight is 0 if we query the value too soon after the
* page is loaded in some circumstances. (#1316)
* TODO : Maybe this is not needed anymore after #35.
*/
if ( FCKBrowserInfo.IsSafari )
{
var originalRefreshSize = retval.RefreshSize ;
retval.RefreshSize = function()
{
FCKTools.SetTimeout( originalRefreshSize, 1, retval ) ;
}
}
/**
* IE6 has a similar bug where it sometimes thinks $('contents') has an
* offsetHeight of 0 (#2114).
*/
if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
{
var originalRefreshContainerSize = retval.RefreshContainerSize ;
retval.RefreshContainerSize = function()
{
FCKTools.SetTimeout( originalRefreshContainerSize, 1, retval ) ;
}
}
window.onresize = function()
{
retval.RefreshContainerSize() ;
}
window.SetAutoSize = FCKTools.Bind( retval, retval.SetAutoSize ) ;
return retval ;
}() ;
// Manages the throbber image that appears if the inner part of dialog is taking too long to load.
var Throbber = function()
{
var timer ;
var updateThrobber = function()
{
var throbberParent = $( 'throbberBlock' ) ;
var throbberBlocks = throbberParent.childNodes ;
var lastClass = throbberParent.lastChild.className ;
// From the last to the second one, copy the class from the previous one.
for ( var i = throbberBlocks.length - 1 ; i > 0 ; i-- )
throbberBlocks[i].className = throbberBlocks[i-1].className ;
// For the first one, copy the last class (rotation).
throbberBlocks[0].className = lastClass ;
}
return {
Show : function( waitMilliseconds )
{
// Auto-setup the Show function to be called again after the
// requested amount of time.
if ( waitMilliseconds && waitMilliseconds > 0 )
{
timer = FCKTools.SetTimeout( this.Show, waitMilliseconds, this, null, window ) ;
return ;
}
var throbberParent = $( 'throbberBlock' ) ;
if (throbberParent.childNodes.length == 0)
{
// Create the throbber blocks.
var classIds = [ 1,2,3,4,5,4,3,2 ] ;
while ( classIds.length > 0 )
throbberParent.appendChild( document.createElement( 'div' ) ).className = ' throbber_' + classIds.shift() ;
}
// Center the throbber.
var frm = $( 'contents' ) ;
var frmCoords = FCKTools.GetDocumentPosition( window, frm ) ;
var x = frmCoords.x + ( frm.offsetWidth - throbberParent.offsetWidth ) / 2 ;
var y = frmCoords.y + ( frm.offsetHeight - throbberParent.offsetHeight ) / 2 ;
throbberParent.style.left = parseInt( x, 10 ) + 'px' ;
throbberParent.style.top = parseInt( y, 10 ) + 'px' ;
// Show it.
throbberParent.style.visibility = '' ;
// Hide tabs and buttons:
$( 'Tabs' ).style.visibility = 'hidden' ;
$( 'PopupButtons' ).style.visibility = 'hidden' ;
// Setup the animation interval.
timer = setInterval( updateThrobber, 100 ) ;
},
Hide : function()
{
if ( timer )
{
clearInterval( timer ) ;
timer = null ;
}
$( 'throbberBlock' ).style.visibility = 'hidden' ;
// Show tabs and buttons:
$( 'Tabs' ).style.visibility = '' ;
$( 'PopupButtons' ).style.visibility = '' ;
}
} ;
}() ;
// Drag and drop handlers.
var DragAndDrop = function()
{
var registeredWindows = [] ;
var lastCoords ;
var currentPos ;
var cleanUpHandlers = function()
{
for ( var i = 0 ; i < registeredWindows.length ; i++ )
{
FCKTools.RemoveEventListener( registeredWindows[i].document, 'mousemove', dragMouseMoveHandler ) ;
FCKTools.RemoveEventListener( registeredWindows[i].document, 'mouseup', dragMouseUpHandler ) ;
}
}
var dragMouseMoveHandler = function( evt )
{
if ( !lastCoords )
return ;
if ( !evt )
evt = FCKTools.GetElementDocument( this ).parentWindow.event ;
// Updated the last coordinates.
var currentCoords =
{
x : evt.screenX,
y : evt.screenY
} ;
currentPos =
{
x : currentPos.x + ( currentCoords.x - lastCoords.x ),
y : currentPos.y + ( currentCoords.y - lastCoords.y )
} ;
lastCoords = currentCoords ;
frameElement.style.left = currentPos.x + 'px' ;
frameElement.style.top = currentPos.y + 'px' ;
if ( evt.preventDefault )
evt.preventDefault() ;
else
evt.returnValue = false ;
}
var dragMouseUpHandler = function( evt )
{
if ( !lastCoords )
return ;
if ( !evt )
evt = FCKTools.GetElementDocument( this ).parentWindow.event ;
cleanUpHandlers() ;
lastCoords = null ;
}
return {
MouseDownHandler : function( evt )
{
var view = null ;
if ( !evt )
{
view = FCKTools.GetElementDocument( this ).parentWindow ;
evt = view.event ;
}
else
view = evt.view ;
var target = evt.srcElement || evt.target ;
if ( target.id == 'closeButton' || target.className == 'PopupTab' || target.className == 'PopupTabSelected' )
return ;
lastCoords =
{
x : evt.screenX,
y : evt.screenY
} ;
// Save the current IFRAME position.
currentPos =
{
x : parseInt( FCKDomTools.GetCurrentElementStyle( frameElement, 'left' ), 10 ),
y : parseInt( FCKDomTools.GetCurrentElementStyle( frameElement, 'top' ), 10 )
} ;
for ( var i = 0 ; i < registeredWindows.length ; i++ )
{
FCKTools.AddEventListener( registeredWindows[i].document, 'mousemove', dragMouseMoveHandler ) ;
FCKTools.AddEventListener( registeredWindows[i].document, 'mouseup', dragMouseUpHandler ) ;
}
if ( evt.preventDefault )
evt.preventDefault() ;
else
evt.returnValue = false ;
},
RegisterHandlers : function( w )
{
registeredWindows.push( w ) ;
}
}
}() ;
// Selection related functions.
//(Became simple shortcuts after the fix for #1990)
var Selection =
{
/**
* Ensures that the editing area contains an active selection. This is a
* requirement for IE, as it looses the selection when the focus moves to other
* frames.
*/
EnsureSelection : function()
{
// Move the focus to the Cancel button so even if the dialog contains a
// contentEditable element the selection is properly restored in the editor #2496
window.focus() ;
$( 'btnCancel' ).focus() ;
FCK.Selection.Restore() ;
},
/**
* Get the FCKSelection object for the editor instance.
*/
GetSelection : function()
{
return FCK.Selection ;
},
/**
* Get the selected element in the editing area (for object selections).
*/
GetSelectedElement : function()
{
return FCK.Selection.GetSelectedElement() ;
}
}
// Tab related functions.
var Tabs = function()
{
// Only element ids should be stored here instead of element references since setSelectedTab and TabDiv_OnClick
// would build circular references with the element references inside and cause memory leaks in IE6.
var oTabs = new Object() ;
var setSelectedTab = function( tabCode )
{
for ( var sCode in oTabs )
{
if ( sCode == tabCode )
$( oTabs[sCode] ).className = 'PopupTabSelected' ;
else
$( oTabs[sCode] ).className = 'PopupTab' ;
}
if ( typeof( window.frames["frmMain"].OnDialogTabChange ) == 'function' )
window.frames["frmMain"].OnDialogTabChange( tabCode ) ;
}
function TabDiv_OnClick()
{
setSelectedTab( this.TabCode ) ;
}
window.AddTab = function( tabCode, tabText, startHidden )
{
if ( typeof( oTabs[ tabCode ] ) != 'undefined' )
return ;
var eTabsRow = $( 'Tabs' ) ;
var oCell = eTabsRow.insertCell( eTabsRow.cells.length - 1 ) ;
oCell.noWrap = true ;
var oDiv = document.createElement( 'DIV' ) ;
oDiv.className = 'PopupTab' ;
oDiv.innerHTML = tabText ;
oDiv.TabCode = tabCode ;
oDiv.onclick = TabDiv_OnClick ;
oDiv.id = Math.random() ;
if ( startHidden )
oDiv.style.display = 'none' ;
eTabsRow = $( 'TabsRow' ) ;
oCell.appendChild( oDiv ) ;
if ( eTabsRow.style.display == 'none' )
{
var eTitleArea = $( 'TitleArea' ) ;
eTitleArea.className = 'PopupTitle' ;
oDiv.className = 'PopupTabSelected' ;
eTabsRow.style.display = '' ;
if ( window.onresize )
window.onresize() ;
}
oTabs[ tabCode ] = oDiv.id ;
FCKTools.DisableSelection( oDiv ) ;
} ;
window.SetSelectedTab = setSelectedTab ;
window.SetTabVisibility = function( tabCode, isVisible )
{
var oTab = $( oTabs[ tabCode ] ) ;
oTab.style.display = isVisible ? '' : 'none' ;
if ( ! isVisible && oTab.className == 'PopupTabSelected' )
{
for ( var sCode in oTabs )
{
if ( $( oTabs[sCode] ).style.display != 'none' )
{
setSelectedTab( sCode ) ;
break ;
}
}
}
} ;
}() ;
// readystatechange handler for registering drag and drop handlers in cover
// iframes, defined out here to avoid memory leak.
// Do NOT put this function as a private function as it will induce memory leak
// in IE and it's not detectable with Drip or sIEve and undetectable leaks are
// really nasty (sigh).
var onReadyRegister = function()
{
if ( this.readyState != 'complete' )
return ;
DragAndDrop.RegisterHandlers( this.contentWindow ) ;
} ;
// The business logic of the dialog, dealing with operational things like
// dialog open/dialog close/enable/disable/etc.
(function()
{
var setOnKeyDown = function( targetDocument )
{
targetDocument.onkeydown = function ( e )
{
e = e || event || this.parentWindow.event ;
switch ( e.keyCode )
{
case 13 : // ENTER
var oTarget = e.srcElement || e.target ;
if ( oTarget.tagName == 'TEXTAREA' )
return true ;
Ok() ;
return false ;
case 27 : // ESC
Cancel() ;
return false ;
}
return true ;
}
} ;
var contextMenuBlocker = function( e )
{
var sTagName = e.target.tagName ;
if ( ! ( ( sTagName == "INPUT" && e.target.type == "text" ) || sTagName == "TEXTAREA" ) )
e.preventDefault() ;
} ;
var disableContextMenu = function( targetDocument )
{
if ( FCKBrowserInfo.IsIE )
return ;
targetDocument.addEventListener( 'contextmenu', contextMenuBlocker, true ) ;
} ;
// Program entry point.
window.Init = function()
{
$( 'contents' ).dir = langDir;
// Start the throbber timer.
Throbber.Show( 1000 ) ;
Sizer.RefreshContainerSize() ;
LoadInnerDialog() ;
FCKTools.DisableSelection( document.body ) ;
// Make the title area draggable.
var titleElement = $( 'header' ) ;
titleElement.onmousedown = DragAndDrop.MouseDownHandler ;
// Connect mousemove and mouseup events from dialog frame and outer window to dialog dragging logic.
DragAndDrop.RegisterHandlers( window ) ;
DragAndDrop.RegisterHandlers( Args().TopWindow ) ;
// Disable the previous dialog if it exists.
if ( ParentDialog() )
{
ParentDialog().contentWindow.SetEnabled( false ) ;
if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
{
var currentParent = ParentDialog() ;
while ( currentParent )
{
var blockerFrame = currentParent.contentWindow.$( 'blocker' ) ;
if ( blockerFrame.readyState == 'complete' )
DragAndDrop.RegisterHandlers( blockerFrame.contentWindow ) ;
else
blockerFrame.onreadystatechange = onReadyRegister ;
currentParent = ParentDialog( currentParent ) ;
}
}
else
{
var currentParent = ParentDialog() ;
while ( currentParent )
{
DragAndDrop.RegisterHandlers( currentParent.contentWindow ) ;
currentParent = ParentDialog( currentParent ) ;
}
}
}
// If this is the only dialog on screen, enable the background cover.
if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
{
var blockerFrame = FCKDialog.GetCover().firstChild ;
if ( blockerFrame.readyState == 'complete' )
DragAndDrop.RegisterHandlers( blockerFrame.contentWindow ) ;
else
blockerFrame.onreadystatechange = onReadyRegister;
}
// Add Enter/Esc hotkeys and disable context menu for the dialog.
setOnKeyDown( document ) ;
disableContextMenu( document ) ;
} ;
window.LoadInnerDialog = function()
{
if ( window.onresize )
window.onresize() ;
// First of all, translate the dialog box contents.
E.FCKLanguageManager.TranslatePage( document ) ;
// Create the IFRAME that holds the dialog contents.
$( 'innerContents' ).innerHTML = '<iframe id="frmMain" src="' + Args().Page + '" name="frmMain" frameborder="0" width="100%" height="100%" scrolling="auto" style="visibility: hidden;" allowtransparency="true"><\/iframe>' ;
} ;
window.InnerDialogLoaded = function()
{
// If the dialog has been closed before the iframe is loaded, do nothing.
if ( !frameElement.parentNode )
return null ;
Throbber.Hide() ;
var frmMain = $('frmMain') ;
var innerWindow = frmMain.contentWindow ;
var innerDoc = innerWindow.document ;
// Show the loaded iframe.
frmMain.style.visibility = '' ;
// Set the language direction.
innerDoc.documentElement.dir = langDir ;
// Sets the Skin CSS.
innerDoc.write( FCKTools.GetStyleHtml( FCKConfig.SkinDialogCSS ) ) ;
setOnKeyDown( innerDoc ) ;
disableContextMenu( innerDoc ) ;
Sizer.RefreshContainerSize();
DragAndDrop.RegisterHandlers( innerWindow ) ;
innerWindow.focus() ;
return E ;
} ;
window.SetOkButton = function( showIt )
{
$('btnOk').style.visibility = ( showIt ? '' : 'hidden' ) ;
} ;
window.Ok = function()
{
Selection.EnsureSelection() ;
var frmMain = window.frames["frmMain"] ;
if ( frmMain.Ok && frmMain.Ok() )
CloseDialog() ;
else
frmMain.focus() ;
} ;
window.Cancel = function( dontFireChange )
{
Selection.EnsureSelection() ;
return CloseDialog( dontFireChange ) ;
} ;
window.CloseDialog = function( dontFireChange )
{
Throbber.Hide() ;
// Points the src to a non-existent location to avoid loading errors later, in case the dialog
// haven't been completed loaded at this point.
if ( $( 'frmMain' ) )
$( 'frmMain' ).src = FCKTools.GetVoidUrl() ;
if ( !dontFireChange && !FCK.EditMode )
{
// All dialog windows, by default, will fire the "OnSelectionChange"
// event, no matter the Ok or Cancel button has been pressed.
// It seems that OnSelectionChange may enter on a concurrency state
// on some situations (#1965), so we should put the event firing in
// the execution queue instead of executing it immediately.
setTimeout( function()
{
FCK.Events.FireEvent( 'OnSelectionChange' ) ;
}, 0 ) ;
}
FCKDialog.OnDialogClose( window ) ;
} ;
window.SetEnabled = function( isEnabled )
{
var cover = $( 'cover' ) ;
cover.style.display = isEnabled ? 'none' : '' ;
if ( FCKBrowserInfo.IsIE && !FCKBrowserInfo.IsIE7 )
{
if ( !isEnabled )
{
// Inser the blocker IFRAME before the cover.
var blocker = document.createElement( 'iframe' ) ;
blocker.src = FCKTools.GetVoidUrl() ;
blocker.hideFocus = true ;
blocker.frameBorder = 0 ;
blocker.id = blocker.className = 'blocker' ;
cover.appendChild( blocker ) ;
}
else
{
var blocker = $( 'blocker' ) ;
if ( blocker && blocker.parentNode )
blocker.parentNode.removeChild( blocker ) ;
}
}
} ;
})() ;
// ]]>
</script>
</head>
<body onload="Init();" class="PopupBody">
<div class="contents" id="contents">
<div id="header">
<div id="TitleArea" class="PopupTitle PopupTitleBorder">
<script type="text/javascript">
// <![CDATA[
document.write( Args().Title ) ;
// ]]>
</script>
<div id="closeButton" onclick="Cancel();"></div>
</div>
<div id="TabsRow" class="PopupTabArea" style="display: none">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr id="Tabs">
<td class="PopupTabEmptyArea"> </td>
<td class="PopupTabEmptyArea" width="100%"> </td>
</tr>
</table>
</div>
</div>
<div id="innerContents"></div>
<div id="PopupButtons" class="PopupButtons">
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="100%"> </td>
<td nowrap="nowrap">
<input id="btnOk" style="visibility: hidden;" type="button" value="Ok" class="Button" onclick="Ok();" fckLang="DlgBtnOK" />
<input id="btnCancel" type="button" value="Cancel" class="Button" onclick="Cancel();" fckLang="DlgBtnCancel" />
</td>
</tr>
</table>
</div>
</div>
<div class="tl"></div>
<div class="tc"></div>
<div class="tr"></div>
<div class="ml"></div>
<div class="mr"></div>
<div class="bl"></div>
<div class="bc"></div>
<div class="br"></div>
<div class="cover" id="cover" style="display:none"></div>
<div id="throbberBlock" style="position: absolute; visibility: hidden"></div>
<script type="text/javascript">
// <![CDATA[
// Set the class name for language direction.
document.body.className += ' ' + langDir ;
var cover = $( 'cover' ) ;
cover.style.backgroundColor = FCKConfig.BackgroundBlockerColor ;
FCKDomTools.SetOpacity( cover, FCKConfig.BackgroundBlockerOpacity ) ;
// ]]>
</script>
</body>
</html>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/fckdialog.html | HTML | asf20 | 22,915 |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!--
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* Main page that holds the editor.
-->
<html>
<head>
<title>FCKeditor</title>
<meta name="robots" content="noindex, nofollow">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Cache-Control" content="public">
<script type="text/javascript">
// #1645: Alert the user if opening FCKeditor in FF3 from local filesystem
// without security.fileuri.strict_origin_policy disabled.
if ( document.location.protocol == 'file:' )
{
try
{
window.parent.document.domain ;
}
catch ( e )
{
window.addEventListener( 'load', function()
{
document.body.innerHTML = '\
<div style="border: 1px red solid; font-family: arial; font-size: 12px; color: red; padding:10px;">\
<p>\
<b>Your browser security settings don\'t allow FCKeditor to be opened from\
the local filesystem.<\/b>\
<\/p>\
<p>\
Please open the <b>about:config<\/b> page and disable the\
"security.fileuri.strict_origin_policy" option; then load this page again.\
<\/p>\
<p>\
Check our <a href="http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/FAQ#ff3perms">FAQ<\/a>\
for more information.\
<\/p>\
<\/div>' ;
}, false ) ;
}
}
// Save a reference to the default domain.
var FCK_ORIGINAL_DOMAIN ;
// Automatically detect the correct document.domain (#123).
(function()
{
var d = FCK_ORIGINAL_DOMAIN = document.domain ;
while ( true )
{
// Test if we can access a parent property.
try
{
var test = window.parent.document.domain ;
break ;
}
catch( e ) {}
// Remove a domain part: www.mytest.example.com => mytest.example.com => example.com ...
d = d.replace( /.*?(?:\.|$)/, '' ) ;
if ( d.length == 0 )
break ; // It was not able to detect the domain.
try
{
document.domain = d ;
}
catch (e)
{
break ;
}
}
})() ;
// Save a reference to the detected runtime domain.
var FCK_RUNTIME_DOMAIN = document.domain ;
var FCK_IS_CUSTOM_DOMAIN = ( FCK_ORIGINAL_DOMAIN != FCK_RUNTIME_DOMAIN ) ;
// Instead of loading scripts and CSSs using inline tags, all scripts are
// loaded by code. In this way we can guarantee the correct processing order,
// otherwise external scripts and inline scripts could be executed in an
// unwanted order (IE).
function LoadScript( url )
{
document.write( '<scr' + 'ipt type="text/javascript" src="' + url + '"><\/scr' + 'ipt>' ) ;
}
// Main editor scripts.
var sSuffix = ( /*@cc_on!@*/false ) ? 'ie' : 'gecko' ;
LoadScript( 'js/fckeditorcode_' + sSuffix + '.js' ) ;
// Base configuration file.
LoadScript( '../fckconfig.js' ) ;
</script>
<script type="text/javascript">
// Adobe AIR compatibility file.
if ( FCKBrowserInfo.IsAIR )
LoadScript( 'js/fckadobeair.js' ) ;
if ( FCKBrowserInfo.IsIE )
{
// Remove IE mouse flickering.
try
{
document.execCommand( 'BackgroundImageCache', false, true ) ;
}
catch (e)
{
// We have been reported about loading problems caused by the above
// line. For safety, let's just ignore errors.
}
// Create the default cleanup object used by the editor.
FCK.IECleanup = new FCKIECleanup( window ) ;
FCK.IECleanup.AddItem( FCKTempBin, FCKTempBin.Reset ) ;
FCK.IECleanup.AddItem( FCK, FCK_Cleanup ) ;
}
// The first function to be called on selection change must the the styles
// change checker, because the result of its processing may be used by another
// functions listening to the same event.
FCK.Events.AttachEvent( 'OnSelectionChange', function() { FCKStyles.CheckSelectionChanges() ; } ) ;
// The config hidden field is processed immediately, because
// CustomConfigurationsPath may be set in the page.
FCKConfig.ProcessHiddenField() ;
// Load the custom configurations file (if defined).
if ( FCKConfig.CustomConfigurationsPath.length > 0 )
LoadScript( FCKConfig.CustomConfigurationsPath ) ;
</script>
<script type="text/javascript">
// Load configurations defined at page level.
FCKConfig_LoadPageConfig() ;
FCKConfig_PreProcess() ;
// Load the full debug script.
if ( FCKConfig.Debug )
LoadScript( '_source/internals/fckdebug.js' ) ;
</script>
<script type="text/javascript">
// CSS minified by http://iceyboard.no-ip.org/projects/css_compressor (see _dev/css_compression.txt).
var FCK_InternalCSS = FCKTools.FixCssUrls( FCKConfig.BasePath + 'css/', 'html{min-height:100%}table.FCK__ShowTableBorders,table.FCK__ShowTableBorders td,table.FCK__ShowTableBorders th{border:#d3d3d3 1px solid}form{border:1px dotted #F00;padding:2px}.FCK__Flash{border:#a9a9a9 1px solid;background-position:center center;background-image:url(images/fck_flashlogo.gif);background-repeat:no-repeat;width:80px;height:80px}.FCK__UnknownObject{border:#a9a9a9 1px solid;background-position:center center;background-image:url(images/fck_plugin.gif);background-repeat:no-repeat;width:80px;height:80px}.FCK__Anchor{border:1px dotted #00F;background-position:center center;background-image:url(images/fck_anchor.gif);background-repeat:no-repeat;width:16px;height:15px;vertical-align:middle}.FCK__AnchorC{border:1px dotted #00F;background-position:1px center;background-image:url(images/fck_anchor.gif);background-repeat:no-repeat;padding-left:18px}a[name]{border:1px dotted #00F;background-position:0 center;background-image:url(images/fck_anchor.gif);background-repeat:no-repeat;padding-left:18px}.FCK__PageBreak{background-position:center center;background-image:url(images/fck_pagebreak.gif);background-repeat:no-repeat;clear:both;display:block;float:none;width:100%;border-top:#999 1px dotted;border-bottom:#999 1px dotted;border-right:0;border-left:0;height:5px}.FCK__InputHidden{width:19px;height:18px;background-image:url(images/fck_hiddenfield.gif);background-repeat:no-repeat;vertical-align:text-bottom;background-position:center center}.FCK__ShowBlocks p,.FCK__ShowBlocks div,.FCK__ShowBlocks pre,.FCK__ShowBlocks address,.FCK__ShowBlocks blockquote,.FCK__ShowBlocks h1,.FCK__ShowBlocks h2,.FCK__ShowBlocks h3,.FCK__ShowBlocks h4,.FCK__ShowBlocks h5,.FCK__ShowBlocks h6{background-repeat:no-repeat;border:1px dotted gray;padding-top:8px;padding-left:8px}.FCK__ShowBlocks p{background-image:url(images/block_p.png)}.FCK__ShowBlocks div{background-image:url(images/block_div.png)}.FCK__ShowBlocks pre{background-image:url(images/block_pre.png)}.FCK__ShowBlocks address{background-image:url(images/block_address.png)}.FCK__ShowBlocks blockquote{background-image:url(images/block_blockquote.png)}.FCK__ShowBlocks h1{background-image:url(images/block_h1.png)}.FCK__ShowBlocks h2{background-image:url(images/block_h2.png)}.FCK__ShowBlocks h3{background-image:url(images/block_h3.png)}.FCK__ShowBlocks h4{background-image:url(images/block_h4.png)}.FCK__ShowBlocks h5{background-image:url(images/block_h5.png)}.FCK__ShowBlocks h6{background-image:url(images/block_h6.png)}' ) ;
var FCK_ShowTableBordersCSS = FCKTools.FixCssUrls( FCKConfig.BasePath + 'css/', 'table:not([border]),table:not([border]) > tr > td,table:not([border]) > tr > th,table:not([border]) > tbody > tr > td,table:not([border]) > tbody > tr > th,table:not([border]) > thead > tr > td,table:not([border]) > thead > tr > th,table:not([border]) > tfoot > tr > td,table:not([border]) > tfoot > tr > th,table[border=\"0\"],table[border=\"0\"] > tr > td,table[border=\"0\"] > tr > th,table[border=\"0\"] > tbody > tr > td,table[border=\"0\"] > tbody > tr > th,table[border=\"0\"] > thead > tr > td,table[border=\"0\"] > thead > tr > th,table[border=\"0\"] > tfoot > tr > td,table[border=\"0\"] > tfoot > tr > th{border:#d3d3d3 1px dotted}' ) ;
// Popup the debug window if debug mode is set to true. It guarantees that the
// first debug message will not be lost.
if ( FCKConfig.Debug )
FCKDebug._GetWindow() ;
// Load the active skin CSS.
document.write( FCKTools.GetStyleHtml( FCKConfig.SkinEditorCSS ) ) ;
// Load the language file.
FCKLanguageManager.Initialize() ;
LoadScript( 'lang/' + FCKLanguageManager.ActiveLanguage.Code + '.js' ) ;
</script>
<script type="text/javascript">
// Initialize the editing area context menu.
FCK_ContextMenu_Init() ;
FCKPlugins.Load() ;
</script>
<script type="text/javascript">
// Set the editor interface direction.
window.document.dir = FCKLang.Dir ;
</script>
<script type="text/javascript">
window.onload = function()
{
InitializeAPI() ;
if ( FCKBrowserInfo.IsIE )
FCK_PreloadImages() ;
else
LoadToolbarSetup() ;
}
function LoadToolbarSetup()
{
FCKeditorAPI._FunctionQueue.Add( LoadToolbar ) ;
}
function LoadToolbar()
{
var oToolbarSet = FCK.ToolbarSet = FCKToolbarSet_Create() ;
if ( oToolbarSet.IsLoaded )
StartEditor() ;
else
{
oToolbarSet.OnLoad = StartEditor ;
oToolbarSet.Load( FCKURLParams['Toolbar'] || 'Default' ) ;
}
}
function StartEditor()
{
// Remove the onload listener.
FCK.ToolbarSet.OnLoad = null ;
FCKeditorAPI._FunctionQueue.Remove( LoadToolbar ) ;
FCK.Events.AttachEvent( 'OnStatusChange', WaitForActive ) ;
// Start the editor.
FCK.StartEditor() ;
}
function WaitForActive( editorInstance, newStatus )
{
if ( newStatus == FCK_STATUS_ACTIVE )
{
if ( FCKBrowserInfo.IsGecko )
FCKTools.RunFunction( window.onresize ) ;
if ( !FCKConfig.PreventSubmitHandler )
_AttachFormSubmitToAPI() ;
FCK.SetStatus( FCK_STATUS_COMPLETE ) ;
// Call the special "FCKeditor_OnComplete" function that should be present in
// the HTML page where the editor is located.
if ( typeof( window.parent.FCKeditor_OnComplete ) == 'function' )
window.parent.FCKeditor_OnComplete( FCK ) ;
}
}
// Gecko browsers doesn't calculate well the IFRAME size so we must
// recalculate it every time the window size changes.
if ( FCKBrowserInfo.IsGecko && !FCKBrowserInfo.IsOpera )
{
window.onresize = function( e )
{
// Running in Chrome makes the window receive the event including subframes.
// we care only about this window. Ticket #1642.
// #2002: The originalTarget from the event can be the current document, the window, or the editing area.
if ( e && e.originalTarget !== document && e.originalTarget !== window && (!e.originalTarget.ownerDocument || e.originalTarget.ownerDocument != document ))
return ;
var oCell = document.getElementById( 'xEditingArea' ) ;
var eInnerElement = oCell.firstChild ;
if ( eInnerElement )
{
eInnerElement.style.height = '0px' ;
eInnerElement.style.height = ( oCell.scrollHeight - 2 ) + 'px' ;
}
}
}
</script>
</head>
<body>
<table width="100%" cellpadding="0" cellspacing="0" style="height: 100%; table-layout: fixed">
<tr id="xToolbarRow" style="display: none">
<td id="xToolbarSpace" style="overflow: hidden">
<table width="100%" cellpadding="0" cellspacing="0">
<tr id="xCollapsed" style="display: none">
<td id="xExpandHandle" class="TB_Expand" colspan="3">
<img class="TB_ExpandImg" alt="" src="images/spacer.gif" width="8" height="4" /></td>
</tr>
<tr id="xExpanded" style="display: none">
<td id="xTBLeftBorder" class="TB_SideBorder" style="width: 1px; display: none;"></td>
<td id="xCollapseHandle" style="display: none" class="TB_Collapse" valign="bottom">
<img class="TB_CollapseImg" alt="" src="images/spacer.gif" width="8" height="4" /></td>
<td id="xToolbar" class="TB_ToolbarSet"></td>
<td class="TB_SideBorder" style="width: 1px"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td id="xEditingArea" valign="top" style="height: 100%"></td>
</tr>
</table>
</body>
</html>
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/editor/fckeditor.html | HTML | asf20 | 12,436 |
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* This is the integration file for JavaScript.
*
* It defines the FCKeditor class that can be used to create editor
* instances in a HTML page in the client side. For server side
* operations, use the specific integration system.
*/
// FCKeditor Class
var FCKeditor = function( instanceName, width, height, toolbarSet, value )
{
// Properties
this.InstanceName = instanceName ;
this.Width = width || '100%' ;
this.Height = height || '200' ;
this.ToolbarSet = toolbarSet || 'Default' ;
this.Value = value || '' ;
this.BasePath = FCKeditor.BasePath ;
this.CheckBrowser = true ;
this.DisplayErrors = true ;
this.Config = new Object() ;
// Events
this.OnError = null ; // function( source, errorNumber, errorDescription )
}
/**
* This is the default BasePath used by all editor instances.
*/
FCKeditor.BasePath = '/fckeditor/' ;
/**
* The minimum height used when replacing textareas.
*/
FCKeditor.MinHeight = 200 ;
/**
* The minimum width used when replacing textareas.
*/
FCKeditor.MinWidth = 750 ;
FCKeditor.prototype.Version = '2.6.4' ;
FCKeditor.prototype.VersionBuild = '21629' ;
FCKeditor.prototype.Create = function()
{
document.write( this.CreateHtml() ) ;
}
FCKeditor.prototype.CreateHtml = function()
{
// Check for errors
if ( !this.InstanceName || this.InstanceName.length == 0 )
{
this._ThrowError( 701, 'You must specify an instance name.' ) ;
return '' ;
}
var sHtml = '' ;
if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
{
sHtml += '<input type="hidden" id="' + this.InstanceName + '" name="' + this.InstanceName + '" value="' + this._HTMLEncode( this.Value ) + '" style="display:none" />' ;
sHtml += this._GetConfigHtml() ;
sHtml += this._GetIFrameHtml() ;
}
else
{
var sWidth = this.Width.toString().indexOf('%') > 0 ? this.Width : this.Width + 'px' ;
var sHeight = this.Height.toString().indexOf('%') > 0 ? this.Height : this.Height + 'px' ;
sHtml += '<textarea name="' + this.InstanceName +
'" rows="4" cols="40" style="width:' + sWidth +
';height:' + sHeight ;
if ( this.TabIndex )
sHtml += '" tabindex="' + this.TabIndex ;
sHtml += '">' +
this._HTMLEncode( this.Value ) +
'<\/textarea>' ;
}
return sHtml ;
}
FCKeditor.prototype.ReplaceTextarea = function()
{
if ( document.getElementById( this.InstanceName + '___Frame' ) )
return ;
if ( !this.CheckBrowser || this._IsCompatibleBrowser() )
{
// We must check the elements firstly using the Id and then the name.
var oTextarea = document.getElementById( this.InstanceName ) ;
var colElementsByName = document.getElementsByName( this.InstanceName ) ;
var i = 0;
while ( oTextarea || i == 0 )
{
if ( oTextarea && oTextarea.tagName.toLowerCase() == 'textarea' )
break ;
oTextarea = colElementsByName[i++] ;
}
if ( !oTextarea )
{
alert( 'Error: The TEXTAREA with id or name set to "' + this.InstanceName + '" was not found' ) ;
return ;
}
oTextarea.style.display = 'none' ;
if ( oTextarea.tabIndex )
this.TabIndex = oTextarea.tabIndex ;
this._InsertHtmlBefore( this._GetConfigHtml(), oTextarea ) ;
this._InsertHtmlBefore( this._GetIFrameHtml(), oTextarea ) ;
}
}
FCKeditor.prototype._InsertHtmlBefore = function( html, element )
{
if ( element.insertAdjacentHTML ) // IE
element.insertAdjacentHTML( 'beforeBegin', html ) ;
else // Gecko
{
var oRange = document.createRange() ;
oRange.setStartBefore( element ) ;
var oFragment = oRange.createContextualFragment( html );
element.parentNode.insertBefore( oFragment, element ) ;
}
}
FCKeditor.prototype._GetConfigHtml = function()
{
var sConfig = '' ;
for ( var o in this.Config )
{
if ( sConfig.length > 0 ) sConfig += '&' ;
sConfig += encodeURIComponent( o ) + '=' + encodeURIComponent( this.Config[o] ) ;
}
return '<input type="hidden" id="' + this.InstanceName + '___Config" value="' + sConfig + '" style="display:none" />' ;
}
FCKeditor.prototype._GetIFrameHtml = function()
{
var sFile = 'fckeditor.html' ;
try
{
if ( (/fcksource=true/i).test( window.top.location.search ) )
sFile = 'fckeditor.original.html' ;
}
catch (e) { /* Ignore it. Much probably we are inside a FRAME where the "top" is in another domain (security error). */ }
var sLink = this.BasePath + 'editor/' + sFile + '?InstanceName=' + encodeURIComponent( this.InstanceName ) ;
if (this.ToolbarSet)
sLink += '&Toolbar=' + this.ToolbarSet ;
var html = '<iframe id="' + this.InstanceName +
'___Frame" src="' + sLink +
'" width="' + this.Width +
'" height="' + this.Height ;
if ( this.TabIndex )
html += '" tabindex="' + this.TabIndex ;
html += '" frameborder="0" scrolling="no"></iframe>' ;
return html ;
}
FCKeditor.prototype._IsCompatibleBrowser = function()
{
return FCKeditor_IsCompatibleBrowser() ;
}
FCKeditor.prototype._ThrowError = function( errorNumber, errorDescription )
{
this.ErrorNumber = errorNumber ;
this.ErrorDescription = errorDescription ;
if ( this.DisplayErrors )
{
document.write( '<div style="COLOR: #ff0000">' ) ;
document.write( '[ FCKeditor Error ' + this.ErrorNumber + ': ' + this.ErrorDescription + ' ]' ) ;
document.write( '</div>' ) ;
}
if ( typeof( this.OnError ) == 'function' )
this.OnError( this, errorNumber, errorDescription ) ;
}
FCKeditor.prototype._HTMLEncode = function( text )
{
if ( typeof( text ) != "string" )
text = text.toString() ;
text = text.replace(
/&/g, "&").replace(
/"/g, """).replace(
/</g, "<").replace(
/>/g, ">") ;
return text ;
}
;(function()
{
var textareaToEditor = function( textarea )
{
var editor = new FCKeditor( textarea.name ) ;
editor.Width = Math.max( textarea.offsetWidth, FCKeditor.MinWidth ) ;
editor.Height = Math.max( textarea.offsetHeight, FCKeditor.MinHeight ) ;
return editor ;
}
/**
* Replace all <textarea> elements available in the document with FCKeditor
* instances.
*
* // Replace all <textarea> elements in the page.
* FCKeditor.ReplaceAllTextareas() ;
*
* // Replace all <textarea class="myClassName"> elements in the page.
* FCKeditor.ReplaceAllTextareas( 'myClassName' ) ;
*
* // Selectively replace <textarea> elements, based on custom assertions.
* FCKeditor.ReplaceAllTextareas( function( textarea, editor )
* {
* // Custom code to evaluate the replace, returning false if it
* // must not be done.
* // It also passes the "editor" parameter, so the developer can
* // customize the instance.
* } ) ;
*/
FCKeditor.ReplaceAllTextareas = function()
{
var textareas = document.getElementsByTagName( 'textarea' ) ;
for ( var i = 0 ; i < textareas.length ; i++ )
{
var editor = null ;
var textarea = textareas[i] ;
var name = textarea.name ;
// The "name" attribute must exist.
if ( !name || name.length == 0 )
continue ;
if ( typeof arguments[0] == 'string' )
{
// The textarea class name could be passed as the function
// parameter.
var classRegex = new RegExp( '(?:^| )' + arguments[0] + '(?:$| )' ) ;
if ( !classRegex.test( textarea.className ) )
continue ;
}
else if ( typeof arguments[0] == 'function' )
{
// An assertion function could be passed as the function parameter.
// It must explicitly return "false" to ignore a specific <textarea>.
editor = textareaToEditor( textarea ) ;
if ( arguments[0]( textarea, editor ) === false )
continue ;
}
if ( !editor )
editor = textareaToEditor( textarea ) ;
editor.ReplaceTextarea() ;
}
}
})() ;
function FCKeditor_IsCompatibleBrowser()
{
var sAgent = navigator.userAgent.toLowerCase() ;
// Internet Explorer 5.5+
if ( /*@cc_on!@*/false && sAgent.indexOf("mac") == -1 )
{
var sBrowserVersion = navigator.appVersion.match(/MSIE (.\..)/)[1] ;
return ( sBrowserVersion >= 5.5 ) ;
}
// Gecko (Opera 9 tries to behave like Gecko at this point).
if ( navigator.product == "Gecko" && navigator.productSub >= 20030210 && !( typeof(opera) == 'object' && opera.postError ) )
return true ;
// Opera 9.50+
if ( window.opera && window.opera.version && parseFloat( window.opera.version() ) >= 9.5 )
return true ;
// Adobe AIR
// Checked before Safari because AIR have the WebKit rich text editor
// features from Safari 3.0.4, but the version reported is 420.
if ( sAgent.indexOf( ' adobeair/' ) != -1 )
return ( sAgent.match( / adobeair\/(\d+)/ )[1] >= 1 ) ; // Build must be at least v1
// Safari 3+
if ( sAgent.indexOf( ' applewebkit/' ) != -1 )
return ( sAgent.match( / applewebkit\/(\d+)/ )[1] >= 522 ) ; // Build must be at least 522 (v3)
return false ;
}
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/fckeditor.js | JavaScript | asf20 | 9,606 |
/*
* FCKeditor - The text editor for Internet - http://www.fckeditor.net
* Copyright (C) 2003-2009 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 ==
*
* Editor configuration settings.
*
* Follow this link for more information:
* http://docs.fckeditor.net/FCKeditor_2.x/Developers_Guide/Configuration/Configuration_Options
*/
FCKConfig.CustomConfigurationsPath = '' ;
FCKConfig.EditorAreaCSS = FCKConfig.BasePath + 'css/fck_editorarea.css' ;
FCKConfig.EditorAreaStyles = '' ;
FCKConfig.ToolbarComboPreviewCSS = '' ;
FCKConfig.DocType = '' ;
FCKConfig.BaseHref = '' ;
FCKConfig.FullPage = false ;
// The following option determines whether the "Show Blocks" feature is enabled or not at startup.
FCKConfig.StartupShowBlocks = false ;
FCKConfig.Debug = false ;
FCKConfig.AllowQueryStringDebug = true ;
FCKConfig.SkinPath = FCKConfig.BasePath + 'skins/silver/' ;
FCKConfig.SkinEditorCSS = '' ; // FCKConfig.SkinPath + "|<minified css>" ;
FCKConfig.SkinDialogCSS = '' ; // FCKConfig.SkinPath + "|<minified css>" ;
FCKConfig.PreloadImages = [ FCKConfig.SkinPath + 'images/toolbar.start.gif', FCKConfig.SkinPath + 'images/toolbar.buttonarrow.gif' ] ;
FCKConfig.PluginsPath = FCKConfig.BasePath + 'plugins/' ;
//FCKConfig.Plugins.Add( 'autogrow' ) ;
//FCKConfig.Plugins.Add( 'dragresizetable' );
FCKConfig.AutoGrowMax = 400 ;
FCKConfig.ProtectedSource.Add( /<\?[\s\S]*?\?>/g ) ; // PHP style server side code
FCKConfig.AutoDetectLanguage = true ;
FCKConfig.DefaultLanguage = 'zh-cn' ;
FCKConfig.ContentLangDirection = 'ltr' ;
FCKConfig.ProcessHTMLEntities = true ;
FCKConfig.IncludeLatinEntities = true ;
FCKConfig.IncludeGreekEntities = true ;
FCKConfig.ProcessNumericEntities = false ;
FCKConfig.AdditionalNumericEntities = '' ; // Single Quote: "'"
FCKConfig.FillEmptyBlocks = true ;
FCKConfig.FormatSource = true ;
FCKConfig.FormatOutput = true ;
FCKConfig.FormatIndentator = ' ' ;
FCKConfig.EMailProtection = 'none' ; // none | encode | function
FCKConfig.EMailProtectionFunction = 'mt(NAME,DOMAIN,SUBJECT,BODY)' ;
FCKConfig.StartupFocus = false ;
FCKConfig.ForcePasteAsPlainText = false ;
FCKConfig.AutoDetectPasteFromWord = true ; // IE only.
FCKConfig.ShowDropDialog = true ;
FCKConfig.ForceSimpleAmpersand = false ;
FCKConfig.TabSpaces = 0 ;
FCKConfig.ShowBorders = true ;
FCKConfig.SourcePopup = false ;
FCKConfig.ToolbarStartExpanded = true ;
FCKConfig.ToolbarCanCollapse = true ;
FCKConfig.IgnoreEmptyParagraphValue = true ;
FCKConfig.FloatingPanelsZIndex = 10000 ;
FCKConfig.HtmlEncodeOutput = false ;
FCKConfig.TemplateReplaceAll = true ;
FCKConfig.TemplateReplaceCheckbox = true ;
FCKConfig.ToolbarLocation = 'In' ;
FCKConfig.ToolbarSets["Default"] = [
['Source','DocProps','-','Save','NewPage','Preview','-','Templates'],
['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Form','Checkbox','Radio','TextField','Textarea','Select','Button','ImageButton','HiddenField'],
'/',
['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
['OrderedList','UnorderedList','-','Outdent','Indent','Blockquote','CreateDiv'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
['Link','Unlink','Anchor'],
['Image','Flash','Table','Rule','Smiley','SpecialChar','PageBreak'],
'/',
['Style','FontFormat','FontName','FontSize'],
['TextColor','BGColor'],
['FitWindow','ShowBlocks','-','About'] // No comma for the last row.
] ;
FCKConfig.ToolbarSets["01cms"] = [
['Source'],
['PasteText','PasteWord'],
['Find','RemoveFormat'],
['Bold','Italic','Underline','StrikeThrough','SpecialChar'],
['TextColor','BGColor'],
['JustifyLeft','JustifyCenter','JustifyRight'],
['FitWindow'],
'/',
['PageBreak','Image','Flash','Table','Link','Unlink'],
['FontFormat','FontName','FontSize']
] ;
FCKConfig.ToolbarSets["Basic"] = [
['Source','PasteText','PasteWord','Bold','Italic','OrderedList','UnorderedList','Link','Unlink','Image','Flash','TextColor','BGColor','FontName','FontSize']
] ;
FCKConfig.EnterMode = 'p' ; // p | div | br
FCKConfig.ShiftEnterMode = 'br' ; // p | div | br
FCKConfig.Keystrokes = [
[ CTRL + 65 /*A*/, true ],
[ CTRL + 67 /*C*/, true ],
[ CTRL + 70 /*F*/, true ],
[ CTRL + 83 /*S*/, true ],
[ CTRL + 84 /*T*/, true ],
[ CTRL + 88 /*X*/, true ],
[ CTRL + 86 /*V*/, 'Paste' ],
[ CTRL + 45 /*INS*/, true ],
[ SHIFT + 45 /*INS*/, 'Paste' ],
[ CTRL + 88 /*X*/, 'Cut' ],
[ SHIFT + 46 /*DEL*/, 'Cut' ],
[ CTRL + 90 /*Z*/, 'Undo' ],
[ CTRL + 89 /*Y*/, 'Redo' ],
[ CTRL + SHIFT + 90 /*Z*/, 'Redo' ],
[ CTRL + 76 /*L*/, 'Link' ],
[ CTRL + 66 /*B*/, 'Bold' ],
[ CTRL + 73 /*I*/, 'Italic' ],
[ CTRL + 85 /*U*/, 'Underline' ],
[ CTRL + SHIFT + 83 /*S*/, 'Save' ],
[ CTRL + ALT + 13 /*ENTER*/, 'FitWindow' ],
[ SHIFT + 32 /*SPACE*/, 'Nbsp' ]
] ;
FCKConfig.ContextMenu = ['Generic','Link','Anchor','Image','Flash','Select','Textarea','Checkbox','Radio','TextField','HiddenField','ImageButton','Button','BulletedList','NumberedList','Table','Form','DivContainer'] ;
FCKConfig.BrowserContextMenuOnCtrl = false ;
FCKConfig.BrowserContextMenu = false ;
FCKConfig.EnableMoreFontColors = true ;
FCKConfig.FontColors = '000000,993300,333300,003300,003366,000080,333399,333333,800000,FF6600,808000,808080,008080,0000FF,666699,808080,FF0000,FF9900,99CC00,339966,33CCCC,3366FF,800080,999999,FF00FF,FFCC00,FFFF00,00FF00,00FFFF,00CCFF,993366,C0C0C0,FF99CC,FFCC99,FFFF99,CCFFCC,CCFFFF,99CCFF,CC99FF,FFFFFF' ;
FCKConfig.FontFormats = 'p;h1;h2;h3;h4;h5;h6;pre;address;div' ;
FCKConfig.FontNames = 'Arial;Comic Sans MS;Courier New;Tahoma;Times New Roman;Verdana' ;
FCKConfig.FontSizes = 'smaller;larger;xx-small;x-small;small;medium;large;x-large;xx-large' ;
FCKConfig.StylesXmlPath = FCKConfig.EditorPath + 'fckstyles.xml' ;
FCKConfig.TemplatesXmlPath = FCKConfig.EditorPath + 'fcktemplates.xml' ;
FCKConfig.SpellChecker = 'WSC' ; // 'WSC' | 'SpellerPages' | 'ieSpell'
FCKConfig.IeSpellDownloadUrl = 'http://www.iespell.com/download.php' ;
FCKConfig.SpellerPagesServerScript = 'server-scripts/spellchecker.php' ; // Available extension: .php .cfm .pl
FCKConfig.FirefoxSpellChecker = false ;
FCKConfig.MaxUndoLevels = 15 ;
FCKConfig.DisableObjectResizing = false ;
FCKConfig.DisableFFTableHandles = true ;
FCKConfig.LinkDlgHideTarget = false ;
FCKConfig.LinkDlgHideAdvanced = false ;
FCKConfig.ImageDlgHideLink = false ;
FCKConfig.ImageDlgHideAdvanced = false ;
FCKConfig.FlashDlgHideAdvanced = false ;
FCKConfig.ProtectedTags = '' ;
// This will be applied to the body element of the editor
FCKConfig.BodyId = '' ;
FCKConfig.BodyClass = '' ;
FCKConfig.DefaultStyleLabel = '' ;
FCKConfig.DefaultFontFormatLabel = '' ;
FCKConfig.DefaultFontLabel = '' ;
FCKConfig.DefaultFontSizeLabel = '' ;
FCKConfig.DefaultLinkTarget = '' ;
// The option switches between trying to keep the html structure or do the changes so the content looks like it was in Word
FCKConfig.CleanWordKeepsStructure = false ;
// Only inline elements are valid.
FCKConfig.RemoveFormatTags = 'b,big,code,del,dfn,em,font,i,ins,kbd,q,samp,small,span,strike,strong,sub,sup,tt,u,var' ;
// Attributes that will be removed
FCKConfig.RemoveAttributes = 'class,style,lang,width,height,align,hspace,valign' ;
FCKConfig.CustomStyles =
{
'Red Title' : { Element : 'h3', Styles : { 'color' : 'Red' } }
};
// Do not add, rename or remove styles here. Only apply definition changes.
FCKConfig.CoreStyles =
{
// Basic Inline Styles.
'Bold' : { Element : 'strong', Overrides : 'b' },
'Italic' : { Element : 'em', Overrides : 'i' },
'Underline' : { Element : 'u' },
'StrikeThrough' : { Element : 'strike' },
'Subscript' : { Element : 'sub' },
'Superscript' : { Element : 'sup' },
// Basic Block Styles (Font Format Combo).
'p' : { Element : 'p' },
'div' : { Element : 'div' },
'pre' : { Element : 'pre' },
'address' : { Element : 'address' },
'h1' : { Element : 'h1' },
'h2' : { Element : 'h2' },
'h3' : { Element : 'h3' },
'h4' : { Element : 'h4' },
'h5' : { Element : 'h5' },
'h6' : { Element : 'h6' },
// Other formatting features.
'FontFace' :
{
Element : 'span',
Styles : { 'font-family' : '#("Font")' },
Overrides : [ { Element : 'font', Attributes : { 'face' : null } } ]
},
'Size' :
{
Element : 'span',
Styles : { 'font-size' : '#("Size","fontSize")' },
Overrides : [ { Element : 'font', Attributes : { 'size' : null } } ]
},
'Color' :
{
Element : 'span',
Styles : { 'color' : '#("Color","color")' },
Overrides : [ { Element : 'font', Attributes : { 'color' : null } } ]
},
'BackColor' : { Element : 'span', Styles : { 'background-color' : '#("Color","color")' } },
'SelectionHighlight' : { Element : 'span', Styles : { 'background-color' : 'navy', 'color' : 'white' } }
};
// The distance of an indentation step.
FCKConfig.IndentLength = 40 ;
FCKConfig.IndentUnit = 'px' ;
// Alternatively, FCKeditor allows the use of CSS classes for block indentation.
// This overrides the IndentLength/IndentUnit settings.
FCKConfig.IndentClasses = [] ;
// [ Left, Center, Right, Justified ]
FCKConfig.JustifyClasses = [] ;
// The following value defines which File Browser connector and Quick Upload
// "uploader" to use. It is valid for the default implementaion and it is here
// just to make this configuration file cleaner.
// It is not possible to change this value using an external file or even
// inline when creating the editor instance. In that cases you must set the
// values of LinkBrowserURL, ImageBrowserURL and so on.
// Custom implementations should just ignore it.
var _FileBrowserLanguage = 'php' ; // asp | aspx | cfm | lasso | perl | php | py
var _QuickUploadLanguage = 'php' ; // asp | aspx | cfm | lasso | perl | php | py
// Don't care about the following two lines. It just calculates the correct connector
// extension to use for the default File Browser (Perl uses "cgi").
var _FileBrowserExtension = _FileBrowserLanguage == 'perl' ? 'cgi' : _FileBrowserLanguage ;
var _QuickUploadExtension = _QuickUploadLanguage == 'perl' ? 'cgi' : _QuickUploadLanguage ;
FCKConfig.LinkBrowser = true ;
FCKConfig.LinkBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Connector=' + encodeURIComponent( FCKConfig.BasePath + 'filemanager/connectors/' + _FileBrowserLanguage + '/connector.' + _FileBrowserExtension ) ;
FCKConfig.LinkBrowserWindowWidth = FCKConfig.ScreenWidth * 0.7 ; // 70%
FCKConfig.LinkBrowserWindowHeight = FCKConfig.ScreenHeight * 0.7 ; // 70%
FCKConfig.ImageBrowser = true ;
//FCKConfig.ImageBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Image&Connector=' + encodeURIComponent( FCKConfig.BasePath + 'filemanager/connectors/' + _FileBrowserLanguage + '/connector.' + _FileBrowserExtension ) ;
FCKConfig.ImageBrowserURL = FCKURLParams['BOOT_URL']+'/file/fckeditor';
FCKConfig.ImageBrowserWindowWidth = FCKConfig.ScreenWidth * 0.7 ; // 70% ;
FCKConfig.ImageBrowserWindowHeight = FCKConfig.ScreenHeight * 0.7 ; // 70% ;
FCKConfig.FlashBrowser = true ;
FCKConfig.FlashBrowserURL = FCKConfig.BasePath + 'filemanager/browser/default/browser.html?Type=Flash&Connector=' + encodeURIComponent( FCKConfig.BasePath + 'filemanager/connectors/' + _FileBrowserLanguage + '/connector.' + _FileBrowserExtension ) ;
FCKConfig.FlashBrowserWindowWidth = FCKConfig.ScreenWidth * 0.7 ; //70% ;
FCKConfig.FlashBrowserWindowHeight = FCKConfig.ScreenHeight * 0.7 ; //70% ;
FCKConfig.LinkUpload = true ;
FCKConfig.LinkUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' + _QuickUploadLanguage + '/upload.' + _QuickUploadExtension ;
FCKConfig.LinkUploadAllowedExtensions = ".(7z|aiff|asf|avi|bmp|csv|doc|fla|flv|gif|gz|gzip|jpeg|jpg|mid|mov|mp3|mp4|mpc|mpeg|mpg|ods|odt|pdf|png|ppt|pxd|qt|ram|rar|rm|rmi|rmvb|rtf|sdc|sitd|swf|sxc|sxw|tar|tgz|tif|tiff|txt|vsd|wav|wma|wmv|xls|xml|zip)$" ; // empty for all
FCKConfig.LinkUploadDeniedExtensions = "" ; // empty for no one
FCKConfig.ImageUpload = true ;
//FCKConfig.ImageUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' + _QuickUploadLanguage + '/upload.' + _QuickUploadExtension + '?Type=Image' ;
FCKConfig.ROOT_DIR = FCKURLParams['ROOT_DIR'];
FCKConfig.PUBLIC_DIR = FCKURLParams['PUBLIC_DIR'];
FCKConfig.BOOT_URL = FCKURLParams['BOOT_URL'];
FCKConfig.ImageUploadURL = FCKConfig.BOOT_URL+'/file/upload/doEdit/NewFile';
FCKConfig.ImageUploadAllowedExtensions = ".(jpg|gif|jpeg|png)$" ; // empty for all
FCKConfig.ImageUploadDeniedExtensions = "" ; // empty for no one
FCKConfig.FlashUpload = true ;
FCKConfig.FlashUploadURL = FCKConfig.BasePath + 'filemanager/connectors/' + _QuickUploadLanguage + '/upload.' + _QuickUploadExtension + '?Type=Flash' ;
FCKConfig.FlashUploadAllowedExtensions = ".(swf|flv)$" ; // empty for all
FCKConfig.FlashUploadDeniedExtensions = "" ; // empty for no one
FCKConfig.SmileyPath = FCKConfig.BasePath + 'images/smiley/msn/' ;
FCKConfig.SmileyImages = ['regular_smile.gif','sad_smile.gif','wink_smile.gif','teeth_smile.gif','confused_smile.gif','tounge_smile.gif','embaressed_smile.gif','omg_smile.gif','whatchutalkingabout_smile.gif','angry_smile.gif','angel_smile.gif','shades_smile.gif','devil_smile.gif','cry_smile.gif','lightbulb.gif','thumbs_down.gif','thumbs_up.gif','heart.gif','broken_heart.gif','kiss.gif','envelope.gif'] ;
FCKConfig.SmileyColumns = 8 ;
FCKConfig.SmileyWindowWidth = 320 ;
FCKConfig.SmileyWindowHeight = 210 ;
FCKConfig.BackgroundBlockerColor = '#ffffff' ;
FCKConfig.BackgroundBlockerOpacity = 0.50 ;
FCKConfig.MsWebBrowserControlCompat = false ;
FCKConfig.PreventSubmitHandler = false ;
| 01cms | 01cms/branches/v1.0/01cms/public/FCKeditor/fckconfig.js | JavaScript | asf20 | 14,442 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>01CMS 安装程序</title>
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/admin.css" rel="stylesheet" type="text/css" />
<style type="text/css">
h1 span{ color:#999;}
ul{padding:2px 0;}
li{color:#333;padding:3px 0;}
.name{ width:90px; background:#fcfcfc;}
.ok{font-weight:bold; color:#090;}
.warning{ font-weight:bold; color:#F00;}
.notice{ font-weight:bold; color:#FC0;}
</style>
</head>
<body>
<div class="wrapper">
<div class="title shadow titleBg">
<table width="100%" border="0" cellspacing="1">
<tr>
<td><h1> 01CMS 安装程序 => 安装检测<span> → 安装设定 → 安装完成</span></h1></td>
</tr>
</table>
</div>
<div class="content shadow textL">
<table width="100%" border="0" cellspacing="1">
<tr class="titleBg">
<th class="textL">
安装检测
</th>
</tr>
<tr>
<td class="textL">
<ul>
<li>1、相关软件:</li>
{:foreach from=$i->soft item=item key=key}
<li> {:$key} {:$item.version} [{:if $item.status}<span class="ok">√</span>{:else}<span class="warning">×</span>{:/if}]</li>
{:/foreach}
<li>2、以下目录必须可写:</li>
{:foreach from=$i->writeable item=item}
<li> {:$item.file} [{:if $item.status}<span class="ok">√</span>{:else}<span class="warning">×</span>{:/if}]</li>
{:/foreach}
</ul>
</td>
</tr>
</table>
</div>
<div class="content shadow textL">
<table width="100%" border="0" cellspacing="1">
<tr class="titleBg">
<th class="textL">
许可协议
</th>
</tr>
<tr>
<td class="textL">
<ul>
<li>1、将本软件应用于非商业用途,不必支付软件版权授权费用,并可以对本软件进行修改或二次开发;</li>
<li>2、如果你的网站整体或部份栏目使用了本软件,请勿删除底部的官方链接,如果的确要删除,必须在该网站上以<strong>友情链接</strong>的形式加上本软件的<strong>官方链接</strong>:<a href="http://www.01cms.com">http://www.01cms.com</a>。</li>
</ul>
</td>
</tr>
<tr>
<td class="textL">
{:if $i->next}<input type="button" name="next" onclick="document.location.href='{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/2'" value="同意协议并继续安装" />{:else}<input type="button" name="next" value="同意协议并继续安装" disabled="disabled" /> 没有通过安装检测,无法继续安装,请检查出现<span class="warning">×</span>的项目。{:/if}
</td>
</tr>
</table>
</div>
</div>
</body>
</html>
| 01cms | 01cms/branches/v1.0/install/view/index/indexStep1.tpl | Smarty | asf20 | 3,112 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>01CMS 安装程序</title>
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/admin.css" rel="stylesheet" type="text/css" />
<style type="text/css">
h1 span{ color:#999;}
ul{padding:2px 0;}
li{color:#333;padding:3px 0;}
.name{ width:90px; background:#fcfcfc;}
.ok{font-weight:bold; color:#090;}
.warning{ font-weight:bold; color:#F00;}
.notice{ font-weight:bold; color:#FC0;}
</style>
</head>
<body>
<div class="wrapper">
<div class="title shadow titleBg">
<table width="100%" border="0" cellspacing="1">
<tr>
<td><h1> 01CMS 安装程序 => <span>安装检测 → </span>安装设定<span> → 安装完成</span></h1></td>
</tr>
</table>
</div>
<div class="content shadow textL">
<form>
<table width="100%" border="0" cellspacing="1">
<tr class="titleBg">
<th colspan="2" class="textL">
安装设定
</th>
</tr>
<tr>
<td class="textR name"> 数据库主机:</td>
<td class="textL"><input type="text" name="hostname" id="hostname" value="localhost" size="20" class="posted check" /></td>
</tr>
<tr>
<td class="textR name"> 数据库用户:</td>
<td class="textL"><input type="text" name="username" id="username" value="root" size="20" class="posted check" /></td>
</tr>
<tr>
<td class="textR name"> 数据库密码:</td>
<td class="textL"><input type="text" name="password" id="password" value="" size="20" class="posted check" />
<span id="checkConnect"><span></td>
</tr>
<tr>
<td class="textR name"> 数据库名称:</td>
<td class="textL"><input type="text" name="database" id="database" value="01cms" size="20" class="posted check" />
<span id="checkDatabase"><span>
</td>
</tr>
<tr>
<td class="textR name"> 数据表前缀:</td>
<td class="textL"><input type="text" name="prefix" value="01cms_" size="20" class="posted check" /></td>
</tr>
<tr>
<td class="textR name"> 后台管理用户:</td>
<td class="textL"><input type="text" name="adminUsername" value="admin" size="20" class="posted check" /></td>
</tr>
<tr>
<td class="textR name"> 后台用户密码:</td>
<td class="textL"><input type="text" name="adminPassword" value="admin" size="20" class="posted check" /></td>
</tr>
<tr>
<td class="textR name"> </td>
<td class="textL"><input type="submit" value="确定安装" />
<input type="button" name="next" onclick="document.location.href='{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/1';return false;" value="返回" /></td>
</tr>
</table>
</form>
</div>
</div>
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/ui.all.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.core.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.draggable.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.dialog.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.post.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
$("form").post({
sendUrl:'{:$smarty.const.BOOT_URL}/{:$i->c}/install',
goUrl:'{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}/3',
stayTime:4
});
$("#hostname,#username,#password").blur(function(){
$.ajax({
type : 'post',
dataType : 'json',
data : "hostname="+$("#hostname").val()+"&username="+$("#username").val()+"&password="+$("#password").val(),
url : '{:$smarty.const.BOOT_URL}/{:$i->c}/check/connect',
success : function(response)
{
if (response.success)
{
$("#checkConnect").html('[√]'+response.message);
$("#checkConnect").removeClass("warning");
$("#checkConnect").addClass("ok");
}
else
{
$("#checkConnect").html('[×]'+response.message);
$("#checkConnect").removeClass("ok");
$("#checkConnect").addClass("warning");
}
}
});
});
$("#database").blur(function(){
$.ajax({
type : 'post',
dataType : 'json',
data : "hostname="+$("#hostname").val()+"&username="+$("#username").val()+"&password="+$("#password").val()+"&database="+$("#database").val(),
url : '{:$smarty.const.BOOT_URL}/{:$i->c}/check/database',
success : function(response)
{
if (response.success)
{
$("#checkDatabase").html('[√]'+response.message);
$("#checkDatabase").removeClass("warning");
$("#checkDatabase").addClass("ok");
}
else
{
$("#checkDatabase").html('[×]'+response.message);
$("#checkDatabase").removeClass("ok");
$("#checkDatabase").addClass("warning");
}
}
});
});
});
</script>
</body>
</html>
| 01cms | 01cms/branches/v1.0/install/view/index/indexStep2.tpl | Smarty | asf20 | 5,502 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>01CMS 安装程序</title>
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/admin.css" rel="stylesheet" type="text/css" />
<style type="text/css">
h1 span{ color:#999;}
ul{padding:2px 0;}
li{color:#333;padding:3px 0;}
.name{ width:90px; background:#fcfcfc;}
.ok{font-weight:bold; color:#090;}
.warning{ font-weight:bold; color:#F00;}
.notice{ font-weight:bold; color:#FC0;}
</style>
</head>
<body>
<div class="wrapper">
<div class="title shadow titleBg">
<table width="100%" border="0" cellspacing="1">
<tr>
<td><h1> 01CMS 安装程序 => <span>安装检测 → 安装设定 →</span> 安装完成</h1></td>
</tr>
</table>
</div>
<div class="content shadow textL">
<table width="100%" border="0" cellspacing="1">
<tr class="titleBg">
<th class="textL">
安装完成
</th>
</tr>
<tr>
<td class="textL">
<ul>
<li>登陆管理后台:<a href="{:$smarty.const.ROOT_DIR}/01cms" target="_blank">{:$smarty.const.ROOT_DIR}/01cms</a></li>
<li>浏览网站首页:<a href="{:$smarty.const.ROOT_DIR}" target="_blank">{:$smarty.const.ROOT_DIR}</a></li>
<li>访问官方首页:<a href="http://www.01cms.com" target="_blank">http://www.01cms.com</a></li>
</ul>
</td>
</tr>
</table>
</div>
</div>
<link href="{:$smarty.const.PUBLIC_DIR}/common/style/ui.all.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.core.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.draggable.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/ui.dialog.js"></script>
<script language="javascript" type="text/javascript" src="{:$smarty.const.PUBLIC_DIR}/common/js/jquery.post.js"></script>
<script language="javascript" type="text/javascript">
$(document).ready(function(){
$("form").post({
sendUrl:'{:$smarty.const.BOOT_URL}/{:$i->c}/install',
goUrl:'{:$smarty.const.BOOT_URL}/{:$i->c}/{:$i->m}',
stayTime:4
});
$("#hostname,#username,#password").blur(function(){
$.ajax({
type : 'post',
dataType : 'json',
data : "hostname="+$("#hostname").val()+"&username="+$("#username").val()+"&password="+$("#password").val(),
url : '{:$smarty.const.BOOT_URL}/{:$i->c}/check/connect',
success : function(response)
{
if (response.success)
{
$("#checkConnect").html('[√]'+response.message);
$("#checkConnect").removeClass("warning");
$("#checkConnect").addClass("ok");
}
else
{
$("#checkConnect").html('[×]'+response.message);
$("#checkConnect").removeClass("ok");
$("#checkConnect").addClass("warning");
}
}
});
});
$("#database").blur(function(){
$.ajax({
type : 'post',
dataType : 'json',
data : "hostname="+$("#hostname").val()+"&username="+$("#username").val()+"&password="+$("#password").val()+"&database="+$("#database").val(),
url : '{:$smarty.const.BOOT_URL}/{:$i->c}/check/database',
success : function(response)
{
if (response.success)
{
$("#checkDatabase").html('[√]'+response.message);
$("#checkDatabase").removeClass("warning");
$("#checkDatabase").addClass("ok");
}
else
{
$("#checkDatabase").html('[×]'+response.message);
$("#checkDatabase").removeClass("ok");
$("#checkDatabase").addClass("warning");
}
}
});
});
});
</script>
</body>
</html>
| 01cms | 01cms/branches/v1.0/install/view/index/indexStep3.tpl | Smarty | asf20 | 4,086 |
<?php
/**
* 安装程序入口文件
*
* @package 01CMS
* @subpackage install
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
//开发期间去掉以下两行注释
ini_set('display_errors', 'on');
error_reporting(E_ALL);
//设定编码
header('Content-Type: text/html; charset=utf-8');
//定义根路径
define('ROOT_PATH', ereg_replace('[\\/]+', '/', realpath('../')));
//公共静态资源路径
define('PUBLIC_PATH', ROOT_PATH . '/public');
//定义APP路径
define('APP_PATH', ereg_replace('[\\/]+', '/', dirname(__FILE__)));
//定义01MVC框架目录
define('SYS_PATH', ROOT_PATH . '/01mvc');
//定义非命令行下运行时需要的常量
if (empty($_SERVER['argv']))
{
$port = ($_SERVER['SERVER_PORT'] == '80') ? '' : ':' . $_SERVER['SERVER_PORT'];
//定义APP入口URL
define('BOOT_URL', 'http://' . $_SERVER['SERVER_NAME'] . $port . $_SERVER['SCRIPT_NAME']);
//定义APP根目录
define('BOOT_DIR', str_replace('/' . basename(BOOT_URL), '', BOOT_URL));
//定义站点根目录
define('ROOT_DIR', substr(BOOT_DIR, 0, strrpos(BOOT_DIR, '/')));
//定义站点公共静态资源目录
define('PUBLIC_DIR', ROOT_DIR . '/public');
}
//启动...
require SYS_PATH . '/boot.php';
//END | 01cms | 01cms/branches/v1.0/install/index.php | PHP | asf20 | 1,361 |
<?php
/**
* 01CMS安装程序
*
* @package 01CMS
* @subpackage install
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
class IndexController extends Controller
{
function __construct ()
{
parent::__construct();
if (file_exists(APP_PATH . '/locked.txt'))
{
$this->backUrl = ROOT_DIR;
$temp = '1CM';
showInfo("你已经安装过0{$temp}S了!<br />如需重新安装请删除文件:" . APP_PATH . '/locked.txt');
}
}
function index ($step = 1)
{
if ($step == 1)
{
$writeable = array();
$writeable[] = array('file' => SYS_PATH . '/config', 'status' => is_writeable(SYS_PATH . '/config'));
$writeable[] = array('file' => SYS_PATH . '/data', 'status' => is_writeable(SYS_PATH . '/data'));
$writeable[] = array('file' => ROOT_PATH . '/01cms/config', 'status' => is_writeable(ROOT_PATH . '/01cms/config'));
$writeable[] = array('file' => ROOT_PATH . '/01cms/data', 'status' => is_writeable(ROOT_PATH . '/01cms/data'));
$writeable[] = array('file' => ROOT_PATH . '/www/config', 'status' => is_writeable(ROOT_PATH . '/www/config'));
$writeable[] = array('file' => ROOT_PATH . '/www/data', 'status' => is_writeable(ROOT_PATH . '/www/data'));
$soft = array();
$soft['PHP']['version'] = substr(phpversion(), 0, 3);
$soft['PHP']['status'] = $soft['PHP']['version'] > 5.0 ? TRUE : FALSE;
$soft['MySQL']['version'] = '';
$soft['MySQL']['status'] = function_exists('mysql_connect') ? TRUE : FALSE;
$soft['GD']['version'] = '';
if (! function_exists('phpinfo'))
{
$soft['GD']['status'] = function_exists('imagecreate') ? TRUE : FALSE;
}
else
{
ob_start();
phpinfo(8);
$phpinfo = ob_get_contents();
ob_end_clean();
$matches = array();
if (preg_match("/\bgd\s+version\b[^\d\n\r]+?([\d\.]+)/i", $phpinfo, $matches))
{
$soft['GD']['version'] = $matches[1];
$soft['GD']['status'] = TRUE;
}
else
{
$soft['GD']['status'] = FALSE;
}
}
$next = true;
foreach ($writeable as $v)
{
if (! $v['status'])
{
$next = false;
break;
}
}
foreach ($soft as $v)
{
if (! $v['status'])
{
$next = false;
break;
}
}
$this->writeable = $writeable;
$this->soft = $soft;
$this->next = $next;
}
if ($step == 3 && ! file_exists(APP_PATH . '/locked.txt'))
{
file_put_contents(APP_PATH . '/locked.txt', "系统安装完成后会自动生成这个文件,如需重新安装请删除本文件!");
}
$this->Load->view('smarty', 'step' . $step);
}
function install ()
{
$data = $this->Load->post('hostname|数据库主机名不能为空,database|数据库名称不能为空,username|数据库用户名不能为空,password,prefix|数据表前缀不能为空,adminUsername|后台管理用户名不能为空,adminPassword|后台用户密码不能为空');
if ($error = $this->Load->getError())
{
response($error);
}
$conn = @mysql_connect($data['hostname'], $data['username'], $data['password']);
if (! $conn)
{
response("数据库连接失败,请检查配置是否正确");
}
$status = @mysql_query("CREATE DATABASE IF NOT EXISTS `{$data['database']}`;", $conn);
if (! $status)
{
response("数据库创建失败,请检查是否有权限创建数据库。");
}
@mysql_close($conn);
$config = array();
$config['secret'] = md5(microtime(TRUE));
$config['urlSuffix'] = '';
$config['mysql']['hostname'] = $data['hostname'];
$config['mysql']['username'] = $data['username'];
$config['mysql']['password'] = $data['password'];
$config['mysql']['database'] = $data['database'];
$config['mysql']['prefix'] = $data['prefix'];
$config['mysql']['pconnect'] = FALSE;
$config['mysql']['charset'] = 'utf8';
$configFile = SYS_PATH . '/config/config.php';
if (! is_writeable($configFile))
{
response("配置文件不可写,无法继续安装:<br />{$configFile}");
}
$comment = "全局配置文件\n\n";
$comment .= "secret:安装时自动生成的加密字符串,请勿修改\n";
$comment .= "urlSuffix:URL伪后缀,用于URL重写时去掉入口文件名";
$status = lib('Write')->phpArray($configFile, $config, $comment);
if (empty($status))
{
response('配置文件写入失败');
}
Base::i()->Load->config = $config;
$Model = model('Db');
$query = '';
$fp = fopen(APP_PATH . '/data/sql/01cms.sql', 'r');
while (! feof($fp))
{
$line = rtrim(fgets($fp, 1024));
if (ereg(";$", $line))
{
$query .= $line . "\n";
$Model->query($query);
$query = '';
}
else if (! ereg("^(//|--|/\*)", $line))
{
$query .= $line;
}
}
fclose($fp);
$Model->query("INSERT INTO `@@__admin_user` (`username`, `password`, `groupId`, `email`, `regTime`, `loginTime`, `loginIp`, `loginNum`)
VALUES ('{$data['adminUsername']}', '" . encrypt($data['adminPassword']) . "', 1, 'cms01@qq.com', '" . TIME . "', '" . TIME . "', '" . getIp() . "', 0);");
response('安装成功,正在转向,请稍候...', true);
}
function check ($type = '')
{
$data = $this->Load->post('hostname|数据库主机名不能为空,username|数据库用户名不能为空,password');
if ($error = $this->Load->getError())
{
$response['message'] = $error;
$response['success'] = FALSE;
}
else
{
$status = @mysql_connect($data['hostname'], $data['username'], $data['password']);
if ($status)
{
if ($type == 'database')
{
$database = $this->Load->post('database', 'one');
$status = @mysql_select_db($database);
if ($status)
{
$response['message'] = '数据库已存在';
$response['success'] = TRUE;
}
else
{
$response['message'] = '数据库不存在,系统将会自动创建数据库';
$response['success'] = TRUE;
}
}
else
{
$response['message'] = '数据库连接成功';
$response['success'] = TRUE;
}
}
else
{
$response['message'] = '数据库连接失败';
$response['success'] = FALSE;
}
}
echo json_encode($response);
}
}
//END | 01cms | 01cms/branches/v1.0/install/controller/IndexController.php | PHP | asf20 | 8,267 |
<div class="foot">
© 2010 01CMS DEV TEAM. All rights reserved. Powered by <a target="_blank" href="http://www.01CMS.com/">01CMS</a>
</div><!--/foot--> | 01cms | 01cms/branches/v1.0/template/default/foot.tpl | Smarty | asf20 | 181 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{:$i->Load->var.siteName}</title>
<link rel="stylesheet" href="{:$smarty.const.PUBLIC_DIR}/common/style/01cms.css" type="text/css" />
</head>
<body>
<div class="wrapper">
{:include file="./head.tpl"}
<div class="index">
<div class="left">
<div class="flash">
<script language='javascript'>
linkarr = new Array();
picarr = new Array();
textarr = new Array();
var swf_width=716;
var swf_height=218;
var files = "";
var links = "";
var texts = "";
var index = 0;
//这里设置调用标记
{:counter start=0 print=false}
{:archive size=5 flag='f'}
index = {:counter};
linkarr[index] = "{:$item->url}";
picarr[index] = "{:$item->thumb}";
textarr[index] = '{:$item->title|@strip_tags}';
{:/archive}
for(i=1;i<picarr.length;i++){
if(files=="") files = picarr[i];
else files += "|"+picarr[i];
}
for(i=1;i<linkarr.length;i++){
if(links=="") links = linkarr[i];
else links += "|"+linkarr[i];
}
for(i=1;i<textarr.length;i++){
if(texts=="") texts = textarr[i];
else texts += "|"+textarr[i];
}
//不显示title
//texts = '';
document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+ swf_width +'" height="'+ swf_height +'">');
document.write('<param name="movie" value="{:$smarty.const.PUBLIC_DIR}/common/image/bcastr3.swf"><param name="quality" value="high">');
document.write('<param name="menu" value="false"><param name=wmode value="opaque">');
document.write('<param name="FlashVars" value="bcastr_file='+files+'&bcastr_link='+links+'&bcastr_title='+texts+'&bcastr_config=0xffffff|2|0xeeeeee|10|0xffffff|0xeeeeee|0x000033|2|0|1|_blank">');
document.write('<embed src="{:$smarty.const.PUBLIC_DIR}/common/image/bcastr3.swf" wmode="opaque" FlashVars="bcastr_config=0xffffff|2|0xeeeeee|10|0xffffff|0xeeeeee|0x000033|2|0|1|_blank&bcastr_file='+files+'&bcastr_link='+links+'&bcastr_title='+texts+'& menu="false" quality="high" width="'+ swf_width +'" height="'+ swf_height +'" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />'); document.write('</object>');
</script>
</div>
<!--/flash-->
<dl class="picture">
<dt><em><a href="{:$category->staticUrl}">更多...</a></em>最新图文</dt>
<dd>
<ul>
{:archive size=5 flag='p'}
<li><img src="{:$item->thumb}" /><div><a href="{:$item->url}">{:$item->title}</a></div></li>
{:/archive}
</ul>
<div class="clear"></div>
</dd>
</dl>
{:block size=10 tpl="archiveBlock"}
<dl>
<dt><em><a href="{:$category->staticUrl}">更多...</a></em>{:$category->name}</dt>
{:$archiveBlock}
</dl>
{:/block}
<div class="blank5"></div>
</div>
<div class="panel">
<h3>推荐文章</h3>
<ul>
{:archive size=10}
<li><a href="{:$item->staticUrl}">{:$item->title}</a></li>
{:/archive}
</ul>
<h3>最新文章</h3>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h3>友情链接</h3>
<ul>
<li><a href="http://www.01cms.com" target="_blank">01CMS网站内容管理系统</a></li>
</ul>
</div>
</div><!--/index-->
{:include file="./foot.tpl"}
</div><!--/wrapper-->
</div>
</body>
</html>
| 01cms | 01cms/branches/v1.0/template/default/index.tpl | Smarty | asf20 | 4,235 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{:$i->data.name} - {:$i->Load->var.siteName}</title>
<link rel="stylesheet" href="{:$smarty.const.PUBLIC_DIR}/common/style/01cms.css" type="text/css" />
</head>
<body>
<div class="wrapper">
{:include file="./head.tpl"}
<div class="list">
<div class="left">
<div class="position"><strong>当前位置:</strong>{:categoryPosition id=$i->id}</div>
{:foreach from=$i->lists item=item}
<dl>
<dt><em><a href="#" onclick="return false;">评论</a>(0)</em><a href="{:$item->url}">{:$item->title}</a> ({:$item->pubTime|date_format:"%y-%m-%d %H:%I"})</dt>
<dd>{:$item->desc}</dd>
</dl>
{:/foreach}
<dl>{:$i->pagesCode}</dl>
<div class="blank5"></div>
</div>
<div class="right">
<h1>推荐文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>热门文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>最新文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>友情链接</h1>
<ul>
<li><a href="http://www.01mvc.com">01开发站</a></li>
</ul>
</div>
</div><!--/mail-->
{:include file="./foot.tpl"}
</div><!--/wrapper-->
</body>
</html>
| 01cms | 01cms/branches/v1.0/template/default/articleList.tpl | Smarty | asf20 | 2,085 |
<div class="head">
<div class="info">
<a href="{:$smarty.const.ROOT_DIR}">本站首页</a>
<a onclick="addFavor('{:$smarty.const.ROOT_DIR}', '{:$i->Load->var.siteName}');return false;" href="#">加入收藏</a>
</div>
<div class="logo"><a href="{:$smarty.const.ROOT_DIR}"><img src="{:$smarty.const.PUBLIC_DIR}/common/image/logo.gif" /></a></div>
</div><!--/head-->
<div class="nav">
<form id="search" action="{:$smarty.const.ROOT_DIR}/io.php/data/search" method="get">关键词:<input size="20" value="{:$i->keyWord}" name="k" />
<a href="#@" onclick="document.getElementById('search').submit();">搜索</a>
</form>
<div class="menu">
{:category}
<a href="{:$item->url}">{:$item->name}</a>
{:/category}
</div>
</div>
<script language="javascript">
function addFavor(sURL, sTitle)
{
try
{
window.external.addFavorite(sURL, sTitle);
}
catch (e)
{
try
{
window.sidebar.addPanel(sTitle, sURL, "");
}
catch (e)
{
alert("加入收藏到浏览器失败,请使用Ctrl+D进行添加");
}
}
}
</script> | 01cms | 01cms/branches/v1.0/template/default/head.tpl | Smarty | asf20 | 1,348 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{:$i->data.name} - {:$i->Load->var.siteName}</title>
<link rel="stylesheet" href="{:$smarty.const.PUBLIC_DIR}/common/style/01cms.css" type="text/css" />
</head>
<body>
<div class="wrapper">
{:include file="./head.tpl"}
<div class="list">
<div class="left">
<div class="position"><strong>当前位置:</strong>{:categoryPosition id=$i->id}</div>
{:foreach from=$i->lists item=item}
<dl>
<dt><em><a href="#" onclick="return false;">评论</a>(0)</em><a href="{:$item->url}">{:$item->title}</a> ({:$item->pubTime|date_format:"%y-%m-%d %H:%I"})</dt>
<dd>{:$item->desc}</dd>
</dl>
{:/foreach}
<dl>{:$i->pagesCode}</dl>
<div class="blank5"></div>
</div>
<div class="right">
<h1>推荐文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>热门文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>最新文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>友情链接</h1>
<ul>
<li><a href="http://www.01mvc.com">01开发站</a></li>
</ul>
</div>
</div><!--/mail-->
{:include file="./foot.tpl"}
</div><!--/wrapper-->
</body>
</html>
| 01cms | 01cms/branches/v1.0/template/default/companyList.tpl | Smarty | asf20 | 2,085 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{:$i->data.name} - {:$i->Load->var.siteName}</title>
<link rel="stylesheet" href="{:$smarty.const.PUBLIC_DIR}/common/style/01cms.css" type="text/css" />
</head>
<body>
<div class="wrapper">
{:include file="./head.tpl"}
<div class="list">
<div class="left">
<div class="position"><strong>当前位置:</strong>{:categoryPosition id=$i->id}</div>
{:foreach from=$i->lists item=item}
<dl>
<dt><em><a href="#" onclick="return false;">评论</a>(0)</em><a href="{:$item->url}">{:$item->title}</a> ({:$item->pubTime|date_format:"%y-%m-%d %H:%I"})</dt>
<dd>{:$item->desc}</dd>
</dl>
{:/foreach}
<dl>{:$i->pagesCode}</dl>
<div class="blank5"></div>
</div>
<div class="right">
<h1>推荐文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>热门文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>最新文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>友情链接</h1>
<ul>
<li><a href="http://www.01mvc.com">01开发站</a></li>
</ul>
</div>
</div><!--/mail-->
{:include file="./foot.tpl"}
</div><!--/wrapper-->
</body>
</html>
| 01cms | 01cms/branches/v1.0/template/default/pictureList.tpl | Smarty | asf20 | 2,085 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{:$i->show->title} - {:$i->Load->var.siteName}</title>
<link rel="stylesheet" href="{:$smarty.const.PUBLIC_DIR}/common/style/01cms.css" type="text/css" />
</head>
<body>
<div class="wrapper">
{:include file="./head.tpl"}
<div class="show">
<div class="left">
<div class="position"><strong>当前位置:</strong>{:categoryPosition id=$i->show->categoryId}</div>
<h1>{:$i->show->title}</h1>
<div class="info">{:$i->show->source} {:$i->show->pubTime|date_format:"%Y-%m-%d %H:%I"} {:$i->show->author}</div>
<div class="desc">{:$i->show->desc}</div>
<div class="content">
{:$i->show->content}
<br />
{:$i->pagesCode}
</div>
<div class="blank5"></div>
</div>
<div class="middle">
<h1>推荐阅读:</h1>
<ul>
{:archive size=20}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
</div>
<div class="right">
<h1>热门文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>最新文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
</div>
</div><!--/main-->
{:include file="./foot.tpl"}
</div><!--/wrapper-->
</body>
</html>
| 01cms | 01cms/branches/v1.0/template/default/articleShow.tpl | Smarty | asf20 | 2,004 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{:$i->show->title} - {:$i->Load->var.siteName}</title>
<link rel="stylesheet" href="{:$smarty.const.PUBLIC_DIR}/common/style/01cms.css" type="text/css" />
</head>
<body>
<div class="wrapper">
{:include file="./head.tpl"}
<div class="show">
<div class="left">
<div class="position"><strong>当前位置:</strong>{:categoryPosition id=$i->show->categoryId}</div>
<h1>{:$i->show->title}</h1>
<div class="info">{:$i->show->source} {:$i->show->pubTime|date_format:"%Y-%m-%d %H:%I"} {:$i->show->author}</div>
<div class="desc">{:$i->show->desc}</div>
<div class="content">
{:$i->show->content}
<br />
{:$i->pagesCode}
</div>
<div class="blank5"></div>
</div>
<div class="middle">
<h1>推荐阅读:</h1>
<ul>
{:archive size=20}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
</div>
<div class="right">
<h1>热门文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>最新文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
</div>
</div><!--/main-->
{:include file="./foot.tpl"}
</div><!--/wrapper-->
</body>
</html>
| 01cms | 01cms/branches/v1.0/template/default/companyShow.tpl | Smarty | asf20 | 2,004 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{:$i->data.name} - {:$i->Load->var.siteName}</title>
<link rel="stylesheet" href="{:$smarty.const.PUBLIC_DIR}/common/style/01cms.css" type="text/css" />
</head>
<body>
<div class="wrapper">
{:include file="./head.tpl"}
<div class="list">
<div class="left">
<div class="position"><strong>当前位置:</strong>{:categoryPosition id=$i->id} <strong>分类:</strong>{:category parentId = $i->id} <a href="{:$item->url}">{:$item->name}</a>{:/category}</div>
{:foreach from=$i->lists item=item}
<dl>
<dt><em><a href="#" onclick="return false;">评论</a>(0)</em><a href="{:$item->url}">{:$item->title}</a> ({:$item->pubTime|date_format:"%y-%m-%d %H:%I"})</dt>
<dd>{:$item->desc}</dd>
</dl>
{:/foreach}
<dl>{:$i->pagesCode}</dl>
<div class="blank5"></div>
</div>
<div class="right">
<h1>推荐文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>热门文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>最新文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>友情链接</h1>
<ul>
<li><a href="http://www.01mvc.com">01开发站</a></li>
</ul>
</div>
</div><!--/mail-->
{:include file="./foot.tpl"}
</div><!--/wrapper-->
</body>
</html>
| 01cms | 01cms/branches/v1.0/template/default/categoryIndex.tpl | Smarty | asf20 | 2,196 |
{:foreach item=item from=$i->archiveBlock}
<dd><em>[{:$item->pubTime|date_format:"%m-%d %H:%I"}]</em><a href="{:$item->url}">{:$item->title}</a></dd>
{:/foreach} | 01cms | 01cms/branches/v1.0/template/default/archiveBlock.tpl | Smarty | asf20 | 163 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>01开发站</title>
<link rel="stylesheet" href="{:$smarty.const.PUBLIC_DIR}/common/style/01cms.css" type="text/css" />
<style>
.result span{ color:#F60;}
</style>
</head>
<body>
<div class="wrapper">
{:include file="./head.tpl"}
<div class="list">
<div class="left">
<h1>搜索:{:$i->keyWord}</h1>
{:foreach from=$i->lists item=item}
<dl class="result">
<dt><em><a href="#" onclick="return false;">评论</a>(0)</em><a href="{:$item->url}">{:$item->title}</a> ({:$item->pubTime|date_format:"%y-%m-%d %H:%I"})</dt>
<dd>{:$item->desc}</dd>
</dl>
{:/foreach}
<dl>{:$i->pagesCode}</dl>
<div class="blank5"></div>
</div>
<div class="right">
<h1>推荐文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>热门文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>最新文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>友情链接</h1>
<ul>
<li><a href="http://www.01mvc.com">01开发站</a></li>
</ul>
</div>
</div><!--/mail-->
{:include file="./foot.tpl"}
</div><!--/wrapper-->
</body>
</html>
| 01cms | 01cms/branches/v1.0/template/default/search.tpl | Smarty | asf20 | 2,039 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{:$i->show->title} - {:$i->Load->var.siteName}</title>
<meta name="keywords" content="{:$i->show->keywords}" />
<meta name="description" content="{:$i->show->description}" />
<link rel="stylesheet" href="{:$smarty.const.PUBLIC_DIR}/default/style.css" type="text/css" />
</head>
<body>
<div class="wrapper">
{:include file="./head.tpl"}
<div class="show">
<div class="left">
<div class="position"><strong>当前位置:</strong>单页文档</div>
<h1>{:$i->show->title}</h1>
<div class="desc">{:$i->show->description}</div>
<div class="content">
{:$i->show->content}
</div>
<div class="blank5"></div>
</div>
<div class="middle">
<h1>推荐阅读:</h1>
<ul>
{:archive size=20}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
</div>
<div class="right">
<h1>热门文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>最新文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
</div>
</div><!--/main-->
{:include file="./foot.tpl"}
</div><!--/wrapper-->
</body>
</html>
| 01cms | 01cms/branches/v1.0/template/default/single.tpl | Smarty | asf20 | 1,876 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>{:$i->show->title} - {:$i->Load->var.siteName}</title>
<link rel="stylesheet" href="{:$smarty.const.PUBLIC_DIR}/common/style/01cms.css" type="text/css" />
</head>
<body>
<div class="wrapper">
{:include file="./head.tpl"}
<div class="show">
<div class="left">
<div class="position"><strong>当前位置:</strong>{:categoryPosition id=$i->show->categoryId}</div>
<h1>{:$i->show->title}</h1>
<div class="info">{:$i->show->source} {:$i->show->pubTime|date_format:"%Y-%m-%d %H:%I"} {:$i->show->author}</div>
<div class="desc">{:$i->show->desc}</div>
<div class="content">
{:$i->show->content}
<br />
{:$i->pagesCode}
</div>
<div class="blank5"></div>
</div>
<div class="middle">
<h1>推荐阅读:</h1>
<ul>
{:archive size=20}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
</div>
<div class="right">
<h1>热门文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
<h1>最新文章</h1>
<ul>
{:archive size=10}
<li><a href="{:$item->url}">{:$item->title}</a></li>
{:/archive}
</ul>
</div>
</div><!--/main-->
{:include file="./foot.tpl"}
</div><!--/wrapper-->
</body>
</html>
| 01cms | 01cms/branches/v1.0/template/default/pictureShow.tpl | Smarty | asf20 | 2,004 |
<?php
/**
* 全局配置文件
*
* secret:安装时自动生成的加密字符串,请勿修改
* urlSuffix:URL伪后缀,用于URL重写时去掉入口文件名
*/
return array (
'secret' => 'f0767113f405339ff7c22055c7bd000a',
'urlSuffix' => '',
'mysql' =>
array (
'hostname' => 'localhost',
'username' => 'root',
'password' => 'feawadsx',
'database' => '01cms',
'prefix' => '01cms_',
'pconnect' => false,
'charset' => 'utf8',
),
); | 01cms | 01cms/branches/v1.0/01mvc/config/config.php | PHP | asf20 | 485 |
<?php
return array (
'siteName' => '01CMS 网站内容管理系统',
'pageDelimiter' => '<div style="page-break-after: always;"><span style="display: none;">01cms</span></div>',
'pagesContentChannel' => 'article',
'pageSize' => '20',
'htmlSaveDir' => '/html',
'homepageTemplateName' => 'index.tpl',
'homepageFileName' => 'index.html',
'publicAppPath' => '/www',
'style' => 'default',
'pass' => '1',
); | 01cms | 01cms/branches/v1.0/01mvc/config/var.php | PHP | asf20 | 421 |
<?php
return array (
'uploadPath' => 'Y/md',
'allowedTypes' => 'jpg|png|gif|rar|zip|doc|txt',
'maxSize' => '2048',
'createThumb' => '1',
'thumbWidth' => '200',
'thumbHeight' => '150',
'thumbPadColor' => '#FFFFFF',
'thumbMarker' => '_thumb',
'width' => '1024',
'height' => '768',
'wmText' => 'www.01cms.com',
'wmType' => 'overlay',
'wmFontSize' => '16',
'wmFontPath' => 'vrinda.ttf',
'wmFontColor' => '#FFFFFF',
'wmShadowColor' => '#333333',
'wmShadowDistance' => '2',
'wmVrtAlignment' => 'B',
'wmHorAlignment' => 'R',
'wmOpacity' => '60',
'wmPadding' => '-5',
'wmOverlayPath' => 'logo.gif',
'wmHorOffset' => '0',
'wmVrtOffset' => '0',
); | 01cms | 01cms/branches/v1.0/01mvc/data/uploadSetting.php | PHP | asf20 | 685 |
<?php
return array( 'hqx' => 'application/mac-binhex40',
'cpt' => 'application/mac-compactpro',
'csv' => array('text/x-comma-separated-values', 'text/comma-separated-values', 'application/octet-stream', 'application/vnd.ms-excel', 'text/csv', 'application/csv', 'application/excel', 'application/vnd.msexcel'),
'bin' => 'application/macbinary',
'dms' => 'application/octet-stream',
'lha' => 'application/octet-stream',
'lzh' => 'application/octet-stream',
'exe' => 'application/octet-stream',
'class' => 'application/octet-stream',
'psd' => 'application/x-photoshop',
'so' => 'application/octet-stream',
'sea' => 'application/octet-stream',
'dll' => 'application/octet-stream',
'oda' => 'application/oda',
'pdf' => array('application/pdf', 'application/x-download'),
'ai' => 'application/postscript',
'eps' => 'application/postscript',
'ps' => 'application/postscript',
'smi' => 'application/smil',
'smil' => 'application/smil',
'mif' => 'application/vnd.mif',
'xls' => array('application/excel', 'application/vnd.ms-excel', 'application/msexcel'),
'ppt' => array('application/powerpoint', 'application/vnd.ms-powerpoint'),
'wbxml' => 'application/wbxml',
'wmlc' => 'application/wmlc',
'dcr' => 'application/x-director',
'dir' => 'application/x-director',
'dxr' => 'application/x-director',
'dvi' => 'application/x-dvi',
'gtar' => 'application/x-gtar',
'gz' => 'application/x-gzip',
'php' => 'application/x-httpd-php',
'php4' => 'application/x-httpd-php',
'php3' => 'application/x-httpd-php',
'phtml' => 'application/x-httpd-php',
'phps' => 'application/x-httpd-php-source',
'js' => 'application/x-javascript',
'swf' => 'application/x-shockwave-flash',
'sit' => 'application/x-stuffit',
'tar' => 'application/x-tar',
'tgz' => 'application/x-tar',
'xhtml' => 'application/xhtml+xml',
'xht' => 'application/xhtml+xml',
'zip' => array('application/x-zip', 'application/zip', 'application/x-zip-compressed'),
'mid' => 'audio/midi',
'midi' => 'audio/midi',
'mpga' => 'audio/mpeg',
'mp2' => 'audio/mpeg',
'mp3' => array('audio/mpeg', 'audio/mpg'),
'aif' => 'audio/x-aiff',
'aiff' => 'audio/x-aiff',
'aifc' => 'audio/x-aiff',
'ram' => 'audio/x-pn-realaudio',
'rm' => 'audio/x-pn-realaudio',
'rpm' => 'audio/x-pn-realaudio-plugin',
'ra' => 'audio/x-realaudio',
'rv' => 'video/vnd.rn-realvideo',
'wav' => 'audio/x-wav',
'bmp' => 'image/bmp',
'gif' => 'image/gif',
'jpeg' => array('image/jpeg', 'image/pjpeg'),
'jpg' => array('image/jpeg', 'image/pjpeg'),
'jpe' => array('image/jpeg', 'image/pjpeg'),
'png' => array('image/png', 'image/x-png'),
'tiff' => 'image/tiff',
'tif' => 'image/tiff',
'css' => 'text/css',
'html' => 'text/html',
'htm' => 'text/html',
'shtml' => 'text/html',
'txt' => 'text/plain',
'text' => 'text/plain',
'log' => array('text/plain', 'text/x-log'),
'rtx' => 'text/richtext',
'rtf' => 'text/rtf',
'xml' => 'text/xml',
'xsl' => 'text/xml',
'mpeg' => 'video/mpeg',
'mpg' => 'video/mpeg',
'mpe' => 'video/mpeg',
'qt' => 'video/quicktime',
'mov' => 'video/quicktime',
'avi' => 'video/x-msvideo',
'movie' => 'video/x-sgi-movie',
'doc' => 'application/msword',
'docx' => 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'word' => array('application/msword', 'application/octet-stream'),
'xl' => 'application/excel',
'eml' => 'message/rfc822'
);
| 01cms | 01cms/branches/v1.0/01mvc/data/mime.php | PHP | asf20 | 3,812 |
<?php
return array (
1 =>
array (
'name' => '办事指南',
'isHidden' => '0',
'type' => '1',
'alias' => 'banshizhinan',
'channelId' => '1',
'pageSize' => '20',
'categoryTemplateName' => 'articleList.tpl',
'archiveTemplateName' => 'articleShow.tpl',
'archiveUrl' => '/html/[alias]/%Y/%m%d/[id].html',
'link' => '',
'sonIds' => '',
'allSonIds' => '',
),
2 =>
array (
'name' => '协会动态',
'isHidden' => '0',
'type' => '1',
'alias' => 'xiehuidongtai',
'channelId' => '1',
'pageSize' => '20',
'categoryTemplateName' => 'articleList.tpl',
'archiveTemplateName' => 'articleShow.tpl',
'archiveUrl' => '/html/[alias]/%Y/%m%d/[id].html',
'link' => '',
'sonIds' => '',
'allSonIds' => '',
),
3 =>
array (
'name' => '政策法规',
'isHidden' => '0',
'type' => '1',
'alias' => 'zhengwugongkai',
'channelId' => '1',
'pageSize' => '20',
'categoryTemplateName' => 'articleList.tpl',
'archiveTemplateName' => 'articleShow.tpl',
'archiveUrl' => '/html/[alias]/%Y/%m%d/[id].html',
'link' => '',
'sonIds' => '',
'allSonIds' => '',
),
4 =>
array (
'name' => '标准规范',
'isHidden' => '0',
'type' => '1',
'alias' => 'biaozhunguifan',
'channelId' => '1',
'pageSize' => '20',
'categoryTemplateName' => 'articleList.tpl',
'archiveTemplateName' => 'articleShow.tpl',
'archiveUrl' => '/html/[alias]/%Y/%m%d/[id].html',
'link' => '',
'sonIds' => '',
'allSonIds' => '',
),
5 =>
array (
'name' => '清洁生产',
'isHidden' => '0',
'type' => '1',
'alias' => 'qingjieshengchan',
'channelId' => '1',
'pageSize' => '20',
'categoryTemplateName' => 'articleList.tpl',
'archiveTemplateName' => 'articleShow.tpl',
'archiveUrl' => '/html/[alias]/%Y/%m%d/[id].html',
'link' => '',
'sonIds' => '',
'allSonIds' => '',
),
6 =>
array (
'name' => '环境信息',
'isHidden' => '0',
'type' => '1',
'alias' => 'huanjingxinxi',
'channelId' => '1',
'pageSize' => '20',
'categoryTemplateName' => 'articleList.tpl',
'archiveTemplateName' => 'articleShow.tpl',
'archiveUrl' => '/html/[alias]/%Y/%m%d/[id].html',
'link' => '',
'sonIds' => '',
'allSonIds' => '',
),
7 =>
array (
'name' => '企业名录',
'isHidden' => '0',
'type' => '1',
'alias' => 'qiyeminglu',
'channelId' => '3',
'pageSize' => '20',
'categoryTemplateName' => 'companyList.tpl',
'archiveTemplateName' => 'companyShow.tpl',
'archiveUrl' => '/html/[alias]/%Y/%m%d/[id].html',
'link' => '',
'sonIds' => '',
'allSonIds' => '',
),
8 =>
array (
'name' => '公告',
'isHidden' => '1',
'type' => '1',
'alias' => 'gonggao',
'channelId' => '1',
'pageSize' => '20',
'categoryTemplateName' => 'articleList.tpl',
'archiveTemplateName' => 'articleShow.tpl',
'archiveUrl' => '/html/[alias]/%Y/%m%d/[id].html',
'link' => '',
'sonIds' => '',
'allSonIds' => '',
),
9 =>
array (
'name' => '产品与技术',
'isHidden' => '1',
'type' => '1',
'alias' => 'chanpinyujishu',
'channelId' => '1',
'pageSize' => '20',
'categoryTemplateName' => 'articleList.tpl',
'archiveTemplateName' => 'articleShow.tpl',
'archiveUrl' => '/html/[alias]/%Y/%m%d/[id].html',
'link' => '',
'sonIds' => '',
'allSonIds' => '',
),
10 =>
array (
'name' => '工作交流',
'isHidden' => '1',
'type' => '1',
'alias' => 'gongzuojiaoliu',
'channelId' => '1',
'pageSize' => '20',
'categoryTemplateName' => 'articleList.tpl',
'archiveTemplateName' => 'articleShow.tpl',
'archiveUrl' => '/html/[alias]/%Y/%m%d/[id].html',
'link' => '',
'sonIds' => '',
'allSonIds' => '',
),
11 =>
array (
'name' => '组织机构',
'isHidden' => '0',
'type' => '1',
'alias' => 'zuzhijigou',
'channelId' => '1',
'pageSize' => '20',
'categoryTemplateName' => 'articleList.tpl',
'archiveTemplateName' => 'articleShow.tpl',
'archiveUrl' => '/html/[alias]/%Y/%m%d/[id].html',
'link' => '',
'sonIds' => '',
'allSonIds' => '',
),
'ids' =>
array (
'banshizhinan' => '1',
'xiehuidongtai' => '2',
'zhengwugongkai' => '3',
'biaozhunguifan' => '4',
'qingjieshengchan' => '5',
'huanjingxinxi' => '6',
'qiyeminglu' => '7',
'gonggao' => '8',
'chanpinyujishu' => '9',
'gongzuojiaoliu' => '10',
'zuzhijigou' => '11',
),
); | 01cms | 01cms/branches/v1.0/01mvc/data/archiveCategory.php | PHP | asf20 | 4,615 |
<?php
return array (
1 =>
array (
'name' => '文章',
'tableId' => 'article',
'fieldList' => 'content|文章内容不能为空',
'categoryIds' => '1,2,3,4,5,6,8,9,10,11',
),
2 =>
array (
'name' => '图集',
'tableId' => 'picture',
'fieldList' => 'content|图片内容不能为空',
'categoryIds' => '',
),
3 =>
array (
'name' => '企业',
'tableId' => 'company',
'fieldList' => 'contact|联系人不能为空,business,address,tel,homepage',
'categoryIds' => '7',
),
); | 01cms | 01cms/branches/v1.0/01mvc/data/archiveChannel.php | PHP | asf20 | 537 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>01CMS 提示信息</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<style>
body { font-family: Verdana; font-size:13px; }
h1 { border-bottom:1px solid #ccc; padding:0 0 5px 0; font-size:18px; margin:0 0 5px 0; }
a { text-decoration:none; color:#666; font-weight:bold; padding:0 3px; }
a:hover { color:#FF6600; }
p { padding:0; margin:0; }
.wrapper { padding:10px; margin:5px auto; color:#666; background:#F6F6F6; border:1px solid #ccc; width:600px; }
.message { padding:10px; line-height:150%; background:#fff; border:1px solid #eee; color:#000;}
.action { padding:0; margin:15px 0 8px 0; }
</style>
</head>
<body>
<div class="wrapper">
<h1>01CMS 提示信息</h1>
<p class="message"><?php echo $message;?></p>
<p class="action"> [<a href="<?php if(isset(Base::i()->backUrl)){echo Base::i()->backUrl;}else{echo 'javascript:history.back()';}?>">返回</a>] [<a href="<?php echo getCurUrl ();?>">重试</a>] [<a href="http://www.01cms.com">求助</a>]</p>
</div>
</body>
</html>
| 01cms | 01cms/branches/v1.0/01mvc/view/info.php | PHP | asf20 | 1,204 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>01CMS ERROR</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8"/>
<style>
body { font-family: Verdana; font-size:13px; }
h1 { border-bottom:1px solid #ddd; padding:8px 0; font-size:18px; margin:0 0 10px 0; }
a { text-decoration:none; color:#000; font-weight:bold; padding:0 3px; }
a:hover { color:#FF6600; }
p { padding:0; margin:0; }
.wrapper { padding:10px; margin:5px; color:#666; background:#FCFCFC; border:1px solid #ddd; }
.message { padding:10px; line-height:150%; background:#ffd; border:1px solid #eee; color:#999;}
.action { padding:0; margin:15px 0 8px 0; }
.error{ color:#000; font-weight:bold;}
</style>
</head>
<body>
<div class="wrapper">
<h1>01CMS ERROR</h1>
<p class="message"><?php echo $message;?></p>
<p class="action"> [<a href="<?php echo($_SERVER['PHP_SELF'])?>">重试</a>] [<a href="javascript:history.back()">返回</a>] [<a href="http://www.01cms.com">发送错误</a>] 到官方网站或登陆 [<a href="http://www.01cms.com">01CMS</a>] 求助中心寻求解决方案</p>
</div>
</body>
</html>
| 01cms | 01cms/branches/v1.0/01mvc/view/error.php | PHP | asf20 | 1,245 |
<?php
/**
* 系统引导文件
*
* @package 01CMS
* @subpackage system
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
if (! defined('SYS_PATH'))
{
exit('SYS_PATH ERROR');
}
try
{
require (SYS_PATH . '/lib/Load.php');
$Load = new Load();
require (SYS_PATH . '/common.php');
require (SYS_PATH . '/lib/Uri.php');
require (SYS_PATH . '/lib/Base.php');
require (SYS_PATH . '/lib/Controller.php');
$Uri = lib('Uri');
$c = $Uri->getClassName();
$m = $Uri->getMethodName();
$p = $Uri->getParam();
$controllerName = $c . 'Controller';
if (! file_exists(APP_PATH . '/controller/' . $controllerName . '.php'))
{
throw new Exception('您访问的页面不存在');
}
else
{
require (APP_PATH . '/controller/' . $controllerName . '.php');
}
if (class_exists($controllerName, FALSE))
{
$Controller = new $controllerName();
if (method_exists($Controller, $m) && ! empty($m))
{
call_user_func_array(array($Controller, $m), $p);
}
else
{
throw new Exception('您访问的页面不存在');
}
}
else
{
throw new Exception('您访问的页面不存在');
}
}
catch (Exception $e)
{
$message = '<span class="error">' . $e->getMessage() . '</span>';
include SYS_PATH . '/view/error.php';
}
/* End of file /01CMS/01mvc/boot.php */ | 01cms | 01cms/branches/v1.0/01mvc/boot.php | PHP | asf20 | 1,590 |
<?php
/**
* 全局函数和设置
*
* @package 01CMS
* @subpackage system
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
//设定编码
header('Content-Type: text/html; charset=utf-8');
//设置时区
if (function_exists('date_default_timezone_set'))
{
date_default_timezone_set('Asia/Shanghai');
}
//定义时间常量
define('TIME', time());
if (! function_exists('date_default_timezone_set'))
{
function json_encode ($data)
{
return lib('Services_JSON')->encode($data);
}
}
if (! defined('DIRECTORY_SEPARATOR'))
{
define('DIRECTORY_SEPARATOR', strtoupper(substr(PHP_OS, 0, 3) == 'WIN') ? '\\' : '/');
}
/**
* 自动加载[类文件]
*
* @param string $className
* @return void
*/
function __autoload ($className)
{
$type = (strpos($className, 'Model') > 0) ? 'model' : 'lib';
if (file_exists(APP_PATH . '/' . $type . '/' . $className . '.php'))
{
require_once (APP_PATH . '/' . $type . '/' . $className . '.php');
}
else if (file_exists(SYS_PATH . '/' . $type . '/' . $className . '.php'))
{
require_once (SYS_PATH . '/' . $type . '/' . $className . '.php');
}
else if (file_exists(APP_PATH . '/' . $type . '/' . $className . '/' . $className . '.php'))
{
require_once (APP_PATH . '/' . $type . '/' . $className . '/' . $className . '.php');
}
else if (file_exists(SYS_PATH . '/' . $type . '/' . $className . '/' . $className . '.php'))
{
require_once (SYS_PATH . '/' . $type . '/' . $className . '/' . $className . '.php');
}
else
{
throw new Exception("Class '{$className}' not found!");
}
}
/**
* 加载类库
*
* @param string $libName
* @param mix $param
* @return object
*/
function lib ($libName, $param = NULL)
{
return $GLOBALS['Load']->_class($libName, $param);
}
/**
* 加载模型
*
* @param string $libName
* @param mix $param
* @return object
*/
function model ($modelName, $param = NULL)
{
return $GLOBALS['Load']->_class($modelName . 'Model', $param);
}
/**
* 加载数据
*
* @param string $libName
* @param mix $param
* @return object
*/
function data ($fileName)
{
return $GLOBALS['Load']->_file($fileName, 'data');
}
/**
* 加载配置文件
*
* @param string $libName
* @param mix $param
* @return object
*/
function config ($fileName)
{
return $GLOBALS['Load']->_file($fileName, 'config');
}
/**
* 输出错误并中止程序运行
*
* @param string $message 错误提示信息
* @return void
*/
function showError ($message = '')
{
if ($message == '404')
{
$message = '您访问的页面不存在!';
}
$message = '<span class="error">' . $message . '</span>';
include SYS_PATH . '/view/error.php';
exit();
}
/**
* 输出提示信息
*
* @param string $message 提示信息
* @return void
*/
function showInfo ($message = '')
{
include SYS_PATH . '/view/info.php';
exit();
}
/**
* postResponse
*
* @param string $message
* @param string $goUrl
* @param string $stayTime
* @param string $javascript
* @return void
*/
function responseToParent ($message, $goUrl = '', $stayTime = 3, $javascript = FALSE)
{
$info = json_encode(array('message'=>$message, 'goUrl'=>$goUrl, 'stayTime'=>$stayTime, 'javascript'=>$javascript));
echo '<script language="javascript" type="text/javascript">window.parent.postResponse(' . $info . ');</script>';
exit();
}
/**
* response
*
* @param string $message
* @param string $success
* @param string $javascript
* @return void
*/
function response ($message, $success = FALSE, $javascript = FALSE)
{
header('Cache-Control:no-cache, must-revalidate');
echo json_encode(array('message'=>$message, 'success'=>$success, 'javascript'=>$javascript));
exit();
}
/**
* 对引号添加或去除反斜杠
*
* @param string $svar
* @param string $type (add | slash)
* @param string $force
* @return void
*/
function slashQuotes (&$svar, $type = 'add', $force = false)
{
if (! get_magic_quotes_gpc() || $force)
{
if (is_array($svar))
{
foreach ($svar as $_k => $_v)
$svar[$_k] = slashQuotes($_v, $type, $force);
}
else
{
$svar = ($type == 'add') ? addslashes($svar) : stripslashes($svar);
}
}
return $svar;
}
/**
* 跳转
*
* @param string $url
* @return void
*/
function redirect ($url)
{
if (strpos($url, 'http://') !== 0)
{
$url = BOOT_URL . '/' . $url;
}
header('location:' . $url);
}
/**
* 获取客户端IP
*
* @return string
*/
function getIp ()
{
if (getenv('HTTP_CLIENT_IP') && strcasecmp(getenv('HTTP_CLIENT_IP'), 'unknown'))
{
$ip = getenv('HTTP_CLIENT_IP');
}
elseif (getenv('HTTP_X_FORWARDED_FOR') && strcasecmp(getenv('HTTP_X_FORWARDED_FOR'), 'unknown'))
{
$ip = getenv('HTTP_X_FORWARDED_FOR');
}
elseif (getenv('REMOTE_ADDR') && strcasecmp(getenv('REMOTE_ADDR'), 'unknown'))
{
$ip = getenv('REMOTE_ADDR');
}
elseif (isset($_SERVER['REMOTE_ADDR']) && $_SERVER['REMOTE_ADDR'] && strcasecmp($_SERVER['REMOTE_ADDR'], 'unknown'))
{
$ip = $_SERVER['REMOTE_ADDR'];
}
return $ip;
}
/**
* 获取加密字符串
*
* @param string $var
* @return string
*/
function encrypt ($var)
{
return md5(Base::i()->Load->config['secret'] . $var);
}
/**
* 新建文件夹
*
* @param string $folder
* @param int $mode (0764)
* @return bool
*/
function makeDirs ($folder, $mode = 0764)
{
if (file_exists($folder))
{
return false;
}
$mkfolder = (substr($folder, 0, 1) == "/") ? '/' : '';
$folder = explode("/", $folder);
for ($i = 0; isset($folder[$i]); $i ++)
{
$parentFolder = $mkfolder;
$mkfolder .= empty($folder[$i]) ? '' : $folder[$i] . "/";
if (is_writable($parentFolder))
{
if (! file_exists($mkfolder) && $i > 1)
{
mkdir($mkfolder, $mode);
}
}
}
return TRUE;
}
/**
* 检测是否非空
*
* @param string $var
* @return bool
*/
function notEmpty ($var)
{
return (! empty($var));
}
/**
* 清空目录
*
* @param string $dir
* @return string
*/
function clearDirs ($dir)
{
$dirHandle = opendir($dir);
$msg = '';
while ($fileName = readdir($dirHandle))
{
if ($fileName != "." && $fileName != "..")
{
if (is_dir("$dir/$fileName"))
{
clearDirs($dir . "/" . $fileName);
if (@rmdir("$dir/$fileName"))
{
$msg .= "成功删除:";
}
else
{
$msg .= "删除失败:";
}
$msg .= " -- <strong>$dir/$fileName</strong>";
$msg .= "<br />";
}
else
{
if (@unlink("$dir/$fileName"))
{
$msg .= "成功删除:";
}
else
{
$msg .= "删除失败:";
}
$msg .= " -- $dir/$fileName";
$msg .= "<br />";
}
}
}
closedir($dirHandle);
return $msg;
}
/**
* 获取当前URL
*
* @return string
*/
function getCurUrl ()
{
if (! empty($_SERVER["REQUEST_URI"]))
{
return $_SERVER["REQUEST_URI"];
}
else
{
$scriptName = $_SERVER["PHP_SELF"];
if (empty($_SERVER["QUERY_STRING"]))
{
return $scriptName;
}
else
{
return $scriptName . "?" . $_SERVER["QUERY_STRING"];
}
}
}
/**
* 中文截取(UTF-8)
*
* @param string $str
* @param int $start
* @param int $length
* @return string
*/
function cnSubstr ($str, $start, $length)
{
if (function_exists('mb_substr'))
{
return mb_substr($str, $start, $length, 'UTF-8');
}
$arr = array();
preg_match_all("/./u", $str, $arr);
return implode('', array_slice($arr[0], $start, $length));
}
/**
* 获取缩略图
*
* @param string $url
* @return string
*/
function getThumb ($url)
{
if(empty($url))
{
return PUBLIC_DIR . '/common/image/no_thumb.gif';
}
$setting = data('uploadSetting');
$pos = strrpos($url, '.');
return substr($url, 0, $pos) . $setting['thumbMarker'] . substr($url, $pos);
}
//END
| 01cms | 01cms/branches/v1.0/01mvc/common.php | PHP | asf20 | 9,105 |
<?php
/**
* 栏目列表
*
* @package 01CMS
* @subpackage plugin
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
function smarty_block_category ($params, $content, $smarty, &$repeat)
{
static $category = array();
if (is_null($content))
{
$parentId = isset($params['parentId']) ? $params['parentId'] : 0;
$category = model('Category')->getChildren($parentId, 0, 0, 1, '', '', 'isHidden = 0');
}
if ($o = current($category))
{
if ($o->type > 0)
{
$o->activeUrl = BOOT_URL . '/data/category/' . $o->id;
$o->staticUrl = ROOT_DIR . Base::i()->Load->var['htmlSaveDir'] . '/' . $o->alias;
switch ($o->visit)
{
case 1:
{
$o->url = $o->staticUrl;
break;
}
case 2:
{
$o->url = $o->activeUrl;
break;
}
default:
{
$o->url = defined('staticHtml') ? $o->staticUrl : $o->activeUrl;
}
}
}
else
{
$o->activeUrl = $o->staticUrl = $o->url = $o->link;
}
$smarty->assign('item', $o);
next($category);
$repeat = true;
}
else
{
$repeat = false;
}
return $content;
} | 01cms | 01cms/branches/v1.0/01mvc/plugin/block.category.php | PHP | asf20 | 1,565 |
<?php
/**
* 列出所有栏目的文档
*
* @package 01CMS
* @subpackage plugin
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
function smarty_block_block ($params, $content, $smarty, &$repeat)
{
static $category = array();
if (is_null($content))
{
$parentId = isset($params['parentId']) ? $params['parentId'] : 0;
$category = model('Category')->getChildren ($parentId, 0, 1);
}
if ($o = current($category))
{
if ($o->type != 0)
{
$o->activeUrl = BOOT_URL . '/data/category/' . $o->id;
$o->staticUrl = Base::i()->Load->var['htmlSaveDir'] . '/' . $o->alias;
$o->url = defined('staticHtml') ? $o->staticUrl : $o->activeUrl;
$smarty->assign('category', $o);
$params['categoryId'] = $o->id;
if(empty($params['tpl'])){
$params['tpl'] = 'archiveBlock';
}
$data = model('Archive')->getArchives($params);
Base::i()->archiveBlock = model('Archive')->setArchiveFlag($data);
$contentBlock = $smarty->fetch($params['tpl'].'.tpl');
$smarty->assign('archiveBlock', $contentBlock);
}
next($category);
$repeat = true;
}
else
{
$repeat = false;
}
return $content;
}
| 01cms | 01cms/branches/v1.0/01mvc/plugin/block.block.php | PHP | asf20 | 1,468 |
<?php
/**
* 调用文档
*
* @package 01CMS
* @subpackage plugin
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
function smarty_block_archive ($params, $content, $smarty, &$repeat)
{
static $data = array();
if (is_null($content))
{
$Model = model('Archive');
$data = $Model->getArchives($params);
$data = $Model->setArchiveFlag($data);
}
if ($o = current($data))
{
$smarty->assign('item', $o);
next($data);
$repeat = true;
}
else
{
$repeat = false;
}
return $content;
}
| 01cms | 01cms/branches/v1.0/01mvc/plugin/block.archive.php | PHP | asf20 | 679 |
<?php
/**
* 打印HTML
*
* @package 01CMS
* @subpackage plugin
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
function smarty_modifier_printHtml ($string)
{
return htmlspecialchars(stripslashes($string));
}
| 01cms | 01cms/branches/v1.0/01mvc/plugin/modifier.printHtml.php | PHP | asf20 | 286 |
<?php
/**
* 当前位置
*
* @package 01CMS
* @subpackage plugin
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
function smarty_function_categoryPosition ($params)
{
if (! isset($params['isLink']))
{
$params['isLink'] = 1;
}
if (! isset($params['sign']))
{
$params['sign'] = ' » ';
}
$Category = model('Category');
$Category->getParent($params['id']);
$parent = $Category->parentCategory;
$string = '';
foreach ($parent as $o)
{
if ($params['isLink'])
{
$o->activeUrl = BOOT_URL . '/data/category/' . $o->id;
$o->staticUrl = ROOT_DIR . Base::i()->Load->var['htmlSaveDir'] . '/' . $o->alias;
switch ($o->visit)
{
case 1:
{
$o->url = $o->staticUrl;
}
case 2:
{
$o->url = $o->activeUrl;
}
default:
{
$o->url = defined('staticHtml') ? $o->staticUrl : $o->activeUrl;
}
}
$o->name = "<a href=\"{$o->url}\">{$o->name}</a>";
}
if (empty($string))
{
$string = $o->name;
}
else
{
$string = $o->name . $params['sign'] . $string;
}
}
return $string;
}
| 01cms | 01cms/branches/v1.0/01mvc/plugin/function.categoryPosition.php | PHP | asf20 | 1,552 |
<?php
/**
* 获取缩略图地址
*
* @package 01CMS
* @subpackage plugin
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
function smarty_modifier_thumb ($url)
{
return getThumb($url);
}
| 01cms | 01cms/branches/v1.0/01mvc/plugin/modifier.thumb.php | PHP | asf20 | 265 |
<?php
/**
* 输出应用于title里的HTML
*
* @package 01CMS
* @subpackage plugin
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
function smarty_modifier_tipHtml ($string)
{
return nl2br(str_replace('"','\'',$string));
} | 01cms | 01cms/branches/v1.0/01mvc/plugin/modifier.tipHtml.php | PHP | asf20 | 299 |
<?php
/**
* 栏目别名
*
* @package 01CMS
* @subpackage plugin
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
function smarty_modifier_alias ($id)
{
$category = Base::i()->Load->data('category');
return $category[$id]['alias'];
}
| 01cms | 01cms/branches/v1.0/01mvc/plugin/modifier.alias.php | PHP | asf20 | 313 |
<?php
/**
* 转换ID
*
* @package 01CMS
* @subpackage plugin
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
function smarty_modifier_translateId ($id,$var)
{
if (isset(Base::i()->{$var}[$id]))
{
return Base::i()->{$var}[$id];
}
return $var;
}
| 01cms | 01cms/branches/v1.0/01mvc/plugin/modifier.translateId.php | PHP | asf20 | 352 |
<?php
/**
* 当前位置
*
* @package 01CMS
* @subpackage plugin
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
function smarty_function_categoryInfo ($params)
{
$Category = model('Category', $params['id']);
if ($Category->type > 0)
{
$Category->activeUrl = BOOT_URL . '/category/' . $params['id'];
$Category->staticUrl = ROOT_DIR . Base::i()->Load->var['htmlSaveDir'] . '/' . $Category->alias;
switch ($Category->visit)
{
case 1:
{
$Category->url = $Category->staticUrl;
break;
}
case 2:
{
$Category->url = $Category->activeUrl;
break;
}
default:
{
$Category->url = defined('staticHtml') ? $Category->staticUrl : $Category->activeUrl;
}
}
}
else
{
$Category->url = $Category->link;
}
return $Category->$params['field'];
}
| 01cms | 01cms/branches/v1.0/01mvc/plugin/function.categoryInfo.php | PHP | asf20 | 1,105 |
<?php
/**
* 加载数据类
*
* @package 01CMS
* @subpackage system
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
class Load
{
public $config = array();
public $var = array();
private $object = array();
private $conf = array();
private $data = array();
private $error = '';
private $Smarty;
private $Base;
private $templateName;
function __construct ()
{
$this->config = $this->_file('config', 'config');
$this->var = include_once (SYS_PATH . '/config/var.php');
if (file_exists(APP_PATH . '/config/var.php'))
{
$var = include_once (APP_PATH . '/config/var.php');
$this->var = array_merge($this->var, $var);
unset($var);
}
}
/**
* 加载类库
*
* @param string $libName
* @param mix $param
* @return object
*/
function lib ($libName, $param = NULL)
{
return $this->_class($libName, $param);
}
/**
* 加载模型
*
* @param string $libName
* @param mix $param
* @return object
*/
function model ($modelName, $param = NULL)
{
return $this->_class($modelName . 'Model', $param);
}
/**
* 加载数据
*
* @param string $libName
* @param mix $param
* @return object
*/
function data ($fileName)
{
return $this->_file($fileName, 'data');
}
/**
* 加载配置文件
*
* @param string $libName
* @param mix $param
* @return object
*/
function config ($fileName)
{
return $this->_file($fileName, 'config');
}
/**
* 加载对象
*
* @param string $fileName
* @param string $param
* @return object
* @access public
*/
public function &_class ($className, $param = NULL)
{
$paramId = (is_string($param) || is_int($param)) ? $param : '';
$classId = $className . $paramId;
if (isset($this->object[$classId]))
{
return $this->object[$classId];
}
$this->object[$classId] = new $className($param);
return $this->object[$classId];
}
/**
* 加载数据文件
*
* @param string $fileName
* @param string $type [data|config]
* @return array
* @access public
*/
public function &_file ($fileName, $type = 'data')
{
if (strpos($fileName, '/') !== FALSE)
{
$fileNameArr = explode('/', $fileName);
$varName = $type . ucfirst($fileNameArr[0]) . ucfirst($fileNameArr[1]);
}
else
{
$varName = $type . $fileName;
}
if (isset($this->data[$varName]))
{
return $this->data[$varName];
}
if (file_exists(APP_PATH . "/{$type}/" . $fileName . '.php'))
{
$this->data[$varName] = include_once (APP_PATH . "/{$type}/" . $fileName . '.php');
}
else if (file_exists(SYS_PATH . "/{$type}/" . $fileName . '.php'))
{
$this->data[$varName] = include_once (SYS_PATH . "/{$type}/" . $fileName . '.php');
}
else
{
return FALSE;
}
return $this->data[$varName];
}
/**
* 加载Smarty
*
* @param string $templateSuffix
* @param int $lifeTime
* @return void
* @access public
*/
public function smarty ($templateSuffix = '', $lifeTime = -1)
{
$this->Base = & Base::i();
$this->templateName = $this->Base->m . ucfirst($templateSuffix) . '.tpl';
$tplPath = isset($this->Base->templateDir) ? $this->Base->templateDir : APP_PATH . '/view/' . $this->Base->c;
$this->Smarty = $this->_class('Smarty');
//$Smarty->debugging = true;
//$this->Smarty->config_dir = '';
//$this->Smarty->use_sub_dirs = true;
$this->Smarty->template_dir = $tplPath;
$compile_dir = APP_PATH . '/data/compile/' . $this->Base->c . '/' . $this->Base->m;
if (! file_exists($compile_dir))
{
makeDirs($compile_dir);
}
if (empty($lifeTime))
{
$caching = FALSE;
}
else
{
$caching = 1;
$cache_dir = APP_PATH . '/data/smarty/cache/' . $this->Base->c . '/' . $this->Base->m;
if (! file_exists($cache_dir))
{
makeDirs($cache_dir);
}
$this->Smarty->cache_dir = $cache_dir;
}
$this->Smarty->compile_dir = $compile_dir;
$this->Smarty->compile_id = isset($this->Base->compileId) ? $this->Base->compileId : '';
$this->Smarty->plugins_dir = array(APP_PATH . '/plugin', SYS_PATH . '/plugin', SYS_PATH . '/lib/Smarty/plugins');
$this->Smarty->caching = $caching;
if ($caching)
{
$this->Smarty->cache_lifetime = $lifeTime;
if ($this->Smarty->is_cached($this->templateName))
{
$this->Smarty->display($this->templateName);
exit();
}
}
}
/**
* 加载视图
*
* @param string $type
* @param string $templateSuffix
* @return void
* @access public
*/
public function view ($type = '', $templateSuffix = '')
{
if ('smarty' == strtolower($type))
{
if (! is_object($this->Smarty))
{
$this->smarty($templateSuffix, 0);
}
$this->Smarty->left_delimiter = '{:';
$this->Smarty->assign_by_ref('i', Base::i());
$this->Smarty->display($this->templateName);
}
else if ('php' == strtolower($type) || empty($type))
{
global $c, $m;
$tplPath = APP_PATH . '/view/' . $c;
if (! file_exists($tplPath . '/' . $m . ucfirst($templateSuffix) . '.tpl'))
{
trigger_error('模板文件 ' . $tplPath . '/' . $m . ucfirst($templateSuffix) . '.tpl 不存在', E_USER_ERROR);
}
include ($tplPath . '/' . $m . ucfirst($templateSuffix) . '.tpl');
}
}
/**
* 获取POST变量
*
* @param string $keys
* @param string $type
* @return mix
* @access public
*/
public function post ($keys, $type = '')
{
$data = $this->processData($_POST, $keys);
return ($type == 'one') ? $data[$keys] : $data;
}
/**
* 获取GET变量
*
* @param string $keys
* @param string $type
* @return mix
* @access public
*/
public function get ($keys, $type = '')
{
$data = $this->processData($_GET, $keys);
return ($type == 'one') ? $data[$keys] : $data;
}
/**
* 获取查询变量
*
* @param string $varString
* @param string $type
* @return mix
* @access public
*/
public function query ($varString, $type = '')
{
if (! empty($_SERVER['QUERY_STRING']))
{
parse_str($_SERVER['QUERY_STRING']);
$varNames = explode(',', $varString);
$data = array();
foreach ($varNames as $varName)
{
$data[$varName] = isset($$varName) ? slashQuotes($$varName, 'add', TRUE) : '';
}
return ($type == 'one') ? $data[$varString] : $data;
}
return FALSE;
}
/**
* 获取错误信息
*
* @return string
* @access public
*/
public function getError ()
{
return $this->error;
}
private function processData ($array, $keys)
{
$keys = explode(',', $keys);
$return = array();
foreach ($keys as $key)
{
$key = explode('|', $key);
$field = $key[0];
if (isset($array[$field]))
{
$curValue = slashQuotes($array[$field]);
if (is_array($curValue))
{
foreach ($curValue as $subCurValue)
{
if (empty($subCurValue))
{
$this->error = $key[1];
return FALSE;
}
}
}
else if (isset($key[1]) && empty($curValue))
{
$this->error = $key[1];
return FALSE;
}
$return[$field] = $curValue;
}
else
{
if (isset($key[1]))
{
$this->error = $key[1];
return FALSE;
}
$return[$field] = NULL;
}
}
return $return;
}
}
// END | 01cms | 01cms/branches/v1.0/01mvc/lib/Load.php | PHP | asf20 | 9,492 |
<?php
/**
* 静态分页类
*
* @package 01CMS
* @subpackage system
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
class StaticPages
{
public $baseUrl = '';
public $firstFileName = '';
public $fileId = '';
public $fileExt = '.html';
public $totalPages = '';
public $pageSize = '';
public $numLinks = 5;
public $curPage = 1;
public $firstLink = '‹ 首页';
public $nextLink = '下一页';
public $prevLink = '上一页';
public $lastLink = '尾页 ›';
public $fullTagOpen = '';
public $fullTagClose = '';
public $firstTagOpen = '';
public $firstTagClose = ' ';
public $lastTagOpen = ' ';
public $lastTagClose = '';
public $curTagOpen = ' <strong>';
public $curTagClose = '</strong>';
public $nextTagOpen = ' ';
public $nextTagClose = ' ';
public $prevTagOpen = ' ';
public $prevTagClose = '';
public $numTagOpen = ' ';
public $numTagClose = '';
public $Base;
function __construct ()
{
$this->Base = & Base::i();
}
function initialize ($params = array())
{
if (count($params) > 0)
{
foreach ($params as $key => $val)
{
if (isset($this->$key))
{
$this->$key = $val;
}
}
}
}
function createLinks ($params)
{
if (count($params) > 0)
{
$this->initialize($params);
}
if (! ($this->totalPages > 0))
{
$this->Base->pagesCode = '<span>没有记录</span>';
return '';
}
if ($this->totalPages == 1)
{
$this->Base->pagesCode = '<span>共1页</span>';
return '';
}
$this->curPage = (int) $this->curPage;
$this->numLinks = (int) $this->numLinks;
if (! is_numeric($this->curPage))
{
$this->curPage = 1;
}
if ($this->curPage > $this->totalPages)
{
$this->curPage = $this->totalPages;
}
$start = (($this->curPage - $this->numLinks) > 0) ? $this->curPage - ($this->numLinks - 1) : 1;
$end = (($this->curPage + $this->numLinks) < $this->totalPages) ? $this->curPage + $this->numLinks : $this->totalPages;
$output = '';
if ($this->curPage > $this->numLinks)
{
$output .= $this->firstTagOpen . '<a href="' . $this->baseUrl . '/' . $this->firstFileName . '">' . $this->firstLink . '</a>' . $this->firstTagClose;
}
if ($this->curPage > 2)
{
$output .= $this->prevTagOpen . '<a href="' . $this->baseUrl . '/' . $this->fileId . ($this->curPage - 1) . $this->fileExt . '">' . $this->prevLink . '</a>' . $this->prevTagClose;
}
for ($loop = $start; $loop <= $end; $loop ++)
{
if ($loop > 0)
{
if ($this->curPage == $loop)
{
$output .= $this->curTagOpen . $loop . $this->curTagClose; // Current page
}
else
{
$n = ($loop == 1) ? "/{$this->firstFileName}" : "/" . $this->fileId . $loop . $this->fileExt;
$output .= $this->numTagOpen . '<a href="' . $this->baseUrl . $n . '">' . $loop . '</a>' . $this->numTagClose;
}
}
}
if ($this->curPage < $this->totalPages)
{
$output .= $this->nextTagOpen . '<a href="' . $this->baseUrl . '/' . $this->fileId . ($this->curPage + 1) . $this->fileExt . '">' . $this->nextLink . '</a>' . $this->nextTagClose;
}
if (($this->curPage + $this->numLinks) < $this->totalPages)
{
$output .= $this->lastTagOpen . '<a href="' . $this->baseUrl . '/' . $this->fileId . $this->totalPages . $this->fileExt . '">' . $this->lastLink . '</a>' . $this->lastTagClose;
}
$output = preg_replace("#([^:])//+#", "\\1/", $output);
$output = $this->fullTagOpen . $output . $this->fullTagClose;
if ($this->pageSize > 1)
{
$output .= " <span>({$this->pageSize}条/页 共{$this->totalPages}页)</span> ";
}
$this->Base->pagesCode = $output;
return '';
}
}
// End | 01cms | 01cms/branches/v1.0/01mvc/lib/StaticPages.php | PHP | asf20 | 4,718 |
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Converts to and from JSON format.
*
* JSON (JavaScript Object Notation) is a lightweight data-interchange
* format. It is easy for humans to read and write. It is easy for machines
* to parse and generate. It is based on a subset of the JavaScript
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
* This feature can also be found in Python. JSON is a text format that is
* completely language independent but uses conventions that are familiar
* to programmers of the C-family of languages, including C, C++, C#, Java,
* JavaScript, Perl, TCL, and many others. These properties make JSON an
* ideal data-interchange language.
*
* This package provides a simple encoder and decoder for JSON notation. It
* is intended for use with client-side Javascript applications that make
* use of HTTPRequest to perform server communication functions - data can
* be encoded into JSON notation for use in a client-side javascript, or
* decoded from incoming Javascript requests. JSON format is native to
* Javascript, and can be directly eval()'ed with no further parsing
* overhead
*
* All strings should be in ASCII or UTF-8 format!
*
* LICENSE: Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met: Redistributions of source code must retain the
* above copyright notice, this list of conditions and the following
* disclaimer. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @package 01CMS
* @subpackage system
* @author Michal Migurski <mike-json@teczno.com>
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
* @copyright 2005 Michal Migurski
* @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
* @license http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
*/
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_SLICE', 1);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_STR', 2);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_ARR', 3);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_OBJ', 4);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_CMT', 5);
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_LOOSE_TYPE', 16);
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
/**
* Converts to and from JSON format.
*
* Brief example of use:
*
* <code>
* // create a new instance of Services_JSON
* $json = new Services_JSON();
*
* // convert a complexe value to JSON notation, and send it to the browser
* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
* $output = $json->encode($value);
*
* print($output);
* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
*
* // accept incoming POST data, assumed to be in JSON notation
* $input = file_get_contents('php://input', 1000000);
* $value = $json->decode($input);
* </code>
*/
class Services_JSON
{
/**
* constructs a new JSON instance
*
* @param int $use object behavior flags; combine with boolean-OR
*
* possible values:
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
* "{...}" syntax creates associative arrays
* instead of objects in decode().
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
* Values which can't be encoded (e.g. resources)
* appear as NULL instead of throwing errors.
* By default, a deeply-nested resource will
* bubble up with an error, so all return values
* from encode() should be checked with isError()
*/
function Services_JSON($use = 0)
{
$this->use = $use;
}
/**
* convert a string from one UTF-16 char to one UTF-8 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf16 UTF-16 character
* @return string UTF-8 character
* @access private
*/
function utf162utf8($utf16)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
switch(true) {
case ((0x7F & $bytes) == $bytes):
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x7F & $bytes);
case (0x07FF & $bytes) == $bytes:
// return a 2-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xC0 | (($bytes >> 6) & 0x1F))
. chr(0x80 | ($bytes & 0x3F));
case (0xFFFF & $bytes) == $bytes:
// return a 3-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xE0 | (($bytes >> 12) & 0x0F))
. chr(0x80 | (($bytes >> 6) & 0x3F))
. chr(0x80 | ($bytes & 0x3F));
}
// ignoring UTF-32 for now, sorry
return '';
}
/**
* convert a string from one UTF-8 char to one UTF-16 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf8 UTF-8 character
* @return string UTF-16 character
* @access private
*/
function utf82utf16($utf8)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
}
switch(strlen($utf8)) {
case 1:
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return $utf8;
case 2:
// return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x07 & (ord($utf8{0}) >> 2))
. chr((0xC0 & (ord($utf8{0}) << 6))
| (0x3F & ord($utf8{1})));
case 3:
// return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr((0xF0 & (ord($utf8{0}) << 4))
| (0x0F & (ord($utf8{1}) >> 2)))
. chr((0xC0 & (ord($utf8{1}) << 6))
| (0x7F & ord($utf8{2})));
}
// ignoring UTF-32 for now, sorry
return '';
}
/**
* encodes an arbitrary variable into JSON format
*
* @param mixed $var any number, boolean, string, array, or object to be encoded.
* see argument 1 to Services_JSON() above for array-parsing behavior.
* if var is a strng, note that encode() always expects it
* to be in ASCII or UTF-8 format!
*
* @return mixed JSON string representation of input var or an error if a problem occurs
* @access public
*/
function encode($var)
{
switch (gettype($var)) {
case 'boolean':
return $var ? 'true' : 'false';
case 'NULL':
return 'null';
case 'integer':
return (int) $var;
case 'double':
case 'float':
return (float) $var;
case 'string':
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
$ascii = '';
$strlen_var = strlen($var);
/*
* Iterate over every character in the string,
* escaping with a slash or encoding to UTF-8 where necessary
*/
for ($c = 0; $c < $strlen_var; ++$c) {
$ord_var_c = ord($var{$c});
switch (true) {
case $ord_var_c == 0x08:
$ascii .= '\b';
break;
case $ord_var_c == 0x09:
$ascii .= '\t';
break;
case $ord_var_c == 0x0A:
$ascii .= '\n';
break;
case $ord_var_c == 0x0C:
$ascii .= '\f';
break;
case $ord_var_c == 0x0D:
$ascii .= '\r';
break;
case $ord_var_c == 0x22:
case $ord_var_c == 0x2F:
case $ord_var_c == 0x5C:
// double quote, slash, slosh
$ascii .= '\\'.$var{$c};
break;
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
// characters U-00000000 - U-0000007F (same as ASCII)
$ascii .= $var{$c};
break;
case (($ord_var_c & 0xE0) == 0xC0):
// characters U-00000080 - U-000007FF, mask 110XXXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
$c += 1;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF0) == 0xE0):
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}));
$c += 2;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF8) == 0xF0):
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}));
$c += 3;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFC) == 0xF8):
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}));
$c += 4;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFE) == 0xFC):
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}),
ord($var{$c + 5}));
$c += 5;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
}
}
return '"'.$ascii.'"';
case 'array':
/*
* As per JSON spec if any array key is not an integer
* we must treat the the whole array as an object. We
* also try to catch a sparsely populated associative
* array with numeric keys here because some JS engines
* will create an array with empty indexes up to
* max_index which can cause memory issues and because
* the keys, which may be relevant, will be remapped
* otherwise.
*
* As per the ECMA and JSON specification an object may
* have any string as a property. Unfortunately due to
* a hole in the ECMA specification if the key is a
* ECMA reserved word or starts with a digit the
* parameter is only accessible using ECMAScript's
* bracket notation.
*/
// treat as a JSON object
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
$properties = array_map(array($this, 'name_value'),
array_keys($var),
array_values($var));
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
return '{' . join(',', $properties) . '}';
}
// treat it like a regular array
$elements = array_map(array($this, 'encode'), $var);
foreach($elements as $element) {
if(Services_JSON::isError($element)) {
return $element;
}
}
return '[' . join(',', $elements) . ']';
case 'object':
$vars = get_object_vars($var);
$properties = array_map(array($this, 'name_value'),
array_keys($vars),
array_values($vars));
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
return '{' . join(',', $properties) . '}';
default:
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
? 'null'
: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
}
}
/**
* array-walking function for use in generating JSON-formatted name-value pairs
*
* @param string $name name of key to use
* @param mixed $value reference to an array element to be encoded
*
* @return string JSON-formatted name-value pair, like '"name":value'
* @access private
*/
function name_value($name, $value)
{
$encoded_value = $this->encode($value);
if(Services_JSON::isError($encoded_value)) {
return $encoded_value;
}
return $this->encode(strval($name)) . ':' . $encoded_value;
}
/**
* reduce a string by removing leading and trailing comments and whitespace
*
* @param $str string string value to strip of comments and whitespace
*
* @return string string value stripped of comments and whitespace
* @access private
*/
function reduce_string($str)
{
$str = preg_replace(array(
// eliminate single line comments in '// ...' form
'#^\s*//(.+)$#m',
// eliminate multi-line comments in '/* ... */' form, at start of string
'#^\s*/\*(.+)\*/#Us',
// eliminate multi-line comments in '/* ... */' form, at end of string
'#/\*(.+)\*/\s*$#Us'
), '', $str);
// eliminate extraneous space
return trim($str);
}
/**
* decodes a JSON string into appropriate variable
*
* @param string $str JSON-formatted string
*
* @return mixed number, boolean, string, array, or object
* corresponding to given JSON input string.
* See argument 1 to Services_JSON() above for object-output behavior.
* Note that decode() always returns strings
* in ASCII or UTF-8 format!
* @access public
*/
function decode($str)
{
$str = $this->reduce_string($str);
switch (strtolower($str)) {
case 'true':
return true;
case 'false':
return false;
case 'null':
return null;
default:
$m = array();
if (is_numeric($str)) {
// Lookie-loo, it's a number
// This would work on its own, but I'm trying to be
// good about returning integers where appropriate:
// return (float)$str;
// Return float or int, as appropriate
return ((float)$str == (integer)$str)
? (integer)$str
: (float)$str;
} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
// STRINGS RETURNED IN UTF-8 FORMAT
$delim = substr($str, 0, 1);
$chrs = substr($str, 1, -1);
$utf8 = '';
$strlen_chrs = strlen($chrs);
for ($c = 0; $c < $strlen_chrs; ++$c) {
$substr_chrs_c_2 = substr($chrs, $c, 2);
$ord_chrs_c = ord($chrs{$c});
switch (true) {
case $substr_chrs_c_2 == '\b':
$utf8 .= chr(0x08);
++$c;
break;
case $substr_chrs_c_2 == '\t':
$utf8 .= chr(0x09);
++$c;
break;
case $substr_chrs_c_2 == '\n':
$utf8 .= chr(0x0A);
++$c;
break;
case $substr_chrs_c_2 == '\f':
$utf8 .= chr(0x0C);
++$c;
break;
case $substr_chrs_c_2 == '\r':
$utf8 .= chr(0x0D);
++$c;
break;
case $substr_chrs_c_2 == '\\"':
case $substr_chrs_c_2 == '\\\'':
case $substr_chrs_c_2 == '\\\\':
case $substr_chrs_c_2 == '\\/':
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
$utf8 .= $chrs{++$c};
}
break;
case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
// single, escaped unicode character
$utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
. chr(hexdec(substr($chrs, ($c + 4), 2)));
$utf8 .= $this->utf162utf8($utf16);
$c += 5;
break;
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
$utf8 .= $chrs{$c};
break;
case ($ord_chrs_c & 0xE0) == 0xC0:
// characters U-00000080 - U-000007FF, mask 110XXXXX
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 2);
++$c;
break;
case ($ord_chrs_c & 0xF0) == 0xE0:
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 3);
$c += 2;
break;
case ($ord_chrs_c & 0xF8) == 0xF0:
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 4);
$c += 3;
break;
case ($ord_chrs_c & 0xFC) == 0xF8:
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 5);
$c += 4;
break;
case ($ord_chrs_c & 0xFE) == 0xFC:
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 6);
$c += 5;
break;
}
}
return $utf8;
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
// array, or object notation
if ($str{0} == '[') {
$stk = array(SERVICES_JSON_IN_ARR);
$arr = array();
} else {
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = array();
} else {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = new stdClass();
}
}
array_push($stk, array('what' => SERVICES_JSON_SLICE,
'where' => 0,
'delim' => false));
$chrs = substr($str, 1, -1);
$chrs = $this->reduce_string($chrs);
if ($chrs == '') {
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
} else {
return $obj;
}
}
//print("\nparsing {$chrs}\n");
$strlen_chrs = strlen($chrs);
for ($c = 0; $c <= $strlen_chrs; ++$c) {
$top = end($stk);
$substr_chrs_c_2 = substr($chrs, $c, 2);
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
// found a comma that is not inside a string, array, etc.,
// OR we've reached the end of the character list
$slice = substr($chrs, $top['where'], ($c - $top['where']));
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
if (reset($stk) == SERVICES_JSON_IN_ARR) {
// we are in an array, so just push an element onto the stack
array_push($arr, $this->decode($slice));
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
// we are in an object, so figure
// out the property name and set an
// element in an associative array,
// for now
$parts = array();
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// "name":value pair
$key = $this->decode($parts[1]);
$val = $this->decode($parts[2]);
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// name:value pair, where name is unquoted
$key = $parts[1];
$val = $this->decode($parts[2]);
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
}
}
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
// found a quote, and we are not inside a string
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
//print("Found start of string at {$c}\n");
} elseif (($chrs{$c} == $top['delim']) &&
($top['what'] == SERVICES_JSON_IN_STR) &&
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
// found a quote, we're in a string, and it's not escaped
// we know that it's not escaped becase there is _not_ an
// odd number of backslashes at the end of the string so far
array_pop($stk);
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
} elseif (($chrs{$c} == '[') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-bracket, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
//print("Found start of array at {$c}\n");
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
// found a right-bracket, and we're in an array
array_pop($stk);
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($chrs{$c} == '{') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-brace, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
//print("Found start of object at {$c}\n");
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
// found a right-brace, and we're in an object
array_pop($stk);
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($substr_chrs_c_2 == '/*') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a comment start, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
$c++;
//print("Found start of comment at {$c}\n");
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
// found a comment end, and we're in one now
array_pop($stk);
$c++;
for ($i = $top['where']; $i <= $c; ++$i)
$chrs = substr_replace($chrs, ' ', $i, 1);
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
}
}
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
return $obj;
}
}
}
}
/**
* Ultimately, this should just call PEAR::isError()
*/
function isError($data, $code = null)
{
if (class_exists('pear')) {
return PEAR::isError($data, $code);
} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
is_subclass_of($data, 'services_json_error'))) {
return true;
}
return false;
}
}
if (class_exists('PEAR_Error')) {
class Services_JSON_Error extends PEAR_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
}
}
} else {
/**
* @todo Ultimately, this class shall be descended from PEAR_Error
*/
class Services_JSON_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
}
}
}
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Services_JSON.php | PHP | asf20 | 34,815 |
<?php
class String
{
private static $pinyins;
function pinyin ($string, $head = 0, $close = 1)
{
$string = iconv('utf-8', 'gbk//ignore', $string);
$returnString = '';
$string = trim($string);
$slen = strlen($string);
if ($slen < 2)
{
return $string;
}
if (count(self::$pinyins) == 0)
{
$fp = fopen(SYS_PATH . '/data/pinyin.dat', 'r');
while (! feof($fp))
{
$line = trim(fgets($fp));
self::$pinyins[$line[0] . $line[1]] = substr($line, 3, strlen($line) - 3);
}
fclose($fp);
}
for ($i = 0; $i < $slen; $i ++)
{
if (ord($string[$i]) > 0x80)
{
$c = $string[$i] . $string[$i + 1];
$i ++;
if (isset(self::$pinyins[$c]))
{
if ($head == 0)
{
$returnString .= self::$pinyins[$c];
}
else
{
$returnString .= self::$pinyins[$c][0];
}
}
else
{
$returnString .= "_";
}
}
else if (eregi("[a-z0-9]", $string[$i]))
{
$returnString .= $string[$i];
}
else
{
$returnString .= "_";
}
}
if ($close == 0)
{
unset(self::$pinyins);
}
return $returnString;
}
} | 01cms | 01cms/branches/v1.0/01mvc/lib/String.php | PHP | asf20 | 1,723 |
<?php
/**
* 会话类
*
* @package 01CMS
* @subpackage system
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
class Session
{
/**
* 写入Cookie
*
* @param string $key
* @param string $value
* @param int $keepTime 有效期(秒)
* @param string $path
* @return bool
* @access public
*/
public static function putCookie ($key, $value, $keepTime = 300, $path = "/")
{
$status1 = setcookie($key, $value, time() + $keepTime, $path);
$status2 = setcookie($key . '_c', encrypt($value), time() + $keepTime, $path);
return ($status1 && $status2);
}
/**
* 删除COOKIE
*
* @param string $key
* @return bool
* @access public
*/
public static function dropCookie ($key)
{
$status1 = setcookie($key, '', time() - 360000, "/");
$status2 = setcookie($key . '_c', '', time() - 360000, "/");
return ($status1 && $status2);
}
/**
* 获取Cookie值
*
* @param string $key
* @return mix
* @access public
*/
public static function getCookie ($key)
{
if (! isset($_COOKIE[$key]) || ! isset($_COOKIE[$key . '_c']))
{
return;
}
if ($_COOKIE[$key . '_c'] != encrypt($_COOKIE[$key]))
{
return;
}
return $_COOKIE[$key];
}
/**
* 写入加密Cookie(设置验证码)
*
* @param string $key
* @param string $value
* @param int $keepTime 有效期(秒)
* @param string $path
* @return bool
* @access public
*/
public static function setCode ($key, $value, $keepTime = 300, $path = "/")
{
return setcookie($key, encrypt(strtolower($value)), time() + $keepTime, $path);
}
/**
* 检测Cookie值(检测验证码)
*
* @param string $key
* @param string $value
* @return bool
* @access public
*/
public static function checkCode ($key, $value)
{
if (! isset($_COOKIE[$key]))
{
return FALSE;
}
$getedValue = $_COOKIE[$key];
setcookie($key, '', time() - 360000, "/");
return (encrypt(strtolower($value)) == $getedValue) ? true : false;
}
/**
* 验证码
*/
public static function validateCode ()
{
//create captcha
$consts = 'cdfgkmnpqrstwxyz23456';
$vowels = 'aek23456789';
for ($x = 0; $x < 6; $x ++)
{
$const[$x] = substr($consts, mt_rand(0, strlen($consts) - 1), 1);
$vow[$x] = substr($vowels, mt_rand(0, strlen($vowels) - 1), 1);
}
$radomstring = $const[0] . $vow[0] . $const[2] . $const[1] . $vow[1] . $const[3] . $vow[3] . $const[4];
$string = substr($radomstring, 0, 4); //only display 4 str
Session::setCode('validateCode', $string, 900);
//set up image, the first number is the width and the second is the height
$imageX = strlen($radomstring) * 8; //the image width
$imageY = 20; //the image height
$im = imagecreatetruecolor($imageX, $imageY);
//creates two variables to store color
$foregroundArr = array(imagecolorallocate($im, rand(0, 20), rand(0, 20), rand(0, 20)), imagecolorallocate($im, rand(0, 20), rand(0, 10), rand(245, 255)), imagecolorallocate($im, rand(245, 255), rand(0, 20), rand(0, 10)), imagecolorallocate($im, rand(245, 255), rand(0, 20), rand(245, 255)));
$middleground = imagecolorallocate($im, rand(200, 160), rand(200, 160), rand(200, 160));
$middleground2 = imagecolorallocatealpha($im, rand(180, 140), rand(180, 140), rand(180, 140), 80);
//fill image with bgcolor
imagefill($im, 0, 0, imagecolorallocate($im, 250, 253, 254));
//writes string
if (function_exists('imagettftext'))
{
imagettftext($im, 18, rand(30, - 30), 5, rand(14, 16), $foregroundArr[rand(0, 3)], SYS_PATH . '/data/font/vrinda.ttf', $string[0]);
imagettftext($im, 12, rand(50, - 50), 20, rand(14, 16), $foregroundArr[rand(0, 3)], SYS_PATH . '/data/font/ARIALNI.TTF', $string[1]);
imagettftext($im, 12, rand(50, - 50), 35, rand(14, 16), $foregroundArr[rand(0, 3)], SYS_PATH . '/data/font/ALGER.TTF', $string[2]);
imagettftext($im, 12, rand(30, - 30), 50, rand(14, 16), $foregroundArr[rand(0, 3)], SYS_PATH . '/data/font/arial.ttf', $string[3]);
}
else
{
imagestring($im, 5, 3, floor(rand(0, 5)) - 1, $string[0], $foregroundArr[rand(0, 3)]);
imagestring($im, 5, 16, floor(rand(0, 5)) - 1, $string[1], $foregroundArr[rand(0, 3)]);
imagestring($im, 5, 23, floor(rand(0, 5)) - 1, $string[2], $foregroundArr[rand(0, 3)]);
imagestring($im, 5, 33, floor(rand(0, 5)) - 1, $string[3], $foregroundArr[rand(0, 3)]);
}
//strikethrough
$border = imagecolorallocate($im, 200, 200, 200);
//imagefilledrectangle($aimg, 0, 0, $x_size - 1, $y_size - 1, $back);
imagerectangle($im, 0, 0, $imageX - 1, $imageY - 1, $border);
$pointcol = imagecolorallocate($im, rand(0, 255), rand(0, 255), rand(0, 255));
for ($i = 0; $i < 80; $i ++)
{
imagesetpixel($im, rand(2, $imageX - 2), rand(2, $imageX - 2), $pointcol);
}
//random shapes
for ($x = 0; $x < 9; $x ++)
{
if (mt_rand(0, $x) % 2 == 0)
{
imageline($im, rand(0, 120), rand(0, 120), rand(0, 120), rand(0, 120), rand(0, 999999));
imageellipse($im, rand(0, 120), rand(0, 120), rand(0, 120), rand(0, 120), $middleground2);
}
else
{
imageline($im, rand(0, 120), rand(0, 120), rand(0, 120), rand(0, 120), rand(0, 999999));
imageellipse($im, rand(0, 120), rand(0, 120), rand(0, 120), rand(0, 120), $middleground);
}
}
//output to browser
header("content-type:image/png\r\n");
imagepng($im);
imagedestroy($im);
}
} | 01cms | 01cms/branches/v1.0/01mvc/lib/Session.php | PHP | asf20 | 6,453 |
<?php
/**
* 文件写操作类
*
* @package 01CMS
* @subpackage system
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
class Write
{
/**
* 将PHP数组写入文件
*
* @param string $filePath 文件路径
* @param array $array 数组值
* @param string $comment 文件注释
* @return int
* @access public
* @version 1.0.0 (2009-7-22)
* @author rolong at vip.qq.com
*/
public function phpArray ($filePath, $array, $comment = '')
{
$string = var_export($array, TRUE);
if(!empty($comment))
{
$comment = str_replace("\r\n", "\n", $comment);
$comment = str_replace("\n", "\n * ", $comment);
$comment = "\n/**\n * {$comment}\n */\n";
}
return file_put_contents($filePath, "<?php{$comment}\nreturn {$string};");
}
}
//End | 01cms | 01cms/branches/v1.0/01mvc/lib/Write.php | PHP | asf20 | 978 |
<?php
/**
* 图片处理类
*
* @package 01CMS
* @subpackage system
* @author rolong at vip.qq.com
* @version 1.0.0
* @link http://www.01cms.com
*/
class ImageLib
{
public $imageLibrary = 'gd2';
public $libraryPath = '';
public $dynamicOutput = FALSE;
public $sourceImage = '';
public $newImage = '';
public $width = '';
public $height = '';
public $quality = '100';
public $createThumb = FALSE;
public $thumbMarker = '_thumb';
public $fullThumbPath;
public $thumbPadColor = '#ffffff';
public $thumbWidth = '';
public $thumbHeight = '';
public $maintainRatio = TRUE;
public $masterDim = 'auto';
public $rotationAngle = '';
public $xAxis = '';
public $yAxis = '';
public $wmText = '';
public $wmType = 'text';
public $wmXTransp = 4;
public $wmYTransp = 4;
public $wmOverlayPath = '';
public $wmFontPath = '';
public $wmFontSize = 17;
public $wmVrtAlignment = 'B';
public $wmHorAlignment = 'C';
public $wmPadding = 5;
public $wmHorOffset = 0;
public $wmVrtOffset = 0;
public $wmFontColor = '#ffffff';
public $wmShadowColor = '';
public $wmShadowDistance = 1;
public $wmOpacity = 50;
public $sourceFolder = '';
public $destFolder = '';
public $mimeType = '';
public $origWidth = '';
public $origHeight = '';
public $imageType = '';
public $sizeStr = '';
public $fullSrcPath = '';
public $fullDstPath = '';
public $createFnc = 'imagecreatetruecolor';
public $copyFnc = 'imagecopyresampled';
public $errorMsg = '';
public $wmUseDropShadow = FALSE;
public $wmUseTruetype = FALSE;
function clear ()
{
$props = array('sourceFolder', 'destFolder', 'sourceImage', 'fullSrcPath', 'fullDstPath', 'newImage', 'imageType', 'sizeStr', 'quality', 'origWidth', 'origHeight', 'rotationAngle', 'xAxis', 'yAxis', 'createFnc', 'copyFnc', 'wmOverlayPath', 'wmUseTruetype', 'dynamicOutput', 'wmFontSize', 'wmText', 'wmVrtAlignment', 'wmHorAlignment', 'wmPadding', 'wmHorOffset', 'wmVrtOffset', 'wmFontColor', 'wmUseDropShadow', 'wmShadowColor', 'wmShadowDistance', 'wmOpacity');
foreach ($props as $val)
{
$this->$val = '';
}
$this->masterDim = 'auto';
}
function initialize ($props = array())
{
if (count($props) > 0)
{
foreach ($props as $key => $val)
{
$this->$key = $val;
}
}
if ($this->sourceImage == '')
{
$this->setError('源图片不存在');
return FALSE;
}
if (! function_exists('getimagesize'))
{
$this->setError('没有加载GD扩展');
return FALSE;
}
$this->imageLibrary = strtolower($this->imageLibrary);
if (function_exists('realpath') and @realpath($this->sourceImage) !== FALSE)
{
$fullSourcePath = str_replace("\\", "/", realpath($this->sourceImage));
}
else
{
$fullSourcePath = $this->sourceImage;
}
$x = explode('/', $fullSourcePath);
$this->sourceImage = end($x);
$this->sourceFolder = str_replace($this->sourceImage, '', $fullSourcePath);
if (! $this->getImageProperties($this->sourceFolder . $this->sourceImage))
{
return FALSE;
}
if ($this->newImage == '')
{
$this->destImage = $this->sourceImage;
$this->destFolder = $this->sourceFolder;
}
else
{
if (strpos($this->newImage, '/') === FALSE)
{
$this->destFolder = $this->sourceFolder;
$this->destImage = $this->newImage;
}
else
{
if (function_exists('realpath') and @realpath($this->newImage) !== FALSE)
{
$fullDestPath = str_replace("\\", "/", realpath($this->newImage));
}
else
{
$fullDestPath = $this->newImage;
}
if (! preg_match("#\.(jpg|jpeg|gif|png)$#i", $fullDestPath))
{
$this->destFolder = $fullDestPath . '/';
$this->destImage = $this->sourceImage;
}
else
{
$x = explode('/', $fullDestPath);
$this->destImage = end($x);
$this->destFolder = str_replace($this->destImage, '', $fullDestPath);
}
}
}
$xp = $this->explodeName($this->destImage);
$filename = $xp['name'];
$file_ext = $xp['ext'];
$this->fullSrcPath = $this->sourceFolder . $this->sourceImage;
$this->fullDstPath = $this->destFolder . $filename . $file_ext;
if ($this->createThumb && $this->thumbMarker != '')
{
$this->fullThumbPath = $this->destFolder . $filename . $this->thumbMarker . $file_ext;
}
if ($this->maintainRatio === TRUE && ($this->width != '' and $this->height != ''))
{
$this->imageReproportion();
}
if ($this->width == '')
{
$this->width = $this->origWidth;
}
if ($this->height == '')
{
$this->height = $this->origHeight;
}
$this->quality = trim(str_replace("%", "", $this->quality));
if ($this->quality == '' or $this->quality == 0 or ! is_numeric($this->quality))
{
$this->quality = 90;
}
$this->xAxis = ($this->xAxis == '' or ! is_numeric($this->xAxis)) ? 0 : $this->xAxis;
$this->yAxis = ($this->yAxis == '' or ! is_numeric($this->yAxis)) ? 0 : $this->yAxis;
if ($this->wmFontColor != '')
{
if (strlen($this->wmFontColor) == 6)
{
$this->wmFontColor = '#' . $this->wmFontColor;
}
}
if ($this->wmShadowColor != '')
{
if (strlen($this->wmShadowColor) == 6)
{
$this->wmShadowColor = '#' . $this->wmShadowColor;
}
}
if ($this->wmOverlayPath != '')
{
$this->wmOverlayPath = str_replace("\\", "/", realpath($this->wmOverlayPath));
}
if ($this->wmShadowColor != '')
{
$this->wmUseDropShadow = TRUE;
}
if ($this->wmFontPath != '')
{
$this->wmUseTruetype = TRUE;
}
return TRUE;
}
function resize ()
{
$protocol = 'imageProcess' . ucfirst($this->imageLibrary);
if (preg_match('/gd2$/i', $protocol))
{
$protocol = 'imageProcessGd';
}
return $this->$protocol('resize');
}
function crop ()
{
$protocol = 'imageProcess' . ucfirst($this->imageLibrary);
if (preg_match('/gd2$/i', $protocol))
{
$protocol = 'imageProcessGd';
}
return $this->$protocol('crop');
}
function rotate ()
{
$degs = array(90, 180, 270, 'vrt', 'hor');
if ($this->rotationAngle == '' or ! in_array($this->rotationAngle, $degs))
{
$this->setError('imglib_rotationAngle_required');
return FALSE;
}
if ($this->rotationAngle == 90 or $this->rotationAngle == 270)
{
$this->width = $this->origHeight;
$this->height = $this->origWidth;
}
else
{
$this->width = $this->origWidth;
$this->height = $this->origHeight;
}
if ($this->imageLibrary == 'imagemagick' or $this->imageLibrary == 'netpbm')
{
$protocol = 'image_process_' . $this->imageLibrary;
return $this->$protocol('rotate');
}
if ($this->rotationAngle == 'hor' or $this->rotationAngle == 'vrt')
{
return $this->imageMirrorGd();
}
else
{
return $this->image_rotate_gd();
}
}
function imageProcessGd ($action = 'resize')
{
$v2Override = FALSE;
if ($this->dynamicOutput === FALSE)
{
if ($this->origWidth == $this->width and $this->origHeight == $this->height)
{
if ($this->sourceImage != $this->newImage)
{
if (@copy($this->fullSrcPath, $this->fullDstPath))
{
@chmod($this->fullDstPath, 0664);
}
}
return TRUE;
}
}
if ($action == 'crop')
{
$this->origWidth = $this->width;
$this->origHeight = $this->height;
if ($this->gdVersion() !== FALSE)
{
$gdVersion = str_replace('0', '', $this->gdVersion());
$v2Override = ($gdVersion == 2) ? TRUE : FALSE;
}
}
else
{
$this->xAxis = 0;
$this->yAxis = 0;
}
if (! ($srcImg = $this->imageCreateGd()))
{
return FALSE;
}
if ($this->origWidth > $this->width || $this->origHeight > $this->height)
{
if ($this->imageLibrary == 'gd2' and function_exists('imagecreatetruecolor'))
{
$create = 'imagecreatetruecolor';
$copy = 'imagecopyresampled';
}
else
{
$create = 'imagecreate';
$copy = 'imagecopyresized';
}
$dstImg = $create($this->width, $this->height);
$copy($dstImg, $srcImg, 0, 0, $this->xAxis, $this->yAxis, $this->width, $this->height, $this->origWidth, $this->origHeight);
if ($this->dynamicOutput == TRUE)
{
$this->image_display_gd($dstImg);
}
else
{
if (! $this->imageSaveGd($dstImg))
{
return FALSE;
}
}
imagedestroy($dstImg);
imagedestroy($srcImg);
@chmod($this->fullDstPath, 0664);
}
return TRUE;
}
function imageProcessImagemagick ($action = 'resize')
{
if ($this->libraryPath == '')
{
$this->setError('imglib_libpath_invalid');
return FALSE;
}
if (! preg_match("/convert$/i", $this->libraryPath))
{
$this->libraryPath = rtrim($this->libraryPath, '/') . '/';
$this->libraryPath .= 'convert';
}
$cmd = $this->libraryPath . " -quality " . $this->quality;
if ($action == 'crop')
{
$cmd .= " -crop " . $this->width . "x" . $this->height . "+" . $this->xAxis . "+" . $this->yAxis . " \"$this->fullSrcPath\" \"$this->fullDstPath\" 2>&1";
}
elseif ($action == 'rotate')
{
switch ($this->rotationAngle)
{
case 'hor':
$angle = '-flop';
break;
case 'vrt':
$angle = '-flip';
break;
default:
$angle = '-rotate ' . $this->rotationAngle;
break;
}
$cmd .= " " . $angle . " \"$this->fullSrcPath\" \"$this->fullDstPath\" 2>&1";
}
else
{
$cmd .= " -resize " . $this->width . "x" . $this->height . " \"$this->fullSrcPath\" \"$this->fullDstPath\" 2>&1";
}
$retval = 1;
@exec($cmd, $output, $retval);
if ($retval > 0)
{
$this->setError('imglib_image_process_failed');
return FALSE;
}
@chmod($this->fullDstPath, DIR_WRITE_MODE);
return TRUE;
}
function imageProcessNetpbm ($action = 'resize')
{
if ($this->libraryPath == '')
{
$this->setError('imglib_libpath_invalid');
return FALSE;
}
switch ($this->imageType)
{
case 1:
$cmd_in = 'giftopnm';
$cmd_out = 'ppmtogif';
break;
case 2:
$cmd_in = 'jpegtopnm';
$cmd_out = 'ppmtojpeg';
break;
case 3:
$cmd_in = 'pngtopnm';
$cmd_out = 'ppmtopng';
break;
}
if ($action == 'crop')
{
$cmd_inner = 'pnmcut -left ' . $this->xAxis . ' -top ' . $this->yAxis . ' -width ' . $this->width . ' -height ' . $this->height;
}
elseif ($action == 'rotate')
{
switch ($this->rotationAngle)
{
case 90:
$angle = 'r270';
break;
case 180:
$angle = 'r180';
break;
case 270:
$angle = 'r90';
break;
case 'vrt':
$angle = 'tb';
break;
case 'hor':
$angle = 'lr';
break;
}
$cmd_inner = 'pnmflip -' . $angle . ' ';
}
else
{
$cmd_inner = 'pnmscale -xysize ' . $this->width . ' ' . $this->height;
}
$cmd = $this->libraryPath . $cmd_in . ' ' . $this->fullSrcPath . ' | ' . $cmd_inner . ' | ' . $cmd_out . ' > ' . $this->destFolder . 'netpbm.tmp';
$retval = 1;
@exec($cmd, $output, $retval);
if ($retval > 0)
{
$this->setError('imglib_image_process_failed');
return FALSE;
}
copy($this->destFolder . 'netpbm.tmp', $this->fullDstPath);
unlink($this->destFolder . 'netpbm.tmp');
@chmod($this->fullDstPath, DIR_WRITE_MODE);
return TRUE;
}
function imageRotateGd ()
{
if (! function_exists('imagerotate'))
{
$this->setError('imglib_rotate_unsupported');
return FALSE;
}
if (! ($srcImg = $this->imageCreateGd()))
{
return FALSE;
}
$white = imagecolorallocate($srcImg, 255, 255, 255);
$dstImg = imagerotate($srcImg, $this->rotationAngle, $white);
if ($this->dynamicOutput == TRUE)
{
$this->image_display_gd($dstImg);
}
else
{
if (! $this->imageSaveGd($dstImg))
{
return FALSE;
}
}
imagedestroy($dstImg);
imagedestroy($srcImg);
@chmod($this->fullDstPath, DIR_WRITE_MODE);
return true;
}
function imageMirrorGd ()
{
if (! $srcImg = $this->imageCreateGd())
{
return FALSE;
}
$width = $this->origWidth;
$height = $this->origHeight;
if ($this->rotationAngle == 'hor')
{
for ($i = 0; $i < $height; $i ++)
{
$left = 0;
$right = $width - 1;
while ($left < $right)
{
$cl = imagecolorat($srcImg, $left, $i);
$cr = imagecolorat($srcImg, $right, $i);
imagesetpixel($srcImg, $left, $i, $cr);
imagesetpixel($srcImg, $right, $i, $cl);
$left ++;
$right --;
}
}
}
else
{
for ($i = 0; $i < $width; $i ++)
{
$top = 0;
$bot = $height - 1;
while ($top < $bot)
{
$ct = imagecolorat($srcImg, $i, $top);
$cb = imagecolorat($srcImg, $i, $bot);
imagesetpixel($srcImg, $i, $top, $cb);
imagesetpixel($srcImg, $i, $bot, $ct);
$top ++;
$bot --;
}
}
}
if ($this->dynamicOutput == TRUE)
{
$this->image_display_gd($srcImg);
}
else
{
if (! $this->imageSaveGd($srcImg))
{
return FALSE;
}
}
imagedestroy($srcImg);
@chmod($this->fullDstPath, DIR_WRITE_MODE);
return TRUE;
}
function watermark ()
{
if ($this->wmType == 'overlay')
{
return $this->overlayWatermark();
}
else
{
return $this->textWatermark();
}
}
function overlayWatermark ()
{
if (! function_exists('imagecolortransparent'))
{
$this->setError('imglib_gd_required');
return FALSE;
}
$this->getImageProperties();
$props = $this->getImageProperties($this->wmOverlayPath, TRUE);
$wmImgType = $props['imageType'];
$wmWidth = $props['width'];
$wmHeight = $props['height'];
$wm_img = $this->imageCreateGd($this->wmOverlayPath, $wmImgType);
$srcImg = $this->imageCreateGd($this->fullSrcPath);
$this->wmVrtAlignment = strtoupper(substr($this->wmVrtAlignment, 0, 1));
$this->wmHorAlignment = strtoupper(substr($this->wmHorAlignment, 0, 1));
if ($this->wmVrtAlignment == 'B')
$this->wmVrtOffset = $this->wmVrtOffset * - 1;
if ($this->wmHorAlignment == 'R')
$this->wmHorOffset = $this->wmHorOffset * - 1;
$xAxis = $this->wmHorOffset + $this->wmPadding;
$yAxis = $this->wmVrtOffset + $this->wmPadding;
switch ($this->wmVrtAlignment)
{
case 'T':
break;
case 'M':
$yAxis += ($this->origHeight / 2) - ($wmHeight / 2);
break;
case 'B':
$yAxis += $this->origHeight - $wmHeight;
break;
}
switch ($this->wmHorAlignment)
{
case 'L':
break;
case 'C':
$xAxis += ($this->origWidth / 2) - ($wmWidth / 2);
break;
case 'R':
$xAxis += $this->origWidth - $wmWidth;
break;
}
if ($wmImgType == 3 and function_exists('imagealphablending'))
{
@imagealphablending($srcImg, TRUE);
}
$rgba = imagecolorat($wm_img, $this->wmXTransp, $this->wmYTransp);
$alpha = ($rgba & 0x7F000000) >> 24;
if ($alpha > 0)
{
imagecopy($srcImg, $wm_img, $xAxis, $yAxis, 0, 0, $wmWidth, $wmHeight);
}
else
{
imagecolortransparent($wm_img, imagecolorat($wm_img, $this->wmXTransp, $this->wmYTransp));
imagecopymerge($srcImg, $wm_img, $xAxis, $yAxis, 0, 0, $wmWidth, $wmHeight, $this->wmOpacity);
}
if ($this->dynamicOutput == TRUE)
{
$this->image_display_gd($srcImg);
}
else
{
if (! $this->imageSaveGd($srcImg))
{
return FALSE;
}
}
imagedestroy($srcImg);
imagedestroy($wm_img);
return TRUE;
}
function textWatermark ()
{
if (! ($srcImg = $this->imageCreateGd()))
{
return FALSE;
}
if ($this->wmUseTruetype == TRUE and ! file_exists($this->wmFontPath))
{
$this->setError('字体文件不存在');
return FALSE;
}
$this->getImageProperties();
$this->wmFontColor = str_replace('#', '', $this->wmFontColor);
$this->wmShadowColor = str_replace('#', '', $this->wmShadowColor);
$R1 = hexdec(substr($this->wmFontColor, 0, 2));
$G1 = hexdec(substr($this->wmFontColor, 2, 2));
$B1 = hexdec(substr($this->wmFontColor, 4, 2));
$R2 = hexdec(substr($this->wmShadowColor, 0, 2));
$G2 = hexdec(substr($this->wmShadowColor, 2, 2));
$B2 = hexdec(substr($this->wmShadowColor, 4, 2));
$txtColor = imagecolorclosest($srcImg, $R1, $G1, $B1);
$drpColor = imagecolorclosest($srcImg, $R2, $G2, $B2);
if ($this->wmVrtAlignment == 'B')
$this->wmVrtOffset = $this->wmVrtOffset * - 1;
if ($this->wmHorAlignment == 'R')
$this->wmHorOffset = $this->wmHorOffset * - 1;
if ($this->wmUseTruetype == TRUE)
{
if ($this->wmFontSize == '')
$this->wmFontSize = '17';
$fontwidth = $this->wmFontSize - ($this->wmFontSize / 4);
$fontheight = $this->wmFontSize;
$this->wmVrtOffset += $this->wmFontSize;
}
else
{
$fontwidth = imagefontwidth($this->wmFontSize);
$fontheight = imagefontheight($this->wmFontSize);
}
$xAxis = $this->wmHorOffset + $this->wmPadding;
$yAxis = $this->wmVrtOffset + $this->wmPadding;
if ($this->wmUseDropShadow == FALSE)
$this->wmShadowDistance = 0;
$this->wmVrtAlignment = strtoupper(substr($this->wmVrtAlignment, 0, 1));
$this->wmHorAlignment = strtoupper(substr($this->wmHorAlignment, 0, 1));
switch ($this->wmVrtAlignment)
{
case "T":
break;
case "M":
$yAxis += ($this->origHeight / 2) + ($fontheight / 2);
break;
case "B":
$yAxis += ($this->origHeight - $fontheight - $this->wmShadowDistance - ($fontheight / 2));
break;
}
$x_shad = $xAxis + $this->wmShadowDistance;
$y_shad = $yAxis + $this->wmShadowDistance;
switch ($this->wmHorAlignment)
{
case "L":
break;
case "R":
if ($this->wmUseDropShadow)
$x_shad += ($this->origWidth - $fontwidth * strlen($this->wmText));
$xAxis += ($this->origWidth - $fontwidth * strlen($this->wmText));
break;
case "C":
if ($this->wmUseDropShadow)
$x_shad += floor(($this->origWidth - $fontwidth * strlen($this->wmText)) / 2);
$xAxis += floor(($this->origWidth - $fontwidth * strlen($this->wmText)) / 2);
break;
}
if ($this->wmUseTruetype)
{
if ($this->wmUseDropShadow)
imagettftext($srcImg, $this->wmFontSize, 0, $x_shad, $y_shad, $drpColor, $this->wmFontPath, $this->wmText);
imagettftext($srcImg, $this->wmFontSize, 0, $xAxis, $yAxis, $txtColor, $this->wmFontPath, $this->wmText);
}
else
{
if ($this->wmUseDropShadow)
imagestring($srcImg, $this->wmFontSize, $x_shad, $y_shad, $this->wmText, $drpColor);
imagestring($srcImg, $this->wmFontSize, $xAxis, $yAxis, $this->wmText, $txtColor);
}
if ($this->dynamicOutput == TRUE)
{
$this->image_display_gd($srcImg);
}
else
{
$this->imageSaveGd($srcImg);
}
imagedestroy($srcImg);
return TRUE;
}
function imageCreateGd ($path = '', $imageType = '')
{
if ($path == '')
$path = $this->fullSrcPath;
if ($imageType == '')
$imageType = $this->imageType;
switch ($imageType)
{
case 1:
if (! function_exists('imagecreatefromgif'))
{
$this->setError(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
return FALSE;
}
return imagecreatefromgif($path);
break;
case 2:
if (! function_exists('imagecreatefromjpeg'))
{
$this->setError(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
return FALSE;
}
return imagecreatefromjpeg($path);
break;
case 3:
if (! function_exists('imagecreatefrompng'))
{
$this->setError(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
return FALSE;
}
return imagecreatefrompng($path);
break;
}
$this->setError(array('imglib_unsupported_imagecreate'));
return FALSE;
}
function imageSaveGd ($resource)
{
switch ($this->imageType)
{
case 1:
if (! function_exists('imagegif'))
{
$this->setError(array('imglib_unsupported_imagecreate', 'imglib_gif_not_supported'));
return FALSE;
}
if (! @imagegif($resource, $this->fullDstPath))
{
$this->setError('imglib_save_failed');
return FALSE;
}
break;
case 2:
if (! function_exists('imagejpeg'))
{
$this->setError(array('imglib_unsupported_imagecreate', 'imglib_jpg_not_supported'));
return FALSE;
}
if (phpversion() == '4.4.1')
{
@touch($this->fullDstPath); // PHP 4.4.1 bug #35060 - workaround
}
if (! @imagejpeg($resource, $this->fullDstPath, $this->quality))
{
$this->setError('imglib_save_failed');
return FALSE;
}
break;
case 3:
if (! function_exists('imagepng'))
{
$this->setError(array('imglib_unsupported_imagecreate', 'imglib_png_not_supported'));
return FALSE;
}
if (! @imagepng($resource, $this->fullDstPath))
{
$this->setError('imglib_save_failed');
return FALSE;
}
break;
default:
$this->setError(array('imglib_unsupported_imagecreate'));
return FALSE;
break;
}
return TRUE;
}
function image_display_gd ($resource)
{
header("Content-Disposition: filename={$this->sourceImage};");
header("Content-Type: {$this->mimeType}");
header('Content-Transfer-Encoding: binary');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
switch ($this->imageType)
{
case 1:
imagegif($resource);
break;
case 2:
imagejpeg($resource, '', $this->quality);
break;
case 3:
imagepng($resource);
break;
default:
echo 'Unable to display the image';
break;
}
}
function imageReproportion ()
{
if (! is_numeric($this->width) or ! is_numeric($this->height) or $this->width == 0 or $this->height == 0)
return;
if (! is_numeric($this->origWidth) or ! is_numeric($this->origHeight) or $this->origWidth == 0 or $this->origHeight == 0)
return;
$newWidth = ceil($this->origWidth * $this->height / $this->origHeight);
$newHeight = ceil($this->width * $this->origHeight / $this->origWidth);
$ratio = (($this->origHeight / $this->origWidth) - ($this->height / $this->width));
if ($this->masterDim != 'width' and $this->masterDim != 'height')
{
$this->masterDim = ($ratio < 0) ? 'width' : 'height';
}
if (($this->width != $newWidth) and ($this->height != $newHeight))
{
if ($this->masterDim == 'height')
{
$this->width = $newWidth;
}
else
{
$this->height = $newHeight;
}
}
}
function getImageProperties ($path = '', $return = FALSE)
{
if ($path == '')
{
$path = $this->fullSrcPath;
}
if (! file_exists($path))
{
$this->setError('图片不存在');
return FALSE;
}
$vals = @getimagesize($path);
$types = array(1=>'gif', 2=>'jpeg', 3=>'png');
$mime = (isset($types[$vals['2']])) ? 'image/' . $types[$vals['2']] : 'image/jpg';
if ($return == TRUE)
{
$v['width'] = $vals['0'];
$v['height'] = $vals['1'];
$v['imageType'] = $vals['2'];
$v['sizeStr'] = $vals['3'];
$v['mimeType'] = $mime;
return $v;
}
$this->origWidth = $vals['0'];
$this->origHeight = $vals['1'];
$this->imageType = $vals['2'];
$this->sizeStr = $vals['3'];
$this->mimeType = $mime;
return TRUE;
}
function sizeCalculator ($vals)
{
if (! is_array($vals))
{
return;
}
$allowed = array('newWidth', 'newHeight', 'width', 'height');
foreach ($allowed as $item)
{
if (! isset($vals[$item]) or $vals[$item] == '')
$vals[$item] = 0;
}
if ($vals['width'] == 0 or $vals['height'] == 0)
{
return $vals;
}
if ($vals['newWidth'] == 0)
{
$vals['newWidth'] = ceil($vals['width'] * $vals['newHeight'] / $vals['height']);
}
elseif ($vals['newHeight'] == 0)
{
$vals['newHeight'] = ceil($vals['newWidth'] * $vals['height'] / $vals['width']);
}
return $vals;
}
function explodeName ($sourceImage)
{
$ext = strrchr($sourceImage, '.');
$name = ($ext === FALSE) ? $sourceImage : substr($sourceImage, 0, - strlen($ext));
return array('ext'=>$ext, 'name'=>$name);
}
function gdLoaded ()
{
if (! extension_loaded('gd'))
{
if (! dl('gd.so'))
{
return FALSE;
}
}
return TRUE;
}
function thumb ()
{
$srcFile = $this->fullSrcPath;
$toFile = $this->fullThumbPath;
$targetWidth = $this->thumbWidth;
$targetHeight = $this->thumbHeight;
switch ($this->imageType)
{
case 1:
{
$img = imagecreatefromgif($srcFile);
break;
}
case 2:
{
$img = imagecreatefromjpeg($srcFile);
break;
}
case 3:
{
$img = imagecreatefrompng($srcFile);
break;
}
case 6:
{
$img = imagecreatefromwbmp($srcFile);
break;
}
}
$width = imagesx($img);
$height = imagesy($img);
if (! $width || ! $height)
{
return false;
}
$targetRatio = $targetWidth / $targetHeight;
$imgRatio = $width / $height;
if ($targetRatio > $imgRatio)
{
$newHeight = $targetHeight;
$newWidth = $imgRatio * $targetHeight;
}
else
{
$newHeight = $targetWidth / $imgRatio;
$newWidth = $targetWidth;
}
if ($newHeight > $targetHeight)
{
$newHeight = $targetHeight;
}
if ($newWidth > $targetWidth)
{
$newHeight = $targetWidth;
}
$newImg = imagecreatetruecolor($targetWidth, $targetHeight);
$padColor = str_replace('#', '', $this->thumbPadColor);
$R = hexdec(substr($padColor, 0, 2));
$G = hexdec(substr($padColor, 2, 2));
$B = hexdec(substr($padColor, 4, 2));
$color = ImageColorAllocate($newImg, $R, $G, $B);
if (! @imagefilledrectangle($newImg, 0, 0, $targetWidth - 1, $targetHeight - 1, $color))
{
return false;
}
if (! @imagecopyresampled($newImg, $img, ($targetWidth - $newWidth) / 2, ($targetHeight - $newHeight) / 2, 0, 0, $newWidth, $newHeight, $width, $height))
{
return false;
}
switch ($this->imageType)
{
case 1:
{
imagegif($newImg, $toFile);
break;
}
case 2:
{
imagejpeg($newImg, $toFile, 100);
break;
}
case 3:
{
imagepng($newImg, $toFile);
break;
}
case 6:
{
imagebmp($newImg, $toFile);
break;
}
default:
{
return false;
}
}
imagedestroy($newImg);
imagedestroy($img);
return true;
}
function gdVersion ()
{
if (function_exists('gd_info'))
{
$gdVersion = @gd_info();
$gdVersion = preg_replace("/\D/", "", $gdVersion['GD Version']);
return $gdVersion;
}
return FALSE;
}
function setError ($msg)
{
if (is_array($msg))
{
foreach ($msg as $val)
{
$this->errorMsg .= ' ' . $val;
}
}
else
{
$this->errorMsg = $msg;
}
}
}
// END ImageLib Class | 01cms | 01cms/branches/v1.0/01mvc/lib/ImageLib.php | PHP | asf20 | 36,305 |
<?php
/**
* Project: Smarty: the PHP compiling template engine
* File: Smarty.class.php
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* For questions, help, comments, discussion, etc., please join the
* Smarty mailing list. Send a blank e-mail to
* smarty-discussion-subscribe@googlegroups.com
*
* @link http://www.smarty.net/
* @copyright 2001-2005 New Digital Group, Inc.
* @author Monte Ohrt <monte at ohrt dot com>
* @author Andrei Zmievski <andrei@php.net>
* @package Smarty
* @version 2.6.22
*/
/* $Id: Smarty.class.php 2785 2008-09-18 21:04:12Z Uwe.Tews $ */
/**
* DIR_SEP isn't used anymore, but third party apps might
*/
if (! defined('DIR_SEP'))
{
define('DIR_SEP', DIRECTORY_SEPARATOR);
}
/**
* set SMARTY_DIR to absolute path to Smarty library files.
* if not defined, include_path will be used. Sets SMARTY_DIR only if user
* application has not already defined it.
*/
if (! defined('SMARTY_DIR'))
{
define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR);
}
if (! defined('SMARTY_CORE_DIR'))
{
define('SMARTY_CORE_DIR', SMARTY_DIR . 'internals' . DIRECTORY_SEPARATOR);
}
define('SMARTY_PHP_PASSTHRU', 0);
define('SMARTY_PHP_QUOTE', 1);
define('SMARTY_PHP_REMOVE', 2);
define('SMARTY_PHP_ALLOW', 3);
/**
* @package Smarty
*/
class Smarty
{
/**#@+
* Smarty Configuration Section
*/
/**
* The name of the directory where templates are located.
*
* @var string
*/
public $template_dir = 'templates';
/**
* The directory where compiled templates are located.
*
* @var string
*/
public $compile_dir = 'templates_c';
/**
* The directory where config files are located.
*
* @var string
*/
public $config_dir = 'configs';
/**
* An array of directories searched for plugins.
*
* @var array
*/
public $plugins_dir = array('plugins');
/**
* If debugging is enabled, a debug console window will display
* when the page loads (make sure your browser allows unrequested
* popup windows)
*
* @var boolean
*/
public $debugging = false;
/**
* When set, smarty does uses this value as error_reporting-level.
*
* @var boolean
*/
public $error_reporting = null;
/**
* This is the path to the debug console template. If not set,
* the default one will be used.
*
* @var string
*/
public $debug_tpl = '';
/**
* This determines if debugging is enable-able from the browser.
* <ul>
* <li>NONE => no debugging control allowed</li>
* <li>Url => enable debugging when SMARTY_DEBUG is found in the Url.</li>
* </ul>
* @link http://www.foo.dom/index.php?SMARTY_DEBUG
* @var string
*/
public $debugging_ctrl = 'NONE';
/**
* This tells Smarty whether to check for recompiling or not. Recompiling
* does not need to happen unless a template or config file is changed.
* Typically you enable this during development, and disable for
* production.
*
* @var boolean
*/
public $compile_check = true;
/**
* This forces templates to compile every time. Useful for development
* or debugging.
*
* @var boolean
*/
public $force_compile = false;
/**
* This enables template caching.
* <ul>
* <li>0 = no caching</li>
* <li>1 = use class cache_lifetime value</li>
* <li>2 = use cache_lifetime in cache file</li>
* </ul>
* @var integer
*/
public $caching = 0;
/**
* The name of the directory for cache files.
*
* @var string
*/
public $cache_dir = 'cache';
/**
* This is the number of seconds cached content will persist.
* <ul>
* <li>0 = always regenerate cache</li>
* <li>-1 = never expires</li>
* </ul>
*
* @var integer
*/
public $cache_lifetime = 3600;
/**
* Only used when $caching is enabled. If true, then If-Modified-Since headers
* are respected with cached content, and appropriate HTTP headers are sent.
* This way repeated hits to a cached page do not send the entire page to the
* client every time.
*
* @var boolean
*/
public $cache_modified_check = false;
/**
* This determines how Smarty handles "<?php ... ?>" tags in templates.
* possible values:
* <ul>
* <li>SMARTY_PHP_PASSTHRU -> print tags as plain text</li>
* <li>SMARTY_PHP_QUOTE -> escape tags as entities</li>
* <li>SMARTY_PHP_REMOVE -> remove php tags</li>
* <li>SMARTY_PHP_ALLOW -> execute php tags</li>
* </ul>
*
* @var integer
*/
public $php_handling = SMARTY_PHP_PASSTHRU;
/**
* This enables template security. When enabled, many things are restricted
* in the templates that normally would go unchecked. This is useful when
* untrusted parties are editing templates and you want a reasonable level
* of security. (no direct execution of PHP in templates for example)
*
* @var boolean
*/
public $security = false;
/**
* This is the list of template directories that are considered secure. This
* is used only if {@link $security} is enabled. One directory per array
* element. {@link $template_dir} is in this list implicitly.
*
* @var array
*/
public $secure_dir = array();
/**
* These are the security settings for Smarty. They are used only when
* {@link $security} is enabled.
*
* @var array
*/
public $security_settings = array('PHP_HANDLING' => false , 'IF_FUNCS' => array('array' , 'list' , 'isset' , 'empty' , 'count' , 'sizeof' , 'in_array' , 'is_array' , 'true' , 'false' , 'null') , 'INCLUDE_ANY' => false , 'PHP_TAGS' => false , 'MODIFIER_FUNCS' => array('count') , 'ALLOW_CONSTANTS' => false);
/**
* This is an array of directories where trusted php scripts reside.
* {@link $security} is disabled during their inclusion/execution.
*
* @var array
*/
public $trusted_dir = array();
/**
* The left delimiter used for the template tags.
*
* @var string
*/
public $left_delimiter = '{';
/**
* The right delimiter used for the template tags.
*
* @var string
*/
public $right_delimiter = '}';
/**
* The order in which request variables are registered, similar to
* variables_order in php.ini E = Environment, G = GET, P = POST,
* C = Cookies, S = Server
*
* @var string
*/
public $request_vars_order = 'EGPCS';
/**
* Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false)
* are uses as request-vars or $_*[]-vars. note: if
* request_use_auto_globals is true, then $request_vars_order has
* no effect, but the php-ini-value "gpc_order"
*
* @var boolean
*/
public $request_use_auto_globals = true;
/**
* Set this if you want different sets of compiled files for the same
* templates. This is useful for things like different languages.
* Instead of creating separate sets of templates per language, you
* set different compile_ids like 'en' and 'de'.
*
* @var string
*/
public $compile_id = null;
/**
* This tells Smarty whether or not to use sub dirs in the cache/ and
* templates_c/ directories. sub directories better organized, but
* may not work well with PHP safe mode enabled.
*
* @var boolean
*
*/
public $use_sub_dirs = false;
/**
* This is a list of the modifiers to apply to all template variables.
* Put each modifier in a separate array element in the order you want
* them applied. example: <code>array('escape:"htmlall"');</code>
*
* @var array
*/
public $default_modifiers = array();
/**
* This is the resource type to be used when not specified
* at the beginning of the resource path. examples:
* $smarty->display('file:index.tpl');
* $smarty->display('db:index.tpl');
* $smarty->display('index.tpl'); // will use default resource type
* {include file="file:index.tpl"}
* {include file="db:index.tpl"}
* {include file="index.tpl"} {* will use default resource type *}
*
* @var array
*/
public $default_resource_type = 'file';
/**
* The function used for cache file handling. If not set, built-in caching is used.
*
* @var null|string function name
*/
public $cache_handler_func = null;
/**
* This indicates which filters are automatically loaded into Smarty.
*
* @var array array of filter names
*/
public $autoload_filters = array();
/**#@+
* @var boolean
*/
/**
* This tells if config file vars of the same name overwrite each other or not.
* if disabled, same name variables are accumulated in an array.
*/
public $config_overwrite = true;
/**
* This tells whether or not to automatically booleanize config file variables.
* If enabled, then the strings "on", "true", and "yes" are treated as boolean
* true, and "off", "false" and "no" are treated as boolean false.
*/
public $config_booleanize = true;
/**
* This tells whether hidden sections [.foobar] are readable from the
* tempalates or not. Normally you would never allow this since that is
* the point behind hidden sections: the application can access them, but
* the templates cannot.
*/
public $config_read_hidden = false;
/**
* This tells whether or not automatically fix newlines in config files.
* It basically converts \r (mac) or \r\n (dos) to \n
*/
public $config_fix_newlines = true;
/**#@-*/
/**
* If a template cannot be found, this PHP function will be executed.
* Useful for creating templates on-the-fly or other special action.
*
* @var string function name
*/
public $default_template_handler_func = '';
/**
* The file that contains the compiler class. This can a full
* pathname, or relative to the php_include path.
*
* @var string
*/
public $compiler_file = 'Smarty_Compiler.class.php';
/**
* The class used for compiling templates.
*
* @var string
*/
public $compiler_class = 'Smarty_Compiler';
/**
* The class used to load config vars.
*
* @var string
*/
public $config_class = 'Config_File';
/**#@+
* END Smarty Configuration Section
* There should be no need to touch anything below this line.
* @access private
*/
/**
* where assigned template vars are kept
*
* @var array
*/
public $_tpl_vars = array();
/**
* stores run-time $smarty.* vars
*
* @var null|array
*/
public $_smarty_vars = null;
/**
* keeps track of sections
*
* @var array
*/
public $_sections = array();
/**
* keeps track of foreach blocks
*
* @var array
*/
public $_foreach = array();
/**
* keeps track of tag hierarchy
*
* @var array
*/
public $_tag_stack = array();
/**
* configuration object
*
* @var Config_file
*/
public $_conf_obj = null;
/**
* loaded configuration settings
*
* @var array
*/
public $_config = array(array('vars' => array() , 'files' => array()));
/**
* md5 checksum of the string 'Smarty'
*
* @var string
*/
public $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f';
/**
* Smarty version number
*
* @var string
*/
public $_version = '2.6.22';
/**
* current template inclusion depth
*
* @var integer
*/
public $_inclusion_depth = 0;
/**
* for different compiled templates
*
* @var string
*/
public $_compile_id = null;
/**
* text in Url to enable debug mode
*
* @var string
*/
public $_smarty_debug_id = 'SMARTY_DEBUG';
/**
* debugging information for debug console
*
* @var array
*/
public $_smarty_debug_info = array();
/**
* info that makes up a cache file
*
* @var array
*/
public $_cache_info = array();
/**
* default file permissions
*
* @var integer
*/
public $_file_perms = 0644;
/**
* default dir permissions
*
* @var integer
*/
public $_dir_perms = 0771;
/**
* registered objects
*
* @var array
*/
public $_reg_objects = array();
/**
* table keeping track of plugins
*
* @var array
*/
public $_plugins = array('modifier' => array() , 'function' => array() , 'block' => array() , 'compiler' => array() , 'prefilter' => array() , 'postfilter' => array() , 'outputfilter' => array() , 'resource' => array() , 'insert' => array());
/**
* cache serials
*
* @var array
*/
public $_cache_serials = array();
/**
* name of optional cache include file
*
* @var string
*/
public $_cache_include = null;
/**
* indicate if the current code is used in a compiled
* include
*
* @var string
*/
public $_cache_including = false;
/**#@-*/
/**
* The class constructor.
*/
function Smarty ()
{
$this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] : @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']);
}
/**
* assigns values to template variables
*
* @param array|string $tpl_var the template variable name(s)
* @param mixed $value the value to assign
*/
function assign ($tpl_var, $value = null)
{
if (is_array($tpl_var))
{
foreach ($tpl_var as $key => $val)
{
if ($key != '')
{
$this->_tpl_vars[$key] = $val;
}
}
}
else
{
if ($tpl_var != '')
$this->_tpl_vars[$tpl_var] = $value;
}
}
/**
* assigns values to template variables by reference
*
* @param string $tpl_var the template variable name
* @param mixed $value the referenced value to assign
*/
function assign_by_ref ($tpl_var, &$value)
{
if ($tpl_var != '')
$this->_tpl_vars[$tpl_var] = &$value;
}
/**
* appends values to template variables
*
* @param array|string $tpl_var the template variable name(s)
* @param mixed $value the value to append
*/
function append ($tpl_var, $value = null, $merge = false)
{
if (is_array($tpl_var))
{
// $tpl_var is an array, ignore $value
foreach ($tpl_var as $_key => $_val)
{
if ($_key != '')
{
if (! @is_array($this->_tpl_vars[$_key]))
{
settype($this->_tpl_vars[$_key], 'array');
}
if ($merge && is_array($_val))
{
foreach ($_val as $_mkey => $_mval)
{
$this->_tpl_vars[$_key][$_mkey] = $_mval;
}
}
else
{
$this->_tpl_vars[$_key][] = $_val;
}
}
}
}
else
{
if ($tpl_var != '' && isset($value))
{
if (! @is_array($this->_tpl_vars[$tpl_var]))
{
settype($this->_tpl_vars[$tpl_var], 'array');
}
if ($merge && is_array($value))
{
foreach ($value as $_mkey => $_mval)
{
$this->_tpl_vars[$tpl_var][$_mkey] = $_mval;
}
}
else
{
$this->_tpl_vars[$tpl_var][] = $value;
}
}
}
}
/**
* appends values to template variables by reference
*
* @param string $tpl_var the template variable name
* @param mixed $value the referenced value to append
*/
function append_by_ref ($tpl_var, &$value, $merge = false)
{
if ($tpl_var != '' && isset($value))
{
if (! @is_array($this->_tpl_vars[$tpl_var]))
{
settype($this->_tpl_vars[$tpl_var], 'array');
}
if ($merge && is_array($value))
{
foreach ($value as $_key => $_val)
{
$this->_tpl_vars[$tpl_var][$_key] = &$value[$_key];
}
}
else
{
$this->_tpl_vars[$tpl_var][] = &$value;
}
}
}
/**
* clear the given assigned template variable.
*
* @param string $tpl_var the template variable to clear
*/
function clear_assign ($tpl_var)
{
if (is_array($tpl_var))
foreach ($tpl_var as $curr_var)
unset($this->_tpl_vars[$curr_var]);
else
unset($this->_tpl_vars[$tpl_var]);
}
/**
* Registers custom function to be used in templates
*
* @param string $function the name of the template function
* @param string $function_impl the name of the PHP function to register
*/
function register_function ($function, $function_impl, $cacheable = true, $cache_attrs = null)
{
$this->_plugins['function'][$function] = array($function_impl , null , null , false , $cacheable , $cache_attrs);
}
/**
* Unregisters custom function
*
* @param string $function name of template function
*/
function unregister_function ($function)
{
unset($this->_plugins['function'][$function]);
}
/**
* Registers object to be used in templates
*
* @param string $object name of template object
* @param object &$object_impl the referenced PHP object to register
* @param null|array $allowed list of allowed methods (empty = all)
* @param boolean $smarty_args smarty argument format, else traditional
* @param null|array $block_functs list of methods that are block format
*/
function register_object ($object, &$object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
{
settype($allowed, 'array');
settype($smarty_args, 'boolean');
$this->_reg_objects[$object] = array(&$object_impl , $allowed , $smarty_args , $block_methods);
}
/**
* Unregisters object
*
* @param string $object name of template object
*/
function unregister_object ($object)
{
unset($this->_reg_objects[$object]);
}
/**
* Registers block function to be used in templates
*
* @param string $block name of template block
* @param string $block_impl PHP function to register
*/
function register_block ($block, $block_impl, $cacheable = true, $cache_attrs = null)
{
$this->_plugins['block'][$block] = array($block_impl , null , null , false , $cacheable , $cache_attrs);
}
/**
* Unregisters block function
*
* @param string $block name of template function
*/
function unregister_block ($block)
{
unset($this->_plugins['block'][$block]);
}
/**
* Registers compiler function
*
* @param string $function name of template function
* @param string $function_impl name of PHP function to register
*/
function register_compiler_function ($function, $function_impl, $cacheable = true)
{
$this->_plugins['compiler'][$function] = array($function_impl , null , null , false , $cacheable);
}
/**
* Unregisters compiler function
*
* @param string $function name of template function
*/
function unregister_compiler_function ($function)
{
unset($this->_plugins['compiler'][$function]);
}
/**
* Registers modifier to be used in templates
*
* @param string $modifier name of template modifier
* @param string $modifier_impl name of PHP function to register
*/
function register_modifier ($modifier, $modifier_impl)
{
$this->_plugins['modifier'][$modifier] = array($modifier_impl , null , null , false);
}
/**
* Unregisters modifier
*
* @param string $modifier name of template modifier
*/
function unregister_modifier ($modifier)
{
unset($this->_plugins['modifier'][$modifier]);
}
/**
* Registers a resource to fetch a template
*
* @param string $type name of resource
* @param array $functions array of functions to handle resource
*/
function register_resource ($type, $functions)
{
if (count($functions) == 4)
{
$this->_plugins['resource'][$type] = array($functions , false);
}
elseif (count($functions) == 5)
{
$this->_plugins['resource'][$type] = array(array(array(&$functions[0] , $functions[1]) , array(&$functions[0] , $functions[2]) , array(&$functions[0] , $functions[3]) , array(&$functions[0] , $functions[4])) , false);
}
else
{
$this->trigger_error("malformed function-list for '$type' in register_resource");
}
}
/**
* Unregisters a resource
*
* @param string $type name of resource
*/
function unregister_resource ($type)
{
unset($this->_plugins['resource'][$type]);
}
/**
* Registers a prefilter function to apply
* to a template before compiling
*
* @param callback $function
*/
function register_prefilter ($function)
{
$this->_plugins['prefilter'][$this->_get_filter_name($function)] = array($function , null , null , false);
}
/**
* Unregisters a prefilter function
*
* @param callback $function
*/
function unregister_prefilter ($function)
{
unset($this->_plugins['prefilter'][$this->_get_filter_name($function)]);
}
/**
* Registers a postfilter function to apply
* to a compiled template after compilation
*
* @param callback $function
*/
function register_postfilter ($function)
{
$this->_plugins['postfilter'][$this->_get_filter_name($function)] = array($function , null , null , false);
}
/**
* Unregisters a postfilter function
*
* @param callback $function
*/
function unregister_postfilter ($function)
{
unset($this->_plugins['postfilter'][$this->_get_filter_name($function)]);
}
/**
* Registers an output filter function to apply
* to a template output
*
* @param callback $function
*/
function register_outputfilter ($function)
{
$this->_plugins['outputfilter'][$this->_get_filter_name($function)] = array($function , null , null , false);
}
/**
* Unregisters an outputfilter function
*
* @param callback $function
*/
function unregister_outputfilter ($function)
{
unset($this->_plugins['outputfilter'][$this->_get_filter_name($function)]);
}
/**
* load a filter of specified type and name
*
* @param string $type filter type
* @param string $name filter name
*/
function load_filter ($type, $name)
{
switch ($type)
{
case 'output' :
$_params = array('plugins' => array(array($type . 'filter' , $name , null , null , false)));
require_once (SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins($_params, $this);
break;
case 'pre' :
case 'post' :
if (! isset($this->_plugins[$type . 'filter'][$name]))
$this->_plugins[$type . 'filter'][$name] = false;
break;
}
}
/**
* clear cached content for the given template and cache id
*
* @param string $tpl_file name of template file
* @param string $cache_id name of cache_id
* @param string $compile_id name of compile_id
* @param string $exp_time expiration time
* @return boolean
*/
function clear_cache ($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
{
if (! isset($compile_id))
$compile_id = $this->compile_id;
if (! isset($tpl_file))
$compile_id = null;
$_auto_id = $this->_get_auto_id($cache_id, $compile_id);
if (! empty($this->cache_handler_func))
{
return call_user_func_array($this->cache_handler_func, array('clear' , &$this , &$dummy , $tpl_file , $cache_id , $compile_id , $exp_time));
}
else
{
$_params = array('auto_base' => $this->cache_dir , 'auto_source' => $tpl_file , 'auto_id' => $_auto_id , 'exp_time' => $exp_time);
require_once (SMARTY_CORE_DIR . 'core.rm_auto.php');
return smarty_core_rm_auto($_params, $this);
}
}
/**
* clear the entire contents of cache (all templates)
*
* @param string $exp_time expire time
* @return boolean results of {@link smarty_core_rm_auto()}
*/
function clear_all_cache ($exp_time = null)
{
return $this->clear_cache(null, null, null, $exp_time);
}
/**
* test to see if valid cache exists for this template
*
* @param string $tpl_file name of template file
* @param string $cache_id
* @param string $compile_id
* @return string|false results of {@link _read_cache_file()}
*/
function is_cached ($tpl_file, $cache_id = null, $compile_id = null)
{
if (! $this->caching)
return false;
if (! isset($compile_id))
$compile_id = $this->compile_id;
$_params = array('tpl_file' => $tpl_file , 'cache_id' => $cache_id , 'compile_id' => $compile_id);
require_once (SMARTY_CORE_DIR . 'core.read_cache_file.php');
return smarty_core_read_cache_file($_params, $this);
}
/**
* clear all the assigned template variables.
*
*/
function clear_all_assign ()
{
$this->_tpl_vars = array();
}
/**
* clears compiled version of specified template resource,
* or all compiled template files if one is not specified.
* This function is for advanced use only, not normally needed.
*
* @param string $tpl_file
* @param string $compile_id
* @param string $exp_time
* @return boolean results of {@link smarty_core_rm_auto()}
*/
function clear_compiled_tpl ($tpl_file = null, $compile_id = null, $exp_time = null)
{
if (! isset($compile_id))
{
$compile_id = $this->compile_id;
}
$_params = array('auto_base' => $this->compile_dir , 'auto_source' => $tpl_file , 'auto_id' => $compile_id , 'exp_time' => $exp_time , 'extensions' => array('.inc' , '.php'));
require_once (SMARTY_CORE_DIR . 'core.rm_auto.php');
return smarty_core_rm_auto($_params, $this);
}
/**
* Checks whether requested template exists.
*
* @param string $tpl_file
* @return boolean
*/
function template_exists ($tpl_file)
{
$_params = array('resource_name' => $tpl_file , 'quiet' => true , 'get_source' => false);
return $this->_fetch_resource_info($_params);
}
/**
* Returns an array containing template variables
*
* @param string $name
* @param string $type
* @return array
*/
function &get_template_vars ($name = null)
{
if (! isset($name))
{
return $this->_tpl_vars;
}
elseif (isset($this->_tpl_vars[$name]))
{
return $this->_tpl_vars[$name];
}
else
{
// var non-existant, return valid reference
$_tmp = null;
return $_tmp;
}
}
/**
* Returns an array containing config variables
*
* @param string $name
* @param string $type
* @return array
*/
function &get_config_vars ($name = null)
{
if (! isset($name) && is_array($this->_config[0]))
{
return $this->_config[0]['vars'];
}
else if (isset($this->_config[0]['vars'][$name]))
{
return $this->_config[0]['vars'][$name];
}
else
{
// var non-existant, return valid reference
$_tmp = null;
return $_tmp;
}
}
/**
* trigger Smarty error
*
* @param string $error_msg
* @param integer $error_type
*/
function trigger_error ($error_msg, $error_type = E_USER_WARNING)
{
trigger_error("Smarty error: $error_msg", $error_type);
}
/**
* executes & displays the template results
*
* @param string $resource_name
* @param string $cache_id
* @param string $compile_id
*/
function display ($resource_name, $cache_id = null, $compile_id = null)
{
$this->fetch($resource_name, $cache_id, $compile_id, true);
}
/**
* executes & returns or displays the template results
*
* @param string $resource_name
* @param string $cache_id
* @param string $compile_id
* @param boolean $display
*/
function fetch ($resource_name, $cache_id = null, $compile_id = null, $display = false)
{
static $_cache_info = array();
$_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting) ? $this->error_reporting : error_reporting() & ~ E_NOTICE);
if (! $this->debugging && $this->debugging_ctrl == 'Url')
{
$_query_string = $this->request_use_auto_globals ? $_SERVER['QUERY_STRING'] : $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING'];
if (@strstr($_query_string, $this->_smarty_debug_id))
{
if (@strstr($_query_string, $this->_smarty_debug_id . '=on'))
{
// enable debugging for this browser session
@setcookie('SMARTY_DEBUG', true);
$this->debugging = true;
}
elseif (@strstr($_query_string, $this->_smarty_debug_id . '=off'))
{
// disable debugging for this browser session
@setcookie('SMARTY_DEBUG', false);
$this->debugging = false;
}
else
{
// enable debugging for this page
$this->debugging = true;
}
}
else
{
$this->debugging = (bool) ($this->request_use_auto_globals ? @$_COOKIE['SMARTY_DEBUG'] : @$GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']);
}
}
if ($this->debugging)
{
// capture time for debugging info
$_params = array();
require_once (SMARTY_CORE_DIR . 'core.get_microtime.php');
$_debug_start_time = smarty_core_get_microtime($_params, $this);
$this->_smarty_debug_info[] = array('type' => 'template' , 'filename' => $resource_name , 'depth' => 0);
$_included_tpls_idx = count($this->_smarty_debug_info) - 1;
}
if (! isset($compile_id))
{
$compile_id = $this->compile_id;
}
$this->_compile_id = $compile_id;
$this->_inclusion_depth = 0;
if ($this->caching)
{
// save old cache_info, initialize cache_info
array_push($_cache_info, $this->_cache_info);
$this->_cache_info = array();
$_params = array('tpl_file' => $resource_name , 'cache_id' => $cache_id , 'compile_id' => $compile_id , 'results' => null);
require_once (SMARTY_CORE_DIR . 'core.read_cache_file.php');
if (smarty_core_read_cache_file($_params, $this))
{
$_smarty_results = $_params['results'];
if (! empty($this->_cache_info['insert_tags']))
{
$_params = array('plugins' => $this->_cache_info['insert_tags']);
require_once (SMARTY_CORE_DIR . 'core.load_plugins.php');
smarty_core_load_plugins($_params, $this);
$_params = array('results' => $_smarty_results);
require_once (SMARTY_CORE_DIR . 'core.process_cached_inserts.php');
$_smarty_results = smarty_core_process_cached_inserts($_params, $this);
}
if (! empty($this->_cache_info['cache_serials']))
{
$_params = array('results' => $_smarty_results);
require_once (SMARTY_CORE_DIR . 'core.process_compiled_include.php');
$_smarty_results = smarty_core_process_compiled_include($_params, $this);
}
if ($display)
{
if ($this->debugging)
{
// capture time for debugging info
$_params = array();
require_once (SMARTY_CORE_DIR . 'core.get_microtime.php');
$this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time;
require_once (SMARTY_CORE_DIR . 'core.display_debug_console.php');
$_smarty_results .= smarty_core_display_debug_console($_params, $this);
}
if ($this->cache_modified_check)
{
$_server_vars = ($this->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
$_last_modified_date = @substr($_server_vars['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_server_vars['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
$_gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']) . ' GMT';
if (@count($this->_cache_info['insert_tags']) == 0 && ! $this->_cache_serials && $_gmt_mtime == $_last_modified_date)
{
if (php_sapi_name() == 'cgi')
header('Status: 304 Not Modified');
else
header('HTTP/1.1 304 Not Modified');
}
else
{
header('Last-Modified: ' . $_gmt_mtime);
echo $_smarty_results;
}
}
else
{
echo $_smarty_results;
}
error_reporting($_smarty_old_error_level);
// restore initial cache_info
$this->_cache_info = array_pop($_cache_info);
return true;
}
else
{
error_reporting($_smarty_old_error_level);
// restore initial cache_info
$this->_cache_info = array_pop($_cache_info);
return $_smarty_results;
}
}
else
{
$this->_cache_info['template'][$resource_name] = true;
if ($this->cache_modified_check && $display)
{
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', time()) . ' GMT');
}
}
}
// load filters that are marked as autoload
if (count($this->autoload_filters))
{
foreach ($this->autoload_filters as $_filter_type => $_filters)
{
foreach ($_filters as $_filter)
{
$this->load_filter($_filter_type, $_filter);
}
}
}
$_smarty_compile_path = $this->_get_compile_path($resource_name);
// if we just need to display the results, don't perform output
// buffering - for speed
$_cache_including = $this->_cache_including;
$this->_cache_including = false;
if ($display && ! $this->caching && count($this->_plugins['outputfilter']) == 0)
{
if ($this->_is_compiled($resource_name, $_smarty_compile_path) || $this->_compile_resource($resource_name, $_smarty_compile_path))
{
include ($_smarty_compile_path);
}
}
else
{
ob_start();
if ($this->_is_compiled($resource_name, $_smarty_compile_path) || $this->_compile_resource($resource_name, $_smarty_compile_path))
{
include ($_smarty_compile_path);
}
$_smarty_results = ob_get_contents();
ob_end_clean();
foreach ((array) $this->_plugins['outputfilter'] as $_output_filter)
{
$_smarty_results = call_user_func_array($_output_filter[0], array($_smarty_results , &$this));
}
}
if ($this->caching)
{
$_params = array('tpl_file' => $resource_name , 'cache_id' => $cache_id , 'compile_id' => $compile_id , 'results' => $_smarty_results);
require_once (SMARTY_CORE_DIR . 'core.write_cache_file.php');
smarty_core_write_cache_file($_params, $this);
require_once (SMARTY_CORE_DIR . 'core.process_cached_inserts.php');
$_smarty_results = smarty_core_process_cached_inserts($_params, $this);
if ($this->_cache_serials)
{
// strip nocache-tags from output
$_smarty_results = preg_replace('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!s', '', $_smarty_results);
}
// restore initial cache_info
$this->_cache_info = array_pop($_cache_info);
}
$this->_cache_including = $_cache_including;
if ($display)
{
if (isset($_smarty_results))
{
echo $_smarty_results;
}
if ($this->debugging)
{
// capture time for debugging info
$_params = array();
require_once (SMARTY_CORE_DIR . 'core.get_microtime.php');
$this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = (smarty_core_get_microtime($_params, $this) - $_debug_start_time);
require_once (SMARTY_CORE_DIR . 'core.display_debug_console.php');
echo smarty_core_display_debug_console($_params, $this);
}
error_reporting($_smarty_old_error_level);
return;
}
else
{
error_reporting($_smarty_old_error_level);
if (isset($_smarty_results))
{
return $_smarty_results;
}
}
}
/**
* load configuration values
*
* @param string $file
* @param string $section
* @param string $scope
*/
function config_load ($file, $section = null, $scope = 'global')
{
require_once ($this->_get_plugin_filepath('function', 'config_load'));
smarty_function_config_load(array('file' => $file , 'section' => $section , 'scope' => $scope), $this);
}
/**
* return a reference to a registered object
*
* @param string $name
* @return object
*/
function &get_registered_object ($name)
{
if (! isset($this->_reg_objects[$name]))
$this->_trigger_fatal_error("'$name' is not a registered object");
if (! is_object($this->_reg_objects[$name][0]))
$this->_trigger_fatal_error("registered '$name' is not an object");
return $this->_reg_objects[$name][0];
}
/**
* clear configuration values
*
* @param string $var
*/
function clear_config ($var = null)
{
if (! isset($var))
{
// clear all values
$this->_config = array(array('vars' => array() , 'files' => array()));
}
else
{
unset($this->_config[0]['vars'][$var]);
}
}
/**
* get filepath of requested plugin
*
* @param string $type
* @param string $name
* @return string|false
*/
function _get_plugin_filepath ($type, $name)
{
$_params = array('type' => $type , 'name' => $name);
require_once (SMARTY_CORE_DIR . 'core.assemble_plugin_filepath.php');
return smarty_core_assemble_plugin_filepath($_params, $this);
}
/**
* test if resource needs compiling
*
* @param string $resource_name
* @param string $compile_path
* @return boolean
*/
function _is_compiled ($resource_name, $compile_path)
{
if (! $this->force_compile && file_exists($compile_path))
{
if (! $this->compile_check)
{
// no need to check compiled file
return true;
}
else
{
// get file source and timestamp
$_params = array('resource_name' => $resource_name , 'get_source' => false);
if (! $this->_fetch_resource_info($_params))
{
return false;
}
if ($_params['resource_timestamp'] <= filemtime($compile_path))
{
// template not expired, no recompile
return true;
}
else
{
// compile template
return false;
}
}
}
else
{
// compiled template does not exist, or forced compile
return false;
}
}
/**
* compile the template
*
* @param string $resource_name
* @param string $compile_path
* @return boolean
*/
function _compile_resource ($resource_name, $compile_path)
{
$_params = array('resource_name' => $resource_name);
if (! $this->_fetch_resource_info($_params))
{
return false;
}
$_source_content = $_params['source_content'];
$_cache_include = substr($compile_path, 0, - 4) . '.inc';
if ($this->_compile_source($resource_name, $_source_content, $_compiled_content, $_cache_include))
{
// if a _cache_serial was set, we also have to write an include-file:
if ($this->_cache_include_info)
{
require_once (SMARTY_CORE_DIR . 'core.write_compiled_include.php');
smarty_core_write_compiled_include(array_merge($this->_cache_include_info, array('compiled_content' => $_compiled_content , 'resource_name' => $resource_name)), $this);
}
$_params = array('compile_path' => $compile_path , 'compiled_content' => $_compiled_content);
require_once (SMARTY_CORE_DIR . 'core.write_compiled_resource.php');
smarty_core_write_compiled_resource($_params, $this);
return true;
}
else
{
return false;
}
}
/**
* compile the given source
*
* @param string $resource_name
* @param string $source_content
* @param string $compiled_content
* @return boolean
*/
function _compile_source ($resource_name, &$source_content, &$compiled_content, $cache_include_path = null)
{
if (file_exists(SMARTY_DIR . $this->compiler_file))
{
require_once (SMARTY_DIR . $this->compiler_file);
}
else
{
// use include_path
require_once ($this->compiler_file);
}
$smarty_compiler = new $this->compiler_class();
$smarty_compiler->template_dir = $this->template_dir;
$smarty_compiler->compile_dir = $this->compile_dir;
$smarty_compiler->plugins_dir = $this->plugins_dir;
$smarty_compiler->config_dir = $this->config_dir;
$smarty_compiler->force_compile = $this->force_compile;
$smarty_compiler->caching = $this->caching;
$smarty_compiler->php_handling = $this->php_handling;
$smarty_compiler->left_delimiter = $this->left_delimiter;
$smarty_compiler->right_delimiter = $this->right_delimiter;
$smarty_compiler->_version = $this->_version;
$smarty_compiler->security = $this->security;
$smarty_compiler->secure_dir = $this->secure_dir;
$smarty_compiler->security_settings = $this->security_settings;
$smarty_compiler->trusted_dir = $this->trusted_dir;
$smarty_compiler->use_sub_dirs = $this->use_sub_dirs;
$smarty_compiler->_reg_objects = &$this->_reg_objects;
$smarty_compiler->_plugins = &$this->_plugins;
$smarty_compiler->_tpl_vars = &$this->_tpl_vars;
$smarty_compiler->default_modifiers = $this->default_modifiers;
$smarty_compiler->compile_id = $this->_compile_id;
$smarty_compiler->_config = $this->_config;
$smarty_compiler->request_use_auto_globals = $this->request_use_auto_globals;
if (isset($cache_include_path) && isset($this->_cache_serials[$cache_include_path]))
{
$smarty_compiler->_cache_serial = $this->_cache_serials[$cache_include_path];
}
$smarty_compiler->_cache_include = $cache_include_path;
$_results = $smarty_compiler->_compile_file($resource_name, $source_content, $compiled_content);
if ($smarty_compiler->_cache_serial)
{
$this->_cache_include_info = array('cache_serial' => $smarty_compiler->_cache_serial , 'plugins_code' => $smarty_compiler->_plugins_code , 'include_file_path' => $cache_include_path);
}
else
{
$this->_cache_include_info = null;
}
return $_results;
}
/**
* Get the compile path for this resource
*
* @param string $resource_name
* @return string results of {@link _get_auto_filename()}
*/
function _get_compile_path ($resource_name)
{
return $this->_get_auto_filename($this->compile_dir, $resource_name, $this->_compile_id) . '.php';
}
/**
* fetch the template info. Gets timestamp, and source
* if get_source is true
*
* sets $source_content to the source of the template, and
* $resource_timestamp to its time stamp
* @param string $resource_name
* @param string $source_content
* @param integer $resource_timestamp
* @param boolean $get_source
* @param boolean $quiet
* @return boolean
*/
function _fetch_resource_info (&$params)
{
if (! isset($params['get_source']))
{
$params['get_source'] = true;
}
if (! isset($params['quiet']))
{
$params['quiet'] = false;
}
$_return = false;
$_params = array('resource_name' => $params['resource_name']);
if (isset($params['resource_base_path']))
$_params['resource_base_path'] = $params['resource_base_path'];
else
$_params['resource_base_path'] = $this->template_dir;
if ($this->_parse_resource_name($_params))
{
$_resource_type = $_params['resource_type'];
$_resource_name = $_params['resource_name'];
switch ($_resource_type)
{
case 'file' :
if ($params['get_source'])
{
$params['source_content'] = $this->_read_file($_resource_name);
}
$params['resource_timestamp'] = filemtime($_resource_name);
$_return = is_file($_resource_name);
break;
default:
// call resource functions to fetch the template source and timestamp
if ($params['get_source'])
{
$_source_return = isset($this->_plugins['resource'][$_resource_type]) && call_user_func_array($this->_plugins['resource'][$_resource_type][0][0], array($_resource_name , &$params['source_content'] , &$this));
}
else
{
$_source_return = true;
}
$_timestamp_return = isset($this->_plugins['resource'][$_resource_type]) && call_user_func_array($this->_plugins['resource'][$_resource_type][0][1], array($_resource_name , &$params['resource_timestamp'] , &$this));
$_return = $_source_return && $_timestamp_return;
break;
}
}
if (! $_return)
{
// see if we can get a template with the default template handler
if (! empty($this->default_template_handler_func))
{
if (! is_callable($this->default_template_handler_func))
{
$this->trigger_error("default template handler function \"$this->default_template_handler_func\" doesn't exist.");
}
else
{
$_return = call_user_func_array($this->default_template_handler_func, array($_params['resource_type'] , $_params['resource_name'] , &$params['source_content'] , &$params['resource_timestamp'] , &$this));
}
}
}
if (! $_return)
{
if (! $params['quiet'])
{
$this->trigger_error('unable to read resource: "' . $params['resource_name'] . '"');
}
}
else if ($_return && $this->security)
{
require_once (SMARTY_CORE_DIR . 'core.is_secure.php');
if (! smarty_core_is_secure($_params, $this))
{
if (! $params['quiet'])
$this->trigger_error('(secure mode) accessing "' . $params['resource_name'] . '" is not allowed');
$params['source_content'] = null;
$params['resource_timestamp'] = null;
return false;
}
}
return $_return;
}
/**
* parse out the type and name from the resource
*
* @param string $resource_base_path
* @param string $resource_name
* @param string $resource_type
* @param string $resource_name
* @return boolean
*/
function _parse_resource_name (&$params)
{
// split tpl_path by the first colon
$_resource_name_parts = explode(':', $params['resource_name'], 2);
if (count($_resource_name_parts) == 1)
{
// no resource type given
$params['resource_type'] = $this->default_resource_type;
$params['resource_name'] = $_resource_name_parts[0];
}
else
{
if (strlen($_resource_name_parts[0]) == 1)
{
// 1 char is not resource type, but part of filepath
$params['resource_type'] = $this->default_resource_type;
$params['resource_name'] = $params['resource_name'];
}
else
{
$params['resource_type'] = $_resource_name_parts[0];
$params['resource_name'] = $_resource_name_parts[1];
}
}
if ($params['resource_type'] == 'file')
{
if (! preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $params['resource_name']))
{
// relative pathname to $params['resource_base_path']
// use the first directory where the file is found
foreach ((array) $params['resource_base_path'] as $_curr_path)
{
$_fullpath = $_curr_path . DIRECTORY_SEPARATOR . $params['resource_name'];
if (file_exists($_fullpath) && is_file($_fullpath))
{
$params['resource_name'] = $_fullpath;
return true;
}
// didn't find the file, try include_path
$_params = array('file_path' => $_fullpath);
require_once (SMARTY_CORE_DIR . 'core.get_include_path.php');
if (smarty_core_get_include_path($_params, $this))
{
$params['resource_name'] = $_params['new_file_path'];
return true;
}
}
return false;
}
else
{
/* absolute path */
return file_exists($params['resource_name']);
}
}
elseif (empty($this->_plugins['resource'][$params['resource_type']]))
{
$_params = array('type' => $params['resource_type']);
require_once (SMARTY_CORE_DIR . 'core.load_resource_plugin.php');
smarty_core_load_resource_plugin($_params, $this);
}
return true;
}
/**
* Handle modifiers
*
* @param string|null $modifier_name
* @param array|null $map_array
* @return string result of modifiers
*/
function _run_mod_handler ()
{
$_args = func_get_args();
list ($_modifier_name, $_map_array) = array_splice($_args, 0, 2);
list ($_func_name, $_tpl_file, $_tpl_line) = $this->_plugins['modifier'][$_modifier_name];
$_var = $_args[0];
foreach ($_var as $_key => $_val)
{
$_args[0] = $_val;
$_var[$_key] = call_user_func_array($_func_name, $_args);
}
return $_var;
}
/**
* Remove starting and ending quotes from the string
*
* @param string $string
* @return string
*/
function _dequote ($string)
{
if ((substr($string, 0, 1) == "'" || substr($string, 0, 1) == '"') && substr($string, - 1) == substr($string, 0, 1))
return substr($string, 1, - 1);
else
return $string;
}
/**
* read in a file
*
* @param string $filename
* @return string
*/
function _read_file ($filename)
{
if (file_exists($filename) && ($fd = @fopen($filename, 'rb')))
{
$contents = '';
while (! feof($fd))
{
$contents .= fread($fd, 8192);
}
fclose($fd);
return $contents;
}
else
{
return false;
}
}
/**
* get a concrete filename for automagically created content
*
* @param string $auto_base
* @param string $auto_source
* @param string $auto_id
* @return string
* @staticvar string|null
* @staticvar string|null
*/
function _get_auto_filename ($auto_base, $auto_source = null, $auto_id = null)
{
$_compile_dir_sep = $this->use_sub_dirs ? DIRECTORY_SEPARATOR : '^';
$_return = $auto_base . DIRECTORY_SEPARATOR;
if (isset($auto_id))
{
// make auto_id safe for directory names
$auto_id = str_replace('%7C', $_compile_dir_sep, (urlencode($auto_id)));
// split into separate directories
$_return .= $auto_id . $_compile_dir_sep;
}
if (isset($auto_source))
{
// make source name safe for filename
$_filename = urlencode(basename($auto_source));
$_crc32 = sprintf('%08X', crc32($auto_source));
// prepend %% to avoid name conflicts with
// with $params['auto_id'] names
$_crc32 = substr($_crc32, 0, 2) . $_compile_dir_sep . substr($_crc32, 0, 3) . $_compile_dir_sep . $_crc32;
$_return .= '%%' . $_crc32 . '%%' . $_filename;
}
return $_return;
}
/**
* unlink a file, possibly using expiration time
*
* @param string $resource
* @param integer $exp_time
*/
function _unlink ($resource, $exp_time = null)
{
if (isset($exp_time))
{
if (time() - @filemtime($resource) >= $exp_time)
{
return @unlink($resource);
}
}
else
{
return @unlink($resource);
}
}
/**
* returns an auto_id for auto-file-functions
*
* @param string $cache_id
* @param string $compile_id
* @return string|null
*/
function _get_auto_id ($cache_id = null, $compile_id = null)
{
if (isset($cache_id))
return (isset($compile_id)) ? $cache_id . '|' . $compile_id : $cache_id;
elseif (isset($compile_id))
return $compile_id;
else
return null;
}
/**
* trigger Smarty plugin error
*
* @param string $error_msg
* @param string $tpl_file
* @param integer $tpl_line
* @param string $file
* @param integer $line
* @param integer $error_type
*/
function _trigger_fatal_error ($error_msg, $tpl_file = null, $tpl_line = null, $file = null, $line = null, $error_type = E_USER_ERROR)
{
if (isset($file) && isset($line))
{
$info = ' (' . basename($file) . ", line $line)";
}
else
{
$info = '';
}
if (isset($tpl_line) && isset($tpl_file))
{
$this->trigger_error('[in ' . $tpl_file . ' line ' . $tpl_line . "]: $error_msg$info", $error_type);
}
else
{
$this->trigger_error($error_msg . $info, $error_type);
}
}
/**
* callback function for preg_replace, to call a non-cacheable block
* @return string
*/
function _process_compiled_include_callback ($match)
{
$_func = '_smarty_tplfunc_' . $match[2] . '_' . $match[3];
ob_start();
$_func($this);
$_ret = ob_get_contents();
ob_end_clean();
return $_ret;
}
/**
* called for included templates
*
* @param string $_smarty_include_tpl_file
* @param string $_smarty_include_vars
*/
// $_smarty_include_tpl_file, $_smarty_include_vars
function _smarty_include ($params)
{
if ($this->debugging)
{
$_params = array();
require_once (SMARTY_CORE_DIR . 'core.get_microtime.php');
$debug_start_time = smarty_core_get_microtime($_params, $this);
$this->_smarty_debug_info[] = array('type' => 'template' , 'filename' => $params['smarty_include_tpl_file'] , 'depth' => ++ $this->_inclusion_depth);
$included_tpls_idx = count($this->_smarty_debug_info) - 1;
}
$this->_tpl_vars = array_merge($this->_tpl_vars, $params['smarty_include_vars']);
// config vars are treated as local, so push a copy of the
// current ones onto the front of the stack
array_unshift($this->_config, $this->_config[0]);
$_smarty_compile_path = $this->_get_compile_path($params['smarty_include_tpl_file']);
if ($this->_is_compiled($params['smarty_include_tpl_file'], $_smarty_compile_path) || $this->_compile_resource($params['smarty_include_tpl_file'], $_smarty_compile_path))
{
include ($_smarty_compile_path);
}
// pop the local vars off the front of the stack
array_shift($this->_config);
$this->_inclusion_depth --;
if ($this->debugging)
{
// capture time for debugging info
$_params = array();
require_once (SMARTY_CORE_DIR . 'core.get_microtime.php');
$this->_smarty_debug_info[$included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $debug_start_time;
}
if ($this->caching)
{
$this->_cache_info['template'][$params['smarty_include_tpl_file']] = true;
}
}
/**
* get or set an array of cached attributes for function that is
* not cacheable
* @return array
*/
function &_smarty_cache_attrs ($cache_serial, $count)
{
$_cache_attrs = & $this->_cache_info['cache_attrs'][$cache_serial][$count];
if ($this->_cache_including)
{
/* return next set of cache_attrs */
$_return = current($_cache_attrs);
next($_cache_attrs);
return $_return;
}
else
{
/* add a reference to a new set of cache_attrs */
$_cache_attrs[] = array();
return $_cache_attrs[count($_cache_attrs) - 1];
}
}
/**
* wrapper for include() retaining $this
* @return mixed
*/
function _include ($filename, $once = false, $params = null)
{
if ($once)
{
return include_once ($filename);
}
else
{
return include ($filename);
}
}
/**
* wrapper for eval() retaining $this
* @return mixed
*/
function _eval ($code, $params = null)
{
return eval($code);
}
/**
* Extracts the filter name from the given callback
*
* @param callback $function
* @return string
*/
function _get_filter_name ($function)
{
if (is_array($function))
{
$_class_name = (is_object($function[0]) ? get_class($function[0]) : $function[0]);
return $_class_name . '_' . $function[1];
}
else
{
return $function;
}
}
/**#@-*/
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/Smarty.php | PHP | asf20 | 66,097 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Smarty debug_console function plugin
*
* Type: core<br>
* Name: display_debug_console<br>
* Purpose: display the javascript debug console window
* @param array Format: null
* @param Smarty
*/
function smarty_core_display_debug_console($params, &$smarty)
{
// we must force compile the debug template in case the environment
// changed between separate applications.
if(empty($smarty->debug_tpl)) {
// set path to debug template from SMARTY_DIR
$smarty->debug_tpl = SMARTY_DIR . 'debug.tpl';
if($smarty->security && is_file($smarty->debug_tpl)) {
$smarty->secure_dir[] = realpath($smarty->debug_tpl);
}
$smarty->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl';
}
$_ldelim_orig = $smarty->left_delimiter;
$_rdelim_orig = $smarty->right_delimiter;
$smarty->left_delimiter = '{';
$smarty->right_delimiter = '}';
$_compile_id_orig = $smarty->_compile_id;
$smarty->_compile_id = null;
$_compile_path = $smarty->_get_compile_path($smarty->debug_tpl);
if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path))
{
ob_start();
$smarty->_include($_compile_path);
$_results = ob_get_contents();
ob_end_clean();
} else {
$_results = '';
}
$smarty->_compile_id = $_compile_id_orig;
$smarty->left_delimiter = $_ldelim_orig;
$smarty->right_delimiter = $_rdelim_orig;
return $_results;
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.display_debug_console.php | PHP | asf20 | 1,583 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* create full directory structure
*
* @param string $dir
*/
// $dir
function smarty_core_create_dir_structure($params, &$smarty)
{
if (!file_exists($params['dir'])) {
$_open_basedir_ini = ini_get('open_basedir');
if (DIRECTORY_SEPARATOR=='/') {
/* unix-style paths */
$_dir = $params['dir'];
$_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY);
$_new_dir = (substr($_dir, 0, 1)=='/') ? '/' : getcwd().'/';
if($_use_open_basedir = !empty($_open_basedir_ini)) {
$_open_basedirs = explode(':', $_open_basedir_ini);
}
} else {
/* other-style paths */
$_dir = str_replace('\\','/', $params['dir']);
$_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY);
if (preg_match('!^((//)|([a-zA-Z]:/))!', $_dir, $_root_dir)) {
/* leading "//" for network volume, or "[letter]:/" for full path */
$_new_dir = $_root_dir[1];
/* remove drive-letter from _dir_parts */
if (isset($_root_dir[3])) array_shift($_dir_parts);
} else {
$_new_dir = str_replace('\\', '/', getcwd()).'/';
}
if($_use_open_basedir = !empty($_open_basedir_ini)) {
$_open_basedirs = explode(';', str_replace('\\', '/', $_open_basedir_ini));
}
}
/* all paths use "/" only from here */
foreach ($_dir_parts as $_dir_part) {
$_new_dir .= $_dir_part;
if ($_use_open_basedir) {
// do not attempt to test or make directories outside of open_basedir
$_make_new_dir = false;
foreach ($_open_basedirs as $_open_basedir) {
if (substr($_new_dir, 0, strlen($_open_basedir)) == $_open_basedir) {
$_make_new_dir = true;
break;
}
}
} else {
$_make_new_dir = true;
}
if ($_make_new_dir && !file_exists($_new_dir) && !@mkdir($_new_dir, $smarty->_dir_perms) && !is_dir($_new_dir)) {
$smarty->trigger_error("problem creating directory '" . $_new_dir . "'");
return false;
}
$_new_dir .= '/';
}
}
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.create_dir_structure.php | PHP | asf20 | 2,507 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* determines if a resource is trusted or not
*
* @param string $resource_type
* @param string $resource_name
* @return boolean
*/
// $resource_type, $resource_name
function smarty_core_is_trusted($params, &$smarty)
{
$_smarty_trusted = false;
if ($params['resource_type'] == 'file') {
if (!empty($smarty->trusted_dir)) {
$_rp = realpath($params['resource_name']);
foreach ((array)$smarty->trusted_dir as $curr_dir) {
if (!empty($curr_dir) && is_readable ($curr_dir)) {
$_cd = realpath($curr_dir);
if (strncmp($_rp, $_cd, strlen($_cd)) == 0
&& substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) {
$_smarty_trusted = true;
break;
}
}
}
}
} else {
// resource is not on local file system
$_smarty_trusted = call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][3],
array($params['resource_name'], $smarty));
}
return $_smarty_trusted;
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.is_trusted.php | PHP | asf20 | 1,284 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Extract non-cacheable parts out of compiled template and write it
*
* @param string $compile_path
* @param string $template_compiled
* @return boolean
*/
function smarty_core_write_compiled_include($params, &$smarty)
{
$_tag_start = 'if \(\$this->caching && \!\$this->_cache_including\)\: echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\'; endif;';
$_tag_end = 'if \(\$this->caching && \!\$this->_cache_including\)\: echo \'\{/nocache\:(\\2)#(\\3)\}\'; endif;';
preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
$params['compiled_content'], $_match_source, PREG_SET_ORDER);
// no nocache-parts found: done
if (count($_match_source)==0) return;
// convert the matched php-code to functions
$_include_compiled = "<?php /* Smarty version ".$smarty->_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n";
$_include_compiled .= " compiled from " . strtr(urlencode($params['resource_name']), array('%2F'=>'/', '%3A'=>':')) . " */\n\n";
$_compile_path = $params['include_file_path'];
$smarty->_cache_serials[$_compile_path] = $params['cache_serial'];
$_include_compiled .= "\$this->_cache_serials['".$_compile_path."'] = '".$params['cache_serial']."';\n\n?>";
$_include_compiled .= $params['plugins_code'];
$_include_compiled .= "<?php";
$this_varname = ((double)phpversion() >= 5.0) ? '_smarty' : 'this';
for ($_i = 0, $_for_max = count($_match_source); $_i < $_for_max; $_i++) {
$_match =& $_match_source[$_i];
$source = $_match[4];
if ($this_varname == '_smarty') {
/* rename $this to $_smarty in the sourcecode */
$tokens = token_get_all('<?php ' . $_match[4]);
/* remove trailing <?php */
$open_tag = '';
while ($tokens) {
$token = array_shift($tokens);
if (is_array($token)) {
$open_tag .= $token[1];
} else {
$open_tag .= $token;
}
if ($open_tag == '<?php ') break;
}
for ($i=0, $count = count($tokens); $i < $count; $i++) {
if (is_array($tokens[$i])) {
if ($tokens[$i][0] == T_VARIABLE && $tokens[$i][1] == '$this') {
$tokens[$i] = '$' . $this_varname;
} else {
$tokens[$i] = $tokens[$i][1];
}
}
}
$source = implode('', $tokens);
}
/* add function to compiled include */
$_include_compiled .= "
function _smarty_tplfunc_$_match[2]_$_match[3](&\$$this_varname)
{
$source
}
";
}
$_include_compiled .= "\n\n?>";
$_params = array('filename' => $_compile_path,
'contents' => $_include_compiled, 'create_dirs' => true);
require_once(SMARTY_CORE_DIR . 'core.write_file.php');
smarty_core_write_file($_params, $smarty);
return true;
}
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.write_compiled_include.php | PHP | asf20 | 3,219 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* load a resource plugin
*
* @param string $type
*/
// $type
function smarty_core_load_resource_plugin($params, &$smarty)
{
/*
* Resource plugins are not quite like the other ones, so they are
* handled differently. The first element of plugin info is the array of
* functions provided by the plugin, the second one indicates whether
* all of them exist or not.
*/
$_plugin = &$smarty->_plugins['resource'][$params['type']];
if (isset($_plugin)) {
if (!$_plugin[1] && count($_plugin[0])) {
$_plugin[1] = true;
foreach ($_plugin[0] as $_plugin_func) {
if (!is_callable($_plugin_func)) {
$_plugin[1] = false;
break;
}
}
}
if (!$_plugin[1]) {
$smarty->_trigger_fatal_error("[plugin] resource '" . $params['type'] . "' is not implemented", null, null, __FILE__, __LINE__);
}
return;
}
$_plugin_file = $smarty->_get_plugin_filepath('resource', $params['type']);
$_found = ($_plugin_file != false);
if ($_found) { /*
* If the plugin file is found, it -must- provide the properly named
* plugin functions.
*/
include_once($_plugin_file);
/*
* Locate functions that we require the plugin to provide.
*/
$_resource_ops = array('source', 'timestamp', 'secure', 'trusted');
$_resource_funcs = array();
foreach ($_resource_ops as $_op) {
$_plugin_func = 'smarty_resource_' . $params['type'] . '_' . $_op;
if (!function_exists($_plugin_func)) {
$smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", null, null, __FILE__, __LINE__);
return;
} else {
$_resource_funcs[] = $_plugin_func;
}
}
$smarty->_plugins['resource'][$params['type']] = array($_resource_funcs, true);
}
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.load_resource_plugin.php | PHP | asf20 | 2,147 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* delete a dir recursively (level=0 -> keep root)
* WARNING: no tests, it will try to remove what you tell it!
*
* @param string $dirname
* @param integer $level
* @param integer $exp_time
* @return boolean
*/
// $dirname, $level = 1, $exp_time = null
function smarty_core_rmdir($params, &$smarty)
{
if(!isset($params['level'])) { $params['level'] = 1; }
if(!isset($params['exp_time'])) { $params['exp_time'] = null; }
if($_handle = @opendir($params['dirname'])) {
while (false !== ($_entry = readdir($_handle))) {
if ($_entry != '.' && $_entry != '..') {
if (@is_dir($params['dirname'] . DIRECTORY_SEPARATOR . $_entry)) {
$_params = array(
'dirname' => $params['dirname'] . DIRECTORY_SEPARATOR . $_entry,
'level' => $params['level'] + 1,
'exp_time' => $params['exp_time']
);
smarty_core_rmdir($_params, $smarty);
}
else {
$smarty->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']);
}
}
}
closedir($_handle);
}
if ($params['level']) {
return @rmdir($params['dirname']);
}
return (bool)$_handle;
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.rmdir.php | PHP | asf20 | 1,498 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Retrieves PHP script resource
*
* sets $php_resource to the returned resource
* @param string $resource
* @param string $resource_type
* @param $php_resource
* @return boolean
*/
function smarty_core_get_php_resource(&$params, &$smarty)
{
$params['resource_base_path'] = $smarty->trusted_dir;
$smarty->_parse_resource_name($params, $smarty);
/*
* Find out if the resource exists.
*/
if ($params['resource_type'] == 'file') {
$_readable = false;
if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) {
$_readable = true;
} else {
// test for file in include_path
$_params = array('file_path' => $params['resource_name']);
require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
if(smarty_core_get_include_path($_params, $smarty)) {
$_include_path = $_params['new_file_path'];
$_readable = true;
}
}
} else if ($params['resource_type'] != 'file') {
$_template_source = null;
$_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0])
&& call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0],
array($params['resource_name'], &$_template_source, &$smarty));
}
/*
* Set the error function, depending on which class calls us.
*/
if (method_exists($smarty, '_syntax_error')) {
$_error_funcc = '_syntax_error';
} else {
$_error_funcc = 'trigger_error';
}
if ($_readable) {
if ($smarty->security) {
require_once(SMARTY_CORE_DIR . 'core.is_trusted.php');
if (!smarty_core_is_trusted($params, $smarty)) {
$smarty->$_error_funcc('(secure mode) ' . $params['resource_type'] . ':' . $params['resource_name'] . ' is not trusted');
return false;
}
}
} else {
$smarty->$_error_funcc($params['resource_type'] . ':' . $params['resource_name'] . ' is not readable');
return false;
}
if ($params['resource_type'] == 'file') {
$params['php_resource'] = $params['resource_name'];
} else {
$params['php_resource'] = $_template_source;
}
return true;
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.get_php_resource.php | PHP | asf20 | 2,467 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Replace cached inserts with the actual results
*
* @param string $results
* @return string
*/
function smarty_core_process_cached_inserts($params, &$smarty)
{
preg_match_all('!'.$smarty->_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis',
$params['results'], $match);
list($cached_inserts, $insert_args) = $match;
for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) {
if ($smarty->debugging) {
$_params = array();
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
$debug_start_time = smarty_core_get_microtime($_params, $smarty);
}
$args = unserialize($insert_args[$i]);
$name = $args['name'];
if (isset($args['script'])) {
$_params = array('resource_name' => $smarty->_dequote($args['script']));
require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
if(!smarty_core_get_php_resource($_params, $smarty)) {
return false;
}
$resource_type = $_params['resource_type'];
$php_resource = $_params['php_resource'];
if ($resource_type == 'file') {
$smarty->_include($php_resource, true);
} else {
$smarty->_eval($php_resource);
}
}
$function_name = $smarty->_plugins['insert'][$name][0];
if (empty($args['assign'])) {
$replace = $function_name($args, $smarty);
} else {
$smarty->assign($args['assign'], $function_name($args, $smarty));
$replace = '';
}
$params['results'] = substr_replace($params['results'], $replace, strpos($params['results'], $cached_inserts[$i]), strlen($cached_inserts[$i]));
if ($smarty->debugging) {
$_params = array();
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
$smarty->_smarty_debug_info[] = array('type' => 'insert',
'filename' => 'insert_'.$name,
'depth' => $smarty->_inclusion_depth,
'exec_time' => smarty_core_get_microtime($_params, $smarty) - $debug_start_time);
}
}
return $params['results'];
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.process_cached_inserts.php | PHP | asf20 | 2,464 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* called for included php files within templates
*
* @param string $smarty_file
* @param string $smarty_assign variable to assign the included template's
* output into
* @param boolean $smarty_once uses include_once if this is true
* @param array $smarty_include_vars associative array of vars from
* {include file="blah" var=$var}
*/
// $file, $assign, $once, $_smarty_include_vars
function smarty_core_smarty_include_php($params, &$smarty)
{
$_params = array('resource_name' => $params['smarty_file']);
require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
smarty_core_get_php_resource($_params, $smarty);
$_smarty_resource_type = $_params['resource_type'];
$_smarty_php_resource = $_params['php_resource'];
if (!empty($params['smarty_assign'])) {
ob_start();
if ($_smarty_resource_type == 'file') {
$smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
} else {
$smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
}
$smarty->assign($params['smarty_assign'], ob_get_contents());
ob_end_clean();
} else {
if ($_smarty_resource_type == 'file') {
$smarty->_include($_smarty_php_resource, $params['smarty_once'], $params['smarty_include_vars']);
} else {
$smarty->_eval($_smarty_php_resource, $params['smarty_include_vars']);
}
}
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.smarty_include_php.php | PHP | asf20 | 1,602 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* delete an automagically created file by name and id
*
* @param string $auto_base
* @param string $auto_source
* @param string $auto_id
* @param integer $exp_time
* @return boolean
*/
// $auto_base, $auto_source = null, $auto_id = null, $exp_time = null
function smarty_core_rm_auto($params, &$smarty)
{
if (!@is_dir($params['auto_base']))
return false;
if(!isset($params['auto_id']) && !isset($params['auto_source'])) {
$_params = array(
'dirname' => $params['auto_base'],
'level' => 0,
'exp_time' => $params['exp_time']
);
require_once(SMARTY_CORE_DIR . 'core.rmdir.php');
$_res = smarty_core_rmdir($_params, $smarty);
} else {
$_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']);
if(isset($params['auto_source'])) {
if (isset($params['extensions'])) {
$_res = false;
foreach ((array)$params['extensions'] as $_extension)
$_res |= $smarty->_unlink($_tname.$_extension, $params['exp_time']);
} else {
$_res = $smarty->_unlink($_tname, $params['exp_time']);
}
} elseif ($smarty->use_sub_dirs) {
$_params = array(
'dirname' => $_tname,
'level' => 1,
'exp_time' => $params['exp_time']
);
require_once(SMARTY_CORE_DIR . 'core.rmdir.php');
$_res = smarty_core_rmdir($_params, $smarty);
} else {
// remove matching file names
$_handle = opendir($params['auto_base']);
$_res = true;
while (false !== ($_filename = readdir($_handle))) {
if($_filename == '.' || $_filename == '..') {
continue;
} elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) {
$_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']);
}
}
}
}
return $_res;
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.rm_auto.php | PHP | asf20 | 2,357 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* assemble filepath of requested plugin
*
* @param string $type
* @param string $name
* @return string|false
*/
function smarty_core_assemble_plugin_filepath($params, &$smarty)
{
static $_filepaths_cache = array();
$_plugin_filename = $params['type'] . '.' . $params['name'] . '.php';
if (isset($_filepaths_cache[$_plugin_filename])) {
return $_filepaths_cache[$_plugin_filename];
}
$_return = false;
foreach ((array)$smarty->plugins_dir as $_plugin_dir) {
$_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
// see if path is relative
if (!preg_match("/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/", $_plugin_dir)) {
$_relative_paths[] = $_plugin_dir;
// relative path, see if it is in the SMARTY_DIR
if (@is_readable(SMARTY_DIR . $_plugin_filepath)) {
$_return = SMARTY_DIR . $_plugin_filepath;
break;
}
}
// try relative to cwd (or absolute)
if (@is_readable($_plugin_filepath)) {
$_return = $_plugin_filepath;
break;
}
}
if($_return === false) {
// still not found, try PHP include_path
if(isset($_relative_paths)) {
foreach ((array)$_relative_paths as $_plugin_dir) {
$_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
$_params = array('file_path' => $_plugin_filepath);
require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
if(smarty_core_get_include_path($_params, $smarty)) {
$_return = $_params['new_file_path'];
break;
}
}
}
}
$_filepaths_cache[$_plugin_filename] = $_return;
return $_return;
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.assemble_plugin_filepath.php | PHP | asf20 | 1,949 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* write out a file to disk
*
* @param string $filename
* @param string $contents
* @param boolean $create_dirs
* @return boolean
*/
function smarty_core_write_file($params, &$smarty)
{
$_dirname = dirname($params['filename']);
if ($params['create_dirs']) {
$_params = array('dir' => $_dirname);
require_once(SMARTY_CORE_DIR . 'core.create_dir_structure.php');
smarty_core_create_dir_structure($_params, $smarty);
}
// write to tmp file, then rename it to avoid file locking race condition
$_tmp_file = tempnam($_dirname, 'wrt');
if (!($fd = @fopen($_tmp_file, 'wb'))) {
$_tmp_file = $_dirname . DIRECTORY_SEPARATOR . uniqid('wrt');
if (!($fd = @fopen($_tmp_file, 'wb'))) {
$smarty->trigger_error("problem writing temporary file '$_tmp_file'");
return false;
}
}
fwrite($fd, $params['contents']);
fclose($fd);
if (DIRECTORY_SEPARATOR == '\\' || !@rename($_tmp_file, $params['filename'])) {
// On platforms and filesystems that cannot overwrite with rename()
// delete the file before renaming it -- because windows always suffers
// this, it is short-circuited to avoid the initial rename() attempt
@unlink($params['filename']);
@rename($_tmp_file, $params['filename']);
}
@chmod($params['filename'], $smarty->_file_perms);
return true;
}
/* vim: set expandtab: */
?> | 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.write_file.php | PHP | asf20 | 1,577 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Get path to file from include_path
*
* @param string $file_path
* @param string $new_file_path
* @return boolean
* @staticvar array|null
*/
// $file_path, &$new_file_path
function smarty_core_get_include_path(&$params, &$smarty)
{
static $_path_array = null;
if(!isset($_path_array)) {
$_ini_include_path = ini_get('include_path');
if(strstr($_ini_include_path,';')) {
// windows pathnames
$_path_array = explode(';',$_ini_include_path);
} else {
$_path_array = explode(':',$_ini_include_path);
}
}
foreach ($_path_array as $_include_path) {
if (@is_readable($_include_path . DIRECTORY_SEPARATOR . $params['file_path'])) {
$params['new_file_path'] = $_include_path . DIRECTORY_SEPARATOR . $params['file_path'];
return true;
}
}
return false;
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.get_include_path.php | PHP | asf20 | 1,002 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Replace nocache-tags by results of the corresponding non-cacheable
* functions and return it
*
* @param string $compiled_tpl
* @param string $cached_source
* @return string
*/
function smarty_core_process_compiled_include($params, &$smarty)
{
$_cache_including = $smarty->_cache_including;
$smarty->_cache_including = true;
$_return = $params['results'];
foreach ($smarty->_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) {
$smarty->_include($_include_file_path, true);
}
foreach ($smarty->_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) {
$_return = preg_replace_callback('!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s',
array(&$smarty, '_process_compiled_include_callback'),
$_return);
}
$smarty->_cache_including = $_cache_including;
return $_return;
}
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.process_compiled_include.php | PHP | asf20 | 1,025 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Get seconds and microseconds
* @return double
*/
function smarty_core_get_microtime($params, &$smarty)
{
$mtime = microtime();
$mtime = explode(" ", $mtime);
$mtime = (double)($mtime[1]) + (double)($mtime[0]);
return ($mtime);
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.get_microtime.php | PHP | asf20 | 360 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Smarty assign_smarty_interface core plugin
*
* Type: core<br>
* Name: assign_smarty_interface<br>
* Purpose: assign the $smarty interface variable
* @param array Format: null
* @param Smarty
*/
function smarty_core_assign_smarty_interface($params, &$smarty)
{
if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars['request'])) {
return;
}
$_globals_map = array('g' => 'HTTP_GET_VARS',
'p' => 'HTTP_POST_VARS',
'c' => 'HTTP_COOKIE_VARS',
's' => 'HTTP_SERVER_VARS',
'e' => 'HTTP_ENV_VARS');
$_smarty_vars_request = array();
foreach (preg_split('!!', strtolower($smarty->request_vars_order)) as $_c) {
if (isset($_globals_map[$_c])) {
$_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]);
}
}
$_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']);
$smarty->_smarty_vars['request'] = $_smarty_vars_request;
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.assign_smarty_interface.php | PHP | asf20 | 1,258 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Prepend the cache information to the cache file
* and write it
*
* @param string $tpl_file
* @param string $cache_id
* @param string $compile_id
* @param string $results
* @return true|null
*/
// $tpl_file, $cache_id, $compile_id, $results
function smarty_core_write_cache_file($params, &$smarty)
{
// put timestamp in cache header
$smarty->_cache_info['timestamp'] = time();
if ($smarty->cache_lifetime > -1){
// expiration set
$smarty->_cache_info['expires'] = $smarty->_cache_info['timestamp'] + $smarty->cache_lifetime;
} else {
// cache will never expire
$smarty->_cache_info['expires'] = -1;
}
// collapse nocache.../nocache-tags
if (preg_match_all('!\{(/?)nocache\:[0-9a-f]{32}#\d+\}!', $params['results'], $match, PREG_PATTERN_ORDER)) {
// remove everything between every pair of outermost noache.../nocache-tags
// and replace it by a single nocache-tag
// this new nocache-tag will be replaced by dynamic contents in
// smarty_core_process_compiled_includes() on a cache-read
$match_count = count($match[0]);
$results = preg_split('!(\{/?nocache\:[0-9a-f]{32}#\d+\})!', $params['results'], -1, PREG_SPLIT_DELIM_CAPTURE);
$level = 0;
$j = 0;
for ($i=0, $results_count = count($results); $i < $results_count && $j < $match_count; $i++) {
if ($results[$i] == $match[0][$j]) {
// nocache tag
if ($match[1][$j]) { // closing tag
$level--;
unset($results[$i]);
} else { // opening tag
if ($level++ > 0) unset($results[$i]);
}
$j++;
} elseif ($level > 0) {
unset($results[$i]);
}
}
$params['results'] = implode('', $results);
}
$smarty->_cache_info['cache_serials'] = $smarty->_cache_serials;
// prepend the cache header info into cache file
$_cache_info = serialize($smarty->_cache_info);
$params['results'] = strlen($_cache_info) . "\n" . $_cache_info . $params['results'];
if (!empty($smarty->cache_handler_func)) {
// use cache_handler function
call_user_func_array($smarty->cache_handler_func,
array('write', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], $smarty->_cache_info['expires']));
} else {
// use local cache file
if(!@is_writable($smarty->cache_dir)) {
// cache_dir not writable, see if it exists
if(!@is_dir($smarty->cache_dir)) {
$smarty->trigger_error('the $cache_dir \'' . $smarty->cache_dir . '\' does not exist, or is not a directory.', E_USER_ERROR);
return false;
}
$smarty->trigger_error('unable to write to $cache_dir \'' . realpath($smarty->cache_dir) . '\'. Be sure $cache_dir is writable by the web server user.', E_USER_ERROR);
return false;
}
$_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']);
$_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id);
$_params = array('filename' => $_cache_file, 'contents' => $params['results'], 'create_dirs' => true);
require_once(SMARTY_CORE_DIR . 'core.write_file.php');
smarty_core_write_file($_params, $smarty);
return true;
}
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.write_cache_file.php | PHP | asf20 | 3,647 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* Load requested plugins
*
* @param array $plugins
*/
// $plugins
function smarty_core_load_plugins($params, &$smarty)
{
foreach ($params['plugins'] as $_plugin_info) {
list($_type, $_name, $_tpl_file, $_tpl_line, $_delayed_loading) = $_plugin_info;
$_plugin = &$smarty->_plugins[$_type][$_name];
/*
* We do not load plugin more than once for each instance of Smarty.
* The following code checks for that. The plugin can also be
* registered dynamically at runtime, in which case template file
* and line number will be unknown, so we fill them in.
*
* The final element of the info array is a flag that indicates
* whether the dynamically registered plugin function has been
* checked for existence yet or not.
*/
if (isset($_plugin)) {
if (empty($_plugin[3])) {
if (!is_callable($_plugin[0])) {
$smarty->_trigger_fatal_error("[plugin] $_type '$_name' is not implemented", $_tpl_file, $_tpl_line, __FILE__, __LINE__);
} else {
$_plugin[1] = $_tpl_file;
$_plugin[2] = $_tpl_line;
$_plugin[3] = true;
if (!isset($_plugin[4])) $_plugin[4] = true; /* cacheable */
}
}
continue;
} else if ($_type == 'insert') {
/*
* For backwards compatibility, we check for insert functions in
* the symbol table before trying to load them as a plugin.
*/
$_plugin_func = 'insert_' . $_name;
if (function_exists($_plugin_func)) {
$_plugin = array($_plugin_func, $_tpl_file, $_tpl_line, true, false);
continue;
}
}
$_plugin_file = $smarty->_get_plugin_filepath($_type, $_name);
if (! $_found = ($_plugin_file != false)) {
$_message = "could not load plugin file '$_type.$_name.php'\n";
}
/*
* If plugin file is found, it -must- provide the properly named
* plugin function. In case it doesn't, simply output the error and
* do not fall back on any other method.
*/
if ($_found) {
include_once $_plugin_file;
$_plugin_func = 'smarty_' . $_type . '_' . $_name;
if (!function_exists($_plugin_func)) {
$smarty->_trigger_fatal_error("[plugin] function $_plugin_func() not found in $_plugin_file", $_tpl_file, $_tpl_line, __FILE__, __LINE__);
continue;
}
}
/*
* In case of insert plugins, their code may be loaded later via
* 'script' attribute.
*/
else if ($_type == 'insert' && $_delayed_loading) {
$_plugin_func = 'smarty_' . $_type . '_' . $_name;
$_found = true;
}
/*
* Plugin specific processing and error checking.
*/
if (!$_found) {
if ($_type == 'modifier') {
/*
* In case modifier falls back on using PHP functions
* directly, we only allow those specified in the security
* context.
*/
if ($smarty->security && !in_array($_name, $smarty->security_settings['MODIFIER_FUNCS'])) {
$_message = "(secure mode) modifier '$_name' is not allowed";
} else {
if (!function_exists($_name)) {
$_message = "modifier '$_name' is not implemented";
} else {
$_plugin_func = $_name;
$_found = true;
}
}
} else if ($_type == 'function') {
/*
* This is a catch-all situation.
*/
$_message = "unknown tag - '$_name'";
}
}
if ($_found) {
$smarty->_plugins[$_type][$_name] = array($_plugin_func, $_tpl_file, $_tpl_line, true, true);
} else {
// output error
$smarty->_trigger_fatal_error('[plugin] ' . $_message, $_tpl_file, $_tpl_line, __FILE__, __LINE__);
}
}
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.load_plugins.php | PHP | asf20 | 4,429 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* read a cache file, determine if it needs to be
* regenerated or not
*
* @param string $tpl_file
* @param string $cache_id
* @param string $compile_id
* @param string $results
* @return boolean
*/
// $tpl_file, $cache_id, $compile_id, &$results
function smarty_core_read_cache_file(&$params, &$smarty)
{
static $content_cache = array();
if ($smarty->force_compile) {
// force compile enabled, always regenerate
return false;
}
if (isset($content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']])) {
list($params['results'], $smarty->_cache_info) = $content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']];
return true;
}
if (!empty($smarty->cache_handler_func)) {
// use cache_handler function
call_user_func_array($smarty->cache_handler_func,
array('read', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null));
} else {
// use local cache file
$_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']);
$_cache_file = $smarty->_get_auto_filename($smarty->cache_dir, $params['tpl_file'], $_auto_id);
$params['results'] = $smarty->_read_file($_cache_file);
}
if (empty($params['results'])) {
// nothing to parse (error?), regenerate cache
return false;
}
$_contents = $params['results'];
$_info_start = strpos($_contents, "\n") + 1;
$_info_len = (int)substr($_contents, 0, $_info_start - 1);
$_cache_info = unserialize(substr($_contents, $_info_start, $_info_len));
$params['results'] = substr($_contents, $_info_start + $_info_len);
if ($smarty->caching == 2 && isset ($_cache_info['expires'])){
// caching by expiration time
if ($_cache_info['expires'] > -1 && (time() > $_cache_info['expires'])) {
// cache expired, regenerate
return false;
}
} else {
// caching by lifetime
if ($smarty->cache_lifetime > -1 && (time() - $_cache_info['timestamp'] > $smarty->cache_lifetime)) {
// cache expired, regenerate
return false;
}
}
if ($smarty->compile_check) {
$_params = array('get_source' => false, 'quiet'=>true);
foreach (array_keys($_cache_info['template']) as $_template_dep) {
$_params['resource_name'] = $_template_dep;
if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) {
// template file has changed, regenerate cache
return false;
}
}
if (isset($_cache_info['config'])) {
$_params = array('resource_base_path' => $smarty->config_dir, 'get_source' => false, 'quiet'=>true);
foreach (array_keys($_cache_info['config']) as $_config_dep) {
$_params['resource_name'] = $_config_dep;
if (!$smarty->_fetch_resource_info($_params) || $_cache_info['timestamp'] < $_params['resource_timestamp']) {
// config file has changed, regenerate cache
return false;
}
}
}
}
$content_cache[$params['tpl_file'].','.$params['cache_id'].','.$params['compile_id']] = array($params['results'], $_cache_info);
$smarty->_cache_info = $_cache_info;
return true;
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.read_cache_file.php | PHP | asf20 | 3,604 |
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage plugins
*/
/**
* determines if a resource is secure or not.
*
* @param string $resource_type
* @param string $resource_name
* @return boolean
*/
// $resource_type, $resource_name
function smarty_core_is_secure($params, &$smarty)
{
if (!$smarty->security || $smarty->security_settings['INCLUDE_ANY']) {
return true;
}
if ($params['resource_type'] == 'file') {
$_rp = realpath($params['resource_name']);
if (isset($params['resource_base_path'])) {
foreach ((array)$params['resource_base_path'] as $curr_dir) {
if ( ($_cd = realpath($curr_dir)) !== false &&
strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) {
return true;
}
}
}
if (!empty($smarty->secure_dir)) {
foreach ((array)$smarty->secure_dir as $curr_dir) {
if ( ($_cd = realpath($curr_dir)) !== false) {
if($_cd == $_rp) {
return true;
} elseif (strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR) {
return true;
}
}
}
}
} else {
// resource is not on local file system
return call_user_func_array(
$smarty->_plugins['resource'][$params['resource_type']][0][2],
array($params['resource_name'], &$smarty));
}
return false;
}
/* vim: set expandtab: */
?>
| 01cms | 01cms/branches/v1.0/01mvc/lib/Smarty/internals/core.is_secure.php | PHP | asf20 | 1,694 |