Initial commit
This commit is contained in:
commit
998d011cd3
233 changed files with 36893 additions and 0 deletions
60
onyx/modules/bbcode/main.php
Normal file
60
onyx/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
onyx/modules/captcha/fonts/0.ttfdd
Normal file
BIN
onyx/modules/captcha/fonts/0.ttfdd
Normal file
Binary file not shown.
BIN
onyx/modules/captcha/fonts/1.ttf
Normal file
BIN
onyx/modules/captcha/fonts/1.ttf
Normal file
Binary file not shown.
121
onyx/modules/captcha/main.php
Normal file
121
onyx/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
onyx/modules/captcha/mots.list
Executable file
3834
onyx/modules/captcha/mots.list
Executable file
File diff suppressed because it is too large
Load diff
28
onyx/modules/chconfig/__config.class.php
Normal file
28
onyx/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
onyx/modules/chconfig/chconfig.class.php
Normal file
110
onyx/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
onyx/modules/chconfig/chmodules.class.php
Normal file
57
onyx/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
onyx/modules/chconfig/main.php
Normal file
65
onyx/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
onyx/modules/db/main.php
Normal file
28
onyx/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
onyx/modules/db/mysql.class.php
Normal file
171
onyx/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
onyx/modules/db/postgresql.class.php
Normal file
169
onyx/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
onyx/modules/lang/main.php
Normal file
96
onyx/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
onyx/modules/mail/class.phpmailer.php
Normal file
2320
onyx/modules/mail/class.phpmailer.php
Normal file
File diff suppressed because it is too large
Load diff
407
onyx/modules/mail/class.pop3.php
Normal file
407
onyx/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
onyx/modules/mail/class.smtp.php
Normal file
814
onyx/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
onyx/modules/mail/language/phpmailer.lang-ar.php
Normal file
26
onyx/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
onyx/modules/mail/language/phpmailer.lang-br.php
Normal file
23
onyx/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
onyx/modules/mail/language/phpmailer.lang-ca.php
Normal file
24
onyx/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
onyx/modules/mail/language/phpmailer.lang-ch.php
Normal file
24
onyx/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
onyx/modules/mail/language/phpmailer.lang-cz.php
Normal file
23
onyx/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
onyx/modules/mail/language/phpmailer.lang-de.php
Normal file
24
onyx/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
onyx/modules/mail/language/phpmailer.lang-dk.php
Normal file
23
onyx/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
onyx/modules/mail/language/phpmailer.lang-en.php
Normal file
23
onyx/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
onyx/modules/mail/language/phpmailer.lang-es.php
Normal file
23
onyx/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
onyx/modules/mail/language/phpmailer.lang-et.php
Normal file
24
onyx/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
onyx/modules/mail/language/phpmailer.lang-fi.php
Normal file
24
onyx/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
onyx/modules/mail/language/phpmailer.lang-fo.php
Normal file
25
onyx/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
onyx/modules/mail/language/phpmailer.lang-fr.php
Normal file
23
onyx/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
onyx/modules/mail/language/phpmailer.lang-hu.php
Normal file
23
onyx/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
onyx/modules/mail/language/phpmailer.lang-it.php
Normal file
26
onyx/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
onyx/modules/mail/language/phpmailer.lang-ja.php
Normal file
24
onyx/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
onyx/modules/mail/language/phpmailer.lang-nl.php
Normal file
23
onyx/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
onyx/modules/mail/language/phpmailer.lang-no.php
Normal file
23
onyx/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
onyx/modules/mail/language/phpmailer.lang-pl.php
Normal file
23
onyx/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
onyx/modules/mail/language/phpmailer.lang-ro.php
Normal file
24
onyx/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
onyx/modules/mail/language/phpmailer.lang-ru.php
Normal file
23
onyx/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
onyx/modules/mail/language/phpmailer.lang-se.php
Normal file
23
onyx/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
onyx/modules/mail/language/phpmailer.lang-tr.php
Normal file
24
onyx/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
onyx/modules/mail/language/phpmailer.lang-zh.php
Normal file
23
onyx/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
onyx/modules/mail/language/phpmailer.lang-zh_cn.php
Normal file
24
onyx/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
onyx/modules/mail/main.php
Normal file
38
onyx/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
onyx/modules/modules.xml
Normal file
93
onyx/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
onyx/modules/pistage/main.php
Normal file
34
onyx/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
onyx/modules/session/main.php
Normal file
20
onyx/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
onyx/modules/session/mysql.class.php
Normal file
161
onyx/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
onyx/modules/session/postgresql.class.php
Normal file
153
onyx/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
onyx/modules/templates/config/config
Normal file
0
onyx/modules/templates/config/config
Normal file
29
onyx/modules/templates/main.php
Normal file
29
onyx/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 !
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
1520
onyx/modules/templates/smarty/Smarty.class.php
Normal file
1520
onyx/modules/templates/smarty/Smarty.class.php
Normal file
File diff suppressed because it is too large
Load diff
460
onyx/modules/templates/smarty/SmartyBC.class.php
Normal file
460
onyx/modules/templates/smarty/SmartyBC.class.php
Normal file
|
|
@ -0,0 +1,460 @@
|
|||
<?php
|
||||
/**
|
||||
* Project: Smarty: the PHP compiling template engine
|
||||
* File: SmartyBC.class.php
|
||||
* SVN: $Id: $
|
||||
*
|
||||
* 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
|
||||
* @author Rodney Rehm
|
||||
* @package Smarty
|
||||
*/
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require(dirname(__FILE__) . '/Smarty.class.php');
|
||||
|
||||
/**
|
||||
* Smarty Backward Compatability Wrapper Class
|
||||
*
|
||||
* @package Smarty
|
||||
*/
|
||||
class SmartyBC extends Smarty {
|
||||
|
||||
/**
|
||||
* Smarty 2 BC
|
||||
* @var string
|
||||
*/
|
||||
public $_version = self::SMARTY_VERSION;
|
||||
|
||||
/**
|
||||
* Initialize new SmartyBC object
|
||||
*
|
||||
* @param array $options options to set during initialization, e.g. array( 'forceCompile' => false )
|
||||
*/
|
||||
public function __construct(array $options=array())
|
||||
{
|
||||
parent::__construct($options);
|
||||
// register {php} tag
|
||||
$this->registerPlugin('block', 'php', 'smarty_php_tag');
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for assign_by_ref
|
||||
*
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to assign
|
||||
*/
|
||||
public function assign_by_ref($tpl_var, &$value)
|
||||
{
|
||||
$this->assignByRef($tpl_var, $value);
|
||||
}
|
||||
|
||||
/**
|
||||
* wrapper for append_by_ref
|
||||
*
|
||||
* @param string $tpl_var the template variable name
|
||||
* @param mixed &$value the referenced value to append
|
||||
* @param boolean $merge flag if array elements shall be merged
|
||||
*/
|
||||
public function append_by_ref($tpl_var, &$value, $merge = false)
|
||||
{
|
||||
$this->appendByRef($tpl_var, $value, $merge);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the given assigned template variable.
|
||||
*
|
||||
* @param string $tpl_var the template variable to clear
|
||||
*/
|
||||
public function clear_assign($tpl_var)
|
||||
{
|
||||
$this->clearAssign($tpl_var);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers custom function to be used in templates
|
||||
*
|
||||
* @param string $function the name of the template function
|
||||
* @param string $function_impl the name of the PHP function to register
|
||||
* @param bool $cacheable
|
||||
* @param mixed $cache_attrs
|
||||
*/
|
||||
public function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null)
|
||||
{
|
||||
$this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters custom function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
*/
|
||||
public function unregister_function($function)
|
||||
{
|
||||
$this->unregisterPlugin('function', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers object to be used in templates
|
||||
*
|
||||
* @param string $object name of template object
|
||||
* @param object $object_impl the referenced PHP object to register
|
||||
* @param array $allowed list of allowed methods (empty = all)
|
||||
* @param boolean $smarty_args smarty argument format, else traditional
|
||||
* @param array $block_functs list of methods that are block format
|
||||
*/
|
||||
public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
|
||||
{
|
||||
settype($allowed, 'array');
|
||||
settype($smarty_args, 'boolean');
|
||||
$this->registerObject($object, $object_impl, $allowed, $smarty_args, $block_methods);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters object
|
||||
*
|
||||
* @param string $object name of template object
|
||||
*/
|
||||
public function unregister_object($object)
|
||||
{
|
||||
$this->unregisterObject($object);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers block function to be used in templates
|
||||
*
|
||||
* @param string $block name of template block
|
||||
* @param string $block_impl PHP function to register
|
||||
* @param bool $cacheable
|
||||
* @param mixed $cache_attrs
|
||||
*/
|
||||
public function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null)
|
||||
{
|
||||
$this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters block function
|
||||
*
|
||||
* @param string $block name of template function
|
||||
*/
|
||||
public function unregister_block($block)
|
||||
{
|
||||
$this->unregisterPlugin('block', $block);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers compiler function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
* @param string $function_impl name of PHP function to register
|
||||
* @param bool $cacheable
|
||||
*/
|
||||
public function register_compiler_function($function, $function_impl, $cacheable=true)
|
||||
{
|
||||
$this->registerPlugin('compiler', $function, $function_impl, $cacheable);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters compiler function
|
||||
*
|
||||
* @param string $function name of template function
|
||||
*/
|
||||
public function unregister_compiler_function($function)
|
||||
{
|
||||
$this->unregisterPlugin('compiler', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers modifier to be used in templates
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
* @param string $modifier_impl name of PHP function to register
|
||||
*/
|
||||
public function register_modifier($modifier, $modifier_impl)
|
||||
{
|
||||
$this->registerPlugin('modifier', $modifier, $modifier_impl);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters modifier
|
||||
*
|
||||
* @param string $modifier name of template modifier
|
||||
*/
|
||||
public function unregister_modifier($modifier)
|
||||
{
|
||||
$this->unregisterPlugin('modifier', $modifier);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a resource to fetch a template
|
||||
*
|
||||
* @param string $type name of resource
|
||||
* @param array $functions array of functions to handle resource
|
||||
*/
|
||||
public function register_resource($type, $functions)
|
||||
{
|
||||
$this->registerResource($type, $functions);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a resource
|
||||
*
|
||||
* @param string $type name of resource
|
||||
*/
|
||||
public function unregister_resource($type)
|
||||
{
|
||||
$this->unregisterResource($type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a prefilter function to apply
|
||||
* to a template before compiling
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function register_prefilter($function)
|
||||
{
|
||||
$this->registerFilter('pre', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a prefilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_prefilter($function)
|
||||
{
|
||||
$this->unregisterFilter('pre', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a postfilter function to apply
|
||||
* to a compiled template after compilation
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function register_postfilter($function)
|
||||
{
|
||||
$this->registerFilter('post', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters a postfilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_postfilter($function)
|
||||
{
|
||||
$this->unregisterFilter('post', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers an output filter function to apply
|
||||
* to a template output
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function register_outputfilter($function)
|
||||
{
|
||||
$this->registerFilter('output', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters an outputfilter function
|
||||
*
|
||||
* @param callable $function
|
||||
*/
|
||||
public function unregister_outputfilter($function)
|
||||
{
|
||||
$this->unregisterFilter('output', $function);
|
||||
}
|
||||
|
||||
/**
|
||||
* load a filter of specified type and name
|
||||
*
|
||||
* @param string $type filter type
|
||||
* @param string $name filter name
|
||||
*/
|
||||
public function load_filter($type, $name)
|
||||
{
|
||||
$this->loadFilter($type, $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear cached content for the given template and cache id
|
||||
*
|
||||
* @param string $tpl_file name of template file
|
||||
* @param string $cache_id name of cache_id
|
||||
* @param string $compile_id name of compile_id
|
||||
* @param string $exp_time expiration time
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
|
||||
{
|
||||
return $this->clearCache($tpl_file, $cache_id, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear the entire contents of cache (all templates)
|
||||
*
|
||||
* @param string $exp_time expire time
|
||||
* @return boolean
|
||||
*/
|
||||
public function clear_all_cache($exp_time = null)
|
||||
{
|
||||
return $this->clearCache(null, null, null, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* test to see if valid cache exists for this template
|
||||
*
|
||||
* @param string $tpl_file name of template file
|
||||
* @param string $cache_id
|
||||
* @param string $compile_id
|
||||
* @return boolean
|
||||
*/
|
||||
public function is_cached($tpl_file, $cache_id = null, $compile_id = null)
|
||||
{
|
||||
return $this->isCached($tpl_file, $cache_id, $compile_id);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear all the assigned template variables.
|
||||
*/
|
||||
public function clear_all_assign()
|
||||
{
|
||||
$this->clearAllAssign();
|
||||
}
|
||||
|
||||
/**
|
||||
* clears compiled version of specified template resource,
|
||||
* or all compiled template files if one is not specified.
|
||||
* This function is for advanced use only, not normally needed.
|
||||
*
|
||||
* @param string $tpl_file
|
||||
* @param string $compile_id
|
||||
* @param string $exp_time
|
||||
* @return boolean results of {@link smarty_core_rm_auto()}
|
||||
*/
|
||||
public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
|
||||
{
|
||||
return $this->clearCompiledTemplate($tpl_file, $compile_id, $exp_time);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether requested template exists.
|
||||
*
|
||||
* @param string $tpl_file
|
||||
* @return boolean
|
||||
*/
|
||||
public function template_exists($tpl_file)
|
||||
{
|
||||
return $this->templateExists($tpl_file);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing template variables
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function get_template_vars($name=null)
|
||||
{
|
||||
return $this->getTemplateVars($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array containing config variables
|
||||
*
|
||||
* @param string $name
|
||||
* @return array
|
||||
*/
|
||||
public function get_config_vars($name=null)
|
||||
{
|
||||
return $this->getConfigVars($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* load configuration values
|
||||
*
|
||||
* @param string $file
|
||||
* @param string $section
|
||||
* @param string $scope
|
||||
*/
|
||||
public function config_load($file, $section = null, $scope = 'global')
|
||||
{
|
||||
$this->ConfigLoad($file, $section, $scope);
|
||||
}
|
||||
|
||||
/**
|
||||
* return a reference to a registered object
|
||||
*
|
||||
* @param string $name
|
||||
* @return object
|
||||
*/
|
||||
public function get_registered_object($name)
|
||||
{
|
||||
return $this->getRegisteredObject($name);
|
||||
}
|
||||
|
||||
/**
|
||||
* clear configuration values
|
||||
*
|
||||
* @param string $var
|
||||
*/
|
||||
public function clear_config($var = null)
|
||||
{
|
||||
$this->clearConfig($var);
|
||||
}
|
||||
|
||||
/**
|
||||
* trigger Smarty error
|
||||
*
|
||||
* @param string $error_msg
|
||||
* @param integer $error_type
|
||||
*/
|
||||
public function trigger_error($error_msg, $error_type = E_USER_WARNING)
|
||||
{
|
||||
trigger_error("Smarty error: $error_msg", $error_type);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Smarty {php}{/php} block function
|
||||
*
|
||||
* @param array $params parameter list
|
||||
* @param string $content contents of the block
|
||||
* @param object $template template object
|
||||
* @param boolean &$repeat repeat flag
|
||||
* @return string content re-formatted
|
||||
*/
|
||||
function smarty_php_tag($params, $content, $template, &$repeat)
|
||||
{
|
||||
eval($content);
|
||||
return '';
|
||||
}
|
||||
|
||||
?>
|
||||
133
onyx/modules/templates/smarty/debug.tpl
Normal file
133
onyx/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 nofilter}{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 nofilter}</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 nofilter}</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' nofilter}");
|
||||
_smarty_console.document.close();
|
||||
</script>
|
||||
27
onyx/modules/templates/smarty/plugins/block.php.php
Normal file
27
onyx/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 '';
|
||||
}
|
||||
|
||||
?>
|
||||
113
onyx/modules/templates/smarty/plugins/block.textformat.php
Normal file
113
onyx/modules/templates/smarty/plugins/block.textformat.php
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
<?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>
|
||||
* Params:
|
||||
* <pre>
|
||||
* - style - string (email)
|
||||
* - indent - integer (0)
|
||||
* - wrap - integer (80)
|
||||
* - wrap_char - string ("\n")
|
||||
* - indent_char - string (" ")
|
||||
* - wrap_boundary - boolean (true)
|
||||
* </pre>
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
|
||||
* (Smarty online manual)
|
||||
* @param array $params parameters
|
||||
* @param string $content contents of the block
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
* @param boolean &$repeat repeat flag
|
||||
* @return string content re-formatted
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
*/
|
||||
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]{2}!', $content);
|
||||
$_output = '';
|
||||
|
||||
|
||||
foreach ($_paragraphs as &$_paragraph) {
|
||||
if (!$_paragraph) {
|
||||
continue;
|
||||
}
|
||||
// convert mult. spaces & special chars to single space
|
||||
$_paragraph = preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER, '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER), array(' ', ''), $_paragraph);
|
||||
// indent first line
|
||||
if ($indent_first > 0) {
|
||||
$_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph;
|
||||
}
|
||||
// wordwrap sentences
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php');
|
||||
$_paragraph = smarty_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
|
||||
} else {
|
||||
$_paragraph = wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
|
||||
}
|
||||
// indent lines
|
||||
if ($indent > 0) {
|
||||
$_paragraph = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraph);
|
||||
}
|
||||
}
|
||||
$_output = implode($wrap_char . $wrap_char, $_paragraphs);
|
||||
|
||||
if ($assign) {
|
||||
$template->assign($assign, $_output);
|
||||
} else {
|
||||
return $_output;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
78
onyx/modules/templates/smarty/plugins/function.counter.php
Normal file
78
onyx/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://www.smarty.net/manual/en/language.function.counter.php {counter}
|
||||
* (Smarty online manual)
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $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
onyx/modules/templates/smarty/plugins/function.cycle.php
Normal file
106
onyx/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>
|
||||
* Params:
|
||||
* <pre>
|
||||
* - 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.
|
||||
* </pre>
|
||||
* Examples:<br>
|
||||
* <pre>
|
||||
* {cycle values="#eeeeee,#d0d0d0d"}
|
||||
* {cycle name=row values="one,two,three" reset=true}
|
||||
* {cycle name=row}
|
||||
* </pre>
|
||||
*
|
||||
* @link http://www.smarty.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 $params parameters
|
||||
* @param Smarty_Internal_Template $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 (!isset($params['values'])) {
|
||||
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;
|
||||
}
|
||||
|
||||
?>
|
||||
214
onyx/modules/templates/smarty/plugins/function.fetch.php
Normal file
214
onyx/modules/templates/smarty/plugins/function.fetch.php
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
<?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://www.smarty.net/manual/en/language.function.fetch.php {fetch}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $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;
|
||||
}
|
||||
|
||||
// strip file protocol
|
||||
if (stripos($params['file'], 'file://') === 0) {
|
||||
$params['file'] = substr($params['file'], 7);
|
||||
}
|
||||
|
||||
$protocol = strpos($params['file'], '://');
|
||||
if ($protocol !== false) {
|
||||
$protocol = strtolower(substr($params['file'], 0, $protocol));
|
||||
}
|
||||
|
||||
if (isset($template->smarty->security_policy)) {
|
||||
if ($protocol) {
|
||||
// remote resource (or php stream, …)
|
||||
if(!$template->smarty->security_policy->isTrustedUri($params['file'])) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// local file
|
||||
if(!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$content = '';
|
||||
if ($protocol == 'http') {
|
||||
// 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 ". Smarty::SMARTY_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 {
|
||||
$content = @file_get_contents($params['file']);
|
||||
if ($content === false) {
|
||||
throw new SmartyException("{fetch} cannot read resource '" . $params['file'] ."'");
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$template->assign($params['assign'], $content);
|
||||
} else {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,216 @@
|
|||
<?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>
|
||||
* Params:
|
||||
* <pre>
|
||||
* - 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
|
||||
* - escape (optional) - escape the content (not value), defaults to true
|
||||
* </pre>
|
||||
*
|
||||
* @link http://www.smarty.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
|
||||
* @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 = array();
|
||||
$separator = '';
|
||||
$escape = true;
|
||||
$labels = true;
|
||||
$label_ids = false;
|
||||
$output = null;
|
||||
|
||||
$extra = '';
|
||||
|
||||
foreach($params as $_key => $_val) {
|
||||
switch($_key) {
|
||||
case 'name':
|
||||
case 'separator':
|
||||
$$_key = (string) $_val;
|
||||
break;
|
||||
|
||||
case 'escape':
|
||||
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 'checked':
|
||||
case 'selected':
|
||||
if (is_array($_val)) {
|
||||
$selected = array();
|
||||
foreach ($_val as $_sel) {
|
||||
if (is_object($_sel)) {
|
||||
if (method_exists($_sel, "__toString")) {
|
||||
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
|
||||
} else {
|
||||
trigger_error("html_checkboxes: selected attribute contains an object of class '". get_class($_sel) ."' without __toString() method", E_USER_NOTICE);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
$_sel = smarty_function_escape_special_chars((string) $_sel);
|
||||
}
|
||||
$selected[$_sel] = true;
|
||||
}
|
||||
} elseif (is_object($_val)) {
|
||||
if (method_exists($_val, "__toString")) {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||
} else {
|
||||
trigger_error("html_checkboxes: selected attribute is an object of class '". get_class($_val) ."' without __toString() method", E_USER_NOTICE);
|
||||
}
|
||||
} else {
|
||||
$selected = smarty_function_escape_special_chars((string) $_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? */
|
||||
|
||||
$_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, $label_ids, $escape);
|
||||
}
|
||||
} 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, $label_ids, $escape);
|
||||
}
|
||||
}
|
||||
|
||||
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, $label_ids, $escape=true) {
|
||||
$_output = '';
|
||||
|
||||
if (is_object($value)) {
|
||||
if (method_exists($value, "__toString")) {
|
||||
$value = (string) $value->__toString();
|
||||
} else {
|
||||
trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE);
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$value = (string) $value;
|
||||
}
|
||||
|
||||
if (is_object($output)) {
|
||||
if (method_exists($output, "__toString")) {
|
||||
$output = (string) $output->__toString();
|
||||
} else {
|
||||
trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE);
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$output = (string) $output;
|
||||
}
|
||||
|
||||
if ($labels) {
|
||||
if ($label_ids) {
|
||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value));
|
||||
$_output .= '<label for="' . $_id . '">';
|
||||
} else {
|
||||
$_output .= '<label>';
|
||||
}
|
||||
}
|
||||
|
||||
$name = smarty_function_escape_special_chars($name);
|
||||
$value = smarty_function_escape_special_chars($value);
|
||||
if ($escape) {
|
||||
$output = smarty_function_escape_special_chars($output);
|
||||
}
|
||||
|
||||
$_output .= '<input type="checkbox" name="' . $name . '[]" value="' . $value . '"';
|
||||
|
||||
if ($labels && $label_ids) {
|
||||
$_output .= ' id="' . $_id . '"';
|
||||
}
|
||||
|
||||
if (is_array($selected)) {
|
||||
if (isset($selected[$value])) {
|
||||
$_output .= ' checked="checked"';
|
||||
}
|
||||
} elseif ($value === $selected) {
|
||||
$_output .= ' checked="checked"';
|
||||
}
|
||||
|
||||
$_output .= $extra . ' />' . $output;
|
||||
if ($labels) {
|
||||
$_output .= '</label>';
|
||||
}
|
||||
|
||||
$_output .= $separator;
|
||||
return $_output;
|
||||
}
|
||||
|
||||
?>
|
||||
159
onyx/modules/templates/smarty/plugins/function.html_image.php
Normal file
159
onyx/modules/templates/smarty/plugins/function.html_image.php
Normal file
|
|
@ -0,0 +1,159 @@
|
|||
<?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"}<br>
|
||||
* Output: <img src="/images/masthead.gif" width=400 height=23><br>
|
||||
* Params:
|
||||
* <pre>
|
||||
* - file - (required) - file (and path) of image
|
||||
* - height - (optional) - image height (default actual height)
|
||||
* - width - (optional) - image width (default actual width)
|
||||
* - basedir - (optional) - base directory for absolute paths, default is environment variable DOCUMENT_ROOT
|
||||
* - path_prefix - prefix for path output (optional, default empty)
|
||||
* </pre>
|
||||
*
|
||||
* @link http://www.smarty.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
|
||||
* @param Smarty_Internal_Template $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 = '';
|
||||
$basedir = isset($_SERVER['DOCUMENT_ROOT']) ? $_SERVER['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 ($file[0] == '/') {
|
||||
$_image_path = $basedir . $file;
|
||||
} else {
|
||||
$_image_path = $file;
|
||||
}
|
||||
|
||||
// strip file protocol
|
||||
if (stripos($params['file'], 'file://') === 0) {
|
||||
$params['file'] = substr($params['file'], 7);
|
||||
}
|
||||
|
||||
$protocol = strpos($params['file'], '://');
|
||||
if ($protocol !== false) {
|
||||
$protocol = strtolower(substr($params['file'], 0, $protocol));
|
||||
}
|
||||
|
||||
if (isset($template->smarty->security_policy)) {
|
||||
if ($protocol) {
|
||||
// remote resource (or php stream, …)
|
||||
if(!$template->smarty->security_policy->isTrustedUri($params['file'])) {
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// local file
|
||||
if(!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($params['width']) || !isset($params['height'])) {
|
||||
// FIXME: (rodneyrehm) getimagesize() loads the complete file off a remote resource, use custom [jpg,png,gif]header reader!
|
||||
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($params['width'])) {
|
||||
$width = $_image_data[0];
|
||||
}
|
||||
if (!isset($params['height'])) {
|
||||
$height = $_image_data[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($params['dpi'])) {
|
||||
if (strstr($_SERVER['HTTP_USER_AGENT'], 'Mac')) {
|
||||
// FIXME: (rodneyrehm) wrong dpi assumption
|
||||
// don't know who thought this up… even if it was true in 1998, it's definitely wrong in 2011.
|
||||
$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;
|
||||
}
|
||||
|
||||
?>
|
||||
176
onyx/modules/templates/smarty/plugins/function.html_options.php
Normal file
176
onyx/modules/templates/smarty/plugins/function.html_options.php
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
<?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<br>
|
||||
* Params:
|
||||
* <pre>
|
||||
* - 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
|
||||
* - id (optional) - string default not set
|
||||
* - class (optional) - string default not set
|
||||
* </pre>
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.options.php {html_image}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de>
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $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 = null;
|
||||
$output = null;
|
||||
$id = null;
|
||||
$class = null;
|
||||
|
||||
$extra = '';
|
||||
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'name':
|
||||
case 'class':
|
||||
case 'id':
|
||||
$$_key = (string) $_val;
|
||||
break;
|
||||
|
||||
case 'options':
|
||||
$options = (array) $_val;
|
||||
break;
|
||||
|
||||
case 'values':
|
||||
case 'output':
|
||||
$$_key = array_values((array) $_val);
|
||||
break;
|
||||
|
||||
case 'selected':
|
||||
if (is_array($_val)) {
|
||||
$selected = array();
|
||||
foreach ($_val as $_sel) {
|
||||
if (is_object($_sel)) {
|
||||
if (method_exists($_sel, "__toString")) {
|
||||
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
|
||||
} else {
|
||||
trigger_error("html_options: selected attribute contains an object of class '". get_class($_sel) ."' without __toString() method", E_USER_NOTICE);
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
$_sel = smarty_function_escape_special_chars((string) $_sel);
|
||||
}
|
||||
$selected[$_sel] = true;
|
||||
}
|
||||
} elseif (is_object($_val)) {
|
||||
if (method_exists($_val, "__toString")) {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||
} else {
|
||||
trigger_error("html_options: selected attribute is an object of class '". get_class($_val) ."' without __toString() method", E_USER_NOTICE);
|
||||
}
|
||||
} else {
|
||||
$selected = smarty_function_escape_special_chars((string) $_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)) {
|
||||
/* raise error here? */
|
||||
return '';
|
||||
}
|
||||
|
||||
$_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)) {
|
||||
$_key = smarty_function_escape_special_chars($key);
|
||||
$_html_result = '<option value="' . $_key . '"';
|
||||
if (is_array($selected)) {
|
||||
if (isset($selected[$_key])) {
|
||||
$_html_result .= ' selected="selected"';
|
||||
}
|
||||
} elseif ($_key === $selected) {
|
||||
$_html_result .= ' selected="selected"';
|
||||
}
|
||||
$_html_class = !empty($class) ? ' class="'.$class.' option"' : '';
|
||||
$_html_id = !empty($id) ? ' id="'.$id.'-'.$idx.'"' : '';
|
||||
if (is_object($value)) {
|
||||
if (method_exists($value, "__toString")) {
|
||||
$value = smarty_function_escape_special_chars((string) $value->__toString());
|
||||
} else {
|
||||
trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE);
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$value = smarty_function_escape_special_chars((string) $value);
|
||||
}
|
||||
$_html_result .= $_html_class . $_html_id . '>' . $value . '</option>' . "\n";
|
||||
$idx++;
|
||||
} else {
|
||||
$_idx = 0;
|
||||
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id.'-'.$idx) : null, $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;
|
||||
}
|
||||
|
||||
?>
|
||||
200
onyx/modules/templates/smarty/plugins/function.html_radios.php
Normal file
200
onyx/modules/templates/smarty/plugins/function.html_radios.php
Normal file
|
|
@ -0,0 +1,200 @@
|
|||
<?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>
|
||||
* Params:
|
||||
* <pre>
|
||||
* - name (optional) - string default "radio"
|
||||
* - values (required) - array
|
||||
* - options (required) - 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
|
||||
* - escape (optional) - escape the content (not value), defaults to true
|
||||
* </pre>
|
||||
* 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
|
||||
* @param Smarty_Internal_Template $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 = '';
|
||||
$escape = true;
|
||||
$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);
|
||||
} elseif (is_object($_val)) {
|
||||
if (method_exists($_val, "__toString")) {
|
||||
$selected = smarty_function_escape_special_chars((string) $_val->__toString());
|
||||
} else {
|
||||
trigger_error("html_radios: selected attribute is an object of class '". get_class($_val) ."' without __toString() method", E_USER_NOTICE);
|
||||
}
|
||||
} else {
|
||||
$selected = (string) $_val;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'escape':
|
||||
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)) {
|
||||
/* raise error here? */
|
||||
return '';
|
||||
}
|
||||
|
||||
$_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, $escape);
|
||||
}
|
||||
} 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, $escape);
|
||||
}
|
||||
}
|
||||
|
||||
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, $escape)
|
||||
{
|
||||
$_output = '';
|
||||
|
||||
if (is_object($value)) {
|
||||
if (method_exists($value, "__toString")) {
|
||||
$value = (string) $value->__toString();
|
||||
} else {
|
||||
trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE);
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$value = (string) $value;
|
||||
}
|
||||
|
||||
if (is_object($output)) {
|
||||
if (method_exists($output, "__toString")) {
|
||||
$output = (string) $output->__toString();
|
||||
} else {
|
||||
trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE);
|
||||
return '';
|
||||
}
|
||||
} else {
|
||||
$output = (string) $output;
|
||||
}
|
||||
|
||||
if ($labels) {
|
||||
if ($label_ids) {
|
||||
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value));
|
||||
$_output .= '<label for="' . $_id . '">';
|
||||
} else {
|
||||
$_output .= '<label>';
|
||||
}
|
||||
}
|
||||
|
||||
$name = smarty_function_escape_special_chars($name);
|
||||
$value = smarty_function_escape_special_chars($value);
|
||||
if ($escape) {
|
||||
$output = smarty_function_escape_special_chars($output);
|
||||
}
|
||||
|
||||
$_output .= '<input type="radio" name="' . $name . '" value="' . $value . '"';
|
||||
|
||||
if ($labels && $label_ids) {
|
||||
$_output .= ' id="' . $_id . '"';
|
||||
}
|
||||
|
||||
if ($value === $selected) {
|
||||
$_output .= ' checked="checked"';
|
||||
}
|
||||
|
||||
$_output .= $extra . ' />' . $output;
|
||||
if ($labels) {
|
||||
$_output .= '</label>';
|
||||
}
|
||||
|
||||
$_output .= $separator;
|
||||
return $_output;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,394 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
|
||||
/**
|
||||
* Smarty {html_select_date} plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: html_select_date<br>
|
||||
* Purpose: Prints the dropdowns for date selection.
|
||||
*
|
||||
* ChangeLog:
|
||||
* <pre>
|
||||
* - 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)
|
||||
* - 2.0 complete rewrite for performance,
|
||||
* added attributes month_names, *_id
|
||||
* </pre>
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
|
||||
* (Smarty online manual)
|
||||
* @version 2.0
|
||||
* @author Andrei Zmievski
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Rodney Rehm
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_html_select_date($params, $template)
|
||||
{
|
||||
// generate timestamps used for month names only
|
||||
static $_month_timestamps = null;
|
||||
static $_current_year = null;
|
||||
if ($_month_timestamps === null) {
|
||||
$_current_year = date('Y');
|
||||
$_month_timestamps = array();
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$_month_timestamps[$i] = mktime(0, 0, 0, $i, 1, 2000);
|
||||
}
|
||||
}
|
||||
|
||||
/* Default values. */
|
||||
$prefix = "Date_";
|
||||
$start_year = null;
|
||||
$end_year = null;
|
||||
$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";
|
||||
$option_separator = "\n";
|
||||
$time = null;
|
||||
// $all_empty = null;
|
||||
// $day_empty = null;
|
||||
// $month_empty = null;
|
||||
// $year_empty = null;
|
||||
$extra_attrs = '';
|
||||
$all_id = null;
|
||||
$day_id = null;
|
||||
$month_id = null;
|
||||
$year_id = null;
|
||||
|
||||
foreach ($params as $_key => $_value) {
|
||||
switch ($_key) {
|
||||
case 'time':
|
||||
if (!is_array($_value) && $_value !== null) {
|
||||
$time = smarty_make_timestamp($_value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'month_names':
|
||||
if (is_array($_value) && count($_value) == 12) {
|
||||
$$_key = $_value;
|
||||
} else {
|
||||
trigger_error("html_select_date: month_names must be an array of 12 strings", E_USER_NOTICE);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'prefix':
|
||||
case 'field_array':
|
||||
case 'start_year':
|
||||
case 'end_year':
|
||||
case 'day_format':
|
||||
case 'day_value_format':
|
||||
case 'month_format':
|
||||
case 'month_value_format':
|
||||
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 'option_separator':
|
||||
case 'all_empty':
|
||||
case 'month_empty':
|
||||
case 'day_empty':
|
||||
case 'year_empty':
|
||||
case 'all_id':
|
||||
case 'month_id':
|
||||
case 'day_id':
|
||||
case 'year_id':
|
||||
$$_key = (string)$_value;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
// Note: date() is faster than strftime()
|
||||
// Note: explode(date()) is faster than date() date() date()
|
||||
if (isset($params['time']) && is_array($params['time'])) {
|
||||
if (isset($params['time'][$prefix . 'Year'])) {
|
||||
// $_REQUEST[$field_array] given
|
||||
foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName = isset($params['time'][$prefix . $_elementName])
|
||||
? $params['time'][$prefix . $_elementName]
|
||||
: date($_elementKey);
|
||||
}
|
||||
$time = mktime(0, 0, 0, $_month, $_day, $_year);
|
||||
} elseif (isset($params['time'][$field_array][$prefix . 'Year'])) {
|
||||
// $_REQUEST given
|
||||
foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName = isset($params['time'][$field_array][$prefix . $_elementName])
|
||||
? $params['time'][$field_array][$prefix . $_elementName]
|
||||
: date($_elementKey);
|
||||
}
|
||||
$time = mktime(0, 0, 0, $_month, $_day, $_year);
|
||||
} else {
|
||||
// no date found, use NOW
|
||||
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d'));
|
||||
}
|
||||
} elseif ($time === null) {
|
||||
if (array_key_exists('time', $params)) {
|
||||
$_year = $_month = $_day = $time = null;
|
||||
} else {
|
||||
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d'));
|
||||
}
|
||||
} else {
|
||||
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d', $time));
|
||||
}
|
||||
|
||||
// make syntax "+N" or "-N" work with $start_year and $end_year
|
||||
// Note preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match) is slower than trim+substr
|
||||
foreach (array('start', 'end') as $key) {
|
||||
$key .= '_year';
|
||||
$t = $$key;
|
||||
if ($t === null) {
|
||||
$$key = (int)$_current_year;
|
||||
} else if ($t[0] == '+') {
|
||||
$$key = (int)($_current_year + trim(substr($t, 1)));
|
||||
} else if ($t[0] == '-') {
|
||||
$$key = (int)($_current_year - trim(substr($t, 1)));
|
||||
} else {
|
||||
$$key = (int)$$key;
|
||||
}
|
||||
}
|
||||
|
||||
// flip for ascending or descending
|
||||
if (($start_year > $end_year && !$reverse_years) || ($start_year < $end_year && $reverse_years)) {
|
||||
$t = $end_year;
|
||||
$end_year = $start_year;
|
||||
$start_year = $t;
|
||||
}
|
||||
|
||||
// generate year <select> or <input>
|
||||
if ($display_years) {
|
||||
$_html_years = '';
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Year]') : ($prefix . 'Year');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
if ($year_extra) {
|
||||
$_extra .= ' ' . $year_extra;
|
||||
}
|
||||
|
||||
if ($year_as_text) {
|
||||
$_html_years = '<input type="text" name="' . $_name . '" value="' . $_year . '" size="4" maxlength="4"' . $_extra . $extra_attrs . ' />';
|
||||
} else {
|
||||
$_html_years = '<select name="' . $_name . '"';
|
||||
if ($year_id !== null || $all_id !== null) {
|
||||
$_html_years .= ' id="' . smarty_function_escape_special_chars(
|
||||
$year_id !== null ? ( $year_id ? $year_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
|
||||
) . '"';
|
||||
}
|
||||
if ($year_size) {
|
||||
$_html_years .= ' size="' . $year_size . '"';
|
||||
}
|
||||
$_html_years .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($year_empty) || isset($all_empty)) {
|
||||
$_html_years .= '<option value="">' . ( isset($year_empty) ? $year_empty : $all_empty ) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$op = $start_year > $end_year ? -1 : 1;
|
||||
for ($i=$start_year; $op > 0 ? $i <= $end_year : $i >= $end_year; $i += $op) {
|
||||
$_html_years .= '<option value="' . $i . '"'
|
||||
. ($_year == $i ? ' selected="selected"' : '')
|
||||
. '>' . $i . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$_html_years .= '</select>';
|
||||
}
|
||||
}
|
||||
|
||||
// generate month <select> or <input>
|
||||
if ($display_months) {
|
||||
$_html_month = '';
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Month]') : ($prefix . 'Month');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
if ($month_extra) {
|
||||
$_extra .= ' ' . $month_extra;
|
||||
}
|
||||
|
||||
$_html_months = '<select name="' . $_name . '"';
|
||||
if ($month_id !== null || $all_id !== null) {
|
||||
$_html_months .= ' id="' . smarty_function_escape_special_chars(
|
||||
$month_id !== null ? ( $month_id ? $month_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
|
||||
) . '"';
|
||||
}
|
||||
if ($month_size) {
|
||||
$_html_months .= ' size="' . $month_size . '"';
|
||||
}
|
||||
$_html_months .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($month_empty) || isset($all_empty)) {
|
||||
$_html_months .= '<option value="">' . ( isset($month_empty) ? $month_empty : $all_empty ) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= 12; $i++) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[$i]) : ($month_format == "%m" ? $_val : strftime($month_format, $_month_timestamps[$i]));
|
||||
$_value = $month_value_format == "%m" ? $_val : strftime($month_value_format, $_month_timestamps[$i]);
|
||||
$_html_months .= '<option value="' . $_value . '"'
|
||||
. ($_val == $_month ? ' selected="selected"' : '')
|
||||
. '>' . $_text . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$_html_months .= '</select>';
|
||||
}
|
||||
|
||||
// generate day <select> or <input>
|
||||
if ($display_days) {
|
||||
$_html_day = '';
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Day]') : ($prefix . 'Day');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
if ($day_extra) {
|
||||
$_extra .= ' ' . $day_extra;
|
||||
}
|
||||
|
||||
$_html_days = '<select name="' . $_name . '"';
|
||||
if ($day_id !== null || $all_id !== null) {
|
||||
$_html_days .= ' id="' . smarty_function_escape_special_chars(
|
||||
$day_id !== null ? ( $day_id ? $day_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
|
||||
) . '"';
|
||||
}
|
||||
if ($day_size) {
|
||||
$_html_days .= ' size="' . $day_size . '"';
|
||||
}
|
||||
$_html_days .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($day_empty) || isset($all_empty)) {
|
||||
$_html_days .= '<option value="">' . ( isset($day_empty) ? $day_empty : $all_empty ) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
for ($i = 1; $i <= 31; $i++) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $day_format == '%02d' ? $_val : sprintf($day_format, $i);
|
||||
$_value = $day_value_format == '%02d' ? $_val : sprintf($day_value_format, $i);
|
||||
$_html_days .= '<option value="' . $_value . '"'
|
||||
. ($_val == $_day ? ' selected="selected"' : '')
|
||||
. '>' . $_text . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$_html_days .= '</select>';
|
||||
}
|
||||
|
||||
// order the fields for output
|
||||
$_html = '';
|
||||
for ($i=0; $i <= 2; $i++) {
|
||||
switch ($field_order[$i]) {
|
||||
case 'Y':
|
||||
case 'y':
|
||||
if (isset($_html_years)) {
|
||||
if ($_html) {
|
||||
$_html .= $field_separator;
|
||||
}
|
||||
$_html .= $_html_years;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'm':
|
||||
case 'M':
|
||||
if (isset($_html_months)) {
|
||||
if ($_html) {
|
||||
$_html .= $field_separator;
|
||||
}
|
||||
$_html .= $_html_months;
|
||||
}
|
||||
break;
|
||||
|
||||
case 'd':
|
||||
case 'D':
|
||||
if (isset($_html_days)) {
|
||||
if ($_html) {
|
||||
$_html .= $field_separator;
|
||||
}
|
||||
$_html .= $_html_days;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $_html;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,366 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsFunction
|
||||
*/
|
||||
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
|
||||
/**
|
||||
* @ignore
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
|
||||
/**
|
||||
* Smarty {html_select_time} function plugin
|
||||
*
|
||||
* Type: function<br>
|
||||
* Name: html_select_time<br>
|
||||
* Purpose: Prints the dropdowns for time selection
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
|
||||
* (Smarty online manual)
|
||||
* @author Roberto Berto <roberto@berto.net>
|
||||
* @author Monte Ohrt <monte AT ohrt DOT com>
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
* @return string
|
||||
* @uses smarty_make_timestamp()
|
||||
*/
|
||||
function smarty_function_html_select_time($params, $template)
|
||||
{
|
||||
$prefix = "Time_";
|
||||
$field_array = null;
|
||||
$field_separator = "\n";
|
||||
$option_separator = "\n";
|
||||
$time = null;
|
||||
|
||||
$display_hours = true;
|
||||
$display_minutes = true;
|
||||
$display_seconds = true;
|
||||
$display_meridian = true;
|
||||
|
||||
$hour_format = '%02d';
|
||||
$hour_value_format = '%02d';
|
||||
$minute_format = '%02d';
|
||||
$minute_value_format = '%02d';
|
||||
$second_format = '%02d';
|
||||
$second_value_format = '%02d';
|
||||
|
||||
$hour_size = null;
|
||||
$minute_size = null;
|
||||
$second_size = null;
|
||||
$meridian_size = null;
|
||||
|
||||
$all_empty = null;
|
||||
$hour_empty = null;
|
||||
$minute_empty = null;
|
||||
$second_empty = null;
|
||||
$meridian_empty = null;
|
||||
|
||||
$all_id = null;
|
||||
$hour_id = null;
|
||||
$minute_id = null;
|
||||
$second_id = null;
|
||||
$meridian_id = null;
|
||||
|
||||
$use_24_hours = true;
|
||||
$minute_interval = 1;
|
||||
$second_interval = 1;
|
||||
|
||||
$extra_attrs = '';
|
||||
$all_extra = null;
|
||||
$hour_extra = null;
|
||||
$minute_extra = null;
|
||||
$second_extra = null;
|
||||
$meridian_extra = null;
|
||||
|
||||
foreach ($params as $_key => $_value) {
|
||||
switch ($_key) {
|
||||
case 'time':
|
||||
if (!is_array($_value) && $_value !== null) {
|
||||
$time = smarty_make_timestamp($_value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'prefix':
|
||||
case 'field_array':
|
||||
|
||||
case 'field_separator':
|
||||
case 'option_separator':
|
||||
|
||||
case 'all_extra':
|
||||
case 'hour_extra':
|
||||
case 'minute_extra':
|
||||
case 'second_extra':
|
||||
case 'meridian_extra':
|
||||
|
||||
case 'all_empty':
|
||||
case 'hour_empty':
|
||||
case 'minute_empty':
|
||||
case 'second_empty':
|
||||
case 'meridian_empty':
|
||||
|
||||
case 'all_id':
|
||||
case 'hour_id':
|
||||
case 'minute_id':
|
||||
case 'second_id':
|
||||
case 'meridian_id':
|
||||
|
||||
case 'hour_format':
|
||||
case 'hour_value_format':
|
||||
case 'minute_format':
|
||||
case 'minute_value_format':
|
||||
case 'second_format':
|
||||
case 'second_value_format':
|
||||
$$_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':
|
||||
|
||||
case 'hour_size':
|
||||
case 'minute_size':
|
||||
case 'second_size':
|
||||
case 'meridian_size':
|
||||
$$_key = (int)$_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 (isset($params['time']) && is_array($params['time'])) {
|
||||
if (isset($params['time'][$prefix . 'Hour'])) {
|
||||
// $_REQUEST[$field_array] given
|
||||
foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName = isset($params['time'][$prefix . $_elementName])
|
||||
? $params['time'][$prefix . $_elementName]
|
||||
: date($_elementKey);
|
||||
}
|
||||
$_meridian = isset($params['time'][$prefix . 'Meridian'])
|
||||
? (' ' . $params['time'][$prefix . 'Meridian'])
|
||||
: '';
|
||||
$time = strtotime( $_hour . ':' . $_minute . ':' . $_second . $_meridian );
|
||||
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
|
||||
} elseif (isset($params['time'][$field_array][$prefix . 'Hour'])) {
|
||||
// $_REQUEST given
|
||||
foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) {
|
||||
$_variableName = '_' . strtolower($_elementName);
|
||||
$$_variableName = isset($params['time'][$field_array][$prefix . $_elementName])
|
||||
? $params['time'][$field_array][$prefix . $_elementName]
|
||||
: date($_elementKey);
|
||||
}
|
||||
$_meridian = isset($params['time'][$field_array][$prefix . 'Meridian'])
|
||||
? (' ' . $params['time'][$field_array][$prefix . 'Meridian'])
|
||||
: '';
|
||||
$time = strtotime( $_hour . ':' . $_minute . ':' . $_second . $_meridian );
|
||||
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
|
||||
} else {
|
||||
// no date found, use NOW
|
||||
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d'));
|
||||
}
|
||||
} elseif ($time === null) {
|
||||
if (array_key_exists('time', $params)) {
|
||||
$_hour = $_minute = $_second = $time = null;
|
||||
} else {
|
||||
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s'));
|
||||
}
|
||||
} else {
|
||||
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
|
||||
}
|
||||
|
||||
// generate hour <select>
|
||||
if ($display_hours) {
|
||||
$_html_hours = '';
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Hour]') : ($prefix . 'Hour');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
if ($hour_extra) {
|
||||
$_extra .= ' ' . $hour_extra;
|
||||
}
|
||||
|
||||
$_html_hours = '<select name="' . $_name . '"';
|
||||
if ($hour_id !== null || $all_id !== null) {
|
||||
$_html_hours .= ' id="' . smarty_function_escape_special_chars(
|
||||
$hour_id !== null ? ( $hour_id ? $hour_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
|
||||
) . '"';
|
||||
}
|
||||
if ($hour_size) {
|
||||
$_html_hours .= ' size="' . $hour_size . '"';
|
||||
}
|
||||
$_html_hours .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($hour_empty) || isset($all_empty)) {
|
||||
$_html_hours .= '<option value="">' . ( isset($hour_empty) ? $hour_empty : $all_empty ) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$start = $use_24_hours ? 0 : 1;
|
||||
$end = $use_24_hours ? 23 : 12;
|
||||
for ($i=$start; $i <= $end; $i++) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $hour_format == '%02d' ? $_val : sprintf($hour_format, $i);
|
||||
$_value = $hour_value_format == '%02d' ? $_val : sprintf($hour_value_format, $i);
|
||||
|
||||
if (!$use_24_hours) {
|
||||
$_hour12 = $_hour == 0
|
||||
? 12
|
||||
: ($_hour <= 12 ? $_hour : $_hour -12);
|
||||
}
|
||||
|
||||
$selected = $_hour !== null ? ($use_24_hours ? $_hour == $_val : $_hour12 == $_val) : null;
|
||||
$_html_hours .= '<option value="' . $_value . '"'
|
||||
. ($selected ? ' selected="selected"' : '')
|
||||
. '>' . $_text . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$_html_hours .= '</select>';
|
||||
}
|
||||
|
||||
// generate minute <select>
|
||||
if ($display_minutes) {
|
||||
$_html_minutes = '';
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Minute]') : ($prefix . 'Minute');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
if ($minute_extra) {
|
||||
$_extra .= ' ' . $minute_extra;
|
||||
}
|
||||
|
||||
$_html_minutes = '<select name="' . $_name . '"';
|
||||
if ($minute_id !== null || $all_id !== null) {
|
||||
$_html_minutes .= ' id="' . smarty_function_escape_special_chars(
|
||||
$minute_id !== null ? ( $minute_id ? $minute_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
|
||||
) . '"';
|
||||
}
|
||||
if ($minute_size) {
|
||||
$_html_minutes .= ' size="' . $minute_size . '"';
|
||||
}
|
||||
$_html_minutes .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($minute_empty) || isset($all_empty)) {
|
||||
$_html_minutes .= '<option value="">' . ( isset($minute_empty) ? $minute_empty : $all_empty ) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null;
|
||||
for ($i=0; $i <= 59; $i += $minute_interval) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $minute_format == '%02d' ? $_val : sprintf($minute_format, $i);
|
||||
$_value = $minute_value_format == '%02d' ? $_val : sprintf($minute_value_format, $i);
|
||||
$_html_minutes .= '<option value="' . $_value . '"'
|
||||
. ($selected === $i ? ' selected="selected"' : '')
|
||||
. '>' . $_text . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$_html_minutes .= '</select>';
|
||||
}
|
||||
|
||||
// generate second <select>
|
||||
if ($display_seconds) {
|
||||
$_html_seconds = '';
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Second]') : ($prefix . 'Second');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
if ($second_extra) {
|
||||
$_extra .= ' ' . $second_extra;
|
||||
}
|
||||
|
||||
$_html_seconds = '<select name="' . $_name . '"';
|
||||
if ($second_id !== null || $all_id !== null) {
|
||||
$_html_seconds .= ' id="' . smarty_function_escape_special_chars(
|
||||
$second_id !== null ? ( $second_id ? $second_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
|
||||
) . '"';
|
||||
}
|
||||
if ($second_size) {
|
||||
$_html_seconds .= ' size="' . $second_size . '"';
|
||||
}
|
||||
$_html_seconds .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($second_empty) || isset($all_empty)) {
|
||||
$_html_seconds .= '<option value="">' . ( isset($second_empty) ? $second_empty : $all_empty ) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$selected = $_second !== null ? ($_second - $_second % $second_interval) : null;
|
||||
for ($i=0; $i <= 59; $i += $second_interval) {
|
||||
$_val = sprintf('%02d', $i);
|
||||
$_text = $second_format == '%02d' ? $_val : sprintf($second_format, $i);
|
||||
$_value = $second_value_format == '%02d' ? $_val : sprintf($second_value_format, $i);
|
||||
$_html_seconds .= '<option value="' . $_value . '"'
|
||||
. ($selected === $i ? ' selected="selected"' : '')
|
||||
. '>' . $_text . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$_html_seconds .= '</select>';
|
||||
}
|
||||
|
||||
// generate meridian <select>
|
||||
if ($display_meridian && !$use_24_hours) {
|
||||
$_html_meridian = '';
|
||||
$_extra = '';
|
||||
$_name = $field_array ? ($field_array . '[' . $prefix . 'Meridian]') : ($prefix . 'Meridian');
|
||||
if ($all_extra) {
|
||||
$_extra .= ' ' . $all_extra;
|
||||
}
|
||||
if ($meridian_extra) {
|
||||
$_extra .= ' ' . $meridian_extra;
|
||||
}
|
||||
|
||||
$_html_meridian = '<select name="' . $_name . '"';
|
||||
if ($meridian_id !== null || $all_id !== null) {
|
||||
$_html_meridian .= ' id="' . smarty_function_escape_special_chars(
|
||||
$meridian_id !== null ? ( $meridian_id ? $meridian_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name )
|
||||
) . '"';
|
||||
}
|
||||
if ($meridian_size) {
|
||||
$_html_meridian .= ' size="' . $meridian_size . '"';
|
||||
}
|
||||
$_html_meridian .= $_extra . $extra_attrs . '>' . $option_separator;
|
||||
|
||||
if (isset($meridian_empty) || isset($all_empty)) {
|
||||
$_html_meridian .= '<option value="">' . ( isset($meridian_empty) ? $meridian_empty : $all_empty ) . '</option>' . $option_separator;
|
||||
}
|
||||
|
||||
$_html_meridian .= '<option value="am"'. ($_hour < 12 ? ' selected="selected"' : '') .'>AM</option>' . $option_separator
|
||||
. '<option value="pm"'. ($_hour < 12 ? '' : ' selected="selected"') .'>PM</option>' . $option_separator
|
||||
. '</select>';
|
||||
}
|
||||
|
||||
$_html = '';
|
||||
foreach (array('_html_hours', '_html_minutes', '_html_seconds', '_html_meridian') as $k) {
|
||||
if (isset($$k)) {
|
||||
if ($_html) {
|
||||
$_html .= $field_separator;
|
||||
}
|
||||
$_html .= $$k;
|
||||
}
|
||||
}
|
||||
|
||||
return $_html;
|
||||
}
|
||||
|
||||
?>
|
||||
177
onyx/modules/templates/smarty/plugins/function.html_table.php
Normal file
177
onyx/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>
|
||||
* Params:
|
||||
* <pre>
|
||||
* - 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)
|
||||
* </pre>
|
||||
* 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://www.smarty.net/manual/en/language.function.html.table.php {html_table}
|
||||
* (Smarty online manual)
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $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 : '';
|
||||
}
|
||||
|
||||
?>
|
||||
152
onyx/modules/templates/smarty/plugins/function.mailto.php
Normal file
152
onyx/modules/templates/smarty/plugins/function.mailto.php
Normal file
|
|
@ -0,0 +1,152 @@
|
|||
<?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>
|
||||
* Params:
|
||||
* <pre>
|
||||
* - address - (required) - 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
|
||||
* </pre>
|
||||
* 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://www.smarty.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
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
* @return string
|
||||
*/
|
||||
function smarty_function_mailto($params, $template)
|
||||
{
|
||||
static $_allowed_encoding = array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true);
|
||||
$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:
|
||||
}
|
||||
}
|
||||
|
||||
if ($mail_parms) {
|
||||
$address .= '?' . join('&', $mail_parms);
|
||||
}
|
||||
|
||||
$encode = (empty($params['encode'])) ? 'none' : $params['encode'];
|
||||
if (!isset($_allowed_encoding[$encode])) {
|
||||
trigger_error("mailto: 'encode' parameter must be none, javascript, javascript_charcode or hex", E_USER_WARNING);
|
||||
return;
|
||||
}
|
||||
// FIXME: (rodneyrehm) document.write() excues me what? 1998 has passed!
|
||||
if ($encode == 'javascript') {
|
||||
$string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');';
|
||||
|
||||
$js_encode = '';
|
||||
for ($x = 0, $_length = strlen($string); $x < $_length; $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"
|
||||
. "{document.write(String.fromCharCode("
|
||||
. implode(',', $ord)
|
||||
. "))"
|
||||
. "}\n"
|
||||
. "</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, $_length = strlen($address); $x < $_length; $x++) {
|
||||
if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[$x])) {
|
||||
$address_encode .= '%' . bin2hex($address[$x]);
|
||||
} else {
|
||||
$address_encode .= $address[$x];
|
||||
}
|
||||
}
|
||||
$text_encode = '';
|
||||
for ($x = 0, $_length = strlen($text); $x < $_length; $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>';
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
87
onyx/modules/templates/smarty/plugins/function.math.php
Normal file
87
onyx/modules/templates/smarty/plugins/function.math.php
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<?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
|
||||
*
|
||||
* @link http://www.smarty.net/manual/en/language.function.math.php {math}
|
||||
* (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param array $params parameters
|
||||
* @param Smarty_Internal_Template $template template object
|
||||
* @return string|null
|
||||
*/
|
||||
function smarty_function_math($params, $template)
|
||||
{
|
||||
static $_allowed_funcs = array(
|
||||
'int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true,
|
||||
'log' => true, 'log10' => true, 'max' => true, 'min' => true, 'pi' => true, 'pow' => true,
|
||||
'rand' => true, 'round' => true, 'sin' => true, 'sqrt' => true, 'srand' => true ,'tan' => true
|
||||
);
|
||||
// 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);
|
||||
|
||||
foreach($match[1] as $curr_var) {
|
||||
if ($curr_var && !isset($params[$curr_var]) && !isset($_allowed_funcs[$curr_var])) {
|
||||
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
onyx/modules/templates/smarty/plugins/function.popup.php
Normal file
118
onyx/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
onyx/modules/templates/smarty/plugins/function.text.php
Normal file
33
onyx/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,65 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty capitalize modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: capitalize<br>
|
||||
* Purpose: capitalize words in the string
|
||||
*
|
||||
* {@internal {$string|capitalize:true:true} is the fastest option for MBString enabled systems }}
|
||||
*
|
||||
* @param string $string string to capitalize
|
||||
* @param boolean $uc_digits also capitalize "x123" to "X123"
|
||||
* @param boolean $lc_rest capitalize first letters, lowercase all following letters "aAa" to "Aaa"
|
||||
* @return string capitalized string
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Rodney Rehm
|
||||
*/
|
||||
function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = false)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if ($lc_rest) {
|
||||
// uppercase (including hyphenated words)
|
||||
$upper_string = mb_convert_case( $string, MB_CASE_TITLE, Smarty::$_CHARSET );
|
||||
} else {
|
||||
// uppercase word breaks
|
||||
$upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!eS" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').mb_convert_case(stripslashes('\\2'),MB_CASE_UPPER, '" . addslashes(Smarty::$_CHARSET) . "')", $string);
|
||||
}
|
||||
// check uc_digits case
|
||||
if (!$uc_digits) {
|
||||
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) {
|
||||
foreach($matches[1] as $match) {
|
||||
$upper_string = substr_replace($upper_string, mb_strtolower($match[0], Smarty::$_CHARSET), $match[1], strlen($match[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
$upper_string = preg_replace("!((^|\s)['\"])(\w)!e" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').mb_convert_case(stripslashes('\\3'),MB_CASE_UPPER, '" . addslashes(Smarty::$_CHARSET) . "')", $upper_string);
|
||||
return $upper_string;
|
||||
}
|
||||
|
||||
// lowercase first
|
||||
if ($lc_rest) {
|
||||
$string = strtolower($string);
|
||||
}
|
||||
// uppercase (including hyphenated words)
|
||||
$upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!eS" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').ucfirst(stripslashes('\\2'))", $string);
|
||||
// check uc_digits case
|
||||
if (!$uc_digits) {
|
||||
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) {
|
||||
foreach($matches[1] as $match) {
|
||||
$upper_string = substr_replace($upper_string, strtolower($match[0]), $match[1], strlen($match[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
$upper_string = preg_replace("!((^|\s)['\"])(\w)!e" . Smarty::$_UTF8_MODIFIER, "stripslashes('\\1').strtoupper(stripslashes('\\3'))", $upper_string);
|
||||
return $upper_string;
|
||||
}
|
||||
|
||||
?>
|
||||
31
onyx/modules/templates/smarty/plugins/modifier.cat.php
Normal file
31
onyx/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);
|
||||
}
|
||||
?>
|
||||
33
onyx/modules/templates/smarty/plugins/modifier.countdown.php
Normal file
33
onyx/modules/templates/smarty/plugins/modifier.countdown.php
Normal file
|
|
@ -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,65 @@
|
|||
<?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://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string $string input date string
|
||||
* @param string $format strftime format for output
|
||||
* @param string $default_date default date if $string is empty
|
||||
* @param string $formatter either 'strftime' or 'auto'
|
||||
* @return string |void
|
||||
* @uses smarty_make_timestamp()
|
||||
*/
|
||||
function smarty_modifier_date_format($string, $format=null, $default_date='', $formatter='auto')
|
||||
{
|
||||
if ($format === null) {
|
||||
$format = Smarty::$_DATE_FORMAT;
|
||||
}
|
||||
/**
|
||||
* Include the {@link shared.make_timestamp.php} plugin
|
||||
*/
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
|
||||
if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') {
|
||||
$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,105 @@
|
|||
<?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
|
||||
*
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param array|object $var variable to be formatted
|
||||
* @param integer $depth maximum recursion depth if $var is an array
|
||||
* @param integer $length maximum string length if $var is a string
|
||||
* @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 (Smarty::$_MBSTRING) {
|
||||
if (mb_strlen($var, Smarty::$_CHARSET) > $length) {
|
||||
$results = mb_substr($var, 0, $length - 3, Smarty::$_CHARSET) . '...';
|
||||
}
|
||||
} else {
|
||||
if (isset($var[$length])) {
|
||||
$results = substr($var, 0, $length - 3) . '...';
|
||||
}
|
||||
}
|
||||
|
||||
$results = htmlspecialchars('"' . $results . '"');
|
||||
break;
|
||||
|
||||
case 'unknown type' :
|
||||
default :
|
||||
$results = strtr((string) $var, $_replace);
|
||||
if (Smarty::$_MBSTRING) {
|
||||
if (mb_strlen($results, Smarty::$_CHARSET) > $length) {
|
||||
$results = mb_substr($results, 0, $length - 3, Smarty::$_CHARSET) . '...';
|
||||
}
|
||||
} else {
|
||||
if (strlen($results) > $length) {
|
||||
$results = substr($results, 0, $length - 3) . '...';
|
||||
}
|
||||
}
|
||||
|
||||
$results = htmlspecialchars($results);
|
||||
}
|
||||
|
||||
return $results;
|
||||
}
|
||||
|
||||
?>
|
||||
29
onyx/modules/templates/smarty/plugins/modifier.default.php
Normal file
29
onyx/modules/templates/smarty/plugins/modifier.default.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty default modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: default<br>
|
||||
* Purpose: designate default value for empty variables
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.default.php
|
||||
* default (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_default($string, $default = '')
|
||||
{
|
||||
if (!isset($string) || $string === '')
|
||||
return $default;
|
||||
else
|
||||
return $string;
|
||||
}
|
||||
?>
|
||||
26
onyx/modules/templates/smarty/plugins/modifier.download.php
Normal file
26
onyx/modules/templates/smarty/plugins/modifier.download.php
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage plugins
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty download modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: download<br>
|
||||
* Purpose: convert string to lowercase
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.lower.php
|
||||
* lower (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_download($id)
|
||||
{
|
||||
return strhex(cxor($id, "download"));
|
||||
}
|
||||
|
||||
?>
|
||||
30
onyx/modules/templates/smarty/plugins/modifier.ereg.php
Normal file
30
onyx/modules/templates/smarty/plugins/modifier.ereg.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage plugins
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return string|null
|
||||
*/
|
||||
function smarty_modifier_ereg($str, $params)
|
||||
{
|
||||
return ereg($str, $params);
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
188
onyx/modules/templates/smarty/plugins/modifier.escape.php
Normal file
188
onyx/modules/templates/smarty/plugins/modifier.escape.php
Normal file
|
|
@ -0,0 +1,188 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty escape modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: escape<br>
|
||||
* Purpose: escape string for output
|
||||
*
|
||||
* @link http://www.smarty.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 string $esc_type escape type
|
||||
* @param string $char_set character set, used for htmlspecialchars() or htmlentities()
|
||||
* @param boolean $double_encode encode already encoded entitites again, used for htmlspecialchars() or htmlentities()
|
||||
* @return string escaped input string
|
||||
*/
|
||||
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
|
||||
{
|
||||
static $_double_encode = null;
|
||||
if ($_double_encode === null) {
|
||||
$_double_encode = version_compare(PHP_VERSION, '5.2.3', '>=');
|
||||
}
|
||||
|
||||
if (!$char_set) {
|
||||
$char_set = Smarty::$_CHARSET;
|
||||
}
|
||||
|
||||
switch ($esc_type) {
|
||||
case 'html':
|
||||
if ($_double_encode) {
|
||||
// php >=5.3.2 - go native
|
||||
return htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
} else {
|
||||
if ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
return htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
} else {
|
||||
// php <5.2.3 - prevent double encoding
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
case 'htmlall':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
// mb_convert_encoding ignores htmlspecialchars()
|
||||
if ($_double_encode) {
|
||||
// php >=5.3.2 - go native
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
} else {
|
||||
if ($double_encode) {
|
||||
// php <5.2.3 - only handle double encoding
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
} else {
|
||||
// php <5.2.3 - prevent double encoding
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlspecialchars($string, ENT_QUOTES, $char_set);
|
||||
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
// htmlentities() won't convert everything, so use mb_convert_encoding
|
||||
return mb_convert_encoding($string, 'HTML-ENTITIES', $char_set);
|
||||
}
|
||||
|
||||
// no MBString fallback
|
||||
if ($_double_encode) {
|
||||
return htmlentities($string, ENT_QUOTES, $char_set, $double_encode);
|
||||
} else {
|
||||
if ($double_encode) {
|
||||
return htmlentities($string, ENT_QUOTES, $char_set);
|
||||
} else {
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlentities($string, ENT_QUOTES, $char_set);
|
||||
$string = str_replace(array('%%%SMARTY_START%%%', '%%%SMARTY_END%%%'), array('&', ';'), $string);
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
case 'url':
|
||||
return rawurlencode($string);
|
||||
|
||||
case 'urlpathinfo':
|
||||
return str_replace('%2F', '/', rawurlencode($string));
|
||||
|
||||
case 'quotes':
|
||||
// escape unescaped single quotes
|
||||
return preg_replace("%(?<!\\\\)'%", "\\'", $string);
|
||||
|
||||
case 'hex':
|
||||
// escape every byte into hex
|
||||
// Note that the UTF-8 encoded character ä will be represented as %c3%a4
|
||||
$return = '';
|
||||
$_length = strlen($string);
|
||||
for ($x = 0; $x < $_length; $x++) {
|
||||
$return .= '%' . bin2hex($string[$x]);
|
||||
}
|
||||
return $return;
|
||||
|
||||
case 'hexentity':
|
||||
$return = '';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
||||
$return = '';
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
$return .= '&#x' . strtoupper(dechex($unicode)) . ';';
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
// no MBString fallback
|
||||
$_length = strlen($string);
|
||||
for ($x = 0; $x < $_length; $x++) {
|
||||
$return .= '&#x' . bin2hex($string[$x]) . ';';
|
||||
}
|
||||
return $return;
|
||||
|
||||
case 'decentity':
|
||||
$return = '';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
||||
$return = '';
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
$return .= '&#' . $unicode . ';';
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
// no MBString fallback
|
||||
$_length = strlen($string);
|
||||
for ($x = 0; $x < $_length; $x++) {
|
||||
$return .= '&#' . ord($string[$x]) . ';';
|
||||
}
|
||||
return $return;
|
||||
|
||||
case 'javascript':
|
||||
// escape quotes and backslashes, newlines, etc.
|
||||
return strtr($string, array('\\' => '\\\\', "'" => "\\'", '"' => '\\"', "\r" => '\\r', "\n" => '\\n', '</' => '<\/'));
|
||||
|
||||
case 'mail':
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
|
||||
return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
|
||||
}
|
||||
// no MBString fallback
|
||||
return str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
|
||||
|
||||
case 'nonstd':
|
||||
// escape non-standard chars, such as ms document quotes
|
||||
$return = '';
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_unicode.php');
|
||||
foreach (smarty_mb_to_unicode($string, Smarty::$_CHARSET) as $unicode) {
|
||||
if ($unicode >= 126) {
|
||||
$return .= '&#' . $unicode . ';';
|
||||
} else {
|
||||
$return .= chr($unicode);
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
$_length = strlen($string);
|
||||
for ($_i = 0; $_i < $_length; $_i++) {
|
||||
$_ord = ord(substr($string, $_i, 1));
|
||||
// non-standard char, escape it
|
||||
if ($_ord >= 126) {
|
||||
$return .= '&#' . $_ord . ';';
|
||||
} else {
|
||||
$return .= substr($string, $_i, 1);
|
||||
}
|
||||
}
|
||||
return $return;
|
||||
|
||||
default:
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage plugins
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty escape modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: escape<br>
|
||||
* Purpose: Escape the string according to escapement type
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.escape.php
|
||||
* escape (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string
|
||||
* @param html|htmlall|url|quotes|hex|hexentity|javascript
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_exploderes($string, $glue = ";")
|
||||
{
|
||||
if (ereg("{", $string))
|
||||
return unserialize($string);
|
||||
else
|
||||
return explode($glue, $string);
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
29
onyx/modules/templates/smarty/plugins/modifier.gravatar.php
Normal file
29
onyx/modules/templates/smarty/plugins/modifier.gravatar.php
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage plugins
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* Type: modifier
|
||||
* Name: gravatar
|
||||
* Date: Feb 2, 2011
|
||||
* Purpose: print the url to the image for gravatar
|
||||
* Example: {$mail|gravatar}
|
||||
* @version 1.0
|
||||
* @author Nemunaire <nemunaire at gmail dot com>
|
||||
* @param int
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_gravatar($mail, $comp = "")
|
||||
{
|
||||
return "http://www.gravatar.com/avatar/".md5(strtolower(trim($mail))).$comp;
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
28
onyx/modules/templates/smarty/plugins/modifier.indent.php
Normal file
28
onyx/modules/templates/smarty/plugins/modifier.indent.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty indent modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: indent<br>
|
||||
* Purpose: indent lines of text
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.indent.php
|
||||
* indent (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string
|
||||
* @param integer
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_indent($string,$chars=4,$char=" ")
|
||||
{
|
||||
return preg_replace('!^!m',str_repeat($char,$chars),$string);
|
||||
}
|
||||
|
||||
?>
|
||||
30
onyx/modules/templates/smarty/plugins/modifier.lower.php
Normal file
30
onyx/modules/templates/smarty/plugins/modifier.lower.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty lower modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: lower<br>
|
||||
* Purpose: convert string to lowercase
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string $
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_lower($string)
|
||||
{
|
||||
if (function_exists('mb_strtolower')) {
|
||||
return mb_strtolower($string);
|
||||
} else {
|
||||
return strtolower($string);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
35
onyx/modules/templates/smarty/plugins/modifier.nl2br.php
Normal file
35
onyx/modules/templates/smarty/plugins/modifier.nl2br.php
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage plugins
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: nl2br<br>
|
||||
* Date: Feb 26, 2003
|
||||
* Purpose: convert \r\n, \r or \n to <<br>>
|
||||
* Input:<br>
|
||||
* - contents = contents to replace
|
||||
* - preceed_test = if true, includes preceeding break tags
|
||||
* in replacement
|
||||
* Example: {$text|nl2br}
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.nl2br.php
|
||||
* nl2br (Smarty online manual)
|
||||
* @version 1.0
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_nl2br($string)
|
||||
{
|
||||
return nl2br($string);
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
30
onyx/modules/templates/smarty/plugins/modifier.nom.php
Normal file
30
onyx/modules/templates/smarty/plugins/modifier.nom.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage plugins
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: separenombre<br>
|
||||
* Date: Aug 22, 2008
|
||||
* Purpose: separe number
|
||||
* Example: {$text|separenombre}
|
||||
* @version 1.0
|
||||
* @author Nemunaire <nemunaire at gmail dot com>
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_nom($string, $type)
|
||||
{
|
||||
global ${$type};
|
||||
return ${$type}[$string];
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
24
onyx/modules/templates/smarty/plugins/modifier.noprint.php
Normal file
24
onyx/modules/templates/smarty/plugins/modifier.noprint.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty noprint modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: noprint<br>
|
||||
* Purpose: return an empty string
|
||||
* @author Uwe Tews
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_noprint($string)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty regex_replace modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: regex_replace<br>
|
||||
* Purpose: regular expression search/replace
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
|
||||
* regex_replace (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string $string input string
|
||||
* @param string|array $search regular expression(s) to search for
|
||||
* @param string|array $replace string(s) that should be replaced
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_regex_replace($string, $search, $replace)
|
||||
{
|
||||
if(is_array($search)) {
|
||||
foreach($search as $idx => $s) {
|
||||
$search[$idx] = _smarty_regex_replace_check($s);
|
||||
}
|
||||
} else {
|
||||
$search = _smarty_regex_replace_check($search);
|
||||
}
|
||||
return preg_replace($search, $replace, $string);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $search string(s) that should be replaced
|
||||
* @return string
|
||||
* @ignore
|
||||
*/
|
||||
function _smarty_regex_replace_check($search)
|
||||
{
|
||||
// null-byte injection detection
|
||||
// anything behind the first null-byte is ignored
|
||||
if (($pos = strpos($search,"\0")) !== false) {
|
||||
$search = substr($search,0,$pos);
|
||||
}
|
||||
// remove eval-modifier from $search
|
||||
if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
|
||||
$search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]);
|
||||
}
|
||||
return $search;
|
||||
}
|
||||
|
||||
?>
|
||||
33
onyx/modules/templates/smarty/plugins/modifier.replace.php
Normal file
33
onyx/modules/templates/smarty/plugins/modifier.replace.php
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty replace modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: replace<br>
|
||||
* Purpose: simple search/replace
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @author Uwe Tews
|
||||
* @param string $string input string
|
||||
* @param string $search text to search for
|
||||
* @param string $replace replacement text
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_replace($string, $search, $replace)
|
||||
{
|
||||
if (Smarty::$_MBSTRING) {
|
||||
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
|
||||
return smarty_mb_str_replace($search, $replace, $string);
|
||||
}
|
||||
|
||||
return str_replace($search, $replace, $string);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage plugins
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: separenombre<br>
|
||||
* Date: Aug 22, 2008
|
||||
* Purpose: separe number
|
||||
* Example: {$text|separenombre}
|
||||
* @version 1.0
|
||||
* @author Nemunaire <nemunaire at gmail dot com>
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_separenombre($string)
|
||||
{
|
||||
return number_format(floor($string), 0, ',', ' ');
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage plugins
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty separe number modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: separenombre<br>
|
||||
* Date: Aug 22, 2008
|
||||
* Purpose: separe number
|
||||
* Example: {$int|separenombre}
|
||||
*
|
||||
* @version 1.0
|
||||
* @author Nemunaire <nemunaire at gmail dot com>
|
||||
* @param float $
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_separerNombres($int)
|
||||
{
|
||||
return number_format(floor($int), 0, ',', ' ');
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage plugins
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty separe number modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: separenombre<br>
|
||||
* Date: Aug 22, 2008
|
||||
* Purpose: separe number
|
||||
* Example: {$int|separenombre}
|
||||
*
|
||||
* @version 1.0
|
||||
* @author Nemunaire <nemunaire at gmail dot com>
|
||||
* @param float $
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_separerNombres($int)
|
||||
{
|
||||
return number_format(floor($int), 0, ',', ' ');
|
||||
}
|
||||
|
||||
?>
|
||||
27
onyx/modules/templates/smarty/plugins/modifier.spacify.php
Normal file
27
onyx/modules/templates/smarty/plugins/modifier.spacify.php
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty spacify modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: spacify<br>
|
||||
* Purpose: add spaces between characters in a string
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string $string input string
|
||||
* @param string $spacify_char string to insert between characters.
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_spacify($string, $spacify_char = ' ')
|
||||
{
|
||||
// well… what about charsets besides latin and UTF-8?
|
||||
return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY));
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
function smarty_modifier_splitwords($string, $max = 77)
|
||||
{
|
||||
$words = preg_split('/\s/', $string);
|
||||
$lines = array();
|
||||
$line = '';
|
||||
|
||||
foreach ($words as $k => $word)
|
||||
{
|
||||
$length = strlen($line . ' ' . $word);
|
||||
if ($length <= $max)
|
||||
$line .= ' ' . $word;
|
||||
else if ($length > $max)
|
||||
{
|
||||
if (!empty($line))
|
||||
$lines[] = trim($line);
|
||||
$line = $word;
|
||||
}
|
||||
else
|
||||
{
|
||||
$lines[] = trim($line) . ' ' . $word;
|
||||
$line = '';
|
||||
}
|
||||
}
|
||||
$lines[] = ($line = trim($line)) ? $line : $word;
|
||||
|
||||
if (!empty($lines[1]))
|
||||
return $lines[0]." ...";
|
||||
else
|
||||
return $lines[0];
|
||||
}
|
||||
?>
|
||||
43
onyx/modules/templates/smarty/plugins/modifier.sprintf.php
Normal file
43
onyx/modules/templates/smarty/plugins/modifier.sprintf.php
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage plugins
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: sprintf<br>
|
||||
* Date: Jan 29, 2009
|
||||
* Purpose: separe number
|
||||
* Example: {$text|sprintf:$LANG['test']}
|
||||
* @version 1.0
|
||||
* @author Nemunaire <nemunaire at gmail dot com>
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_sprintf($string, $var0 = null, $var1 = null, $var2 = null, $var3 = null, $var4 = null, $var5 = null, $var6 = null, $var7 = null, $var8 = null, $var9 = null)
|
||||
{
|
||||
for($i = -1; $i<9; $i++) {
|
||||
if (empty(${'var'.($i+1)})) break;
|
||||
}
|
||||
|
||||
if ($i == 0) return sprintf($string, $var0);
|
||||
elseif ($i == 1) return sprintf($string, $var0, $var1);
|
||||
elseif ($i == 2) return sprintf($string, $var0, $var1, $var2);
|
||||
elseif ($i == 3) return sprintf($string, $var0, $var1, $var2, $var3);
|
||||
elseif ($i == 4) return sprintf($string, $var0, $var1, $var2, $var3, $var4);
|
||||
elseif ($i == 5) return sprintf($string, $var0, $var1, $var2, $var3, $var4, $var5);
|
||||
elseif ($i == 6) return sprintf($string, $var0, $var1, $var2, $var3, $var4, $var5, $var6);
|
||||
elseif ($i == 7) return sprintf($string, $var0, $var1, $var2, $var3, $var4, $var5, $var6, $var7);
|
||||
elseif ($i == 8) return sprintf($string, $var0, $var1, $var2, $var3, $var4, $var5, $var6, $var7, $var8);
|
||||
elseif ($i == 9) return sprintf($string, $var0, $var1, $var2, $var3, $var4, $var5, $var6, $var7, $var8, $var9);
|
||||
else return $string;
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
106
onyx/modules/templates/smarty/plugins/modifier.status.php
Normal file
106
onyx/modules/templates/smarty/plugins/modifier.status.php
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
* @package Smarty
|
||||
* @subpackage plugins
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* Type: modifier
|
||||
* Name: status
|
||||
* Date: Feb 2, 2011
|
||||
* Purpose: print the text corresponding to the state
|
||||
* Example: {$int|status}
|
||||
* @version 1.0
|
||||
* @author Nemunaire <nemunaire at gmail dot com>
|
||||
* @param int
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_status($int, $bool = false)
|
||||
{
|
||||
if ($bool)
|
||||
{
|
||||
if ($int < 1)
|
||||
{
|
||||
if ($int > -2)
|
||||
{
|
||||
if ($int == 0)
|
||||
return "Nouveau document !";
|
||||
else //$int == -1
|
||||
return "Document en cours de création/correction";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($int == -2)
|
||||
return "Refusé";
|
||||
else //$int == -3
|
||||
return "Supprimé";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($int > 3)
|
||||
{
|
||||
if ($int == 4)
|
||||
return "Publié";
|
||||
else //$int == 5 || $int == 6
|
||||
return "Mis en valeur";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($int == 2)
|
||||
return "Corrigé";
|
||||
elseif ($int == 1)
|
||||
return "En cours de correction";
|
||||
else //$int == 3
|
||||
return "Contrôle";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($int < 1)
|
||||
{
|
||||
if ($int > -2)
|
||||
{
|
||||
if ($int == 0)
|
||||
return "Document en attente de correction";
|
||||
else //$int == -1
|
||||
return "Document à compléter";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($int == -2)
|
||||
return "Document refusé";
|
||||
else //$int == -3
|
||||
return "Document supprimé";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($int > 3)
|
||||
{
|
||||
if ($int == 4)
|
||||
return "Document publié";
|
||||
else //$int == 5 || $int == 6
|
||||
return "Document mis en valeur";
|
||||
}
|
||||
else
|
||||
{
|
||||
if ($int == 2)
|
||||
return "Corrigé";
|
||||
elseif ($int == 1)
|
||||
return "En cours de correction";
|
||||
else //$int == 3
|
||||
return "En cours de contrôle";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
@ -0,0 +1,27 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty string_format modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: string_format<br>
|
||||
* Purpose: format strings via sprintf
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @param string $string input string
|
||||
* @param string $format format string
|
||||
* @return string formatted string
|
||||
*/
|
||||
function smarty_modifier_string_format($string, $format)
|
||||
{
|
||||
return sprintf($format, $string);
|
||||
}
|
||||
|
||||
?>
|
||||
31
onyx/modules/templates/smarty/plugins/modifier.strip.php
Normal file
31
onyx/modules/templates/smarty/plugins/modifier.strip.php
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
/**
|
||||
* Smarty plugin
|
||||
*
|
||||
* @package Smarty
|
||||
* @subpackage PluginsModifier
|
||||
*/
|
||||
|
||||
/**
|
||||
* Smarty strip modifier plugin
|
||||
*
|
||||
* Type: modifier<br>
|
||||
* Name: strip<br>
|
||||
* Purpose: Replace all repeated spaces, newlines, tabs
|
||||
* with a single space or supplied replacement string.<br>
|
||||
* Example: {$var|strip} {$var|strip:" "}
|
||||
* Date: September 25th, 2002
|
||||
*
|
||||
* @link http://smarty.php.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
|
||||
* @author Monte Ohrt <monte at ohrt dot com>
|
||||
* @version 1.0
|
||||
* @param string $
|
||||
* @param string $
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_strip($text, $replace = ' ')
|
||||
{
|
||||
return preg_replace('!\s+!', $replace, $text);
|
||||
}
|
||||
|
||||
?>
|
||||
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue