reorganize and cleanup php server code
This commit is contained in:
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,39 @@
|
||||
CKEditor 4
|
||||
==========
|
||||
|
||||
Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
|
||||
http://ckeditor.com - See LICENSE.md for license information.
|
||||
|
||||
CKEditor is a text editor to be used inside web pages. It's not a replacement
|
||||
for desktop text editors like Word or OpenOffice, but a component to be used as
|
||||
part of web applications and websites.
|
||||
|
||||
## Documentation
|
||||
|
||||
The full editor documentation is available online at the following address:
|
||||
http://docs.ckeditor.com
|
||||
|
||||
## Installation
|
||||
|
||||
Installing CKEditor is an easy task. Just follow these simple steps:
|
||||
|
||||
1. **Download** the latest version from the CKEditor website:
|
||||
http://ckeditor.com. You should have already completed this step, but be
|
||||
sure you have the very latest version.
|
||||
2. **Extract** (decompress) the downloaded file into the root of your website.
|
||||
|
||||
**Note:** CKEditor is by default installed in the `ckeditor` folder. You can
|
||||
place the files in whichever you want though.
|
||||
|
||||
## Checking Your Installation
|
||||
|
||||
The editor comes with a few sample pages that can be used to verify that
|
||||
installation proceeded properly. Take a look at the `samples` directory.
|
||||
|
||||
To test your installation, just call the following page at your website:
|
||||
|
||||
http://<your site>/<CKEditor installation path>/samples/index.html
|
||||
|
||||
For example:
|
||||
|
||||
http://www.example.com/ckeditor/samples/index.html
|
||||
@@ -0,0 +1,10 @@
|
||||
/*
|
||||
Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
|
||||
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
||||
*/
|
||||
(function(a){if("undefined"==typeof a)throw Error("jQuery should be loaded before CKEditor jQuery adapter.");if("undefined"==typeof CKEDITOR)throw Error("CKEditor should be loaded before CKEditor jQuery adapter.");CKEDITOR.config.jqueryOverrideVal="undefined"==typeof CKEDITOR.config.jqueryOverrideVal?!0:CKEDITOR.config.jqueryOverrideVal;a.extend(a.fn,{ckeditorGet:function(){var a=this.eq(0).data("ckeditorInstance");if(!a)throw"CKEditor is not initialized yet, use ckeditor() with a callback.";return a},
|
||||
ckeditor:function(g,d){if(!CKEDITOR.env.isCompatible)throw Error("The environment is incompatible.");if(!a.isFunction(g)){var m=d;d=g;g=m}var k=[];d=d||{};this.each(function(){var b=a(this),c=b.data("ckeditorInstance"),f=b.data("_ckeditorInstanceLock"),h=this,l=new a.Deferred;k.push(l.promise());if(c&&!f)g&&g.apply(c,[this]),l.resolve();else if(f)c.once("instanceReady",function(){setTimeout(function(){c.element?(c.element.$==h&&g&&g.apply(c,[h]),l.resolve()):setTimeout(arguments.callee,100)},0)},
|
||||
null,null,9999);else{if(d.autoUpdateElement||"undefined"==typeof d.autoUpdateElement&&CKEDITOR.config.autoUpdateElement)d.autoUpdateElementJquery=!0;d.autoUpdateElement=!1;b.data("_ckeditorInstanceLock",!0);c=a(this).is("textarea")?CKEDITOR.replace(h,d):CKEDITOR.inline(h,d);b.data("ckeditorInstance",c);c.on("instanceReady",function(d){var e=d.editor;setTimeout(function(){if(e.element){d.removeListener();e.on("dataReady",function(){b.trigger("dataReady.ckeditor",[e])});e.on("setData",function(a){b.trigger("setData.ckeditor",
|
||||
[e,a.data])});e.on("getData",function(a){b.trigger("getData.ckeditor",[e,a.data])},999);e.on("destroy",function(){b.trigger("destroy.ckeditor",[e])});e.on("save",function(){a(h.form).submit();return!1},null,null,20);if(e.config.autoUpdateElementJquery&&b.is("textarea")&&a(h.form).length){var c=function(){b.ckeditor(function(){e.updateElement()})};a(h.form).submit(c);a(h.form).bind("form-pre-serialize",c);b.bind("destroy.ckeditor",function(){a(h.form).unbind("submit",c);a(h.form).unbind("form-pre-serialize",
|
||||
c)})}e.on("destroy",function(){b.removeData("ckeditorInstance")});b.removeData("_ckeditorInstanceLock");b.trigger("instanceReady.ckeditor",[e]);g&&g.apply(e,[h]);l.resolve()}else setTimeout(arguments.callee,100)},0)},null,null,9999)}});var f=new a.Deferred;this.promise=f.promise();a.when.apply(this,k).then(function(){f.resolve()});this.editor=this.eq(0).data("ckeditorInstance");return this}});CKEDITOR.config.jqueryOverrideVal&&(a.fn.val=CKEDITOR.tools.override(a.fn.val,function(g){return function(d){if(arguments.length){var m=
|
||||
this,k=[],f=this.each(function(){var b=a(this),c=b.data("ckeditorInstance");if(b.is("textarea")&&c){var f=new a.Deferred;c.setData(d,function(){f.resolve()});k.push(f.promise());return!0}return g.call(b,d)});if(k.length){var b=new a.Deferred;a.when.apply(this,k).done(function(){b.resolveWith(m)});return b.promise()}return f}var f=a(this).eq(0),c=f.data("ckeditorInstance");return f.is("textarea")&&c?c.getData():g.call(f)}}))})(window.jQuery);
|
||||
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
|
||||
* For licensing, see LICENSE.md or http://ckeditor.com/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* This file was added automatically by CKEditor builder.
|
||||
* You may re-use it at any time to build CKEditor again.
|
||||
*
|
||||
* If you would like to build CKEditor online again
|
||||
* (for example to upgrade), visit one the following links:
|
||||
*
|
||||
* (1) http://ckeditor.com/builder
|
||||
* Visit online builder to build CKEditor from scratch.
|
||||
*
|
||||
* (2) http://ckeditor.com/builder/8e53a61c5a403d4161d253fb0657d352
|
||||
* Visit online builder to build CKEditor, starting with the same setup as before.
|
||||
*
|
||||
* (3) http://ckeditor.com/builder/download/8e53a61c5a403d4161d253fb0657d352
|
||||
* Straight download link to the latest version of CKEditor (Optimized) with the same setup as before.
|
||||
*
|
||||
* NOTE:
|
||||
* This file is not used by CKEditor, you may remove it.
|
||||
* Changing this file will not change your CKEditor configuration.
|
||||
*/
|
||||
|
||||
var CKBUILDER_CONFIG = {
|
||||
skin: 'moono',
|
||||
preset: 'full',
|
||||
ignore: [
|
||||
'.DS_Store',
|
||||
'.bender',
|
||||
'.editorconfig',
|
||||
'.gitattributes',
|
||||
'.gitignore',
|
||||
'.idea',
|
||||
'.jscsrc',
|
||||
'.jshintignore',
|
||||
'.jshintrc',
|
||||
'.mailmap',
|
||||
'.travis.yml',
|
||||
'bender-err.log',
|
||||
'bender-out.log',
|
||||
'bender.ci.js',
|
||||
'bender.js',
|
||||
'dev',
|
||||
'gruntfile.js',
|
||||
'less',
|
||||
'node_modules',
|
||||
'package.json',
|
||||
'tests'
|
||||
],
|
||||
plugins : {
|
||||
'a11yhelp' : 1,
|
||||
'about' : 1,
|
||||
'basicstyles' : 1,
|
||||
'bidi' : 1,
|
||||
'blockquote' : 1,
|
||||
'clipboard' : 1,
|
||||
'colorbutton' : 1,
|
||||
'colordialog' : 1,
|
||||
'contextmenu' : 1,
|
||||
'copyformatting' : 1,
|
||||
'dialogadvtab' : 1,
|
||||
'div' : 1,
|
||||
'elementspath' : 1,
|
||||
'enterkey' : 1,
|
||||
'entities' : 1,
|
||||
'filebrowser' : 1,
|
||||
'find' : 1,
|
||||
'flash' : 1,
|
||||
'floatingspace' : 1,
|
||||
'font' : 1,
|
||||
'format' : 1,
|
||||
'forms' : 1,
|
||||
'horizontalrule' : 1,
|
||||
'htmlwriter' : 1,
|
||||
'iframe' : 1,
|
||||
'image' : 1,
|
||||
'indentblock' : 1,
|
||||
'indentlist' : 1,
|
||||
'justify' : 1,
|
||||
'language' : 1,
|
||||
'link' : 1,
|
||||
'list' : 1,
|
||||
'liststyle' : 1,
|
||||
'magicline' : 1,
|
||||
'maximize' : 1,
|
||||
'newpage' : 1,
|
||||
'pagebreak' : 1,
|
||||
'pastefromword' : 1,
|
||||
'pastetext' : 1,
|
||||
'preview' : 1,
|
||||
'print' : 1,
|
||||
'removeformat' : 1,
|
||||
'resize' : 1,
|
||||
'save' : 1,
|
||||
'scayt' : 1,
|
||||
'selectall' : 1,
|
||||
'showblocks' : 1,
|
||||
'showborders' : 1,
|
||||
'smiley' : 1,
|
||||
'sourcearea' : 1,
|
||||
'specialchar' : 1,
|
||||
'stylescombo' : 1,
|
||||
'tab' : 1,
|
||||
'table' : 1,
|
||||
'tableselection' : 1,
|
||||
'tabletools' : 1,
|
||||
'templates' : 1,
|
||||
'toolbar' : 1,
|
||||
'undo' : 1,
|
||||
'uploadimage' : 1,
|
||||
'wsc' : 1,
|
||||
'wysiwygarea' : 1
|
||||
},
|
||||
languages : {
|
||||
'en' : 1
|
||||
}
|
||||
};
|
||||
+1318
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
|
||||
* For licensing, see LICENSE.html or http://ckeditor.com/license
|
||||
*/
|
||||
|
||||
/*! \mainpage CKEditor - PHP server side intergation
|
||||
* \section intro_sec CKEditor
|
||||
* Visit <a href="http://ckeditor.com">CKEditor web site</a> to find more information about the editor.
|
||||
* \section install_sec Installation
|
||||
* \subsection step1 Include ckeditor.php in your PHP web site.
|
||||
* @code
|
||||
* <?php
|
||||
* include("ckeditor/ckeditor.php");
|
||||
* ?>
|
||||
* @endcode
|
||||
* \subsection step2 Create CKEditor class instance and use one of available methods to insert CKEditor.
|
||||
* @code
|
||||
* <?php
|
||||
* $CKEditor = new CKEditor();
|
||||
* echo $CKEditor->textarea("field1", "<p>Initial value.</p>");
|
||||
* ?>
|
||||
* @endcode
|
||||
*/
|
||||
|
||||
if ( !function_exists('version_compare') || version_compare( phpversion(), '5', '<' ) )
|
||||
include_once( 'ckeditor_php4.php' ) ;
|
||||
else
|
||||
include_once( 'ckeditor_php5.php' ) ;
|
||||
@@ -0,0 +1,618 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
|
||||
* For licensing, see LICENSE.html or http://ckeditor.com/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief CKEditor class that can be used to create editor
|
||||
* instances in PHP pages on server side.
|
||||
* @see http://ckeditor.com
|
||||
*
|
||||
* Sample usage:
|
||||
* @code
|
||||
* $CKEditor = new CKEditor();
|
||||
* $CKEditor->editor("editor1", "<p>Initial value.</p>");
|
||||
* @endcode
|
||||
*/
|
||||
class CKEditor
|
||||
{
|
||||
/**
|
||||
* The version of %CKEditor.
|
||||
* \private
|
||||
*/
|
||||
var $version = '3.5';
|
||||
/**
|
||||
* A constant string unique for each release of %CKEditor.
|
||||
* \private
|
||||
*/
|
||||
var $_timestamp = 'ABLC4TW';
|
||||
|
||||
/**
|
||||
* URL to the %CKEditor installation directory (absolute or relative to document root).
|
||||
* If not set, CKEditor will try to guess it's path.
|
||||
*
|
||||
* Example usage:
|
||||
* @code
|
||||
* $CKEditor->basePath = '/ckeditor/';
|
||||
* @endcode
|
||||
*/
|
||||
var $basePath;
|
||||
/**
|
||||
* An array that holds the global %CKEditor configuration.
|
||||
* For the list of available options, see http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html
|
||||
*
|
||||
* Example usage:
|
||||
* @code
|
||||
* $CKEditor->config['height'] = 400;
|
||||
* // Use @@ at the beggining of a string to ouput it without surrounding quotes.
|
||||
* $CKEditor->config['width'] = '@@screen.width * 0.8';
|
||||
* @endcode
|
||||
*/
|
||||
var $config = array();
|
||||
/**
|
||||
* A boolean variable indicating whether CKEditor has been initialized.
|
||||
* Set it to true only if you have already included
|
||||
* <script> tag loading ckeditor.js in your website.
|
||||
*/
|
||||
var $initialized = false;
|
||||
/**
|
||||
* Boolean variable indicating whether created code should be printed out or returned by a function.
|
||||
*
|
||||
* Example 1: get the code creating %CKEditor instance and print it on a page with the "echo" function.
|
||||
* @code
|
||||
* $CKEditor = new CKEditor();
|
||||
* $CKEditor->returnOutput = true;
|
||||
* $code = $CKEditor->editor("editor1", "<p>Initial value.</p>");
|
||||
* echo "<p>Editor 1:</p>";
|
||||
* echo $code;
|
||||
* @endcode
|
||||
*/
|
||||
var $returnOutput = false;
|
||||
/**
|
||||
* An array with textarea attributes.
|
||||
*
|
||||
* When %CKEditor is created with the editor() method, a HTML <textarea> element is created,
|
||||
* it will be displayed to anyone with JavaScript disabled or with incompatible browser.
|
||||
*/
|
||||
var $textareaAttributes = array( "rows" => 8, "cols" => 60 );
|
||||
/**
|
||||
* A string indicating the creation date of %CKEditor.
|
||||
* Do not change it unless you want to force browsers to not use previously cached version of %CKEditor.
|
||||
*/
|
||||
var $timestamp = "ABLC4TW";
|
||||
/**
|
||||
* An array that holds event listeners.
|
||||
* \private
|
||||
*/
|
||||
var $_events = array();
|
||||
/**
|
||||
* An array that holds global event listeners.
|
||||
* \private
|
||||
*/
|
||||
var $_globalEvents = array();
|
||||
|
||||
/**
|
||||
* Main Constructor.
|
||||
*
|
||||
* @param $basePath (string) URL to the %CKEditor installation directory (optional).
|
||||
*/
|
||||
function CKEditor($basePath = null) {
|
||||
if (!empty($basePath)) {
|
||||
$this->basePath = $basePath;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a %CKEditor instance.
|
||||
* In incompatible browsers %CKEditor will downgrade to plain HTML <textarea> element.
|
||||
*
|
||||
* @param $name (string) Name of the %CKEditor instance (this will be also the "name" attribute of textarea element).
|
||||
* @param $value (string) Initial value (optional).
|
||||
* @param $config (array) The specific configurations to apply to this editor instance (optional).
|
||||
* @param $events (array) Event listeners for this editor instance (optional).
|
||||
*
|
||||
* Example usage:
|
||||
* @code
|
||||
* $CKEditor = new CKEditor();
|
||||
* $CKEditor->editor("field1", "<p>Initial value.</p>");
|
||||
* @endcode
|
||||
*
|
||||
* Advanced example:
|
||||
* @code
|
||||
* $CKEditor = new CKEditor();
|
||||
* $config = array();
|
||||
* $config['toolbar'] = array(
|
||||
* array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ),
|
||||
* array( 'Image', 'Link', 'Unlink', 'Anchor' )
|
||||
* );
|
||||
* $events['instanceReady'] = 'function (ev) {
|
||||
* alert("Loaded: " + ev.editor.name);
|
||||
* }';
|
||||
* $CKEditor->editor("field1", "<p>Initial value.</p>", $config, $events);
|
||||
* @endcode
|
||||
*/
|
||||
function editor($name, $value = "", $config = array(), $events = array())
|
||||
{
|
||||
$attr = "";
|
||||
|
||||
if (isset($config["skin"])) {
|
||||
if (!file_exists(dirname(__FILE__)."/skins/".$config["skin"])) {
|
||||
$dirs = scandir(dirname(__FILE__)."/skins/");
|
||||
for ($x=0; $x<sizeof($dirs); $x++) {
|
||||
if (is_dir(dirname(__FILE__)."/skins/" . $dirs[$x]) && $dirs[$x] != "." && $dirs[$x] != ".." ) {
|
||||
$config["skin"] = $dirs[$x];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($this->textareaAttributes as $key => $val) {
|
||||
$attr.= " " . $key . '="' . str_replace('"', '"', $val) . '"';
|
||||
}
|
||||
if (isset($config['props'])) {
|
||||
if (isset($config['props']['required']) && $config['props']['required']) {
|
||||
if (isset($config['props']['class'])) {
|
||||
$config['props']['class'] .= " cke_validated";
|
||||
} else {
|
||||
$config['props']['class'] = "cke_validated";
|
||||
}
|
||||
}
|
||||
foreach ($config['props'] as $key => $val) {
|
||||
$attr.= " " . $key . '="' . str_replace('"', '"', $val) . '"';
|
||||
}
|
||||
}
|
||||
$out = "<textarea id=\"" . $name . "\" name=\"" . $name . "\"" . $attr . ">" . htmlspecialchars($value, ENT_COMPAT|ENT_IGNORE, "UTF-8") . "</textarea>\n";
|
||||
if (!$this->initialized) {
|
||||
$out .= $this->init();
|
||||
}
|
||||
|
||||
$_config = $this->configSettings($config, $events);
|
||||
|
||||
$js = $this->returnGlobalEvents();
|
||||
if (!empty($_config))
|
||||
$js .= "CKEDITOR.replace('".$name."', ".$this->jsEncode($_config).");";
|
||||
else
|
||||
$js .= "CKEDITOR.replace('".$name."');";
|
||||
|
||||
$out .= $this->script($js);
|
||||
|
||||
if (!$this->returnOutput) {
|
||||
print $out;
|
||||
$out = "";
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces a <textarea> with a %CKEditor instance.
|
||||
*
|
||||
* @param $id (string) The id or name of textarea element.
|
||||
* @param $config (array) The specific configurations to apply to this editor instance (optional).
|
||||
* @param $events (array) Event listeners for this editor instance (optional).
|
||||
*
|
||||
* Example 1: adding %CKEditor to <textarea name="article"></textarea> element:
|
||||
* @code
|
||||
* $CKEditor = new CKEditor();
|
||||
* $CKEditor->replace("article");
|
||||
* @endcode
|
||||
*/
|
||||
function replace($id, $config = array(), $events = array())
|
||||
{
|
||||
$out = "";
|
||||
if (!$this->initialized) {
|
||||
$out .= $this->init();
|
||||
}
|
||||
|
||||
$_config = $this->configSettings($config, $events);
|
||||
|
||||
$js = $this->returnGlobalEvents();
|
||||
if (!empty($_config)) {
|
||||
$js .= "CKEDITOR.replace('".$id."', ".$this->jsEncode($_config).");";
|
||||
}
|
||||
else {
|
||||
$js .= "CKEDITOR.replace('".$id."');";
|
||||
}
|
||||
$out .= $this->script($js);
|
||||
|
||||
if (!$this->returnOutput) {
|
||||
print $out;
|
||||
$out = "";
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace all <textarea> elements available in the document with editor instances.
|
||||
*
|
||||
* @param $className (string) If set, replace all textareas with class className in the page.
|
||||
*
|
||||
* Example 1: replace all <textarea> elements in the page.
|
||||
* @code
|
||||
* $CKEditor = new CKEditor();
|
||||
* $CKEditor->replaceAll();
|
||||
* @endcode
|
||||
*
|
||||
* Example 2: replace all <textarea class="myClassName"> elements in the page.
|
||||
* @code
|
||||
* $CKEditor = new CKEditor();
|
||||
* $CKEditor->replaceAll( 'myClassName' );
|
||||
* @endcode
|
||||
*/
|
||||
function replaceAll($className = null)
|
||||
{
|
||||
$out = "";
|
||||
if (!$this->initialized) {
|
||||
$out .= $this->init();
|
||||
}
|
||||
|
||||
$_config = $this->configSettings();
|
||||
|
||||
$js = $this->returnGlobalEvents();
|
||||
if (empty($_config)) {
|
||||
if (empty($className)) {
|
||||
$js .= "CKEDITOR.replaceAll();";
|
||||
}
|
||||
else {
|
||||
$js .= "CKEDITOR.replaceAll('".$className."');";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$classDetection = "";
|
||||
$js .= "CKEDITOR.replaceAll( function(textarea, config) {\n";
|
||||
if (!empty($className)) {
|
||||
$js .= " var classRegex = new RegExp('(?:^| )' + '". $className ."' + '(?:$| )');\n";
|
||||
$js .= " if (!classRegex.test(textarea.className))\n";
|
||||
$js .= " return false;\n";
|
||||
}
|
||||
$js .= " CKEDITOR.tools.extend(config, ". $this->jsEncode($_config) .", true);";
|
||||
$js .= "} );";
|
||||
|
||||
}
|
||||
|
||||
$out .= $this->script($js);
|
||||
|
||||
if (!$this->returnOutput) {
|
||||
print $out;
|
||||
$out = "";
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds event listener.
|
||||
* Events are fired by %CKEditor in various situations.
|
||||
*
|
||||
* @param $event (string) Event name.
|
||||
* @param $javascriptCode (string) Javascript anonymous function or function name.
|
||||
*
|
||||
* Example usage:
|
||||
* @code
|
||||
* $CKEditor->addEventHandler('instanceReady', 'function (ev) {
|
||||
* alert("Loaded: " + ev.editor.name);
|
||||
* }');
|
||||
* @endcode
|
||||
*/
|
||||
function addEventHandler($event, $javascriptCode)
|
||||
{
|
||||
if (!isset($this->_events[$event])) {
|
||||
$this->_events[$event] = array();
|
||||
}
|
||||
// Avoid duplicates.
|
||||
if (!in_array($javascriptCode, $this->_events[$event])) {
|
||||
$this->_events[$event][] = $javascriptCode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear registered event handlers.
|
||||
* Note: this function will have no effect on already created editor instances.
|
||||
*
|
||||
* @param $event (string) Event name, if not set all event handlers will be removed (optional).
|
||||
*/
|
||||
function clearEventHandlers($event = null)
|
||||
{
|
||||
if (!empty($event)) {
|
||||
$this->_events[$event] = array();
|
||||
}
|
||||
else {
|
||||
$this->_events = array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds global event listener.
|
||||
*
|
||||
* @param $event (string) Event name.
|
||||
* @param $javascriptCode (string) Javascript anonymous function or function name.
|
||||
*
|
||||
* Example usage:
|
||||
* @code
|
||||
* $CKEditor->addGlobalEventHandler('dialogDefinition', 'function (ev) {
|
||||
* alert("Loading dialog: " + ev.data.name);
|
||||
* }');
|
||||
* @endcode
|
||||
*/
|
||||
function addGlobalEventHandler($event, $javascriptCode)
|
||||
{
|
||||
if (!isset($this->_globalEvents[$event])) {
|
||||
$this->_globalEvents[$event] = array();
|
||||
}
|
||||
// Avoid duplicates.
|
||||
if (!in_array($javascriptCode, $this->_globalEvents[$event])) {
|
||||
$this->_globalEvents[$event][] = $javascriptCode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear registered global event handlers.
|
||||
* Note: this function will have no effect if the event handler has been already printed/returned.
|
||||
*
|
||||
* @param $event (string) Event name, if not set all event handlers will be removed (optional).
|
||||
*/
|
||||
function clearGlobalEventHandlers($event = null)
|
||||
{
|
||||
if (!empty($event)) {
|
||||
$this->_globalEvents[$event] = array();
|
||||
}
|
||||
else {
|
||||
$this->_globalEvents = array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints javascript code.
|
||||
* \private
|
||||
*
|
||||
* @param string $js
|
||||
*/
|
||||
function script($js)
|
||||
{
|
||||
$out = "<script type=\"text/javascript\">";
|
||||
$out .= "//<![CDATA[\n";
|
||||
$out .= $js;
|
||||
$out .= "\n//]]>";
|
||||
$out .= "</script>\n";
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration array (global and instance specific settings are merged into one array).
|
||||
* \private
|
||||
*
|
||||
* @param $config (array) The specific configurations to apply to editor instance.
|
||||
* @param $events (array) Event listeners for editor instance.
|
||||
*/
|
||||
function configSettings($config = array(), $events = array())
|
||||
{
|
||||
$_config = $this->config;
|
||||
$_events = $this->_events;
|
||||
|
||||
if (is_array($config) && !empty($config)) {
|
||||
$_config = array_merge($_config, $config);
|
||||
}
|
||||
|
||||
if (is_array($events) && !empty($events)) {
|
||||
foreach ($events as $eventName => $code) {
|
||||
if (!isset($_events[$eventName])) {
|
||||
$_events[$eventName] = array();
|
||||
}
|
||||
if (!in_array($code, $_events[$eventName])) {
|
||||
$_events[$eventName][] = $code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_events)) {
|
||||
foreach($_events as $eventName => $handlers) {
|
||||
if (empty($handlers)) {
|
||||
continue;
|
||||
}
|
||||
else if (count($handlers) == 1) {
|
||||
$_config['on'][$eventName] = '@@'.$handlers[0];
|
||||
}
|
||||
else {
|
||||
$_config['on'][$eventName] = '@@function (ev){';
|
||||
foreach ($handlers as $handler => $code) {
|
||||
$_config['on'][$eventName] .= '('.$code.')(ev);';
|
||||
}
|
||||
$_config['on'][$eventName] .= '}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $_config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return global event handlers.
|
||||
* \private
|
||||
*/
|
||||
function returnGlobalEvents()
|
||||
{
|
||||
static $returnedEvents;
|
||||
$out = "";
|
||||
|
||||
if (!isset($returnedEvents)) {
|
||||
$returnedEvents = array();
|
||||
}
|
||||
|
||||
if (!empty($this->_globalEvents)) {
|
||||
foreach ($this->_globalEvents as $eventName => $handlers) {
|
||||
foreach ($handlers as $handler => $code) {
|
||||
if (!isset($returnedEvents[$eventName])) {
|
||||
$returnedEvents[$eventName] = array();
|
||||
}
|
||||
// Return only new events
|
||||
if (!in_array($code, $returnedEvents[$eventName])) {
|
||||
$out .= ($code ? "\n" : "") . "CKEDITOR.on('". $eventName ."', $code);";
|
||||
$returnedEvents[$eventName][] = $code;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes CKEditor (executed only once).
|
||||
* \private
|
||||
*/
|
||||
function init()
|
||||
{
|
||||
static $initComplete;
|
||||
$out = "";
|
||||
|
||||
if (!empty($initComplete)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if ($this->initialized) {
|
||||
$initComplete = true;
|
||||
return "";
|
||||
}
|
||||
|
||||
$args = "";
|
||||
$ckeditorPath = $this->ckeditorPath();
|
||||
|
||||
if (!empty($this->timestamp) && $this->timestamp != "%"."TIMESTAMP%") {
|
||||
$args = '?t=' . $this->timestamp;
|
||||
}
|
||||
|
||||
// Skip relative paths...
|
||||
if (strpos($ckeditorPath, '..') !== 0) {
|
||||
$out .= $this->script("window.CKEDITOR_BASEPATH='". $ckeditorPath ."';");
|
||||
}
|
||||
|
||||
$out .= "<script type=\"text/javascript\" src=\"" . $ckeditorPath . 'ckeditor.js' . $args . "\"></script>\n";
|
||||
|
||||
$extraCode = "";
|
||||
if ($this->timestamp != $this->_timestamp) {
|
||||
$extraCode .= ($extraCode ? "\n" : "") . "CKEDITOR.timestamp = '". $this->timestamp ."';";
|
||||
}
|
||||
if ($extraCode) {
|
||||
$out .= $this->script($extraCode);
|
||||
}
|
||||
|
||||
$initComplete = $this->initialized = true;
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return path to ckeditor.js.
|
||||
* \private
|
||||
*/
|
||||
function ckeditorPath()
|
||||
{
|
||||
if (!empty($this->basePath)) {
|
||||
return $this->basePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* The absolute pathname of the currently executing script.
|
||||
* Note: If a script is executed with the CLI, as a relative path, such as file.php or ../file.php,
|
||||
* $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user.
|
||||
*/
|
||||
if (isset($_SERVER['SCRIPT_FILENAME'])) {
|
||||
$realPath = dirname($_SERVER['SCRIPT_FILENAME']);
|
||||
}
|
||||
else {
|
||||
/**
|
||||
* realpath — Returns canonicalized absolute pathname
|
||||
*/
|
||||
$realPath = realpath( './' ) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* The filename of the currently executing script, relative to the document root.
|
||||
* For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar
|
||||
* would be /test.php/foo.bar.
|
||||
*/
|
||||
$selfPath = dirname($_SERVER['PHP_SELF']);
|
||||
$file = str_replace("\\", "/", __FILE__);
|
||||
|
||||
if (!$selfPath || !$realPath || !$file) {
|
||||
return "/ckeditor/";
|
||||
}
|
||||
|
||||
$documentRoot = substr($realPath, 0, strlen($realPath) - strlen($selfPath));
|
||||
$fileUrl = substr($file, strlen($documentRoot));
|
||||
$ckeditorUrl = str_replace("ckeditor_php5.php", "", $fileUrl);
|
||||
|
||||
return $ckeditorUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* This little function provides a basic JSON support.
|
||||
* http://php.net/manual/en/function.json-encode.php
|
||||
* \private
|
||||
*
|
||||
* @param mixed $val
|
||||
* @return string
|
||||
*/
|
||||
function jsEncode($val)
|
||||
{
|
||||
if (is_null($val)) {
|
||||
return 'null';
|
||||
}
|
||||
if ($val === false) {
|
||||
return 'false';
|
||||
}
|
||||
if ($val === true) {
|
||||
return 'true';
|
||||
}
|
||||
if (is_scalar($val))
|
||||
{
|
||||
if (is_float($val))
|
||||
{
|
||||
// Always use "." for floats.
|
||||
$val = str_replace(",", ".", strval($val));
|
||||
}
|
||||
|
||||
// Use @@ to not use quotes when outputting string value
|
||||
if (strpos($val, '@@') === 0) {
|
||||
return substr($val, 2);
|
||||
}
|
||||
else {
|
||||
// All scalars are converted to strings to avoid indeterminism.
|
||||
// PHP's "1" and 1 are equal for all PHP operators, but
|
||||
// JS's "1" and 1 are not. So if we pass "1" or 1 from the PHP backend,
|
||||
// we should get the same result in the JS frontend (string).
|
||||
// Character replacements for JSON.
|
||||
static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'),
|
||||
array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
|
||||
|
||||
$val = str_replace($jsonReplaces[0], $jsonReplaces[1], $val);
|
||||
|
||||
return '"' . $val . '"';
|
||||
}
|
||||
}
|
||||
$isList = true;
|
||||
for ($i = 0, reset($val); $i < count($val); $i++, next($val))
|
||||
{
|
||||
if (key($val) !== $i)
|
||||
{
|
||||
$isList = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$result = array();
|
||||
if ($isList)
|
||||
{
|
||||
foreach ($val as $v) $result[] = $this->jsEncode($v);
|
||||
return '[ ' . join(', ', $result) . ' ]';
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($val as $k => $v) $result[] = $this->jsEncode($k).': '.$this->jsEncode($v);
|
||||
return '{ ' . join(', ', $result) . ' }';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,607 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright (c) 2003-2010, CKSource - Frederico Knabben. All rights reserved.
|
||||
* For licensing, see LICENSE.html or http://ckeditor.com/license
|
||||
*/
|
||||
|
||||
/**
|
||||
* \brief CKEditor class that can be used to create editor
|
||||
* instances in PHP pages on server side.
|
||||
* @see http://ckeditor.com
|
||||
*
|
||||
* Sample usage:
|
||||
* @code
|
||||
* $CKEditor = new CKEditor();
|
||||
* $CKEditor->editor("editor1", "<p>Initial value.</p>");
|
||||
* @endcode
|
||||
*/
|
||||
class CKEditor
|
||||
{
|
||||
/**
|
||||
* The version of %CKEditor.
|
||||
*/
|
||||
const version = '3.5';
|
||||
/**
|
||||
* A constant string unique for each release of %CKEditor.
|
||||
*/
|
||||
const timestamp = 'ABLC4TW';
|
||||
|
||||
/**
|
||||
* URL to the %CKEditor installation directory (absolute or relative to document root).
|
||||
* If not set, CKEditor will try to guess it's path.
|
||||
*
|
||||
* Example usage:
|
||||
* @code
|
||||
* $CKEditor->basePath = '/ckeditor/';
|
||||
* @endcode
|
||||
*/
|
||||
public $basePath;
|
||||
/**
|
||||
* An array that holds the global %CKEditor configuration.
|
||||
* For the list of available options, see http://docs.cksource.com/ckeditor_api/symbols/CKEDITOR.config.html
|
||||
*
|
||||
* Example usage:
|
||||
* @code
|
||||
* $CKEditor->config['height'] = 400;
|
||||
* // Use @@ at the beggining of a string to ouput it without surrounding quotes.
|
||||
* $CKEditor->config['width'] = '@@screen.width * 0.8';
|
||||
* @endcode
|
||||
*/
|
||||
public $config = array();
|
||||
/**
|
||||
* A boolean variable indicating whether CKEditor has been initialized.
|
||||
* Set it to true only if you have already included
|
||||
* <script> tag loading ckeditor.js in your website.
|
||||
*/
|
||||
public $initialized = false;
|
||||
/**
|
||||
* Boolean variable indicating whether created code should be printed out or returned by a function.
|
||||
*
|
||||
* Example 1: get the code creating %CKEditor instance and print it on a page with the "echo" function.
|
||||
* @code
|
||||
* $CKEditor = new CKEditor();
|
||||
* $CKEditor->returnOutput = true;
|
||||
* $code = $CKEditor->editor("editor1", "<p>Initial value.</p>");
|
||||
* echo "<p>Editor 1:</p>";
|
||||
* echo $code;
|
||||
* @endcode
|
||||
*/
|
||||
public $returnOutput = false;
|
||||
/**
|
||||
* An array with textarea attributes.
|
||||
*
|
||||
* When %CKEditor is created with the editor() method, a HTML <textarea> element is created,
|
||||
* it will be displayed to anyone with JavaScript disabled or with incompatible browser.
|
||||
*/
|
||||
public $textareaAttributes = array( "rows" => 8, "cols" => 60 );
|
||||
/**
|
||||
* A string indicating the creation date of %CKEditor.
|
||||
* Do not change it unless you want to force browsers to not use previously cached version of %CKEditor.
|
||||
*/
|
||||
public $timestamp = "ABLC4TW";
|
||||
/**
|
||||
* An array that holds event listeners.
|
||||
*/
|
||||
private $events = array();
|
||||
/**
|
||||
* An array that holds global event listeners.
|
||||
*/
|
||||
private $globalEvents = array();
|
||||
|
||||
/**
|
||||
* Main Constructor.
|
||||
*
|
||||
* @param $basePath (string) URL to the %CKEditor installation directory (optional).
|
||||
*/
|
||||
function __construct($basePath = null) {
|
||||
if (!empty($basePath)) {
|
||||
$this->basePath = $basePath;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a %CKEditor instance.
|
||||
* In incompatible browsers %CKEditor will downgrade to plain HTML <textarea> element.
|
||||
*
|
||||
* @param $name (string) Name of the %CKEditor instance (this will be also the "name" attribute of textarea element).
|
||||
* @param $value (string) Initial value (optional).
|
||||
* @param $config (array) The specific configurations to apply to this editor instance (optional).
|
||||
* @param $events (array) Event listeners for this editor instance (optional).
|
||||
*
|
||||
* Example usage:
|
||||
* @code
|
||||
* $CKEditor = new CKEditor();
|
||||
* $CKEditor->editor("field1", "<p>Initial value.</p>");
|
||||
* @endcode
|
||||
*
|
||||
* Advanced example:
|
||||
* @code
|
||||
* $CKEditor = new CKEditor();
|
||||
* $config = array();
|
||||
* $config['toolbar'] = array(
|
||||
* array( 'Source', '-', 'Bold', 'Italic', 'Underline', 'Strike' ),
|
||||
* array( 'Image', 'Link', 'Unlink', 'Anchor' )
|
||||
* );
|
||||
* $events['instanceReady'] = 'function (ev) {
|
||||
* alert("Loaded: " + ev.editor.name);
|
||||
* }';
|
||||
* $CKEditor->editor("field1", "<p>Initial value.</p>", $config, $events);
|
||||
* @endcode
|
||||
*/
|
||||
public function editor($name, $value = "", $config = array(), $events = array())
|
||||
{
|
||||
$attr = "";
|
||||
if (isset($config["skin"])) {
|
||||
if (!file_exists(dirname(__FILE__)."/skins/".$config["skin"])) {
|
||||
$dirs = scandir(dirname(__FILE__)."/skins/");
|
||||
for ($x=0; $x<sizeof($dirs); $x++) {
|
||||
if (is_dir(dirname(__FILE__)."/skins/" . $dirs[$x]) && $dirs[$x] != "." && $dirs[$x] != ".." ) {
|
||||
$config["skin"] = $dirs[$x];
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
foreach ($this->textareaAttributes as $key => $val) {
|
||||
$attr.= " " . $key . '="' . str_replace('"', '"', $val) . '"';
|
||||
}
|
||||
if (isset($config['props'])) {
|
||||
if (isset($config['props']['required']) && $config['props']['required']) {
|
||||
if (isset($config['props']['class'])) {
|
||||
$config['props']['class'] .= " cke_validated";
|
||||
} else {
|
||||
$config['props']['class'] = "cke_validated";
|
||||
}
|
||||
}
|
||||
foreach ($config['props'] as $key => $val) {
|
||||
$attr.= " " . $key . '="' . str_replace('"', '"', $val) . '"';
|
||||
}
|
||||
}
|
||||
$out = "<textarea id=\"" . $name . "\" name=\"" . $name . "\"" . $attr . ">" . htmlspecialchars($value, ENT_COMPAT|ENT_IGNORE, "UTF-8") . "</textarea>\n";
|
||||
if (!$this->initialized) {
|
||||
$out .= $this->init();
|
||||
}
|
||||
|
||||
$_config = $this->configSettings($config, $events);
|
||||
|
||||
$js = $this->returnGlobalEvents();
|
||||
if (!empty($_config))
|
||||
$js .= "CKEDITOR.replace('".$name."', ".$this->jsEncode($_config).");";
|
||||
else
|
||||
$js .= "CKEDITOR.replace('".$name."');";
|
||||
|
||||
$out .= $this->script($js);
|
||||
|
||||
if (!$this->returnOutput) {
|
||||
print $out;
|
||||
$out = "";
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replaces a <textarea> with a %CKEditor instance.
|
||||
*
|
||||
* @param $id (string) The id or name of textarea element.
|
||||
* @param $config (array) The specific configurations to apply to this editor instance (optional).
|
||||
* @param $events (array) Event listeners for this editor instance (optional).
|
||||
*
|
||||
* Example 1: adding %CKEditor to <textarea name="article"></textarea> element:
|
||||
* @code
|
||||
* $CKEditor = new CKEditor();
|
||||
* $CKEditor->replace("article");
|
||||
* @endcode
|
||||
*/
|
||||
public function replace($id, $config = array(), $events = array())
|
||||
{
|
||||
$out = "";
|
||||
if (!$this->initialized) {
|
||||
$out .= $this->init();
|
||||
}
|
||||
|
||||
$_config = $this->configSettings($config, $events);
|
||||
|
||||
$js = $this->returnGlobalEvents();
|
||||
if (!empty($_config)) {
|
||||
$js .= "CKEDITOR.replace('".$id."', ".$this->jsEncode($_config).");";
|
||||
}
|
||||
else {
|
||||
$js .= "CKEDITOR.replace('".$id."');";
|
||||
}
|
||||
$out .= $this->script($js);
|
||||
|
||||
if (!$this->returnOutput) {
|
||||
print $out;
|
||||
$out = "";
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Replace all <textarea> elements available in the document with editor instances.
|
||||
*
|
||||
* @param $className (string) If set, replace all textareas with class className in the page.
|
||||
*
|
||||
* Example 1: replace all <textarea> elements in the page.
|
||||
* @code
|
||||
* $CKEditor = new CKEditor();
|
||||
* $CKEditor->replaceAll();
|
||||
* @endcode
|
||||
*
|
||||
* Example 2: replace all <textarea class="myClassName"> elements in the page.
|
||||
* @code
|
||||
* $CKEditor = new CKEditor();
|
||||
* $CKEditor->replaceAll( 'myClassName' );
|
||||
* @endcode
|
||||
*/
|
||||
public function replaceAll($className = null)
|
||||
{
|
||||
$out = "";
|
||||
if (!$this->initialized) {
|
||||
$out .= $this->init();
|
||||
}
|
||||
|
||||
$_config = $this->configSettings();
|
||||
|
||||
$js = $this->returnGlobalEvents();
|
||||
if (empty($_config)) {
|
||||
if (empty($className)) {
|
||||
$js .= "CKEDITOR.replaceAll();";
|
||||
}
|
||||
else {
|
||||
$js .= "CKEDITOR.replaceAll('".$className."');";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$classDetection = "";
|
||||
$js .= "CKEDITOR.replaceAll( function(textarea, config) {\n";
|
||||
if (!empty($className)) {
|
||||
$js .= " var classRegex = new RegExp('(?:^| )' + '". $className ."' + '(?:$| )');\n";
|
||||
$js .= " if (!classRegex.test(textarea.className))\n";
|
||||
$js .= " return false;\n";
|
||||
}
|
||||
$js .= " CKEDITOR.tools.extend(config, ". $this->jsEncode($_config) .", true);";
|
||||
$js .= "} );";
|
||||
|
||||
}
|
||||
|
||||
$out .= $this->script($js);
|
||||
|
||||
if (!$this->returnOutput) {
|
||||
print $out;
|
||||
$out = "";
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds event listener.
|
||||
* Events are fired by %CKEditor in various situations.
|
||||
*
|
||||
* @param $event (string) Event name.
|
||||
* @param $javascriptCode (string) Javascript anonymous function or function name.
|
||||
*
|
||||
* Example usage:
|
||||
* @code
|
||||
* $CKEditor->addEventHandler('instanceReady', 'function (ev) {
|
||||
* alert("Loaded: " + ev.editor.name);
|
||||
* }');
|
||||
* @endcode
|
||||
*/
|
||||
public function addEventHandler($event, $javascriptCode)
|
||||
{
|
||||
if (!isset($this->events[$event])) {
|
||||
$this->events[$event] = array();
|
||||
}
|
||||
// Avoid duplicates.
|
||||
if (!in_array($javascriptCode, $this->events[$event])) {
|
||||
$this->events[$event][] = $javascriptCode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear registered event handlers.
|
||||
* Note: this function will have no effect on already created editor instances.
|
||||
*
|
||||
* @param $event (string) Event name, if not set all event handlers will be removed (optional).
|
||||
*/
|
||||
public function clearEventHandlers($event = null)
|
||||
{
|
||||
if (!empty($event)) {
|
||||
$this->events[$event] = array();
|
||||
}
|
||||
else {
|
||||
$this->events = array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds global event listener.
|
||||
*
|
||||
* @param $event (string) Event name.
|
||||
* @param $javascriptCode (string) Javascript anonymous function or function name.
|
||||
*
|
||||
* Example usage:
|
||||
* @code
|
||||
* $CKEditor->addGlobalEventHandler('dialogDefinition', 'function (ev) {
|
||||
* alert("Loading dialog: " + ev.data.name);
|
||||
* }');
|
||||
* @endcode
|
||||
*/
|
||||
public function addGlobalEventHandler($event, $javascriptCode)
|
||||
{
|
||||
if (!isset($this->globalEvents[$event])) {
|
||||
$this->globalEvents[$event] = array();
|
||||
}
|
||||
// Avoid duplicates.
|
||||
if (!in_array($javascriptCode, $this->globalEvents[$event])) {
|
||||
$this->globalEvents[$event][] = $javascriptCode;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear registered global event handlers.
|
||||
* Note: this function will have no effect if the event handler has been already printed/returned.
|
||||
*
|
||||
* @param $event (string) Event name, if not set all event handlers will be removed (optional).
|
||||
*/
|
||||
public function clearGlobalEventHandlers($event = null)
|
||||
{
|
||||
if (!empty($event)) {
|
||||
$this->globalEvents[$event] = array();
|
||||
}
|
||||
else {
|
||||
$this->globalEvents = array();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prints javascript code.
|
||||
*
|
||||
* @param string $js
|
||||
*/
|
||||
private function script($js)
|
||||
{
|
||||
$out = "<script type=\"text/javascript\">";
|
||||
$out .= "//<![CDATA[\n";
|
||||
$out .= $js;
|
||||
$out .= "\n//]]>";
|
||||
$out .= "</script>\n";
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the configuration array (global and instance specific settings are merged into one array).
|
||||
*
|
||||
* @param $config (array) The specific configurations to apply to editor instance.
|
||||
* @param $events (array) Event listeners for editor instance.
|
||||
*/
|
||||
private function configSettings($config = array(), $events = array())
|
||||
{
|
||||
$_config = $this->config;
|
||||
$_events = $this->events;
|
||||
|
||||
if (is_array($config) && !empty($config)) {
|
||||
$_config = array_merge($_config, $config);
|
||||
}
|
||||
|
||||
if (is_array($events) && !empty($events)) {
|
||||
foreach ($events as $eventName => $code) {
|
||||
if (!isset($_events[$eventName])) {
|
||||
$_events[$eventName] = array();
|
||||
}
|
||||
if (!in_array($code, $_events[$eventName])) {
|
||||
$_events[$eventName][] = $code;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($_events)) {
|
||||
foreach($_events as $eventName => $handlers) {
|
||||
if (empty($handlers)) {
|
||||
continue;
|
||||
}
|
||||
else if (count($handlers) == 1) {
|
||||
$_config['on'][$eventName] = '@@'.$handlers[0];
|
||||
}
|
||||
else {
|
||||
$_config['on'][$eventName] = '@@function (ev){';
|
||||
foreach ($handlers as $handler => $code) {
|
||||
$_config['on'][$eventName] .= '('.$code.')(ev);';
|
||||
}
|
||||
$_config['on'][$eventName] .= '}';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $_config;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return global event handlers.
|
||||
*/
|
||||
private function returnGlobalEvents()
|
||||
{
|
||||
static $returnedEvents;
|
||||
$out = "";
|
||||
|
||||
if (!isset($returnedEvents)) {
|
||||
$returnedEvents = array();
|
||||
}
|
||||
|
||||
if (!empty($this->globalEvents)) {
|
||||
foreach ($this->globalEvents as $eventName => $handlers) {
|
||||
foreach ($handlers as $handler => $code) {
|
||||
if (!isset($returnedEvents[$eventName])) {
|
||||
$returnedEvents[$eventName] = array();
|
||||
}
|
||||
// Return only new events
|
||||
if (!in_array($code, $returnedEvents[$eventName])) {
|
||||
$out .= ($code ? "\n" : "") . "CKEDITOR.on('". $eventName ."', $code);";
|
||||
$returnedEvents[$eventName][] = $code;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes CKEditor (executed only once).
|
||||
*/
|
||||
private function init()
|
||||
{
|
||||
static $initComplete;
|
||||
$out = "";
|
||||
|
||||
if (!empty($initComplete)) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if ($this->initialized) {
|
||||
$initComplete = true;
|
||||
return "";
|
||||
}
|
||||
|
||||
$args = "";
|
||||
$ckeditorPath = $this->ckeditorPath();
|
||||
|
||||
if (!empty($this->timestamp) && $this->timestamp != "%"."TIMESTAMP%") {
|
||||
$args = '?t=' . $this->timestamp;
|
||||
}
|
||||
|
||||
// Skip relative paths...
|
||||
if (strpos($ckeditorPath, '..') !== 0) {
|
||||
$out .= $this->script("window.CKEDITOR_BASEPATH='". $ckeditorPath ."';");
|
||||
}
|
||||
|
||||
$out .= "<script type=\"text/javascript\" src=\"" . $ckeditorPath . 'ckeditor.js' . $args . "\"></script>\n";
|
||||
|
||||
$extraCode = "";
|
||||
if ($this->timestamp != self::timestamp) {
|
||||
$extraCode .= ($extraCode ? "\n" : "") . "CKEDITOR.timestamp = '". $this->timestamp ."';";
|
||||
}
|
||||
if ($extraCode) {
|
||||
$out .= $this->script($extraCode);
|
||||
}
|
||||
|
||||
$initComplete = $this->initialized = true;
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return path to ckeditor.js.
|
||||
*/
|
||||
private function ckeditorPath()
|
||||
{
|
||||
if (!empty($this->basePath)) {
|
||||
return $this->basePath;
|
||||
}
|
||||
|
||||
/**
|
||||
* The absolute pathname of the currently executing script.
|
||||
* Note: If a script is executed with the CLI, as a relative path, such as file.php or ../file.php,
|
||||
* $_SERVER['SCRIPT_FILENAME'] will contain the relative path specified by the user.
|
||||
*/
|
||||
if (isset($_SERVER['SCRIPT_FILENAME'])) {
|
||||
$realPath = dirname($_SERVER['SCRIPT_FILENAME']);
|
||||
}
|
||||
else {
|
||||
/**
|
||||
* realpath — Returns canonicalized absolute pathname
|
||||
*/
|
||||
$realPath = realpath( './' ) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* The filename of the currently executing script, relative to the document root.
|
||||
* For instance, $_SERVER['PHP_SELF'] in a script at the address http://example.com/test.php/foo.bar
|
||||
* would be /test.php/foo.bar.
|
||||
*/
|
||||
$selfPath = dirname($_SERVER['PHP_SELF']);
|
||||
$file = str_replace("\\", "/", __FILE__);
|
||||
|
||||
if (!$selfPath || !$realPath || !$file) {
|
||||
return "/ckeditor/";
|
||||
}
|
||||
|
||||
$documentRoot = substr($realPath, 0, strlen($realPath) - strlen($selfPath));
|
||||
$fileUrl = substr($file, strlen($documentRoot));
|
||||
$ckeditorUrl = str_replace("ckeditor_php5.php", "", $fileUrl);
|
||||
|
||||
return $ckeditorUrl;
|
||||
}
|
||||
|
||||
/**
|
||||
* This little function provides a basic JSON support.
|
||||
* http://php.net/manual/en/function.json-encode.php
|
||||
*
|
||||
* @param mixed $val
|
||||
* @return string
|
||||
*/
|
||||
private function jsEncode($val)
|
||||
{
|
||||
if (is_null($val)) {
|
||||
return 'null';
|
||||
}
|
||||
if ($val === false) {
|
||||
return 'false';
|
||||
}
|
||||
if ($val === true) {
|
||||
return 'true';
|
||||
}
|
||||
if (is_scalar($val))
|
||||
{
|
||||
if (is_float($val))
|
||||
{
|
||||
// Always use "." for floats.
|
||||
$val = str_replace(",", ".", strval($val));
|
||||
}
|
||||
|
||||
// Use @@ to not use quotes when outputting string value
|
||||
if (strpos($val, '@@') === 0) {
|
||||
return substr($val, 2);
|
||||
}
|
||||
else {
|
||||
// All scalars are converted to strings to avoid indeterminism.
|
||||
// PHP's "1" and 1 are equal for all PHP operators, but
|
||||
// JS's "1" and 1 are not. So if we pass "1" or 1 from the PHP backend,
|
||||
// we should get the same result in the JS frontend (string).
|
||||
// Character replacements for JSON.
|
||||
static $jsonReplaces = array(array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'),
|
||||
array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
|
||||
|
||||
$val = str_replace($jsonReplaces[0], $jsonReplaces[1], $val);
|
||||
|
||||
return '"' . $val . '"';
|
||||
}
|
||||
}
|
||||
$isList = true;
|
||||
for ($i = 0, reset($val); $i < count($val); $i++, next($val))
|
||||
{
|
||||
if (key($val) !== $i)
|
||||
{
|
||||
$isList = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$result = array();
|
||||
if ($isList)
|
||||
{
|
||||
foreach ($val as $v) $result[] = $this->jsEncode($v);
|
||||
return '[ ' . join(', ', $result) . ' ]';
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach ($val as $k => $v) $result[] = $this->jsEncode($k).': '.$this->jsEncode($v);
|
||||
return '{ ' . join(', ', $result) . ' }';
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,13 @@
|
||||
/**
|
||||
* @license Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
|
||||
* For licensing, see https://ckeditor.com/legal/ckeditor-oss-license
|
||||
*/
|
||||
|
||||
CKEDITOR.editorConfig = function( config ) {
|
||||
// Define changes to default configuration here. For example:
|
||||
// config.language = 'fr';
|
||||
// config.uiColor = '#AADC6E';
|
||||
config.enterMode = CKEDITOR.ENTER_BR;
|
||||
config.allowedContent = true;
|
||||
config.autoParagraph = false;
|
||||
};
|
||||
@@ -0,0 +1,207 @@
|
||||
/*
|
||||
Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
|
||||
For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
||||
*/
|
||||
|
||||
body
|
||||
{
|
||||
/* Font */
|
||||
font-family: sans-serif, Arial, Verdana, "Trebuchet MS";
|
||||
font-size: 12px;
|
||||
|
||||
/* Text color */
|
||||
color: #333;
|
||||
|
||||
/* Remove the background color to make it transparent */
|
||||
background-color: #fff;
|
||||
|
||||
margin: 20px;
|
||||
}
|
||||
|
||||
.cke_editable
|
||||
{
|
||||
font-size: 13px;
|
||||
line-height: 1.6;
|
||||
|
||||
/* Fix for missing scrollbars with RTL texts. (#10488) */
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
blockquote
|
||||
{
|
||||
font-style: italic;
|
||||
font-family: Georgia, Times, "Times New Roman", serif;
|
||||
padding: 2px 0;
|
||||
border-style: solid;
|
||||
border-color: #ccc;
|
||||
border-width: 0;
|
||||
}
|
||||
|
||||
.cke_contents_ltr blockquote
|
||||
{
|
||||
padding-left: 20px;
|
||||
padding-right: 8px;
|
||||
border-left-width: 5px;
|
||||
}
|
||||
|
||||
.cke_contents_rtl blockquote
|
||||
{
|
||||
padding-left: 8px;
|
||||
padding-right: 20px;
|
||||
border-right-width: 5px;
|
||||
}
|
||||
|
||||
a
|
||||
{
|
||||
color: #0782C1;
|
||||
}
|
||||
|
||||
ol,ul,dl
|
||||
{
|
||||
/* IE7: reset rtl list margin. (#7334) */
|
||||
*margin-right: 0px;
|
||||
/* preserved spaces for list items with text direction other than the list. (#6249,#8049)*/
|
||||
padding: 0 40px;
|
||||
}
|
||||
|
||||
h1,h2,h3,h4,h5,h6
|
||||
{
|
||||
font-weight: normal;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
hr
|
||||
{
|
||||
border: 0px;
|
||||
border-top: 1px solid #ccc;
|
||||
}
|
||||
|
||||
img.right
|
||||
{
|
||||
border: 1px solid #ccc;
|
||||
float: right;
|
||||
margin-left: 15px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
img.left
|
||||
{
|
||||
border: 1px solid #ccc;
|
||||
float: left;
|
||||
margin-right: 15px;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
pre
|
||||
{
|
||||
white-space: pre-wrap; /* CSS 2.1 */
|
||||
word-wrap: break-word; /* IE7 */
|
||||
-moz-tab-size: 4;
|
||||
tab-size: 4;
|
||||
}
|
||||
|
||||
.marker
|
||||
{
|
||||
background-color: Yellow;
|
||||
}
|
||||
|
||||
span[lang]
|
||||
{
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
figure
|
||||
{
|
||||
text-align: center;
|
||||
outline: solid 1px #ccc;
|
||||
background: rgba(0,0,0,0.05);
|
||||
padding: 10px;
|
||||
margin: 10px 20px;
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
figure > figcaption
|
||||
{
|
||||
text-align: center;
|
||||
display: block; /* For IE8 */
|
||||
}
|
||||
|
||||
a > img {
|
||||
padding: 1px;
|
||||
margin: 1px;
|
||||
border: none;
|
||||
outline: 1px solid #0782C1;
|
||||
}
|
||||
|
||||
/* Widget Styles */
|
||||
.code-featured
|
||||
{
|
||||
border: 5px solid red;
|
||||
}
|
||||
|
||||
.math-featured
|
||||
{
|
||||
padding: 20px;
|
||||
box-shadow: 0 0 2px rgba(200, 0, 0, 1);
|
||||
background-color: rgba(255, 0, 0, 0.05);
|
||||
margin: 10px;
|
||||
}
|
||||
|
||||
.image-clean
|
||||
{
|
||||
border: 0;
|
||||
background: none;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.image-clean > figcaption
|
||||
{
|
||||
font-size: .9em;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.image-grayscale
|
||||
{
|
||||
background-color: white;
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.image-grayscale img, img.image-grayscale
|
||||
{
|
||||
filter: grayscale(100%);
|
||||
}
|
||||
|
||||
.embed-240p
|
||||
{
|
||||
max-width: 426px;
|
||||
max-height: 240px;
|
||||
margin:0 auto;
|
||||
}
|
||||
|
||||
.embed-360p
|
||||
{
|
||||
max-width: 640px;
|
||||
max-height: 360px;
|
||||
margin:0 auto;
|
||||
}
|
||||
|
||||
.embed-480p
|
||||
{
|
||||
max-width: 854px;
|
||||
max-height: 480px;
|
||||
margin:0 auto;
|
||||
}
|
||||
|
||||
.embed-720p
|
||||
{
|
||||
max-width: 1280px;
|
||||
max-height: 720px;
|
||||
margin:0 auto;
|
||||
}
|
||||
|
||||
.embed-1080p
|
||||
{
|
||||
max-width: 1920px;
|
||||
max-height: 1080px;
|
||||
margin:0 auto;
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 39 KiB |
@@ -0,0 +1,137 @@
|
||||
/**
|
||||
* Copyright (c) 2003-2018, CKSource - Frederico Knabben. All rights reserved.
|
||||
* For licensing, see LICENSE.md or https://ckeditor.com/legal/ckeditor-oss-license
|
||||
*/
|
||||
|
||||
// This file contains style definitions that can be used by CKEditor plugins.
|
||||
//
|
||||
// The most common use for it is the "stylescombo" plugin which shows the Styles drop-down
|
||||
// list containing all styles in the editor toolbar. Other plugins, like
|
||||
// the "div" plugin, use a subset of the styles for their features.
|
||||
//
|
||||
// If you do not have plugins that depend on this file in your editor build, you can simply
|
||||
// ignore it. Otherwise it is strongly recommended to customize this file to match your
|
||||
// website requirements and design properly.
|
||||
//
|
||||
// For more information refer to: https://docs.ckeditor.com/ckeditor4/docs/#!/guide/dev_styles-section-style-rules
|
||||
|
||||
CKEDITOR.stylesSet.add( 'default', [
|
||||
/* Block styles */
|
||||
|
||||
// These styles are already available in the "Format" drop-down list ("format" plugin),
|
||||
// so they are not needed here by default. You may enable them to avoid
|
||||
// placing the "Format" combo in the toolbar, maintaining the same features.
|
||||
/*
|
||||
{ name: 'Paragraph', element: 'p' },
|
||||
{ name: 'Heading 1', element: 'h1' },
|
||||
{ name: 'Heading 2', element: 'h2' },
|
||||
{ name: 'Heading 3', element: 'h3' },
|
||||
{ name: 'Heading 4', element: 'h4' },
|
||||
{ name: 'Heading 5', element: 'h5' },
|
||||
{ name: 'Heading 6', element: 'h6' },
|
||||
{ name: 'Preformatted Text',element: 'pre' },
|
||||
{ name: 'Address', element: 'address' },
|
||||
*/
|
||||
|
||||
{ name: 'Italic Title', element: 'h2', styles: { 'font-style': 'italic' } },
|
||||
{ name: 'Subtitle', element: 'h3', styles: { 'color': '#aaa', 'font-style': 'italic' } },
|
||||
{
|
||||
name: 'Special Container',
|
||||
element: 'div',
|
||||
styles: {
|
||||
padding: '5px 10px',
|
||||
background: '#eee',
|
||||
border: '1px solid #ccc'
|
||||
}
|
||||
},
|
||||
|
||||
/* Inline styles */
|
||||
|
||||
// These are core styles available as toolbar buttons. You may opt enabling
|
||||
// some of them in the Styles drop-down list, removing them from the toolbar.
|
||||
// (This requires the "stylescombo" plugin.)
|
||||
/*
|
||||
{ name: 'Strong', element: 'strong', overrides: 'b' },
|
||||
{ name: 'Emphasis', element: 'em' , overrides: 'i' },
|
||||
{ name: 'Underline', element: 'u' },
|
||||
{ name: 'Strikethrough', element: 'strike' },
|
||||
{ name: 'Subscript', element: 'sub' },
|
||||
{ name: 'Superscript', element: 'sup' },
|
||||
*/
|
||||
|
||||
{ name: 'Marker', element: 'span', attributes: { 'class': 'marker' } },
|
||||
|
||||
{ name: 'Big', element: 'big' },
|
||||
{ name: 'Small', element: 'small' },
|
||||
{ name: 'Typewriter', element: 'tt' },
|
||||
|
||||
{ name: 'Computer Code', element: 'code' },
|
||||
{ name: 'Keyboard Phrase', element: 'kbd' },
|
||||
{ name: 'Sample Text', element: 'samp' },
|
||||
{ name: 'Variable', element: 'var' },
|
||||
|
||||
{ name: 'Deleted Text', element: 'del' },
|
||||
{ name: 'Inserted Text', element: 'ins' },
|
||||
|
||||
{ name: 'Cited Work', element: 'cite' },
|
||||
{ name: 'Inline Quotation', element: 'q' },
|
||||
|
||||
{ name: 'Language: RTL', element: 'span', attributes: { 'dir': 'rtl' } },
|
||||
{ name: 'Language: LTR', element: 'span', attributes: { 'dir': 'ltr' } },
|
||||
|
||||
/* Object styles */
|
||||
|
||||
{
|
||||
name: 'Styled Image (left)',
|
||||
element: 'img',
|
||||
attributes: { 'class': 'left' }
|
||||
},
|
||||
|
||||
{
|
||||
name: 'Styled Image (right)',
|
||||
element: 'img',
|
||||
attributes: { 'class': 'right' }
|
||||
},
|
||||
|
||||
{
|
||||
name: 'Compact Table',
|
||||
element: 'table',
|
||||
attributes: {
|
||||
cellpadding: '5',
|
||||
cellspacing: '0',
|
||||
border: '1',
|
||||
bordercolor: '#ccc'
|
||||
},
|
||||
styles: {
|
||||
'border-collapse': 'collapse'
|
||||
}
|
||||
},
|
||||
|
||||
{ name: 'Borderless Table', element: 'table', styles: { 'border-style': 'hidden', 'background-color': '#E6E6FA' } },
|
||||
{ name: 'Square Bulleted List', element: 'ul', styles: { 'list-style-type': 'square' } },
|
||||
|
||||
/* Widget styles */
|
||||
|
||||
{ name: 'Clean Image', type: 'widget', widget: 'image', attributes: { 'class': 'image-clean' } },
|
||||
{ name: 'Grayscale Image', type: 'widget', widget: 'image', attributes: { 'class': 'image-grayscale' } },
|
||||
|
||||
{ name: 'Featured Snippet', type: 'widget', widget: 'codeSnippet', attributes: { 'class': 'code-featured' } },
|
||||
|
||||
{ name: 'Featured Formula', type: 'widget', widget: 'mathjax', attributes: { 'class': 'math-featured' } },
|
||||
|
||||
{ name: '240p', type: 'widget', widget: 'embedSemantic', attributes: { 'class': 'embed-240p' }, group: 'size' },
|
||||
{ name: '360p', type: 'widget', widget: 'embedSemantic', attributes: { 'class': 'embed-360p' }, group: 'size' },
|
||||
{ name: '480p', type: 'widget', widget: 'embedSemantic', attributes: { 'class': 'embed-480p' }, group: 'size' },
|
||||
{ name: '720p', type: 'widget', widget: 'embedSemantic', attributes: { 'class': 'embed-720p' }, group: 'size' },
|
||||
{ name: '1080p', type: 'widget', widget: 'embedSemantic', attributes: { 'class': 'embed-1080p' }, group: 'size' },
|
||||
|
||||
// Adding space after the style name is an intended workaround. For now, there
|
||||
// is no option to create two styles with the same name for different widget types. See https://dev.ckeditor.com/ticket/16664.
|
||||
{ name: '240p ', type: 'widget', widget: 'embed', attributes: { 'class': 'embed-240p' }, group: 'size' },
|
||||
{ name: '360p ', type: 'widget', widget: 'embed', attributes: { 'class': 'embed-360p' }, group: 'size' },
|
||||
{ name: '480p ', type: 'widget', widget: 'embed', attributes: { 'class': 'embed-480p' }, group: 'size' },
|
||||
{ name: '720p ', type: 'widget', widget: 'embed', attributes: { 'class': 'embed-720p' }, group: 'size' },
|
||||
{ name: '1080p ', type: 'widget', widget: 'embed', attributes: { 'class': 'embed-1080p' }, group: 'size' }
|
||||
|
||||
] );
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
4.92
|
||||
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
/*-----------------------------------------------------------------------------
|
||||
- This file contains proprietary and confidential information from WebAssist.com
|
||||
- corporation. Any unauthorized reuse, reproduction, or modification without
|
||||
- the prior written consent of WebAssist.com is strictly prohibited.
|
||||
-
|
||||
- Copyright 2005-2007 WebAssist.com Corporation. All rights reserved.
|
||||
------------------------------------------------------------------------------*/
|
||||
$WA_AB_Split = "|§|";
|
||||
|
||||
// Application Builder functions
|
||||
function WA_AB_getLoopedFieldName($tName, $loopInde) {
|
||||
if (!strlen($tName)) {
|
||||
return $tName;
|
||||
}
|
||||
if (strlen($tName) == 1 || substr($tName, strlen($tName)-1) != "_") {
|
||||
$tName = $tName . "_";
|
||||
}
|
||||
return $tName . $loopInde;
|
||||
}
|
||||
|
||||
function WA_AB_getLoopedFieldValue($loopedFieldName, $counterVal) {
|
||||
$loopedFieldName = WA_AB_getLoopedFieldName($loopedFieldName, $counterVal);
|
||||
if ($loopedFieldName != "" && (isset($_POST[$loopedFieldName]) || isset($_GET[$loopedFieldName]))) {
|
||||
if (isset($_POST[$loopedFieldName])) {
|
||||
return $_POST[$loopedFieldName];
|
||||
}
|
||||
return $_GET[$loopedFieldName];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
function WA_AB_checkLoopedFieldsExist($loopedFields, $counterVal) {
|
||||
for ($n=0; $n<sizeof($loopedFields); $n++) {
|
||||
$loopedFieldName = WA_AB_getLoopedFieldName($loopedFields[$n], $counterVal);
|
||||
if ($loopedFieldName != "" && (isset($_POST[$loopedFieldName]) || isset($_GET[$loopedFieldName]))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function WA_AB_checkMultiInsertLoopedFieldsExist($loopedFields, $counterVal) {
|
||||
for ($n=0; $n<sizeof($loopedFields); $n++) {
|
||||
$loopedFieldName = WA_AB_getLoopedFieldName($loopedFields[$n] . "_wamultihidden", $counterVal);
|
||||
if ($loopedFieldName != "" && (isset($_POST[$loopedFieldName]) || isset($_GET[$loopedFieldName]))) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function WA_AB_checkLoopedFieldsNotBlank($loopedFields, $counterVal) {
|
||||
if (!WA_AB_checkLoopedFieldsExist($loopedFields, $counterVal)) {
|
||||
return false;
|
||||
}
|
||||
for ($n=0; $n<sizeof($loopedFields); $n++) {
|
||||
if (WA_AB_getLoopedFieldValue($loopedFields[$n], $counterVal) != "") {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function WA_AB_returnPreSelectValue($PreSelectArray, $optionValue) {
|
||||
for ($n=0; $n<sizeof($PreSelectArray); $n++) {
|
||||
if ($PreSelectArray[$n] == $optionValue) {
|
||||
return $optionValue;
|
||||
}
|
||||
}
|
||||
return $optionValue . "DONOTSELECT";
|
||||
}
|
||||
|
||||
function WA_AB_doManageRelationalTable($WA_valuesList, $WA_appliedString, $WA_appliedList, $WA_connection, $WA_table, $WA_masterKeyField, $WA_masterKeyType, $WA_masterKeyValue, $WA_masterKeyComp, $WA_joinedKeyField, $WA_joinedKeyType, $WA_joinedKeyComp, $WA_fieldNamesStr, $WA_columnTypesStr) {
|
||||
global $WA_AB_Split;
|
||||
$WA_fieldNames = explode("|", $WA_fieldNamesStr);
|
||||
$WA_columns = explode("|", $WA_columnTypesStr);
|
||||
$WA_formerString = "";
|
||||
$WA_formerList = array();
|
||||
$WA_insertIDs = "";
|
||||
$WhereObj = WA_AB_generateWhereClause(array($WA_masterKeyField), array($WA_masterKeyType), array($WA_masterKeyValue), array($WA_masterKeyComp));
|
||||
$WA_Sql = "SELECT ".$WA_masterKeyField.", ".$WA_joinedKeyField." FROM ".$WA_table." WHERE ".$WhereObj->sqlWhereClause." ORDER BY ".$WA_joinedKeyField;
|
||||
$WA_mrtJoinRS = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
|
||||
if (mysql_num_rows($WA_mrtJoinRS) > 0) {
|
||||
while ($row_WA_mrtJoinRS = mysql_fetch_assoc($WA_mrtJoinRS)) {
|
||||
$WA_formerString .= "^" . $row_WA_mrtJoinRS[$WA_joinedKeyField] . "^";
|
||||
$WA_formerList[] = $row_WA_mrtJoinRS[$WA_joinedKeyField];
|
||||
}
|
||||
}
|
||||
for ($n=0; $n<sizeof($WA_formerList); $n++) {
|
||||
if (strpos($WA_appliedString, "^" . $WA_formerList[$n] . "^") === false) {
|
||||
$deleteParamsObj = WA_AB_generateWhereClause(array($WA_masterKeyField, $WA_joinedKeyField), array($WA_masterKeyType, $WA_joinedKeyType), array($WA_masterKeyValue, $WA_formerList[$n]), array($WA_masterKeyComp, $WA_joinedKeyComp));
|
||||
$WA_Sql = "DELETE FROM `" . $WA_table . "` WHERE " . $deleteParamsObj->sqlWhereClause;
|
||||
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
|
||||
}
|
||||
}
|
||||
for ($n=0; $n<sizeof($WA_appliedList); $n++) {
|
||||
if (strpos($WA_formerString, "^" . $WA_appliedList[$n] . "^") === false) {
|
||||
$WA_insertIDs .= "^" . $WA_appliedList[$n] . "^";
|
||||
}
|
||||
}
|
||||
for ($n=0; $n<sizeof($WA_valuesList); $n++) {
|
||||
$WA_fieldValues = explode($WA_AB_Split, str_replace("^MASTERID^", $WA_masterKeyValue, str_replace("^JOINID^", $WA_valuesList[$n][0], $WA_valuesList[$n][1])));
|
||||
if (strpos($WA_insertIDs, "^" . $WA_valuesList[$n][0] . "^") === false) {
|
||||
if (str_replace("^MASTERID^", "", str_replace("^JOINID^", "", $WA_valuesList[$n][1])) != $WA_AB_Split) {
|
||||
$updateParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
|
||||
$WhereObj = WA_AB_generateWhereClause(array($WA_masterKeyField, $WA_joinedKeyField), array($WA_masterKeyType, $WA_joinedKeyType), array($WA_masterKeyValue, $WA_valuesList[$n][0]), array($WA_masterKeyComp, $WA_joinedKeyComp));
|
||||
$WA_Sql = "UPDATE `" . $WA_table . "` SET " . $updateParamsObj->WA_setValues . " WHERE " . $WhereObj->sqlWhereClause . "";
|
||||
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
|
||||
}
|
||||
}
|
||||
else {
|
||||
$insertParamsObj = WA_AB_generateInsertParams($WA_fieldNames, $WA_columns, $WA_fieldValues, -1);
|
||||
$WA_Sql = "INSERT INTO `" . $WA_table . "` (" . $insertParamsObj->WA_tableValues . ") VALUES (" . $insertParamsObj->WA_dbValues . ")";
|
||||
$MM_editCmd = mysql_query($WA_Sql, $WA_connection) or die(mysql_error());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class WA_AB_InsertParams {
|
||||
var $WA_tableValues;
|
||||
var $WA_dbValues;
|
||||
var $WA_setValues;
|
||||
function WA_AB_InsertParams($WA_tableValues = "", $WA_dbValues = "", $WA_setValues = "") {
|
||||
$this->WA_tableValues = $WA_tableValues;
|
||||
$this->WA_dbValues = $WA_dbValues;
|
||||
$this->WA_setValues = $WA_setValues;
|
||||
}
|
||||
}
|
||||
function WA_AB_generateInsertParams($fieldNameList, $columnTypeList, $fieldValueList, $ignoreIndex) {
|
||||
$obj = new WA_AB_InsertParams();
|
||||
for ($i=0; $i < sizeof($fieldNameList); $i++) {
|
||||
if ($i !== $ignoreIndex) {
|
||||
$formVal = $fieldValueList[$i];
|
||||
$WA_typesArray = explode(",", $columnTypeList[$i]);
|
||||
$delim = ($WA_typesArray[0] != "none") ? $WA_typesArray[0] : "";
|
||||
$altVal = ($WA_typesArray[1] != "none") ? $WA_typesArray[1] : "";
|
||||
$emptyVal = ($WA_typesArray[2] != "none") ? $WA_typesArray[2] : "";
|
||||
if ($formVal == "" || $formVal == "undefined") {
|
||||
$formVal = $emptyVal;
|
||||
} else {
|
||||
if ($altVal != "") {
|
||||
$formVal = $altVal;
|
||||
} else if ($delim == "'") { // escape quotes
|
||||
$formVal = "'".((!(preg_match("/(^|[^\\\\])'/", $formVal))) ? $formVal : addslashes($formVal))."'";
|
||||
} else if ($delim == "") {
|
||||
//numeric
|
||||
if (is_numeric($formVal)) {
|
||||
$formVal = "".floatval($formVal);
|
||||
}
|
||||
else {
|
||||
$formVal = "0";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$formVal = $delim.WA_AB_clearOutSQLKeywords($formVal).$delim;
|
||||
}
|
||||
}
|
||||
$obj->WA_tableValues .= (($obj->WA_tableValues != "") ? "," : "") . "`" . WA_AB_cleanUpColumnName($fieldNameList[$i]) . "`";
|
||||
$obj->WA_dbValues .= (($obj->WA_dbValues != "") ? "," : "") . $formVal;
|
||||
$obj->WA_setValues .= (($obj->WA_setValues != "") ? ", " : "") . "`" . WA_AB_cleanUpColumnName($fieldNameList[$i]) ."`" . " = " . $formVal;
|
||||
}
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
class WA_AB_WhereClause {
|
||||
var $sqlWhereClause;
|
||||
function WA_AB_WhereClause($sqlWhereClause = "") {
|
||||
$this->WA_AB_WhereClause = $sqlWhereClause;
|
||||
}
|
||||
}
|
||||
function WA_AB_generateWhereClause($fieldNameList, $columnTypeList, $fieldValueList, $comparisonList)
|
||||
{
|
||||
$obj = new WA_AB_WhereClause();
|
||||
for ($i = 0; $i < sizeof($fieldNameList); $i++) {
|
||||
$formVal = $fieldValueList[$i];
|
||||
$WA_typesArray = explode(",", $columnTypeList[$i]);
|
||||
$delim = ($WA_typesArray[0] != "none") ? $WA_typesArray[0] : "";
|
||||
$altVal = ($WA_typesArray[1] != "none") ? $WA_typesArray[1] : "";
|
||||
$emptyVal = ($WA_typesArray[2] != "none") ? $WA_typesArray[2] : "";
|
||||
if ($formVal == "" || $formVal == "undefined") {
|
||||
$formVal = $emptyVal;
|
||||
} else {
|
||||
if ($altVal != "") {
|
||||
$formVal = $altVal;
|
||||
} else if ($delim == "'") { // escape quotes
|
||||
$formVal = "'".((!(preg_match("/(^|[^\\\\])'/", $formVal))) ? $formVal : addslashes($formVal));
|
||||
if ($comparisonList[$i] == " LIKE ") $formVal .= "%";;
|
||||
$formVal .= "'";
|
||||
} else if ($delim == "") {
|
||||
//numeric
|
||||
if (is_numeric($formVal)) {
|
||||
$formVal = "".floatval($formVal);
|
||||
}
|
||||
else {
|
||||
$formVal = "0";
|
||||
}
|
||||
} else {
|
||||
$formVal = $delim.WA_AB_clearOutSQLKeywords($formVal).$delim;
|
||||
}
|
||||
}
|
||||
if (!($delim == "" && strpos($formVal,"()")>0)) {
|
||||
if ($formVal == "NULL") {
|
||||
$obj->sqlWhereClause .= (($i != 0) ? " AND " : "")."`". WA_AB_cleanUpColumnName($fieldNameList[$i])."`"." IS ".$formVal;
|
||||
}
|
||||
else {
|
||||
$obj->sqlWhereClause .= (($i != 0) ? " AND " : "")."`". WA_AB_cleanUpColumnName($fieldNameList[$i])."`".WA_AB_cleanUpEquality($comparisonList[$i]).$formVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
function WA_AB_cleanUpColumnName($colName) {
|
||||
if (strpos($colName, ";") !== false) {
|
||||
$colName = substr($colName, 0, strpos($colName, ";"));
|
||||
}
|
||||
if (strpos($colName, "(") !== false) {
|
||||
$colName = substr($colName, 0, strpos($colName, "("));
|
||||
}
|
||||
if (strpos($colName, "=") !== false) {
|
||||
$colName = substr($colName, 0, strpos($colName, "="));
|
||||
}
|
||||
return $colName;
|
||||
}
|
||||
|
||||
function WA_AB_cleanUpEquality($tEquality) {
|
||||
if (preg_replace('/^\\s*|\\s*$/', "", $tEquality) != "=") {
|
||||
return WA_AB_cleanUpColumnName($tEquality);
|
||||
}
|
||||
return $tEquality;
|
||||
}
|
||||
|
||||
function WA_AB_clearOutSQLKeywords($tString) {
|
||||
if (strpos(strtolower($tString), "select") !== false) {
|
||||
return "";
|
||||
}
|
||||
if (strpos(strtolower($tString), "drop") !== false) {
|
||||
return "";
|
||||
}
|
||||
if (strpos(strtolower($tString), "alter") !== false) {
|
||||
return "";
|
||||
}
|
||||
if (strpos(strtolower($tString), "create") !== false) {
|
||||
return "";
|
||||
}
|
||||
if (strpos(strtolower($tString), "update") !== false) {
|
||||
return "";
|
||||
}
|
||||
if (strpos(strtolower($tString), "insert") !== false) {
|
||||
return "";
|
||||
}
|
||||
if (strpos(strtolower($tString), "delete") !== false) {
|
||||
return "";
|
||||
}
|
||||
if (strpos(strtolower($tString), "'") !== false) {
|
||||
return "";
|
||||
}
|
||||
if (strpos(strtolower($tString), "#") !== false) {
|
||||
return "";
|
||||
}
|
||||
return $tString;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,909 @@
|
||||
<?php
|
||||
// version 2.02
|
||||
/*
|
||||
-----------------------------------------------------------------------------
|
||||
- File Name:
|
||||
- WAFV_Scripts_PHP.php
|
||||
-
|
||||
- Description:
|
||||
- Shared functions for WA Form Validations - Server Side PHP
|
||||
-
|
||||
- This file contains proprietary and confidential information from WebAssist.com
|
||||
- corporation. Any unauthorized reuse, reproduction, or modification without
|
||||
- the prior written consent of WebAssist.com is strictly prohibited.
|
||||
-
|
||||
- Copyright 2004 WebAssist.com Corporation. All rights reserved.
|
||||
-----------------------------------------------------------------------------
|
||||
*/
|
||||
function SaveFormToSession($theErrors, $valPage) {
|
||||
$postVars = "";
|
||||
$formVars = array_keys($_POST);
|
||||
$loopInde = 0;
|
||||
foreach ($formVars as $theKey) {
|
||||
if (is_array($_POST[$theKey])) {
|
||||
$toAdd = "";
|
||||
for ($x=0; $x < count($_POST[$theKey]); $x++) {
|
||||
if ($x != 0) {
|
||||
$toAdd .= "&";
|
||||
}
|
||||
if(get_magic_quotes_gpc()){
|
||||
$toAdd .= "WAVT_".($theKey)."[".$x."]=".( stripslashes( $_POST[$theKey][$x]) );
|
||||
}
|
||||
else{
|
||||
$toAdd .= "WAVT_".($theKey)."[".$x."]=".($_POST[$theKey][$x]);
|
||||
}
|
||||
}
|
||||
}
|
||||
else{
|
||||
if(get_magic_quotes_gpc()){
|
||||
$toAdd = "WAVT_".($theKey)."=".( stripslashes( $_POST[$theKey] ) );
|
||||
}
|
||||
else{
|
||||
$toAdd = "WAVT_".($theKey)."=".($_POST[$theKey]);
|
||||
}
|
||||
}
|
||||
if ($loopInde != 0) {
|
||||
$postVars .= "&";
|
||||
}
|
||||
$postVars .= $toAdd;
|
||||
$loopInde++;
|
||||
}
|
||||
$postVars .= "&WAVT_".$valPage."_Errors=".substr($theErrors,1);
|
||||
$_SESSION['WAVT_'.$valPage."_Errors"] = $postVars;
|
||||
}
|
||||
|
||||
function PostResult($thePage, $theErrors, $valPage, $appendParams = true) {
|
||||
$thePostURL = "";
|
||||
SaveFormToSession($theErrors, $valPage);
|
||||
if (isset($_GET["plugin_file"])) return;
|
||||
$thePostURL .= $thePage;
|
||||
$urlParams = "";
|
||||
$schema = $_SERVER['SERVER_PORT'] == '443' ? 'https' : 'http';
|
||||
$host = strlen($_SERVER['HTTP_HOST'])?$_SERVER['HTTP_HOST']:$_SERVER['SERVER_NAME'];
|
||||
|
||||
if (strpos($thePostURL,"://") === false) {
|
||||
if (strpos($thePage,"/") !== 0) {
|
||||
$thePostURL = substr($_SERVER["REQUEST_URI"],0,strrpos($_SERVER["REQUEST_URI"],"/")+1) . $thePostURL;
|
||||
}
|
||||
if (strpos($thePostURL,"?") !== false) {
|
||||
$urlParams = substr($thePostURL,strpos($thePostURL,"?"));
|
||||
$thePostURL = substr($thePostURL,0,strpos($thePostURL,"?"));
|
||||
}
|
||||
$thePostURL = $schema."://".str_replace("%2F","/",$host.rawurlencode($thePostURL)).$urlParams;
|
||||
}
|
||||
while (!(strpos($thePostURL,"/../") === false)) {
|
||||
$thePostURL = substr($thePostURL, 0, strrpos(substr($thePostURL,0,strpos($thePostURL,"/../")),"/")+1).substr($thePostURL,strpos($thePostURL,"/../")+4);
|
||||
}
|
||||
|
||||
if (strpos($thePage,"#") === false && $appendParams && isset($_SERVER['QUERY_STRING']) && ($_SERVER['QUERY_STRING'] != '')) {
|
||||
if (strpos($thePostURL,"?") !== false) {
|
||||
$thePostURL.= "&" . ($_SERVER['QUERY_STRING']);
|
||||
} else {
|
||||
$thePostURL.= "?" . ($_SERVER['QUERY_STRING']);
|
||||
}
|
||||
}
|
||||
$thePostURL = str_replace("%23","#",$thePostURL);
|
||||
header("Location: ". $thePostURL);
|
||||
exit;
|
||||
}
|
||||
|
||||
function WAtrimIt($theString,$leaveLeft,$leaveRight) {
|
||||
if (!isset($leaveLeft) || $leaveLeft == 0) {
|
||||
$theString = ltrim($theString);
|
||||
}
|
||||
if (!isset($leaveRight) || $leaveRight == 0) {
|
||||
$theString = rtrim($theString);
|
||||
}
|
||||
return $theString;
|
||||
}
|
||||
|
||||
function WAValidateAN($value,$allowUpper,$allowLower,$allowNumbers,$allowSpace,$extraChars,$required,$number) {
|
||||
$WAFV_ErrorMessage = "";
|
||||
$isValid = true;
|
||||
for ($x=0; $x < strlen($value); $x++) {
|
||||
$charGood = false;
|
||||
$nextChar = substr($value,$x,1);
|
||||
$charCode = ord(substr($value,$x,1));
|
||||
if ($allowLower) {
|
||||
if ($charCode >= 97 && $charCode <= 122) {
|
||||
$charGood = true;
|
||||
}
|
||||
}
|
||||
if ($allowUpper) {
|
||||
if ($charCode >= 65 && $charCode <= 90) {
|
||||
$charGood = true;
|
||||
}
|
||||
}
|
||||
if ($allowNumbers) {
|
||||
if ($charCode >= 48 && $charCode <= 57) {
|
||||
$charGood = true;
|
||||
}
|
||||
}
|
||||
if ($allowSpace) {
|
||||
if ($nextChar == " ") {
|
||||
$charGood = true;
|
||||
}
|
||||
}
|
||||
if ($extraChars != "") {
|
||||
if (strpos(str_replace(""",'"',$extraChars),$nextChar) !== false) {
|
||||
$charGood = true;
|
||||
}
|
||||
}
|
||||
if (!$charGood) {
|
||||
$isValid = false;
|
||||
$x = strlen($value);
|
||||
}
|
||||
}
|
||||
if ($required && $value == "") $isValid = false;
|
||||
if (!$isValid) {
|
||||
$WAFV_ErrorMessage .= ",".$number;
|
||||
}
|
||||
return $WAFV_ErrorMessage;
|
||||
}
|
||||
|
||||
function WAValidateCC($value,$allow,$required,$number) {
|
||||
$WAFV_ErrorMessage = "";
|
||||
$isValid = true;
|
||||
$accepted = "\r\n\t.- ";
|
||||
if (!(!$required && $value == "")) {
|
||||
$stripVal = "";
|
||||
for ($x=0; $x < strlen($value); $x++) {
|
||||
$charGood = false;
|
||||
$nextChar = substr($value,$x,1);
|
||||
$charCode = ord($nextChar);
|
||||
if ($charCode >= 48 AND $charCode <= 57) {
|
||||
$stripVal .= $nextChar;
|
||||
} else {
|
||||
if (strpos($accepted,$nextChar)==0) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strlen($stripVal) < 13)
|
||||
$isValid = false;
|
||||
if ($isValid) {
|
||||
if ($allow != "") {
|
||||
$isValid = false;
|
||||
$allow = explode(":",$allow);
|
||||
foreach ($allow as $aStr) {
|
||||
if ($aStr != "" && strpos($stripVal, $aStr) === 0) {
|
||||
$isValid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($isValid) {
|
||||
$isValid = WA_isCreditCard($stripVal);
|
||||
}
|
||||
}
|
||||
if (!$isValid) {
|
||||
$WAFV_ErrorMessage .= ",".$number;
|
||||
}
|
||||
return $WAFV_ErrorMessage;
|
||||
}
|
||||
|
||||
function WA_isCreditCard($st) {
|
||||
if ($st == 0)
|
||||
return (false);
|
||||
if (strlen($st) > 19)
|
||||
return (false);
|
||||
$sum = 0; $mul = 1; $l = strlen($st);
|
||||
for ($i = 0; $i < $l; $i++) {
|
||||
$digit = substr($st, $l-$i-1, 1);
|
||||
$tproduct = $digit*$mul;
|
||||
if ($tproduct >= 10)
|
||||
$sum += ($tproduct % 10) + 1;
|
||||
else
|
||||
$sum += $tproduct;
|
||||
if ($mul == 1)
|
||||
$mul++;
|
||||
else
|
||||
$mul--;
|
||||
}
|
||||
if (($sum % 10) == 0)
|
||||
return (true);
|
||||
else
|
||||
return (false);
|
||||
}
|
||||
|
||||
function WAValidateDT($value,$doDate,$dateFormatStr,$dateMin,$dateMax,$doTime,$timeFormatStr,$timeMin,$timeMax,$required,$number) {
|
||||
$WAFV_ErrorMessage = "";
|
||||
$isValid = true;
|
||||
$Now = getdate();
|
||||
$Today = mktime(0, 0, 0, date("n"), date("j"), date("Y"));
|
||||
if (!(!$required && $value=="")) {
|
||||
if ($value=="") {
|
||||
$isValid = false;
|
||||
}
|
||||
if ($doDate) {
|
||||
if ($dateFormatStr != "") {
|
||||
if (preg_match("/".$dateFormatStr."/i", $value)==0) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
if ($isValid) {
|
||||
$dateVar = WAGetDateFormat($value, $dateFormatStr);
|
||||
if (strtotime($dateVar) === 0 || $dateVar == -1 || is_numeric($value) || ((strpos($value, "/") == strrpos($value, "/") && strpos($value, "/") != false)) || ((strpos($value, "-") == strrpos($value, "-") && strpos($value, "-") != false)))
|
||||
$isValid = false;
|
||||
if ($dateMin != "") {
|
||||
$compareDay = WAGetDateFormat($dateMin, $dateFormatStr);
|
||||
if ($compareDay == -1) {
|
||||
eval("\$compareDay = ".str_replace(""",'"',$dateMin));
|
||||
}
|
||||
if ($dateVar < $compareDay)
|
||||
$isValid = false;
|
||||
}
|
||||
if ($dateMax != "") {
|
||||
$compareDay = WAGetDateFormat($dateMax, $dateFormatStr);
|
||||
if ($compareDay == -1) {
|
||||
eval("\$compareDay = ".str_replace(""",'"',$dateMax));
|
||||
}
|
||||
if ($dateVar > $compareDay)
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($doTime) {
|
||||
$isValid = WAValidateTheTime($doTime, $timeFormatStr, $value, $isValid, $timeMin, $timeMax);
|
||||
}
|
||||
}
|
||||
if (!$isValid) {
|
||||
$WAFV_ErrorMessage .= ",".$number;
|
||||
}
|
||||
return $WAFV_ErrorMessage;
|
||||
}
|
||||
|
||||
function WAValidateTheTime($doTime, $timeFormatStr, $value, $isValid, $timeMin, $timeMax) {
|
||||
if ($doTime) {
|
||||
if ($timeFormatStr != "") {
|
||||
if (preg_match("/".$timeFormatStr."/i", $value)==0) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
if (strpos($value, ":")===false) {
|
||||
$isValid = false;
|
||||
}
|
||||
if ($isValid) {
|
||||
$dateVar = strtotime($value);
|
||||
$fullYear = date("Y", $dateVar);
|
||||
if ($dateVar == -1)
|
||||
$dateVar = strtotime("1/1/1 ".$value);
|
||||
if ($dateVar == -1)
|
||||
$isValid = false;
|
||||
if ($timeMin != "") {
|
||||
$Today = strtotime("1/1/1 ".$timeMin);
|
||||
if (!$Today == -1) {
|
||||
$Today = eval(str_replace(""",'"',$timeMin));
|
||||
}
|
||||
$enterTime = (date("H", $dateVar)*360) + (date("i", $dateVar)*60) + date("s", $dateVar);
|
||||
$minTime = (date("H", $Today)*360) + (date("i", $Today)*60) + date("s", $Today);
|
||||
if ($enterTime < $minTime)
|
||||
$isValid = false;
|
||||
}
|
||||
if ($timeMax != "") {
|
||||
$Today = strtotime("1/1/1 ".$timeMax);
|
||||
if ($Today == -1) {
|
||||
$Today = eval(str_replace(""",'"',$timeMax));
|
||||
}
|
||||
$enterTime = ($dateVar["hours"]*360) + ($dateVar["minutes"]*60) + $dateVar["seconds"];
|
||||
$minTime = ($Today["hours"]*360) + ($Today["minutes"]*60) + $Today["seconds"];
|
||||
if ($enterTime > $minTime)
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $isValid;
|
||||
}
|
||||
|
||||
|
||||
function WAGetDateFormat($value, $dateFormat) {
|
||||
$isUSServ = (date("n", strtotime("1/2/2006")) == 1);
|
||||
$tValue = $value;
|
||||
$isEuroDate = (($dateFormat && strpos($dateFormat, "[12]\\d|3[0-1]") < strpos($dateFormat, "1[0-2]|") && strpos($dateFormat, "\\w*") === false) || (!$isUSServ));
|
||||
if (($isEuroDate && $isUSServ) || (!$isEuroDate && !$isUSServ)) {
|
||||
$datePattn = "/(\\d*)[-\\.\\/](\\d*)[-\\.\\/](\d*)/";
|
||||
preg_match($datePattn, $tValue, $tMatch);
|
||||
if ($tMatch && sizeof($tMatch)) {
|
||||
if ($isEuroDate) {
|
||||
$value = $tMatch[2] . "/" . $tMatch[1] . "/" . $tMatch[3];
|
||||
}
|
||||
else {
|
||||
$value = $tMatch[1] . "/" . $tMatch[2] . "/" . $tMatch[3];
|
||||
}
|
||||
if (strpos($tValue, " ") !== false) {
|
||||
$value .= substr($tValue, strpos($tValue, " "));
|
||||
}
|
||||
}
|
||||
}
|
||||
return strtotime(preg_replace("/[\.-]/", "/", $value));
|
||||
}
|
||||
|
||||
|
||||
function WAValidateEM($value,$required,$number) {
|
||||
$WAFV_ErrorMessage = "";
|
||||
$isValid = true;
|
||||
if (!(!$required && $value == "")) {
|
||||
$knownDomsPat = "/^(com|net|org|edu|int|mil|gov|arpa|biz|aero|name|coop|info|pro|museum|cat|\w{2,2})$/";
|
||||
$emailPat = "/^(.+)@(.+)$/";
|
||||
$accepted = "[^\s\(\)><@,;:\\\"\.\[\]]+";
|
||||
$quotedUser = "(\"[^\"]*\")";
|
||||
$ipDomainPat = "/^\[(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})\]$/";
|
||||
$section = "(".$accepted."|".$quotedUser.")";
|
||||
$userPat = "/^".$section."(\\.".$section.")*$/";
|
||||
$domainPat = "/^".$accepted."(\\.".$accepted.")*$/";
|
||||
$theMatch = preg_match($emailPat,$value,$MatchVal);
|
||||
$acceptedPat = "/^" . $accepted . "$/";
|
||||
$userName = "";
|
||||
$domainName = "";
|
||||
if (!$theMatch) {
|
||||
$isValid = false;
|
||||
}
|
||||
else {
|
||||
$userName = $MatchVal[1];
|
||||
$domainName = $MatchVal[2];
|
||||
$domArr = explode(".",$domainName);
|
||||
$IPArray = preg_match($ipDomainPat,$domainName,$ipMatch);
|
||||
for ($x=0; $x < strlen($userName); $x++) {
|
||||
if ((ord(substr($userName,$x,1)) > 127 && ord(substr($userName,$x,1)) < 192) || ord(substr($userName,$x,1)) > 255) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
for ($x=0; $x < strlen($domainName); $x++) {
|
||||
if ((ord(substr($domainName,$x,1)) > 127 && ord(substr($domainName,$x,1)) < 192) || ord(substr($domainName,$x,1)) > 255) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
if (!preg_match($userPat,$userName)) {
|
||||
$isValid = false;
|
||||
}
|
||||
if ($IPArray) {
|
||||
for ($x=1; $x <= 4; $x++) {
|
||||
if ($IPArray[x] > 255) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
for ($x=0; $x<sizeof($domArr); $x++) {
|
||||
if (!preg_match($acceptedPat,$domArr[$x]) || strlen($domArr[$x]) == 0 || (strlen($domArr[$x]) < 2 && $x >= (sizeof($domArr)-2) && $x > 0)) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
if (count($domArr) < 2) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$isValid) {
|
||||
$WAFV_ErrorMessage .= ",".$number;
|
||||
}
|
||||
return $WAFV_ErrorMessage;
|
||||
}
|
||||
|
||||
function WAValidateEL($value,$minLength,$maxLength,$required,$number) {
|
||||
$WAFV_ErrorMessage = "";
|
||||
$isValid = true;
|
||||
if ($required && $value == "") $isValid = false;
|
||||
if (!(!$required && $value == "")) {
|
||||
if ((strlen($value) < $minLength) || (strlen($value) > $maxLength && $maxLength > 0)) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
if (!$isValid) {
|
||||
$WAFV_ErrorMessage .= ",".$number;
|
||||
}
|
||||
return $WAFV_ErrorMessage;
|
||||
}
|
||||
|
||||
function WAValidateFE($value,$extensions,$required,$number) {
|
||||
$WAFV_ErrorMessage = "";
|
||||
$isValid = true;
|
||||
$extensions = str_replace(", ",",",$extensions);
|
||||
$ExtensionArr = explode(",",$extensions);
|
||||
if (!(!$required && $value == "")) {
|
||||
$isValid = false;
|
||||
if (strrpos($value,".") > 0) {
|
||||
$value = substr($value, strrpos($value,"."));
|
||||
foreach ($ExtensionArr as $extension) {
|
||||
$extension = str_replace(" ","",$extension);
|
||||
if (strtolower($value) == strtolower($extension)) {
|
||||
$isValid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$isValid) {
|
||||
$WAFV_ErrorMessage .= ",".$number;
|
||||
}
|
||||
return $WAFV_ErrorMessage;
|
||||
}
|
||||
|
||||
function WAValidateLE($value1,$value2,$required,$number) {
|
||||
$WAFV_ErrorMessage = "";
|
||||
$isValid = true;
|
||||
if ($value1 != $value2 || ($required && $value1 == "")) {
|
||||
$isValid = false;
|
||||
}
|
||||
if (!$isValid) {
|
||||
$WAFV_ErrorMessage .= ",".$number;
|
||||
}
|
||||
return $WAFV_ErrorMessage;
|
||||
}
|
||||
|
||||
function WAValidateNM($value,$minLength,$maxLength,$allowDecimals,$punctuationMarks,$required,$number) {
|
||||
$WAFV_ErrorMessage = "";
|
||||
$isValid = true;
|
||||
$theCheck = (11/10);
|
||||
$trueDecimal = substr($theCheck,1,1);
|
||||
if (!$punctuationMarks) {
|
||||
if ($trueDecimal == ".") {
|
||||
$punctuationMarks =",.";
|
||||
} else {
|
||||
$punctuationMarks =".,";
|
||||
}
|
||||
}
|
||||
$theThousand = substr($punctuationMarks,0,1);
|
||||
$theDecimal = substr($punctuationMarks,1,1);
|
||||
$startVal = $value;
|
||||
$decimalIndex = strlen($value);
|
||||
if (strrpos($punctuationMarks, $trueDecimal)===false && strrpos($value, $trueDecimal) !== false) {
|
||||
$isValid = false;
|
||||
}
|
||||
$tempValue = $value;
|
||||
if ($theDecimal && strpos($value, $theDecimal) !== false) {
|
||||
if (strpos($value, $theDecimal) != strrpos($value, $theDecimal)) {
|
||||
$isValid = false;
|
||||
}
|
||||
else {
|
||||
$decimalIndex = strpos($value, $theDecimal);
|
||||
$tempValue = substr($value, 0, $decimalIndex);
|
||||
}
|
||||
}
|
||||
if ($theThousand && $isValid && strpos($tempValue, $theThousand) !== false) {
|
||||
if (strpos($tempValue, $theThousand) > 3 || strpos($tempValue, $theThousand) == 0) {
|
||||
$isValid = false;
|
||||
}
|
||||
else {
|
||||
$valArr = explode($theThousand,$tempValue);
|
||||
for ($v=1; $v < sizeof($valArr); $v++) {
|
||||
if (strlen($valArr[$v]) != 3) {
|
||||
$isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$tempValue = implode("",$valArr);
|
||||
}
|
||||
}
|
||||
if ($isValid && strpos($value, $theDecimal) !== false) {
|
||||
$tempValue = $tempValue . substr($value, strpos($value, $theDecimal));
|
||||
}
|
||||
$value = $tempValue;
|
||||
if ($isValid && $trueDecimal != $theDecimal && strpos($value, $theDecimal) !== false) {
|
||||
$value = substr($value,0,strpos($value, $theDecimal)) . $trueDecimal . substr($value,strpos($value, $theDecimal)+1);
|
||||
}
|
||||
if ($isValid && !(!$required && $value=="")) {
|
||||
for ($x=0; $x < strlen($value); $x++) {
|
||||
$theDigit = substr($value, $x, 1);
|
||||
if (!is_numeric($theDigit) && $theDigit != " " && $theDigit != "," && $theDigit != "." && $theDigit != "-") {
|
||||
$isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($value == "") {
|
||||
$isValid = false;
|
||||
}
|
||||
if (!is_numeric($value)) {
|
||||
$isValid = false;
|
||||
}
|
||||
else {
|
||||
if (($minLength !== "" && $minLength > $value) || ($maxLength !== "" && $maxLength < $value)) {
|
||||
$isValid = false;
|
||||
} else {
|
||||
if ($allowDecimals !== "") {
|
||||
$decCheck = strpos($startVal,$theDecimal);
|
||||
$decCheck += $allowDecimals;
|
||||
$decCheck += 2;
|
||||
if (strpos($startVal,$theDecimal)!==false && ($decCheck <= strlen($startVal) || $allowDecimals === 0)) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$isValid) {
|
||||
$WAFV_ErrorMessage .= ",".$number;
|
||||
}
|
||||
return $WAFV_ErrorMessage;
|
||||
}
|
||||
|
||||
function WAValidatePN($value,$areaCode,$international,$required,$number) {
|
||||
$WAFV_ErrorMessage = "";
|
||||
$isValid = true;
|
||||
$allowed = "*() -./_+".Chr(10).Chr(8);
|
||||
$newVal = "";
|
||||
if (!(!$required AND $value == "")) {
|
||||
for ($x=0; $x < strlen($value); $x++) {
|
||||
$z = substr($value,$x,1);
|
||||
if (($z >= "0") && ($z <= "9")) {
|
||||
$newVal = $newVal.$z;
|
||||
} else {
|
||||
if (strpos($allowed,$z) === false) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($international) {
|
||||
if (strlen($newVal) < 5) {
|
||||
$isValid = false;
|
||||
}
|
||||
} else {
|
||||
if (strlen($newVal) == 11) {
|
||||
if (substr($newVal,0,1) != "1") {
|
||||
$isValid = false;
|
||||
}
|
||||
} else {
|
||||
if ((strlen($newVal) != 10 && strlen($newVal) != 7) || (strlen($newVal)==7 && $areaCode)) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$isValid) {
|
||||
$WAFV_ErrorMessage .= ",".$number;
|
||||
}
|
||||
return $WAFV_ErrorMessage;
|
||||
}
|
||||
|
||||
function WAValidateRX($value,$regExStr,$required,$number) {
|
||||
$value = $value;
|
||||
$WAFV_ErrorMessage = "";
|
||||
$isValid = true;
|
||||
$regExStr = str_replace(""", '"', $regExStr);
|
||||
if (!(!$required && $value=="")) {
|
||||
$theMatch = preg_match($regExStr, $value);
|
||||
if (!$theMatch) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
if (!$isValid) {
|
||||
$WAFV_ErrorMessage .= ",".$number;
|
||||
}
|
||||
return $WAFV_ErrorMessage;
|
||||
}
|
||||
|
||||
function WAValidateRQ($value,$trimWhite,$number) {
|
||||
$WAFV_ErrorMessage = "";
|
||||
$isValid = true;
|
||||
if ($trimWhite) {
|
||||
$value = WAtrimIt($value,0,0);
|
||||
}
|
||||
if (!isset($value) || $value === "") {
|
||||
$isValid = false;
|
||||
}
|
||||
|
||||
if (!$isValid) {
|
||||
$WAFV_ErrorMessage .= ",".$number;
|
||||
}
|
||||
return $WAFV_ErrorMessage;
|
||||
}
|
||||
|
||||
function WAValidateRT($value,$notAllowed,$required,$number) {
|
||||
$WAFV_ErrorMessage = "";
|
||||
$isValid = true;
|
||||
$augValue = " ".strtolower($value)." ";
|
||||
$tempVal = $augValue;
|
||||
if (!(!$required && $value=="")) {
|
||||
$notAllowed = explode(", ", $notAllowed);
|
||||
foreach ($notAllowed AS $x) {
|
||||
if ($x != "") {
|
||||
$notAllowedInfo = explode("|", $x);
|
||||
$notAllowedInfo[0] = str_replace (""", "\"", $notAllowedInfo[0]);
|
||||
$notAllowedInfo[1] = str_replace (""", "\"", $notAllowedInfo[1]);
|
||||
if (!(strpos($tempVal, strtolower($notAllowedInfo[0]))===false)) {
|
||||
$isValid = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($required && $value=="")
|
||||
$isValid = false;
|
||||
if (!$isValid) {
|
||||
$WAFV_ErrorMessage .= ",".$number;
|
||||
}
|
||||
return $WAFV_ErrorMessage;
|
||||
}
|
||||
|
||||
function WAValidateSS($value,$required,$number) {
|
||||
$WAFV_ErrorMessage = "";
|
||||
$isValid = true;
|
||||
$allowed = "*() -./_\n\r+";
|
||||
if (!(!$required && $value=="")) {
|
||||
$newVal = "";
|
||||
for ($x=0; $x < strlen($value); $x++) {
|
||||
$z = substr($value, $x, 1);
|
||||
if (($z >= "0") && ($z <= "9")) {
|
||||
$newVal .= $z;
|
||||
}
|
||||
else {
|
||||
if (strpos($allowed, $z) < 0) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (strlen($newVal) != 9) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
if (!$isValid) {
|
||||
$WAFV_ErrorMessage .= ",".$number;
|
||||
}
|
||||
return $WAFV_ErrorMessage;
|
||||
}
|
||||
|
||||
function WAValidateUnique($connName,$conn,$db,$tableName,$keyCol,$keyType,$keyValue,$filterCol,$filterType,$filterValue,$required,$number) {
|
||||
$WAFV_ErrorMessage = ( ($required) ? WAValidateRQ($filterValue, true, $number) : "" );
|
||||
if (!$WAFV_ErrorMessage) {
|
||||
$isValid = true;
|
||||
$WA_UniqueWhere = Validations_generateWhereClause(array($filterCol, $keyCol), array($filterType, $keyType), array($filterValue, $keyValue), array("=", "<>"));
|
||||
$WA_UniqueSQL = "SELECT `".$keyCol."` FROM `".$tableName."` WHERE ".$WA_UniqueWhere->sqlWhereClause;
|
||||
if (is_object($conn) && get_class($conn) == "mysqli") {
|
||||
$WA_UniqueRS = mysqli_query($conn, $WA_UniqueSQL) or die(mysqli_error());
|
||||
if ($WA_UniqueRS->num_rows > 0) {
|
||||
$isValid = false;
|
||||
}
|
||||
} else {
|
||||
mysql_select_db($db, $conn);
|
||||
$WA_UniqueRS = mysql_query($WA_UniqueSQL, $conn) or die(mysql_error());
|
||||
$WA_UniqueRows = mysql_num_rows($WA_UniqueRS);
|
||||
if ($WA_UniqueRows) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
if (!$isValid) {
|
||||
$WAFV_ErrorMessage .= ",".$number;
|
||||
}
|
||||
}
|
||||
return $WAFV_ErrorMessage;
|
||||
}
|
||||
|
||||
if (!function_exists("Validations_generateWhereClause")) {
|
||||
class Validations_WhereClause {
|
||||
var $sqlWhereClause;
|
||||
function __construct($sqlWhereClause = "") {
|
||||
$this->sqlWhereClause = $sqlWhereClause;
|
||||
}
|
||||
}
|
||||
function Validations_generateWhereClause($fieldNameList, $columnTypeList, $fieldValueList, $comparisonList)
|
||||
{
|
||||
$obj = new Validations_WhereClause();
|
||||
for ($i = 0; $i < sizeof($fieldNameList); $i++) {
|
||||
$formVal = $fieldValueList[$i];
|
||||
$WA_typesArray = explode(",", $columnTypeList[$i]);
|
||||
$delim = ($WA_typesArray[0] != "none") ? $WA_typesArray[0] : "";
|
||||
$altVal = ($WA_typesArray[1] != "none") ? $WA_typesArray[1] : "";
|
||||
$emptyVal = ($WA_typesArray[2] != "none") ? $WA_typesArray[2] : "";
|
||||
if ($formVal == "" || $formVal == "undefined") {
|
||||
$formVal = $emptyVal;
|
||||
} else {
|
||||
if ($altVal != "") {
|
||||
$formVal = $altVal;
|
||||
} else if ($delim == "'") { // escape quotes
|
||||
$formVal = "'".((!(preg_match("/(^|[^\\\\])'/", $formVal))) ? $formVal : addslashes($formVal));
|
||||
if ($comparisonList[$i] == " LIKE ") $formVal .= "%";;
|
||||
$formVal .= "'";
|
||||
} else if ($delim == "") {
|
||||
//numeric
|
||||
if (is_numeric($formVal)) {
|
||||
$formVal = "".floatval($formVal);
|
||||
}
|
||||
else {
|
||||
$formVal = "0";
|
||||
}
|
||||
} else {
|
||||
$formVal = $delim.Validations_clearOutSQLKeywords($formVal).$delim;
|
||||
}
|
||||
}
|
||||
if (!($delim == "" && strpos($formVal,"()")>0)) {
|
||||
if ($formVal == "NULL") {
|
||||
$obj->sqlWhereClause .= (($i != 0) ? " AND " : "")."`". Validations_cleanUpColumnName($fieldNameList[$i])."`"." IS " .(($comparisonList[$i] == '<>')?"NOT ":"") .$formVal;
|
||||
}
|
||||
else {
|
||||
$obj->sqlWhereClause .= (($i != 0) ? " AND " : "")."`". Validations_cleanUpColumnName($fieldNameList[$i])."`".Validations_cleanUpEquality($comparisonList[$i]).$formVal;
|
||||
}
|
||||
}
|
||||
}
|
||||
return $obj;
|
||||
}
|
||||
|
||||
function Validations_cleanUpColumnName($colName) {
|
||||
if (strpos($colName, ";") !== false) {
|
||||
$colName = substr($colName, 0, strpos($colName, ";"));
|
||||
}
|
||||
if (strpos($colName, "(") !== false) {
|
||||
$colName = substr($colName, 0, strpos($colName, "("));
|
||||
}
|
||||
if (strpos($colName, "=") !== false) {
|
||||
$colName = substr($colName, 0, strpos($colName, "="));
|
||||
}
|
||||
return $colName;
|
||||
}
|
||||
|
||||
function Validations_cleanUpEquality($tEquality) {
|
||||
if (preg_replace('/^\\s*|\\s*$/', "", $tEquality) != "=") {
|
||||
return Validations_cleanUpColumnName($tEquality);
|
||||
}
|
||||
return $tEquality;
|
||||
}
|
||||
|
||||
function Validations_clearOutSQLKeywords($tString) {
|
||||
if (strpos(strtolower($tString), "select") !== false) {
|
||||
return "";
|
||||
}
|
||||
if (strpos(strtolower($tString), "drop") !== false) {
|
||||
return "";
|
||||
}
|
||||
if (strpos(strtolower($tString), "alter") !== false) {
|
||||
return "";
|
||||
}
|
||||
if (strpos(strtolower($tString), "create") !== false) {
|
||||
return "";
|
||||
}
|
||||
if (strpos(strtolower($tString), "update") !== false) {
|
||||
return "";
|
||||
}
|
||||
if (strpos(strtolower($tString), "insert") !== false) {
|
||||
return "";
|
||||
}
|
||||
if (strpos(strtolower($tString), "delete") !== false) {
|
||||
return "";
|
||||
}
|
||||
if (strpos(strtolower($tString), "'") !== false) {
|
||||
return "";
|
||||
}
|
||||
if (strpos(strtolower($tString), "#") !== false) {
|
||||
return "";
|
||||
}
|
||||
return $tString;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function WAValidateUR($value,$force,$required,$number) {
|
||||
$WAFV_ErrorMessage = "";
|
||||
$isValid = true;
|
||||
$valURL = $value;
|
||||
if (!strpos($valURL, "://")===false) {
|
||||
$valURL = substr($valURL, strpos($valURL, "://")+3);
|
||||
}
|
||||
if (strpos($valURL, "?")>0) {
|
||||
$valURL = substr($valURL, 0,strpos($valURL, "?"));
|
||||
}
|
||||
if (!(!$required && preg_replace("/\s/", "", $valURL)=="")) {
|
||||
if (strtolower($force) == "none") {
|
||||
if (strpos($value, "://")!==false)
|
||||
$isValid = false;
|
||||
}
|
||||
if (strpos($value, "?") != strrpos($value, "?") || !strpos($value, " ") === false) {
|
||||
$isValid = false;
|
||||
}
|
||||
if ($isValid) {
|
||||
if (!strpos($valURL, ";") === false || !strpos($valURL, "&") === false || !strpos($valURL, "=") === false || !strpos($valURL, ",") === false) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
if (strtolower($force) != "false" && strtolower($force) != "none" && $isValid) {
|
||||
$force = preg_replace("/\\s*,\\s*/", ",", $force);
|
||||
$force = explode(",", $force);
|
||||
$isValid = false;
|
||||
foreach ($force as $x) {
|
||||
if (strpos(strtolower($value), strtolower($x))===0) {
|
||||
$isValid = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($isValid && strpos($valURL, ".") < 1)
|
||||
$isValid = false;
|
||||
if ($isValid) {
|
||||
$tDomain = $valURL;
|
||||
if (strpos($tDomain, ":") !== false) {
|
||||
$tDomain = substr($tDomain, 0, strpos($tDomain, ":"));
|
||||
$tPort = substr($valURL, strlen($tDomain)+1);
|
||||
if (strpos($tDomain, "/") !== false) {
|
||||
$isValid = false;
|
||||
}
|
||||
else {
|
||||
if (strpos($tPort, "/") !== false) {
|
||||
$tPort = substr($tPort, 0, strpos($tPort, "/"));
|
||||
}
|
||||
if (!is_numeric($tPort) && $tPort !== "") {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($isValid && strpos($tDomain, "/") !== false) {
|
||||
$tDomain = substr($tDomain, 0, strpos($tDomain, "/"));
|
||||
}
|
||||
if ($isValid) {
|
||||
$tDomainA = explode(".", $tDomain);
|
||||
if (sizeof($tDomainA) < 2) {
|
||||
$isValid = false;
|
||||
}
|
||||
else {
|
||||
$ipMatch = "/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/";
|
||||
if (preg_match($ipMatch,$tDomain)) {
|
||||
if ($tDomainA[0] > 255 || $tDomainA[1] > 255 || $tDomainA[2] > 255 || $tDomainA[3] > 255) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (strlen($tDomainA[sizeof($tDomainA)-1]) < 2 || strlen($tDomainA[sizeof($tDomainA)-2]) < 2) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($isValid && $required && preg_replace("/\s/", "", $valURL)=="")
|
||||
$isValid = false;
|
||||
if (!$isValid) {
|
||||
$WAFV_ErrorMessage .= ",".$number;
|
||||
}
|
||||
return $WAFV_ErrorMessage;
|
||||
}
|
||||
|
||||
function WAValidateZC($value,$us5,$us9,$can6,$uk,$required,$number) {
|
||||
$WAFV_ErrorMessage = "";
|
||||
$isValid = true;
|
||||
$allowed = "() -.\n\r";
|
||||
$charVal = "";
|
||||
if (!(!$required && $value=="")) {
|
||||
$newVal = "";
|
||||
$hasLetters = false;
|
||||
for ($x=0; $x < strlen($value); $x++) {
|
||||
$z = substr($value, $x, 1);
|
||||
if (($z >= "0") && ($z <= "9")) {
|
||||
$newVal .= $z;
|
||||
$charVal .= "N";
|
||||
}
|
||||
else if (($uk || $can6) && ((($z >= "a") && ($z <= "z")) || (($z >= "A") && ($z <= "Z")))) {
|
||||
$charVal .= "A";
|
||||
$hasLetters = true;
|
||||
}
|
||||
else if (strpos($allowed, $z) < 0 || $x == 0 || $x == strlen($value)-1) {
|
||||
$isValid = false;
|
||||
}
|
||||
}
|
||||
$acceptPattern = ",";
|
||||
if ($us5) {
|
||||
$acceptPattern .= "NNNNN,";
|
||||
}
|
||||
if ($us9) {
|
||||
$acceptPattern .= "NNNNNNNNN,";
|
||||
}
|
||||
if ($uk) {
|
||||
$acceptPattern .= "ANNAA,ANNNAA,AANNAA,AANNNAA,ANANAA,AANANAA,";
|
||||
}
|
||||
if ($can6) {
|
||||
$acceptPattern .= "ANANAN,";
|
||||
}
|
||||
if (strpos($acceptPattern,",".$charVal.",") === false)
|
||||
$isValid = false;
|
||||
if ($isValid && !$hasLetters && ($us5 || $us9)) {
|
||||
if ($us5) {
|
||||
$isValid = preg_match('/^\d{5}$/', $value);
|
||||
}
|
||||
if ($us9 && (($us5 && !$isValid) || !$us5)) {
|
||||
$isValid = (preg_match('/^\d{5}[-\. ]\d{4}$/', $value) || preg_match('/^\d{9}$/', $value));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!$isValid) {
|
||||
$WAFV_ErrorMessage .= ",".$number;
|
||||
}
|
||||
return $WAFV_ErrorMessage;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
@session_start();
|
||||
function ValidatedField($page,$field,$encoded=true) {
|
||||
$theFields= "";
|
||||
$retVal = "";
|
||||
if (isset($_SESSION["WAVT_".$page."_Errors"])) {
|
||||
$theFields = "&".$_SESSION["WAVT_".$page."_Errors"];
|
||||
}
|
||||
if (strpos($theFields,"&WAVT_".$field."=") !== false) {
|
||||
$retVal = substr($theFields,strpos($theFields,"&WAVT_".$field."=")+strlen("&WAVT_".$field."="));
|
||||
} else if (strpos($theFields,"&WAVT_".$field."[0]=") !== false) {
|
||||
$retVal = array();
|
||||
$arrIndex = 0;
|
||||
while (strpos($theFields,"&WAVT_".$field."[".$arrIndex."]=") !== false) {
|
||||
$arrVal = substr($theFields,strpos($theFields,"&WAVT_".$field."[".$arrIndex."]=")+strlen("&WAVT_".$field."[".$arrIndex."]="));
|
||||
if (strpos($arrVal,"&WAVT_") !== false) $arrVal = substr($arrVal,0,strpos($arrVal,"&WAVT_"));
|
||||
$retVal[] = htmlspecialchars($arrVal);
|
||||
$arrIndex++;
|
||||
}
|
||||
return $retVal;
|
||||
}
|
||||
if (strpos($retVal,"&WAVT_") !== false) {
|
||||
$retVal = substr($retVal,0,strpos($retVal,"&WAVT_"));
|
||||
}
|
||||
if ($retVal == "" && $page == $field) {
|
||||
$retVal = ValidatedField($page,$field."_Errors");
|
||||
}
|
||||
if ($encoded) $retVal = htmlspecialchars($retVal);
|
||||
return $retVal;
|
||||
}
|
||||
?>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?><wa_form name="Update" id="Update" submit_text="" send_mail="true" use_upload="true"> <wa_form_fieldset label="Update" id="Update"> @@FieldsRequired@@ <wa_form_line> <wa_form_group_reference label="" continueLine="false"> <wa_field_group name=""> <wa_field_line> <wa_field_column> <wa_field_set_validation>Please enter a value.</wa_field_set_validation> <wa_field_reference value='".$WADAbeaches_update->getColumnVal("namebeach") ."' elementName="namebeach" src="text_medium.xml" label="namebeach:" validation="{ type: 'none' }" undefinedundefined continueLine="false"></wa_field_reference> </wa_field_column> </wa_field_line> </wa_field_group> </wa_form_group_reference> </wa_form_line>
|
||||
<wa_form_line> <wa_form_group_reference label="" continueLine="false"> <wa_field_group name=""> <wa_field_line> <wa_field_column> <wa_field_set_validation>Please enter a value.</wa_field_set_validation> <wa_field_reference value='".$WADAbeaches_update->getColumnVal("addressbeach") ."' elementName="addressbeach" src="Text_medium.xml" label="addressbeach:" validation="{ type: 'none' }" undefinedundefined continueLine="false"></wa_field_reference> </wa_field_column> </wa_field_line> </wa_field_group> </wa_form_group_reference> </wa_form_line>
|
||||
<wa_form_line> <wa_form_group_reference label="" continueLine="false"> <wa_field_group name=""> <wa_field_line> <wa_field_column> <wa_field_set_validation>Please enter a value.</wa_field_set_validation> <wa_field_reference value='".$WADAbeaches_update->getColumnVal("citybeach") ."' elementName="citybeach" src="Text_medium.xml" label="citybeach:" validation="{ type: 'none' }" undefinedundefined continueLine="false"></wa_field_reference> </wa_field_column> </wa_field_line> </wa_field_group> </wa_form_group_reference> </wa_form_line>
|
||||
<wa_form_line> <wa_form_group_reference label="" continueLine="false"> <wa_field_group name=""> <wa_field_line> <wa_field_column> <wa_field_set_validation>Please enter a value.</wa_field_set_validation> <wa_field_reference value='".$WADAbeaches_update->getColumnVal("zipbeach") ."' elementName="zipbeach" src="text_medium.xml" label="zipbeach:" validation="{ type: 'integer' }" serverValidation="integer" undefinedundefined continueLine="false"></wa_field_reference> </wa_field_column> </wa_field_line> </wa_field_group> </wa_form_group_reference> </wa_form_line>
|
||||
<wa_form_line> <wa_form_group_reference label="" continueLine="false"> <wa_field_group name=""> <wa_field_line> <wa_field_column> <wa_field_set_validation>Please enter a value.</wa_field_set_validation> <wa_field_reference value='".$WADAbeaches_update->getColumnVal("countrybeach") ."' elementName="countrybeach" src="Text_medium.xml" label="countrybeach:" validation="{ type: 'none' }" undefinedundefined continueLine="false"></wa_field_reference> </wa_field_column> </wa_field_line> </wa_field_group> </wa_form_group_reference> </wa_form_line>
|
||||
<wa_form_line> <wa_form_group_reference label="" continueLine="false"> <wa_field_group name=""> <wa_field_line> <wa_field_column> <wa_field_set_validation>Please enter a value.</wa_field_set_validation> <wa_field_reference value='".$WADAbeaches_update->getColumnVal("phonebeach") ."' elementName="phonebeach" src="Text_medium.xml" label="phonebeach:" validation="{ type: 'none' }" undefinedundefined continueLine="false"></wa_field_reference> </wa_field_column> </wa_field_line> </wa_field_group> </wa_form_group_reference> </wa_form_line>
|
||||
<wa_form_line> <wa_form_group_reference label="" continueLine="false"> <wa_field_group name=""> <wa_field_line> <wa_field_column> <wa_field_set_validation>Please enter a value.</wa_field_set_validation> <wa_field_reference value='".$WADAbeaches_update->getColumnVal("emailbeach") ."' elementName="emailbeach" src="text_medium.xml" label="emailbeach:" validation="{ type: 'email' }" serverValidation="email" undefinedundefined continueLine="false"></wa_field_reference> </wa_field_column> </wa_field_line> </wa_field_group> </wa_form_group_reference> </wa_form_line>
|
||||
<wa_form_line> <wa_form_group_reference label="" continueLine="false"> <wa_field_group name=""> <wa_field_line> <wa_field_column> <wa_field_set_validation>Please enter a value.</wa_field_set_validation> <wa_field_reference value='".$WADAbeaches_update->getColumnVal("idownerbeach") ."' elementName="idownerbeach" src="Text_medium.xml" label="idownerbeach:" validation="{ type: 'none' }" undefinedundefined continueLine="false"></wa_field_reference> </wa_field_column> </wa_field_line> </wa_field_group> </wa_form_group_reference> </wa_form_line>
|
||||
<wa_form_line> <wa_form_group_reference label="" continueLine="false"> <wa_field_group name=""> <wa_field_line> <wa_field_column> <wa_field_set_validation>Please enter a value.</wa_field_set_validation> <wa_field_reference value='".$WADAbeaches_update->getColumnVal("long") ."' elementName="long" src="Text_medium.xml" label="long:" validation="{ type: 'none' }" undefinedundefined continueLine="false"></wa_field_reference> </wa_field_column> </wa_field_line> </wa_field_group> </wa_form_group_reference> </wa_form_line>
|
||||
<wa_form_line> <wa_form_group_reference label="" continueLine="false"> <wa_field_group name=""> <wa_field_line> <wa_field_column> <wa_field_set_validation>Please enter a value.</wa_field_set_validation> <wa_field_reference value='".$WADAbeaches_update->getColumnVal("lat") ."' elementName="lat" src="Text_medium.xml" label="lat:" validation="{ type: 'none' }" undefinedundefined continueLine="false"></wa_field_reference> </wa_field_column> </wa_field_line> </wa_field_group> </wa_form_group_reference> </wa_form_line> </wa_form_fieldset> <wa_email_settings>
|
||||
<com_settings charset="undefined" com_index="undefined" com_name="undefined">
|
||||
</com_settings>
|
||||
<to_settings send_index="undefined" send_setting="undefined" burst_size="undefined" burst_time="undefined" wait_time="undefined">
|
||||
</to_settings>
|
||||
<from_settings reply_to="undefined" return_path="undefined" from_name="" from_email="" />
|
||||
<cc_settings>
|
||||
</cc_settings>
|
||||
<bcc_settings>
|
||||
</bcc_settings>
|
||||
<att_settings>
|
||||
</att_settings>
|
||||
<log_settings>
|
||||
<onany_ui_values response="0" connection="" table="" column=""></onany_ui_values>
|
||||
<onsuccess_ui_values response="0" connection="" table="" column=""></onsuccess_ui_values>
|
||||
<onfailure_ui_values response="0" connection="" table="" column=""></onfailure_ui_values>
|
||||
</log_settings>
|
||||
<other_settings subject="undefined" allow_multi="undefined" use_template="true" template_path="" has_html="undefined" has_text="undefined" body_format="0" importance_option="undefined" importance_value="3" importance_enteredvalue="undefined"></other_settings>
|
||||
</wa_email_settings>
|
||||
</wa_form>
|
||||
@@ -0,0 +1,14 @@
|
||||
<wa_form name="Link Exchange Request" id="LinkExchangeRequest" submit_text="Submit Request" send_mail="false" use_upload="true">
|
||||
<wa_form_fieldset label="Link Exchange Request" id="Registration">
|
||||
<wa_fieldset_description>Required *</wa_fieldset_description>
|
||||
<wa_form_line>
|
||||
<wa_form_group_reference group="Webdesign.xml" src="Linkexchangerequestinfo.xml" label="Information" continueLine="false" />
|
||||
</wa_form_line>
|
||||
<wa_form_line>
|
||||
<wa_form_group_reference group="Webdesign.xml" src="Linkexchangerequestpageranks.xml" label="Google page rank" continueLine="false" />
|
||||
</wa_form_line>
|
||||
<wa_form_line>
|
||||
<wa_form_group_reference group="Webdesign.xml" src="Linkexchangerequestcomments.xml" label="" continueLine="false" />
|
||||
</wa_form_line>
|
||||
</wa_form_fieldset>
|
||||
</wa_form>
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
@media only screen and (undefined) {undefined}
|
||||
@@ -0,0 +1,366 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<wa_form_theme name="Default" id="Basic_Default" version="1.0">
|
||||
<wa_theme_group id="form">
|
||||
<wa_theme_configuration id="width">760px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="column_width">760px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="max_columns">1</wa_theme_configuration>
|
||||
<wa_theme_configuration id="use_tabindex">true</wa_theme_configuration>
|
||||
<wa_theme_configuration id="tabindex_increment">1</wa_theme_configuration>
|
||||
<wa_theme_configuration id="progressbar_category">BigSpin</wa_theme_configuration>
|
||||
<wa_theme_configuration id="progressbar_theme">Slate</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="fieldset">
|
||||
<wa_theme_configuration id="padding-bottom">12px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="fieldset_legend">
|
||||
<wa_theme_configuration id="legend_option">true|false</wa_theme_configuration>
|
||||
<wa_theme_configuration id="span_for_legend">false</wa_theme_configuration>
|
||||
<wa_theme_configuration id="font-size">larger</wa_theme_configuration>
|
||||
<wa_theme_configuration id="font-weight">bold</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="fieldset_description">
|
||||
<wa_theme_configuration id="color">#b40000</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="fieldset_contents">
|
||||
<wa_theme_configuration id="margin-top">0</wa_theme_configuration>
|
||||
<wa_theme_configuration id="margin-right">0</wa_theme_configuration>
|
||||
<wa_theme_configuration id="margin-bottom">0</wa_theme_configuration>
|
||||
<wa_theme_configuration id="margin-left">0</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">0</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">0</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">0</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">0</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="headers">
|
||||
<wa_theme_configuration id="placement_option">true|true</wa_theme_configuration>
|
||||
<wa_theme_configuration id="text-align">right</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="element_groups">
|
||||
<wa_theme_configuration id="padding-top">7px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">0</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">15px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">0</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="labels">
|
||||
<wa_theme_configuration id="label_orientation">left</wa_theme_configuration>
|
||||
<wa_theme_configuration id="label_append">:</wa_theme_configuration>
|
||||
<wa_theme_configuration id="text-align">right</wa_theme_configuration>
|
||||
<wa_theme_configuration id="float">left</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="margin-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="margin-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="font-weight">normal</wa_theme_configuration>
|
||||
<wa_theme_configuration id="label_width">120px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="line-height">30px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_text_xsmall">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">50px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_text_small">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">80px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_text_medium">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">120px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_text_large">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">200px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_text_xlarge">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">592px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_textarea_large">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">514px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="height">200px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_textarea_medium">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">382px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="height">150px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_textarea_small">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">252px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="height">100px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_menu_xsmall">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">50px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_menu_small">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">80px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_menu_medium">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">120px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_menu_large">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">252px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_menu_xlarge">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">382px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_list_xsmall">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">50px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="height">100px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_list_small">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">80px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="height">100px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_list_medium">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">120px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="height">100px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_list_large">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">252px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="height">100px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_list_xlarge">
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">5px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">382px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="height">150px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_checkbox_all">
|
||||
<wa_theme_configuration id="labels_placement">right</wa_theme_configuration>
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">2px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_checkboxgroup_onecolumn">
|
||||
<wa_theme_configuration id="labels_placement">left</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_checkboxgroup_narrow">
|
||||
<wa_theme_configuration id="labels_placement">left</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">60px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_checkboxgroup_wide">
|
||||
<wa_theme_configuration id="labels_placement">left</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">135px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_radio_all">
|
||||
<wa_theme_configuration id="labels_placement">left</wa_theme_configuration>
|
||||
<wa_theme_configuration id="margin-left">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-top">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">2px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_radiogroup_all">
|
||||
<wa_theme_configuration id="padding-top">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-right">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-bottom">2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">2px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_radiogroup_onecolumn">
|
||||
<wa_theme_configuration id="labels_placement">left</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_radiogroup_narrow">
|
||||
<wa_theme_configuration id="labels_placement">left</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">60px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_radiogroup_wide">
|
||||
<wa_theme_configuration id="labels_placement">left</wa_theme_configuration>
|
||||
<wa_theme_configuration id="width">135px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_file_small">
|
||||
<wa_theme_configuration id="width">20</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_file_large">
|
||||
<wa_theme_configuration id="width">30</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_captcha_all">
|
||||
<wa_theme_configuration id="font_file">MOM_T___.TTF</wa_theme_configuration>
|
||||
<wa_theme_configuration id="margin">0 0 -7px 2px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="font_color">#040404</wa_theme_configuration>
|
||||
<wa_theme_configuration id="noise_level">15</wa_theme_configuration>
|
||||
<wa_theme_configuration id="noise_color">#060606</wa_theme_configuration>
|
||||
<wa_theme_configuration id="grid_color">#080808</wa_theme_configuration>
|
||||
<wa_theme_configuration id="input_size">Large</wa_theme_configuration>
|
||||
<wa_theme_configuration id="noise_placement">default</wa_theme_configuration>
|
||||
<wa_theme_configuration id="grid_level">none</wa_theme_configuration>
|
||||
<wa_theme_configuration id="grid_placement">default</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_htmleditor_large">
|
||||
<wa_theme_configuration id="editor_preset">Full</wa_theme_configuration>
|
||||
<wa_theme_configuration id="editor_skin">moono</wa_theme_configuration>
|
||||
<wa_theme_configuration id="editor_width">514px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="editor_height">350px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_htmleditor_medium">
|
||||
<wa_theme_configuration id="editor_preset">Normal</wa_theme_configuration>
|
||||
<wa_theme_configuration id="editor_skin">moono</wa_theme_configuration>
|
||||
<wa_theme_configuration id="editor_width">382px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="editor_height">250px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="elm_htmleditor_small">
|
||||
<wa_theme_configuration id="editor_preset">Compact</wa_theme_configuration>
|
||||
<wa_theme_configuration id="editor_skin">moono</wa_theme_configuration>
|
||||
<wa_theme_configuration id="editor_width">252px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="editor_height">150px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_text_initial">
|
||||
<wa_theme_configuration id="background-color">#FFF</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_text_active">
|
||||
<wa_theme_configuration id="background-color">#FFFFCC</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_text_valid">
|
||||
<wa_theme_configuration id="background-color">#B8F5B1</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_text_invalid">
|
||||
<wa_theme_configuration id="background-color">#FF9F9F</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_textarea_initial">
|
||||
<wa_theme_configuration id="background-color">#FFF</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_textarea_active">
|
||||
<wa_theme_configuration id="background-color">#FFFFCC</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_textarea_valid">
|
||||
<wa_theme_configuration id="background-color">#B8F5B1</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_textarea_invalid">
|
||||
<wa_theme_configuration id="background-color">#FF9F9F</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_select_initial">
|
||||
<wa_theme_configuration id="background-color">#FFF</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_select_active">
|
||||
<wa_theme_configuration id="background-color">#FFFFCC</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_select_valid">
|
||||
<wa_theme_configuration id="background-color">#B8F5B1</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_select_invalid">
|
||||
<wa_theme_configuration id="background-color">#FF9F9F</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_checkbox_initial">
|
||||
<wa_theme_configuration id="background-color">#FFF</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_checkbox_active">
|
||||
<wa_theme_configuration id="background-color">#FFF</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_checkbox_valid">
|
||||
<wa_theme_configuration id="background-color">#B8F5B1</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_checkbox_invalid">
|
||||
<wa_theme_configuration id="background-color">#FF9F9F</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_radio_initial">
|
||||
<wa_theme_configuration id="background-color">#FFF</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_radio_active">
|
||||
<wa_theme_configuration id="background-color">#FFF</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_radio_valid">
|
||||
<wa_theme_configuration id="background-color">#B8F5B1</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="state_radio_invalid">
|
||||
<wa_theme_configuration id="background-color">#FF9F9F</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="validation">
|
||||
<wa_theme_configuration id="required_indicator"> *</wa_theme_configuration>
|
||||
<wa_theme_configuration id="use_server">true</wa_theme_configuration>
|
||||
<wa_theme_configuration id="use_client">true</wa_theme_configuration>
|
||||
<wa_theme_configuration id="validation_onblur">true</wa_theme_configuration>
|
||||
<wa_theme_configuration id="validation_location">right</wa_theme_configuration>
|
||||
<wa_theme_configuration id="color">#b40000</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="button">
|
||||
<wa_theme_configuration id="position_inside">true</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="button_span">
|
||||
<wa_theme_configuration id="padding-top">15px</wa_theme_configuration>
|
||||
<wa_theme_configuration id="padding-left">125px</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
<wa_theme_group id="appended_text">
|
||||
<wa_theme_configuration id="text_location">below</wa_theme_configuration>
|
||||
</wa_theme_group>
|
||||
</wa_form_theme>
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 94 B |
Binary file not shown.
|
After Width: | Height: | Size: 66 KiB |
@@ -0,0 +1,27 @@
|
||||
function hideServerError(theID) {
|
||||
if (document.getElementById(theID)) document.getElementById(theID).style.display='none';
|
||||
}
|
||||
|
||||
function clearAllServerErrors(theFormID) {
|
||||
if (Spry && Spry.Widget && Spry.Widget.Form) {
|
||||
var theForm = document.getElementById(theFormID);
|
||||
var q = Spry.Widget.Form.onSubmitWidgetQueue;
|
||||
var qlen = q.length;
|
||||
for (var i = 0; i < qlen; i++)
|
||||
if (q[i].form == theForm) {
|
||||
clearRelated(q[i].element.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function clearRelated(theID) {
|
||||
var theTestID = theID.replace(/_[^_]*$/,"");
|
||||
while (theTestID != "") {
|
||||
if (document.getElementById(theTestID+"_ServerError")) {
|
||||
document.getElementById(theTestID+"_ServerError").style.display='none';
|
||||
return;
|
||||
}
|
||||
if (theTestID.search(/_[^_]*$/)<0) theTestID = ""; else theTestID = theTestID.replace(/_[^_]*$/,"");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*right triangle*/
|
||||
.serverInvalidState {
|
||||
display:none;
|
||||
}
|
||||
|
||||
.validation-close {
|
||||
font-size: 12px;
|
||||
position: absolute;
|
||||
right: 2px;
|
||||
top: 2px;
|
||||
cursor: pointer;
|
||||
color: #FFFFFF;
|
||||
border: 0px solid #FFFFFF;
|
||||
-webkit-border-radius: 0px;
|
||||
-moz-border-radius: 0px;
|
||||
border-radius: 0px;
|
||||
padding: 0px;
|
||||
font-family: monospace;
|
||||
font-weight: normal;
|
||||
font-style: normal;
|
||||
}
|
||||
|
||||
.Bloom {
|
||||
position:absolute;
|
||||
padding:10px 15px 10px 15px ;
|
||||
color:#FFFFFF;
|
||||
background:#b8b369; /* default background for browsers without gradient support */
|
||||
|
||||
background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#b8b369), to(#b8b369));
|
||||
background-image: -webkit-linear-gradient(top, #b8b369, #b8b369); /* For Chrome and Safari */
|
||||
background-image: -moz-linear-gradient(top, #b8b369, #b8b369); /* For old Fx (3.6 to 15) */
|
||||
background-image: -ms-linear-gradient(top, #b8b369, #b8b369); /* For pre-releases of IE 10*/
|
||||
background-image: -o-linear-gradient(top, #b8b369, #b8b369); /* For old Opera (11.1 to 12.0) */
|
||||
background-image: linear-gradient(to bottom, #b8b369, #b8b369); /* Standard syntax; must be last */
|
||||
|
||||
-webkit-border-radius:0px;
|
||||
-moz-border-radius:0px;
|
||||
border-radius:0px;
|
||||
border: 1px solid #b2ad56;
|
||||
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
font-weight: undefined;
|
||||
font-style: inherit;
|
||||
max-width: 350em;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* THE POINTER
|
||||
------------------------------------------------------------------------------------------------------------------------------- */
|
||||
|
||||
.Bloom-wrapper {
|
||||
opacity:0.8;
|
||||
position:absolute;
|
||||
top:0;
|
||||
left:0;
|
||||
}
|
||||
|
||||
.Bloom-before {
|
||||
position:absolute;
|
||||
border-style:solid;
|
||||
display:block;
|
||||
width:0;
|
||||
border-width:17.236067977499786px 34.47213595499957px 0 0; /* vary these values to change the angle of the vertex */
|
||||
border-style:solid;
|
||||
border-color:#b2ad56 transparent;
|
||||
}
|
||||
|
||||
.Bloom-after {
|
||||
position:absolute;
|
||||
content:"";
|
||||
border:0;
|
||||
border-width:15px 30px 0 0;
|
||||
border-style:solid;
|
||||
border-color:#b8b369 transparent;
|
||||
display:block;
|
||||
width:0;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,815 @@
|
||||
<?php
|
||||
// version 2.31
|
||||
if (!class_exists("WA_MySQLi_Query")) {
|
||||
|
||||
class WA_MySQLi_Query {
|
||||
public function __construct($conn, $mrt = "mrt") {
|
||||
$this->Action = "";
|
||||
$this->UseAction = "";
|
||||
$this->AffectedRows = 0;
|
||||
$this->Connection = $conn;
|
||||
$this->Debug = false;
|
||||
$this->DieOnError = true;
|
||||
$this->EncryptionAlgorithm = "blowfish";
|
||||
$this->EncryptionKey = "Change Me";
|
||||
$this->EncryptionMode = "cbc";
|
||||
$this->Error = "";
|
||||
$this->ErrorMessage = "There is an error in your SQL syntax.";
|
||||
$this->ErrorNo = 0;
|
||||
$this->FieldCount = 0;
|
||||
$this->Filter = "";
|
||||
$this->FilterValues = array();
|
||||
$this->ID = 0;
|
||||
$this->InsertID = 0;
|
||||
$this->JavascriptRedirect = false;
|
||||
$this->MRTField = $mrt;
|
||||
$this->NumRows = 0;
|
||||
$this->OnDuplicate = "";
|
||||
$this->ParamColumns = array();
|
||||
$this->ParamCount = 0;
|
||||
$this->ParamDefaults = array();
|
||||
$this->ParamTypes = array();
|
||||
$this->ParamValues = array();
|
||||
$this->Prepared = true;
|
||||
$this->RelationalColumns = array();
|
||||
$this->RelationalKeyColumn = false;
|
||||
$this->RelationalRows = array();
|
||||
$this->RelationalRowsFound = false;
|
||||
$this->RepeatConditions = array();
|
||||
$this->RepeatedParams = array();
|
||||
$this->RepeatIndex = 0;
|
||||
$this->SelectedResult = false;
|
||||
$this->Salt = false;
|
||||
$this->SaveAs = "";
|
||||
$this->Statement = "";
|
||||
$this->Table = "";
|
||||
}
|
||||
|
||||
public function addFilter($filterColumn, $filterComparison, $filterType, $filterValue, $filterRepeat = false, $temporary = false) {
|
||||
if ($filterType == 'i') {
|
||||
if (strval(intval($filterValue)) != $filterValue) {
|
||||
if ($this->Debug) {
|
||||
die("incorrect INTEGER value: " . $filterValue);
|
||||
} else {
|
||||
die($this->ErrorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($filterType == 'd') {
|
||||
if (strval(floatval($filterValue)) != $filterValue) {
|
||||
if ($this->Debug) {
|
||||
die("incorrect DOUBLE value: " . $filterValue);
|
||||
} else {
|
||||
die($this->ErrorMessage);
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->FilterValues[] = array($filterColumn, $filterComparison, $filterType, $filterValue, $filterRepeat, $temporary);
|
||||
}
|
||||
|
||||
private function addRelationalFilters() {
|
||||
$filterValues = array();
|
||||
for ($x=0; $x<sizeof($this->ParamColumns); $x++) {
|
||||
if ($this->ParamColumns[$x][0] == $this->RelationalColumns[0] || $this->ParamColumns[$x][0] == $this->RelationalColumns[1]) {
|
||||
$filterValues[] = array($this->ParamColumns[$x][0], "=", $this->ParamTypes[$x], $this->ParamValues[$x], false, true);
|
||||
}
|
||||
}
|
||||
$this->FilterValues = $filterValues;
|
||||
}
|
||||
|
||||
public function addRelationship($relationalParentColumn, $relationalChildColumn) {
|
||||
$this->RelationalColumns = array($relationalParentColumn, $relationalChildColumn);
|
||||
}
|
||||
|
||||
private function addQuerystring($url) {
|
||||
if (empty($_SERVER['QUERY_STRING'])) return $url;
|
||||
if (strpos($url,"?")!==false) return $url . "&" . $_SERVER['QUERY_STRING'];
|
||||
return $url . "?" . $_SERVER['QUERY_STRING'];
|
||||
}
|
||||
|
||||
public function bindColumn($paramColumn, $paramType, $paramValue, $paramDefault, $mrtParam = false) {
|
||||
if ($this->isBound($paramColumn)) return;
|
||||
if ($mrtParam && !is_array($paramValue)) {
|
||||
$paramValue = array();
|
||||
$toCheck = isset($_POST[$this->MRTField])?$_POST[$this->MRTField]:array();
|
||||
for ($x=0; $x<sizeof($toCheck); $x++) {
|
||||
if (isset($_POST[$mrtParam."_".$toCheck[$x]])) {
|
||||
$paramValue[] = $_POST[$mrtParam."_".$toCheck[$x]];
|
||||
} else {
|
||||
$paramValue[] = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
if (is_array($paramValue) && sizeof($paramValue) > 0) {
|
||||
$this->RepeatedParams[] = array(sizeof($this->ParamColumns), $paramValue, false);
|
||||
$paramValue = $paramValue[0];
|
||||
}
|
||||
$this->ParamColumns[] = array($paramColumn, false);
|
||||
if ($paramType == "c") $paramType = "z";
|
||||
$this->bindParam($paramType, $paramValue, $paramDefault);
|
||||
}
|
||||
|
||||
private function bindDefault($paramType,$paramValue,$paramDefault) {
|
||||
if ($paramValue === "" || $paramValue === NULL) {
|
||||
if (($paramType == "d" || $paramType == "i") && $paramDefault == "WA_BLANK") $paramDefault = "WA_ZERO";
|
||||
switch ($paramDefault) {
|
||||
case "WA_BLANK":
|
||||
case "WA_IGNORE":
|
||||
case "WA_SKIP":
|
||||
case "WA_DEFAULT":
|
||||
case "WA_TIMESTAMP":
|
||||
$paramValue = "";
|
||||
break;
|
||||
case "WA_NULL":
|
||||
$paramValue = null;
|
||||
break;
|
||||
case "WA_CURRENT_TIMESTAMP":
|
||||
$paramValue = date("Y-m-d H:i:s");
|
||||
break;
|
||||
case "WA_ZERO":
|
||||
$paramValue = "0";
|
||||
break;
|
||||
case "WA_NO":
|
||||
$paramValue = "N";
|
||||
break;
|
||||
default:
|
||||
$paramValue = $paramDefault;
|
||||
}
|
||||
}
|
||||
if ($paramType == "t") {
|
||||
if ($paramValue) {
|
||||
$hasTime = strpos($paramValue," ") !== false;
|
||||
$paramValue = strtotime($paramValue);
|
||||
if ($hasTime) {
|
||||
$paramValue = date('Y-m-d H:i:s',$paramValue);
|
||||
} else {
|
||||
$paramValue = date('Y-m-d',$paramValue);
|
||||
}
|
||||
} else {
|
||||
$paramValue = null;
|
||||
}
|
||||
} else if ($paramType == "c") {
|
||||
$paramValue = "%" . $paramValue . "%";
|
||||
} else if ($paramType == "b") {
|
||||
$paramValue = $paramValue . "%";
|
||||
} else if ($paramType == "e") {
|
||||
$paramValue = "%" . $paramValue;
|
||||
} else if ($paramType == "y") {
|
||||
if ($paramValue) {
|
||||
$paramValue = "Y";
|
||||
} else {
|
||||
$paramValue = "N";
|
||||
}
|
||||
} else if ($paramType == "n" || $paramType == "z") {
|
||||
if ($paramValue) {
|
||||
$paramValue = ($paramType == "n")?"-1":"1";
|
||||
} else {
|
||||
$paramValue = "0";
|
||||
}
|
||||
}
|
||||
return $paramValue;
|
||||
}
|
||||
|
||||
public function bindParam($paramType,$paramValue,$paramDefault="",$paramPosition=false) {
|
||||
$paramArray = array($paramValue);
|
||||
$isList = false;
|
||||
if (strpos($paramType,"l")) {
|
||||
$paramType = substr($paramType,0,1);
|
||||
$paramArray = preg_split("/\s*\,\s*/", $paramValue);
|
||||
$isList = true;
|
||||
}
|
||||
for ($x=0; $x<sizeof($paramArray); $x++) {
|
||||
$paramValue = $paramArray[$x];
|
||||
$paramValue = $this->bindDefault($paramType,$paramValue,$paramDefault);
|
||||
if (($isList || sizeof($paramArray) > 1) && $x == 0) {
|
||||
$sqlParts = explode("?",$this->Statement);
|
||||
if (!preg_match("/\(\s*$/",$sqlParts[sizeof($this->ParamValues)]) && !preg_match("/^\s*\)/",$sqlParts[sizeof($this->ParamValues)+1])) {
|
||||
$sqlParts[sizeof($this->ParamValues)] = $sqlParts[sizeof($this->ParamValues)] . "(";
|
||||
$sqlParts[sizeof($this->ParamValues)+1] = ")" . $sqlParts[sizeof($this->ParamValues)+1];
|
||||
}
|
||||
$this->Statement = implode("?",$sqlParts);
|
||||
}
|
||||
if ($x>0) {
|
||||
$sqlParts = explode("?",$this->Statement);
|
||||
$sqlParts[sizeof($this->ParamValues)] = ", ?" . $sqlParts[sizeof($this->ParamValues)];
|
||||
$this->Statement = implode("?",$sqlParts);
|
||||
}
|
||||
if ($paramPosition == false) {
|
||||
$this->ParamTypes[] = $paramType;
|
||||
$this->ParamValues[] = $paramValue;
|
||||
$this->ParamDefaults[] = $paramDefault;
|
||||
} else {
|
||||
array_splice($this->ParamTypes, $paramPosition, 0, $paramType);
|
||||
array_splice($this->ParamValues, $paramPosition, 0, $paramValue);
|
||||
array_splice($this->ParamDefaults, $paramPosition, 0, $paramDefault);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function checkRepeatConditions() {
|
||||
for ($x=0; $x<sizeof($this->RepeatConditions); $x++) {
|
||||
if (!(isset($_POST[$this->RepeatConditions[$x] . $this->RepeatIndex]) || isset($_GET[$this->RepeatConditions[$x] . $this->RepeatIndex]))) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private function clearRepeatedFilters() {
|
||||
for ($x=sizeof($this->RepeatedParams)-1; $x>=0; $x--) {
|
||||
if ($this->RepeatedParams[$x][2]) {
|
||||
array_splice($this->ParamValues, $this->RepeatedParams[$x][0], 1);
|
||||
array_splice($this->ParamTypes, $this->RepeatedParams[$x][0], 1);
|
||||
array_splice($this->ParamDefaults, $this->RepeatedParams[$x][0], 1);
|
||||
array_splice($this->RepeatedParams, $x, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function clearTemporaryFilters() {
|
||||
for ($x=sizeof($this->FilterValues)-1; $x>=0; $x--) {
|
||||
if ($this->FilterValues[$x][5]) {
|
||||
array_pop($this->ParamValues);
|
||||
array_pop($this->ParamTypes);
|
||||
array_pop($this->ParamDefaults);
|
||||
array_pop($this->FilterValues);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function clearTemporaryColumns() {
|
||||
for ($x=sizeof($this->ParamColumns)-1; $x>=0; $x--) {
|
||||
if ($this->ParamColumns[$x][1]) {
|
||||
array_splice($this->ParamColumns, $x, 1);
|
||||
array_splice($this->ParamTypes, $x, 1);
|
||||
array_splice($this->ParamDefaults, $x, 1);
|
||||
array_splice($this->ParamValues, $x, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function createStatement() {
|
||||
$this->UseAction = $this->Action;
|
||||
if (strtolower($this->UseAction) == "relational") {
|
||||
if (!$this->RelationalRowsFound) {
|
||||
$this->RelationalRowsFound = true;
|
||||
if (!class_exists("WA_MySQLi_RS")) require(dirname(__FILE__) . "/" . "rsobj.php");
|
||||
$KeyRS = new WA_MySQLi_RS("KeyRS",$this->Connection,0);
|
||||
$KeyRS->setQuery("SHOW KEYS FROM " . $this->Table ." WHERE Key_name = 'PRIMARY'");
|
||||
$KeyRS->execute();
|
||||
$this->RelationalKeyColumn = $KeyRS->getColumnVal("Column_name");
|
||||
|
||||
if (!$this->RelationalKeyColumn) {
|
||||
$ReplaceDelete = new WA_MySQLi_Query($this->Connection);
|
||||
$ReplaceDelete->setQuery("DELETE FROM " . $this->Table);
|
||||
if (sizeof($ReplaceDelete->FilterValues) >= 1) {
|
||||
$ReplaceDelete->setFilter();
|
||||
$ReplaceDelete->execute();
|
||||
}
|
||||
} else {
|
||||
if (!$this->SelectedResult) {
|
||||
$RelationalRS = new WA_MySQLi_RS("RelationalRS",$this->Connection,0);
|
||||
$RelationalRS->setQuery("SELECT " . $this->RelationalColumns[1] . ", " .$this->RelationalKeyColumn. " FROM " . $this->Table);
|
||||
$RelationalRS->FilterValues = array($this->getParentFilterFromRelational());
|
||||
$RelationalRS->setFilter();
|
||||
$RelationalRS->execute();
|
||||
$this->SelectedResult = $RelationalRS;
|
||||
}
|
||||
for ($x=0; $x<sizeof($this->SelectedResult->Results); $x++) {
|
||||
$this->RelationalRows[] = array($this->SelectedResult->Results[$x][$this->RelationalColumns[1]], false, $this->SelectedResult->Results[$x][$this->RelationalKeyColumn]);
|
||||
}
|
||||
}
|
||||
}
|
||||
$relationalChildValue = -1;
|
||||
for ($x=0; $x<sizeof($this->ParamColumns); $x++) {
|
||||
if ($this->ParamColumns[$x][0] == $this->RelationalColumns[1]) {
|
||||
if (empty($this->ParamValues[$x])) {
|
||||
$this->Statement = "";
|
||||
return;
|
||||
}
|
||||
$relationalChildValue = $this->ParamValues[$x];
|
||||
}
|
||||
if ($this->ParamColumns[$x][0] == $this->RelationalColumns[0] && empty($this->ParamValues[$x])) {
|
||||
$this->Statement = "";
|
||||
return;
|
||||
}
|
||||
}
|
||||
$childFound = false;
|
||||
for ($x=0; $x<sizeof($this->RelationalRows); $x++) {
|
||||
if ($relationalChildValue == $this->RelationalRows[$x][0]) {
|
||||
$this->RelationalRows[$x][1] = true;
|
||||
$childFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($childFound) {
|
||||
$this->addRelationalFilters();
|
||||
$this->UseAction = "update";
|
||||
} else {
|
||||
$this->UseAction = "insert";
|
||||
}
|
||||
}
|
||||
if (strtolower($this->UseAction) == "conditional") {
|
||||
if (sizeof($this->FilterValues) > 0) {
|
||||
if (!class_exists("WA_MySQLi_RS")) require(dirname(__FILE__) . "/" . "rsobj.php");
|
||||
$ConditionalRS = new WA_MySQLi_RS("ConditionalRS",$this->Connection,1);
|
||||
$ConditionalRS->setQuery("SELECT Count(*) AS RowCount FROM " . $this->Table);
|
||||
$ConditionalRS->FilterValues = $this->FilterValues;
|
||||
$ConditionalRS->setFilter();
|
||||
$ConditionalRS->execute();
|
||||
if ($ConditionalRS->getColumnVal("RowCount")) {
|
||||
$this->UseAction = "update";
|
||||
} else {
|
||||
$this->FilterValues = array();
|
||||
$this->UseAction = "insert";
|
||||
}
|
||||
} else {
|
||||
$this->UseAction = "insert";
|
||||
}
|
||||
}
|
||||
if (strtolower($this->UseAction) == "replace") {
|
||||
if (sizeof($this->FilterValues) > 0) {
|
||||
$ReplaceDelete = new WA_MySQLi_Query($this->Connection);
|
||||
$ReplaceDelete->setQuery("DELETE FROM " . $this->Table);
|
||||
$ReplaceDelete->FilterValues = $this->FilterValues;
|
||||
$ReplaceDelete->setFilter();
|
||||
$ReplaceDelete->execute();
|
||||
}
|
||||
$this->UseAction = "insert";
|
||||
}
|
||||
switch (strtolower($this->UseAction)) {
|
||||
case "update":
|
||||
$Columns = "";
|
||||
$this->Statement = "UPDATE " . $this->Table . " SET ";
|
||||
$oneAdded = false;
|
||||
for ($x=0; $x<sizeof($this->ParamColumns); $x++) {
|
||||
if (!(($this->ParamDefaults[$x] == "WA_IGNORE" || $this->ParamDefaults[$x] == "WA_SKIP") && ($this->ParamValues[$x] === "" || $this->ParamValues[$x] === false || $this->ParamValues[$x] === null))) {
|
||||
if ($Columns != "") $Columns .= ", ";
|
||||
$columnRef = $this->ParamColumns[$x][0];
|
||||
if (strpos($columnRef,"`") == false && strpos($columnRef,"(") == false) $columnRef = '`'.$columnRef.'`';
|
||||
$colPlaceholder = "?";
|
||||
if ($this->ParamDefaults[$x] == "WA_DEFAULT" && ($this->ParamValues[$x] === "" || $this->ParamValues[$x] === null || $this->ParamValues[$x] === false)) $colPlaceholder = "DEFAULT";
|
||||
if ($this->ParamDefaults[$x] == "WA_TIMESTAMP" && $this->ParamValues[$x] == "") $colPlaceholder = "SYSDATE()";
|
||||
$Columns .= $columnRef . " = " . $colPlaceholder;
|
||||
$oneAdded = true;
|
||||
}
|
||||
}
|
||||
if (!$oneAdded) {
|
||||
$this->Statement = false;
|
||||
return;
|
||||
}
|
||||
$this->Statement .= $Columns;
|
||||
break;
|
||||
case "insert":
|
||||
$Columns = "";
|
||||
$Values = "";
|
||||
$this->Statement = "INSERT ".($this->OnDuplicate == "ignore"?"IGNORE":"INTO")." " . $this->Table . " (";
|
||||
$oneAdded = false;
|
||||
$onDuplicate = "";
|
||||
for ($x=0; $x<sizeof($this->ParamColumns); $x++) {
|
||||
if (!(($this->ParamDefaults[$x] == "WA_IGNORE" || $this->ParamDefaults[$x] == "WA_SKIP") && ($this->ParamValues[$x] === "" || $this->ParamValues[$x] === null || $this->ParamValues[$x] === false))) {
|
||||
if ($Columns != "") {
|
||||
$Columns .= ", ";
|
||||
$Values .= ", ";
|
||||
}
|
||||
$columnRef = $this->ParamColumns[$x][0];
|
||||
if (strpos($columnRef,"`") == false && strpos($columnRef,"(") == false) $columnRef = '`'.$columnRef.'`';
|
||||
$Columns .= $columnRef;
|
||||
if ($this->ParamDefaults[$x] == "WA_DEFAULT" && ($this->ParamValues[$x] === "" || $this->ParamValues[$x] === null || $this->ParamValues[$x] === false)) {
|
||||
$addValue = "DEFAULT";
|
||||
} else if ($this->ParamDefaults[$x] == "WA_TIMESTAMP") {
|
||||
$addValue = "SYSDATE()";
|
||||
} else {
|
||||
$addValue = "?";
|
||||
}
|
||||
$Values .= $addValue;
|
||||
if ($this->OnDuplicate == "update") {
|
||||
if ($onDuplicate != "") $onDuplicate .= ", ";
|
||||
$onDuplicate .= $columnRef ."=" . $addValue;
|
||||
}
|
||||
$oneAdded = true;
|
||||
}
|
||||
}
|
||||
if (!$oneAdded) {
|
||||
$this->Statement = false;
|
||||
return;
|
||||
}
|
||||
$this->Statement .= $Columns . ") VALUES (" . $Values . ")";
|
||||
if ($this->OnDuplicate == "update") {
|
||||
$this->ParamTypes= array_merge($this->ParamTypes, $this->ParamTypes);
|
||||
$this->ParamValues = array_merge($this->ParamValues, $this->ParamValues);
|
||||
$this->ParamDefaults = array_merge($this->ParamDefaults, $this->ParamDefaults);
|
||||
$onDuplicate = " ON DUPLICATE KEY UPDATE " . $onDuplicate;
|
||||
}
|
||||
$this->Statement .= $onDuplicate;
|
||||
break;
|
||||
case "delete":
|
||||
$this->Statement = "DELETE FROM " . $this->Table;
|
||||
if (sizeof($this->ParamColumns) > 0) $this->Statement .= " WHERE ";
|
||||
for ($x=0; $x<sizeof($this->ParamColumns); $x++) {
|
||||
if ($x!=0) $this->Statement .= " AND ";
|
||||
$columnRef = $this->ParamColumns[$x][0];
|
||||
if (strpos($columnRef,"`") == false && strpos($columnRef,"(") == false) $columnRef = '`'.$columnRef.'`';
|
||||
$colPlaceholder = "?";
|
||||
$this->Statement .= $columnRef . " = " . $colPlaceholder;
|
||||
}
|
||||
break;
|
||||
}
|
||||
$this->setFilter();
|
||||
}
|
||||
|
||||
public function debugSQL() {
|
||||
$statement = $this->Statement;
|
||||
$paramLen = 1;
|
||||
for ($x=0; $x<sizeof($this->ParamValues); $x++) {
|
||||
if (is_array($this->ParamValues[$x])) $paramLen = sizeof($this->ParamValues[$x]);
|
||||
}
|
||||
for ($x=0; $x<$paramLen; $x++) {
|
||||
$params = ($this->getParams($x));
|
||||
$paramTypes = $params[0];
|
||||
$startStatement = "";
|
||||
$endStatement = $statement;
|
||||
for ($x=0; $x<strlen($paramTypes); $x++) {
|
||||
$pos = strpos($endStatement, "?");
|
||||
if ($pos !== false) {
|
||||
$replace = $this->getSQLValue($params[$x+1],$paramTypes[$x],true);
|
||||
$startStatement .= substr($endStatement,0,$pos) . $replace;
|
||||
$endStatement = substr($endStatement, $pos + 1);
|
||||
}
|
||||
}
|
||||
$statement = $startStatement . $endStatement;
|
||||
}
|
||||
$statement = $startStatement . $endStatement;
|
||||
return $statement;
|
||||
}
|
||||
|
||||
public function execute($allowTableOverwrite=false) {
|
||||
$shouldRun = true;
|
||||
$startStatement = $this->Statement;
|
||||
while ($this->incrementRepeat()) {
|
||||
if (sizeof($this->RepeatedParams) > 0) {
|
||||
if (!$this->checkRepeatConditions()) {
|
||||
continue;
|
||||
}
|
||||
$this->clearRepeatedFilters();
|
||||
$this->resetRepeated();
|
||||
}
|
||||
if (!$startStatement) {
|
||||
$this->clearTemporaryColumns();
|
||||
$this->createStatement();
|
||||
if (!$this->Statement) continue;
|
||||
if ((strtolower($this->UseAction) == "delete" || strtolower($this->UseAction) == "update") && strpos($this->Statement," WHERE ") === false && !$allowTableOverwrite) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (in_array("WA_SKIP",$this->ParamValues)) continue;
|
||||
if (!$this->Prepared) {
|
||||
$statement = $this->Statement;
|
||||
if (sizeof($this->ParamValues) > 0) {
|
||||
$paramLen = 1;
|
||||
for ($x=0; $x<sizeof($this->ParamValues); $x++) {
|
||||
if (is_array($this->ParamValues[$x])) $paramLen = sizeof($this->ParamValues[$x]);
|
||||
}
|
||||
for ($x=0; $x<$paramLen; $x++) {
|
||||
$params = ($this->getParams($x));
|
||||
$paramTypes = $params[0];
|
||||
$startStatement = "";
|
||||
$endStatement = $statement;
|
||||
for ($x=0; $x<strlen($paramTypes); $x++) {
|
||||
$pos = strpos($endStatement, "?");
|
||||
if ($pos !== false) {
|
||||
$replace = $this->getSQLValue($params[$x+1],$paramTypes[$x]);
|
||||
$startStatement .= substr($endStatement,0,$pos) . $replace;
|
||||
$endStatement = substr($endStatement, $pos + 1);
|
||||
}
|
||||
}
|
||||
$statement = $startStatement . $endStatement;
|
||||
}
|
||||
}
|
||||
$query = $this->Connection->query($statement);
|
||||
if ($query == false) {
|
||||
if ($this->Debug) {
|
||||
die($this->debugSQL() . "<BR><BR>" . mysqli_error($this->Connection));
|
||||
} else {
|
||||
if ($this->DieOnError) {
|
||||
die($this->ErrorMessage);
|
||||
} else {
|
||||
$this->Error = $this->debugSQL() . "<BR><BR>" . mysqli_error($this->Connection);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$query = false;
|
||||
}
|
||||
} else {
|
||||
if (sizeof($this->ParamTypes) && strpos($this->Statement,"?") !== false) {
|
||||
$query = $this->Connection->Prepare($this->Statement);
|
||||
if ($query == false) {
|
||||
if ($this->Debug) {
|
||||
die($this->debugSQL() . "<BR><BR>" . mysqli_error($this->Connection));
|
||||
} else {
|
||||
if ($this->DieOnError) {
|
||||
die($this->ErrorMessage);
|
||||
} else {
|
||||
$this->Error = $this->debugSQL() . "<BR><BR>" . mysqli_error($this->Connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
$paramLen = 1;
|
||||
for ($x=0; $x<sizeof($this->ParamValues); $x++) {
|
||||
if (is_array($this->ParamValues[$x])) $paramLen = sizeof($this->ParamValues[$x]);
|
||||
}
|
||||
for ($x=0; $x<$paramLen; $x++) {
|
||||
call_user_func_array(array($query, "bind_param"),$this->paramRefs($this->getParams($x)));
|
||||
$query->execute();
|
||||
if ($query->errno) {
|
||||
if ($this->Debug) {
|
||||
die($this->debugSQL() . "<BR><BR>" . $query->error);
|
||||
} else {
|
||||
if ($this->DieOnError) {
|
||||
die($this->ErrorMessage);
|
||||
} else {
|
||||
$this->Error = $this->debugSQL() . "<BR><BR>" . mysqli_error($this->Connection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$this->clearTemporaryFilters();
|
||||
} else {
|
||||
$query = $this->Connection->query($this->Statement);
|
||||
if ($query == false) {
|
||||
if ($this->Debug) {
|
||||
die($this->debugSQL() . "<BR><BR>" . mysqli_error($this->Connection));
|
||||
} else {
|
||||
if ($this->DieOnError) {
|
||||
die($this->ErrorMessage);
|
||||
} else {
|
||||
$this->Error = $this->debugSQL() . "<BR><BR>" . mysqli_error($this->Connection);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$query = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($this->SaveAs != "" && strtolower($this->UseAction) == "insert") {
|
||||
@session_start();
|
||||
$_SESSION[$this->SaveAs] = $query?$query->insert_id:$this->Connection->insert_id;
|
||||
}
|
||||
$this->AffectedRows = $query?$query->affected_rows:$this->Connection->affected_rows;
|
||||
$this->AffectedRows = ($this->AffectedRows===-1)?0:$this->AffectedRows;
|
||||
$this->InsertID = $query?$query->insert_id:$this->Connection->insert_id;
|
||||
$this->NumRows = $query?$query->num_rows:0;
|
||||
$this->ParamCount = $query?$query->param_count:0;
|
||||
$this->FieldCount = $query?$query->field_count:$this->Connection->field_count;
|
||||
if (!$this->Error) $this->Error = $query?$query->error:$this->Connection->error;
|
||||
$this->ErrorNo = $query?$query->errno:$this->Connection->errno;
|
||||
$this->ID = $query?$query->id:$this->Connection->thread_id;
|
||||
if ($query && method_exists($query,"close")) $query->close();
|
||||
}
|
||||
|
||||
|
||||
if (sizeof($this->RelationalRows)) {
|
||||
$this->addRelationalFilters();
|
||||
for ($x=0; $x<sizeof($this->RelationalRows); $x++) {
|
||||
if ($this->RelationalRows[$x][1] == false) {
|
||||
$CleanUpQuery = new WA_MySQLi_Query($this->Connection);
|
||||
$CleanUpQuery->Statement = "delete FROM " . $this->Table . " WHERE " . $this->RelationalKeyColumn . " = " . $this->RelationalRows[$x][2];
|
||||
$CleanUpQuery->execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private function getChildFilterFromRelational($row) {
|
||||
for ($x=0; $x<sizeof($this->ParamColumns); $x++) {
|
||||
if ($this->ParamColumns[$x][0] == $this->RelationalColumns[1]) {
|
||||
return array($this->RelationalColumns[1], "=", $this->ParamTypes[$x], $this->RelationalRows[$row][0], false, true);
|
||||
}
|
||||
}
|
||||
return array($this->RelationalColumns[0], "=", "i", "-1", false, true);
|
||||
}
|
||||
|
||||
public function getSalt() {
|
||||
$isStrong = false;
|
||||
$this->Salt = base64_encode(openssl_random_pseudo_bytes(openssl_cipher_iv_length($this->EncryptionAlgorithm),$isStrong));
|
||||
}
|
||||
|
||||
public function getEncryptedVal($val) {
|
||||
$retVal = $val;
|
||||
$salt = "";
|
||||
if ($this->Salt) $salt = base64_decode($this->Salt);
|
||||
if ($retVal !== "") {
|
||||
$retVal = base64_encode(openssl_encrypt($val,$this->EncryptionAlgorithm,$this->EncryptionKey, OPENSSL_RAW_DATA, $salt));
|
||||
}
|
||||
|
||||
return $retVal;
|
||||
}
|
||||
|
||||
private function getParentFilterFromRelational() {
|
||||
for ($x=0; $x<sizeof($this->ParamColumns); $x++) {
|
||||
if ($this->ParamColumns[$x][0] == $this->RelationalColumns[0]) {
|
||||
return array($this->RelationalColumns[0], "=", $this->ParamTypes[$x], $this->ParamValues[$x], false, true);
|
||||
}
|
||||
}
|
||||
return array($this->RelationalColumns[0], "=", "i", "-1", false, true);
|
||||
}
|
||||
|
||||
private function getParams($index) {
|
||||
$useParams = array();
|
||||
$useTypes = array();
|
||||
for ($x=0; $x<sizeof($this->ParamValues); $x++) {
|
||||
$paramVal = is_array($this->ParamValues[$x])?$this->ParamValues[$x][$index]:$this->ParamValues[$x];
|
||||
if (!(($paramVal === "" || $paramVal === null || $paramVal === false) && ($this->ParamDefaults[$x] == "WA_DEFAULT" || $this->ParamDefaults[$x] == "WA_IGNORE" || $this->ParamDefaults[$x] == "WA_SKIP" || $this->ParamDefaults[$x] == "WA_TIMESTAMP"))) {
|
||||
$useParams[] = $paramVal;
|
||||
$typesVal = $this->ParamTypes[$x];
|
||||
if ($typesVal == "t" || $typesVal == "c" || $typesVal == "b" || $typesVal == "e" || $typesVal == "y") {
|
||||
$typesVal = "s";
|
||||
} else if ($typesVal == "n" || $typesVal == "z") {
|
||||
$typesVal = "i";
|
||||
} else if ($typesVal != "i" && $typesVal != "d" && $typesVal != "s" && $typesVal != "b") {
|
||||
$typesVal = "s";
|
||||
}
|
||||
$useTypes[] = $typesVal;
|
||||
}
|
||||
}
|
||||
return array_merge(array(implode("",$useTypes)), $useParams);
|
||||
}
|
||||
|
||||
public function getSelected() {
|
||||
if (!$this->SelectedResult) {
|
||||
$RelationalRS = new WA_MySQLi_RS("RelationalRS",$this->Connection,0);
|
||||
$RelationalRS->setQuery("SELECT " . $this->RelationalColumns[1] . ($this->RelationalKeyColumn?", " .$this->RelationalKeyColumn:""). " FROM " . $this->Table);
|
||||
$RelationalRS->FilterValues = array($this->getParentFilterFromRelational());
|
||||
$RelationalRS->setFilter();
|
||||
$RelationalRS->execute();
|
||||
$this->SelectedResult = $RelationalRS;
|
||||
}
|
||||
return $this->SelectedResult->getColumnArray($this->RelationalColumns[1]);
|
||||
}
|
||||
|
||||
public function getSQLValue($val,$type,$forDebug=false) {
|
||||
if (is_null($val)) {
|
||||
$retval = "NULL";
|
||||
} else if ($type == 'i') {
|
||||
if (!$forDebug && strval(intval($val)) != $val) {
|
||||
if ($this->Debug) {
|
||||
die($this->debugSQL() . "<BR><BR>" . "Truncated incorrect INTEGER value: " . $val);
|
||||
} else {
|
||||
die($this->ErrorMessage);
|
||||
}
|
||||
}
|
||||
$retval = intval($val);
|
||||
} else if ($type == 'd') {
|
||||
if (!$forDebug && strval(floatval($val)) != $val) {
|
||||
if ($this->Debug) {
|
||||
die($this->debugSQL() . "<BR><BR>" . "Truncated incorrect DOUBLE value: " . $val);
|
||||
} else {
|
||||
die($this->ErrorMessage);
|
||||
}
|
||||
}
|
||||
$retval = floatval($val);
|
||||
} else {
|
||||
$retval = "'" . mysqli_real_escape_string($this->Connection,$val) . "'";
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
private function incrementRepeat() {
|
||||
$this->RepeatIndex++;
|
||||
$totalRepeats = 1;
|
||||
// check action
|
||||
if ($this->Action == "relational" && sizeof($this->RepeatedParams)>0) {
|
||||
$totalRepeats = sizeof($this->RepeatedParams[0][1]);
|
||||
} else {
|
||||
for ($x=0; $x<sizeof($this->RepeatedParams); $x++) {
|
||||
$totalRepeats *= sizeof($this->RepeatedParams[$x][1]);
|
||||
}
|
||||
}
|
||||
return ($this->RepeatIndex <= $totalRepeats);
|
||||
}
|
||||
|
||||
public function isBound($column) {
|
||||
for ($x=0; $x<sizeof($this->ParamColumns); $x++) {
|
||||
if ($this->ParamColumns[$x][0] == $column) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public function paramRefs($arr) {
|
||||
if (strnatcmp(phpversion(),'5.3') >= 0) {
|
||||
$refs = array();
|
||||
foreach($arr as $key => $value) $refs[$key] = &$arr[$key];
|
||||
return $refs;
|
||||
}
|
||||
return $arr;
|
||||
}
|
||||
|
||||
public function redirect($url,$keepQuerystring=false) {
|
||||
if ($url) {
|
||||
$url = str_replace("[InsertID]",$this->InsertID,$url);
|
||||
$url = str_replace("[Insert_ID]",$this->InsertID,$url);
|
||||
if ($keepQuerystring) {
|
||||
if ($this->JavascriptRedirect) {
|
||||
echo('<script>document.location.href="'.$this->addQuerystring($url).'";</script>');
|
||||
} else {
|
||||
header("location: " . $this->addQuerystring($url));
|
||||
}
|
||||
}
|
||||
if ($this->JavascriptRedirect) {
|
||||
echo('<script>document.location.href="'.$url.'";</script>');
|
||||
} else {
|
||||
header("location: " . $url);
|
||||
}
|
||||
die();
|
||||
}
|
||||
}
|
||||
|
||||
private function resetCombinations($arrays, $i = 0) {
|
||||
if (!isset($arrays[$i])) {
|
||||
return array();
|
||||
}
|
||||
if ($i == count($arrays) - 1) {
|
||||
return $arrays[$i];
|
||||
}
|
||||
if ($this->Action === "relational") {
|
||||
for ($x=0; $x<sizeof($arrays[0]); $x++) {
|
||||
$row = array();
|
||||
for ($y=0; $y<sizeof($arrays); $y++) {
|
||||
$row[] = $arrays[$y][$x];
|
||||
}
|
||||
$result[] = $row;
|
||||
}
|
||||
} else {
|
||||
$tmp = $this->resetCombinations($arrays, $i + 1);
|
||||
$result = array();
|
||||
foreach ($arrays[$i] as $v) {
|
||||
foreach ($tmp as $t) {
|
||||
$result[] = is_array($t) ?
|
||||
array_merge(array($v), $t) :
|
||||
array($v, $t);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
public function resetRepeated() {
|
||||
$index = 0;
|
||||
$combinations = array();
|
||||
for ($x=0; $x<sizeof($this->RepeatedParams); $x++) {
|
||||
$combinations[] = $this->RepeatedParams[$x][1];
|
||||
}
|
||||
$allParams = $this->resetCombinations($combinations);
|
||||
for ($x=0; $x<sizeof($this->RepeatedParams); $x++) {
|
||||
$newVal = $allParams[$this->RepeatIndex-1];
|
||||
if (is_array($newVal)) $newVal = $newVal[$x];
|
||||
if ($this->RepeatedParams[$x][2]) {
|
||||
$this->bindParam($this->ParamColumns[$this->RepeatedParams[$x][0]],$this->ParamTypes[$this->RepeatedParams[$x][0]],$newVal,$this->ParamDefaults[$this->RepeatedParams[$x][0]]);
|
||||
} else {
|
||||
$this->ParamValues[$this->RepeatedParams[$x][0]] = $this->bindDefault($this->ParamTypes[$this->RepeatedParams[$x][0]],$newVal,$this->ParamDefaults[$this->RepeatedParams[$x][0]]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function saveInSession($varname) {
|
||||
$this->SaveAs = $varname;
|
||||
}
|
||||
|
||||
public function setFilter() {
|
||||
if (sizeof($this->FilterValues) > 0) {
|
||||
$this->Statement .= " WHERE ";
|
||||
for ($x=0; $x<sizeof($this->FilterValues); $x++) {
|
||||
if (!is_array($this->FilterValues[$x][3])) {
|
||||
$filterValues = array($this->FilterValues[$x][3]);
|
||||
} else {
|
||||
$filterValues = $this->FilterValues[$x][3];
|
||||
}
|
||||
for ($y=0; $y<sizeof($filterValues); $y++) {
|
||||
if ($x>0 && $y==0) $this->Statement .= " AND ";
|
||||
if (sizeof($filterValues)>1 && $y==0) $this->Statement .= "(";
|
||||
if ($y>0) $this->Statement .= ($this->FilterValues[$x][1] == "<>" || strtoupper($this->FilterValues[$x][1]) == "IS NOT")?" AND ":" OR ";
|
||||
if ($this->FilterValues[$x][4]) $this->RepeatedParams[] = array(sizeof($this->ParamValues),$this->FilterValues[$x][4],true);
|
||||
$columnRef = $this->FilterValues[$x][0];
|
||||
if (strpos($columnRef,"`") == false && strpos($columnRef,"(") == false) $columnRef = '`'.$columnRef.'`';
|
||||
if (strtoupper($this->FilterValues[$x][1]) == "IS" || strtoupper($this->FilterValues[$x][1]) == "IS NOT") {
|
||||
$this->Statement .= $columnRef . " " . $this->FilterValues[$x][1] . " NULL";
|
||||
} else {
|
||||
$this->Statement .= $columnRef . " " . $this->FilterValues[$x][1] . " ?";
|
||||
$this->bindParam($this->FilterValues[$x][2], strval($filterValues[$y]), "");
|
||||
}
|
||||
}
|
||||
if (sizeof($filterValues)>1) $this->Statement .= ")";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function setQuery($statement) {
|
||||
$this->Statement = $statement;
|
||||
}
|
||||
|
||||
public function setRepeatCondition($conditionalField) {
|
||||
$this->RepeatConditions[] = $conditionalField;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
Binary file not shown.
|
After Width: | Height: | Size: 6.7 KiB |
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user