First commit, current version 0.2
This commit is contained in:
commit
872acdbc01
353 changed files with 45771 additions and 0 deletions
0
onyx2/ban.list
Normal file
0
onyx2/ban.list
Normal file
0
onyx2/cache/templates/cache/cache
vendored
Normal file
0
onyx2/cache/templates/cache/cache
vendored
Normal file
0
onyx2/cache/templates/compile/compile
vendored
Normal file
0
onyx2/cache/templates/compile/compile
vendored
Normal file
80
onyx2/config/root.sample.xml
Normal file
80
onyx2/config/root.sample.xml
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configs active="1" root="/var/www/pa4home/htdocs/" cache="1">
|
||||
<config match="ajax.php">
|
||||
<env option="header">
|
||||
<env option="Content-Type">text/xml;charset=utf-8</env>
|
||||
</env>
|
||||
</config>
|
||||
<config match="index.php">
|
||||
<env option="header">
|
||||
<env option="Content-Type">text/html;charset=utf-8</env>
|
||||
</env>
|
||||
</config>
|
||||
<config match="w/4eduel.php">
|
||||
<var name="chrono"></var>
|
||||
<env option="header">
|
||||
<env option="Content-Type">text/html;charset=utf-8</env>
|
||||
</env>
|
||||
</config>
|
||||
<config match="*">
|
||||
<var name="version">1.0 Pré-alpha</var>
|
||||
<var name="first_page">index.php</var> <!-- Page principale -->
|
||||
<var name="url_images"></var> <!-- Adresse du serveur d'images et de contenu -->
|
||||
|
||||
<var name="db_prefix"></var> <!-- Préfixe des tables dans la base de données -->
|
||||
|
||||
<var name="chrono"><![CDATA[<!--Page générée en: $ secondes.-->]]></var>
|
||||
|
||||
<env option="auth">0</env>
|
||||
<env option="timezone">Europe/Paris</env>
|
||||
<env option="ignore_user_abort">1</env>
|
||||
<env option="error_level">6143</env>
|
||||
<env option="ini">
|
||||
<env option="allow_url_fopen">0</env>
|
||||
<env option="allow_url_include">0</env>
|
||||
<env option="display_errors">1</env>
|
||||
<env option="display_startup_errors">1</env>
|
||||
<env option="magic_quotes_runtime">0</env>
|
||||
<env option="magic_quotes_sybase">0</env>
|
||||
<env option="memory_limit">64M</env>
|
||||
<env option="log_errors">1</env>
|
||||
</env>
|
||||
<env option="log_php">1</env>
|
||||
<env option="locale">
|
||||
<env option="0">fr_FR.UTF8</env>
|
||||
<env option="1">fr.UTF8</env>
|
||||
<env option="2">fr_FR.UTF-8</env>
|
||||
<env option="3">fr.UTF-8</env>
|
||||
</env>
|
||||
|
||||
<module name="db">
|
||||
<option name="type">mysql</option>
|
||||
<option name="profile">default</option>
|
||||
<option name="log">0</option>
|
||||
<option name="crypt"></option>
|
||||
<option name="no_connection"><![CDATA[Connexion à la base de donnée impossible]]></option>
|
||||
</module>
|
||||
|
||||
<module name="session">
|
||||
<option name="active">1</option>
|
||||
<option name="time">3600</option>
|
||||
<option name="maxip">20</option>
|
||||
<option name="cookie">pasession</option>
|
||||
<option name="db">
|
||||
<option name="table">sessions</option>
|
||||
</option>
|
||||
</module>
|
||||
|
||||
<!--<module name="templates">
|
||||
<option name="tpl"></option>
|
||||
<option name="compile">modules/templates/compile/</option>
|
||||
<option name="config">cache/templates/config/</option>
|
||||
<option name="cache">cache/templates/cache/</option>
|
||||
</module>-->
|
||||
|
||||
<!--<module name="fermerServeur">
|
||||
<option name="type">1</option><!- 1: mise à jour prévue ; 2: mise à jour exceptionnelle ->
|
||||
<option name="temps">900</option> <!- temps en secondes ->
|
||||
</module>-->
|
||||
</config>
|
||||
</configs>
|
||||
10
onyx2/db/default.profile.php
Normal file
10
onyx2/db/default.profile.php
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
$___profile['db'] = 'pa4home';
|
||||
$___profile['host'] = 'localhost';
|
||||
$___profile['user'] = 'root';
|
||||
$___profile['pass'] = '';
|
||||
|
||||
?>
|
||||
806
onyx2/include/JSON.php
Normal file
806
onyx2/include/JSON.php
Normal file
|
|
@ -0,0 +1,806 @@
|
|||
<?php
|
||||
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
|
||||
|
||||
/**
|
||||
* Converts to and from JSON format.
|
||||
*
|
||||
* JSON (JavaScript Object Notation) is a lightweight data-interchange
|
||||
* format. It is easy for humans to read and write. It is easy for machines
|
||||
* to parse and generate. It is based on a subset of the JavaScript
|
||||
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
|
||||
* This feature can also be found in Python. JSON is a text format that is
|
||||
* completely language independent but uses conventions that are familiar
|
||||
* to programmers of the C-family of languages, including C, C++, C#, Java,
|
||||
* JavaScript, Perl, TCL, and many others. These properties make JSON an
|
||||
* ideal data-interchange language.
|
||||
*
|
||||
* This package provides a simple encoder and decoder for JSON notation. It
|
||||
* is intended for use with client-side Javascript applications that make
|
||||
* use of HTTPRequest to perform server communication functions - data can
|
||||
* be encoded into JSON notation for use in a client-side javascript, or
|
||||
* decoded from incoming Javascript requests. JSON format is native to
|
||||
* Javascript, and can be directly eval()'ed with no further parsing
|
||||
* overhead
|
||||
*
|
||||
* All strings should be in ASCII or UTF-8 format!
|
||||
*
|
||||
* LICENSE: Redistribution and use in source and binary forms, with or
|
||||
* without modification, are permitted provided that the following
|
||||
* conditions are met: Redistributions of source code must retain the
|
||||
* above copyright notice, this list of conditions and the following
|
||||
* disclaimer. Redistributions in binary form must reproduce the above
|
||||
* copyright notice, this list of conditions and the following disclaimer
|
||||
* in the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
|
||||
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
|
||||
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
|
||||
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
|
||||
* DAMAGE.
|
||||
*
|
||||
* @category
|
||||
* @package Services_JSON
|
||||
* @author Michal Migurski <mike-json@teczno.com>
|
||||
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
|
||||
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
|
||||
* @copyright 2005 Michal Migurski
|
||||
* @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
|
||||
* @license http://www.opensource.org/licenses/bsd-license.php
|
||||
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
|
||||
*/
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_SLICE', 1);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_STR', 2);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_ARR', 3);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_OBJ', 4);
|
||||
|
||||
/**
|
||||
* Marker constant for Services_JSON::decode(), used to flag stack state
|
||||
*/
|
||||
define('SERVICES_JSON_IN_CMT', 5);
|
||||
|
||||
/**
|
||||
* Behavior switch for Services_JSON::decode()
|
||||
*/
|
||||
define('SERVICES_JSON_LOOSE_TYPE', 16);
|
||||
|
||||
/**
|
||||
* Behavior switch for Services_JSON::decode()
|
||||
*/
|
||||
define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
|
||||
|
||||
/**
|
||||
* Converts to and from JSON format.
|
||||
*
|
||||
* Brief example of use:
|
||||
*
|
||||
* <code>
|
||||
* // create a new instance of Services_JSON
|
||||
* $json = new Services_JSON();
|
||||
*
|
||||
* // convert a complexe value to JSON notation, and send it to the browser
|
||||
* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
|
||||
* $output = $json->encode($value);
|
||||
*
|
||||
* print($output);
|
||||
* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
|
||||
*
|
||||
* // accept incoming POST data, assumed to be in JSON notation
|
||||
* $input = file_get_contents('php://input', 1000000);
|
||||
* $value = $json->decode($input);
|
||||
* </code>
|
||||
*/
|
||||
class Services_JSON
|
||||
{
|
||||
/**
|
||||
* constructs a new JSON instance
|
||||
*
|
||||
* @param int $use object behavior flags; combine with boolean-OR
|
||||
*
|
||||
* possible values:
|
||||
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
|
||||
* "{...}" syntax creates associative arrays
|
||||
* instead of objects in decode().
|
||||
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
|
||||
* Values which can't be encoded (e.g. resources)
|
||||
* appear as NULL instead of throwing errors.
|
||||
* By default, a deeply-nested resource will
|
||||
* bubble up with an error, so all return values
|
||||
* from encode() should be checked with isError()
|
||||
*/
|
||||
function Services_JSON($use = 0)
|
||||
{
|
||||
$this->use = $use;
|
||||
}
|
||||
|
||||
/**
|
||||
* convert a string from one UTF-16 char to one UTF-8 char
|
||||
*
|
||||
* Normally should be handled by mb_convert_encoding, but
|
||||
* provides a slower PHP-only method for installations
|
||||
* that lack the multibye string extension.
|
||||
*
|
||||
* @param string $utf16 UTF-16 character
|
||||
* @return string UTF-8 character
|
||||
* @access private
|
||||
*/
|
||||
function utf162utf8($utf16)
|
||||
{
|
||||
// oh please oh please oh please oh please oh please
|
||||
if(function_exists('mb_convert_encoding')) {
|
||||
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
|
||||
}
|
||||
|
||||
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
|
||||
|
||||
switch(true) {
|
||||
case ((0x7F & $bytes) == $bytes):
|
||||
// this case should never be reached, because we are in ASCII range
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0x7F & $bytes);
|
||||
|
||||
case (0x07FF & $bytes) == $bytes:
|
||||
// return a 2-byte UTF-8 character
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0xC0 | (($bytes >> 6) & 0x1F))
|
||||
. chr(0x80 | ($bytes & 0x3F));
|
||||
|
||||
case (0xFFFF & $bytes) == $bytes:
|
||||
// return a 3-byte UTF-8 character
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0xE0 | (($bytes >> 12) & 0x0F))
|
||||
. chr(0x80 | (($bytes >> 6) & 0x3F))
|
||||
. chr(0x80 | ($bytes & 0x3F));
|
||||
}
|
||||
|
||||
// ignoring UTF-32 for now, sorry
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* convert a string from one UTF-8 char to one UTF-16 char
|
||||
*
|
||||
* Normally should be handled by mb_convert_encoding, but
|
||||
* provides a slower PHP-only method for installations
|
||||
* that lack the multibye string extension.
|
||||
*
|
||||
* @param string $utf8 UTF-8 character
|
||||
* @return string UTF-16 character
|
||||
* @access private
|
||||
*/
|
||||
function utf82utf16($utf8)
|
||||
{
|
||||
// oh please oh please oh please oh please oh please
|
||||
if(function_exists('mb_convert_encoding')) {
|
||||
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
|
||||
}
|
||||
|
||||
switch(strlen($utf8)) {
|
||||
case 1:
|
||||
// this case should never be reached, because we are in ASCII range
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return $utf8;
|
||||
|
||||
case 2:
|
||||
// return a UTF-16 character from a 2-byte UTF-8 char
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr(0x07 & (ord($utf8{0}) >> 2))
|
||||
. chr((0xC0 & (ord($utf8{0}) << 6))
|
||||
| (0x3F & ord($utf8{1})));
|
||||
|
||||
case 3:
|
||||
// return a UTF-16 character from a 3-byte UTF-8 char
|
||||
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
return chr((0xF0 & (ord($utf8{0}) << 4))
|
||||
| (0x0F & (ord($utf8{1}) >> 2)))
|
||||
. chr((0xC0 & (ord($utf8{1}) << 6))
|
||||
| (0x7F & ord($utf8{2})));
|
||||
}
|
||||
|
||||
// ignoring UTF-32 for now, sorry
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* encodes an arbitrary variable into JSON format
|
||||
*
|
||||
* @param mixed $var any number, boolean, string, array, or object to be encoded.
|
||||
* see argument 1 to Services_JSON() above for array-parsing behavior.
|
||||
* if var is a strng, note that encode() always expects it
|
||||
* to be in ASCII or UTF-8 format!
|
||||
*
|
||||
* @return mixed JSON string representation of input var or an error if a problem occurs
|
||||
* @access public
|
||||
*/
|
||||
function encode($var)
|
||||
{
|
||||
switch (gettype($var)) {
|
||||
case 'boolean':
|
||||
return $var ? 'true' : 'false';
|
||||
|
||||
case 'NULL':
|
||||
return 'null';
|
||||
|
||||
case 'integer':
|
||||
return (int) $var;
|
||||
|
||||
case 'double':
|
||||
case 'float':
|
||||
return (float) $var;
|
||||
|
||||
case 'string':
|
||||
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
|
||||
$ascii = '';
|
||||
$strlen_var = strlen($var);
|
||||
|
||||
/*
|
||||
* Iterate over every character in the string,
|
||||
* escaping with a slash or encoding to UTF-8 where necessary
|
||||
*/
|
||||
for ($c = 0; $c < $strlen_var; ++$c) {
|
||||
|
||||
$ord_var_c = ord($var{$c});
|
||||
|
||||
switch (true) {
|
||||
case $ord_var_c == 0x08:
|
||||
$ascii .= '\b';
|
||||
break;
|
||||
case $ord_var_c == 0x09:
|
||||
$ascii .= '\t';
|
||||
break;
|
||||
case $ord_var_c == 0x0A:
|
||||
$ascii .= '\n';
|
||||
break;
|
||||
case $ord_var_c == 0x0C:
|
||||
$ascii .= '\f';
|
||||
break;
|
||||
case $ord_var_c == 0x0D:
|
||||
$ascii .= '\r';
|
||||
break;
|
||||
|
||||
case $ord_var_c == 0x22:
|
||||
case $ord_var_c == 0x2F:
|
||||
case $ord_var_c == 0x5C:
|
||||
// double quote, slash, slosh
|
||||
$ascii .= '\\'.$var{$c};
|
||||
break;
|
||||
|
||||
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
|
||||
// characters U-00000000 - U-0000007F (same as ASCII)
|
||||
$ascii .= $var{$c};
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xE0) == 0xC0):
|
||||
// characters U-00000080 - U-000007FF, mask 110XXXXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
|
||||
$c += 1;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xF0) == 0xE0):
|
||||
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}));
|
||||
$c += 2;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xF8) == 0xF0):
|
||||
// characters U-00010000 - U-001FFFFF, mask 11110XXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}));
|
||||
$c += 3;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xFC) == 0xF8):
|
||||
// characters U-00200000 - U-03FFFFFF, mask 111110XX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}),
|
||||
ord($var{$c + 4}));
|
||||
$c += 4;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
|
||||
case (($ord_var_c & 0xFE) == 0xFC):
|
||||
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$char = pack('C*', $ord_var_c,
|
||||
ord($var{$c + 1}),
|
||||
ord($var{$c + 2}),
|
||||
ord($var{$c + 3}),
|
||||
ord($var{$c + 4}),
|
||||
ord($var{$c + 5}));
|
||||
$c += 5;
|
||||
$utf16 = $this->utf82utf16($char);
|
||||
$ascii .= sprintf('\u%04s', bin2hex($utf16));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return '"'.$ascii.'"';
|
||||
|
||||
case 'array':
|
||||
/*
|
||||
* As per JSON spec if any array key is not an integer
|
||||
* we must treat the the whole array as an object. We
|
||||
* also try to catch a sparsely populated associative
|
||||
* array with numeric keys here because some JS engines
|
||||
* will create an array with empty indexes up to
|
||||
* max_index which can cause memory issues and because
|
||||
* the keys, which may be relevant, will be remapped
|
||||
* otherwise.
|
||||
*
|
||||
* As per the ECMA and JSON specification an object may
|
||||
* have any string as a property. Unfortunately due to
|
||||
* a hole in the ECMA specification if the key is a
|
||||
* ECMA reserved word or starts with a digit the
|
||||
* parameter is only accessible using ECMAScript's
|
||||
* bracket notation.
|
||||
*/
|
||||
|
||||
// treat as a JSON object
|
||||
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
|
||||
$properties = array_map(array($this, 'name_value'),
|
||||
array_keys($var),
|
||||
array_values($var));
|
||||
|
||||
foreach($properties as $property) {
|
||||
if(Services_JSON::isError($property)) {
|
||||
return $property;
|
||||
}
|
||||
}
|
||||
|
||||
return '{' . join(',', $properties) . '}';
|
||||
}
|
||||
|
||||
// treat it like a regular array
|
||||
$elements = array_map(array($this, 'encode'), $var);
|
||||
|
||||
foreach($elements as $element) {
|
||||
if(Services_JSON::isError($element)) {
|
||||
return $element;
|
||||
}
|
||||
}
|
||||
|
||||
return '[' . join(',', $elements) . ']';
|
||||
|
||||
case 'object':
|
||||
$vars = get_object_vars($var);
|
||||
|
||||
$properties = array_map(array($this, 'name_value'),
|
||||
array_keys($vars),
|
||||
array_values($vars));
|
||||
|
||||
foreach($properties as $property) {
|
||||
if(Services_JSON::isError($property)) {
|
||||
return $property;
|
||||
}
|
||||
}
|
||||
|
||||
return '{' . join(',', $properties) . '}';
|
||||
|
||||
default:
|
||||
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
|
||||
? 'null'
|
||||
: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* array-walking function for use in generating JSON-formatted name-value pairs
|
||||
*
|
||||
* @param string $name name of key to use
|
||||
* @param mixed $value reference to an array element to be encoded
|
||||
*
|
||||
* @return string JSON-formatted name-value pair, like '"name":value'
|
||||
* @access private
|
||||
*/
|
||||
function name_value($name, $value)
|
||||
{
|
||||
$encoded_value = $this->encode($value);
|
||||
|
||||
if(Services_JSON::isError($encoded_value)) {
|
||||
return $encoded_value;
|
||||
}
|
||||
|
||||
return $this->encode(strval($name)) . ':' . $encoded_value;
|
||||
}
|
||||
|
||||
/**
|
||||
* reduce a string by removing leading and trailing comments and whitespace
|
||||
*
|
||||
* @param $str string string value to strip of comments and whitespace
|
||||
*
|
||||
* @return string string value stripped of comments and whitespace
|
||||
* @access private
|
||||
*/
|
||||
function reduce_string($str)
|
||||
{
|
||||
$str = preg_replace(array(
|
||||
|
||||
// eliminate single line comments in '// ...' form
|
||||
'#^\s*//(.+)$#m',
|
||||
|
||||
// eliminate multi-line comments in '/* ... */' form, at start of string
|
||||
'#^\s*/\*(.+)\*/#Us',
|
||||
|
||||
// eliminate multi-line comments in '/* ... */' form, at end of string
|
||||
'#/\*(.+)\*/\s*$#Us'
|
||||
|
||||
), '', $str);
|
||||
|
||||
// eliminate extraneous space
|
||||
return trim($str);
|
||||
}
|
||||
|
||||
/**
|
||||
* decodes a JSON string into appropriate variable
|
||||
*
|
||||
* @param string $str JSON-formatted string
|
||||
*
|
||||
* @return mixed number, boolean, string, array, or object
|
||||
* corresponding to given JSON input string.
|
||||
* See argument 1 to Services_JSON() above for object-output behavior.
|
||||
* Note that decode() always returns strings
|
||||
* in ASCII or UTF-8 format!
|
||||
* @access public
|
||||
*/
|
||||
function decode($str)
|
||||
{
|
||||
$str = $this->reduce_string($str);
|
||||
|
||||
switch (strtolower($str)) {
|
||||
case 'true':
|
||||
return true;
|
||||
|
||||
case 'false':
|
||||
return false;
|
||||
|
||||
case 'null':
|
||||
return null;
|
||||
|
||||
default:
|
||||
$m = array();
|
||||
|
||||
if (is_numeric($str)) {
|
||||
// Lookie-loo, it's a number
|
||||
|
||||
// This would work on its own, but I'm trying to be
|
||||
// good about returning integers where appropriate:
|
||||
// return (float)$str;
|
||||
|
||||
// Return float or int, as appropriate
|
||||
return ((float)$str == (integer)$str)
|
||||
? (integer)$str
|
||||
: (float)$str;
|
||||
|
||||
} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
|
||||
// STRINGS RETURNED IN UTF-8 FORMAT
|
||||
$delim = substr($str, 0, 1);
|
||||
$chrs = substr($str, 1, -1);
|
||||
$utf8 = '';
|
||||
$strlen_chrs = strlen($chrs);
|
||||
|
||||
for ($c = 0; $c < $strlen_chrs; ++$c) {
|
||||
|
||||
$substr_chrs_c_2 = substr($chrs, $c, 2);
|
||||
$ord_chrs_c = ord($chrs{$c});
|
||||
|
||||
switch (true) {
|
||||
case $substr_chrs_c_2 == '\b':
|
||||
$utf8 .= chr(0x08);
|
||||
++$c;
|
||||
break;
|
||||
case $substr_chrs_c_2 == '\t':
|
||||
$utf8 .= chr(0x09);
|
||||
++$c;
|
||||
break;
|
||||
case $substr_chrs_c_2 == '\n':
|
||||
$utf8 .= chr(0x0A);
|
||||
++$c;
|
||||
break;
|
||||
case $substr_chrs_c_2 == '\f':
|
||||
$utf8 .= chr(0x0C);
|
||||
++$c;
|
||||
break;
|
||||
case $substr_chrs_c_2 == '\r':
|
||||
$utf8 .= chr(0x0D);
|
||||
++$c;
|
||||
break;
|
||||
|
||||
case $substr_chrs_c_2 == '\\"':
|
||||
case $substr_chrs_c_2 == '\\\'':
|
||||
case $substr_chrs_c_2 == '\\\\':
|
||||
case $substr_chrs_c_2 == '\\/':
|
||||
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
|
||||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
|
||||
$utf8 .= $chrs{++$c};
|
||||
}
|
||||
break;
|
||||
|
||||
case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
|
||||
// single, escaped unicode character
|
||||
$utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
|
||||
. chr(hexdec(substr($chrs, ($c + 4), 2)));
|
||||
$utf8 .= $this->utf162utf8($utf16);
|
||||
$c += 5;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
|
||||
$utf8 .= $chrs{$c};
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xE0) == 0xC0:
|
||||
// characters U-00000080 - U-000007FF, mask 110XXXXX
|
||||
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= substr($chrs, $c, 2);
|
||||
++$c;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xF0) == 0xE0:
|
||||
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= substr($chrs, $c, 3);
|
||||
$c += 2;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xF8) == 0xF0:
|
||||
// characters U-00010000 - U-001FFFFF, mask 11110XXX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= substr($chrs, $c, 4);
|
||||
$c += 3;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xFC) == 0xF8:
|
||||
// characters U-00200000 - U-03FFFFFF, mask 111110XX
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= substr($chrs, $c, 5);
|
||||
$c += 4;
|
||||
break;
|
||||
|
||||
case ($ord_chrs_c & 0xFE) == 0xFC:
|
||||
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
|
||||
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
|
||||
$utf8 .= substr($chrs, $c, 6);
|
||||
$c += 5;
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return $utf8;
|
||||
|
||||
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
|
||||
// array, or object notation
|
||||
|
||||
if ($str{0} == '[') {
|
||||
$stk = array(SERVICES_JSON_IN_ARR);
|
||||
$arr = array();
|
||||
} else {
|
||||
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
||||
$stk = array(SERVICES_JSON_IN_OBJ);
|
||||
$obj = array();
|
||||
} else {
|
||||
$stk = array(SERVICES_JSON_IN_OBJ);
|
||||
$obj = new stdClass();
|
||||
}
|
||||
}
|
||||
|
||||
array_push($stk, array('what' => SERVICES_JSON_SLICE,
|
||||
'where' => 0,
|
||||
'delim' => false));
|
||||
|
||||
$chrs = substr($str, 1, -1);
|
||||
$chrs = $this->reduce_string($chrs);
|
||||
|
||||
if ($chrs == '') {
|
||||
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
||||
return $arr;
|
||||
|
||||
} else {
|
||||
return $obj;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//print("\nparsing {$chrs}\n");
|
||||
|
||||
$strlen_chrs = strlen($chrs);
|
||||
|
||||
for ($c = 0; $c <= $strlen_chrs; ++$c) {
|
||||
|
||||
$top = end($stk);
|
||||
$substr_chrs_c_2 = substr($chrs, $c, 2);
|
||||
|
||||
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
|
||||
// found a comma that is not inside a string, array, etc.,
|
||||
// OR we've reached the end of the character list
|
||||
$slice = substr($chrs, $top['where'], ($c - $top['where']));
|
||||
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
|
||||
//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
||||
// we are in an array, so just push an element onto the stack
|
||||
array_push($arr, $this->decode($slice));
|
||||
|
||||
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
|
||||
// we are in an object, so figure
|
||||
// out the property name and set an
|
||||
// element in an associative array,
|
||||
// for now
|
||||
$parts = array();
|
||||
|
||||
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
|
||||
// "name":value pair
|
||||
$key = $this->decode($parts[1]);
|
||||
$val = $this->decode($parts[2]);
|
||||
|
||||
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
||||
$obj[$key] = $val;
|
||||
} else {
|
||||
$obj->$key = $val;
|
||||
}
|
||||
} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
|
||||
// name:value pair, where name is unquoted
|
||||
$key = $parts[1];
|
||||
$val = $this->decode($parts[2]);
|
||||
|
||||
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
|
||||
$obj[$key] = $val;
|
||||
} else {
|
||||
$obj->$key = $val;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
|
||||
// found a quote, and we are not inside a string
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
|
||||
//print("Found start of string at {$c}\n");
|
||||
|
||||
} elseif (($chrs{$c} == $top['delim']) &&
|
||||
($top['what'] == SERVICES_JSON_IN_STR) &&
|
||||
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
|
||||
// found a quote, we're in a string, and it's not escaped
|
||||
// we know that it's not escaped becase there is _not_ an
|
||||
// odd number of backslashes at the end of the string so far
|
||||
array_pop($stk);
|
||||
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
|
||||
|
||||
} elseif (($chrs{$c} == '[') &&
|
||||
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
||||
// found a left-bracket, and we are in an array, object, or slice
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
|
||||
//print("Found start of array at {$c}\n");
|
||||
|
||||
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
|
||||
// found a right-bracket, and we're in an array
|
||||
array_pop($stk);
|
||||
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
} elseif (($chrs{$c} == '{') &&
|
||||
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
||||
// found a left-brace, and we are in an array, object, or slice
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
|
||||
//print("Found start of object at {$c}\n");
|
||||
|
||||
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
|
||||
// found a right-brace, and we're in an object
|
||||
array_pop($stk);
|
||||
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
} elseif (($substr_chrs_c_2 == '/*') &&
|
||||
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
|
||||
// found a comment start, and we are in an array, object, or slice
|
||||
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
|
||||
$c++;
|
||||
//print("Found start of comment at {$c}\n");
|
||||
|
||||
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
|
||||
// found a comment end, and we're in one now
|
||||
array_pop($stk);
|
||||
$c++;
|
||||
|
||||
for ($i = $top['where']; $i <= $c; ++$i)
|
||||
$chrs = substr_replace($chrs, ' ', $i, 1);
|
||||
|
||||
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (reset($stk) == SERVICES_JSON_IN_ARR) {
|
||||
return $arr;
|
||||
|
||||
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
|
||||
return $obj;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @todo Ultimately, this should just call PEAR::isError()
|
||||
*/
|
||||
function isError($data, $code = null)
|
||||
{
|
||||
if (class_exists('pear')) {
|
||||
return PEAR::isError($data, $code);
|
||||
} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
|
||||
is_subclass_of($data, 'services_json_error'))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (class_exists('PEAR_Error')) {
|
||||
|
||||
class Services_JSON_Error extends PEAR_Error
|
||||
{
|
||||
function Services_JSON_Error($message = 'unknown error', $code = null,
|
||||
$mode = null, $options = null, $userinfo = null)
|
||||
{
|
||||
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
/**
|
||||
* @todo Ultimately, this class shall be descended from PEAR_Error
|
||||
*/
|
||||
class Services_JSON_Error
|
||||
{
|
||||
function Services_JSON_Error($message = 'unknown error', $code = null,
|
||||
$mode = null, $options = null, $userinfo = null)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
326
onyx2/include/applications/GSM/main.php
Normal file
326
onyx2/include/applications/GSM/main.php
Normal file
|
|
@ -0,0 +1,326 @@
|
|||
<?php
|
||||
//Fichier appelé pour afficher l'application
|
||||
|
||||
$p = strtolower(gpc("p"));
|
||||
$titre = ucfirst(trim(gpc("titre", "post")));
|
||||
$auteur = ucwords(trim(gpc("auteur", "post")));
|
||||
|
||||
if ($p == "liste")
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->query("SELECT id, titre, chanteur, CDDeca, CDChanteur, CDAnnee FROM gsm ORDER BY id;");
|
||||
$req["nombre"] = $bdd->num_rows;
|
||||
$reqCDA = $bdd->query("SELECT id, nom FROM gsm_cdannee;");
|
||||
$reqCDC = $bdd->query("SELECT id, nom FROM gsm_cdchant;");
|
||||
$reqCDD = $bdd->query("SELECT id, nom FROM gsm_cddece;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$xml_cds = $xml->createElement("liste");
|
||||
if (!empty($req))
|
||||
foreach($req as $ligne)
|
||||
{
|
||||
if (!empty($ligne["id"]))
|
||||
{
|
||||
$chan = $xml->createElement("chanson");
|
||||
$chan->setAttribute("id", $ligne["id"]);
|
||||
$chan->setAttribute("titre", $ligne["titre"]);
|
||||
$chan->setAttribute("chanteur", $ligne["chanteur"]);
|
||||
$chan->setAttribute("CD_decenie", $ligne["CDDeca"]);
|
||||
$chan->setAttribute("CD_annee", $ligne["CDAnnee"]);
|
||||
$chan->setAttribute("CD_interprete", $ligne["CDChanteur"]);
|
||||
$xml_cds->appendChild($chan);
|
||||
}
|
||||
}
|
||||
if (!empty($reqCDA))
|
||||
foreach($reqCDA as $cd)
|
||||
{
|
||||
$chan = $xml->createElement("cdannee");
|
||||
$chan->setAttribute("id", $cd["id"]);
|
||||
$chan->setAttribute("nom", $cd["nom"]);
|
||||
$xml_cds->appendChild($chan);
|
||||
}
|
||||
if (!empty($reqCDC))
|
||||
foreach($reqCDC as $cd)
|
||||
{
|
||||
$chan = $xml->createElement("cdchant");
|
||||
$chan->setAttribute("id", $cd["id"]);
|
||||
$chan->setAttribute("nom", $cd["nom"]);
|
||||
$xml_cds->appendChild($chan);
|
||||
}
|
||||
if (!empty($reqCDD))
|
||||
foreach($reqCDD as $cd)
|
||||
{
|
||||
$chan = $xml->createElement("cddece");
|
||||
$chan->setAttribute("id", $cd["id"]);
|
||||
$chan->setAttribute("nom", $cd["nom"]);
|
||||
$xml_cds->appendChild($chan);
|
||||
}
|
||||
$xml_root->appendChild($xml_cds);
|
||||
}
|
||||
elseif ($p == "add" && ($type = intval(gpc("type", "post"))) && ($title = gpc("title", "post")))
|
||||
{
|
||||
$color = hexdec(gpc("color", "post"));
|
||||
|
||||
if ($type == 1)
|
||||
$table = "gsm_cdannee";
|
||||
else if ($type == 2)
|
||||
$table = "gsm_cdchant";
|
||||
else
|
||||
$table = "gsm_cddece";
|
||||
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($title);
|
||||
$bdd->query("INSERT INTO `$table` (nom, color) VALUES ('$title', $color);");
|
||||
$id = $bdd->insert_id();
|
||||
$req = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM gsm");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$xml_root->appendChild($xml->createElement("id", $id));
|
||||
}
|
||||
elseif ($p == "del" && $id = intval(gpc("id", "post")))
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$bdd->query("DELETE FROM `gsm` WHERE id = $id;");
|
||||
$req = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM gsm");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif ($p == "color" && ($type = intval(gpc("type", "get"))) && ($idAlbum = intval(gpc("id", "get"))))
|
||||
{
|
||||
if ($type == 1)
|
||||
$table = "gsm_cdannee";
|
||||
else if ($type == 2)
|
||||
$table = "gsm_cdchant";
|
||||
else
|
||||
$table = "gsm_cddece";
|
||||
|
||||
$bdd = new BDD();
|
||||
$res = $bdd->unique_query("SELECT color FROM `$table` WHERE id = $idAlbum;");
|
||||
$req = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM gsm");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$xml_root->appendChild($xml->createElement("color", sprintf("#%06X", $res["color"])));
|
||||
|
||||
$color2R = ($res["color"] >> 16) & 255;
|
||||
if ($color2R >= 25)
|
||||
$color2R -= 25;
|
||||
$color2G = ($res["color"] >> 8) & 255;
|
||||
if ($color2G >= 25)
|
||||
$color2G -= 25;
|
||||
$color2B = ($res["color"]) & 255;
|
||||
if ($color2B >= 25)
|
||||
$color2B -= 25;
|
||||
$xml_root->appendChild($xml->createElement("color", sprintf("#%02X%02X%02X", $color2R, $color2G, $color2B)));
|
||||
}
|
||||
elseif ($p == "rech")
|
||||
{
|
||||
$type = substr(gpc("type", "post"), 0, 1);
|
||||
$id = intval(gpc("id", "post"));
|
||||
|
||||
if ($type == "d")
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$rech = $bdd->query("SELECT * FROM gsm WHERE CDDeca = $id;");
|
||||
$req = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM gsm");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif ($type == "a")
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$rech = $bdd->query("SELECT * FROM gsm WHERE CDAnnee = $id;");
|
||||
$req = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM gsm");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif ($type == "i")
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$rech = $bdd->query("SELECT * FROM gsm WHERE CDChanteur = $id;");
|
||||
$req = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM gsm");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
||||
$xml_cds = $xml->createElement("album");
|
||||
if (!empty($rech))
|
||||
{
|
||||
foreach($rech as $ligne)
|
||||
{
|
||||
$chan = $xml->createElement("chanson");
|
||||
$chan->setAttribute("id", $ligne["id"]);
|
||||
$chan->setAttribute("titre", $ligne["titre"]);
|
||||
$chan->setAttribute("chanteur", $ligne["chanteur"]);
|
||||
$chan->setAttribute("CD_decenie", $ligne["CDDeca"]);
|
||||
$chan->setAttribute("CD_annee", $ligne["CDAnnee"]);
|
||||
$chan->setAttribute("CD_interprete", $ligne["CDChanteur"]);
|
||||
$xml_cds->appendChild($chan);
|
||||
}
|
||||
}
|
||||
$xml_root->appendChild($xml_cds);
|
||||
}
|
||||
elseif ($p == "stats")
|
||||
{
|
||||
$cds = array();
|
||||
|
||||
$bdd = new BDD();
|
||||
$cds["annees"] = $bdd->query("SELECT A.id, A.nom, COUNT(T.id) AS nombre FROM gsm_cdannee A LEFT OUTER JOIN gsm T ON A.id = T.CDAnnee GROUP BY A.id ORDER BY A.nom;");
|
||||
$cds["interpretes"] = $bdd->query("SELECT A.id, A.nom, COUNT(T.id) AS nombre FROM gsm_cdchant A LEFT OUTER JOIN gsm T ON A.id = T.CDChanteur GROUP BY A.id ORDER BY A.nom;");
|
||||
$cds["decenies"] = $bdd->query("SELECT A.id, A.nom, COUNT(T.id) AS nombre FROM gsm_cddece A LEFT OUTER JOIN gsm T ON A.id = T.CDDeca GROUP BY A.id ORDER BY A.nom;");
|
||||
$req = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM gsm");
|
||||
$bdd->deconnexion();
|
||||
|
||||
if (!empty($cds["annees"]))
|
||||
{
|
||||
foreach($cds["annees"] as $ligne)
|
||||
{
|
||||
$cd = $xml->createElement("annee");
|
||||
$cd->setAttribute("id", $ligne["id"]);
|
||||
$cd->setAttribute("nbTitles", $ligne["nombre"]);
|
||||
$xml_root->appendChild($cd);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($cds["interpretes"]))
|
||||
{
|
||||
foreach($cds["interpretes"] as $ligne)
|
||||
{
|
||||
$cd = $xml->createElement("interprete");
|
||||
$cd->setAttribute("id", $ligne["id"]);
|
||||
$cd->setAttribute("nbTitles", $ligne["nombre"]);
|
||||
$xml_root->appendChild($cd);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($cds["decenies"]))
|
||||
{
|
||||
foreach($cds["decenies"] as $ligne)
|
||||
{
|
||||
$cd = $xml->createElement("decenie");
|
||||
$cd->setAttribute("id", $ligne["id"]);
|
||||
$cd->setAttribute("nbTitles", $ligne["nombre"]);
|
||||
$xml_root->appendChild($cd);
|
||||
}
|
||||
}
|
||||
}
|
||||
elseif ($p == "cds")
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$cds["decenies"] = $bdd->query("SELECT A.*, COUNT(T.id) AS nombre FROM gsm_cddece A LEFT OUTER JOIN gsm T ON A.id = T.CDDeca GROUP BY A.nom;");
|
||||
$cds["interpretes"] = $bdd->query("SELECT A.*, COUNT(T.id) AS nombre FROM gsm_cdchant A LEFT OUTER JOIN gsm T ON A.id = T.CDChanteur GROUP BY A.nom;");
|
||||
$cds["annees"] = $bdd->query("SELECT A.*, COUNT(T.id) AS nombre FROM gsm_cdannee A LEFT OUTER JOIN gsm T ON A.id = T.CDAnnee GROUP BY A.nom;");
|
||||
$req = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM gsm");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$xml_cds = $xml->createElement("decenies");
|
||||
if (!empty($cds["decenies"]))
|
||||
{
|
||||
foreach($cds["decenies"] as $ligne)
|
||||
{
|
||||
$cd = $xml->createElement("cd");
|
||||
$cd->setAttribute("id", $ligne["id"]);
|
||||
$cd->setAttribute("nom", $ligne["nom"]);
|
||||
$cd->setAttribute("nombre_titres", $ligne["nombre"]);
|
||||
$xml_cds->appendChild($cd);
|
||||
}
|
||||
}
|
||||
$xml_root->appendChild($xml_cds);
|
||||
|
||||
$xml_cds = $xml->createElement("interpretes");
|
||||
if (!empty($cds["interpretes"]))
|
||||
{
|
||||
foreach($cds["interpretes"] as $ligne)
|
||||
{
|
||||
$cd = $xml->createElement("cd");
|
||||
$cd->setAttribute("id", $ligne["id"]);
|
||||
$cd->setAttribute("nom", $ligne["nom"]);
|
||||
$cd->setAttribute("nombre_titres", $ligne["nombre"]);
|
||||
$xml_cds->appendChild($cd);
|
||||
}
|
||||
}
|
||||
$xml_root->appendChild($xml_cds);
|
||||
|
||||
$xml_cds = $xml->createElement("annees");
|
||||
if (!empty($cds["annees"]))
|
||||
{
|
||||
foreach($cds["annees"] as $ligne)
|
||||
{
|
||||
$cd = $xml->createElement("cd");
|
||||
$cd->setAttribute("id", $ligne["id"]);
|
||||
$cd->setAttribute("nom", $ligne["nom"]);
|
||||
$cd->setAttribute("nombre_titres", $ligne["nombre"]);
|
||||
$xml_cds->appendChild($cd);
|
||||
}
|
||||
}
|
||||
$xml_root->appendChild($xml_cds);
|
||||
}
|
||||
elseif (!empty($titre) && !empty($auteur))
|
||||
{
|
||||
$alb = intval(gpc("alb", "post"));
|
||||
$type = intval(gpc("type", "post"));
|
||||
$id = intval(gpc("id"));
|
||||
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($titre);
|
||||
$bdd->escape($auteur);
|
||||
if ($id)
|
||||
$bdd->query("UPDATE gsm SET titre = '$titre', chanteur = '$auteur' WHERE id = $id;");
|
||||
else
|
||||
{
|
||||
//On recherche la chanson pour tester si elle n'existe pas déjà
|
||||
$chanson = $bdd->unique_query("SELECT id, CDDeca, CDAnnee, CDChanteur FROM gsm WHERE titre LIKE '$titre' AND chanteur LIKE '$auteur' LIMIT 1;");
|
||||
$update = "";
|
||||
if (!empty($chanson))
|
||||
{
|
||||
if (isset($update) && !empty($type) && $type == 3)
|
||||
{
|
||||
if (empty($chanson["CDDeca"]))
|
||||
$update .= "CDDeca = ".$alb.", ";
|
||||
else
|
||||
$update = null;
|
||||
}
|
||||
if (isset($update) && !empty($type) && $type == 1)
|
||||
{
|
||||
if (empty($chanson["CDAnnee"]))
|
||||
$update .= "CDAnnee = ".$alb.", ";
|
||||
else
|
||||
$update = null;
|
||||
}
|
||||
if (isset($update) && !empty($type) && $type == 2)
|
||||
{
|
||||
if (empty($chanson["CDChanteur"]))
|
||||
$update .= "CDChanteur = ".$alb.", ";
|
||||
else
|
||||
$update = null;
|
||||
}
|
||||
}
|
||||
if (!empty($update))
|
||||
{
|
||||
$bdd->query("UPDATE gsm SET $update titre = titre WHERE id = ".$chanson["id"].";");
|
||||
$res = $chanson["id"];
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($type == 1)
|
||||
$disc = array("annee" => $alb, "interprete" => 0, "decenie" => 0);
|
||||
else if ($type == 2)
|
||||
$disc = array("annee" => 0, "interprete" => $alb, "decenie" => 0);
|
||||
else if ($type == 3)
|
||||
$disc = array("annee" => 0, "interprete" => 0, "decenie" => $alb);
|
||||
else
|
||||
$disc = array("annee" => 0, "interprete" => 0, "decenie" => 0);
|
||||
|
||||
$bdd->query("INSERT INTO gsm (titre, chanteur, CDDeca, CDAnnee, CDChanteur) VALUES ('$titre', '$auteur', ".$disc["decenie"].", ".$disc["annee"].", ".$disc["interprete"].");");
|
||||
$res = $bdd->insert_id();
|
||||
}
|
||||
}
|
||||
$req = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM gsm");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$xml_root->appendChild($xml->createElement("id", $res));
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT COUNT(id) AS nombre FROM gsm");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
||||
$json["nombre"] = $req["nombre"];
|
||||
?>
|
||||
50
onyx2/include/applications/GSM/property.xml
Normal file
50
onyx2/include/applications/GSM/property.xml
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<application active="1">
|
||||
<property value="name">Gérer sa musique</property>
|
||||
<property value="description">Cette application vous permet de gérer facilement votre discothèque.</property>
|
||||
<property value="etatAvancement">beta</property>
|
||||
<property value="version">1.1</property>
|
||||
<property value="lang">fr_FR</property>
|
||||
<property value="developpeur"><![CDATA[<span style="font-variant: small-caps">Mercier</span> Pierre-Olivier]]></property>
|
||||
<property value="corps">contenu</property>
|
||||
|
||||
<security type="users" default="restricted">
|
||||
<user>1</user>
|
||||
<user>2</user>
|
||||
</security>
|
||||
|
||||
<display value="logo">0</display>
|
||||
<display value="css" media="all">main.css</display>
|
||||
<display value="css" media="screen">style.css</display>
|
||||
<display value="css" media="print">print.css</display>
|
||||
<display value="script">app.js</display>
|
||||
<display value="body">
|
||||
<![CDATA[
|
||||
<h1>Bienvenue dans la gestion d'une discothèque</h1>
|
||||
<ul id="GSM_menu">
|
||||
<li><h2>Discothèque</h2></li>
|
||||
<li onclick="GSM_add();">Ajouter un album</li>
|
||||
<li onclick="GSM_listAlbums();">Liste des albums</li>
|
||||
<li onclick="GSM_listTitres();">Liste des titres</li>
|
||||
<li>Nombre de titres enregistrés : <span id="nbpc"></span></li>
|
||||
</ul>
|
||||
<div id="contenu"></div>
|
||||
]]>
|
||||
</display>
|
||||
<display value="js">
|
||||
<![CDATA[
|
||||
function runApplication(property, display, json)
|
||||
{
|
||||
$('logo').style.display = 'none';
|
||||
|
||||
$('contenu').innerHTML = "";
|
||||
news = document.createElement("div");
|
||||
news.className = "news";
|
||||
news.innerHTML = "<h3>Bienvenue dans la version béta de GSM pour Pommultimédia For Home !</h3>Cette nouvelle version est plus rapide que la version précédente et a une meilleur intégration avec Pommultimédia For Home.<br />N'hésitez pas à nous faire part de vos commentaires ;)";
|
||||
$('contenu').appendChild(news);
|
||||
}
|
||||
]]>
|
||||
</display>
|
||||
|
||||
<config value="table_bdd">gsm</config>
|
||||
</application>
|
||||
81
onyx2/include/applications/GSPC/main.php
Normal file
81
onyx2/include/applications/GSPC/main.php
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
<?php
|
||||
//Fichier appelé pour afficher l'application
|
||||
|
||||
$p = strtolower(gpc("p"));
|
||||
$nom = trim(utf8_decode(utf8_encode(strtolower(gpc("nom", "post")))));
|
||||
$ligne = trim(utf8_decode(utf8_encode(strtoupper(gpc("ligne", "post")))));
|
||||
|
||||
//sleep(5);
|
||||
|
||||
if ($p == "liste")
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->query("SELECT * FROM gspc;");
|
||||
$req["nombre"] = $bdd->num_rows;
|
||||
$bdd->deconnexion();
|
||||
|
||||
$xml_pc = $xml->createElement("liste");
|
||||
foreach($req as $ligne)
|
||||
{
|
||||
if (!empty($ligne["reftable"]))
|
||||
{
|
||||
$portecle = $xml->createElement("porteclef");
|
||||
$portecle->setAttribute("id", $ligne["reftable"]);
|
||||
$portecle->setAttribute("nom", $ligne["nom"]);
|
||||
$portecle->setAttribute("caracteristique", ucfirst($ligne["caracteristique"]));
|
||||
$portecle->setAttribute("ligne", $ligne["ligne"]);
|
||||
$portecle->setAttribute("special", $ligne["special"]);
|
||||
$xml_pc->appendChild($portecle);
|
||||
}
|
||||
}
|
||||
$xml_root->appendChild($xml_pc);
|
||||
}
|
||||
elseif ($p == "stats")
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->query("SELECT ligne, COUNT(reftable) AS nombre FROM `gspc` GROUP BY ligne ORDER BY ligne ASC;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$xml_pc = $xml->createElement("statistiques");
|
||||
foreach($req as $ligne)
|
||||
{
|
||||
$portecle = $xml->createElement("ligne");
|
||||
$portecle->setAttribute("nom", $ligne["ligne"]);
|
||||
$portecle->setAttribute("nombre", $ligne["nombre"]);
|
||||
$xml_pc->appendChild($portecle);
|
||||
}
|
||||
$xml_root->appendChild($xml_pc);
|
||||
}
|
||||
elseif ($p == "del" && $id = intval(gpc("id", "post")))
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$bdd->query("DELETE FROM `gspc` WHERE reftable = $id;");
|
||||
$req = $bdd->unique_query("SELECT COUNT(reftable) AS nombre FROM gspc");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
elseif (!empty($nom) && !empty($ligne))
|
||||
{
|
||||
$carac = trim(utf8_decode(utf8_encode(gpc("caracteristique", "post"))));
|
||||
$quantite = intval(gpc("quantite", "post"));
|
||||
$id = intval(gpc("id"));
|
||||
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($nom);
|
||||
$bdd->escape($carac);
|
||||
$bdd->escape($ligne);
|
||||
if ($id)
|
||||
$bdd->query("UPDATE gspc SET nom = '$nom', caracteristique = '$carac', ligne = '$ligne', special = $quantite WHERE reftable = $id;");
|
||||
else
|
||||
$bdd->query("INSERT INTO gspc (nom, caracteristique, ligne, special) VALUES ('$nom', '$carac', '$ligne', $quantite);");
|
||||
$req = $bdd->unique_query("SELECT COUNT(reftable) AS nombre FROM gspc");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$req = $bdd->unique_query("SELECT COUNT(reftable) AS nombre FROM gspc");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
|
||||
$json["nombre"] = $req["nombre"];
|
||||
?>
|
||||
51
onyx2/include/applications/GSPC/property.xml
Normal file
51
onyx2/include/applications/GSPC/property.xml
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<application active="1">
|
||||
<property value="name">Gérer ses porte-clefs</property>
|
||||
<property value="description">Cette application vous permet de gérer facilement une collection de porte-clefs.</property>
|
||||
<property value="etatAvancement">final</property>
|
||||
<property value="version">1.1</property>
|
||||
<property value="lang">fr_FR</property>
|
||||
<property value="developpeur"><![CDATA[<span style="font-variant: small-caps">Mercier</span> Pierre-Olivier]]></property>
|
||||
<property value="corps">contenu</property>
|
||||
|
||||
<security type="users" default="restricted">
|
||||
<user>1</user>
|
||||
<user>2</user>
|
||||
</security>
|
||||
<!--
|
||||
<menu text="Test pommes" eventClick="alert('Alerte aux pommes !');" />
|
||||
<menu text="Test abricot" eventClick="alert('Alerte aux abricots !');" />
|
||||
-->
|
||||
<display value="logo">0</display>
|
||||
<display value="css">style.css</display>
|
||||
<display value="script">app.js</display>
|
||||
<display value="body">
|
||||
<![CDATA[
|
||||
<h1>Bienvenue dans la gestion de collection de porte-clefs</h1>
|
||||
<ul id="GSPC_menu">
|
||||
<li><h2>Porte-clefs</h2></li>
|
||||
<li onclick="GSPC_add();">Ajouter un porte-clef</li>
|
||||
<li onclick="GSPC_list();">Liste des porte-clefs</li>
|
||||
<li onclick="GSPC_stats();">Liste des lignes</li>
|
||||
<li>Nombre de porte-clefs enregistrés : <span id="nbpc"></span></li>
|
||||
</ul>
|
||||
<div id="contenu"></div>
|
||||
]]>
|
||||
</display>
|
||||
<display value="js">
|
||||
<![CDATA[
|
||||
function runApplication(property, display, json)
|
||||
{
|
||||
$('logo').style.display = 'none';
|
||||
|
||||
$('contenu').innerHTML = "";
|
||||
news = document.createElement("div");
|
||||
news.className = "news";
|
||||
news.innerHTML = "<h3>Bienvenue dans la version finale de GSPC pour Pommultimédia For Home !</h3>Cette nouvelle version a été encore plus simplifiée et réduit les temps d'attente en préchargeant les données de manière asynchrone.<br />N'hésitez pas à nous faire part de vos commentaires. Bonne utilisation ;)";
|
||||
$('contenu').appendChild(news);
|
||||
}
|
||||
]]>
|
||||
</display>
|
||||
|
||||
<config value="table_bdd">gspc</config>
|
||||
</application>
|
||||
3
onyx2/include/applications/UDload/main.php
Normal file
3
onyx2/include/applications/UDload/main.php
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
//Fichier appelé pour afficher l'application
|
||||
?>
|
||||
32
onyx2/include/applications/UDload/property.xml
Normal file
32
onyx2/include/applications/UDload/property.xml
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<application active="1">
|
||||
<property value="name">Transfert de fichiers</property>
|
||||
<property value="description">Cette application vous permet de transférer rapidement de petits fichiers et de les partager sur Internet.</property>
|
||||
<property value="dir">UDload</property>
|
||||
<property value="etatAvancement">final</property>
|
||||
<property value="version">1.0</property>
|
||||
<property value="lang">fr_FR</property>
|
||||
<property value="developpeur"><![CDATA[<span style="font-variant: small-caps">Mercier</span> Pierre-Olivier]]></property>
|
||||
<property value="js">
|
||||
<![CDATA[
|
||||
function runApplication(property, display, json)
|
||||
{
|
||||
formulaire = document.createElement("form");
|
||||
formfield = document.createElement("fieldset");
|
||||
labelfile = document.createElement("label");
|
||||
labelfile.innerHTML = "Fichier à uploader : ";
|
||||
formfield.appendChild(labelfile);
|
||||
inputfile = document.createElement("input");
|
||||
inputfile.name = "upfile";
|
||||
formulaire.appendChild(formfield);
|
||||
$('corps').appendChild(formulaire);
|
||||
}
|
||||
]]>
|
||||
</property>
|
||||
|
||||
<security default="connected" />
|
||||
|
||||
<display value="titre">download.png</display>
|
||||
|
||||
<config value="table_bdd">udload</config>
|
||||
</application>
|
||||
72
onyx2/include/applications/chat/main.php
Normal file
72
onyx2/include/applications/chat/main.php
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
<?php
|
||||
//Fichier appelé pour afficher l'application
|
||||
if (isset($_POST['message']))
|
||||
{
|
||||
$message = strip_tags(trim(gpc("message", "post")));
|
||||
if (!empty($message) || $message == "0")
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$bdd->escape($message);
|
||||
$bdd->query("INSERT INTO chat (id_membre, timestamp, message) VALUES (".$SESS->values['id_user'].", ".time().", '$message');");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
}
|
||||
elseif (isset($_POST['comm']))
|
||||
{
|
||||
$commande = strip_tags(trim(gpc("comm", "post")));
|
||||
if ($commande == "!clear")
|
||||
{
|
||||
if ($SESS->values["id_user"] == 1)
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$bdd->query("DELETE FROM chat;");
|
||||
$bdd->deconnexion();
|
||||
$json["confirm"] = "Tous les messages ont été supprimés";
|
||||
}
|
||||
else
|
||||
$json["confirm"] = "Vous n'avez pas les autorisations nécessaires pour effacer les messages.";
|
||||
}
|
||||
elseif ($commande == "!online")
|
||||
{
|
||||
$users = Cache::read('chat_online');
|
||||
$json["confirm"] = "Actuellement en ligne :<ul>";
|
||||
foreach($users as $username => $time)
|
||||
{
|
||||
if (time()-30 < $time)
|
||||
$json["confirm"] .= "<li>$username</li>";
|
||||
}
|
||||
$json["confirm"] .= "</ul>";
|
||||
}
|
||||
elseif ($commande == "!help" || $commande == "!hlp" || $commande == "!aide")
|
||||
{
|
||||
$json["confirm"] = "<table><tr><th>Commande</th><th>Description</th></tr>
|
||||
<tr><td>!changeRefreshTime <ins>int</ins></td><td>Change le temps de rafraîchissement à <ins>int</ins> (milli)secondes</td></tr>
|
||||
<tr><td>!cls</td><td>Nettoie l'écran</td></tr>
|
||||
<tr><td>!clear</td><td>Supprime tous les messages enregistrés dans la base de données</td></tr>
|
||||
<tr><td>!help</td><td>Affiche cet aide</td></tr>
|
||||
<tr><td>!maj</td><td>Actualise les messages du chat</td></tr>
|
||||
<tr><td>!online</td><td>Montre les utilisateurs en ligne (ces 30 dernières secondes)</td></tr>
|
||||
<tr><td>!quit</td><td>Quitte le chat et affiche l'accueil</td></tr>
|
||||
<tr><td>!reset</td><td>Réaffiche les 15 derniers messages envoyés</td></tr>
|
||||
</table>";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//Met à jour la liste des personnes en ligne
|
||||
$users = Cache::read('chat_online');
|
||||
$users[$SESS->values["username"]] = time();
|
||||
Cache::set('chat_online', $users);
|
||||
|
||||
if (!empty($_GET['time']))
|
||||
$time = intval(gpc("time"))." ORDER BY timestamp DESC";
|
||||
else
|
||||
$time = "0 ORDER BY timestamp DESC LIMIT 15";
|
||||
|
||||
$bdd = new BDD();
|
||||
$messages = $bdd->query("SELECT C.*, U.pseudo FROM chat C INNER JOIN users U ON U.id = C.id_membre WHERE C.timestamp > $time;");
|
||||
$bdd->deconnexion();
|
||||
|
||||
$json["messages"] = $messages;
|
||||
}
|
||||
?>
|
||||
121
onyx2/include/applications/chat/property.xml
Normal file
121
onyx2/include/applications/chat/property.xml
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<application active="1">
|
||||
<property value="name">Chat</property>
|
||||
<property value="description">Cette application vous permet de dialoguer facilement avec les autres personnes connectées.</property>
|
||||
<property value="dir">chat</property>
|
||||
<property value="etatAvancement">beta</property>
|
||||
<property value="version">1.0</property>
|
||||
<property value="lang">fr_FR</property>
|
||||
<property value="developpeur"><![CDATA[<span style="font-variant: small-caps">Mercier</span> Pierre-Olivier]]></property>
|
||||
<property value="js">
|
||||
<![CDATA[
|
||||
function runApplication(property, display, json)
|
||||
{
|
||||
formulaire = document.createElement("form");
|
||||
formulaire.onsubmit = sendMessage;
|
||||
formfield = document.createElement("fieldset");
|
||||
formfield.style.margin = "auto";
|
||||
labelmess = document.createElement("label");
|
||||
labelmess.innerHTML = "Message : ";
|
||||
labelmess.setAttribute("for", "message");
|
||||
formfield.appendChild(labelmess);
|
||||
inputmessage = document.createElement("input");
|
||||
inputmessage.name = "message";
|
||||
inputmessage.id = "message";
|
||||
inputmessage.size = "40";
|
||||
formfield.appendChild(inputmessage);
|
||||
formulaire.appendChild(formfield);
|
||||
$('corps').appendChild(formulaire);
|
||||
tableMessages = document.createElement("table");
|
||||
tableMessages.style.margin = "auto";
|
||||
tableMessages.style.width = "90%";
|
||||
theMess = document.createElement("thead");
|
||||
trMess = document.createElement("tr");
|
||||
thMess = document.createElement("th");
|
||||
thMess.innerHTML = "Date et heure";
|
||||
trMess.appendChild(thMess);
|
||||
thMess = document.createElement("th");
|
||||
thMess.innerHTML = "Message";
|
||||
trMess.appendChild(thMess);
|
||||
theMess.appendChild(trMess);
|
||||
tableMessages.appendChild(theMess);
|
||||
tboMess = document.createElement("tbody");
|
||||
tboMess.style.textAlign = "left";
|
||||
tboMess.id = "chat";
|
||||
tableMessages.appendChild(tboMess);
|
||||
$('corps').appendChild(tableMessages);
|
||||
|
||||
printEtat(0);
|
||||
chat_MAJ();
|
||||
}
|
||||
|
||||
function sendMessage()
|
||||
{
|
||||
if ($('message').value == "!cls")
|
||||
{
|
||||
chat_clearScreen();
|
||||
$('message').value = "";
|
||||
}
|
||||
else if ($('message').value == "!maj")
|
||||
{
|
||||
chat_refreshScreen();
|
||||
$('message').value = "";
|
||||
}
|
||||
else if ($('message').value == "!reset")
|
||||
{
|
||||
chat_reset();
|
||||
$('message').value = "";
|
||||
}
|
||||
else if ($('message').value == "!quit" || $('message').value == "!exit" || $('message').value == "!deco" || $('message').value == "!deconnexion")
|
||||
{
|
||||
first_page();
|
||||
}
|
||||
else if ($('message').value.toString().indexOf("!changerefreshtime ") == 0 || $('message').value.toString().indexOf("!changeRefreshtime ") == 0 || $('message').value.toString().indexOf("!changerefreshTime ") == 0 || $('message').value.toString().indexOf("!changeRefreshTime ") == 0)
|
||||
{
|
||||
split = $('message').value.toString().split(" ");
|
||||
$('message').value = "";
|
||||
chat_changeRefreshTime(split[1]);
|
||||
}
|
||||
else if ($('message').value == "!clear" || $('message').value == "!online" || $('message').value == "!help" || $('message').value == "!hlp" || $('message').value == "!aide")
|
||||
{
|
||||
chat_sendCommande($('message').value);
|
||||
$('message').value = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
new Ajax.Request(
|
||||
'ajax.php?d=action&a=chat',
|
||||
{
|
||||
method: 'post',
|
||||
parameters: {message: $('message').value},
|
||||
onSuccess: function(transport, json) {
|
||||
$('message').value = "";
|
||||
},
|
||||
onFailure: function() { if (confirm("La requête a échouée, voulez-vous réessayer de renvoyer votre message ?")) sendMessage(); }
|
||||
}
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function chat_MAJ()
|
||||
{
|
||||
var date = new Date();
|
||||
var newRow = $('chat').insertRow(0);
|
||||
var newCell = newRow.insertCell(0);
|
||||
newCell.innerHTML = '<em>JS</em> ' + (date.getHours()<10?"0"+date.getHours():date.getHours()) + ":" + (date.getMinutes()<10?"0"+date.getMinutes():date.getMinutes()) + ":" + (date.getSeconds()<10?"0"+date.getSeconds():date.getSeconds());
|
||||
newCell = newRow.insertCell(1);
|
||||
newCell.innerHTML = "<em>Connexion au chat</em>";
|
||||
$('message').focus();
|
||||
chat_refresh = setTimeout("chat_MAJ()", 150);
|
||||
}
|
||||
]]>
|
||||
</property>
|
||||
|
||||
<security default="connected" />
|
||||
|
||||
<display value="titre">chat.png</display>
|
||||
<display value="js">app.js</display>
|
||||
|
||||
<config value="table_bdd">chat</config>
|
||||
</application>
|
||||
13
onyx2/include/applications/users/main.php
Normal file
13
onyx2/include/applications/users/main.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
//Fichier appelé pour afficher l'application
|
||||
if (isset($_POST['message']))
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
$bdd = new BDD();
|
||||
$json["users"] = $bdd->query("SELECT * FROM users ORDER BY last_visite DESC;");
|
||||
$bdd->deconnexion();
|
||||
}
|
||||
?>
|
||||
36
onyx2/include/applications/users/property.xml
Normal file
36
onyx2/include/applications/users/property.xml
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<application active="1">
|
||||
<property value="name">Gestion des utilisateurs</property>
|
||||
<property value="description">Cette application permet de gérer les utilisateurs et les accès aux applications.</property>
|
||||
<property value="dir">users</property>
|
||||
<property value="etatAvancement">enconstruction</property>
|
||||
<property value="version">1.0</property>
|
||||
<property value="lang">fr_FR</property>
|
||||
<property value="developpeur"><![CDATA[<span style="font-variant: small-caps">Mercier</span> Pierre-Olivier]]></property>
|
||||
<property value="js">
|
||||
<![CDATA[
|
||||
function runApplication(property, display, json)
|
||||
{
|
||||
alert('pom');
|
||||
USERS_display("main", json)
|
||||
printEtat(0);
|
||||
}
|
||||
|
||||
function USERS_display(page, plus)
|
||||
{
|
||||
alert("USERS_display('" + page + "', " + plus + ");");
|
||||
USERS_liste = plus.users;
|
||||
setTimeout("USERS_display('" + page + "', false);", 100);
|
||||
}
|
||||
]]>
|
||||
</property>
|
||||
|
||||
<security type="users" default="restricted">
|
||||
<user>1</user>
|
||||
</security>
|
||||
|
||||
<display value="titre">utilisateurs.png</display>
|
||||
<display value="js">app.js</display>
|
||||
|
||||
<config value="table_bdd">users</config>
|
||||
</application>
|
||||
85
onyx2/include/functions.php
Normal file
85
onyx2/include/functions.php
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
<?php
|
||||
if (!defined("ONYX"))
|
||||
exit;
|
||||
|
||||
define("APPSDIR", ONYX."include/applications/");
|
||||
define("PAGESDIR", ONYX."include/pages/");
|
||||
|
||||
function acces_application($application, $applicationXML = null)
|
||||
{
|
||||
global $SESS;
|
||||
|
||||
$autoriser = false;
|
||||
|
||||
if (empty($applicationXML))
|
||||
{
|
||||
$applicationXML = new DOMDocument();
|
||||
$applicationXML->load(APPSDIR.$application.'/property.xml');
|
||||
}
|
||||
|
||||
if ($applicationXML->documentElement->getAttribute('active') && ($applicationXML->getElementsByTagName('application') || $applicationXML->getElementsByTagName('page')))
|
||||
{
|
||||
foreach($applicationXML->getElementsByTagName('security') as $security)
|
||||
{
|
||||
//Autorisation par défaut
|
||||
if ($security->getAttribute('default') == "connected")
|
||||
$autoriser = !empty($SESS->values["connecte"]);
|
||||
elseif ($security->getAttribute('default') == "authorized")
|
||||
$autoriser = true;
|
||||
|
||||
//Méthode(s) d'autorisation(s)
|
||||
if (ereg("users", $security->getAttribute('type')) && !empty($SESS->values["username"]))
|
||||
{
|
||||
foreach($applicationXML->getElementsByTagName('user') as $user)
|
||||
{
|
||||
if (strtolower($user->textContent) == strtolower($SESS->values["id_user"]))
|
||||
return !$autoriser;
|
||||
}
|
||||
}
|
||||
if (ereg("usernames", $security->getAttribute('type')) && !empty($SESS->values["username"]))
|
||||
{
|
||||
foreach($applicationXML->getElementsByTagName('username') as $user)
|
||||
{
|
||||
if (strtolower($user->textContent) == strtolower($SESS->values["username"]))
|
||||
return !$autoriser;
|
||||
}
|
||||
}
|
||||
if (ereg("ips", $security->getAttribute('type')))
|
||||
{
|
||||
foreach($applicationXML->getElementsByTagName('ip') as $ip)
|
||||
{
|
||||
if ($ip->textContent == $_SERVER["REMOTE_ADDR"])
|
||||
return !$autoriser;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return $autoriser;
|
||||
}
|
||||
|
||||
function send404(&$xml_root)
|
||||
{
|
||||
global $xml;
|
||||
|
||||
$xml_root->appendChild($xml->createElement("titre", "404.png"));
|
||||
$xml_root->appendChild($xml->createElement("body", "Page introuvable"));
|
||||
}
|
||||
|
||||
function send403(&$xml_root)
|
||||
{
|
||||
global $xml;
|
||||
|
||||
$xml_root->appendChild($xml->createElement("titre", "avertissements.png"));
|
||||
$xml_root->appendChild($xml->createElement("body", "<h2>Erreur 403</h2><h3>Vous n'êtes pas autorisé à accéder à cette page.</h3>Si vous êtes sur d'avoir le droit d'accèder à cette page et que le problème perciste, contacter l'administrateur."));
|
||||
}
|
||||
|
||||
if (!function_exists("json_encode"))
|
||||
{
|
||||
include_once(ONYX.'include/JSON.php');
|
||||
function json_encode($value, $option = 0)
|
||||
{
|
||||
$json = new Services_JSON();
|
||||
return $json->encode($value);
|
||||
}
|
||||
}
|
||||
?>
|
||||
30
onyx2/include/pages/aproposdusite.xml
Normal file
30
onyx2/include/pages/aproposdusite.xml
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<page active="1">
|
||||
<display value="titre">aproposdusite.png</display>
|
||||
<display value="body">
|
||||
<![CDATA[
|
||||
<h2>A propos de Pommultimedia for Home</h2>
|
||||
<h3>Pommultimedia for Home<br />
|
||||
Version 0.2 du 22/04/2011</h3>
|
||||
<h3>Ce site a été développé avec Emacs et Eclipse (plug-in Aptana) sur un serveur utilisant la technologie <a href="http://www.php.net/">PHP</a>.</h3>
|
||||
<br />
|
||||
<h3>Navigateurs conseillés : <a href="www.mozilla.org/firefox/">Mozilla Firefox</a> et <a href="http://www.google.com/chrome/">Google Chrome</a>.</h3>
|
||||
<br />
|
||||
<h3>Historique des versions :</h3>
|
||||
<h4>Version 0.2 du 22/04/2011</h4>
|
||||
<ul>
|
||||
<li>Factorisation du code JavaScript du framework</li>
|
||||
<li>La page connexion est maintenant une page à part entière</li>
|
||||
<li>Ajout du JavaScript aux pages</li>
|
||||
<li>Les items du menu font maintenant parti du fichier XML de chaque application, ce n'est plus dans le JavaScript</li>
|
||||
<li>Régénération de toutes les images d'en-tête : utilisation de la police du cahier des charges et toutes ont été générés</li>
|
||||
<li>Le JavaScript évalué ne fait plus parti des propriétés de l'application, il est dans l'affichage (d'où : accélération du chargement de la liste des applications sur la page d'accueil)</li>
|
||||
<li>Il peut y avoir plusieurs fichiers de scripts et de style par app, ils sont mieux déchargé à la fermeture de l'app</li>
|
||||
</ul>
|
||||
<h4>Version 0.1 du 04/08/2009</h4>
|
||||
Version initiale
|
||||
]]>
|
||||
</display>
|
||||
|
||||
<security default="authorized" />
|
||||
</page>
|
||||
63
onyx2/include/pages/connexion.xml
Normal file
63
onyx2/include/pages/connexion.xml
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<page active="1">
|
||||
<display value="titre">identification.png</display>
|
||||
<display value="body">
|
||||
<![CDATA[
|
||||
<h1>Bienvenue sur le serveur <em>Pommultimédia for home</em> !</h1>
|
||||
<h2>Pour vous connecter au serveur, veuillez indiquer votre nom d'utilisateur ainsi que votre mot de passe.</h2>
|
||||
<form action="#" method="post">
|
||||
<fieldset class="connexion">
|
||||
<label for="pseudo">Nom d'utilisateur :</label>
|
||||
<input type="text" id="pseudo" maxlength="32"><br>
|
||||
<label for="mdp">Mot de passe :</label>
|
||||
<input type="password" id="mdp" maxlength="32"><br>
|
||||
<input type="submit" value="Connexion">
|
||||
</fieldset>
|
||||
</form>
|
||||
<p id="erreur"></p>
|
||||
]]>
|
||||
</display>
|
||||
<display value="js">
|
||||
<![CDATA[
|
||||
function connexion(nom, pass)
|
||||
{
|
||||
printEtat(4);
|
||||
$('pseudo').disabled = "disabled";
|
||||
$('mdp').disabled = "disabled";
|
||||
new Ajax.Request(
|
||||
'ajax.php?d=connecte',
|
||||
{
|
||||
method: 'post',
|
||||
parameters: {name: nom, mdp: pass},
|
||||
onSuccess: function(transport, json)
|
||||
{
|
||||
if (json.statut == 1)
|
||||
{
|
||||
printEtat(2);
|
||||
username = nom.toLowerCase();
|
||||
page_accueil();
|
||||
}
|
||||
else
|
||||
{
|
||||
$('pseudo').disabled = "";
|
||||
$('mdp').disabled = "";
|
||||
$('pseudo').className = "erreur";
|
||||
$('mdp').className = "erreur";
|
||||
$('erreur').innerHTML = "Nom d'utilisateur ou mot de passe incorrect !";
|
||||
$('pseudo').focus();
|
||||
$('pseudo').select();
|
||||
printEtat(0);
|
||||
}
|
||||
},
|
||||
onFailure: function() { printEtat(3); }
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$('corps').getElementsByTagName("form")[0].onsubmit = function() { connexion($('pseudo').value, $('mdp').value); return false; };
|
||||
$('pseudo').focus();
|
||||
]]>
|
||||
</display>
|
||||
|
||||
<security default="authorized" />
|
||||
</page>
|
||||
56
onyx2/lang/en.xml
Normal file
56
onyx2/lang/en.xml
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<lang type="en">
|
||||
<!-- Module : fermerServeur -->
|
||||
<var name="mdl_fermerServeur_title1">Server in maintenance</var>
|
||||
<var name="mdl_fermerServeur_title2">Server in maintenance</var>
|
||||
<var name="mdl_fermerServeur_title3">Server in maintenance</var>
|
||||
<var name="mdl_fermerServeur_texte1"><![CDATA[The server is actualy under maintenance. Because of that, the website is unavailable at this time. We expect the server to be back in %d minutes.<br /><br />For more informations about corrections and novelties, please read the <a href="%s" class="lien">news on our board</a>.]]></var>
|
||||
<var name="mdl_fermerServeur_texte2"><![CDATA[The server is actualy under maintenance. Because of that, the website is unavailable at this time. We expect the server to be back in %d minutes.<br /><br />For more informations about corrections and novelties, we advise you to read the <a href="%s" class="lien">HB Weekly Update on our board</a>.]]></var>
|
||||
<var name="mdl_fermerServeur_texte3"><![CDATA[The server is actualy under maintenance. Because of that, the website is unavailable at this time. We expect the server to be back in %d minutes.<br /><br />For more informations about corrections and novelties, we advise you to read the <a href="http://www.halo-battle.fr/tester/changelog_page.php" class="lien">Mantis' ChangeLog</a>.]]></var>
|
||||
<var name="mdl_fermerServeur_thanks">Thank you for your understanding</var>
|
||||
|
||||
<!-- game/serveur -->
|
||||
<var name="badNomMdp">Username or password incorrect.</var>
|
||||
<var name="badAuthConnect">The server is unable to authenticate the connection.</var>
|
||||
<var name="servSature">There is currently too many people logged on Halo-Battle. To ensure a reasonable speed for players, please try later.</var>
|
||||
<var name="badPlanete">Your planet cannot be find !</var>
|
||||
|
||||
<var name="banInf">You have been ban permanently from this galaxy for %s. You can't connect yourself anymore.</var>
|
||||
<var name="banVac">An operator placed your account in vacation mode for %s. You can't connect until %s.</var>
|
||||
<var name="modVac"><![CDATA[This account is in vacation mode. You can't have access to it until <br />%s.]]></var>
|
||||
|
||||
<!--
|
||||
TEMPLATES
|
||||
-->
|
||||
<!-- Menu Header -->
|
||||
<var name="hd_menu_Accueil">HOME</var>
|
||||
<var name="hd_menu_Jeu">THE GAME</var>
|
||||
<var name="hd_menu_Inscrire">JOIN NOW</var>
|
||||
<var name="hd_menu_Forum">BOARD</var>
|
||||
<var name="hd_menu_Blog">BLOG</var>
|
||||
<var name="hd_menu_Hfr">HALO.FR</var>
|
||||
<var name="hd_menu_rss">RSS :: subscribe</var>
|
||||
<var name="hd_menu_search">search...</var>
|
||||
<var name="hd_menu_advSearch">Advanced Search</var>
|
||||
<!-- Connexion -->
|
||||
<var name="mod_login_titre">Log-in</var>
|
||||
<var name="mod_login_galaxie">Galaxy</var>
|
||||
<var name="mod_login_forgotMdp">Forgot your password?</var>
|
||||
<!-- Inscription -->
|
||||
<var name="mod_inscription_texte"><![CDATA[<span><a href="%s">REGISTER NOW</a> Join the Humanity or Destroy it</span> <p><br />Fight your enemy and Conquer the Sacred Rings in large and beautiful Galaxies inspired by the famous game Halo.<br /><br /><em>A simple free-registration and a web browser are required to play Halo-Battle so don't way anymore and join many others in epic battles!</em></p> <a href="%s" class="link"><span>Click here to join!</span></a> <a href="%s" class="more">Want to know more?</a>]]></var>
|
||||
<!-- Accueil -->
|
||||
<var name="cntRaces"><![CDATA[%d Marines and %d Covenants are fighting in <ins>this galaxy</ins>]]></var>
|
||||
<!-- Footer -->
|
||||
<var name="foot_realise">Directed by</var>
|
||||
<var name="foot_design">Design by</var>
|
||||
<var name="foot_menu_Accueil">Home</var>
|
||||
<var name="foot_menu_Inscrire">Register</var>
|
||||
<var name="foot_menu_Forum">Board</var>
|
||||
<var name="foot_menu_Staff">Staff</var>
|
||||
<var name="foot_menu_Faq">F.A.Q.</var>
|
||||
|
||||
<!-- Général -->
|
||||
<var name="contactAdmin">If the problem persists, please contact an administrator.</var>
|
||||
<var name="hello">Hello</var>
|
||||
<var name="bye">Good bye</var>
|
||||
</lang>
|
||||
1176
onyx2/lang/fr.xml
Normal file
1176
onyx2/lang/fr.xml
Normal file
File diff suppressed because it is too large
Load diff
166
onyx2/load.php
Normal file
166
onyx2/load.php
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
<?php
|
||||
|
||||
$chrono_start = microtime(TRUE);
|
||||
|
||||
if(version_compare(PHP_VERSION, '5.1.0', '<')) trigger_error('Version de php non supportee',E_USER_ERROR);
|
||||
|
||||
define('ONYX_VERSION','2.0');
|
||||
|
||||
define('FILE',$_SERVER["SCRIPT_FILENAME"]);
|
||||
|
||||
define('ONYX',dirname(__FILE__).'/');
|
||||
|
||||
if(!is_readable(ONYX."ban.list")) trigger_error('Fichier de ban introuvable',E_USER_ERROR);
|
||||
if(in_array($_SERVER['REMOTE_ADDR'], file(ONYX."ban.list",FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES))) die('banni');
|
||||
|
||||
require_once('require/parse.php');
|
||||
require_once('require/cache.php');
|
||||
require_once('require/str.php');
|
||||
require_once('require/env.php');
|
||||
|
||||
# *** Chargement de la configuration ***
|
||||
|
||||
$cached = Cache::read('_configuration_'.FILE);
|
||||
if($cached['check'] == md5_file(ONYX.'config/root.xml').md5_file(ONYX.'modules/modules.xml'))
|
||||
{
|
||||
$VAR = $cached['var'];
|
||||
$ENV = $cached['env'];
|
||||
define('ROOT',$cached['root']);
|
||||
|
||||
foreach($cached['modules'] as $name)
|
||||
{
|
||||
if(isset($cached['opt'][$name]))
|
||||
{
|
||||
$OPT = $cached['opt'][$name];
|
||||
|
||||
include_once(ONYX.'modules/'.$name.'/main.php');
|
||||
}
|
||||
}
|
||||
|
||||
define('CACHED',TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
$xml = new DOMDocument();
|
||||
|
||||
$xml->load(ONYX.'config/root.xml') or trigger_error('Erreur du fichier de configuration',E_USER_ERROR);
|
||||
$xml->normalizeDocument();
|
||||
//$xml->validate();
|
||||
|
||||
if($root = $xml->documentElement->getAttribute('root'))
|
||||
{
|
||||
if($root == substr(FILE,0,strlen($root)))
|
||||
{
|
||||
define('ROOT',$root);
|
||||
|
||||
$search = substr(FILE,strlen($root));
|
||||
|
||||
$paths = explode('/',$search);
|
||||
$paths2 = $paths;
|
||||
foreach($paths as $key => $path)
|
||||
{
|
||||
for($i = $key - 1; $i >= 0; $i--)
|
||||
{
|
||||
$paths2[$key] = $paths[$i] . '/' . $paths2[$key];
|
||||
}
|
||||
if($key != count($paths) - 1) $paths2[$key] .= '/';
|
||||
}
|
||||
|
||||
foreach($xml->getElementsByTagName('config') as $value)
|
||||
{
|
||||
$config[$value->getAttribute('match')] = $value;
|
||||
}
|
||||
|
||||
$VAR = $ENV = $modules = array();
|
||||
array_unshift($paths2,'*');
|
||||
|
||||
foreach($paths2 as $path)
|
||||
{
|
||||
if(isset($config[$path]))
|
||||
{
|
||||
$VAR = array_merge($VAR,parse_config($config[$path]));
|
||||
|
||||
$ENV = array_merge($ENV,parse_config($config[$path],'env','option'));
|
||||
|
||||
foreach($config[$path]->getElementsByTagName('module') as $module)
|
||||
{
|
||||
$modules[$module->getAttribute('name')] = $module;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$xml_modules = new DOMDocument();
|
||||
$xml_modules->load(ONYX.'modules/modules.xml') or trigger_error('Erreur du fichier de modules',E_USER_ERROR);
|
||||
$xml_modules->normalizeDocument();
|
||||
foreach($xml_modules->getElementsByTagName('module') as $module)
|
||||
{
|
||||
if(!ctype_alnum($module->getAttribute('name'))) trigger_error('Le nom du module contient des caracteres illegaux',E_USER_ERROR);
|
||||
|
||||
$all_modules[$module->getAttribute('name')] = $module;
|
||||
}
|
||||
|
||||
$all_opt = $load_modules = array();
|
||||
|
||||
foreach($modules as $name => $module)
|
||||
{
|
||||
if(isset($all_modules[$name]) && !in_array($name,$load_modules))
|
||||
{
|
||||
if($require = $all_modules[$name]->getAttribute('require'))
|
||||
if(!in_array($require,$load_modules))
|
||||
{
|
||||
trigger_error("Module '$name' requiert '$require'",E_USER_WARNING);
|
||||
continue;
|
||||
}
|
||||
|
||||
$OPT = parse_config($module,'option');
|
||||
$OPT = array_merge(parse_config($all_modules[$name]->getElementsByTagName('default')->item(0),'option'), $OPT);
|
||||
|
||||
include_once(ONYX.'modules/'.$name.'/main.php');
|
||||
|
||||
$all_opt[$name] = $OPT;
|
||||
|
||||
$load_modules[] = $name;
|
||||
}
|
||||
}
|
||||
|
||||
if($xml->documentElement->getAttribute('cache'))
|
||||
Cache::set('_configuration_'.FILE,array('var' => $VAR,'env' => $ENV, 'root' => $root,'modules' => $load_modules,'opt' => $all_opt, 'check' => md5_file(ONYX.'config/root.xml').md5_file(ONYX.'modules/modules.xml')));
|
||||
|
||||
else Cache::del('_configuration_'.FILE);
|
||||
}
|
||||
else trigger_error('Fichier hors de la racine',E_USER_ERROR);
|
||||
}
|
||||
else trigger_error('Configuration erronnee',E_USER_ERROR);
|
||||
|
||||
define('CACHED',FALSE);
|
||||
}
|
||||
|
||||
error_reporting($ENV['error_level']);
|
||||
|
||||
set_include_path(get_include_path() . PATH_SEPARATOR . ONYX.'include/');
|
||||
|
||||
ignore_user_abort($ENV['ignore_user_abort']);
|
||||
|
||||
setLocale(LC_ALL,$ENV['locale']);
|
||||
|
||||
date_default_timezone_set($ENV["timezone"]);
|
||||
|
||||
if(isset($VAR['chrono']))
|
||||
{
|
||||
function view_chrono()
|
||||
{
|
||||
global $chrono_start,$VAR;
|
||||
echo str_replace('$',round(microtime(TRUE) - $chrono_start,4),$VAR['chrono']);
|
||||
}
|
||||
register_shutdown_function('view_chrono');
|
||||
}
|
||||
|
||||
if($ENV['log_php']) ini_set('error_log',ONYX.'log/php.log');
|
||||
|
||||
foreach($ENV['ini'] as $name => $value) ini_set($name,$value);
|
||||
|
||||
foreach($ENV['header'] as $name => $value) header($name.': '.$value);
|
||||
|
||||
unset($xml,$root,$search,$paths,$paths2,$path,$key,$i,$value,$config,$modules,$module,$load_modules,$xml_modules,$all_modules,$name,$require,$OPT,$all_opt,$dir,$file,$ENV,$cached);
|
||||
|
||||
?>
|
||||
0
onyx2/log/php.log
Executable file
0
onyx2/log/php.log
Executable file
60
onyx2/modules/bbcode/main.php
Normal file
60
onyx2/modules/bbcode/main.php
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
$bbcode_config = $OPT;
|
||||
|
||||
function bbcode($var,$level=0)
|
||||
{
|
||||
global $bbcode_config;
|
||||
|
||||
switch($level)
|
||||
{
|
||||
case 1:
|
||||
$pattern[] = '#\\[code\\](.+?)\\[/code\\]#us';
|
||||
$replace[] = '<pre>$1</pre>';
|
||||
|
||||
$pattern[] = '#\\[size=([1-3][0-9])\\](.+?)\\[/size\\]#us';
|
||||
$replace[] = '<span style="font-size: $1px;">$2</span>';
|
||||
|
||||
$pattern[] = '#\\[color=(aqua|black|blue|fuchsia|gray|green|lime|maroon|navy|olive|purple|red|silver|teal|white|yellow|\\#[0-9A-Fa-f]{6})\\](.+?)\\[/color\\]#us';
|
||||
$replace[] = '<span style="color: $1;">$2</span>';
|
||||
|
||||
$pattern[] = '#\\[img\\]http(s)?://([a-zA-Z0-9_/.%*+~,;:\\#-]+)\\[/img\\]#u';
|
||||
$replace[] = '<img src="http$1://$2" alt="$2" />';
|
||||
|
||||
default:
|
||||
case 0:
|
||||
$pattern[] = '#\\[url=(?:http(s)?://)?([a-zA-Z0-9_/.%*+~,;:?&=\\#-]+)\\](.+?)\\[/url\\]#u';
|
||||
$replace[] = '<a href="http$1://$2">$3</a>';
|
||||
|
||||
$pattern[] = '#\\[url\\](?:http(s)?://)?([a-zA-Z0-9_/.%*+~,;:?&=\\#-]+)\\[/url\\]#u';
|
||||
$replace[] = '<a href="http$1://$2">$2</a>';
|
||||
|
||||
$pattern[] = '#\\[cite\\](.+?)\\[/cite\\]#us';
|
||||
$replace[] = '<q>$1</q>';
|
||||
|
||||
$pattern[] = '#\\[u\\](.+?)\\[/u\\]#us';
|
||||
$replace[] = '<ins>$1</ins>';
|
||||
|
||||
$pattern[] = '#\\[i\\](.+?)\\[/i\\]#us';
|
||||
$replace[] = '<em>$1</em>';
|
||||
|
||||
$pattern[] = '#\\[b\\](.+?)\\[/b\\]#us';
|
||||
$replace[] = '<strong>$1</strong>';
|
||||
|
||||
if(isset($bbcode_config['smiley']) && isset($bbcode_config['smiley_dir']))
|
||||
foreach($bbcode_config['smiley'] as $keys => $values)
|
||||
{
|
||||
$pattern[] = '#'.preg_quote($values).'#u';
|
||||
$replace[] = '<img src="'.$bbcode_config['smiley_dir'].'/'.htmlspecialchars($keys).'.gif" alt="'.htmlspecialchars($keys).'" />';
|
||||
}
|
||||
}
|
||||
|
||||
$pattern = array_reverse($pattern);
|
||||
$replace = array_reverse($replace);
|
||||
|
||||
$var = preg_replace($pattern,$replace,$var);
|
||||
return $var;
|
||||
}
|
||||
?>
|
||||
BIN
onyx2/modules/captcha/fonts/0.ttfdd
Normal file
BIN
onyx2/modules/captcha/fonts/0.ttfdd
Normal file
Binary file not shown.
BIN
onyx2/modules/captcha/fonts/1.ttf
Normal file
BIN
onyx2/modules/captcha/fonts/1.ttf
Normal file
Binary file not shown.
121
onyx2/modules/captcha/main.php
Normal file
121
onyx2/modules/captcha/main.php
Normal file
|
|
@ -0,0 +1,121 @@
|
|||
<?php
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
$_ONYX_OPT_CAPTCHA = $OPT;
|
||||
|
||||
class Captcha
|
||||
{
|
||||
static function check($entry)
|
||||
{
|
||||
$SESS = new Session();
|
||||
|
||||
return isset($SESS->values["_captcha"]) && $SESS->values["_captcha"] == strtolower($entry);
|
||||
}
|
||||
|
||||
private static function genImg()
|
||||
{
|
||||
global $_ONYX_OPT_CAPTCHA;
|
||||
$SESS = new Session();
|
||||
|
||||
//Création de l'image à partir d'un fond
|
||||
$_img = imagecreate($_ONYX_OPT_CAPTCHA["sizeX"], $_ONYX_OPT_CAPTCHA["sizeY"]);
|
||||
imagefilledrectangle($_img, 0, 0, $_ONYX_OPT_CAPTCHA["sizeX"], $_ONYX_OPT_CAPTCHA["sizeY"], imagecolorallocate($_img, $_ONYX_OPT_CAPTCHA["back"]["red"], $_ONYX_OPT_CAPTCHA["back"]["green"], $_ONYX_OPT_CAPTCHA["back"]["blue"]));
|
||||
|
||||
//Définition de la liste des caractères
|
||||
if (empty($_ONYX_OPT_CAPTCHA["caracteres"]))
|
||||
$caracteres = "2345678azertypsdfhjkmwxcbn";
|
||||
else
|
||||
$caracteres = $_ONYX_OPT_CAPTCHA["caracteres"];
|
||||
$nb_caracteres = strlen($caracteres) - 1;
|
||||
|
||||
//On récupère tous les fichiers de polices
|
||||
if (empty($_ONYX_OPT_CAPTCHA["fonts_dir"]))
|
||||
$fontsDir = ONYX."modules/captcha/fonts";
|
||||
else
|
||||
$fontsDir = ONYX.$_ONYX_OPT_CAPTCHA["fonts_dir"];
|
||||
|
||||
$fonts = glob($fontsDir."/*.ttf");
|
||||
$nb_fonts = count($fonts) - 1;
|
||||
|
||||
//On définit des couleurs
|
||||
if (empty($_ONYX_OPT_CAPTCHA["colors"]) || !is_array($_ONYX_OPT_CAPTCHA["colors"]))
|
||||
$colors = array(
|
||||
imagecolorallocate($_img, rand(250,225), rand(0,25), rand(0,25)),
|
||||
imagecolorallocate($_img, rand(0,25), rand(250,225), rand(0,25)),
|
||||
imagecolorallocate($_img, rand(0,55), rand(0,55), rand(250,255)),
|
||||
imagecolorallocate($_img, rand(0,25), rand(250,225), rand(250,225)),
|
||||
imagecolorallocate($_img, rand(250,225), rand(0,25), rand(250,225)),
|
||||
imagecolorallocate($_img, rand(250,225), rand(250,225), rand(0,25)),
|
||||
//imagecolorallocate($_img, rand(200,225), rand(200,225), rand(200,225))
|
||||
imagecolorallocate($_img, rand(0,55), rand(0,55), rand(0,55))
|
||||
);
|
||||
else
|
||||
$colors = $_ONYX_OPT_CAPTCHA["colors"];
|
||||
$nb_colors = count($colors) - 1;
|
||||
|
||||
//On définit la couleur de fond
|
||||
$arriere_plan = imagecolorallocatealpha($_img, 0, mt_rand(0,255), 0, 127);
|
||||
|
||||
$SESS->values["_captcha"] = "";
|
||||
|
||||
$dist = $_ONYX_OPT_CAPTCHA["sizeX"] / $_ONYX_OPT_CAPTCHA["nb_carac"];
|
||||
$dist2 = $dist / 2;
|
||||
$dist4 = $dist2 / 2;
|
||||
$height2 = $_ONYX_OPT_CAPTCHA["sizeY"] / 2;
|
||||
$height4 = $height2 / 2;
|
||||
|
||||
//Si la configuration indique un fichier contenant des mots, on l'utilise
|
||||
if (!empty($_ONYX_OPT_CAPTCHA["mots"]) && is_readable(ONYX."modules/captcha/".$_ONYX_OPT_CAPTCHA["mots"]))
|
||||
{
|
||||
$mot = file(ONYX."modules/captcha/".$_ONYX_OPT_CAPTCHA["mots"], FILE_IGNORE_NEW_LINES|FILE_SKIP_EMPTY_LINES);
|
||||
$mot = $mot[mt_rand(0, count($mot) - 1)];
|
||||
}
|
||||
|
||||
//Création du captcha en lui-même
|
||||
for($i = 0; $i < $_ONYX_OPT_CAPTCHA["nb_carac"]; $i++)
|
||||
{
|
||||
if (empty($mot) || empty($mot[$i]))
|
||||
{
|
||||
if (mt_rand(0,2) == 1)
|
||||
$char = strtoupper($caracteres[mt_rand(0, $nb_caracteres)]);
|
||||
else
|
||||
$char = $caracteres[mt_rand(0, $nb_caracteres)];
|
||||
}
|
||||
else
|
||||
$char = $mot[$i];
|
||||
|
||||
ImageTTFText($_img, mt_rand(14,23), mt_rand(-17, 20), $i * $dist + mt_rand(0,$dist2), mt_rand(0, $height4) + $height2, $colors[mt_rand(0, $nb_colors)], $fonts[mt_rand(0, $nb_fonts)], $char);
|
||||
|
||||
$SESS->values["_captcha"] .= strtolower($char);
|
||||
}
|
||||
$SESS->put();
|
||||
|
||||
return $_img;
|
||||
}
|
||||
|
||||
static function newCaptcha()
|
||||
{
|
||||
ob_start();
|
||||
imagepng(Captcha::genImg());
|
||||
return base64_encode(ob_get_clean());
|
||||
}
|
||||
|
||||
static function _debug()
|
||||
{
|
||||
return base64_decode(Captcha::newCaptcha());
|
||||
}
|
||||
|
||||
static function printNewCaptcha()
|
||||
{
|
||||
print "data:image/png;base64,".Captcha::newCaptcha();
|
||||
}
|
||||
|
||||
static function showNewCaptcha()
|
||||
{
|
||||
header ("Content-type: image/png");
|
||||
|
||||
imagepng($_img = Captcha::genImg());
|
||||
imagedestroy($_img);
|
||||
}
|
||||
}
|
||||
?>
|
||||
3834
onyx2/modules/captcha/mots.list
Normal file
3834
onyx2/modules/captcha/mots.list
Normal file
File diff suppressed because it is too large
Load diff
28
onyx2/modules/chconfig/__config.class.php
Normal file
28
onyx2/modules/chconfig/__config.class.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
class __config
|
||||
{
|
||||
//Tableau des variables de la configuration
|
||||
var $vars = array();
|
||||
|
||||
//Tableau des variables d'environnement
|
||||
var $envs = array();
|
||||
|
||||
//Tableau des modules
|
||||
var $modules = array();
|
||||
|
||||
function __construct($xml = null)
|
||||
{
|
||||
if (isset($xml))
|
||||
{
|
||||
$this->vars = parse_config($xml, "var", "name");
|
||||
$this->envs = parse_config($xml, "env", "option");
|
||||
|
||||
foreach($xml->getElementsByTagName('module') as $module)
|
||||
$this->modules[$module->getAttribute('name')] = parse_config($module, "option", "name");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
110
onyx2/modules/chconfig/chconfig.class.php
Normal file
110
onyx2/modules/chconfig/chconfig.class.php
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
class chConfig
|
||||
{
|
||||
//Adresse vers le fichier de configuration en cours de modification
|
||||
private $_filename;
|
||||
|
||||
//Le site est-il actif ?
|
||||
var $active = 1;
|
||||
|
||||
//Adresse absolue vers le dossier principal
|
||||
var $root;
|
||||
|
||||
//Activer le cache ?
|
||||
var $cache = 1;
|
||||
|
||||
//Liste des configurations en fonction des fichiers
|
||||
var $configs;
|
||||
|
||||
|
||||
// Constructeur qui charge le fichier de configuration
|
||||
function __construct($filename = null)
|
||||
{
|
||||
if (!empty($filename))
|
||||
$this->_filename = $filename;
|
||||
else
|
||||
$this->_filename = ONYX."config/root.xml";
|
||||
|
||||
//On charge le fichier
|
||||
$xml = new DOMDocument();
|
||||
$xml->load($this->_filename);
|
||||
|
||||
$this->active = $xml->documentElement->getAttribute('active');
|
||||
$this->root = $xml->documentElement->getAttribute('root');
|
||||
$this->cache = $xml->documentElement->getAttribute('cache');
|
||||
|
||||
$this->configs = array();
|
||||
|
||||
foreach($xml->getElementsByTagName('config') as $value)
|
||||
{
|
||||
$this->configs[$value->getAttribute('match')] = new __config($value);
|
||||
}
|
||||
}
|
||||
|
||||
function addConfig($config)
|
||||
{
|
||||
$this->configs[$config] = new __config();
|
||||
}
|
||||
|
||||
function addVar($name, $value, $config = "*")
|
||||
{
|
||||
$this->configs[$config]->vars[$name] = $value;
|
||||
}
|
||||
|
||||
function addEnv($option, $value, $config = "*")
|
||||
{
|
||||
$this->configs[$config]->envs[$option] = $value;
|
||||
}
|
||||
|
||||
function addModule($name, $config = "*")
|
||||
{
|
||||
$this->configs[$config]->modules[$name] = array();
|
||||
}
|
||||
|
||||
function addModuleOption($moduleName, $name, $value, $config = "*")
|
||||
{
|
||||
$this->configs[$config]->modules[$moduleName][$name] = $value;
|
||||
}
|
||||
|
||||
//Fonction qui écrit le fichier
|
||||
function write()
|
||||
{
|
||||
$xml = new DOMDocument('1.0', 'UTF-8');
|
||||
$xml->formatOutput = true;
|
||||
|
||||
$xml_configs = $xml->createElement("configs");
|
||||
$xml_configs->setAttribute("active", $this->active);
|
||||
$xml_configs->setAttribute("root", $this->root);
|
||||
$xml_configs->setAttribute("cache", $this->cache);
|
||||
|
||||
foreach($this->configs as $match => $config)
|
||||
{
|
||||
$xml_config = $xml->createElement("config");
|
||||
$xml_config->setAttribute("match", $match);
|
||||
|
||||
//On écrit les variables
|
||||
chConfig::unparse_config($xml, $xml_config, $config->vars, "var", "name");
|
||||
chConfig::unparse_config($xml, $xml_config, $config->envs, "env", "option");
|
||||
|
||||
//On écrit les modules
|
||||
if (is_array($config->modules))
|
||||
foreach($config->modules as $mod_name => $module)
|
||||
{
|
||||
$xml_module = $xml->createElement("module");
|
||||
$xml_module->setAttribute("name", $mod_name);
|
||||
chConfig::unparse_config($xml, $xml_module, $module, "option", "name");
|
||||
$xml_config->appendChild($xml_module);
|
||||
}
|
||||
|
||||
$xml_configs->appendChild($xml_config);
|
||||
}
|
||||
|
||||
$xml->appendChild($xml_configs);
|
||||
|
||||
$xml->save($this->_filename);
|
||||
}
|
||||
}
|
||||
?>
|
||||
57
onyx2/modules/chconfig/chmodules.class.php
Normal file
57
onyx2/modules/chconfig/chmodules.class.php
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
class chModules
|
||||
{
|
||||
//Adresse vers le fichier de configuration en cours de modification
|
||||
private $_filename;
|
||||
|
||||
//Liste des modules
|
||||
var $modules = array();
|
||||
|
||||
|
||||
// Constructeur qui charge le fichier de modules
|
||||
function __construct($filename = null)
|
||||
{
|
||||
if (!empty($filename))
|
||||
$this->_filename = $filename;
|
||||
else
|
||||
$this->_filename = ONYX."modules/modules.xml";
|
||||
|
||||
//On charge le fichier
|
||||
$xml = new DOMDocument();
|
||||
$xml->load($this->_filename);
|
||||
|
||||
foreach($xml->getElementsByTagName('module') as $value)
|
||||
{
|
||||
$this->modules[$value->getAttribute('name')] = parse_config($value->getElementsByTagName("default")->item(0), "option", "name");
|
||||
}
|
||||
}
|
||||
|
||||
function write()
|
||||
{
|
||||
$xml = new DOMDocument('1.0', 'UTF-8');
|
||||
$xml->formatOutput = true;
|
||||
|
||||
$xml_modules = $xml->createElement("modules");
|
||||
|
||||
foreach($this->modules as $name => $module)
|
||||
{
|
||||
$xml_module = $xml->createElement("module");
|
||||
$xml_module->setAttribute("name", $name);
|
||||
|
||||
$xml_def = $xml->createElement("default");
|
||||
unparse_config($xml, $xml_def, $module, "option", "name");
|
||||
|
||||
$xml_module->appendChild($xml_def);
|
||||
$xml_modules->appendChild($xml_module);
|
||||
}
|
||||
|
||||
$xml->appendChild($xml_modules);
|
||||
|
||||
return $xml;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
65
onyx2/modules/chconfig/main.php
Normal file
65
onyx2/modules/chconfig/main.php
Normal file
|
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
function unparse_config($create, $xml, $array, $node = 'var', $attribut = 'name')
|
||||
{
|
||||
if (is_array($array))
|
||||
foreach($array as $name => $var)
|
||||
{
|
||||
if (is_array($var))
|
||||
{
|
||||
$xml_var = $create->createElement($node);
|
||||
$xml_var->setAttribute($attribut, $name);
|
||||
|
||||
unparse_config($create, $xml_var, $var, $node, $attribut);
|
||||
|
||||
$xml->appendChild($xml_var);
|
||||
}
|
||||
else
|
||||
{
|
||||
$xml_var = $create->createElement($node, $var);
|
||||
$xml_var->setAttribute($attribut, $name);
|
||||
$xml->appendChild($xml_var);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
require_once("__config.class.php");
|
||||
require_once("chconfig.class.php");
|
||||
require_once("chmodules.class.php");
|
||||
|
||||
function chconfig($type, $file = null)
|
||||
{
|
||||
$sortie = "";
|
||||
|
||||
if ($type == "modules")
|
||||
{
|
||||
$sortie .= '<h1>Modification des paramètres de modules</h1><form action="?t=modules" method="post">';
|
||||
|
||||
//On charge ce qu'on veut afficher
|
||||
$mods = new chModules($file);
|
||||
|
||||
$sortie .= '</form>';
|
||||
}
|
||||
elseif ($type == "bdd")
|
||||
{
|
||||
$sortie .= "<h1>Modification des paramètres de base de données</h1>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sortie .= "<h1>Modification des paramètres de configuration</h1>";
|
||||
}
|
||||
|
||||
return $sortie;
|
||||
}
|
||||
|
||||
//Affichage automatique
|
||||
if (!empty($OPT["show"]))
|
||||
{
|
||||
echo "<html><head><title>Modification des paramètres d'Onyx2</title></head><body>";
|
||||
echo chconfig(gpc("t"));
|
||||
echo "</body></html>";
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
28
onyx2/modules/db/main.php
Normal file
28
onyx2/modules/db/main.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
switch($OPT['type'])
|
||||
{
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
|
||||
$api = array('mysql' => 'mysql_connect', 'postgresql' => 'pg_connect');
|
||||
if(!function_exists($api[$OPT['type']])) trigger_error('API introuvable',E_USER_ERROR);
|
||||
unset($api);
|
||||
|
||||
function dbpass($crypt,$cle)
|
||||
{
|
||||
return cxor(base64_decode($crypt),md5($cle,TRUE));
|
||||
}
|
||||
|
||||
$db_config = $OPT;
|
||||
|
||||
require_once($OPT['type'].'.class.php');
|
||||
define('DB_TYPE',$OPT['type']);
|
||||
break;
|
||||
|
||||
default: trigger_error('Base de donnee inconnue',E_USER_ERROR);
|
||||
}
|
||||
|
||||
?>
|
||||
171
onyx2/modules/db/mysql.class.php
Normal file
171
onyx2/modules/db/mysql.class.php
Normal file
|
|
@ -0,0 +1,171 @@
|
|||
<?php
|
||||
|
||||
class BDD
|
||||
{
|
||||
var $connected;
|
||||
|
||||
private $session;
|
||||
|
||||
private $reponse;
|
||||
|
||||
var $host;
|
||||
|
||||
var $user;
|
||||
|
||||
private $password;
|
||||
|
||||
var $database;
|
||||
|
||||
var $num_rows;
|
||||
|
||||
var $nodb;
|
||||
|
||||
|
||||
function __construct($profile=NULL)
|
||||
{
|
||||
if($profile === FALSE) return FALSE;
|
||||
|
||||
global $db_config;
|
||||
|
||||
if(empty($profile))
|
||||
{
|
||||
if(!$db_config['profile']) return FALSE;
|
||||
$profile = &$db_config['profile'];
|
||||
}
|
||||
|
||||
if(!ctype_alnum($profile)) trigger_error('Le nom du profil contient des caracteres illegaux',E_USER_ERROR);
|
||||
|
||||
if($db_config['profile'])
|
||||
{
|
||||
require(ONYX.'db/'.$profile.'.profile.php');
|
||||
|
||||
$db = &$___profile['db'];
|
||||
$host = &$___profile['host'];
|
||||
$user = &$___profile['user'];
|
||||
$pass = &$___profile['pass'];
|
||||
}
|
||||
|
||||
if($db_config['crypt']) $pass = dbpass($pass,$db_config['crypt']);
|
||||
|
||||
return $this->connexion($host,$user,$pass,$db);
|
||||
}
|
||||
|
||||
function connexion($host,$user,$pass,$db=NULL)
|
||||
{
|
||||
if($this->session) $this->deconnexion();
|
||||
|
||||
$this->reponse = NULL;
|
||||
|
||||
$this->session = mysql_connect($host,$user,$pass);
|
||||
|
||||
if(!$this->session)
|
||||
{
|
||||
elog('Connexion impossible a la base de donnee : '.$this->erreur(),2);
|
||||
if(function_exists($this->nodb)) call_user_func($this->nodb);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
mysql_query('SET CHARACTER SET "utf8"',$this->session);
|
||||
|
||||
$this->host = $host;
|
||||
$this->user = $user;
|
||||
$this->password = $pass;
|
||||
if($db) $this->db($db);
|
||||
|
||||
$this->connected = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function reconnexion()
|
||||
{
|
||||
if(!empty($this->host) && !empty($this->user) && !empty($this->password) && !empty($this->database)) return $this->connexion($this->host,$this->user,$this->password,$this->database);
|
||||
}
|
||||
|
||||
function deconnexion()
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
$r = mysql_close($this->session);
|
||||
$this->session = FALSE;
|
||||
$this->connected = FALSE;
|
||||
return $r;
|
||||
}
|
||||
|
||||
function erreur()
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
return mysql_error($this->session);
|
||||
}
|
||||
|
||||
function db($db=NULL)
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
return $this->database = mysql_select_db($db,$this->session) ? $db : $this->database;
|
||||
}
|
||||
|
||||
function escape(&$var)
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
$var = mysql_real_escape_string($var,$this->session);
|
||||
return $var;
|
||||
}
|
||||
|
||||
function query($query)
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
$this->reponse = mysql_query($query,$this->session);
|
||||
|
||||
global $db_config;
|
||||
|
||||
if(!$this->reponse && $db_config['log']) elog('Erreur Mysql: " '.$this->erreur().' ", avec la requète: { '.$query.' }.',1);
|
||||
|
||||
$this->num_rows = @mysql_num_rows($this->reponse);
|
||||
|
||||
if($this->num_rows == 0) return NULL;
|
||||
|
||||
elseif($this->num_rows >= 1)
|
||||
{
|
||||
for($i=0; $var = mysql_fetch_assoc($this->reponse); $i++) $sortie[$i] = $var;
|
||||
return $sortie;
|
||||
}
|
||||
|
||||
else return FALSE;
|
||||
}
|
||||
|
||||
function unique_query($query)
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
$this->reponse = mysql_query($query,$this->session);
|
||||
|
||||
global $db_config;
|
||||
|
||||
if(!$this->reponse && $db_config['log']) elog('Erreur Mysql: " '.$this->erreur().' ", avec la requète: { '.$query.' }.',1);
|
||||
|
||||
$this->num_rows = @mysql_num_rows($this->reponse);
|
||||
|
||||
if($this->num_rows == 0) return NULL;
|
||||
|
||||
elseif($this->num_rows >= 1) return mysql_fetch_assoc($this->reponse);
|
||||
|
||||
else return FALSE;
|
||||
}
|
||||
|
||||
function affected()
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
return mysql_affected_rows($this->session);
|
||||
}
|
||||
|
||||
function insert_id()
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
return mysql_insert_id($this->session);
|
||||
}
|
||||
}
|
||||
?>
|
||||
169
onyx2/modules/db/postgresql.class.php
Normal file
169
onyx2/modules/db/postgresql.class.php
Normal file
|
|
@ -0,0 +1,169 @@
|
|||
<?php
|
||||
|
||||
class BDD
|
||||
{
|
||||
var $connected;
|
||||
|
||||
private $session;
|
||||
|
||||
private $reponse;
|
||||
|
||||
var $host;
|
||||
|
||||
var $user;
|
||||
|
||||
private $password;
|
||||
|
||||
var $database;
|
||||
|
||||
var $num_rows;
|
||||
|
||||
var $nodb;
|
||||
|
||||
|
||||
function __construct($profile=NULL)
|
||||
{
|
||||
if($profile === FALSE) return FALSE;
|
||||
|
||||
global $db_config;
|
||||
|
||||
if(empty($profile))
|
||||
{
|
||||
if(!$db_config['profile']) return FALSE;
|
||||
$profile = &$db_config['profile'];
|
||||
}
|
||||
|
||||
if(!ctype_alnum($profile)) trigger_error('Le nom du profil contient des caracteres illegaux',E_USER_ERROR);
|
||||
|
||||
if($db_config['profile'])
|
||||
{
|
||||
require(ONYX.'db/'.$profile.'.profile.php');
|
||||
|
||||
$db = &$___profile['db'];
|
||||
$host = &$___profile['host'];
|
||||
$user = &$___profile['user'];
|
||||
$pass = &$___profile['pass'];
|
||||
}
|
||||
|
||||
if($db_config['crypt']) $pass = dbpass($pass,$db_config['crypt']);
|
||||
|
||||
return $this->connexion($host,$user,$pass,$db);
|
||||
}
|
||||
|
||||
function connexion($host,$user,$pass,$db=NULL)
|
||||
{
|
||||
if($this->session) $this->deconnexion();
|
||||
|
||||
$this->reponse = NULL;
|
||||
|
||||
$host = pg_escape_string($host);
|
||||
$user = pg_escape_string($user);
|
||||
$pass = pg_escape_string($pass);
|
||||
$db = pg_escape_string($db);
|
||||
|
||||
$this->session = pg_connect("host='$host' port=5432 dbname='$db' user='$user' password='$pass'");
|
||||
|
||||
if(!$this->session)
|
||||
{
|
||||
elog('Connexion impossible a la base de donnee : '.$this->erreur(),2);
|
||||
if(function_exists($this->nodb)) call_user_func($this->nodb);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
pg_setclientencoding($this->session,'UTF8');
|
||||
|
||||
$this->host = $host;
|
||||
$this->user = $user;
|
||||
$this->password = $pass;
|
||||
$this->database = $db;
|
||||
|
||||
$this->connected = TRUE;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
function reconnexion()
|
||||
{
|
||||
if(!empty($this->host) && !empty($this->user) && !empty($this->password) && !empty($this->database)) return $this->connexion($this->host,$this->user,$this->password,$this->database);
|
||||
}
|
||||
|
||||
function deconnexion()
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
$r = pg_close($this->session);
|
||||
$this->session = FALSE;
|
||||
$this->connected = FALSE;
|
||||
return $r;
|
||||
}
|
||||
|
||||
function erreur()
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
return pg_last_error($this->session);
|
||||
}
|
||||
|
||||
function db($db)
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
return $this->database = pg_query($this->session,"\\connect ".pg_escape_string($db)) ? $db : $this->database;
|
||||
}
|
||||
|
||||
function escape(&$var)
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
$var = pg_escape_string($this->session,$var);
|
||||
return $var;
|
||||
}
|
||||
|
||||
function query($query)
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
$this->reponse = pg_query($this->session,$query);
|
||||
|
||||
global $db_config;
|
||||
|
||||
if(!$this->reponse && $db_config['log']) elog('Erreur PostgreSQL: " '.$this->erreur().' ", avec la requète: { '.$query.' }.',1);
|
||||
|
||||
$this->num_rows = pg_num_rows($this->reponse);
|
||||
|
||||
if($this->num_rows == 0) return NULL;
|
||||
|
||||
elseif($this->num_rows >= 1)
|
||||
{
|
||||
for($i=0; $var = pg_fetch_assoc($this->reponse); $i++) $sortie[$i] = $var;
|
||||
return $sortie;
|
||||
}
|
||||
|
||||
else return FALSE;
|
||||
}
|
||||
|
||||
function unique_query($query)
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
$this->reponse = pg_query($this->session,$query);
|
||||
|
||||
global $db_config;
|
||||
|
||||
if(!$this->reponse && $db_config['log']) elog('Erreur PostgreSQL: " '.$this->erreur().' ", avec la requète: { '.$query.' }.',1);
|
||||
|
||||
$this->num_rows = pg_num_rows($this->reponse);
|
||||
|
||||
if($this->num_rows == 0) return NULL;
|
||||
|
||||
elseif($this->num_rows >= 1) return pg_fetch_assoc($this->reponse);
|
||||
|
||||
else return FALSE;
|
||||
}
|
||||
|
||||
function affected()
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
return pg_affected_rows($this->reponse);
|
||||
}
|
||||
}
|
||||
?>
|
||||
96
onyx2/modules/lang/main.php
Normal file
96
onyx2/modules/lang/main.php
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Module de gestion des langues pour Onyx
|
||||
*
|
||||
* @link http://onyx.halo-battle.fr/
|
||||
* @authour 2011 Némunaire <nemunaire@gmail.com>
|
||||
* @version 2.0
|
||||
* @see The GNU Public License (GPL)
|
||||
* Last modified: 13/02/2011
|
||||
*/
|
||||
|
||||
/**
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
if(!defined("ONYX")) exit;
|
||||
|
||||
if(!is_readable(ONYX."lang/".$OPT["type"]."/"))
|
||||
{
|
||||
if(is_readable(ONYX."lang/".$OPT["type"].".xml"))
|
||||
trigger_error("You run the version 2 of Onyx language module. Convert your XML language file into JSON files (see Onyx website : http://onyx.halo-battle.fr/).", E_USER_ERROR);
|
||||
else
|
||||
trigger_error('Language directory not found or unreadable.', E_USER_ERROR);
|
||||
}
|
||||
|
||||
define('LANG', $OPT['type']);
|
||||
|
||||
/**
|
||||
* Classe gérant les chargements dynamiques des fichiers de langue
|
||||
*/
|
||||
class Lang
|
||||
{
|
||||
private static $loaded = array();
|
||||
|
||||
private static function loadFile($file, $lang = LANG)
|
||||
{
|
||||
if (is_array($file))
|
||||
$filename = ONYX."lang/".$lang."/".implode("/", $file).".json";
|
||||
else
|
||||
$filename = ONYX."lang/".$lang."/".$file.".json";
|
||||
|
||||
if(!is_readable($filename))
|
||||
{
|
||||
if (is_array($file))
|
||||
trigger_error("Language file $lang/".implode("/", $file)." not found or unreadable.", E_USER_ERROR);
|
||||
else
|
||||
trigger_error("Language file $lang/$file not found or unreadable.", E_USER_ERROR);
|
||||
}
|
||||
|
||||
//Lang::loaded[md5($filename)] = json_decode(file_get_contents($filename), true);
|
||||
Lang::$loaded[$filename] = json_decode(file_get_contents($filename), true);
|
||||
}
|
||||
|
||||
public static function getText($file, $path, $lang = LANG)
|
||||
{
|
||||
if (is_array($file))
|
||||
$filename = ONYX."lang/".$lang."/".implode("/", $file).".json";
|
||||
else
|
||||
$filename = ONYX."lang/".$lang."/".$file.".json";
|
||||
//$filename = md5($filename);
|
||||
|
||||
if (empty(Lang::$loaded[$filename]))
|
||||
Lang::loadFile($file, $lang);
|
||||
|
||||
if (!is_array($path) && preg_match("#/#", $path))
|
||||
$path = explode("/", $path);
|
||||
|
||||
if (is_array($path))
|
||||
{
|
||||
$ret = Lang::$loaded[$filename];
|
||||
|
||||
foreach($path as $p)
|
||||
{
|
||||
$ret = $ret[$p];
|
||||
}
|
||||
|
||||
return $ret;
|
||||
}
|
||||
else
|
||||
return Lang::$loaded[$filename][$path];
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
2320
onyx2/modules/mail/class.phpmailer.php
Normal file
2320
onyx2/modules/mail/class.phpmailer.php
Normal file
File diff suppressed because it is too large
Load diff
407
onyx2/modules/mail/class.pop3.php
Normal file
407
onyx2/modules/mail/class.pop3.php
Normal file
|
|
@ -0,0 +1,407 @@
|
|||
<?php
|
||||
/*~ class.pop3.php
|
||||
.---------------------------------------------------------------------------.
|
||||
| Software: PHPMailer - PHP email class |
|
||||
| Version: 5.1 |
|
||||
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
|
||||
| Info: http://phpmailer.sourceforge.net |
|
||||
| Support: http://sourceforge.net/projects/phpmailer/ |
|
||||
| ------------------------------------------------------------------------- |
|
||||
| Admin: Andy Prevost (project admininistrator) |
|
||||
| Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net |
|
||||
| : Marcus Bointon (coolbru) coolbru@users.sourceforge.net |
|
||||
| Founder: Brent R. Matzelle (original founder) |
|
||||
| Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. |
|
||||
| Copyright (c) 2001-2003, Brent R. Matzelle |
|
||||
| ------------------------------------------------------------------------- |
|
||||
| License: Distributed under the Lesser General Public License (LGPL) |
|
||||
| http://www.gnu.org/copyleft/lesser.html |
|
||||
| This program is distributed in the hope that it will be useful - WITHOUT |
|
||||
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
||||
| FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| ------------------------------------------------------------------------- |
|
||||
| We offer a number of paid services (www.codeworxtech.com): |
|
||||
| - Web Hosting on highly optimized fast and secure servers |
|
||||
| - Technology Consulting |
|
||||
| - Oursourcing (highly qualified programmers and graphic designers) |
|
||||
'---------------------------------------------------------------------------'
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPMailer - PHP POP Before SMTP Authentication Class
|
||||
* NOTE: Designed for use with PHP version 5 and up
|
||||
* @package PHPMailer
|
||||
* @author Andy Prevost
|
||||
* @author Marcus Bointon
|
||||
* @copyright 2004 - 2009 Andy Prevost
|
||||
* @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL)
|
||||
* @version $Id: class.pop3.php 444 2009-05-05 11:22:26Z coolbru $
|
||||
*/
|
||||
|
||||
/**
|
||||
* POP Before SMTP Authentication Class
|
||||
* Version 5.0.0
|
||||
*
|
||||
* Author: Richard Davey (rich@corephp.co.uk)
|
||||
* Modifications: Andy Prevost
|
||||
* License: LGPL, see PHPMailer License
|
||||
*
|
||||
* Specifically for PHPMailer to allow POP before SMTP authentication.
|
||||
* Does not yet work with APOP - if you have an APOP account, contact Richard Davey
|
||||
* and we can test changes to this script.
|
||||
*
|
||||
* This class is based on the structure of the SMTP class originally authored by Chris Ryan
|
||||
*
|
||||
* This class is rfc 1939 compliant and implements all the commands
|
||||
* required for POP3 connection, authentication and disconnection.
|
||||
*
|
||||
* @package PHPMailer
|
||||
* @author Richard Davey
|
||||
*/
|
||||
|
||||
class POP3 {
|
||||
/**
|
||||
* Default POP3 port
|
||||
* @var int
|
||||
*/
|
||||
public $POP3_PORT = 110;
|
||||
|
||||
/**
|
||||
* Default Timeout
|
||||
* @var int
|
||||
*/
|
||||
public $POP3_TIMEOUT = 30;
|
||||
|
||||
/**
|
||||
* POP3 Carriage Return + Line Feed
|
||||
* @var string
|
||||
*/
|
||||
public $CRLF = "\r\n";
|
||||
|
||||
/**
|
||||
* Displaying Debug warnings? (0 = now, 1+ = yes)
|
||||
* @var int
|
||||
*/
|
||||
public $do_debug = 2;
|
||||
|
||||
/**
|
||||
* POP3 Mail Server
|
||||
* @var string
|
||||
*/
|
||||
public $host;
|
||||
|
||||
/**
|
||||
* POP3 Port
|
||||
* @var int
|
||||
*/
|
||||
public $port;
|
||||
|
||||
/**
|
||||
* POP3 Timeout Value
|
||||
* @var int
|
||||
*/
|
||||
public $tval;
|
||||
|
||||
/**
|
||||
* POP3 Username
|
||||
* @var string
|
||||
*/
|
||||
public $username;
|
||||
|
||||
/**
|
||||
* POP3 Password
|
||||
* @var string
|
||||
*/
|
||||
public $password;
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// PROPERTIES, PRIVATE AND PROTECTED
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
private $pop_conn;
|
||||
private $connected;
|
||||
private $error; // Error log array
|
||||
|
||||
/**
|
||||
* Constructor, sets the initial values
|
||||
* @access public
|
||||
* @return POP3
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->pop_conn = 0;
|
||||
$this->connected = false;
|
||||
$this->error = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Combination of public events - connect, login, disconnect
|
||||
* @access public
|
||||
* @param string $host
|
||||
* @param integer $port
|
||||
* @param integer $tval
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
*/
|
||||
public function Authorise ($host, $port = false, $tval = false, $username, $password, $debug_level = 0) {
|
||||
$this->host = $host;
|
||||
|
||||
// If no port value is passed, retrieve it
|
||||
if ($port == false) {
|
||||
$this->port = $this->POP3_PORT;
|
||||
} else {
|
||||
$this->port = $port;
|
||||
}
|
||||
|
||||
// If no port value is passed, retrieve it
|
||||
if ($tval == false) {
|
||||
$this->tval = $this->POP3_TIMEOUT;
|
||||
} else {
|
||||
$this->tval = $tval;
|
||||
}
|
||||
|
||||
$this->do_debug = $debug_level;
|
||||
$this->username = $username;
|
||||
$this->password = $password;
|
||||
|
||||
// Refresh the error log
|
||||
$this->error = null;
|
||||
|
||||
// Connect
|
||||
$result = $this->Connect($this->host, $this->port, $this->tval);
|
||||
|
||||
if ($result) {
|
||||
$login_result = $this->Login($this->username, $this->password);
|
||||
|
||||
if ($login_result) {
|
||||
$this->Disconnect();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// We need to disconnect regardless if the login succeeded
|
||||
$this->Disconnect();
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Connect to the POP3 server
|
||||
* @access public
|
||||
* @param string $host
|
||||
* @param integer $port
|
||||
* @param integer $tval
|
||||
* @return boolean
|
||||
*/
|
||||
public function Connect ($host, $port = false, $tval = 30) {
|
||||
// Are we already connected?
|
||||
if ($this->connected) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/*
|
||||
On Windows this will raise a PHP Warning error if the hostname doesn't exist.
|
||||
Rather than supress it with @fsockopen, let's capture it cleanly instead
|
||||
*/
|
||||
|
||||
set_error_handler(array(&$this, 'catchWarning'));
|
||||
|
||||
// Connect to the POP3 server
|
||||
$this->pop_conn = fsockopen($host, // POP3 Host
|
||||
$port, // Port #
|
||||
$errno, // Error Number
|
||||
$errstr, // Error Message
|
||||
$tval); // Timeout (seconds)
|
||||
|
||||
// Restore the error handler
|
||||
restore_error_handler();
|
||||
|
||||
// Does the Error Log now contain anything?
|
||||
if ($this->error && $this->do_debug >= 1) {
|
||||
$this->displayErrors();
|
||||
}
|
||||
|
||||
// Did we connect?
|
||||
if ($this->pop_conn == false) {
|
||||
// It would appear not...
|
||||
$this->error = array(
|
||||
'error' => "Failed to connect to server $host on port $port",
|
||||
'errno' => $errno,
|
||||
'errstr' => $errstr
|
||||
);
|
||||
|
||||
if ($this->do_debug >= 1) {
|
||||
$this->displayErrors();
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Increase the stream time-out
|
||||
|
||||
// Check for PHP 4.3.0 or later
|
||||
if (version_compare(phpversion(), '5.0.0', 'ge')) {
|
||||
stream_set_timeout($this->pop_conn, $tval, 0);
|
||||
} else {
|
||||
// Does not work on Windows
|
||||
if (substr(PHP_OS, 0, 3) !== 'WIN') {
|
||||
socket_set_timeout($this->pop_conn, $tval, 0);
|
||||
}
|
||||
}
|
||||
|
||||
// Get the POP3 server response
|
||||
$pop3_response = $this->getResponse();
|
||||
|
||||
// Check for the +OK
|
||||
if ($this->checkResponse($pop3_response)) {
|
||||
// The connection is established and the POP3 server is talking
|
||||
$this->connected = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Login to the POP3 server (does not support APOP yet)
|
||||
* @access public
|
||||
* @param string $username
|
||||
* @param string $password
|
||||
* @return boolean
|
||||
*/
|
||||
public function Login ($username = '', $password = '') {
|
||||
if ($this->connected == false) {
|
||||
$this->error = 'Not connected to POP3 server';
|
||||
|
||||
if ($this->do_debug >= 1) {
|
||||
$this->displayErrors();
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($username)) {
|
||||
$username = $this->username;
|
||||
}
|
||||
|
||||
if (empty($password)) {
|
||||
$password = $this->password;
|
||||
}
|
||||
|
||||
$pop_username = "USER $username" . $this->CRLF;
|
||||
$pop_password = "PASS $password" . $this->CRLF;
|
||||
|
||||
// Send the Username
|
||||
$this->sendString($pop_username);
|
||||
$pop3_response = $this->getResponse();
|
||||
|
||||
if ($this->checkResponse($pop3_response)) {
|
||||
// Send the Password
|
||||
$this->sendString($pop_password);
|
||||
$pop3_response = $this->getResponse();
|
||||
|
||||
if ($this->checkResponse($pop3_response)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnect from the POP3 server
|
||||
* @access public
|
||||
*/
|
||||
public function Disconnect () {
|
||||
$this->sendString('QUIT');
|
||||
|
||||
fclose($this->pop_conn);
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// Private Methods
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Get the socket response back.
|
||||
* $size is the maximum number of bytes to retrieve
|
||||
* @access private
|
||||
* @param integer $size
|
||||
* @return string
|
||||
*/
|
||||
private function getResponse ($size = 128) {
|
||||
$pop3_response = fgets($this->pop_conn, $size);
|
||||
|
||||
return $pop3_response;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a string down the open socket connection to the POP3 server
|
||||
* @access private
|
||||
* @param string $string
|
||||
* @return integer
|
||||
*/
|
||||
private function sendString ($string) {
|
||||
$bytes_sent = fwrite($this->pop_conn, $string, strlen($string));
|
||||
|
||||
return $bytes_sent;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the POP3 server response for +OK or -ERR
|
||||
* @access private
|
||||
* @param string $string
|
||||
* @return boolean
|
||||
*/
|
||||
private function checkResponse ($string) {
|
||||
if (substr($string, 0, 3) !== '+OK') {
|
||||
$this->error = array(
|
||||
'error' => "Server reported an error: $string",
|
||||
'errno' => 0,
|
||||
'errstr' => ''
|
||||
);
|
||||
|
||||
if ($this->do_debug >= 1) {
|
||||
$this->displayErrors();
|
||||
}
|
||||
|
||||
return false;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* If debug is enabled, display the error message array
|
||||
* @access private
|
||||
*/
|
||||
private function displayErrors () {
|
||||
echo '<pre>';
|
||||
|
||||
foreach ($this->error as $single_error) {
|
||||
print_r($single_error);
|
||||
}
|
||||
|
||||
echo '</pre>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes over from PHP for the socket warning handler
|
||||
* @access private
|
||||
* @param integer $errno
|
||||
* @param string $errstr
|
||||
* @param string $errfile
|
||||
* @param integer $errline
|
||||
*/
|
||||
private function catchWarning ($errno, $errstr, $errfile, $errline) {
|
||||
$this->error[] = array(
|
||||
'error' => "Connecting to the POP3 server raised a PHP warning: ",
|
||||
'errno' => $errno,
|
||||
'errstr' => $errstr
|
||||
);
|
||||
}
|
||||
|
||||
// End of class
|
||||
}
|
||||
?>
|
||||
814
onyx2/modules/mail/class.smtp.php
Normal file
814
onyx2/modules/mail/class.smtp.php
Normal file
|
|
@ -0,0 +1,814 @@
|
|||
<?php
|
||||
/*~ class.smtp.php
|
||||
.---------------------------------------------------------------------------.
|
||||
| Software: PHPMailer - PHP email class |
|
||||
| Version: 5.1 |
|
||||
| Contact: via sourceforge.net support pages (also www.codeworxtech.com) |
|
||||
| Info: http://phpmailer.sourceforge.net |
|
||||
| Support: http://sourceforge.net/projects/phpmailer/ |
|
||||
| ------------------------------------------------------------------------- |
|
||||
| Admin: Andy Prevost (project admininistrator) |
|
||||
| Authors: Andy Prevost (codeworxtech) codeworxtech@users.sourceforge.net |
|
||||
| : Marcus Bointon (coolbru) coolbru@users.sourceforge.net |
|
||||
| Founder: Brent R. Matzelle (original founder) |
|
||||
| Copyright (c) 2004-2009, Andy Prevost. All Rights Reserved. |
|
||||
| Copyright (c) 2001-2003, Brent R. Matzelle |
|
||||
| ------------------------------------------------------------------------- |
|
||||
| License: Distributed under the Lesser General Public License (LGPL) |
|
||||
| http://www.gnu.org/copyleft/lesser.html |
|
||||
| This program is distributed in the hope that it will be useful - WITHOUT |
|
||||
| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
||||
| FITNESS FOR A PARTICULAR PURPOSE. |
|
||||
| ------------------------------------------------------------------------- |
|
||||
| We offer a number of paid services (www.codeworxtech.com): |
|
||||
| - Web Hosting on highly optimized fast and secure servers |
|
||||
| - Technology Consulting |
|
||||
| - Oursourcing (highly qualified programmers and graphic designers) |
|
||||
'---------------------------------------------------------------------------'
|
||||
*/
|
||||
|
||||
/**
|
||||
* PHPMailer - PHP SMTP email transport class
|
||||
* NOTE: Designed for use with PHP version 5 and up
|
||||
* @package PHPMailer
|
||||
* @author Andy Prevost
|
||||
* @author Marcus Bointon
|
||||
* @copyright 2004 - 2008 Andy Prevost
|
||||
* @license http://www.gnu.org/copyleft/lesser.html Distributed under the Lesser General Public License (LGPL)
|
||||
* @version $Id: class.smtp.php 444 2009-05-05 11:22:26Z coolbru $
|
||||
*/
|
||||
|
||||
/**
|
||||
* SMTP is rfc 821 compliant and implements all the rfc 821 SMTP
|
||||
* commands except TURN which will always return a not implemented
|
||||
* error. SMTP also provides some utility methods for sending mail
|
||||
* to an SMTP server.
|
||||
* original author: Chris Ryan
|
||||
*/
|
||||
|
||||
class SMTP {
|
||||
/**
|
||||
* SMTP server port
|
||||
* @var int
|
||||
*/
|
||||
public $SMTP_PORT = 25;
|
||||
|
||||
/**
|
||||
* SMTP reply line ending
|
||||
* @var string
|
||||
*/
|
||||
public $CRLF = "\r\n";
|
||||
|
||||
/**
|
||||
* Sets whether debugging is turned on
|
||||
* @var bool
|
||||
*/
|
||||
public $do_debug; // the level of debug to perform
|
||||
|
||||
/**
|
||||
* Sets VERP use on/off (default is off)
|
||||
* @var bool
|
||||
*/
|
||||
public $do_verp = false;
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// PROPERTIES, PRIVATE AND PROTECTED
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
private $smtp_conn; // the socket to the server
|
||||
private $error; // error if any on the last call
|
||||
private $helo_rply; // the reply the server sent to us for HELO
|
||||
|
||||
/**
|
||||
* Initialize the class so that the data is in a known state.
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->smtp_conn = 0;
|
||||
$this->error = null;
|
||||
$this->helo_rply = null;
|
||||
|
||||
$this->do_debug = 0;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// CONNECTION FUNCTIONS
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Connect to the server specified on the port specified.
|
||||
* If the port is not specified use the default SMTP_PORT.
|
||||
* If tval is specified then a connection will try and be
|
||||
* established with the server for that number of seconds.
|
||||
* If tval is not specified the default is 30 seconds to
|
||||
* try on the connection.
|
||||
*
|
||||
* SMTP CODE SUCCESS: 220
|
||||
* SMTP CODE FAILURE: 421
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Connect($host, $port = 0, $tval = 30) {
|
||||
// set the error val to null so there is no confusion
|
||||
$this->error = null;
|
||||
|
||||
// make sure we are __not__ connected
|
||||
if($this->connected()) {
|
||||
// already connected, generate error
|
||||
$this->error = array("error" => "Already connected to a server");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(empty($port)) {
|
||||
$port = $this->SMTP_PORT;
|
||||
}
|
||||
|
||||
// connect to the smtp server
|
||||
$this->smtp_conn = @fsockopen($host, // the host of the server
|
||||
$port, // the port to use
|
||||
$errno, // error number if any
|
||||
$errstr, // error message if any
|
||||
$tval); // give up after ? secs
|
||||
// verify we connected properly
|
||||
if(empty($this->smtp_conn)) {
|
||||
$this->error = array("error" => "Failed to connect to server",
|
||||
"errno" => $errno,
|
||||
"errstr" => $errstr);
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// SMTP server can take longer to respond, give longer timeout for first read
|
||||
// Windows does not have support for this timeout function
|
||||
if(substr(PHP_OS, 0, 3) != "WIN")
|
||||
socket_set_timeout($this->smtp_conn, $tval, 0);
|
||||
|
||||
// get any announcement
|
||||
$announce = $this->get_lines();
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initiate a TLS communication with the server.
|
||||
*
|
||||
* SMTP CODE 220 Ready to start TLS
|
||||
* SMTP CODE 501 Syntax error (no parameters allowed)
|
||||
* SMTP CODE 454 TLS not available due to temporary reason
|
||||
* @access public
|
||||
* @return bool success
|
||||
*/
|
||||
public function StartTLS() {
|
||||
$this->error = null; # to avoid confusion
|
||||
|
||||
if(!$this->connected()) {
|
||||
$this->error = array("error" => "Called StartTLS() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"STARTTLS" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
if($code != 220) {
|
||||
$this->error =
|
||||
array("error" => "STARTTLS not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Begin encrypted connection
|
||||
if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs SMTP authentication. Must be run after running the
|
||||
* Hello() method. Returns true if successfully authenticated.
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Authenticate($username, $password) {
|
||||
// Start authentication
|
||||
fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($code != 334) {
|
||||
$this->error =
|
||||
array("error" => "AUTH not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Send encoded username
|
||||
fputs($this->smtp_conn, base64_encode($username) . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($code != 334) {
|
||||
$this->error =
|
||||
array("error" => "Username not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// Send encoded password
|
||||
fputs($this->smtp_conn, base64_encode($password) . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($code != 235) {
|
||||
$this->error =
|
||||
array("error" => "Password not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if connected to a server otherwise false
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Connected() {
|
||||
if(!empty($this->smtp_conn)) {
|
||||
$sock_status = socket_get_status($this->smtp_conn);
|
||||
if($sock_status["eof"]) {
|
||||
// the socket is valid but we are not connected
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected";
|
||||
}
|
||||
$this->Close();
|
||||
return false;
|
||||
}
|
||||
return true; // everything looks good
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Closes the socket and cleans up the state of the class.
|
||||
* It is not considered good to use this function without
|
||||
* first trying to use QUIT.
|
||||
* @access public
|
||||
* @return void
|
||||
*/
|
||||
public function Close() {
|
||||
$this->error = null; // so there is no confusion
|
||||
$this->helo_rply = null;
|
||||
if(!empty($this->smtp_conn)) {
|
||||
// close the connection and cleanup
|
||||
fclose($this->smtp_conn);
|
||||
$this->smtp_conn = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// SMTP COMMANDS
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Issues a data command and sends the msg_data to the server
|
||||
* finializing the mail transaction. $msg_data is the message
|
||||
* that is to be send with the headers. Each header needs to be
|
||||
* on a single line followed by a <CRLF> with the message headers
|
||||
* and the message body being seperated by and additional <CRLF>.
|
||||
*
|
||||
* Implements rfc 821: DATA <CRLF>
|
||||
*
|
||||
* SMTP CODE INTERMEDIATE: 354
|
||||
* [data]
|
||||
* <CRLF>.<CRLF>
|
||||
* SMTP CODE SUCCESS: 250
|
||||
* SMTP CODE FAILURE: 552,554,451,452
|
||||
* SMTP CODE FAILURE: 451,554
|
||||
* SMTP CODE ERROR : 500,501,503,421
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Data($msg_data) {
|
||||
$this->error = null; // so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Data() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"DATA" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
if($code != 354) {
|
||||
$this->error =
|
||||
array("error" => "DATA command not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/* the server is ready to accept data!
|
||||
* according to rfc 821 we should not send more than 1000
|
||||
* including the CRLF
|
||||
* characters on a single line so we will break the data up
|
||||
* into lines by \r and/or \n then if needed we will break
|
||||
* each of those into smaller lines to fit within the limit.
|
||||
* in addition we will be looking for lines that start with
|
||||
* a period '.' and append and additional period '.' to that
|
||||
* line. NOTE: this does not count towards limit.
|
||||
*/
|
||||
|
||||
// normalize the line breaks so we know the explode works
|
||||
$msg_data = str_replace("\r\n","\n",$msg_data);
|
||||
$msg_data = str_replace("\r","\n",$msg_data);
|
||||
$lines = explode("\n",$msg_data);
|
||||
|
||||
/* we need to find a good way to determine is headers are
|
||||
* in the msg_data or if it is a straight msg body
|
||||
* currently I am assuming rfc 822 definitions of msg headers
|
||||
* and if the first field of the first line (':' sperated)
|
||||
* does not contain a space then it _should_ be a header
|
||||
* and we can process all lines before a blank "" line as
|
||||
* headers.
|
||||
*/
|
||||
|
||||
$field = substr($lines[0],0,strpos($lines[0],":"));
|
||||
$in_headers = false;
|
||||
if(!empty($field) && !strstr($field," ")) {
|
||||
$in_headers = true;
|
||||
}
|
||||
|
||||
$max_line_length = 998; // used below; set here for ease in change
|
||||
|
||||
while(list(,$line) = @each($lines)) {
|
||||
$lines_out = null;
|
||||
if($line == "" && $in_headers) {
|
||||
$in_headers = false;
|
||||
}
|
||||
// ok we need to break this line up into several smaller lines
|
||||
while(strlen($line) > $max_line_length) {
|
||||
$pos = strrpos(substr($line,0,$max_line_length)," ");
|
||||
|
||||
// Patch to fix DOS attack
|
||||
if(!$pos) {
|
||||
$pos = $max_line_length - 1;
|
||||
$lines_out[] = substr($line,0,$pos);
|
||||
$line = substr($line,$pos);
|
||||
} else {
|
||||
$lines_out[] = substr($line,0,$pos);
|
||||
$line = substr($line,$pos + 1);
|
||||
}
|
||||
|
||||
/* if processing headers add a LWSP-char to the front of new line
|
||||
* rfc 822 on long msg headers
|
||||
*/
|
||||
if($in_headers) {
|
||||
$line = "\t" . $line;
|
||||
}
|
||||
}
|
||||
$lines_out[] = $line;
|
||||
|
||||
// send the lines to the server
|
||||
while(list(,$line_out) = @each($lines_out)) {
|
||||
if(strlen($line_out) > 0)
|
||||
{
|
||||
if(substr($line_out, 0, 1) == ".") {
|
||||
$line_out = "." . $line_out;
|
||||
}
|
||||
}
|
||||
fputs($this->smtp_conn,$line_out . $this->CRLF);
|
||||
}
|
||||
}
|
||||
|
||||
// message data has been sent
|
||||
fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "DATA not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the HELO command to the smtp server.
|
||||
* This makes sure that we and the server are in
|
||||
* the same known state.
|
||||
*
|
||||
* Implements from rfc 821: HELO <SP> <domain> <CRLF>
|
||||
*
|
||||
* SMTP CODE SUCCESS: 250
|
||||
* SMTP CODE ERROR : 500, 501, 504, 421
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Hello($host = '') {
|
||||
$this->error = null; // so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Hello() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
// if hostname for HELO was not specified send default
|
||||
if(empty($host)) {
|
||||
// determine appropriate default to send to server
|
||||
$host = "localhost";
|
||||
}
|
||||
|
||||
// Send extended hello first (RFC 2821)
|
||||
if(!$this->SendHello("EHLO", $host)) {
|
||||
if(!$this->SendHello("HELO", $host)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends a HELO/EHLO command.
|
||||
* @access private
|
||||
* @return bool
|
||||
*/
|
||||
private function SendHello($hello, $host) {
|
||||
fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
$this->error =
|
||||
array("error" => $hello . " not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->helo_rply = $rply;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a mail transaction from the email address specified in
|
||||
* $from. Returns true if successful or false otherwise. If True
|
||||
* the mail transaction is started and then one or more Recipient
|
||||
* commands may be called followed by a Data command.
|
||||
*
|
||||
* Implements rfc 821: MAIL <SP> FROM:<reverse-path> <CRLF>
|
||||
*
|
||||
* SMTP CODE SUCCESS: 250
|
||||
* SMTP CODE SUCCESS: 552,451,452
|
||||
* SMTP CODE SUCCESS: 500,501,421
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Mail($from) {
|
||||
$this->error = null; // so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Mail() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
$useVerp = ($this->do_verp ? "XVERP" : "");
|
||||
fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "MAIL not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the quit command to the server and then closes the socket
|
||||
* if there is no error or the $close_on_error argument is true.
|
||||
*
|
||||
* Implements from rfc 821: QUIT <CRLF>
|
||||
*
|
||||
* SMTP CODE SUCCESS: 221
|
||||
* SMTP CODE ERROR : 500
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Quit($close_on_error = true) {
|
||||
$this->error = null; // so there is no confusion
|
||||
|
||||
if(!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Quit() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
// send the quit command to the server
|
||||
fputs($this->smtp_conn,"quit" . $this->CRLF);
|
||||
|
||||
// get any good-bye messages
|
||||
$byemsg = $this->get_lines();
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
$rval = true;
|
||||
$e = null;
|
||||
|
||||
$code = substr($byemsg,0,3);
|
||||
if($code != 221) {
|
||||
// use e as a tmp var cause Close will overwrite $this->error
|
||||
$e = array("error" => "SMTP server rejected quit command",
|
||||
"smtp_code" => $code,
|
||||
"smtp_rply" => substr($byemsg,4));
|
||||
$rval = false;
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
if(empty($e) || $close_on_error) {
|
||||
$this->Close();
|
||||
}
|
||||
|
||||
return $rval;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the command RCPT to the SMTP server with the TO: argument of $to.
|
||||
* Returns true if the recipient was accepted false if it was rejected.
|
||||
*
|
||||
* Implements from rfc 821: RCPT <SP> TO:<forward-path> <CRLF>
|
||||
*
|
||||
* SMTP CODE SUCCESS: 250,251
|
||||
* SMTP CODE FAILURE: 550,551,552,553,450,451,452
|
||||
* SMTP CODE ERROR : 500,501,503,421
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Recipient($to) {
|
||||
$this->error = null; // so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Recipient() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
if($code != 250 && $code != 251) {
|
||||
$this->error =
|
||||
array("error" => "RCPT not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends the RSET command to abort and transaction that is
|
||||
* currently in progress. Returns true if successful false
|
||||
* otherwise.
|
||||
*
|
||||
* Implements rfc 821: RSET <CRLF>
|
||||
*
|
||||
* SMTP CODE SUCCESS: 250
|
||||
* SMTP CODE ERROR : 500,501,504,421
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Reset() {
|
||||
$this->error = null; // so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called Reset() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"RSET" . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "RSET failed",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a mail transaction from the email address specified in
|
||||
* $from. Returns true if successful or false otherwise. If True
|
||||
* the mail transaction is started and then one or more Recipient
|
||||
* commands may be called followed by a Data command. This command
|
||||
* will send the message to the users terminal if they are logged
|
||||
* in and send them an email.
|
||||
*
|
||||
* Implements rfc 821: SAML <SP> FROM:<reverse-path> <CRLF>
|
||||
*
|
||||
* SMTP CODE SUCCESS: 250
|
||||
* SMTP CODE SUCCESS: 552,451,452
|
||||
* SMTP CODE SUCCESS: 500,501,502,421
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function SendAndMail($from) {
|
||||
$this->error = null; // so no confusion is caused
|
||||
|
||||
if(!$this->connected()) {
|
||||
$this->error = array(
|
||||
"error" => "Called SendAndMail() without being connected");
|
||||
return false;
|
||||
}
|
||||
|
||||
fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF);
|
||||
|
||||
$rply = $this->get_lines();
|
||||
$code = substr($rply,0,3);
|
||||
|
||||
if($this->do_debug >= 2) {
|
||||
echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
|
||||
if($code != 250) {
|
||||
$this->error =
|
||||
array("error" => "SAML not accepted from server",
|
||||
"smtp_code" => $code,
|
||||
"smtp_msg" => substr($rply,4));
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is an optional command for SMTP that this class does not
|
||||
* support. This method is here to make the RFC821 Definition
|
||||
* complete for this class and __may__ be implimented in the future
|
||||
*
|
||||
* Implements from rfc 821: TURN <CRLF>
|
||||
*
|
||||
* SMTP CODE SUCCESS: 250
|
||||
* SMTP CODE FAILURE: 502
|
||||
* SMTP CODE ERROR : 500, 503
|
||||
* @access public
|
||||
* @return bool
|
||||
*/
|
||||
public function Turn() {
|
||||
$this->error = array("error" => "This method, TURN, of the SMTP ".
|
||||
"is not implemented");
|
||||
if($this->do_debug >= 1) {
|
||||
echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '<br />';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the current error
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getError() {
|
||||
return $this->error;
|
||||
}
|
||||
|
||||
/////////////////////////////////////////////////
|
||||
// INTERNAL FUNCTIONS
|
||||
/////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Read in as many lines as possible
|
||||
* either before eof or socket timeout occurs on the operation.
|
||||
* With SMTP we can tell if we have more lines to read if the
|
||||
* 4th character is '-' symbol. If it is a space then we don't
|
||||
* need to read anything else.
|
||||
* @access private
|
||||
* @return string
|
||||
*/
|
||||
private function get_lines() {
|
||||
$data = "";
|
||||
while($str = @fgets($this->smtp_conn,515)) {
|
||||
if($this->do_debug >= 4) {
|
||||
echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '<br />';
|
||||
echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '<br />';
|
||||
}
|
||||
$data .= $str;
|
||||
if($this->do_debug >= 4) {
|
||||
echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '<br />';
|
||||
}
|
||||
// if 4th character is a space, we are done reading, break the loop
|
||||
if(substr($str,3,1) == " ") { break; }
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
26
onyx2/modules/mail/language/phpmailer.lang-ar.php
Normal file
26
onyx2/modules/mail/language/phpmailer.lang-ar.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Arabic Version, UTF-8
|
||||
* by : bahjat al mostafa <bahjat983@hotmail.com>
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'You must provide at least one ' .
|
||||
'recipient email address.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer غير مدعوم.';
|
||||
$PHPMAILER_LANG['execute'] = 'لم أستطع تنفيذ : ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'لم نستطع توفير خدمة البريد.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTP Error: لم نستطع تأكيد الهوية.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'البريد التالي لم نستطع ارسال البريد له : ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: الأخطاء التالية ' .
|
||||
'فشل في الارسال لكل من : ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: لم يتم قبول المعلومات .';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP Error: لم نستطع الاتصال بمخدم SMTP.';
|
||||
$PHPMAILER_LANG['file_access'] = 'لم نستطع الوصول للملف: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'File Error: لم نستطع فتح الملف: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'ترميز غير معروف: ';
|
||||
$PHPMAILER_LANG['signing'] = 'خطأ في التوقيع: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
23
onyx2/modules/mail/language/phpmailer.lang-br.php
Normal file
23
onyx2/modules/mail/language/phpmailer.lang-br.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Portuguese Version
|
||||
* By Paulo Henrique Garcia - paulo@controllerweb.com.br
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
$PHPMAILER_LANG['provide_address'] = 'Você deve fornecer pelo menos um endereço de destinatário de email.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer não suportado.';
|
||||
$PHPMAILER_LANG['execute'] = 'Não foi possível executar: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'Não foi possível instanciar a função mail.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'Erro de SMTP: Não foi possível autenticar.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'Os endereços de rementente a seguir falharam: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'Erro de SMTP: Os endereços de destinatário a seguir falharam: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'Erro de SMTP: Dados não aceitos.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'Erro de SMTP: Não foi possível conectar com o servidor SMTP.';
|
||||
$PHPMAILER_LANG['file_access'] = 'Não foi possível acessar o arquivo: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Erro de Arquivo: Não foi possível abrir o arquivo: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Codificação desconhecida: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
24
onyx2/modules/mail/language/phpmailer.lang-ca.php
Normal file
24
onyx2/modules/mail/language/phpmailer.lang-ca.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Catalan Version
|
||||
* By Ivan: web AT microstudi DOT com
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'S\'ha de proveir almenys una adreça d\'email com a destinatari.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer no està suportat';
|
||||
$PHPMAILER_LANG['execute'] = 'No es pot executar: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'No s\'ha pogut crear una instància de la funció Mail.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'Error SMTP: No s\'hapogut autenticar.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'La(s) següent(s) adreces de remitent han fallat: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'Error SMTP: Els següents destinataris han fallat: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'Error SMTP: Dades no acceptades.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'Error SMTP: No es pot connectar al servidor SMTP.';
|
||||
$PHPMAILER_LANG['file_access'] = 'No es pot accedir a l\'arxiu: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Error d\'Arxiu: No es pot obrir l\'arxiu: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Codificació desconeguda: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
24
onyx2/modules/mail/language/phpmailer.lang-ch.php
Normal file
24
onyx2/modules/mail/language/phpmailer.lang-ch.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Chinese Version
|
||||
* By LiuXin: www.80x86.cn/blog/
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = '您必须提供至少一个 收信人的email地址。';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' 您所选择的发送邮件的方法并不支持。';
|
||||
$PHPMAILER_LANG['execute'] = '不能执行: ';
|
||||
$PHPMAILER_LANG['instantiate'] = '不能实现mail方法。';
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTP 错误:身份验证失败。';
|
||||
$PHPMAILER_LANG['from_failed'] = '下面的发送地址邮件发送失败了: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTP 错误: 下面的 收件人失败了: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP 错误: 数据不可接受。';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP 错误: 不能连接SMTP主机。';
|
||||
$PHPMAILER_LANG['file_access'] = '不能访问文件:';
|
||||
$PHPMAILER_LANG['file_open'] = '文件错误:不能打开文件:';
|
||||
$PHPMAILER_LANG['encoding'] = '未知编码:';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
23
onyx2/modules/mail/language/phpmailer.lang-cz.php
Normal file
23
onyx2/modules/mail/language/phpmailer.lang-cz.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Czech Version
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG["provide_address"] = 'Musíte zadat alespoò jednu emailovou adresu pøíjemce.';
|
||||
$PHPMAILER_LANG["mailer_not_supported"] = ' mailový klient není podporován.';
|
||||
$PHPMAILER_LANG["execute"] = 'Nelze provést: ';
|
||||
$PHPMAILER_LANG["instantiate"] = 'Nelze vytvoøit instanci emailové funkce.';
|
||||
$PHPMAILER_LANG["authenticate"] = 'SMTP Error: Chyba autentikace.';
|
||||
$PHPMAILER_LANG["from_failed"] = 'Následující adresa From je nesprávná: ';
|
||||
$PHPMAILER_LANG["recipients_failed"] = 'SMTP Error: Adresy pøíjemcù nejsou správné ' .
|
||||
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP Error: Data nebyla pøijata';
|
||||
$PHPMAILER_LANG["connect_host"] = 'SMTP Error: Nelze navázat spojení se SMTP serverem.';
|
||||
$PHPMAILER_LANG["file_access"] = 'Soubor nenalezen: ';
|
||||
$PHPMAILER_LANG["file_open"] = 'File Error: Nelze otevøít soubor pro ètení: ';
|
||||
$PHPMAILER_LANG["encoding"] = 'Neznámé kódování: ';
|
||||
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
24
onyx2/modules/mail/language/phpmailer.lang-de.php
Normal file
24
onyx2/modules/mail/language/phpmailer.lang-de.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* German Version
|
||||
* Thanks to Yann-Patrick Schlame for the latest update!
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'Bitte geben Sie mindestens eine Empfänger Emailadresse an.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer wird nicht unterstützt.';
|
||||
$PHPMAILER_LANG['execute'] = 'Konnte folgenden Befehl nicht ausführen: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'Mail Funktion konnte nicht initialisiert werden.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTP Fehler: Authentifizierung fehlgeschlagen.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'Die folgende Absenderadresse ist nicht korrekt: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Fehler: Die folgenden Empfänger sind nicht korrekt: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Fehler: Daten werden nicht akzeptiert.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP Fehler: Konnte keine Verbindung zum SMTP-Host herstellen.';
|
||||
$PHPMAILER_LANG['file_access'] = 'Zugriff auf folgende Datei fehlgeschlagen: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Datei Fehler: konnte folgende Datei nicht öffnen: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Unbekanntes Encoding-Format: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Fehler beim Signieren: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
23
onyx2/modules/mail/language/phpmailer.lang-dk.php
Normal file
23
onyx2/modules/mail/language/phpmailer.lang-dk.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Danish Version
|
||||
* Author: Mikael Stokkebro <info@stokkebro.dk> */
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'Du skal indtaste mindst en modtagers emailadresse.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer understøttes ikke.';
|
||||
$PHPMAILER_LANG['execute'] = 'Kunne ikke køre: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'Kunne ikke initialisere email funktionen.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTP fejl: Kunne ikke logge på.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'Følgende afsenderadresse er forkert: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTP fejl: Følgende modtagere er forkerte: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP fejl: Data kunne ikke accepteres.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP fejl: Kunne ikke tilslutte SMTP serveren.';
|
||||
$PHPMAILER_LANG['file_access'] = 'Ingen adgang til fil: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Fil fejl: Kunne ikke åbne filen: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Ukendt encode-format: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
23
onyx2/modules/mail/language/phpmailer.lang-en.php
Normal file
23
onyx2/modules/mail/language/phpmailer.lang-en.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* English Version
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'You must provide at least one recipient email address.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer is not supported.';
|
||||
$PHPMAILER_LANG['execute'] = 'Could not execute: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'Could not instantiate mail function.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTP Error: Could not authenticate.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'The following From address failed: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: The following recipients failed: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: Data not accepted.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP Error: Could not connect to SMTP host.';
|
||||
$PHPMAILER_LANG['file_access'] = 'Could not access file: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'File Error: Could not open file: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Unknown encoding: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
23
onyx2/modules/mail/language/phpmailer.lang-es.php
Normal file
23
onyx2/modules/mail/language/phpmailer.lang-es.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Versión en español
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'Debe proveer al menos una dirección de email como destinatario.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer no está soportado.';
|
||||
$PHPMAILER_LANG['execute'] = 'No puedo ejecutar: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'No pude crear una instancia de la función Mail.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'Error SMTP: No se pudo autentificar.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'La(s) siguiente(s) direcciones de remitente fallaron: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'Error SMTP: Los siguientes destinatarios fallaron: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'Error SMTP: Datos no aceptados.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'Error SMTP: No puedo conectar al servidor SMTP.';
|
||||
$PHPMAILER_LANG['file_access'] = 'No puedo acceder al archivo: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Error de Archivo: No puede abrir el archivo: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Codificación desconocida: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Error al firmar: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
24
onyx2/modules/mail/language/phpmailer.lang-et.php
Normal file
24
onyx2/modules/mail/language/phpmailer.lang-et.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Estonian Version
|
||||
* By Indrek Päri
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'Te peate määrama vähemalt ühe saaja e-posti aadressi.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' maileri tugi puudub.';
|
||||
$PHPMAILER_LANG['execute'] = 'Tegevus ebaõnnestus: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'mail funktiooni käivitamine ebaõnnestus.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTP Viga: Autoriseerimise viga.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'Järgnev saatja e-posti aadress on vigane: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Viga: Järgnevate saajate e-posti aadressid on vigased: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Viga: Vigased andmed.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP Viga: Ei õnnestunud luua ühendust SMTP serveriga.';
|
||||
$PHPMAILER_LANG['file_access'] = 'Pole piisavalt õiguseid järgneva faili avamiseks: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Faili Viga: Faili avamine ebaõnnestus: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Tundmatu Unknown kodeering: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
24
onyx2/modules/mail/language/phpmailer.lang-fi.php
Normal file
24
onyx2/modules/mail/language/phpmailer.lang-fi.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Finnish Version
|
||||
* By Jyry Kuukanen
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'Aseta vähintään yksi vastaanottajan sähköpostiosoite.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = 'postivälitintyyppiä ei tueta.';
|
||||
$PHPMAILER_LANG['execute'] = 'Suoritus epäonnistui: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'mail-funktion luonti epäonnistui.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTP-virhe: käyttäjätunnistus epäonnistui.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'Seuraava lähettäjän osoite on virheellinen: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTP-virhe: seuraava vastaanottaja osoite on virheellinen.';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP-virhe: data on virheellinen.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP-virhe: yhteys palvelimeen ei onnistu.';
|
||||
$PHPMAILER_LANG['file_access'] = 'Seuraavaan tiedostoon ei ole oikeuksia: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Tiedostovirhe: Ei voida avata tiedostoa: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Tuntematon koodaustyyppi: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
25
onyx2/modules/mail/language/phpmailer.lang-fo.php
Normal file
25
onyx2/modules/mail/language/phpmailer.lang-fo.php
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Faroese Version [language of the Faroe Islands, a Danish dominion]
|
||||
* This file created: 11-06-2004
|
||||
* Supplied by Dávur Sørensen [www.profo-webdesign.dk]
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'Tú skal uppgeva minst móttakara-emailadressu(r).';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' er ikki supporterað.';
|
||||
$PHPMAILER_LANG['execute'] = 'Kundi ikki útføra: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'Kuni ikki instantiera mail funktión.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTP feilur: Kundi ikki góðkenna.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'fylgjandi Frá/From adressa miseydnaðist: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Feilur: Fylgjandi móttakarar miseydnaðust: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP feilur: Data ikki góðkent.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP feilur: Kundi ikki knýta samband við SMTP vert.';
|
||||
$PHPMAILER_LANG['file_access'] = 'Kundi ikki tilganga fílu: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Fílu feilur: Kundi ikki opna fílu: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Ókend encoding: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
23
onyx2/modules/mail/language/phpmailer.lang-fr.php
Normal file
23
onyx2/modules/mail/language/phpmailer.lang-fr.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* French Version
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'Vous devez fournir au moins une adresse de destinataire.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' client de messagerie non supporté.';
|
||||
$PHPMAILER_LANG['execute'] = 'Impossible de lancer l\'exécution : ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'Impossible d\'instancier la fonction mail.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'Erreur SMTP : Echec de l\'authentification.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'L\'adresse d\'expéditeur suivante a échouée : ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'Erreur SMTP : Les destinataires suivants sont en erreur : ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'Erreur SMTP : Données incorrects.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'Erreur SMTP : Impossible de se connecter au serveur SMTP.';
|
||||
$PHPMAILER_LANG['file_access'] = 'Impossible d\'accéder au fichier : ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Erreur Fichier : ouverture impossible : ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Encodage inconnu : ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
23
onyx2/modules/mail/language/phpmailer.lang-hu.php
Normal file
23
onyx2/modules/mail/language/phpmailer.lang-hu.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Hungarian Version
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'Meg kell adnod legalább egy címzett email címet.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' levelezõ nem támogatott.';
|
||||
$PHPMAILER_LANG['execute'] = 'Nem tudtam végrehajtani: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'Nem sikerült példányosítani a mail funkciót.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTP Hiba: Sikertelen autentikáció.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'Az alábbi Feladó cím hibás: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Hiba: Az alábbi címzettek hibásak: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Hiba: Nem elfogadható adat.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP Hiba: Nem tudtam csatlakozni az SMTP host-hoz.';
|
||||
$PHPMAILER_LANG['file_access'] = 'Nem sikerült elérni a következõ fájlt: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Fájl Hiba: Nem sikerült megnyitni a következõ fájlt: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Ismeretlen kódolás: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
26
onyx2/modules/mail/language/phpmailer.lang-it.php
Normal file
26
onyx2/modules/mail/language/phpmailer.lang-it.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Italian version
|
||||
* @package PHPMailer
|
||||
* @author Ilias Bartolini <brain79@inwind.it>*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'Deve essere fornito almeno un indirizzo ricevente';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = 'Mailer non supportato';
|
||||
$PHPMAILER_LANG['execute'] = 'Impossibile eseguire l\'operazione: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'Impossibile istanziare la funzione mail';
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTP Error: Impossibile autenticarsi.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'I seguenti indirizzi mittenti hanno generato errore: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Error: I seguenti indirizzi'.
|
||||
'destinatari hanno generato errore: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Error: Data non accettati dal'.
|
||||
'server.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP Error: Impossibile connettersi all\'host SMTP.';
|
||||
$PHPMAILER_LANG['file_access'] = 'Impossibile accedere al file: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'File Error: Impossibile aprire il file: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Encoding set dei caratteri sconosciuto: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
24
onyx2/modules/mail/language/phpmailer.lang-ja.php
Normal file
24
onyx2/modules/mail/language/phpmailer.lang-ja.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Japanese Version
|
||||
* By Mitsuhiro Yoshida - http://mitstek.com/
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = '少なくとも1つメールアドレスを 指定する必要があります。';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' メーラーがサポートされていません。';
|
||||
$PHPMAILER_LANG['execute'] = '実行できませんでした: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'メール関数が正常に動作しませんでした。';
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTPエラー: 認証できませんでした。';
|
||||
$PHPMAILER_LANG['from_failed'] = '次のFromアドレスに間違いがあります: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTPエラー: 次の受信者アドレスに 間違いがあります: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTPエラー: データが受け付けられませんでした。';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTPエラー: SMTPホストに接続できませんでした。';
|
||||
$PHPMAILER_LANG['file_access'] = 'ファイルにアクセスできません: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'ファイルエラー: ファイルを開けません: ';
|
||||
$PHPMAILER_LANG['encoding'] = '不明なエンコーディング: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
23
onyx2/modules/mail/language/phpmailer.lang-nl.php
Normal file
23
onyx2/modules/mail/language/phpmailer.lang-nl.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Dutch Version
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'Er moet tenmiste één ontvanger emailadres opgegeven worden.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer wordt niet ondersteund.';
|
||||
$PHPMAILER_LANG['execute'] = 'Kon niet uitvoeren: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'Kon mail functie niet initialiseren.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTP Fout: authenticatie mislukt.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'De volgende afzender adressen zijn mislukt: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Fout: De volgende ontvangers zijn mislukt: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Fout: Data niet geaccepteerd.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP Fout: Kon niet verbinden met SMTP host.';
|
||||
$PHPMAILER_LANG['file_access'] = 'Kreeg geen toegang tot bestand: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Bestandsfout: Kon bestand niet openen: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Onbekende codering: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
23
onyx2/modules/mail/language/phpmailer.lang-no.php
Normal file
23
onyx2/modules/mail/language/phpmailer.lang-no.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Norwegian Version
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'Du må ha med minst en mottager adresse.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer er ikke supportert.';
|
||||
$PHPMAILER_LANG['execute'] = 'Kunne ikke utføre: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'Kunne ikke instantiate mail funksjonen.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTP Feil: Kunne ikke authentisere.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'Følgende Fra feilet: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Feil: Følgende mottagere feilet: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Feil: Data ble ikke akseptert.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP Feil: Kunne ikke koble til SMTP host.';
|
||||
$PHPMAILER_LANG['file_access'] = 'Kunne ikke få tilgang til filen: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Fil feil: Kunne ikke åpne filen: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Ukjent encoding: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
23
onyx2/modules/mail/language/phpmailer.lang-pl.php
Normal file
23
onyx2/modules/mail/language/phpmailer.lang-pl.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Polish Version
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG["provide_address"] = 'Należy podać prawidłowy adres email Odbiorcy.';
|
||||
$PHPMAILER_LANG["mailer_not_supported"] = 'Wybrana metoda wysyłki wiadomości nie jest obsługiwana.';
|
||||
$PHPMAILER_LANG["execute"] = 'Nie można uruchomić: ';
|
||||
$PHPMAILER_LANG["instantiate"] = 'Nie można wywołać funkcji mail(). Sprawdź konfigurację serwera.';
|
||||
$PHPMAILER_LANG["authenticate"] = 'Błąd SMTP: Nie można przeprowadzić autentykacji.';
|
||||
$PHPMAILER_LANG["from_failed"] = 'Następujący adres Nadawcy jest jest nieprawidłowy: ';
|
||||
$PHPMAILER_LANG["recipients_failed"] = 'Błąd SMTP: Następujący odbiorcy są nieprawidłowi: ';
|
||||
$PHPMAILER_LANG["data_not_accepted"] = 'Błąd SMTP: Dane nie zostały przyjęte.';
|
||||
$PHPMAILER_LANG["connect_host"] = 'Błąd SMTP: Nie można połączyć się z wybranym hostem.';
|
||||
$PHPMAILER_LANG["file_access"] = 'Brak dostępu do pliku: ';
|
||||
$PHPMAILER_LANG["file_open"] = 'Nie można otworzyć pliku: ';
|
||||
$PHPMAILER_LANG["encoding"] = 'Nieznany sposób kodowania znaków: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
24
onyx2/modules/mail/language/phpmailer.lang-ro.php
Normal file
24
onyx2/modules/mail/language/phpmailer.lang-ro.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Romanian Version
|
||||
* @package PHPMailer
|
||||
* @author Catalin Constantin <catalin@dazoot.ro> */
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'Trebuie sa adaugati cel putin un recipient (adresa de mail).';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer nu este suportat.';
|
||||
$PHPMAILER_LANG['execute'] = 'Nu pot executa: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'Nu am putut instantia functia mail.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'Eroare SMTP: Nu a functionat autentificarea.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'Urmatoarele adrese From au dat eroare: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'Eroare SMTP: Urmatoarele adrese de mail au dat eroare: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'Eroare SMTP: Continutul mailului nu a fost acceptat.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'Eroare SMTP: Nu m-am putut conecta la adresa SMTP.';
|
||||
$PHPMAILER_LANG['file_access'] = 'Nu pot accesa fisierul: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Eroare de fisier: Nu pot deschide fisierul: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Encodare necunoscuta: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
23
onyx2/modules/mail/language/phpmailer.lang-ru.php
Normal file
23
onyx2/modules/mail/language/phpmailer.lang-ru.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Russian Version by Alexey Chumakov <alex@chumakov.ru> */
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'Пожалуйста, введите хотя бы один адрес e-mail получателя.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' - почтовый сервер не поддерживается.';
|
||||
$PHPMAILER_LANG['execute'] = 'Невозможно выполнить команду: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'Невозможно запустить функцию mail.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'Ошибка SMTP: ошибка авторизации.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'Неверный адрес отправителя: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'Ошибка SMTP: отправка по следующим ' .
|
||||
'адресам получателей не удалась: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'Ошибка SMTP: данные не приняты.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'Ошибка SMTP: не удается подключиться к серверу SMTP.';
|
||||
$PHPMAILER_LANG['file_access'] = 'Нет доступа к файлу: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Файловая ошибка: не удается открыть файл: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Неизвестный вид кодировки: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
23
onyx2/modules/mail/language/phpmailer.lang-se.php
Normal file
23
onyx2/modules/mail/language/phpmailer.lang-se.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Swedish Version
|
||||
* Author: Johan Linnér <johan@linner.biz> */
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'Du måste ange minst en mottagares e-postadress.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' mailer stöds inte.';
|
||||
$PHPMAILER_LANG['execute'] = 'Kunde inte köra: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'Kunde inte initiera e-postfunktion.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTP fel: Kunde inte autentisera.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'Följande avsändaradress är felaktig: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTP fel: Följande mottagare är felaktig: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP fel: Data accepterades inte.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP fel: Kunde inte ansluta till SMTP-server.';
|
||||
$PHPMAILER_LANG['file_access'] = 'Ingen åtkomst till fil: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Fil fel: Kunde inte öppna fil: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Okänt encode-format: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
24
onyx2/modules/mail/language/phpmailer.lang-tr.php
Normal file
24
onyx2/modules/mail/language/phpmailer.lang-tr.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer dil dosyasý.
|
||||
* Türkçe Versiyonu
|
||||
* ÝZYAZILIM - Elçin Özel - Can Yýlmaz - Mehmet Benlioðlu
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG['provide_address'] = 'En az bir tane mail adresi belirtmek zorundasýnýz alýcýnýn email adresi.';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = ' mailler desteklenmemektedir.';
|
||||
$PHPMAILER_LANG['execute'] = 'Çalýþtýrýlamýyor: ';
|
||||
$PHPMAILER_LANG['instantiate'] = 'Örnek mail fonksiyonu yaratýlamadý.';
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTP Hatasý: Doðrulanamýyor.';
|
||||
$PHPMAILER_LANG['from_failed'] = 'Baþarýsýz olan gönderici adresi: ';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTP Hatasý: alýcýlara ulaþmadý: ';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP Hatasý: Veri kabul edilmedi.';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP Hatasý: SMTP hosta baðlanýlamýyor.';
|
||||
$PHPMAILER_LANG['file_access'] = 'Dosyaya eriþilemiyor: ';
|
||||
$PHPMAILER_LANG['file_open'] = 'Dosya Hatasý: Dosya açýlamýyor: ';
|
||||
$PHPMAILER_LANG['encoding'] = 'Bilinmeyen þifreleme: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
23
onyx2/modules/mail/language/phpmailer.lang-zh.php
Normal file
23
onyx2/modules/mail/language/phpmailer.lang-zh.php
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Traditional Chinese Version
|
||||
* @author liqwei <liqwei@liqwei.com>
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
$PHPMAILER_LANG['provide_address'] = '必須提供至少一個收件人地址。';
|
||||
$PHPMAILER_LANG['mailer_not_supported'] = '發信客戶端不被支持。';
|
||||
$PHPMAILER_LANG['execute'] = '無法執行:';
|
||||
$PHPMAILER_LANG['instantiate'] = '未知函數調用。';
|
||||
$PHPMAILER_LANG['authenticate'] = 'SMTP 錯誤:登錄失敗。';
|
||||
$PHPMAILER_LANG['from_failed'] = '發送地址錯誤:';
|
||||
$PHPMAILER_LANG['recipients_failed'] = 'SMTP 錯誤:收件人地址錯誤:';
|
||||
$PHPMAILER_LANG['data_not_accepted'] = 'SMTP 錯誤:數據不被接受。';
|
||||
$PHPMAILER_LANG['connect_host'] = 'SMTP 錯誤:無法連接到 SMTP 主機。';
|
||||
$PHPMAILER_LANG['file_access'] = '無法訪問文件:';
|
||||
$PHPMAILER_LANG['file_open'] = '文件錯誤:無法打開文件:';
|
||||
$PHPMAILER_LANG['encoding'] = '未知編碼: ';
|
||||
$PHPMAILER_LANG['signing'] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
24
onyx2/modules/mail/language/phpmailer.lang-zh_cn.php
Normal file
24
onyx2/modules/mail/language/phpmailer.lang-zh_cn.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* PHPMailer language file.
|
||||
* Simplified Chinese Version
|
||||
* @author liqwei <liqwei@liqwei.com>
|
||||
*/
|
||||
|
||||
$PHPMAILER_LANG = array();
|
||||
|
||||
$PHPMAILER_LANG["provide_address"] = '必须提供至少一个收件人地址。';
|
||||
$PHPMAILER_LANG["mailer_not_supported"] = '发信客户端不被支持。';
|
||||
$PHPMAILER_LANG["execute"] = '无法执行:';
|
||||
$PHPMAILER_LANG["instantiate"] = '未知函数调用。';
|
||||
$PHPMAILER_LANG["authenticate"] = 'SMTP 错误:登录失败。';
|
||||
$PHPMAILER_LANG["from_failed"] = '发送地址错误:';
|
||||
$PHPMAILER_LANG["recipients_failed"] = 'SMTP 错误:收件人地址错误:';
|
||||
$PHPMAILER_LANG["data_not_accepted"] = 'SMTP 错误:数据不被接受。';
|
||||
$PHPMAILER_LANG["connect_host"] = 'SMTP 错误:无法连接到 SMTP 主机。';
|
||||
$PHPMAILER_LANG["file_access"] = '无法访问文件:';
|
||||
$PHPMAILER_LANG["file_open"] = '文件错误:无法打开文件:';
|
||||
$PHPMAILER_LANG["encoding"] = '未知编码: ';
|
||||
$PHPMAILER_LANG["signing"] = 'Signing Error: ';
|
||||
$PHPMAILER_LANG['smtp_error'] = 'SMTP server error: ';
|
||||
?>
|
||||
38
onyx2/modules/mail/main.php
Normal file
38
onyx2/modules/mail/main.php
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
define('PHPMAILER_DIR', ONYX.'modules/mail/');
|
||||
|
||||
require_once(PHPMAILER_DIR."class.phpmailer.php");
|
||||
|
||||
define('_MAIL_MAILER', $OPT['mailer']);
|
||||
define('_MAIL_LANG', $OPT['lang']);
|
||||
define('_MAIL_CHARSET', $OPT['charset']);
|
||||
define('_MAIL_HOST', $OPT['host']);
|
||||
define('_MAIL_PORT', $OPT['port']);
|
||||
define('_MAIL_SECURE', $OPT['secure']);
|
||||
define('_MAIL_FROM', $OPT['from']);
|
||||
define('_MAIL_FROMNAME', $OPT['fromname']);
|
||||
define('_MAIL_AUTH', !empty($OPT['username']));
|
||||
define('_MAIL_USERNAME', $OPT['username']);
|
||||
define('_MAIL_PASSWORD', $OPT['password']);
|
||||
|
||||
class Mailer extends PHPmailer
|
||||
{
|
||||
var $CharSet = _MAIL_CHARSET;
|
||||
var $From = _MAIL_FROM;
|
||||
var $FromName = _MAIL_FROMNAME;
|
||||
var $Mailer = _MAIL_MAILER;
|
||||
var $Version = "2.0";
|
||||
var $Host = _MAIL_HOST;
|
||||
var $Port = _MAIL_PORT;
|
||||
var $SMTPSecure = _MAIL_SECURE;
|
||||
var $SMTPAuth = _MAIL_AUTH;
|
||||
var $Username = _MAIL_USERNAME;
|
||||
var $Password = _MAIL_PASSWORD;
|
||||
var $Timeout = 5;
|
||||
|
||||
var $Sendmail = "/usr/lib/sendmail";
|
||||
}
|
||||
?>
|
||||
93
onyx2/modules/modules.xml
Normal file
93
onyx2/modules/modules.xml
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<modules>
|
||||
<module name="db">
|
||||
<default>
|
||||
<option name="type">mysql</option>
|
||||
</default>
|
||||
</module>
|
||||
|
||||
<module name="session" require="db"/>
|
||||
|
||||
<module name="test"/>
|
||||
|
||||
<module name="templates">
|
||||
<default>
|
||||
<option name="profile">default</option>
|
||||
<option name="compile">cache/templates/compile/</option>
|
||||
<option name="config">modules/templates/config/</option>
|
||||
<option name="cache">cache/templates/cache/</option>
|
||||
</default>
|
||||
</module>
|
||||
|
||||
<module name="bbcode">
|
||||
<default>
|
||||
<option name="smiley_dir">./images/smile/</option>
|
||||
<option name="smiley">
|
||||
<option name="wink">:wink:</option>
|
||||
<option name="biggrin">:D</option>
|
||||
<option name="smile">:-)</option>
|
||||
<option name="razz">:P</option>
|
||||
<option name="eek">:shock:</option>
|
||||
<option name="cool">8-)</option>
|
||||
<option name="twisted">:twisted:</option>
|
||||
<option name="evil">:evil:</option>
|
||||
<option name="mad">:-x</option>
|
||||
<option name="confused">:-?</option>
|
||||
<option name="sad">:-(</option>
|
||||
<option name="surprised">:-O</option>
|
||||
<option name="neutral">:-|</option>
|
||||
<option name="redface">:oops:</option>
|
||||
<option name="rolleyes">:roll:</option>
|
||||
<option name="lol">:lol:</option>
|
||||
</option>
|
||||
</default>
|
||||
</module>
|
||||
|
||||
<module name="lang">
|
||||
<default>
|
||||
<option name="type">fr</option>
|
||||
</default>
|
||||
</module>
|
||||
|
||||
<module name="chconfig">
|
||||
<default>
|
||||
<option name="show">0</option>
|
||||
</default>
|
||||
</module>
|
||||
|
||||
<module name="mail">
|
||||
<default>
|
||||
<option name="mailer">smtp</option>
|
||||
<option name="lang">fr</option>
|
||||
<option name="charset">utf-8</option>
|
||||
<option name="host">smtp.googlemail.com</option>
|
||||
<option name="port">465</option>
|
||||
<option name="secure">tls</option>
|
||||
<option name="from">no-reply@halo-battle.fr</option>
|
||||
<option name="fromname">Halo-Battle</option>
|
||||
<option name="username">halo-battle</option>
|
||||
<option name="password">bloublou</option>
|
||||
</default>
|
||||
</module>
|
||||
|
||||
<module name="pistage">
|
||||
<default>
|
||||
<option name="dir">log/users</option>
|
||||
<option name="ips"></option>
|
||||
</default>
|
||||
</module>
|
||||
|
||||
<module name="captcha" require="session">
|
||||
<default>
|
||||
<option name="caracteres">34678aertyupqdfhjkmwxcbn</option>
|
||||
<option name="sizeX">231</option>
|
||||
<option name="sizeY">60</option>
|
||||
<option name="nb_carac">6</option>
|
||||
<option name="back">
|
||||
<option name="red">0</option>
|
||||
<option name="green">0</option>
|
||||
<option name="blue">0</option>
|
||||
</option>
|
||||
</default>
|
||||
</module>
|
||||
</modules>
|
||||
34
onyx2/modules/pistage/main.php
Normal file
34
onyx2/modules/pistage/main.php
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
$pistage = false;
|
||||
$file = null;
|
||||
|
||||
if (!is_dir(ONYX."log/users"))
|
||||
mkdir(ONYX."log/users");
|
||||
|
||||
if (!empty($OPT['ips']))
|
||||
{
|
||||
$ips = explode(';', $OPT['ips']);
|
||||
if (in_array($_SERVER["REMOTE_ADDR"], $ips))
|
||||
$pistage = true;
|
||||
}
|
||||
|
||||
if (!empty($OPT['ids']))
|
||||
{
|
||||
$SESS = new Session();
|
||||
|
||||
$ids = explode(';', $OPT['ids']);
|
||||
if (isset($SESS->values['id']) && in_array($SESS->values['id'], $ids))
|
||||
{
|
||||
$pistage = true;
|
||||
$file = $SESS->values['id'].".log";
|
||||
}
|
||||
}
|
||||
|
||||
if ($pistage)
|
||||
elog(var_export($_REQUEST, TRUE), 0, ONYX."log/users", $file);
|
||||
|
||||
unset($pistage, $SESS, $ips, $ids);
|
||||
?>
|
||||
20
onyx2/modules/session/main.php
Normal file
20
onyx2/modules/session/main.php
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
if(defined('DB_TYPE'))
|
||||
{
|
||||
switch(DB_TYPE)
|
||||
{
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
|
||||
$session_config = $OPT;
|
||||
|
||||
require_once(DB_TYPE.'.class.php');
|
||||
break;
|
||||
|
||||
default: trigger_error('Base de donnee inconnue',E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
?>
|
||||
161
onyx2/modules/session/mysql.class.php
Normal file
161
onyx2/modules/session/mysql.class.php
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
<?php
|
||||
|
||||
class Session
|
||||
{
|
||||
|
||||
private $cookie;
|
||||
|
||||
private $db;
|
||||
|
||||
var $level = 0;
|
||||
|
||||
var $values = array();
|
||||
|
||||
function __construct($profile = NULL)
|
||||
{
|
||||
global $session_config;
|
||||
|
||||
if(!empty($session_config['profile'])) $profile = $session_config['profile'];
|
||||
|
||||
$cookie = strhex(base64_decode(gpc($session_config['cookie'],'cookie')));
|
||||
$ip = encode_ip();
|
||||
|
||||
$table = $session_config['db']['table'];
|
||||
|
||||
$this->db = new BDD($profile);
|
||||
|
||||
$this->clean();
|
||||
|
||||
if(!$cookie)
|
||||
{
|
||||
$this->new_cookie();
|
||||
$this->db->deconnexion();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->db->escape($cookie);
|
||||
|
||||
if (defined("DEBUG"))
|
||||
$query = $this->db->unique_query("SELECT session,level,var FROM $table WHERE session= 0x$cookie AND active=1");
|
||||
else
|
||||
$query = $this->db->unique_query("SELECT session,level,var FROM $table WHERE session= 0x$cookie AND ip= 0x$ip AND active=1");
|
||||
|
||||
if($this->db->num_rows == 1)
|
||||
{
|
||||
$time = time();
|
||||
|
||||
$this->db->query("UPDATE $table SET time='$time' WHERE session= 0x$cookie");
|
||||
|
||||
$this->db->deconnexion();
|
||||
|
||||
$this->cookie = strhex($query['session']);
|
||||
$this->level = $query['level'];
|
||||
if(!empty($query['var'])) $this->values = unserialize($query['var']);
|
||||
|
||||
setcookie($session_config['cookie'],base64_encode(hexstr($this->cookie)),time() + $session_config['time']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->new_cookie();
|
||||
$this->db->deconnexion();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
private function clean()
|
||||
{
|
||||
global $session_config;
|
||||
|
||||
if(!$this->db->connected) return FALSE;
|
||||
|
||||
$time = time()-$session_config['time'];
|
||||
$ip = encode_ip();
|
||||
$ipmax = $session_config['maxip'];
|
||||
|
||||
$table = $session_config['db']['table'];
|
||||
|
||||
$this->db->query("DELETE FROM $table WHERE time < $time AND active = 1");
|
||||
|
||||
if($ipmax > 0) $this->db->query("DELETE FROM $table WHERE ip = (SELECT * FROM (SELECT ip FROM $table GROUP BY ip HAVING COUNT(ip) > $ipmax) AS tmp)");
|
||||
}
|
||||
|
||||
private function new_cookie()
|
||||
{
|
||||
global $session_config;
|
||||
|
||||
if(!$this->db->connected) return FALSE;
|
||||
|
||||
$time = time();
|
||||
|
||||
$level = (is_int($this->level) && strlen($this->level) <= 2) ? $this->level : 0 ;
|
||||
|
||||
$sess_cookie = random(256);
|
||||
$ip = encode_ip();
|
||||
|
||||
$this->cookie = $sess_cookie;
|
||||
|
||||
$table = $session_config['db']['table'];
|
||||
|
||||
$this->db->escape($sess_cookie);
|
||||
|
||||
$this->db->query("INSERT INTO $table(session,time,ip,var,level,active) VALUES(0x$sess_cookie,$time,0x$ip,$level,0,1) ");
|
||||
|
||||
setcookie($session_config['cookie'],base64_encode(hexstr($this->cookie)),time() + $session_config['time']);
|
||||
}
|
||||
|
||||
function put($uid = NULL)
|
||||
{
|
||||
global $session_config;
|
||||
|
||||
if(empty($this->cookie)) return FALSE;
|
||||
|
||||
$var = serialize($this->values);
|
||||
|
||||
$cookie = $this->cookie;
|
||||
|
||||
$uid = empty($uid) ? '0' : md5($uid);
|
||||
|
||||
$level = (is_int($this->level) || (ctype_digit($this->level)) && strlen($this->level) <= 2) ? $this->level : 0 ;
|
||||
|
||||
$table = $session_config['db']['table'];
|
||||
|
||||
$this->db->reconnexion();
|
||||
|
||||
$this->db->escape($var);
|
||||
|
||||
if($uid != '0')
|
||||
{
|
||||
$this->db->query("DELETE FROM $table WHERE uid = 0x$uid AND session != 0x$cookie AND active = 1");
|
||||
$this->db->query("UPDATE $table SET var='$var', level='$level', uid= 0x$uid WHERE session= 0x$cookie");
|
||||
}
|
||||
else
|
||||
$this->db->query("UPDATE $table SET var='$var', level='$level' WHERE session= 0x$cookie");
|
||||
|
||||
$this->db->deconnexion();
|
||||
}
|
||||
|
||||
function close()
|
||||
{
|
||||
global $session_config;
|
||||
|
||||
if(empty($this->cookie)) return FALSE;
|
||||
|
||||
$cookie = $this->cookie;
|
||||
|
||||
$table = $session_config['db']['table'];
|
||||
|
||||
$this->db->reconnexion();
|
||||
|
||||
$this->db->query("DELETE FROM $table WHERE session = 0x$cookie AND active = 1");
|
||||
|
||||
$this->db->deconnexion();
|
||||
|
||||
setcookie($session_config['cookie'],'',0);
|
||||
|
||||
$this->values = array();
|
||||
$this->level = 0;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
153
onyx2/modules/session/postgresql.class.php
Normal file
153
onyx2/modules/session/postgresql.class.php
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
<?php
|
||||
|
||||
class Session {
|
||||
|
||||
private $cookie;
|
||||
|
||||
private $db;
|
||||
|
||||
var $level = 0;
|
||||
|
||||
var $values = array();
|
||||
|
||||
function __construct($profile = NULL)
|
||||
{
|
||||
global $session_config;
|
||||
|
||||
if(!empty($session_config['profile'])) $profile = $session_config['profile'];
|
||||
|
||||
$cookie = strhex(base64_decode(gpc($session_config['cookie'],'cookie')));
|
||||
$ip = encode_ip();
|
||||
|
||||
$table = $session_config['db']['table'];
|
||||
|
||||
$this->db = new BDD($profile);
|
||||
|
||||
$this->clean();
|
||||
|
||||
if(!$cookie)
|
||||
{
|
||||
$this->new_cookie();
|
||||
$this->db->deconnexion();
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$this->db->escape($cookie);
|
||||
|
||||
$query = $this->db->unique_query("SELECT session,level,var FROM $table WHERE session= X'$cookie' AND ip= X'$ip' AND active= TRUE");
|
||||
|
||||
if($this->db->num_rows == 1)
|
||||
{
|
||||
$time = time();
|
||||
|
||||
$this->db->query("UPDATE $table SET time='$time' WHERE session= X'$cookie'");
|
||||
|
||||
$this->db->deconnexion();
|
||||
|
||||
$this->cookie = bithex($query['session']);
|
||||
$this->level = $query['level'];
|
||||
if(!empty($query['var'])) $this->values = unserialize($query['var']);
|
||||
|
||||
setcookie($session_config['cookie'],base64_encode(hexstr($this->cookie)),time() + $session_config['time']);
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->new_cookie();
|
||||
$this->db->deconnexion();
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
private function clean()
|
||||
{
|
||||
global $session_config;
|
||||
|
||||
if(!$this->db->connected) return FALSE;
|
||||
|
||||
$time = time()-$session_config['time'];
|
||||
$ip = encode_ip();
|
||||
$ipmax = $session_config['maxip'];
|
||||
|
||||
$table = $session_config['db']['table'];
|
||||
|
||||
$this->db->query("DELETE FROM $table WHERE time < $time AND active = TRUE");
|
||||
|
||||
if($ipmax > 0) $this->db->query("DELETE FROM $table WHERE ip = (SELECT ip FROM $table GROUP BY ip HAVING COUNT(ip) > $ipmax)");
|
||||
}
|
||||
|
||||
private function new_cookie()
|
||||
{
|
||||
global $session_config;
|
||||
|
||||
if(!$this->db->connected) return FALSE;
|
||||
|
||||
$time = time();
|
||||
|
||||
$level = (is_int($this->level) && strlen($this->level) <= 2) ? $this->level : 0 ;
|
||||
|
||||
$sess_cookie = random(256);
|
||||
$ip = encode_ip();
|
||||
|
||||
$this->cookie = $sess_cookie;
|
||||
|
||||
$table = $session_config['db']['table'];
|
||||
|
||||
$this->db->escape($sess_cookie);
|
||||
|
||||
$this->db->query("INSERT INTO $table(session,time,ip,var,level,active) VALUES(X'$sess_cookie',$time,X'$ip',$level,0,TRUE)");
|
||||
|
||||
setcookie($session_config['cookie'],base64_encode(hexstr($this->cookie)),time() + $session_config['time']);
|
||||
}
|
||||
|
||||
function put($uid = NULL)
|
||||
{
|
||||
global $session_config;
|
||||
|
||||
if(empty($this->cookie)) return FALSE;
|
||||
|
||||
$var = serialize($this->values);
|
||||
|
||||
$cookie = $this->cookie;
|
||||
|
||||
$uid = empty($uid) ? '0' : md5($uid);
|
||||
|
||||
$level = (is_int($this->level) || (ctype_digit($this->level)) && strlen($this->level) <= 2) ? $this->level : 0 ;
|
||||
|
||||
$table = $session_config['db']['table'];
|
||||
|
||||
$this->db->reconnexion();
|
||||
|
||||
$this->db->escape($var);
|
||||
|
||||
if($uid != '0') $this->db->query("DELETE FROM $table WHERE uid = X'$uid' AND session != X'$cookie' AND active = TRUE");
|
||||
|
||||
$this->db->query("UPDATE $table SET var='$var', level='$level', uid= X'$uid' WHERE session= X'$cookie'");
|
||||
|
||||
$this->db->deconnexion();
|
||||
}
|
||||
|
||||
function close()
|
||||
{
|
||||
global $session_config;
|
||||
|
||||
if(empty($this->cookie)) return FALSE;
|
||||
|
||||
$cookie = $this->cookie;
|
||||
|
||||
$table = $session_config['db']['table'];
|
||||
|
||||
$this->db->reconnexion();
|
||||
|
||||
$this->db->query("DELETE FROM $table WHERE session = X'$cookie' AND active = TRUE");
|
||||
|
||||
$this->db->deconnexion();
|
||||
|
||||
setcookie($session_config['cookie'],'',0);
|
||||
|
||||
$this->values = array();
|
||||
$this->level = 0;
|
||||
|
||||
}
|
||||
}
|
||||
?>
|
||||
0
onyx2/modules/templates/config/config
Normal file
0
onyx2/modules/templates/config/config
Normal file
29
onyx2/modules/templates/main.php
Normal file
29
onyx2/modules/templates/main.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
|
||||
define('SMARTY_DIR',ONYX.'modules/templates/smarty/');
|
||||
|
||||
require_once(SMARTY_DIR."Smarty.class.php");
|
||||
|
||||
define('_TEMPLATE_DIR',ONYX.'tpl/'.$OPT['tpl'].'/');
|
||||
define('_TEMPLATE_COMPILE',ONYX.$OPT['compile']);
|
||||
define('_TEMPLATE_CONFIG',ONYX.$OPT['config']);
|
||||
define('_TEMPLATE_CACHE',ONYX.$OPT['cache']);
|
||||
|
||||
class Template extends Smarty
|
||||
{
|
||||
//var $compile_check = false;
|
||||
//var $force_compile = true;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
$this->setTemplateDir(_TEMPLATE_DIR);
|
||||
$this->setCompileDir(_TEMPLATE_COMPILE);
|
||||
$this->setCacheDir(_TEMPLATE_CACHE);
|
||||
//SetCONFIGDIR !
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
815
onyx2/modules/templates/smarty/Smarty.class.php
Normal file
815
onyx2/modules/templates/smarty/Smarty.class.php
Normal file
|
|
@ -0,0 +1,815 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Project: Smarty: the PHP compiling template engine
|
||||
* File: Smarty.class.php
|
||||
* SVN: $Id: Smarty.class.php 3895 2010-12-31 13:47:12Z uwe.tews@googlemail.com $
|
||||
*
|
||||
* This library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Lesser General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2.1 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public
|
||||
* License along with this library; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
* For questions, help, comments, discussion, etc., please join the
|
||||
* Smarty mailing list. Send a blank e-mail to
|
||||
* smarty-discussion-subscribe@googlegroups.com
|
||||
*
|
||||
* @link http://www.smarty.net/
|
||||
* @copyright 2008 New Digital Group, Inc.
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
* @package Smarty
|
||||
* @version 3.0.7
|
||||
*/
|
||||
|
||||
/**
|
||||
* define shorthand directory separator constant
|
||||
*/
|
||||
if (!defined('DS')) {
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
* set SMARTY_DIR to absolute path to Smarty library files.
|
||||
* Sets SMARTY_DIR only if user application has not already defined it.
|
||||
*/
|
||||
if (!defined('SMARTY_DIR')) {
|
||||
define('SMARTY_DIR', dirname(__FILE__) . DS);
|
||||
}
|
||||
|
||||
/**
|
||||
* set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins.
|
||||
* Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it.
|
||||
*/
|
||||
if (!defined('SMARTY_SYSPLUGINS_DIR')) {
|
||||
define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DS);
|
||||
}
|
||||
if (!defined('SMARTY_PLUGINS_DIR')) {
|
||||
define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DS);
|
||||
}
|
||||
if (!defined('SMARTY_RESOURCE_CHAR_SET')) {
|
||||
define('SMARTY_RESOURCE_CHAR_SET', 'UTF-8');
|
||||
}
|
||||
if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) {
|
||||
define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y');
|
||||
}
|
||||
|
||||
/**
|
||||
* register the class autoloader
|
||||
*/
|
||||
if (!defined('SMARTY_SPL_AUTOLOAD')) {
|
||||
define('SMARTY_SPL_AUTOLOAD', 0);
|
||||
}
|
||||
|
||||
if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) {
|
||||
$registeredAutoLoadFunctions = spl_autoload_functions();
|
||||
if (!isset($registeredAutoLoadFunctions['spl_autoload'])) {
|
||||
spl_autoload_register();
|
||||
}
|
||||
} else {
|
||||
spl_autoload_register('smartyAutoload');
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the main Smarty class
|
||||
*/
|
||||
class Smarty extends Smarty_Internal_Data {
|
||||
/**
|
||||
* constant definitions
|
||||
*/
|
||||
// smarty version
|
||||
const SMARTY_VERSION = 'Smarty-3.0.7';
|
||||
//define variable scopes
|
||||
const SCOPE_LOCAL = 0;
|
||||
const SCOPE_PARENT = 1;
|
||||
const SCOPE_ROOT = 2;
|
||||
const SCOPE_GLOBAL = 3;
|
||||
// define caching modes
|
||||
const CACHING_OFF = 0;
|
||||
const CACHING_LIFETIME_CURRENT = 1;
|
||||
const CACHING_LIFETIME_SAVED = 2;
|
||||
/** modes for handling of "<?php ... ?>" tags in templates. **/
|
||||
const PHP_PASSTHRU = 0; //-> print tags as plain text
|
||||
const PHP_QUOTE = 1; //-> escape tags as entities
|
||||
const PHP_REMOVE = 2; //-> escape tags as entities
|
||||
const PHP_ALLOW = 3; //-> escape tags as entities
|
||||
// filter types
|
||||
const FILTER_POST = 'post';
|
||||
const FILTER_PRE = 'pre';
|
||||
const FILTER_OUTPUT = 'output';
|
||||
const FILTER_VARIABLE = 'variable';
|
||||
// plugin types
|
||||
const PLUGIN_FUNCTION = 'function';
|
||||
const PLUGIN_BLOCK = 'block';
|
||||
const PLUGIN_COMPILER = 'compiler';
|
||||
const PLUGIN_MODIFIER = 'modifier';
|
||||
|
||||
/**
|
||||
* static variables
|
||||
*/
|
||||
// assigned global tpl vars
|
||||
static $global_tpl_vars = array();
|
||||
|
||||
/**
|
||||
* variables
|
||||
*/
|
||||
// auto literal on delimiters with whitspace
|
||||
public $auto_literal = true;
|
||||
// display error on not assigned variables
|
||||
public $error_unassigned = false;
|
||||
// template directory
|
||||
public $template_dir = null;
|
||||
// default template handler
|
||||
public $default_template_handler_func = null;
|
||||
// compile directory
|
||||
public $compile_dir = null;
|
||||
// plugins directory
|
||||
public $plugins_dir = null;
|
||||
// cache directory
|
||||
public $cache_dir = null;
|
||||
// config directory
|
||||
public $config_dir = null;
|
||||
// force template compiling?
|
||||
public $force_compile = false;
|
||||
// check template for modifications?
|
||||
public $compile_check = true;
|
||||
// locking concurrent compiles
|
||||
public $compile_locking = true;
|
||||
// use sub dirs for compiled/cached files?
|
||||
public $use_sub_dirs = false;
|
||||
// compile_error?
|
||||
public $compile_error = false;
|
||||
// caching enabled
|
||||
public $caching = false;
|
||||
// merge compiled includes
|
||||
public $merge_compiled_includes = false;
|
||||
// cache lifetime
|
||||
public $cache_lifetime = 3600;
|
||||
// force cache file creation
|
||||
public $force_cache = false;
|
||||
// cache_id
|
||||
public $cache_id = null;
|
||||
// compile_id
|
||||
public $compile_id = null;
|
||||
// template delimiters
|
||||
public $left_delimiter = "{";
|
||||
public $right_delimiter = "}";
|
||||
// security
|
||||
public $security_class = 'Smarty_Security';
|
||||
public $security_policy = null;
|
||||
public $php_handling = self::PHP_PASSTHRU;
|
||||
public $allow_php_tag = false;
|
||||
public $allow_php_templates = false;
|
||||
public $direct_access_security = true;
|
||||
public $trusted_dir = array();
|
||||
// debug mode
|
||||
public $debugging = false;
|
||||
public $debugging_ctrl = 'NONE';
|
||||
public $smarty_debug_id = 'SMARTY_DEBUG';
|
||||
public $debug_tpl = null;
|
||||
// When set, smarty does uses this value as error_reporting-level.
|
||||
public $error_reporting = null;
|
||||
// config var settings
|
||||
public $config_overwrite = true; //Controls whether variables with the same name overwrite each other.
|
||||
public $config_booleanize = true; //Controls whether config values of on/true/yes and off/false/no get converted to boolean
|
||||
public $config_read_hidden = false; //Controls whether hidden config sections/vars are read from the file.
|
||||
// config vars
|
||||
public $config_vars = array();
|
||||
// assigned tpl vars
|
||||
public $tpl_vars = array();
|
||||
// dummy parent object
|
||||
public $parent = null;
|
||||
// global template functions
|
||||
public $template_functions = array();
|
||||
// resource type used if none given
|
||||
public $default_resource_type = 'file';
|
||||
// caching type
|
||||
public $caching_type = 'file';
|
||||
// internal cache resource types
|
||||
public $cache_resource_types = array('file');
|
||||
// internal config properties
|
||||
public $properties = array();
|
||||
// config type
|
||||
public $default_config_type = 'file';
|
||||
// cached template objects
|
||||
public $template_objects = null;
|
||||
// check If-Modified-Since headers
|
||||
public $cache_modified_check = false;
|
||||
// registered plugins
|
||||
public $registered_plugins = array();
|
||||
// plugin search order
|
||||
public $plugin_search_order = array('function', 'block', 'compiler', 'class');
|
||||
// registered objects
|
||||
public $registered_objects = array();
|
||||
// registered classes
|
||||
public $registered_classes = array();
|
||||
// registered filters
|
||||
public $registered_filters = array();
|
||||
// registered resources
|
||||
public $registered_resources = array();
|
||||
// autoload filter
|
||||
public $autoload_filters = array();
|
||||
// status of filter on variable output
|
||||
public $variable_filter = true;
|
||||
// default modifier
|
||||
public $default_modifiers = array();
|
||||
// global internal smarty vars
|
||||
static $_smarty_vars = array();
|
||||
// start time for execution time calculation
|
||||
public $start_time = 0;
|
||||
// default file permissions
|
||||
public $_file_perms = 0644;
|
||||
// default dir permissions
|
||||
public $_dir_perms = 0771;
|
||||
// block tag hierarchy
|
||||
public $_tag_stack = array();
|
||||
// flag if {block} tag is compiled for template inheritance
|
||||
public $inheritance = false;
|
||||
// generate deprecated function call notices?
|
||||
public $deprecation_notices = true;
|
||||
// Smarty 2 BC
|
||||
public $_version = self::SMARTY_VERSION;
|
||||
// self pointer to Smarty object
|
||||
public $smarty;
|
||||
|
||||
/**
|
||||
* Class constructor, initializes basic smarty properties
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
// selfpointer need by some other class methods
|
||||
$this->smarty = $this;
|
||||
if (is_callable('mb_internal_encoding')) {
|
||||
mb_internal_encoding(SMARTY_RESOURCE_CHAR_SET);
|
||||
}
|
||||
$this->start_time = microtime(true);
|
||||
// set default dirs
|
||||
$this->template_dir = array('.' . DS . 'templates' . DS);
|
||||
$this->compile_dir = '.' . DS . 'templates_c' . DS;
|
||||
$this->plugins_dir = array(SMARTY_PLUGINS_DIR);
|
||||
$this->cache_dir = '.' . DS . 'cache' . DS;
|
||||
$this->config_dir = '.' . DS . 'configs' . DS;
|
||||
$this->debug_tpl = SMARTY_DIR . 'debug.tpl';
|
||||
if (isset($_SERVER['SCRIPT_NAME'])) {
|
||||
$this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Class destructor
|
||||
*/
|
||||
public function __destruct()
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* fetches a rendered Smarty template
|
||||
*
|
||||
* @param string $template the resource handle of the template file or template object
|
||||
* @param mixed $cache_id cache id to be used with this template
|
||||
* @param mixed $compile_id compile id to be used with this template
|
||||
* @param object $ |null $parent next higher level of Smarty variables
|
||||
* @return string rendered template output
|
||||
*/
|
||||
public function fetch($template, $cache_id = null, $compile_id = null, $parent = null, $display = false)
|
||||
{
|
||||
if (!empty($cache_id) && is_object($cache_id)) {
|
||||
$parent = $cache_id;
|
||||
$cache_id = null;
|
||||
}
|
||||
if ($parent === null) {
|
||||
// get default Smarty data object
|
||||
$parent = $this;
|
||||
}
|
||||
// create template object if necessary
|
||||
($template instanceof $this->template_class)? $_template = $template :
|
||||
$_template = $this->createTemplate ($template, $cache_id, $compile_id, $parent, false);
|
||||
if (isset($this->error_reporting)) {
|
||||
$_smarty_old_error_level = error_reporting($this->error_reporting);
|
||||
}
|
||||
// check URL debugging control
|
||||
if (!$this->debugging && $this->debugging_ctrl == 'URL') {
|
||||
if (isset($_SERVER['QUERY_STRING'])) {
|
||||
$_query_string = $_SERVER['QUERY_STRING'];
|
||||
} else {
|
||||
$_query_string = '';
|
||||
}
|
||||
if (false !== strpos($_query_string, $this->smarty_debug_id)) {
|
||||
if (false !== strpos($_query_string, $this->smarty_debug_id . '=on')) {
|
||||
// enable debugging for this browser session
|
||||
setcookie('SMARTY_DEBUG', true);
|
||||
$this->debugging = true;
|
||||
} elseif (false !== strpos($_query_string, $this->smarty_debug_id . '=off')) {
|
||||
// disable debugging for this browser session
|
||||
setcookie('SMARTY_DEBUG', false);
|
||||
$this->debugging = false;
|
||||
} else {
|
||||
// enable debugging for this page
|
||||
$this->debugging = true;
|
||||
}
|
||||
} else {
|
||||
if (isset($_COOKIE['SMARTY_DEBUG'])) {
|
||||
$this->debugging = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// obtain data for cache modified check
|
||||
if ($this->cache_modified_check && $this->caching && $display) {
|
||||
$_isCached = $_template->isCached() && !$_template->has_nocache_code;
|
||||
if ($_isCached) {
|
||||
$_gmt_mtime = gmdate('D, d M Y H:i:s', $_template->getCachedTimestamp()) . ' GMT';
|
||||
} else {
|
||||
$_gmt_mtime = '';
|
||||
}
|
||||
}
|
||||
// return rendered template
|
||||
if ((!$this->caching || $_template->resource_object->isEvaluated) && (isset($this->autoload_filters['output']) || isset($this->registered_filters['output']))) {
|
||||
$_output = Smarty_Internal_Filter_Handler::runFilter('output', $_template->getRenderedTemplate(), $_template);
|
||||
} else {
|
||||
$_output = $_template->getRenderedTemplate();
|
||||
}
|
||||
$_template->rendered_content = null;
|
||||
if (isset($this->error_reporting)) {
|
||||
error_reporting($_smarty_old_error_level);
|
||||
}
|
||||
// display or fetch
|
||||
if ($display) {
|
||||
if ($this->caching && $this->cache_modified_check) {
|
||||
$_last_modified_date = @substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
|
||||
if ($_isCached && $_gmt_mtime == $_last_modified_date) {
|
||||
if (php_sapi_name() == 'cgi')
|
||||
header('Status: 304 Not Modified');
|
||||
else
|
||||
header('HTTP/1.1 304 Not Modified');
|
||||
} else {
|
||||
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->getCachedTimestamp()) . ' GMT');
|
||||
echo $_output;
|
||||
}
|
||||
} else {
|
||||
echo $_output;
|
||||
}
|
||||
// debug output
|
||||
if ($this->debugging) {
|
||||
Smarty_Internal_Debug::display_debug($this);
|
||||
}
|
||||
return;
|
||||
} else {
|
||||
// return fetched content
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* displays a Smarty template
|
||||
*
|
||||
* @param string $ |object $template the resource handle of the template file or template object
|
||||
* @param mixed $cache_id cache id to be used with this template
|
||||
* @param mixed $compile_id compile id to be used with this template
|
||||
* @param object $parent next higher level of Smarty variables
|
||||
*/
|
||||
public function display($template, $cache_id = null, $compile_id = null, $parent = null)
|
||||
{
|
||||
// display template
|
||||
$this->fetch ($template, $cache_id, $compile_id, $parent, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* test if cache i valid
|
||||
*
|
||||
* @param string $ |object $template the resource handle of the template file or template object
|
||||
* @param mixed $cache_id cache id to be used with this template
|
||||
* @param mixed $compile_id compile id to be used with this template
|
||||
* @param object $parent next higher level of Smarty variables
|
||||
* @return boolean cache status
|
||||
*/
|
||||
public function isCached($template, $cache_id = null, $compile_id = null, $parent = null)
|
||||
{
|
||||
if ($parent === null) {
|
||||
$parent = $this;
|
||||
}
|
||||
if (!($template instanceof $this->template_class)) {
|
||||
$template = $this->createTemplate ($template, $cache_id, $compile_id, $parent, false);
|
||||
}
|
||||
// return cache status of template
|
||||
return $template->isCached();
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a data object
|
||||
*
|
||||
* @param object $parent next higher level of Smarty variables
|
||||
* @returns object data object
|
||||
*/
|
||||
public function createData($parent = null)
|
||||
{
|
||||
return new Smarty_Data($parent, $this);
|
||||
}
|
||||
|
||||
/**
|
||||
* creates a template object
|
||||
*
|
||||
* @param string $template the resource handle of the template file
|
||||
* @param mixed $cache_id cache id to be used with this template
|
||||
* @param mixed $compile_id compile id to be used with this template
|
||||
* @param object $parent next higher level of Smarty variables
|
||||
* @param boolean $do_clone flag is Smarty object shall be cloned
|
||||
* @returns object template object
|
||||
*/
|
||||
public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true)
|
||||
{
|
||||
if (!empty($cache_id) && (is_object($cache_id) || is_array($cache_id))) {
|
||||
$parent = $cache_id;
|
||||
$cache_id = null;
|
||||
}
|
||||
if (!empty($parent) && is_array($parent)) {
|
||||
$data = $parent;
|
||||
$parent = null;
|
||||
} else {
|
||||
$data = null;
|
||||
}
|
||||
if (!is_object($template)) {
|
||||
// we got a template resource
|
||||
// already in template cache?
|
||||
$_templateId = sha1($template . $cache_id . $compile_id);
|
||||
if (isset($this->template_objects[$_templateId]) && $this->caching) {
|
||||
// return cached template object
|
||||
$tpl = $this->template_objects[$_templateId];
|
||||
} else {
|
||||
// create new template object
|
||||
if ($do_clone) {
|
||||
$tpl = new $this->template_class($template, clone $this, $parent, $cache_id, $compile_id);
|
||||
} else {
|
||||
$tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// just return a copy of template class
|
||||
$tpl = $template;
|
||||
}
|
||||
// fill data if present
|
||||
if (!empty($data) && is_array($data)) {
|
||||
// set up variable values
|
||||
foreach ($data as $_key => $_val) {
|
||||
$tpl->tpl_vars[$_key] = new Smarty_variable($_val);
|
||||
}
|
||||
}
|
||||
return $tpl;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Check if a template resource exists
|
||||
*
|
||||
* @param string $resource_name template name
|
||||
* @return boolean status
|
||||
*/
|
||||
function templateExists($resource_name)
|
||||
{
|
||||
// create template object
|
||||
$save = $this->template_objects;
|
||||
$tpl = new $this->template_class($resource_name, $this);
|
||||
// check if it does exists
|
||||
$result = $tpl->isExisting();
|
||||
$this->template_objects = $save;
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a single or all global variables
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param string $varname variable name or null
|
||||
* @return string variable value or or array of variables
|
||||
*/
|
||||
function getGlobal($varname = null)
|
||||
{
|
||||
if (isset($varname)) {
|
||||
if (isset(self::$global_tpl_vars[$varname])) {
|
||||
return self::$global_tpl_vars[$varname]->value;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$_result = array();
|
||||
foreach (self::$global_tpl_vars AS $key => $var) {
|
||||
$_result[$key] = $var->value;
|
||||
}
|
||||
return $_result;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty cache folder
|
||||
*
|
||||
* @param integer $exp_time expiration time
|
||||
* @param string $type resource type
|
||||
* @return integer number of cache files deleted
|
||||
*/
|
||||
function clearAllCache($exp_time = null, $type = null)
|
||||
{
|
||||
// load cache resource and call clearAll
|
||||
return $this->loadCacheResource($type)->clearAll($exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Empty cache for a specific template
|
||||
*
|
||||
* @param string $template_name template name
|
||||
* @param string $cache_id cache id
|
||||
* @param string $compile_id compile id
|
||||
* @param integer $exp_time expiration time
|
||||
* @param string $type resource type
|
||||
* @return integer number of cache files deleted
|
||||
*/
|
||||
function clearCache($template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null)
|
||||
{
|
||||
// load cache resource and call clear
|
||||
return $this->loadCacheResource($type)->clear($template_name, $cache_id, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads security class and enables security
|
||||
*/
|
||||
public function enableSecurity($security_class = null)
|
||||
{
|
||||
if ($security_class instanceof Smarty_Security) {
|
||||
$this->security_policy = $security_class;
|
||||
return;
|
||||
}
|
||||
if ($security_class == null) {
|
||||
$security_class = $this->security_class;
|
||||
}
|
||||
if (class_exists($security_class)) {
|
||||
$this->security_policy = new $security_class($this);
|
||||
} else {
|
||||
throw new SmartyException("Security class '$security_class' is not defined");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable security
|
||||
*/
|
||||
public function disableSecurity()
|
||||
{
|
||||
$this->security_policy = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads cache resource.
|
||||
*
|
||||
* @param string $type cache resource type
|
||||
* @return object of cache resource
|
||||
*/
|
||||
public function loadCacheResource($type = null) {
|
||||
if (!isset($type)) {
|
||||
$type = $this->caching_type;
|
||||
}
|
||||
if (in_array($type, $this->cache_resource_types)) {
|
||||
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
|
||||
return new $cache_resource_class($this);
|
||||
}
|
||||
else {
|
||||
// try plugins dir
|
||||
$cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
|
||||
if ($this->loadPlugin($cache_resource_class)) {
|
||||
return new $cache_resource_class($this);
|
||||
}
|
||||
else {
|
||||
throw new SmartyException("Unable to load cache resource '{$type}'");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Set template directory
|
||||
*
|
||||
* @param string $ |array $template_dir folder(s) of template sorces
|
||||
*/
|
||||
public function setTemplateDir($template_dir)
|
||||
{
|
||||
$this->template_dir = (array)$template_dir;
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds template directory(s) to existing ones
|
||||
*
|
||||
* @param string $ |array $template_dir folder(s) of template sources
|
||||
*/
|
||||
public function addTemplateDir($template_dir)
|
||||
{
|
||||
$this->template_dir = array_unique(array_merge((array)$this->template_dir, (array)$template_dir));
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds directory of plugin files
|
||||
*
|
||||
* @param object $smarty
|
||||
* @param string $ |array $ plugins folder
|
||||
* @return
|
||||
*/
|
||||
function addPluginsDir($plugins_dir)
|
||||
{
|
||||
$this->plugins_dir = array_unique(array_merge((array)$this->plugins_dir, (array)$plugins_dir));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* return a reference to a registered object
|
||||
*
|
||||
* @param string $name object name
|
||||
* @return object
|
||||
*/
|
||||
function getRegisteredObject($name)
|
||||
{
|
||||
if (!isset($this->registered_objects[$name]))
|
||||
throw new SmartyException("'$name' is not a registered object");
|
||||
|
||||
if (!is_object($this->registered_objects[$name][0]))
|
||||
throw new SmartyException("registered '$name' is not an object");
|
||||
|
||||
return $this->registered_objects[$name][0];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* return name of debugging template
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
function getDebugTemplate()
|
||||
{
|
||||
return $this->debug_tpl;
|
||||
}
|
||||
|
||||
/**
|
||||
* set the debug template
|
||||
*
|
||||
* @param string $tpl_name
|
||||
* @return bool
|
||||
*/
|
||||
function setDebugTemplate($tpl_name)
|
||||
{
|
||||
return $this->debug_tpl = $tpl_name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Takes unknown classes and loads plugin files for them
|
||||
* class name format: Smarty_PluginType_PluginName
|
||||
* plugin filename format: plugintype.pluginname.php
|
||||
*
|
||||
* @param string $plugin_name class plugin name to load
|
||||
* @return string |boolean filepath of loaded file or false
|
||||
*/
|
||||
public function loadPlugin($plugin_name, $check = true)
|
||||
{
|
||||
// if function or class exists, exit silently (already loaded)
|
||||
if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false)))
|
||||
return true;
|
||||
// Plugin name is expected to be: Smarty_[Type]_[Name]
|
||||
$_plugin_name = strtolower($plugin_name);
|
||||
$_name_parts = explode('_', $_plugin_name, 3);
|
||||
// class name must have three parts to be valid plugin
|
||||
if (count($_name_parts) < 3 || $_name_parts[0] !== 'smarty') {
|
||||
throw new SmartyException("plugin {$plugin_name} is not a valid name format");
|
||||
return false;
|
||||
}
|
||||
// if type is "internal", get plugin from sysplugins
|
||||
if ($_name_parts[1] == 'internal') {
|
||||
$file = SMARTY_SYSPLUGINS_DIR . $_plugin_name . '.php';
|
||||
if (file_exists($file)) {
|
||||
require_once($file);
|
||||
return $file;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// plugin filename is expected to be: [type].[name].php
|
||||
$_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php";
|
||||
// loop through plugin dirs and find the plugin
|
||||
foreach((array)$this->plugins_dir as $_plugin_dir) {
|
||||
if (strpos('/\\', substr($_plugin_dir, -1)) === false) {
|
||||
$_plugin_dir .= DS;
|
||||
}
|
||||
$file = $_plugin_dir . $_plugin_filename;
|
||||
if (file_exists($file)) {
|
||||
require_once($file);
|
||||
return $file;
|
||||
}
|
||||
}
|
||||
// no plugin loaded
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* clean up properties on cloned object
|
||||
*/
|
||||
public function __clone()
|
||||
{
|
||||
// clear config vars
|
||||
$this->config_vars = array();
|
||||
// clear assigned tpl vars
|
||||
$this->tpl_vars = array();
|
||||
// clear objects for external methods
|
||||
unset($this->register);
|
||||
unset($this->filter);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Handle unknown class methods
|
||||
*
|
||||
* @param string $name unknown methode name
|
||||
* @param array $args aurgument array
|
||||
*/
|
||||
public function __call($name, $args)
|
||||
{
|
||||
static $camel_func;
|
||||
if (!isset($camel_func))
|
||||
$camel_func = create_function('$c', 'return "_" . strtolower($c[1]);');
|
||||
// see if this is a set/get for a property
|
||||
$first3 = strtolower(substr($name, 0, 3));
|
||||
if (in_array($first3, array('set', 'get')) && substr($name, 3, 1) !== '_') {
|
||||
// try to keep case correct for future PHP 6.0 case-sensitive class methods
|
||||
// lcfirst() not available < PHP 5.3.0, so improvise
|
||||
$property_name = strtolower(substr($name, 3, 1)) . substr($name, 4);
|
||||
// convert camel case to underscored name
|
||||
$property_name = preg_replace_callback('/([A-Z])/', $camel_func, $property_name);
|
||||
if (!property_exists($this, $property_name)) {
|
||||
throw new SmartyException("property '$property_name' does not exist.");
|
||||
return false;
|
||||
}
|
||||
if ($first3 == 'get')
|
||||
return $this->$property_name;
|
||||
else
|
||||
return $this->$property_name = $args[0];
|
||||
}
|
||||
// Smarty Backward Compatible wrapper
|
||||
if (strpos($name,'_') !== false) {
|
||||
if (!isset($this->wrapper)) {
|
||||
$this->wrapper = new Smarty_Internal_Wrapper($this);
|
||||
}
|
||||
return $this->wrapper->convert($name, $args);
|
||||
}
|
||||
// external Smarty methods ?
|
||||
foreach(array('filter','register') as $external) {
|
||||
if (method_exists("Smarty_Internal_{$external}",$name)) {
|
||||
if (!isset($this->$external)) {
|
||||
$class = "Smarty_Internal_{$external}";
|
||||
$this->$external = new $class($this);
|
||||
}
|
||||
return call_user_func_array(array($this->$external,$name), $args);
|
||||
}
|
||||
}
|
||||
if (in_array($name,array('clearCompiledTemplate','compileAllTemplates','compileAllConfig','testInstall','getTags'))) {
|
||||
if (!isset($this->utility)) {
|
||||
$this->utility = new Smarty_Internal_Utility($this);
|
||||
}
|
||||
return call_user_func_array(array($this->utility,$name), $args);
|
||||
}
|
||||
// PHP4 call to constructor?
|
||||
if (strtolower($name) == 'smarty') {
|
||||
throw new SmartyException('Please use parent::__construct() to call parent constuctor');
|
||||
return false;
|
||||
}
|
||||
throw new SmartyException("Call of unknown function '$name'.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoloader
|
||||
*/
|
||||
function smartyAutoload($class)
|
||||
{
|
||||
$_class = strtolower($class);
|
||||
if (substr($_class, 0, 16) === 'smarty_internal_' || $_class == 'smarty_security') {
|
||||
include SMARTY_SYSPLUGINS_DIR . $_class . '.php';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty exception class
|
||||
*/
|
||||
Class SmartyException extends Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty compiler exception class
|
||||
*/
|
||||
Class SmartyCompilerException extends SmartyException {
|
||||
}
|
||||
|
||||
?>
|
||||
133
onyx2/modules/templates/smarty/debug.tpl
Normal file
133
onyx2/modules/templates/smarty/debug.tpl
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
{capture name='_smarty_debug' assign=debug_output}
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
|
||||
<head>
|
||||
<title>Smarty Debug Console</title>
|
||||
<style type="text/css">
|
||||
{literal}
|
||||
body, h1, h2, td, th, p {
|
||||
font-family: sans-serif;
|
||||
font-weight: normal;
|
||||
font-size: 0.9em;
|
||||
margin: 1px;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0;
|
||||
text-align: left;
|
||||
padding: 2px;
|
||||
background-color: #f0c040;
|
||||
color: black;
|
||||
font-weight: bold;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
|
||||
h2 {
|
||||
background-color: #9B410E;
|
||||
color: white;
|
||||
text-align: left;
|
||||
font-weight: bold;
|
||||
padding: 2px;
|
||||
border-top: 1px solid black;
|
||||
}
|
||||
|
||||
body {
|
||||
background: black;
|
||||
}
|
||||
|
||||
p, table, div {
|
||||
background: #f0ead8;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
table {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
th, td {
|
||||
font-family: monospace;
|
||||
vertical-align: top;
|
||||
text-align: left;
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
td {
|
||||
color: green;
|
||||
}
|
||||
|
||||
.odd {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
|
||||
.even {
|
||||
background-color: #fafafa;
|
||||
}
|
||||
|
||||
.exectime {
|
||||
font-size: 0.8em;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
#table_assigned_vars th {
|
||||
color: blue;
|
||||
}
|
||||
|
||||
#table_config_vars th {
|
||||
color: maroon;
|
||||
}
|
||||
{/literal}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Smarty Debug Console - {if isset($template_name)}{$template_name|debug_print_var}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}</h1>
|
||||
|
||||
{if !empty($template_data)}
|
||||
<h2>included templates & config files (load time in seconds)</h2>
|
||||
|
||||
<div>
|
||||
{foreach $template_data as $template}
|
||||
<font color=brown>{$template.name}</font>
|
||||
<span class="exectime">
|
||||
(compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"})
|
||||
</span>
|
||||
<br>
|
||||
{/foreach}
|
||||
</div>
|
||||
{/if}
|
||||
|
||||
<h2>assigned template variables</h2>
|
||||
|
||||
<table id="table_assigned_vars">
|
||||
{foreach $assigned_vars as $vars}
|
||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||
<th>${$vars@key|escape:'html'}</th>
|
||||
<td>{$vars|debug_print_var}</td></tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
|
||||
<h2>assigned config file variables (outer template scope)</h2>
|
||||
|
||||
<table id="table_config_vars">
|
||||
{foreach $config_vars as $vars}
|
||||
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
|
||||
<th>{$vars@key|escape:'html'}</th>
|
||||
<td>{$vars|debug_print_var}</td></tr>
|
||||
{/foreach}
|
||||
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
||||
{/capture}
|
||||
<script type="text/javascript">
|
||||
{$id = $template_name|default:''|md5}
|
||||
_smarty_console = window.open("","console{$id}","width=680,height=600,resizable,scrollbars=yes");
|
||||
_smarty_console.document.write("{$debug_output|escape:'javascript'}");
|
||||
_smarty_console.document.close();
|
||||
</script>
|
||||
27
onyx2/modules/templates/smarty/plugins/block.php.php
Normal file
27
onyx2/modules/templates/smarty/plugins/block.php.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin to execute PHP code
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsBlock
|
||||
* @author Uwe Tews
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {php}{/php} block plugin
|
||||
*
|
||||
* @param string $content contents of the block
|
||||
* @param object $template template object
|
||||
* @param boolean $ &$repeat repeat flag
|
||||
* @return string content re-formatted
|
||||
*/
|
||||
function smarty_block_php($params, $content, $template, &$repeat)
|
||||
{
|
||||
if (!$template->allow_php_tag) {
|
||||
throw new SmartyException("{php} is deprecated, set allow_php_tag = true to enable");
|
||||
}
|
||||
eval($content);
|
||||
return '';
|
||||
}
|
||||
|
||||
?>
|
||||
102
onyx2/modules/templates/smarty/plugins/block.textformat.php
Normal file
102
onyx2/modules/templates/smarty/plugins/block.textformat.php
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin to format text blocks
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsBlock
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {textformat}{/textformat} block plugin
|
||||
*
|
||||
* Type: block function<br>
|
||||
* Name: textformat<br>
|
||||
* Purpose: format text a certain way with preset styles
|
||||
* or custom wrap/indent settings<br>
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat}
|
||||
* (Smarty online manual)
|
||||
* @param array $params parameters
|
||||
* <pre>
|
||||
* Params: style: string (email)
|
||||
* indent: integer (0)
|
||||
* wrap: integer (80)
|
||||
* wrap_char string ("\n")
|
||||
* indent_char: string (" ")
|
||||
* wrap_boundary: boolean (true)
|
||||
* </pre>
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string $content contents of the block
|
||||
* @param object $template template object
|
||||
* @param boolean &$repeat repeat flag
|
||||
* @return string content re-formatted
|
||||
*/
|
||||
function smarty_block_textformat($params, $content, $template, &$repeat)
|
||||
{
|
||||
if (is_null($content)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$style = null;
|
||||
$indent = 0;
|
||||
$indent_first = 0;
|
||||
$indent_char = ' ';
|
||||
$wrap = 80;
|
||||
$wrap_char = "\n";
|
||||
$wrap_cut = false;
|
||||
$assign = null;
|
||||
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'style':
|
||||
case 'indent_char':
|
||||
case 'wrap_char':
|
||||
case 'assign':
|
||||
$$_key = (string)$_val;
|
||||
break;
|
||||
|
||||
case 'indent':
|
||||
case 'indent_first':
|
||||
case 'wrap':
|
||||
$$_key = (int)$_val;
|
||||
break;
|
||||
|
||||
case 'wrap_cut':
|
||||
$$_key = (bool)$_val;
|
||||
break;
|
||||
|
||||
default:
|
||||
trigger_error("textformat: unknown attribute '$_key'");
|
||||
}
|
||||
}
|
||||
|
||||
if ($style == 'email') {
|
||||
$wrap = 72;
|
||||
}
|
||||
// split into paragraphs
|
||||
$_paragraphs = preg_split('![\r\n][\r\n]!', $content);
|
||||
$_output = '';
|
||||
|
||||
for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
|
||||
if ($_paragraphs[$_x] == '') {
|
||||
continue;
|
||||
}
|
||||
// convert mult. spaces & special chars to single space
|
||||
$_paragraphs[$_x] = preg_replace(array('!\s+!', '!(^\s+)|(\s+$)!'), array(' ', ''), $_paragraphs[$_x]);
|
||||
// indent first line
|
||||
if ($indent_first > 0) {
|
||||
$_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x];
|
||||
}
|
||||
// wordwrap sentences
|
||||
$_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut);
|
||||
// indent lines
|
||||
if ($indent > 0) {
|
||||
$_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]);
|
||||
}
|
||||
}
|
||||
$_output = implode($wrap_char . $wrap_char, $_paragraphs);
|
||||
|
||||
return $assign ? $template->assign($assign, $_output) : $_output;
|
||||
}
|
||||
|
||||
?>
|
||||
78
onyx2/modules/templates/smarty/plugins/function.counter.php
Normal file
78
onyx2/modules/templates/smarty/plugins/function.counter.php
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {counter} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: counter<br>
|
||||
* Purpose: print out a counter value
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @link http://smarty.php.net/manual/en/language.function.counter.php {counter}
|
||||
* (Smarty online manual)
|
||||
* @param array parameters
|
||||
* @param Smarty
|
||||
* @param object $template template object
|
||||
* @return string|null
|
||||
*/
|
||||
function smarty_function_counter($params, $template)
|
||||
{
|
||||
static $counters = array();
|
||||
|
||||
$name = (isset($params['name'])) ? $params['name'] : 'default';
|
||||
if (!isset($counters[$name])) {
|
||||
$counters[$name] = array(
|
||||
'start'=>1,
|
||||
'skip'=>1,
|
||||
'direction'=>'up',
|
||||
'count'=>1
|
||||
);
|
||||
}
|
||||
$counter =& $counters[$name];
|
||||
|
||||
if (isset($params['start'])) {
|
||||
$counter['start'] = $counter['count'] = (int)$params['start'];
|
||||
}
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$counter['assign'] = $params['assign'];
|
||||
}
|
||||
|
||||
if (isset($counter['assign'])) {
|
||||
$template->assign($counter['assign'], $counter['count']);
|
||||
}
|
||||
|
||||
if (isset($params['print'])) {
|
||||
$print = (bool)$params['print'];
|
||||
} else {
|
||||
$print = empty($counter['assign']);
|
||||
}
|
||||
|
||||
if ($print) {
|
||||
$retval = $counter['count'];
|
||||
} else {
|
||||
$retval = null;
|
||||
}
|
||||
|
||||
if (isset($params['skip'])) {
|
||||
$counter['skip'] = $params['skip'];
|
||||
}
|
||||
|
||||
if (isset($params['direction'])) {
|
||||
$counter['direction'] = $params['direction'];
|
||||
}
|
||||
|
||||
if ($counter['direction'] == "down")
|
||||
$counter['count'] -= $counter['skip'];
|
||||
else
|
||||
$counter['count'] += $counter['skip'];
|
||||
|
||||
return $retval;
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
106
onyx2/modules/templates/smarty/plugins/function.cycle.php
Normal file
106
onyx2/modules/templates/smarty/plugins/function.cycle.php
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {cycle} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: cycle<br>
|
||||
* Date: May 3, 2002<br>
|
||||
* Purpose: cycle through given values<br>
|
||||
* Input:
|
||||
* - name = name of cycle (optional)
|
||||
* - values = comma separated list of values to cycle,
|
||||
* or an array of values to cycle
|
||||
* (this can be left out for subsequent calls)
|
||||
* - reset = boolean - resets given var to true
|
||||
* - print = boolean - print var or not. default is true
|
||||
* - advance = boolean - whether or not to advance the cycle
|
||||
* - delimiter = the value delimiter, default is ","
|
||||
* - assign = boolean, assigns to template var instead of
|
||||
* printed.
|
||||
*
|
||||
* Examples:<br>
|
||||
* <pre>
|
||||
* {cycle values="#eeeeee,#d0d0d0d"}
|
||||
* {cycle name=row values="one,two,three" reset=true}
|
||||
* {cycle name=row}
|
||||
* </pre>
|
||||
* @link http://smarty.php.net/manual/en/language.function.cycle.php {cycle}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credit to Mark Priatel <mpriatel@rogers.com>
|
||||
* @author credit to Gerard <gerard@interfold.com>
|
||||
* @author credit to Jason Sweat <jsweat_php@yahoo.com>
|
||||
* @version 1.3
|
||||
* @param array
|
||||
* @param object $template template object
|
||||
* @return string|null
|
||||
*/
|
||||
|
||||
function smarty_function_cycle($params, $template)
|
||||
{
|
||||
static $cycle_vars;
|
||||
|
||||
$name = (empty($params['name'])) ? 'default' : $params['name'];
|
||||
$print = (isset($params['print'])) ? (bool)$params['print'] : true;
|
||||
$advance = (isset($params['advance'])) ? (bool)$params['advance'] : true;
|
||||
$reset = (isset($params['reset'])) ? (bool)$params['reset'] : false;
|
||||
|
||||
if (!in_array('values', array_keys($params))) {
|
||||
if(!isset($cycle_vars[$name]['values'])) {
|
||||
trigger_error("cycle: missing 'values' parameter");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if(isset($cycle_vars[$name]['values'])
|
||||
&& $cycle_vars[$name]['values'] != $params['values'] ) {
|
||||
$cycle_vars[$name]['index'] = 0;
|
||||
}
|
||||
$cycle_vars[$name]['values'] = $params['values'];
|
||||
}
|
||||
|
||||
if (isset($params['delimiter'])) {
|
||||
$cycle_vars[$name]['delimiter'] = $params['delimiter'];
|
||||
} elseif (!isset($cycle_vars[$name]['delimiter'])) {
|
||||
$cycle_vars[$name]['delimiter'] = ',';
|
||||
}
|
||||
|
||||
if(is_array($cycle_vars[$name]['values'])) {
|
||||
$cycle_array = $cycle_vars[$name]['values'];
|
||||
} else {
|
||||
$cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']);
|
||||
}
|
||||
|
||||
if(!isset($cycle_vars[$name]['index']) || $reset ) {
|
||||
$cycle_vars[$name]['index'] = 0;
|
||||
}
|
||||
|
||||
if (isset($params['assign'])) {
|
||||
$print = false;
|
||||
$template->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]);
|
||||
}
|
||||
|
||||
if($print) {
|
||||
$retval = $cycle_array[$cycle_vars[$name]['index']];
|
||||
} else {
|
||||
$retval = null;
|
||||
}
|
||||
|
||||
if($advance) {
|
||||
if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
|
||||
$cycle_vars[$name]['index'] = 0;
|
||||
} else {
|
||||
$cycle_vars[$name]['index']++;
|
||||
}
|
||||
}
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
?>
|
||||
216
onyx2/modules/templates/smarty/plugins/function.fetch.php
Normal file
216
onyx2/modules/templates/smarty/plugins/function.fetch.php
Normal file
|
|
@ -0,0 +1,216 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {fetch} plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: fetch<br>
|
||||
* Purpose: fetch file, web or ftp data and display results
|
||||
* @link http://smarty.php.net/manual/en/language.function.fetch.php {fetch}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param array $params parameters
|
||||
* @param object $template template object
|
||||
* @return string|null if the assign parameter is passed, Smarty assigns the
|
||||
* result to a template variable
|
||||
*/
|
||||
function smarty_function_fetch($params, $template)
|
||||
{
|
||||
if (empty($params['file'])) {
|
||||
trigger_error("[plugin] fetch parameter 'file' cannot be empty",E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
|
||||
$content = '';
|
||||
if (isset($template->security_policy) && !preg_match('!^(http|ftp)://!i', $params['file'])) {
|
||||
if(!$template->security_policy->isTrustedResourceDir($params['file'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
// fetch the file
|
||||
if($fp = @fopen($params['file'],'r')) {
|
||||
while(!feof($fp)) {
|
||||
$content .= fgets ($fp,4096);
|
||||
}
|
||||
fclose($fp);
|
||||
} else {
|
||||
trigger_error('[plugin] fetch cannot read file \'' . $params['file'] . '\'',E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// not a local file
|
||||
if(preg_match('!^http://!i',$params['file'])) {
|
||||
// http fetch
|
||||
if($uri_parts = parse_url($params['file'])) {
|
||||
// set defaults
|
||||
$host = $server_name = $uri_parts['host'];
|
||||
$timeout = 30;
|
||||
$accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
|
||||
$agent = "Smarty Template Engine ".$template->_version;
|
||||
$referer = "";
|
||||
$uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/';
|
||||
$uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : '';
|
||||
$_is_proxy = false;
|
||||
if(empty($uri_parts['port'])) {
|
||||
$port = 80;
|
||||
} else {
|
||||
$port = $uri_parts['port'];
|
||||
}
|
||||
if(!empty($uri_parts['user'])) {
|
||||
$user = $uri_parts['user'];
|
||||
}
|
||||
if(!empty($uri_parts['pass'])) {
|
||||
$pass = $uri_parts['pass'];
|
||||
}
|
||||
// loop through parameters, setup headers
|
||||
foreach($params as $param_key => $param_value) {
|
||||
switch($param_key) {
|
||||
case "file":
|
||||
case "assign":
|
||||
case "assign_headers":
|
||||
break;
|
||||
case "user":
|
||||
if(!empty($param_value)) {
|
||||
$user = $param_value;
|
||||
}
|
||||
break;
|
||||
case "pass":
|
||||
if(!empty($param_value)) {
|
||||
$pass = $param_value;
|
||||
}
|
||||
break;
|
||||
case "accept":
|
||||
if(!empty($param_value)) {
|
||||
$accept = $param_value;
|
||||
}
|
||||
break;
|
||||
case "header":
|
||||
if(!empty($param_value)) {
|
||||
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
|
||||
trigger_error("[plugin] invalid header format '".$param_value."'",E_USER_NOTICE);
|
||||
return;
|
||||
} else {
|
||||
$extra_headers[] = $param_value;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case "proxy_host":
|
||||
if(!empty($param_value)) {
|
||||
$proxy_host = $param_value;
|
||||
}
|
||||
break;
|
||||
case "proxy_port":
|
||||
if(!preg_match('!\D!', $param_value)) {
|
||||
$proxy_port = (int) $param_value;
|
||||
} else {
|
||||
trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
case "agent":
|
||||
if(!empty($param_value)) {
|
||||
$agent = $param_value;
|
||||
}
|
||||
break;
|
||||
case "referer":
|
||||
if(!empty($param_value)) {
|
||||
$referer = $param_value;
|
||||
}
|
||||
break;
|
||||
case "timeout":
|
||||
if(!preg_match('!\D!', $param_value)) {
|
||||
$timeout = (int) $param_value;
|
||||
} else {
|
||||
trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
trigger_error("[plugin] unrecognized attribute '".$param_key."'",E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(!empty($proxy_host) && !empty($proxy_port)) {
|
||||
$_is_proxy = true;
|
||||
$fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout);
|
||||
} else {
|
||||
$fp = fsockopen($server_name,$port,$errno,$errstr,$timeout);
|
||||
}
|
||||
|
||||
if(!$fp) {
|
||||
trigger_error("[plugin] unable to fetch: $errstr ($errno)",E_USER_NOTICE);
|
||||
return;
|
||||
} else {
|
||||
if($_is_proxy) {
|
||||
fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n");
|
||||
} else {
|
||||
fputs($fp, "GET $uri HTTP/1.0\r\n");
|
||||
}
|
||||
if(!empty($host)) {
|
||||
fputs($fp, "Host: $host\r\n");
|
||||
}
|
||||
if(!empty($accept)) {
|
||||
fputs($fp, "Accept: $accept\r\n");
|
||||
}
|
||||
if(!empty($agent)) {
|
||||
fputs($fp, "User-Agent: $agent\r\n");
|
||||
}
|
||||
if(!empty($referer)) {
|
||||
fputs($fp, "Referer: $referer\r\n");
|
||||
}
|
||||
if(isset($extra_headers) && is_array($extra_headers)) {
|
||||
foreach($extra_headers as $curr_header) {
|
||||
fputs($fp, $curr_header."\r\n");
|
||||
}
|
||||
}
|
||||
if(!empty($user) && !empty($pass)) {
|
||||
fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n");
|
||||
}
|
||||
|
||||
fputs($fp, "\r\n");
|
||||
while(!feof($fp)) {
|
||||
$content .= fgets($fp,4096);
|
||||
}
|
||||
fclose($fp);
|
||||
$csplit = preg_split("!\r\n\r\n!",$content,2);
|
||||
|
||||
$content = $csplit[1];
|
||||
|
||||
if(!empty($params['assign_headers'])) {
|
||||
$template->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0]));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
trigger_error("[plugin fetch] unable to parse URL, check syntax",E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// ftp fetch
|
||||
if($fp = @fopen($params['file'],'r')) {
|
||||
while(!feof($fp)) {
|
||||
$content .= fgets ($fp,4096);
|
||||
}
|
||||
fclose($fp);
|
||||
} else {
|
||||
trigger_error('[plugin] fetch cannot read file \'' . $params['file'] .'\'',E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$template->assign($params['assign'],$content);
|
||||
} else {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_checkboxes} function plugin
|
||||
*
|
||||
* File: function.html_checkboxes.php<br>
|
||||
* Type: function<br>
|
||||
* Name: html_checkboxes<br>
|
||||
* Date: 24.Feb.2003<br>
|
||||
* Purpose: Prints out a list of checkbox input types<br>
|
||||
* Examples:
|
||||
* <pre>
|
||||
* {html_checkboxes values=$ids output=$names}
|
||||
* {html_checkboxes values=$ids name='box' separator='<br>' output=$names}
|
||||
* {html_checkboxes values=$ids checked=$checked separator='<br>' output=$names}
|
||||
* </pre>
|
||||
* @link http://smarty.php.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
|
||||
* (Smarty online manual)
|
||||
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
||||
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
||||
* @version 1.0
|
||||
* @param array $params parameters
|
||||
* Input:<br>
|
||||
* - name (optional) - string default "checkbox"
|
||||
* - values (required) - array
|
||||
* - options (optional) - associative array
|
||||
* - checked (optional) - array default not set
|
||||
* - separator (optional) - ie <br> or
|
||||
* - output (optional) - the output next to each checkbox
|
||||
* - assign (optional) - assign the output as an array to this variable
|
||||
* @param object $template template object
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
*/
|
||||
function smarty_function_html_checkboxes($params, $template)
|
||||
{
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
|
||||
$name = 'checkbox';
|
||||
$values = null;
|
||||
$options = null;
|
||||
$selected = null;
|
||||
$separator = '';
|
||||
$labels = true;
|
||||
$output = null;
|
||||
|
||||
$extra = '';
|
||||
|
||||
foreach($params as $_key => $_val) {
|
||||
switch($_key) {
|
||||
case 'name':
|
||||
case 'separator':
|
||||
$$_key = $_val;
|
||||
break;
|
||||
|
||||
case 'labels':
|
||||
$$_key = (bool)$_val;
|
||||
break;
|
||||
|
||||
case 'options':
|
||||
$$_key = (array)$_val;
|
||||
break;
|
||||
|
||||
case 'values':
|
||||
case 'output':
|
||||
$$_key = array_values((array)$_val);
|
||||
break;
|
||||
|
||||
case 'checked':
|
||||
case 'selected':
|
||||
$selected = array_map('strval', array_values((array)$_val));
|
||||
break;
|
||||
|
||||
case 'checkboxes':
|
||||
trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING);
|
||||
$options = (array)$_val;
|
||||
break;
|
||||
|
||||
case 'assign':
|
||||
break;
|
||||
|
||||
default:
|
||||
if(!is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
} else {
|
||||
trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($options) && !isset($values))
|
||||
return ''; /* raise error here? */
|
||||
|
||||
settype($selected, 'array');
|
||||
$_html_result = array();
|
||||
|
||||
if (isset($options)) {
|
||||
|
||||
foreach ($options as $_key=>$_val)
|
||||
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
|
||||
|
||||
|
||||
} else {
|
||||
foreach ($values as $_i=>$_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!empty($params['assign'])) {
|
||||
$template->assign($params['assign'], $_html_result);
|
||||
} else {
|
||||
return implode("\n",$_html_result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels) {
|
||||
$_output = '';
|
||||
if ($labels) $_output .= '<label>';
|
||||
$_output .= '<input type="checkbox" name="'
|
||||
. smarty_function_escape_special_chars($name) . '[]" value="'
|
||||
. smarty_function_escape_special_chars($value) . '"';
|
||||
|
||||
if (in_array((string)$value, $selected)) {
|
||||
$_output .= ' checked="checked"';
|
||||
}
|
||||
$_output .= $extra . ' />' . $output;
|
||||
if ($labels) $_output .= '</label>';
|
||||
$_output .= $separator;
|
||||
|
||||
return $_output;
|
||||
}
|
||||
|
||||
?>
|
||||
137
onyx2/modules/templates/smarty/plugins/function.html_image.php
Normal file
137
onyx2/modules/templates/smarty/plugins/function.html_image.php
Normal file
|
|
@ -0,0 +1,137 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_image} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: html_image<br>
|
||||
* Date: Feb 24, 2003<br>
|
||||
* Purpose: format HTML tags for the image<br>
|
||||
* Examples: {html_image file="/images/masthead.gif"}
|
||||
* Output: <img src="/images/masthead.gif" width=400 height=23>
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credits to Duda <duda@big.hu>
|
||||
* @version 1.0
|
||||
* @param array $params parameters
|
||||
* Input:<br>
|
||||
* - file = file (and path) of image (required)
|
||||
* - height = image height (optional, default actual height)
|
||||
* - width = image width (optional, default actual width)
|
||||
* - basedir = base directory for absolute paths, default
|
||||
* is environment variable DOCUMENT_ROOT
|
||||
* - path_prefix = prefix for path output (optional, default empty)
|
||||
* @param object $template template object
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
*/
|
||||
function smarty_function_html_image($params, $template)
|
||||
{
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
|
||||
$alt = '';
|
||||
$file = '';
|
||||
$height = '';
|
||||
$width = '';
|
||||
$extra = '';
|
||||
$prefix = '';
|
||||
$suffix = '';
|
||||
$path_prefix = '';
|
||||
$server_vars = $_SERVER;
|
||||
$basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : '';
|
||||
foreach($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'file':
|
||||
case 'height':
|
||||
case 'width':
|
||||
case 'dpi':
|
||||
case 'path_prefix':
|
||||
case 'basedir':
|
||||
$$_key = $_val;
|
||||
break;
|
||||
|
||||
case 'alt':
|
||||
if (!is_array($_val)) {
|
||||
$$_key = smarty_function_escape_special_chars($_val);
|
||||
} else {
|
||||
throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'link':
|
||||
case 'href':
|
||||
$prefix = '<a href="' . $_val . '">';
|
||||
$suffix = '</a>';
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
} else {
|
||||
throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($file)) {
|
||||
trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
|
||||
if (substr($file, 0, 1) == '/') {
|
||||
$_image_path = $basedir . $file;
|
||||
} else {
|
||||
$_image_path = $file;
|
||||
}
|
||||
|
||||
if (!isset($params['width']) || !isset($params['height'])) {
|
||||
if (!$_image_data = @getimagesize($_image_path)) {
|
||||
if (!file_exists($_image_path)) {
|
||||
trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE);
|
||||
return;
|
||||
} else if (!is_readable($_image_path)) {
|
||||
trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE);
|
||||
return;
|
||||
} else {
|
||||
trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (isset($template->security_policy)) {
|
||||
if (!$template->security_policy->isTrustedResourceDir($_image_path)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($params['width'])) {
|
||||
$width = $_image_data[0];
|
||||
}
|
||||
if (!isset($params['height'])) {
|
||||
$height = $_image_data[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($params['dpi'])) {
|
||||
if (strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) {
|
||||
$dpi_default = 72;
|
||||
} else {
|
||||
$dpi_default = 96;
|
||||
}
|
||||
$_resize = $dpi_default / $params['dpi'];
|
||||
$width = round($width * $_resize);
|
||||
$height = round($height * $_resize);
|
||||
}
|
||||
|
||||
return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' . $height . '"' . $extra . ' />' . $suffix;
|
||||
}
|
||||
|
||||
?>
|
||||
133
onyx2/modules/templates/smarty/plugins/function.html_options.php
Normal file
133
onyx2/modules/templates/smarty/plugins/function.html_options.php
Normal file
|
|
@ -0,0 +1,133 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_options} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: html_options<br>
|
||||
* Purpose: Prints the list of <option> tags generated from
|
||||
* the passed parameters
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.function.html.options.php {html_image}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param array $params parameters
|
||||
* Input:<br>
|
||||
* - name (optional) - string default "select"
|
||||
* - values (required if no options supplied) - array
|
||||
* - options (required if no values supplied) - associative array
|
||||
* - selected (optional) - string default not set
|
||||
* - output (required if not options supplied) - array
|
||||
* @param object $template template object
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
*/
|
||||
function smarty_function_html_options($params, $template)
|
||||
{
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
|
||||
$name = null;
|
||||
$values = null;
|
||||
$options = null;
|
||||
$selected = array();
|
||||
$output = null;
|
||||
$id = null;
|
||||
$class = null;
|
||||
|
||||
$extra = '';
|
||||
$options_extra = '';
|
||||
|
||||
foreach($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'name':
|
||||
case 'class':
|
||||
case 'id':
|
||||
$$_key = (string)$_val;
|
||||
break;
|
||||
|
||||
case 'options':
|
||||
$$_key = (array)$_val;
|
||||
break;
|
||||
|
||||
case 'values':
|
||||
case 'output':
|
||||
$$_key = array_values((array)$_val);
|
||||
break;
|
||||
|
||||
case 'selected':
|
||||
$$_key = array_map('strval', array_values((array)$_val));
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
} else {
|
||||
trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($options) && !isset($values))
|
||||
return '';
|
||||
/* raise error here? */
|
||||
|
||||
$_html_result = '';
|
||||
$_idx = 0;
|
||||
|
||||
if (isset($options)) {
|
||||
foreach ($options as $_key => $_val) {
|
||||
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx);
|
||||
}
|
||||
} else {
|
||||
foreach ($values as $_i => $_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($name)) {
|
||||
$_html_class = !empty($class) ? ' class="'.$class.'"' : '';
|
||||
$_html_id = !empty($id) ? ' id="'.$id.'"' : '';
|
||||
$_html_result = '<select name="' . $name . '"' . $_html_class . $_html_id . $extra . '>' . "\n" . $_html_result . '</select>' . "\n";
|
||||
}
|
||||
|
||||
return $_html_result;
|
||||
}
|
||||
|
||||
function smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, &$idx)
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
$_html_result = '<option value="' .
|
||||
smarty_function_escape_special_chars($key) . '"';
|
||||
if (in_array((string)$key, $selected))
|
||||
$_html_result .= ' selected="selected"';
|
||||
$_html_class = !empty($class) ? ' class="'.$class.' option"' : '';
|
||||
$_html_id = !empty($id) ? ' id="'.$id.'-'.$idx.'"' : '';
|
||||
$_html_result .= $_html_class . $_html_id . '>' . smarty_function_escape_special_chars($value) . '</option>' . "\n";
|
||||
$idx++;
|
||||
} else {
|
||||
$_idx = 0;
|
||||
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected, $id.'-'.$idx, $class, $_idx);
|
||||
$idx++;
|
||||
}
|
||||
return $_html_result;
|
||||
}
|
||||
|
||||
function smarty_function_html_options_optgroup($key, $values, $selected, $id, $class, &$idx)
|
||||
{
|
||||
$optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n";
|
||||
foreach ($values as $key => $value) {
|
||||
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, $idx);
|
||||
}
|
||||
$optgroup_html .= "</optgroup>\n";
|
||||
return $optgroup_html;
|
||||
}
|
||||
|
||||
?>
|
||||
154
onyx2/modules/templates/smarty/plugins/function.html_radios.php
Normal file
154
onyx2/modules/templates/smarty/plugins/function.html_radios.php
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_radios} function plugin
|
||||
*
|
||||
* File: function.html_radios.php<br>
|
||||
* Type: function<br>
|
||||
* Name: html_radios<br>
|
||||
* Date: 24.Feb.2003<br>
|
||||
* Purpose: Prints out a list of radio input types<br>
|
||||
* Examples:
|
||||
* <pre>
|
||||
* {html_radios values=$ids output=$names}
|
||||
* {html_radios values=$ids name='box' separator='<br>' output=$names}
|
||||
* {html_radios values=$ids checked=$checked separator='<br>' output=$names}
|
||||
* </pre>
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
|
||||
* (Smarty online manual)
|
||||
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
|
||||
* @author credits to Monte Ohrt <monte at ohrt dot com>
|
||||
* @version 1.0
|
||||
* @param array $params parameters
|
||||
* Input:<br>
|
||||
* - name (optional) - string default "radio"
|
||||
* - values (required) - array
|
||||
* - options (optional) - associative array
|
||||
* - checked (optional) - array default not set
|
||||
* - separator (optional) - ie <br> or
|
||||
* - output (optional) - the output next to each radio button
|
||||
* - assign (optional) - assign the output as an array to this variable
|
||||
* @param object $template template object
|
||||
* @return string
|
||||
* @uses smarty_function_escape_special_chars()
|
||||
*/
|
||||
function smarty_function_html_radios($params, $template)
|
||||
{
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
|
||||
$name = 'radio';
|
||||
$values = null;
|
||||
$options = null;
|
||||
$selected = null;
|
||||
$separator = '';
|
||||
$labels = true;
|
||||
$label_ids = false;
|
||||
$output = null;
|
||||
$extra = '';
|
||||
|
||||
foreach($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'name':
|
||||
case 'separator':
|
||||
$$_key = (string)$_val;
|
||||
break;
|
||||
|
||||
case 'checked':
|
||||
case 'selected':
|
||||
if (is_array($_val)) {
|
||||
trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
|
||||
} else {
|
||||
$selected = (string)$_val;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'labels':
|
||||
case 'label_ids':
|
||||
$$_key = (bool)$_val;
|
||||
break;
|
||||
|
||||
case 'options':
|
||||
$$_key = (array)$_val;
|
||||
break;
|
||||
|
||||
case 'values':
|
||||
case 'output':
|
||||
$$_key = array_values((array)$_val);
|
||||
break;
|
||||
|
||||
case 'radios':
|
||||
trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING);
|
||||
$options = (array)$_val;
|
||||
break;
|
||||
|
||||
case 'assign':
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
|
||||
} else {
|
||||
trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($options) && !isset($values))
|
||||
return '';
|
||||
/* raise error here? */
|
||||
|
||||
$_html_result = array();
|
||||
|
||||
if (isset($options)) {
|
||||
foreach ($options as $_key => $_val)
|
||||
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
|
||||
} else {
|
||||
foreach ($values as $_i => $_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$template->assign($params['assign'], $_html_result);
|
||||
} else {
|
||||
return implode("\n", $_html_result);
|
||||
}
|
||||
}
|
||||
|
||||
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids)
|
||||
{
|
||||
$_output = '';
|
||||
if ($labels) {
|
||||
if ($label_ids) {
|
||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!', '_', $name . '_' . $value));
|
||||
$_output .= '<label for="' . $_id . '">';
|
||||
} else {
|
||||
$_output .= '<label>';
|
||||
}
|
||||
}
|
||||
$_output .= '<input type="radio" name="'
|
||||
. smarty_function_escape_special_chars($name) . '" value="'
|
||||
. smarty_function_escape_special_chars($value) . '"';
|
||||
|
||||
if ($labels && $label_ids) $_output .= ' id="' . $_id . '"';
|
||||
|
||||
if ((string)$value == $selected) {
|
||||
$_output .= ' checked="checked"';
|
||||
}
|
||||
$_output .= $extra . ' />' . $output;
|
||||
if ($labels) $_output .= '</label>';
|
||||
$_output .= $separator;
|
||||
|
||||
return $_output;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,330 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_select_date} plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: html_select_date<br>
|
||||
* Purpose: Prints the dropdowns for date selection.
|
||||
*
|
||||
* ChangeLog:<br>
|
||||
* - 1.0 initial release
|
||||
* - 1.1 added support for +/- N syntax for begin
|
||||
* and end year values. (Monte)
|
||||
* - 1.2 added support for yyyy-mm-dd syntax for
|
||||
* time value. (Jan Rosier)
|
||||
* - 1.3 added support for choosing format for
|
||||
* month values (Gary Loescher)
|
||||
* - 1.3.1 added support for choosing format for
|
||||
* day values (Marcus Bointon)
|
||||
* - 1.3.2 support negative timestamps, force year
|
||||
* dropdown to include given date unless explicitly set (Monte)
|
||||
* - 1.3.4 fix behaviour of 0000-00-00 00:00:00 dates to match that
|
||||
* of 0000-00-00 dates (cybot, boots)
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.function.html.select.date.php {html_select_date}
|
||||
* (Smarty online manual)
|
||||
* @version 1.3.4
|
||||
* @author Andrei Zmievski
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param array $params parameters
|
||||
* @param object $template template object
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_html_select_date($params, $template)
|
||||
{
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
require_once(SMARTY_PLUGINS_DIR . 'function.html_options.php');
|
||||
|
||||
/* Default values. */
|
||||
$prefix = "Date_";
|
||||
$start_year = strftime("%Y");
|
||||
$end_year = $start_year;
|
||||
$display_days = true;
|
||||
$display_months = true;
|
||||
$display_years = true;
|
||||
$month_format = "%B";
|
||||
/* Write months as numbers by default GL */
|
||||
$month_value_format = "%m";
|
||||
$day_format = "%02d";
|
||||
/* Write day values using this format MB */
|
||||
$day_value_format = "%d";
|
||||
$year_as_text = false;
|
||||
/* Display years in reverse order? Ie. 2000,1999,.... */
|
||||
$reverse_years = false;
|
||||
/* Should the select boxes be part of an array when returned from PHP?
|
||||
e.g. setting it to "birthday", would create "birthday[Day]",
|
||||
"birthday[Month]" & "birthday[Year]". Can be combined with prefix */
|
||||
$field_array = null;
|
||||
/* <select size>'s of the different <select> tags.
|
||||
If not set, uses default dropdown. */
|
||||
$day_size = null;
|
||||
$month_size = null;
|
||||
$year_size = null;
|
||||
/* Unparsed attributes common to *ALL* the <select>/<input> tags.
|
||||
An example might be in the template: all_extra ='class ="foo"'. */
|
||||
$all_extra = null;
|
||||
/* Separate attributes for the tags. */
|
||||
$day_extra = null;
|
||||
$month_extra = null;
|
||||
$year_extra = null;
|
||||
/* Order in which to display the fields.
|
||||
"D" -> day, "M" -> month, "Y" -> year. */
|
||||
$field_order = 'MDY';
|
||||
/* String printed between the different fields. */
|
||||
$field_separator = "\n";
|
||||
$time = time();
|
||||
$all_empty = null;
|
||||
$day_empty = null;
|
||||
$month_empty = null;
|
||||
$year_empty = null;
|
||||
$extra_attrs = '';
|
||||
|
||||
foreach ($params as $_key => $_value) {
|
||||
switch ($_key) {
|
||||
case 'prefix':
|
||||
case 'time':
|
||||
case 'start_year':
|
||||
case 'end_year':
|
||||
case 'month_format':
|
||||
case 'day_format':
|
||||
case 'day_value_format':
|
||||
case 'field_array':
|
||||
case 'day_size':
|
||||
case 'month_size':
|
||||
case 'year_size':
|
||||
case 'all_extra':
|
||||
case 'day_extra':
|
||||
case 'month_extra':
|
||||
case 'year_extra':
|
||||
case 'field_order':
|
||||
case 'field_separator':
|
||||
case 'month_value_format':
|
||||
case 'month_empty':
|
||||
case 'day_empty':
|
||||
case 'year_empty':
|
||||
$$_key = (string)$_value;
|
||||
break;
|
||||
|
||||
case 'all_empty':
|
||||
$$_key = (string)$_value;
|
||||
$day_empty = $month_empty = $year_empty = $all_empty;
|
||||
break;
|
||||
|
||||
case 'display_days':
|
||||
case 'display_months':
|
||||
case 'display_years':
|
||||
case 'year_as_text':
|
||||
case 'reverse_years':
|
||||
$$_key = (bool)$_value;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (!is_array($_value)) {
|
||||
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
|
||||
} else {
|
||||
trigger_error("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (preg_match('!^-\d+$!', $time)) {
|
||||
// negative timestamp, use date()
|
||||
$time = date('Y-m-d', $time);
|
||||
}
|
||||
// If $time is not in format yyyy-mm-dd
|
||||
if (preg_match('/^(\d{0,4}-\d{0,2}-\d{0,2})/', $time, $found)) {
|
||||
$time = $found[1];
|
||||
} else {
|
||||
// use smarty_make_timestamp to get an unix timestamp and
|
||||
// strftime to make yyyy-mm-dd
|
||||
$time = strftime('%Y-%m-%d', smarty_make_timestamp($time));
|
||||
}
|
||||
// Now split this in pieces, which later can be used to set the select
|
||||
$time = explode("-", $time);
|
||||
// make syntax "+N" or "-N" work with start_year and end_year
|
||||
if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) {
|
||||
if ($match[1] == '+') {
|
||||
$end_year = strftime('%Y') + $match[2];
|
||||
} else {
|
||||
$end_year = strftime('%Y') - $match[2];
|
||||
}
|
||||
}
|
||||
if (preg_match('!^(\+|\-)\s*(\d+)$!', $start_year, $match)) {
|
||||
if ($match[1] == '+') {
|
||||
$start_year = strftime('%Y') + $match[2];
|
||||
} else {
|
||||
$start_year = strftime('%Y') - $match[2];
|
||||
}
|
||||
}
|
||||
if (strlen($time[0]) > 0) {
|
||||
if ($start_year > $time[0] && !isset($params['start_year'])) {
|
||||
// force start year to include given date if not explicitly set
|
||||
$start_year = $time[0];
|
||||
}
|
||||
if ($end_year < $time[0] && !isset($params['end_year'])) {
|
||||
// force end year to include given date if not explicitly set
|
||||
$end_year = $time[0];
|
||||
}
|
||||
}
|
||||
|
||||
$field_order = strtoupper($field_order);
|
||||
|
||||
$html_result = $month_result = $day_result = $year_result = "";
|
||||
|
||||
$field_separator_count = -1;
|
||||
if ($display_months) {
|
||||
$field_separator_count++;
|
||||
$month_names = array();
|
||||
$month_values = array();
|
||||
if (isset($month_empty)) {
|
||||
$month_names[''] = $month_empty;
|
||||
$month_values[''] = '';
|
||||
}
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$month_names[$i] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
|
||||
$month_values[$i] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
|
||||
}
|
||||
|
||||
$month_result .= '<select name=';
|
||||
if (null !== $field_array) {
|
||||
$month_result .= '"' . $field_array . '[' . $prefix . 'Month]"';
|
||||
} else {
|
||||
$month_result .= '"' . $prefix . 'Month"';
|
||||
}
|
||||
if (null !== $month_size) {
|
||||
$month_result .= ' size="' . $month_size . '"';
|
||||
}
|
||||
if (null !== $month_extra) {
|
||||
$month_result .= ' ' . $month_extra;
|
||||
}
|
||||
if (null !== $all_extra) {
|
||||
$month_result .= ' ' . $all_extra;
|
||||
}
|
||||
$month_result .= $extra_attrs . '>' . "\n";
|
||||
|
||||
$month_result .= smarty_function_html_options(array('output' => $month_names,
|
||||
'values' => $month_values,
|
||||
'selected' => (int)$time[1] ? strftime($month_value_format, mktime(0, 0, 0, (int)$time[1], 1, 2000)) : '',
|
||||
'print_result' => false),
|
||||
$template);
|
||||
$month_result .= '</select>';
|
||||
}
|
||||
|
||||
if ($display_days) {
|
||||
$field_separator_count++;
|
||||
$days = array();
|
||||
if (isset($day_empty)) {
|
||||
$days[''] = $day_empty;
|
||||
$day_values[''] = '';
|
||||
}
|
||||
for ($i = 1; $i <= 31; $i++) {
|
||||
$days[] = sprintf($day_format, $i);
|
||||
$day_values[] = sprintf($day_value_format, $i);
|
||||
}
|
||||
|
||||
$day_result .= '<select name=';
|
||||
if (null !== $field_array) {
|
||||
$day_result .= '"' . $field_array . '[' . $prefix . 'Day]"';
|
||||
} else {
|
||||
$day_result .= '"' . $prefix . 'Day"';
|
||||
}
|
||||
if (null !== $day_size) {
|
||||
$day_result .= ' size="' . $day_size . '"';
|
||||
}
|
||||
if (null !== $all_extra) {
|
||||
$day_result .= ' ' . $all_extra;
|
||||
}
|
||||
if (null !== $day_extra) {
|
||||
$day_result .= ' ' . $day_extra;
|
||||
}
|
||||
$day_result .= $extra_attrs . '>' . "\n";
|
||||
$day_result .= smarty_function_html_options(array('output' => $days,
|
||||
'values' => $day_values,
|
||||
'selected' => $time[2],
|
||||
'print_result' => false),
|
||||
$template);
|
||||
$day_result .= '</select>';
|
||||
}
|
||||
|
||||
if ($display_years) {
|
||||
$field_separator_count++;
|
||||
if (null !== $field_array) {
|
||||
$year_name = $field_array . '[' . $prefix . 'Year]';
|
||||
} else {
|
||||
$year_name = $prefix . 'Year';
|
||||
}
|
||||
if ($year_as_text) {
|
||||
$year_result .= '<input type="text" name="' . $year_name . '" value="' . $time[0] . '" size="4" maxlength="4"';
|
||||
if (null !== $all_extra) {
|
||||
$year_result .= ' ' . $all_extra;
|
||||
}
|
||||
if (null !== $year_extra) {
|
||||
$year_result .= ' ' . $year_extra;
|
||||
}
|
||||
$year_result .= ' />';
|
||||
} else {
|
||||
$years = range((int)$start_year, (int)$end_year);
|
||||
if ($reverse_years) {
|
||||
rsort($years, SORT_NUMERIC);
|
||||
} else {
|
||||
sort($years, SORT_NUMERIC);
|
||||
}
|
||||
$yearvals = $years;
|
||||
if (isset($year_empty)) {
|
||||
array_unshift($years, $year_empty);
|
||||
array_unshift($yearvals, '');
|
||||
}
|
||||
$year_result .= '<select name="' . $year_name . '"';
|
||||
if (null !== $year_size) {
|
||||
$year_result .= ' size="' . $year_size . '"';
|
||||
}
|
||||
if (null !== $all_extra) {
|
||||
$year_result .= ' ' . $all_extra;
|
||||
}
|
||||
if (null !== $year_extra) {
|
||||
$year_result .= ' ' . $year_extra;
|
||||
}
|
||||
$year_result .= $extra_attrs . '>' . "\n";
|
||||
$year_result .= smarty_function_html_options(array('output' => $years,
|
||||
'values' => $yearvals,
|
||||
'selected' => $time[0],
|
||||
'print_result' => false),
|
||||
$template);
|
||||
$year_result .= '</select>';
|
||||
}
|
||||
}
|
||||
// Loop thru the field_order field
|
||||
for ($i = 0; $i <= 2; $i++) {
|
||||
$c = substr($field_order, $i, 1);
|
||||
switch ($c) {
|
||||
case 'D':
|
||||
$html_result .= $day_result;
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
$html_result .= $month_result;
|
||||
break;
|
||||
|
||||
case 'Y':
|
||||
$html_result .= $year_result;
|
||||
break;
|
||||
}
|
||||
// Add the field seperator
|
||||
if ($i < $field_separator_count) {
|
||||
$html_result .= $field_separator;
|
||||
}
|
||||
}
|
||||
|
||||
return $html_result;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,194 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_select_time} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: html_select_time<br>
|
||||
* Purpose: Prints the dropdowns for time selection
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.function.html.select.time.php {html_select_time}
|
||||
* (Smarty online manual)
|
||||
* @author Roberto Berto <roberto@berto.net>
|
||||
* @credits Monte Ohrt <monte AT ohrt DOT com>
|
||||
* @param array $params parameters
|
||||
* @param object $template template object
|
||||
* @return string
|
||||
* @uses smarty_make_timestamp()
|
||||
*/
|
||||
function smarty_function_html_select_time($params, $template)
|
||||
{
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
require_once(SMARTY_PLUGINS_DIR . 'function.html_options.php');
|
||||
|
||||
/* Default values. */
|
||||
$prefix = "Time_";
|
||||
$time = time();
|
||||
$display_hours = true;
|
||||
$display_minutes = true;
|
||||
$display_seconds = true;
|
||||
$display_meridian = true;
|
||||
$use_24_hours = true;
|
||||
$minute_interval = 1;
|
||||
$second_interval = 1;
|
||||
/* Should the select boxes be part of an array when returned from PHP?
|
||||
e.g. setting it to "birthday", would create "birthday[Hour]",
|
||||
"birthday[Minute]", "birthday[Seconds]" & "birthday[Meridian]".
|
||||
Can be combined with prefix. */
|
||||
$field_array = null;
|
||||
$all_extra = null;
|
||||
$hour_extra = null;
|
||||
$minute_extra = null;
|
||||
$second_extra = null;
|
||||
$meridian_extra = null;
|
||||
|
||||
foreach ($params as $_key => $_value) {
|
||||
switch ($_key) {
|
||||
case 'prefix':
|
||||
case 'time':
|
||||
case 'field_array':
|
||||
case 'all_extra':
|
||||
case 'hour_extra':
|
||||
case 'minute_extra':
|
||||
case 'second_extra':
|
||||
case 'meridian_extra':
|
||||
$$_key = (string)$_value;
|
||||
break;
|
||||
|
||||
case 'display_hours':
|
||||
case 'display_minutes':
|
||||
case 'display_seconds':
|
||||
case 'display_meridian':
|
||||
case 'use_24_hours':
|
||||
$$_key = (bool)$_value;
|
||||
break;
|
||||
|
||||
case 'minute_interval':
|
||||
case 'second_interval':
|
||||
$$_key = (int)$_value;
|
||||
break;
|
||||
|
||||
default:
|
||||
trigger_error("[html_select_time] unknown parameter $_key", E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
$time = smarty_make_timestamp($time);
|
||||
|
||||
$html_result = '';
|
||||
|
||||
if ($display_hours) {
|
||||
$hours = $use_24_hours ? range(0, 23) : range(1, 12);
|
||||
$hour_fmt = $use_24_hours ? '%H' : '%I';
|
||||
for ($i = 0, $for_max = count($hours); $i < $for_max; $i++)
|
||||
$hours[$i] = sprintf('%02d', $hours[$i]);
|
||||
$html_result .= '<select name=';
|
||||
if (null !== $field_array) {
|
||||
$html_result .= '"' . $field_array . '[' . $prefix . 'Hour]"';
|
||||
} else {
|
||||
$html_result .= '"' . $prefix . 'Hour"';
|
||||
}
|
||||
if (null !== $hour_extra) {
|
||||
$html_result .= ' ' . $hour_extra;
|
||||
}
|
||||
if (null !== $all_extra) {
|
||||
$html_result .= ' ' . $all_extra;
|
||||
}
|
||||
$html_result .= '>' . "\n";
|
||||
$html_result .= smarty_function_html_options(array('output' => $hours,
|
||||
'values' => $hours,
|
||||
'selected' => strftime($hour_fmt, $time),
|
||||
'print_result' => false),
|
||||
$template);
|
||||
$html_result .= "</select>\n";
|
||||
}
|
||||
|
||||
if ($display_minutes) {
|
||||
$all_minutes = range(0, 59);
|
||||
for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i += $minute_interval)
|
||||
$minutes[] = sprintf('%02d', $all_minutes[$i]);
|
||||
$selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval);
|
||||
$html_result .= '<select name=';
|
||||
if (null !== $field_array) {
|
||||
$html_result .= '"' . $field_array . '[' . $prefix . 'Minute]"';
|
||||
} else {
|
||||
$html_result .= '"' . $prefix . 'Minute"';
|
||||
}
|
||||
if (null !== $minute_extra) {
|
||||
$html_result .= ' ' . $minute_extra;
|
||||
}
|
||||
if (null !== $all_extra) {
|
||||
$html_result .= ' ' . $all_extra;
|
||||
}
|
||||
$html_result .= '>' . "\n";
|
||||
|
||||
$html_result .= smarty_function_html_options(array('output' => $minutes,
|
||||
'values' => $minutes,
|
||||
'selected' => $selected,
|
||||
'print_result' => false),
|
||||
$template);
|
||||
$html_result .= "</select>\n";
|
||||
}
|
||||
|
||||
if ($display_seconds) {
|
||||
$all_seconds = range(0, 59);
|
||||
for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i += $second_interval)
|
||||
$seconds[] = sprintf('%02d', $all_seconds[$i]);
|
||||
$selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval);
|
||||
$html_result .= '<select name=';
|
||||
if (null !== $field_array) {
|
||||
$html_result .= '"' . $field_array . '[' . $prefix . 'Second]"';
|
||||
} else {
|
||||
$html_result .= '"' . $prefix . 'Second"';
|
||||
}
|
||||
|
||||
if (null !== $second_extra) {
|
||||
$html_result .= ' ' . $second_extra;
|
||||
}
|
||||
if (null !== $all_extra) {
|
||||
$html_result .= ' ' . $all_extra;
|
||||
}
|
||||
$html_result .= '>' . "\n";
|
||||
|
||||
$html_result .= smarty_function_html_options(array('output' => $seconds,
|
||||
'values' => $seconds,
|
||||
'selected' => $selected,
|
||||
'print_result' => false),
|
||||
$template);
|
||||
$html_result .= "</select>\n";
|
||||
}
|
||||
|
||||
if ($display_meridian && !$use_24_hours) {
|
||||
$html_result .= '<select name=';
|
||||
if (null !== $field_array) {
|
||||
$html_result .= '"' . $field_array . '[' . $prefix . 'Meridian]"';
|
||||
} else {
|
||||
$html_result .= '"' . $prefix . 'Meridian"';
|
||||
}
|
||||
|
||||
if (null !== $meridian_extra) {
|
||||
$html_result .= ' ' . $meridian_extra;
|
||||
}
|
||||
if (null !== $all_extra) {
|
||||
$html_result .= ' ' . $all_extra;
|
||||
}
|
||||
$html_result .= '>' . "\n";
|
||||
|
||||
$html_result .= smarty_function_html_options(array('output' => array('AM', 'PM'),
|
||||
'values' => array('am', 'pm'),
|
||||
'selected' => strtolower(strftime('%p', $time)),
|
||||
'print_result' => false),
|
||||
$template);
|
||||
$html_result .= "</select>\n";
|
||||
}
|
||||
|
||||
return $html_result;
|
||||
}
|
||||
|
||||
?>
|
||||
177
onyx2/modules/templates/smarty/plugins/function.html_table.php
Normal file
177
onyx2/modules/templates/smarty/plugins/function.html_table.php
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {html_table} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: html_table<br>
|
||||
* Date: Feb 17, 2003<br>
|
||||
* Purpose: make an html table from an array of data<br>
|
||||
*
|
||||
*
|
||||
* Examples:
|
||||
* <pre>
|
||||
* {table loop=$data}
|
||||
* {table loop=$data cols=4 tr_attr='"bgcolor=red"'}
|
||||
* {table loop=$data cols="first,second,third" tr_attr=$colors}
|
||||
* </pre>
|
||||
*
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credit to Messju Mohr <messju at lammfellpuschen dot de>
|
||||
* @author credit to boots <boots dot smarty at yahoo dot com>
|
||||
* @version 1.1
|
||||
* @link http://smarty.php.net/manual/en/language.function.html.table.php {html_table}
|
||||
* (Smarty online manual)
|
||||
* @param array $params parameters
|
||||
* Input:<br>
|
||||
* - loop = array to loop through
|
||||
* - cols = number of columns, comma separated list of column names
|
||||
* or array of column names
|
||||
* - rows = number of rows
|
||||
* - table_attr = table attributes
|
||||
* - th_attr = table heading attributes (arrays are cycled)
|
||||
* - tr_attr = table row attributes (arrays are cycled)
|
||||
* - td_attr = table cell attributes (arrays are cycled)
|
||||
* - trailpad = value to pad trailing cells with
|
||||
* - caption = text for caption element
|
||||
* - vdir = vertical direction (default: "down", means top-to-bottom)
|
||||
* - hdir = horizontal direction (default: "right", means left-to-right)
|
||||
* - inner = inner loop (default "cols": print $loop line by line,
|
||||
* $loop will be printed column by column otherwise)
|
||||
* @param object $template template object
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_html_table($params, $template)
|
||||
{
|
||||
$table_attr = 'border="1"';
|
||||
$tr_attr = '';
|
||||
$th_attr = '';
|
||||
$td_attr = '';
|
||||
$cols = $cols_count = 3;
|
||||
$rows = 3;
|
||||
$trailpad = ' ';
|
||||
$vdir = 'down';
|
||||
$hdir = 'right';
|
||||
$inner = 'cols';
|
||||
$caption = '';
|
||||
$loop = null;
|
||||
|
||||
if (!isset($params['loop'])) {
|
||||
trigger_error("html_table: missing 'loop' parameter",E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
foreach ($params as $_key => $_value) {
|
||||
switch ($_key) {
|
||||
case 'loop':
|
||||
$$_key = (array)$_value;
|
||||
break;
|
||||
|
||||
case 'cols':
|
||||
if (is_array($_value) && !empty($_value)) {
|
||||
$cols = $_value;
|
||||
$cols_count = count($_value);
|
||||
} elseif (!is_numeric($_value) && is_string($_value) && !empty($_value)) {
|
||||
$cols = explode(',', $_value);
|
||||
$cols_count = count($cols);
|
||||
} elseif (!empty($_value)) {
|
||||
$cols_count = (int)$_value;
|
||||
} else {
|
||||
$cols_count = $cols;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'rows':
|
||||
$$_key = (int)$_value;
|
||||
break;
|
||||
|
||||
case 'table_attr':
|
||||
case 'trailpad':
|
||||
case 'hdir':
|
||||
case 'vdir':
|
||||
case 'inner':
|
||||
case 'caption':
|
||||
$$_key = (string)$_value;
|
||||
break;
|
||||
|
||||
case 'tr_attr':
|
||||
case 'td_attr':
|
||||
case 'th_attr':
|
||||
$$_key = $_value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$loop_count = count($loop);
|
||||
if (empty($params['rows'])) {
|
||||
/* no rows specified */
|
||||
$rows = ceil($loop_count / $cols_count);
|
||||
} elseif (empty($params['cols'])) {
|
||||
if (!empty($params['rows'])) {
|
||||
/* no cols specified, but rows */
|
||||
$cols_count = ceil($loop_count / $rows);
|
||||
}
|
||||
}
|
||||
|
||||
$output = "<table $table_attr>\n";
|
||||
|
||||
if (!empty($caption)) {
|
||||
$output .= '<caption>' . $caption . "</caption>\n";
|
||||
}
|
||||
|
||||
if (is_array($cols)) {
|
||||
$cols = ($hdir == 'right') ? $cols : array_reverse($cols);
|
||||
$output .= "<thead><tr>\n";
|
||||
|
||||
for ($r = 0; $r < $cols_count; $r++) {
|
||||
$output .= '<th' . smarty_function_html_table_cycle('th', $th_attr, $r) . '>';
|
||||
$output .= $cols[$r];
|
||||
$output .= "</th>\n";
|
||||
}
|
||||
$output .= "</tr></thead>\n";
|
||||
}
|
||||
|
||||
$output .= "<tbody>\n";
|
||||
for ($r = 0; $r < $rows; $r++) {
|
||||
$output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n";
|
||||
$rx = ($vdir == 'down') ? $r * $cols_count : ($rows-1 - $r) * $cols_count;
|
||||
|
||||
for ($c = 0; $c < $cols_count; $c++) {
|
||||
$x = ($hdir == 'right') ? $rx + $c : $rx + $cols_count-1 - $c;
|
||||
if ($inner != 'cols') {
|
||||
/* shuffle x to loop over rows*/
|
||||
$x = floor($x / $cols_count) + ($x % $cols_count) * $rows;
|
||||
}
|
||||
|
||||
if ($x < $loop_count) {
|
||||
$output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">" . $loop[$x] . "</td>\n";
|
||||
} else {
|
||||
$output .= "<td" . smarty_function_html_table_cycle('td', $td_attr, $c) . ">$trailpad</td>\n";
|
||||
}
|
||||
}
|
||||
$output .= "</tr>\n";
|
||||
}
|
||||
$output .= "</tbody>\n";
|
||||
$output .= "</table>\n";
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function smarty_function_html_table_cycle($name, $var, $no)
|
||||
{
|
||||
if (!is_array($var)) {
|
||||
$ret = $var;
|
||||
} else {
|
||||
$ret = $var[$no % count($var)];
|
||||
}
|
||||
|
||||
return ($ret) ? ' ' . $ret : '';
|
||||
}
|
||||
|
||||
?>
|
||||
156
onyx2/modules/templates/smarty/plugins/function.mailto.php
Normal file
156
onyx2/modules/templates/smarty/plugins/function.mailto.php
Normal file
|
|
@ -0,0 +1,156 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {mailto} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: mailto<br>
|
||||
* Date: May 21, 2002
|
||||
* Purpose: automate mailto address link creation, and optionally
|
||||
* encode them.<br>
|
||||
*
|
||||
* Examples:
|
||||
* <pre>
|
||||
* {mailto address="me@domain.com"}
|
||||
* {mailto address="me@domain.com" encode="javascript"}
|
||||
* {mailto address="me@domain.com" encode="hex"}
|
||||
* {mailto address="me@domain.com" subject="Hello to you!"}
|
||||
* {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
|
||||
* {mailto address="me@domain.com" extra='class="mailto"'}
|
||||
* </pre>
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.function.mailto.php {mailto}
|
||||
* (Smarty online manual)
|
||||
* @version 1.2
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author credits to Jason Sweat (added cc, bcc and subject functionality)
|
||||
* @param array $params parameters
|
||||
* Input:<br>
|
||||
* - address = e-mail address
|
||||
* - text = (optional) text to display, default is address
|
||||
* - encode = (optional) can be one of:
|
||||
* * none : no encoding (default)
|
||||
* * javascript : encode with javascript
|
||||
* * javascript_charcode : encode with javascript charcode
|
||||
* * hex : encode with hexidecimal (no javascript)
|
||||
* - cc = (optional) address(es) to carbon copy
|
||||
* - bcc = (optional) address(es) to blind carbon copy
|
||||
* - subject = (optional) e-mail subject
|
||||
* - newsgroups = (optional) newsgroup(s) to post to
|
||||
* - followupto = (optional) address(es) to follow up to
|
||||
* - extra = (optional) extra tags for the href link
|
||||
* @param object $template template object
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_mailto($params, $template)
|
||||
{
|
||||
$extra = '';
|
||||
|
||||
if (empty($params['address'])) {
|
||||
trigger_error("mailto: missing 'address' parameter",E_USER_WARNING);
|
||||
return;
|
||||
} else {
|
||||
$address = $params['address'];
|
||||
}
|
||||
|
||||
$text = $address;
|
||||
// netscape and mozilla do not decode %40 (@) in BCC field (bug?)
|
||||
// so, don't encode it.
|
||||
$search = array('%40', '%2C');
|
||||
$replace = array('@', ',');
|
||||
$mail_parms = array();
|
||||
foreach ($params as $var => $value) {
|
||||
switch ($var) {
|
||||
case 'cc':
|
||||
case 'bcc':
|
||||
case 'followupto':
|
||||
if (!empty($value))
|
||||
$mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value));
|
||||
break;
|
||||
|
||||
case 'subject':
|
||||
case 'newsgroups':
|
||||
$mail_parms[] = $var . '=' . rawurlencode($value);
|
||||
break;
|
||||
|
||||
case 'extra':
|
||||
case 'text':
|
||||
$$var = $value;
|
||||
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
||||
$mail_parm_vals = '';
|
||||
for ($i = 0; $i < count($mail_parms); $i++) {
|
||||
$mail_parm_vals .= (0 == $i) ? '?' : '&';
|
||||
$mail_parm_vals .= $mail_parms[$i];
|
||||
}
|
||||
$address .= $mail_parm_vals;
|
||||
|
||||
$encode = (empty($params['encode'])) ? 'none' : $params['encode'];
|
||||
if (!in_array($encode, array('javascript', 'javascript_charcode', 'hex', 'none'))) {
|
||||
trigger_error("mailto: 'encode' parameter must be none, javascript or hex",E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
if ($encode == 'javascript') {
|
||||
$string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');';
|
||||
|
||||
$js_encode = '';
|
||||
for ($x = 0; $x < strlen($string); $x++) {
|
||||
$js_encode .= '%' . bin2hex($string[$x]);
|
||||
}
|
||||
|
||||
return '<script type="text/javascript">eval(unescape(\'' . $js_encode . '\'))</script>';
|
||||
} elseif ($encode == 'javascript_charcode') {
|
||||
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
||||
|
||||
for($x = 0, $y = strlen($string); $x < $y; $x++) {
|
||||
$ord[] = ord($string[$x]);
|
||||
}
|
||||
|
||||
$_ret = "<script type=\"text/javascript\" language=\"javascript\">\n";
|
||||
$_ret .= "<!--\n";
|
||||
$_ret .= "{document.write(String.fromCharCode(";
|
||||
$_ret .= implode(',', $ord);
|
||||
$_ret .= "))";
|
||||
$_ret .= "}\n";
|
||||
$_ret .= "//-->\n";
|
||||
$_ret .= "</script>\n";
|
||||
|
||||
return $_ret;
|
||||
} elseif ($encode == 'hex') {
|
||||
preg_match('!^(.*)(\?.*)$!', $address, $match);
|
||||
if (!empty($match[2])) {
|
||||
trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.",E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
$address_encode = '';
|
||||
for ($x = 0; $x < strlen($address); $x++) {
|
||||
if (preg_match('!\w!', $address[$x])) {
|
||||
$address_encode .= '%' . bin2hex($address[$x]);
|
||||
} else {
|
||||
$address_encode .= $address[$x];
|
||||
}
|
||||
}
|
||||
$text_encode = '';
|
||||
for ($x = 0; $x < strlen($text); $x++) {
|
||||
$text_encode .= '&#x' . bin2hex($text[$x]) . ';';
|
||||
}
|
||||
|
||||
$mailto = "mailto:";
|
||||
return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>';
|
||||
} else {
|
||||
// no encoding
|
||||
return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
83
onyx2/modules/templates/smarty/plugins/function.math.php
Normal file
83
onyx2/modules/templates/smarty/plugins/function.math.php
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* This plugin is only for Smarty2 BC
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {math} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: math<br>
|
||||
* Purpose: handle math computations in template<br>
|
||||
* @link http://smarty.php.net/manual/en/language.function.math.php {math}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param array $params parameters
|
||||
* @param object $template template object
|
||||
* @return string|null
|
||||
*/
|
||||
function smarty_function_math($params, $template)
|
||||
{
|
||||
// be sure equation parameter is present
|
||||
if (empty($params['equation'])) {
|
||||
trigger_error("math: missing equation parameter",E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
$equation = $params['equation'];
|
||||
|
||||
// make sure parenthesis are balanced
|
||||
if (substr_count($equation,"(") != substr_count($equation,")")) {
|
||||
trigger_error("math: unbalanced parenthesis",E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
|
||||
// match all vars in equation, make sure all are passed
|
||||
preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!",$equation, $match);
|
||||
$allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10',
|
||||
'max','min','pi','pow','rand','round','sin','sqrt','srand','tan');
|
||||
|
||||
foreach($match[1] as $curr_var) {
|
||||
if ($curr_var && !in_array($curr_var, array_keys($params)) && !in_array($curr_var, $allowed_funcs)) {
|
||||
trigger_error("math: function call $curr_var not allowed",E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
foreach($params as $key => $val) {
|
||||
if ($key != "equation" && $key != "format" && $key != "assign") {
|
||||
// make sure value is not empty
|
||||
if (strlen($val)==0) {
|
||||
trigger_error("math: parameter $key is empty",E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
if (!is_numeric($val)) {
|
||||
trigger_error("math: parameter $key: is not numeric",E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
$equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
|
||||
}
|
||||
}
|
||||
$smarty_math_result = null;
|
||||
eval("\$smarty_math_result = ".$equation.";");
|
||||
|
||||
if (empty($params['format'])) {
|
||||
if (empty($params['assign'])) {
|
||||
return $smarty_math_result;
|
||||
} else {
|
||||
$template->assign($params['assign'],$smarty_math_result);
|
||||
}
|
||||
} else {
|
||||
if (empty($params['assign'])){
|
||||
printf($params['format'],$smarty_math_result);
|
||||
} else {
|
||||
$template->assign($params['assign'],sprintf($params['format'],$smarty_math_result));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
118
onyx2/modules/templates/smarty/plugins/function.popup.php
Normal file
118
onyx2/modules/templates/smarty/plugins/function.popup.php
Normal file
|
|
@ -0,0 +1,118 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty {popup} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: popup<br>
|
||||
* Purpose: make text pop up in windows via overlib
|
||||
* @link http://smarty.php.net/manual/en/language.function.popup.php {popup}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param array $params parameters
|
||||
* @param object $smarty Smarty object
|
||||
* @param object $template template object
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_popup($params, $smarty, $template)
|
||||
{
|
||||
$append = '';
|
||||
foreach ($params as $_key=>$_value) {
|
||||
switch ($_key) {
|
||||
case 'text':
|
||||
case 'trigger':
|
||||
case 'function':
|
||||
case 'inarray':
|
||||
$$_key = (string)$_value;
|
||||
if ($_key == 'function' || $_key == 'inarray')
|
||||
$append .= ',' . strtoupper($_key) . ",'$_value'";
|
||||
break;
|
||||
|
||||
case 'caption':
|
||||
case 'closetext':
|
||||
case 'status':
|
||||
$append .= ',' . strtoupper($_key) . ",'" . str_replace("'","\'",$_value) . "'";
|
||||
break;
|
||||
|
||||
case 'fgcolor':
|
||||
case 'bgcolor':
|
||||
case 'textcolor':
|
||||
case 'capcolor':
|
||||
case 'closecolor':
|
||||
case 'textfont':
|
||||
case 'captionfont':
|
||||
case 'closefont':
|
||||
case 'fgbackground':
|
||||
case 'bgbackground':
|
||||
case 'caparray':
|
||||
case 'capicon':
|
||||
case 'background':
|
||||
case 'frame':
|
||||
$append .= ',' . strtoupper($_key) . ",'$_value'";
|
||||
break;
|
||||
|
||||
case 'textsize':
|
||||
case 'captionsize':
|
||||
case 'closesize':
|
||||
case 'width':
|
||||
case 'height':
|
||||
case 'border':
|
||||
case 'offsetx':
|
||||
case 'offsety':
|
||||
case 'snapx':
|
||||
case 'snapy':
|
||||
case 'fixx':
|
||||
case 'fixy':
|
||||
case 'padx':
|
||||
case 'pady':
|
||||
case 'timeout':
|
||||
case 'delay':
|
||||
$append .= ',' . strtoupper($_key) . ",$_value";
|
||||
break;
|
||||
|
||||
case 'sticky':
|
||||
case 'left':
|
||||
case 'right':
|
||||
case 'center':
|
||||
case 'above':
|
||||
case 'below':
|
||||
case 'noclose':
|
||||
case 'autostatus':
|
||||
case 'autostatuscap':
|
||||
case 'fullhtml':
|
||||
case 'hauto':
|
||||
case 'vauto':
|
||||
case 'mouseoff':
|
||||
case 'followmouse':
|
||||
case 'closeclick':
|
||||
case 'wrap':
|
||||
if ($_value) $append .= ',' . strtoupper($_key);
|
||||
break;
|
||||
|
||||
default:
|
||||
trigger_error("[popup] unknown parameter $_key", E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
|
||||
if (empty($text) && !isset($inarray) && empty($function)) {
|
||||
trigger_error("overlib: attribute 'text' or 'inarray' or 'function' required",E_USER_WARNING);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (empty($trigger)) { $trigger = "onmouseover"; }
|
||||
|
||||
$retval = $trigger . '="return overlib(\''.preg_replace(array("!'!",'!"!',"![\r\n]!"),array("\'","\'",'\r'),$text).'\'';
|
||||
$retval .= $append . ');"';
|
||||
if ($trigger == 'onmouseover')
|
||||
$retval .= ' onmouseout="nd();"';
|
||||
|
||||
|
||||
return $retval;
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty {popup_init} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: popup_init<br>
|
||||
* Purpose: initialize overlib
|
||||
* @link http://smarty.php.net/manual/en/language.function.popup.init.php {popup_init}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param array $params parameters
|
||||
* @param object $smarty Smarty object
|
||||
* @param object $template template object
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_popup_init($params, $smarty, $template)
|
||||
{
|
||||
$zindex = 1000;
|
||||
|
||||
if (!empty($params['zindex'])) {
|
||||
$zindex = $params['zindex'];
|
||||
}
|
||||
|
||||
if (!empty($params['src'])) {
|
||||
return '<div id="overDiv" style="position:absolute; visibility:hidden; z-index:'.$zindex.';"></div>' . "\n"
|
||||
. '<script type="text/javascript" language="JavaScript" src="'.$params['src'].'"></script>' . "\n";
|
||||
} else {
|
||||
trigger_error("popup_init: missing src parameter",E_USER_WARNING);
|
||||
}
|
||||
}
|
||||
?>
|
||||
33
onyx2/modules/templates/smarty/plugins/function.text.php
Normal file
33
onyx2/modules/templates/smarty/plugins/function.text.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty {text} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: text<br>
|
||||
* @author Némunaire <nemunaire@gmail.com>
|
||||
*/
|
||||
function smarty_function_text($params, &$template)
|
||||
{
|
||||
if (empty($params["lang"]))
|
||||
{
|
||||
if (isset($params['assign']))
|
||||
$template->assign($params['assign'], Lang::getText($params["file"], $params["path"]));
|
||||
else
|
||||
return Lang::getText($params["file"], $params["path"]);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (isset($params['assign']))
|
||||
$template->assign($params['assign'], Lang::getText($params["file"], $params["path"], $params["lang"]));
|
||||
else
|
||||
return Lang::getText($params["file"], $params["path"], $params["lang"]);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty capitalize modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: capitalize<br>
|
||||
* Purpose: capitalize words in the string
|
||||
*
|
||||
* @link
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string $
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_capitalize($string, $uc_digits = false)
|
||||
{
|
||||
// uppercase with php function ucwords
|
||||
$upper_string = ucwords($string);
|
||||
// check for any missed hyphenated words
|
||||
$upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!ue", "'\\1'.ucfirst('\\2')", $upper_string);
|
||||
// check uc_digits case
|
||||
if (!$uc_digits) {
|
||||
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!u", $string, $matches, PREG_OFFSET_CAPTURE)) {
|
||||
foreach($matches[1] as $match)
|
||||
$upper_string = substr_replace($upper_string, $match[0], $match[1], strlen($match[0]));
|
||||
}
|
||||
}
|
||||
return $upper_string;
|
||||
}
|
||||
|
||||
?>
|
||||
31
onyx2/modules/templates/smarty/plugins/modifier.cat.php
Normal file
31
onyx2/modules/templates/smarty/plugins/modifier.cat.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty cat modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: cat<br>
|
||||
* Date: Feb 24, 2003
|
||||
* Purpose: catenate a value to a variable
|
||||
* Input: string to catenate
|
||||
* Example: {$var|cat:"foo"}
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @version 1.0
|
||||
* @param string
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_cat($string, $cat)
|
||||
{
|
||||
return $string . $cat;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty count_characters modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: count_characteres<br>
|
||||
* Purpose: count the number of characters in a text
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.count.characters.php
|
||||
* count_characters (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string $string input string
|
||||
* @param boolean $include_spaces include whitespace in the character count
|
||||
* @return integer number of characters
|
||||
*/
|
||||
function smarty_modifier_count_characters($string, $include_spaces = false)
|
||||
{
|
||||
if ($include_spaces)
|
||||
return(strlen($string));
|
||||
|
||||
return preg_match_all("/[^\s]/",$string, $match);
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty count_paragraphs modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: count_paragraphs<br>
|
||||
* Purpose: count the number of paragraphs in a text
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* count_paragraphs (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string
|
||||
* @return integer
|
||||
*/
|
||||
function smarty_modifier_count_paragraphs($string)
|
||||
{
|
||||
// count \r or \n characters
|
||||
return count(preg_split('/[\r\n]+/', $string));
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty count_sentences modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: count_sentences
|
||||
* Purpose: count the number of sentences in a text
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.count.paragraphs.php
|
||||
* count_sentences (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string
|
||||
* @return integer
|
||||
*/
|
||||
function smarty_modifier_count_sentences($string)
|
||||
{
|
||||
// find periods with a word before but not after.
|
||||
return preg_match_all('/[^\s]\.(?!\w)/', $string, $match);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty count_words modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: count_words<br>
|
||||
* Purpose: count the number of words in a text
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.count.words.php
|
||||
* count_words (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string
|
||||
* @return integer
|
||||
*/
|
||||
function smarty_modifier_count_words($string)
|
||||
{
|
||||
return str_word_count($string);
|
||||
}
|
||||
?>
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage plugins
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty countdown modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: countdown<br>
|
||||
* Date: Apr 15, 2009
|
||||
* Example: {$seconds|countdown}
|
||||
* @version 1.0
|
||||
* @author Nemunaire <nemunaire at gmail dot com>
|
||||
* @param timestamp
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_countdown($secondes)
|
||||
{
|
||||
$heures = intval($secondes/3600);
|
||||
if ($heures < 10) $heures = '0'.$heures;
|
||||
$minutes = intval(($secondes%3600)/60);
|
||||
if ($minutes < 10) $minutes = '0'.$minutes;
|
||||
$secondes = $secondes%60;
|
||||
if ($secondes < 10) $secondes = '0'.$secondes;
|
||||
|
||||
return $heures.':'.$minutes.':'.$secondes;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty date_format modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: date_format<br>
|
||||
* Purpose: format datestamps via strftime<br>
|
||||
* Input:<br>
|
||||
* - string: input date string
|
||||
* - format: strftime format for output
|
||||
* - default_date: default date if $string is empty
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string $
|
||||
* @param string $
|
||||
* @param string $
|
||||
* @return string |void
|
||||
* @uses smarty_make_timestamp()
|
||||
*/
|
||||
function smarty_modifier_date_format($string, $format = SMARTY_RESOURCE_DATE_FORMAT, $default_date = '',$formatter='auto')
|
||||
{
|
||||
/**
|
||||
* Include the {@link shared.make_timestamp.php} plugin
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
if ($string != '') {
|
||||
$timestamp = smarty_make_timestamp($string);
|
||||
} elseif ($default_date != '') {
|
||||
$timestamp = smarty_make_timestamp($default_date);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
if($formatter=='strftime'||($formatter=='auto'&&strpos($format,'%')!==false)) {
|
||||
if (DS == '\\') {
|
||||
$_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
|
||||
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
|
||||
if (strpos($format, '%e') !== false) {
|
||||
$_win_from[] = '%e';
|
||||
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
|
||||
}
|
||||
if (strpos($format, '%l') !== false) {
|
||||
$_win_from[] = '%l';
|
||||
$_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
|
||||
}
|
||||
$format = str_replace($_win_from, $_win_to, $format);
|
||||
}
|
||||
return strftime($format, $timestamp);
|
||||
} else {
|
||||
return date($format, $timestamp);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage Debug
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty debug_print_var modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: debug_print_var<br>
|
||||
* Purpose: formats variable contents for display in the console
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php debug_print_var (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param array $ |object
|
||||
* @param integer $
|
||||
* @param integer $
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40)
|
||||
{
|
||||
$_replace = array("\n" => '<i>\n</i>',
|
||||
"\r" => '<i>\r</i>',
|
||||
"\t" => '<i>\t</i>'
|
||||
);
|
||||
|
||||
switch (gettype($var)) {
|
||||
case 'array' :
|
||||
$results = '<b>Array (' . count($var) . ')</b>';
|
||||
foreach ($var as $curr_key => $curr_val) {
|
||||
$results .= '<br>' . str_repeat(' ', $depth * 2)
|
||||
. '<b>' . strtr($curr_key, $_replace) . '</b> => '
|
||||
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
|
||||
$depth--;
|
||||
}
|
||||
break;
|
||||
case 'object' :
|
||||
$object_vars = get_object_vars($var);
|
||||
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
|
||||
foreach ($object_vars as $curr_key => $curr_val) {
|
||||
$results .= '<br>' . str_repeat(' ', $depth * 2)
|
||||
. '<b> ->' . strtr($curr_key, $_replace) . '</b> = '
|
||||
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
|
||||
$depth--;
|
||||
}
|
||||
break;
|
||||
case 'boolean' :
|
||||
case 'NULL' :
|
||||
case 'resource' :
|
||||
if (true === $var) {
|
||||
$results = 'true';
|
||||
} elseif (false === $var) {
|
||||
$results = 'false';
|
||||
} elseif (null === $var) {
|
||||
$results = 'null';
|
||||
} else {
|
||||
$results = htmlspecialchars((string) $var);
|
||||
}
|
||||
$results = '<i>' . $results . '</i>';
|
||||
break;
|
||||
case 'integer' :
|
||||
case 'float' :
|
||||
$results = htmlspecialchars((string) $var);
|
||||
break;
|
||||
case 'string' :
|
||||
$results = strtr($var, $_replace);
|
||||
if (strlen($var) > $length) {
|
||||
$results = substr($var, 0, $length - 3) . '...';
|
||||
}
|
||||
$results = htmlspecialchars('"' . $results . '"');
|
||||
break;
|
||||
case 'unknown type' :
|
||||
default :
|
||||
$results = strtr((string) $var, $_replace);
|
||||
if (strlen($results) > $length) {
|
||||
$results = substr($results, 0, $length - 3) . '...';
|
||||
}
|
||||
$results = htmlspecialchars($results);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue