First commit, current version 0.2

This commit is contained in:
Némunaire 2011-07-30 00:14:52 +02:00
commit 872acdbc01
353 changed files with 45771 additions and 0 deletions

View 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;
}
?>

Binary file not shown.

Binary file not shown.

View 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);
}
}
?>

File diff suppressed because it is too large Load diff

View 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");
}
}
}
?>

View 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);
}
}
?>

View 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;
}
}
?>

View file

@ -0,0 +1,65 @@
<?php
if(!defined('ONYX')) exit;
function unparse_config($create, $xml, $array, $node = 'var', $attribut = 'name')
{
if (is_array($array))
foreach($array as $name => $var)
{
if (is_array($var))
{
$xml_var = $create->createElement($node);
$xml_var->setAttribute($attribut, $name);
unparse_config($create, $xml_var, $var, $node, $attribut);
$xml->appendChild($xml_var);
}
else
{
$xml_var = $create->createElement($node, $var);
$xml_var->setAttribute($attribut, $name);
$xml->appendChild($xml_var);
}
}
}
require_once("__config.class.php");
require_once("chconfig.class.php");
require_once("chmodules.class.php");
function chconfig($type, $file = null)
{
$sortie = "";
if ($type == "modules")
{
$sortie .= '<h1>Modification des paramètres de modules</h1><form action="?t=modules" method="post">';
//On charge ce qu'on veut afficher
$mods = new chModules($file);
$sortie .= '</form>';
}
elseif ($type == "bdd")
{
$sortie .= "<h1>Modification des paramètres de base de données</h1>";
}
else
{
$sortie .= "<h1>Modification des paramètres de configuration</h1>";
}
return $sortie;
}
//Affichage automatique
if (!empty($OPT["show"]))
{
echo "<html><head><title>Modification des paramètres d'Onyx2</title></head><body>";
echo chconfig(gpc("t"));
echo "</body></html>";
exit;
}
?>

28
onyx2/modules/db/main.php Normal file
View 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);
}
?>

View 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);
}
}
?>

View 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);
}
}
?>

View 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];
}
}
?>

File diff suppressed because it is too large Load diff

View 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
}
?>

View 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;
}
}
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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&ouml;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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View 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: ';
?>

View file

@ -0,0 +1,38 @@
<?php
if(!defined('ONYX')) exit;
define('PHPMAILER_DIR', ONYX.'modules/mail/');
require_once(PHPMAILER_DIR."class.phpmailer.php");
define('_MAIL_MAILER', $OPT['mailer']);
define('_MAIL_LANG', $OPT['lang']);
define('_MAIL_CHARSET', $OPT['charset']);
define('_MAIL_HOST', $OPT['host']);
define('_MAIL_PORT', $OPT['port']);
define('_MAIL_SECURE', $OPT['secure']);
define('_MAIL_FROM', $OPT['from']);
define('_MAIL_FROMNAME', $OPT['fromname']);
define('_MAIL_AUTH', !empty($OPT['username']));
define('_MAIL_USERNAME', $OPT['username']);
define('_MAIL_PASSWORD', $OPT['password']);
class Mailer extends PHPmailer
{
var $CharSet = _MAIL_CHARSET;
var $From = _MAIL_FROM;
var $FromName = _MAIL_FROMNAME;
var $Mailer = _MAIL_MAILER;
var $Version = "2.0";
var $Host = _MAIL_HOST;
var $Port = _MAIL_PORT;
var $SMTPSecure = _MAIL_SECURE;
var $SMTPAuth = _MAIL_AUTH;
var $Username = _MAIL_USERNAME;
var $Password = _MAIL_PASSWORD;
var $Timeout = 5;
var $Sendmail = "/usr/lib/sendmail";
}
?>

93
onyx2/modules/modules.xml Normal file
View 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>

View 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);
?>

View 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);
}
}
?>

View 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;
}
}
?>

View 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;
}
}
?>

View file

View 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 !
}
}
?>

View file

@ -0,0 +1,815 @@
<?php
/**
* Project: Smarty: the PHP compiling template engine
* File: Smarty.class.php
* SVN: $Id: Smarty.class.php 3895 2010-12-31 13:47:12Z uwe.tews@googlemail.com $
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* For questions, help, comments, discussion, etc., please join the
* Smarty mailing list. Send a blank e-mail to
* smarty-discussion-subscribe@googlegroups.com
*
* @link http://www.smarty.net/
* @copyright 2008 New Digital Group, Inc.
* @author Monte Ohrt <monte at ohrt dot com>
* @author Uwe Tews
* @package Smarty
* @version 3.0.7
*/
/**
* define shorthand directory separator constant
*/
if (!defined('DS')) {
define('DS', DIRECTORY_SEPARATOR);
}
/**
* set SMARTY_DIR to absolute path to Smarty library files.
* Sets SMARTY_DIR only if user application has not already defined it.
*/
if (!defined('SMARTY_DIR')) {
define('SMARTY_DIR', dirname(__FILE__) . DS);
}
/**
* set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins.
* Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it.
*/
if (!defined('SMARTY_SYSPLUGINS_DIR')) {
define('SMARTY_SYSPLUGINS_DIR', SMARTY_DIR . 'sysplugins' . DS);
}
if (!defined('SMARTY_PLUGINS_DIR')) {
define('SMARTY_PLUGINS_DIR', SMARTY_DIR . 'plugins' . DS);
}
if (!defined('SMARTY_RESOURCE_CHAR_SET')) {
define('SMARTY_RESOURCE_CHAR_SET', 'UTF-8');
}
if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) {
define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y');
}
/**
* register the class autoloader
*/
if (!defined('SMARTY_SPL_AUTOLOAD')) {
define('SMARTY_SPL_AUTOLOAD', 0);
}
if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) {
$registeredAutoLoadFunctions = spl_autoload_functions();
if (!isset($registeredAutoLoadFunctions['spl_autoload'])) {
spl_autoload_register();
}
} else {
spl_autoload_register('smartyAutoload');
}
/**
* This is the main Smarty class
*/
class Smarty extends Smarty_Internal_Data {
/**
* constant definitions
*/
// smarty version
const SMARTY_VERSION = 'Smarty-3.0.7';
//define variable scopes
const SCOPE_LOCAL = 0;
const SCOPE_PARENT = 1;
const SCOPE_ROOT = 2;
const SCOPE_GLOBAL = 3;
// define caching modes
const CACHING_OFF = 0;
const CACHING_LIFETIME_CURRENT = 1;
const CACHING_LIFETIME_SAVED = 2;
/** modes for handling of "<?php ... ?>" tags in templates. **/
const PHP_PASSTHRU = 0; //-> print tags as plain text
const PHP_QUOTE = 1; //-> escape tags as entities
const PHP_REMOVE = 2; //-> escape tags as entities
const PHP_ALLOW = 3; //-> escape tags as entities
// filter types
const FILTER_POST = 'post';
const FILTER_PRE = 'pre';
const FILTER_OUTPUT = 'output';
const FILTER_VARIABLE = 'variable';
// plugin types
const PLUGIN_FUNCTION = 'function';
const PLUGIN_BLOCK = 'block';
const PLUGIN_COMPILER = 'compiler';
const PLUGIN_MODIFIER = 'modifier';
/**
* static variables
*/
// assigned global tpl vars
static $global_tpl_vars = array();
/**
* variables
*/
// auto literal on delimiters with whitspace
public $auto_literal = true;
// display error on not assigned variables
public $error_unassigned = false;
// template directory
public $template_dir = null;
// default template handler
public $default_template_handler_func = null;
// compile directory
public $compile_dir = null;
// plugins directory
public $plugins_dir = null;
// cache directory
public $cache_dir = null;
// config directory
public $config_dir = null;
// force template compiling?
public $force_compile = false;
// check template for modifications?
public $compile_check = true;
// locking concurrent compiles
public $compile_locking = true;
// use sub dirs for compiled/cached files?
public $use_sub_dirs = false;
// compile_error?
public $compile_error = false;
// caching enabled
public $caching = false;
// merge compiled includes
public $merge_compiled_includes = false;
// cache lifetime
public $cache_lifetime = 3600;
// force cache file creation
public $force_cache = false;
// cache_id
public $cache_id = null;
// compile_id
public $compile_id = null;
// template delimiters
public $left_delimiter = "{";
public $right_delimiter = "}";
// security
public $security_class = 'Smarty_Security';
public $security_policy = null;
public $php_handling = self::PHP_PASSTHRU;
public $allow_php_tag = false;
public $allow_php_templates = false;
public $direct_access_security = true;
public $trusted_dir = array();
// debug mode
public $debugging = false;
public $debugging_ctrl = 'NONE';
public $smarty_debug_id = 'SMARTY_DEBUG';
public $debug_tpl = null;
// When set, smarty does uses this value as error_reporting-level.
public $error_reporting = null;
// config var settings
public $config_overwrite = true; //Controls whether variables with the same name overwrite each other.
public $config_booleanize = true; //Controls whether config values of on/true/yes and off/false/no get converted to boolean
public $config_read_hidden = false; //Controls whether hidden config sections/vars are read from the file.
// config vars
public $config_vars = array();
// assigned tpl vars
public $tpl_vars = array();
// dummy parent object
public $parent = null;
// global template functions
public $template_functions = array();
// resource type used if none given
public $default_resource_type = 'file';
// caching type
public $caching_type = 'file';
// internal cache resource types
public $cache_resource_types = array('file');
// internal config properties
public $properties = array();
// config type
public $default_config_type = 'file';
// cached template objects
public $template_objects = null;
// check If-Modified-Since headers
public $cache_modified_check = false;
// registered plugins
public $registered_plugins = array();
// plugin search order
public $plugin_search_order = array('function', 'block', 'compiler', 'class');
// registered objects
public $registered_objects = array();
// registered classes
public $registered_classes = array();
// registered filters
public $registered_filters = array();
// registered resources
public $registered_resources = array();
// autoload filter
public $autoload_filters = array();
// status of filter on variable output
public $variable_filter = true;
// default modifier
public $default_modifiers = array();
// global internal smarty vars
static $_smarty_vars = array();
// start time for execution time calculation
public $start_time = 0;
// default file permissions
public $_file_perms = 0644;
// default dir permissions
public $_dir_perms = 0771;
// block tag hierarchy
public $_tag_stack = array();
// flag if {block} tag is compiled for template inheritance
public $inheritance = false;
// generate deprecated function call notices?
public $deprecation_notices = true;
// Smarty 2 BC
public $_version = self::SMARTY_VERSION;
// self pointer to Smarty object
public $smarty;
/**
* Class constructor, initializes basic smarty properties
*/
public function __construct()
{
// selfpointer need by some other class methods
$this->smarty = $this;
if (is_callable('mb_internal_encoding')) {
mb_internal_encoding(SMARTY_RESOURCE_CHAR_SET);
}
$this->start_time = microtime(true);
// set default dirs
$this->template_dir = array('.' . DS . 'templates' . DS);
$this->compile_dir = '.' . DS . 'templates_c' . DS;
$this->plugins_dir = array(SMARTY_PLUGINS_DIR);
$this->cache_dir = '.' . DS . 'cache' . DS;
$this->config_dir = '.' . DS . 'configs' . DS;
$this->debug_tpl = SMARTY_DIR . 'debug.tpl';
if (isset($_SERVER['SCRIPT_NAME'])) {
$this->assignGlobal('SCRIPT_NAME', $_SERVER['SCRIPT_NAME']);
}
}
/**
* Class destructor
*/
public function __destruct()
{
}
/**
* fetches a rendered Smarty template
*
* @param string $template the resource handle of the template file or template object
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
* @param object $ |null $parent next higher level of Smarty variables
* @return string rendered template output
*/
public function fetch($template, $cache_id = null, $compile_id = null, $parent = null, $display = false)
{
if (!empty($cache_id) && is_object($cache_id)) {
$parent = $cache_id;
$cache_id = null;
}
if ($parent === null) {
// get default Smarty data object
$parent = $this;
}
// create template object if necessary
($template instanceof $this->template_class)? $_template = $template :
$_template = $this->createTemplate ($template, $cache_id, $compile_id, $parent, false);
if (isset($this->error_reporting)) {
$_smarty_old_error_level = error_reporting($this->error_reporting);
}
// check URL debugging control
if (!$this->debugging && $this->debugging_ctrl == 'URL') {
if (isset($_SERVER['QUERY_STRING'])) {
$_query_string = $_SERVER['QUERY_STRING'];
} else {
$_query_string = '';
}
if (false !== strpos($_query_string, $this->smarty_debug_id)) {
if (false !== strpos($_query_string, $this->smarty_debug_id . '=on')) {
// enable debugging for this browser session
setcookie('SMARTY_DEBUG', true);
$this->debugging = true;
} elseif (false !== strpos($_query_string, $this->smarty_debug_id . '=off')) {
// disable debugging for this browser session
setcookie('SMARTY_DEBUG', false);
$this->debugging = false;
} else {
// enable debugging for this page
$this->debugging = true;
}
} else {
if (isset($_COOKIE['SMARTY_DEBUG'])) {
$this->debugging = true;
}
}
}
// obtain data for cache modified check
if ($this->cache_modified_check && $this->caching && $display) {
$_isCached = $_template->isCached() && !$_template->has_nocache_code;
if ($_isCached) {
$_gmt_mtime = gmdate('D, d M Y H:i:s', $_template->getCachedTimestamp()) . ' GMT';
} else {
$_gmt_mtime = '';
}
}
// return rendered template
if ((!$this->caching || $_template->resource_object->isEvaluated) && (isset($this->autoload_filters['output']) || isset($this->registered_filters['output']))) {
$_output = Smarty_Internal_Filter_Handler::runFilter('output', $_template->getRenderedTemplate(), $_template);
} else {
$_output = $_template->getRenderedTemplate();
}
$_template->rendered_content = null;
if (isset($this->error_reporting)) {
error_reporting($_smarty_old_error_level);
}
// display or fetch
if ($display) {
if ($this->caching && $this->cache_modified_check) {
$_last_modified_date = @substr($_SERVER['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_SERVER['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3);
if ($_isCached && $_gmt_mtime == $_last_modified_date) {
if (php_sapi_name() == 'cgi')
header('Status: 304 Not Modified');
else
header('HTTP/1.1 304 Not Modified');
} else {
header('Last-Modified: ' . gmdate('D, d M Y H:i:s', $_template->getCachedTimestamp()) . ' GMT');
echo $_output;
}
} else {
echo $_output;
}
// debug output
if ($this->debugging) {
Smarty_Internal_Debug::display_debug($this);
}
return;
} else {
// return fetched content
return $_output;
}
}
/**
* displays a Smarty template
*
* @param string $ |object $template the resource handle of the template file or template object
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
* @param object $parent next higher level of Smarty variables
*/
public function display($template, $cache_id = null, $compile_id = null, $parent = null)
{
// display template
$this->fetch ($template, $cache_id, $compile_id, $parent, true);
}
/**
* test if cache i valid
*
* @param string $ |object $template the resource handle of the template file or template object
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
* @param object $parent next higher level of Smarty variables
* @return boolean cache status
*/
public function isCached($template, $cache_id = null, $compile_id = null, $parent = null)
{
if ($parent === null) {
$parent = $this;
}
if (!($template instanceof $this->template_class)) {
$template = $this->createTemplate ($template, $cache_id, $compile_id, $parent, false);
}
// return cache status of template
return $template->isCached();
}
/**
* creates a data object
*
* @param object $parent next higher level of Smarty variables
* @returns object data object
*/
public function createData($parent = null)
{
return new Smarty_Data($parent, $this);
}
/**
* creates a template object
*
* @param string $template the resource handle of the template file
* @param mixed $cache_id cache id to be used with this template
* @param mixed $compile_id compile id to be used with this template
* @param object $parent next higher level of Smarty variables
* @param boolean $do_clone flag is Smarty object shall be cloned
* @returns object template object
*/
public function createTemplate($template, $cache_id = null, $compile_id = null, $parent = null, $do_clone = true)
{
if (!empty($cache_id) && (is_object($cache_id) || is_array($cache_id))) {
$parent = $cache_id;
$cache_id = null;
}
if (!empty($parent) && is_array($parent)) {
$data = $parent;
$parent = null;
} else {
$data = null;
}
if (!is_object($template)) {
// we got a template resource
// already in template cache?
$_templateId = sha1($template . $cache_id . $compile_id);
if (isset($this->template_objects[$_templateId]) && $this->caching) {
// return cached template object
$tpl = $this->template_objects[$_templateId];
} else {
// create new template object
if ($do_clone) {
$tpl = new $this->template_class($template, clone $this, $parent, $cache_id, $compile_id);
} else {
$tpl = new $this->template_class($template, $this, $parent, $cache_id, $compile_id);
}
}
} else {
// just return a copy of template class
$tpl = $template;
}
// fill data if present
if (!empty($data) && is_array($data)) {
// set up variable values
foreach ($data as $_key => $_val) {
$tpl->tpl_vars[$_key] = new Smarty_variable($_val);
}
}
return $tpl;
}
/**
* Check if a template resource exists
*
* @param string $resource_name template name
* @return boolean status
*/
function templateExists($resource_name)
{
// create template object
$save = $this->template_objects;
$tpl = new $this->template_class($resource_name, $this);
// check if it does exists
$result = $tpl->isExisting();
$this->template_objects = $save;
return $result;
}
/**
* Returns a single or all global variables
*
* @param object $smarty
* @param string $varname variable name or null
* @return string variable value or or array of variables
*/
function getGlobal($varname = null)
{
if (isset($varname)) {
if (isset(self::$global_tpl_vars[$varname])) {
return self::$global_tpl_vars[$varname]->value;
} else {
return '';
}
} else {
$_result = array();
foreach (self::$global_tpl_vars AS $key => $var) {
$_result[$key] = $var->value;
}
return $_result;
}
}
/**
* Empty cache folder
*
* @param integer $exp_time expiration time
* @param string $type resource type
* @return integer number of cache files deleted
*/
function clearAllCache($exp_time = null, $type = null)
{
// load cache resource and call clearAll
return $this->loadCacheResource($type)->clearAll($exp_time);
}
/**
* Empty cache for a specific template
*
* @param string $template_name template name
* @param string $cache_id cache id
* @param string $compile_id compile id
* @param integer $exp_time expiration time
* @param string $type resource type
* @return integer number of cache files deleted
*/
function clearCache($template_name, $cache_id = null, $compile_id = null, $exp_time = null, $type = null)
{
// load cache resource and call clear
return $this->loadCacheResource($type)->clear($template_name, $cache_id, $compile_id, $exp_time);
}
/**
* Loads security class and enables security
*/
public function enableSecurity($security_class = null)
{
if ($security_class instanceof Smarty_Security) {
$this->security_policy = $security_class;
return;
}
if ($security_class == null) {
$security_class = $this->security_class;
}
if (class_exists($security_class)) {
$this->security_policy = new $security_class($this);
} else {
throw new SmartyException("Security class '$security_class' is not defined");
}
}
/**
* Disable security
*/
public function disableSecurity()
{
$this->security_policy = null;
}
/**
* Loads cache resource.
*
* @param string $type cache resource type
* @return object of cache resource
*/
public function loadCacheResource($type = null) {
if (!isset($type)) {
$type = $this->caching_type;
}
if (in_array($type, $this->cache_resource_types)) {
$cache_resource_class = 'Smarty_Internal_CacheResource_' . ucfirst($type);
return new $cache_resource_class($this);
}
else {
// try plugins dir
$cache_resource_class = 'Smarty_CacheResource_' . ucfirst($type);
if ($this->loadPlugin($cache_resource_class)) {
return new $cache_resource_class($this);
}
else {
throw new SmartyException("Unable to load cache resource '{$type}'");
}
}
}
/**
* Set template directory
*
* @param string $ |array $template_dir folder(s) of template sorces
*/
public function setTemplateDir($template_dir)
{
$this->template_dir = (array)$template_dir;
return;
}
/**
* Adds template directory(s) to existing ones
*
* @param string $ |array $template_dir folder(s) of template sources
*/
public function addTemplateDir($template_dir)
{
$this->template_dir = array_unique(array_merge((array)$this->template_dir, (array)$template_dir));
return;
}
/**
* Adds directory of plugin files
*
* @param object $smarty
* @param string $ |array $ plugins folder
* @return
*/
function addPluginsDir($plugins_dir)
{
$this->plugins_dir = array_unique(array_merge((array)$this->plugins_dir, (array)$plugins_dir));
return;
}
/**
* return a reference to a registered object
*
* @param string $name object name
* @return object
*/
function getRegisteredObject($name)
{
if (!isset($this->registered_objects[$name]))
throw new SmartyException("'$name' is not a registered object");
if (!is_object($this->registered_objects[$name][0]))
throw new SmartyException("registered '$name' is not an object");
return $this->registered_objects[$name][0];
}
/**
* return name of debugging template
*
* @return string
*/
function getDebugTemplate()
{
return $this->debug_tpl;
}
/**
* set the debug template
*
* @param string $tpl_name
* @return bool
*/
function setDebugTemplate($tpl_name)
{
return $this->debug_tpl = $tpl_name;
}
/**
* Takes unknown classes and loads plugin files for them
* class name format: Smarty_PluginType_PluginName
* plugin filename format: plugintype.pluginname.php
*
* @param string $plugin_name class plugin name to load
* @return string |boolean filepath of loaded file or false
*/
public function loadPlugin($plugin_name, $check = true)
{
// if function or class exists, exit silently (already loaded)
if ($check && (is_callable($plugin_name) || class_exists($plugin_name, false)))
return true;
// Plugin name is expected to be: Smarty_[Type]_[Name]
$_plugin_name = strtolower($plugin_name);
$_name_parts = explode('_', $_plugin_name, 3);
// class name must have three parts to be valid plugin
if (count($_name_parts) < 3 || $_name_parts[0] !== 'smarty') {
throw new SmartyException("plugin {$plugin_name} is not a valid name format");
return false;
}
// if type is "internal", get plugin from sysplugins
if ($_name_parts[1] == 'internal') {
$file = SMARTY_SYSPLUGINS_DIR . $_plugin_name . '.php';
if (file_exists($file)) {
require_once($file);
return $file;
} else {
return false;
}
}
// plugin filename is expected to be: [type].[name].php
$_plugin_filename = "{$_name_parts[1]}.{$_name_parts[2]}.php";
// loop through plugin dirs and find the plugin
foreach((array)$this->plugins_dir as $_plugin_dir) {
if (strpos('/\\', substr($_plugin_dir, -1)) === false) {
$_plugin_dir .= DS;
}
$file = $_plugin_dir . $_plugin_filename;
if (file_exists($file)) {
require_once($file);
return $file;
}
}
// no plugin loaded
return false;
}
/**
* clean up properties on cloned object
*/
public function __clone()
{
// clear config vars
$this->config_vars = array();
// clear assigned tpl vars
$this->tpl_vars = array();
// clear objects for external methods
unset($this->register);
unset($this->filter);
}
/**
* Handle unknown class methods
*
* @param string $name unknown methode name
* @param array $args aurgument array
*/
public function __call($name, $args)
{
static $camel_func;
if (!isset($camel_func))
$camel_func = create_function('$c', 'return "_" . strtolower($c[1]);');
// see if this is a set/get for a property
$first3 = strtolower(substr($name, 0, 3));
if (in_array($first3, array('set', 'get')) && substr($name, 3, 1) !== '_') {
// try to keep case correct for future PHP 6.0 case-sensitive class methods
// lcfirst() not available < PHP 5.3.0, so improvise
$property_name = strtolower(substr($name, 3, 1)) . substr($name, 4);
// convert camel case to underscored name
$property_name = preg_replace_callback('/([A-Z])/', $camel_func, $property_name);
if (!property_exists($this, $property_name)) {
throw new SmartyException("property '$property_name' does not exist.");
return false;
}
if ($first3 == 'get')
return $this->$property_name;
else
return $this->$property_name = $args[0];
}
// Smarty Backward Compatible wrapper
if (strpos($name,'_') !== false) {
if (!isset($this->wrapper)) {
$this->wrapper = new Smarty_Internal_Wrapper($this);
}
return $this->wrapper->convert($name, $args);
}
// external Smarty methods ?
foreach(array('filter','register') as $external) {
if (method_exists("Smarty_Internal_{$external}",$name)) {
if (!isset($this->$external)) {
$class = "Smarty_Internal_{$external}";
$this->$external = new $class($this);
}
return call_user_func_array(array($this->$external,$name), $args);
}
}
if (in_array($name,array('clearCompiledTemplate','compileAllTemplates','compileAllConfig','testInstall','getTags'))) {
if (!isset($this->utility)) {
$this->utility = new Smarty_Internal_Utility($this);
}
return call_user_func_array(array($this->utility,$name), $args);
}
// PHP4 call to constructor?
if (strtolower($name) == 'smarty') {
throw new SmartyException('Please use parent::__construct() to call parent constuctor');
return false;
}
throw new SmartyException("Call of unknown function '$name'.");
}
}
/**
* Autoloader
*/
function smartyAutoload($class)
{
$_class = strtolower($class);
if (substr($_class, 0, 16) === 'smarty_internal_' || $_class == 'smarty_security') {
include SMARTY_SYSPLUGINS_DIR . $_class . '.php';
}
}
/**
* Smarty exception class
*/
Class SmartyException extends Exception {
}
/**
* Smarty compiler exception class
*/
Class SmartyCompilerException extends SmartyException {
}
?>

View file

@ -0,0 +1,133 @@
{capture name='_smarty_debug' assign=debug_output}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Smarty Debug Console</title>
<style type="text/css">
{literal}
body, h1, h2, td, th, p {
font-family: sans-serif;
font-weight: normal;
font-size: 0.9em;
margin: 1px;
padding: 0;
}
h1 {
margin: 0;
text-align: left;
padding: 2px;
background-color: #f0c040;
color: black;
font-weight: bold;
font-size: 1.2em;
}
h2 {
background-color: #9B410E;
color: white;
text-align: left;
font-weight: bold;
padding: 2px;
border-top: 1px solid black;
}
body {
background: black;
}
p, table, div {
background: #f0ead8;
}
p {
margin: 0;
font-style: italic;
text-align: center;
}
table {
width: 100%;
}
th, td {
font-family: monospace;
vertical-align: top;
text-align: left;
width: 50%;
}
td {
color: green;
}
.odd {
background-color: #eeeeee;
}
.even {
background-color: #fafafa;
}
.exectime {
font-size: 0.8em;
font-style: italic;
}
#table_assigned_vars th {
color: blue;
}
#table_config_vars th {
color: maroon;
}
{/literal}
</style>
</head>
<body>
<h1>Smarty Debug Console - {if isset($template_name)}{$template_name|debug_print_var}{else}Total Time {$execution_time|string_format:"%.5f"}{/if}</h1>
{if !empty($template_data)}
<h2>included templates &amp; config files (load time in seconds)</h2>
<div>
{foreach $template_data as $template}
<font color=brown>{$template.name}</font>
<span class="exectime">
(compile {$template['compile_time']|string_format:"%.5f"}) (render {$template['render_time']|string_format:"%.5f"}) (cache {$template['cache_time']|string_format:"%.5f"})
</span>
<br>
{/foreach}
</div>
{/if}
<h2>assigned template variables</h2>
<table id="table_assigned_vars">
{foreach $assigned_vars as $vars}
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
<th>${$vars@key|escape:'html'}</th>
<td>{$vars|debug_print_var}</td></tr>
{/foreach}
</table>
<h2>assigned config file variables (outer template scope)</h2>
<table id="table_config_vars">
{foreach $config_vars as $vars}
<tr class="{if $vars@iteration % 2 eq 0}odd{else}even{/if}">
<th>{$vars@key|escape:'html'}</th>
<td>{$vars|debug_print_var}</td></tr>
{/foreach}
</table>
</body>
</html>
{/capture}
<script type="text/javascript">
{$id = $template_name|default:''|md5}
_smarty_console = window.open("","console{$id}","width=680,height=600,resizable,scrollbars=yes");
_smarty_console.document.write("{$debug_output|escape:'javascript'}");
_smarty_console.document.close();
</script>

View 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 '';
}
?>

View file

@ -0,0 +1,102 @@
<?php
/**
* Smarty plugin to format text blocks
*
* @package Smarty
* @subpackage PluginsBlock
*/
/**
* Smarty {textformat}{/textformat} block plugin
*
* Type: block function<br>
* Name: textformat<br>
* Purpose: format text a certain way with preset styles
* or custom wrap/indent settings<br>
*
* @link http://smarty.php.net/manual/en/language.function.textformat.php {textformat}
* (Smarty online manual)
* @param array $params parameters
* <pre>
* Params: style: string (email)
* indent: integer (0)
* wrap: integer (80)
* wrap_char string ("\n")
* indent_char: string (" ")
* wrap_boundary: boolean (true)
* </pre>
* @author Monte Ohrt <monte at ohrt dot com>
* @param string $content contents of the block
* @param object $template template object
* @param boolean &$repeat repeat flag
* @return string content re-formatted
*/
function smarty_block_textformat($params, $content, $template, &$repeat)
{
if (is_null($content)) {
return;
}
$style = null;
$indent = 0;
$indent_first = 0;
$indent_char = ' ';
$wrap = 80;
$wrap_char = "\n";
$wrap_cut = false;
$assign = null;
foreach ($params as $_key => $_val) {
switch ($_key) {
case 'style':
case 'indent_char':
case 'wrap_char':
case 'assign':
$$_key = (string)$_val;
break;
case 'indent':
case 'indent_first':
case 'wrap':
$$_key = (int)$_val;
break;
case 'wrap_cut':
$$_key = (bool)$_val;
break;
default:
trigger_error("textformat: unknown attribute '$_key'");
}
}
if ($style == 'email') {
$wrap = 72;
}
// split into paragraphs
$_paragraphs = preg_split('![\r\n][\r\n]!', $content);
$_output = '';
for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
if ($_paragraphs[$_x] == '') {
continue;
}
// convert mult. spaces & special chars to single space
$_paragraphs[$_x] = preg_replace(array('!\s+!', '!(^\s+)|(\s+$)!'), array(' ', ''), $_paragraphs[$_x]);
// indent first line
if ($indent_first > 0) {
$_paragraphs[$_x] = str_repeat($indent_char, $indent_first) . $_paragraphs[$_x];
}
// wordwrap sentences
$_paragraphs[$_x] = wordwrap($_paragraphs[$_x], $wrap - $indent, $wrap_char, $wrap_cut);
// indent lines
if ($indent > 0) {
$_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]);
}
}
$_output = implode($wrap_char . $wrap_char, $_paragraphs);
return $assign ? $template->assign($assign, $_output) : $_output;
}
?>

View file

@ -0,0 +1,78 @@
<?php
/**
* Smarty plugin
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {counter} function plugin
*
* Type: function<br>
* Name: counter<br>
* Purpose: print out a counter value
* @author Monte Ohrt <monte at ohrt dot com>
* @link http://smarty.php.net/manual/en/language.function.counter.php {counter}
* (Smarty online manual)
* @param array parameters
* @param Smarty
* @param object $template template object
* @return string|null
*/
function smarty_function_counter($params, $template)
{
static $counters = array();
$name = (isset($params['name'])) ? $params['name'] : 'default';
if (!isset($counters[$name])) {
$counters[$name] = array(
'start'=>1,
'skip'=>1,
'direction'=>'up',
'count'=>1
);
}
$counter =& $counters[$name];
if (isset($params['start'])) {
$counter['start'] = $counter['count'] = (int)$params['start'];
}
if (!empty($params['assign'])) {
$counter['assign'] = $params['assign'];
}
if (isset($counter['assign'])) {
$template->assign($counter['assign'], $counter['count']);
}
if (isset($params['print'])) {
$print = (bool)$params['print'];
} else {
$print = empty($counter['assign']);
}
if ($print) {
$retval = $counter['count'];
} else {
$retval = null;
}
if (isset($params['skip'])) {
$counter['skip'] = $params['skip'];
}
if (isset($params['direction'])) {
$counter['direction'] = $params['direction'];
}
if ($counter['direction'] == "down")
$counter['count'] -= $counter['skip'];
else
$counter['count'] += $counter['skip'];
return $retval;
}
?>

View file

@ -0,0 +1,106 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {cycle} function plugin
*
* Type: function<br>
* Name: cycle<br>
* Date: May 3, 2002<br>
* Purpose: cycle through given values<br>
* Input:
* - name = name of cycle (optional)
* - values = comma separated list of values to cycle,
* or an array of values to cycle
* (this can be left out for subsequent calls)
* - reset = boolean - resets given var to true
* - print = boolean - print var or not. default is true
* - advance = boolean - whether or not to advance the cycle
* - delimiter = the value delimiter, default is ","
* - assign = boolean, assigns to template var instead of
* printed.
*
* Examples:<br>
* <pre>
* {cycle values="#eeeeee,#d0d0d0d"}
* {cycle name=row values="one,two,three" reset=true}
* {cycle name=row}
* </pre>
* @link http://smarty.php.net/manual/en/language.function.cycle.php {cycle}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author credit to Mark Priatel <mpriatel@rogers.com>
* @author credit to Gerard <gerard@interfold.com>
* @author credit to Jason Sweat <jsweat_php@yahoo.com>
* @version 1.3
* @param array
* @param object $template template object
* @return string|null
*/
function smarty_function_cycle($params, $template)
{
static $cycle_vars;
$name = (empty($params['name'])) ? 'default' : $params['name'];
$print = (isset($params['print'])) ? (bool)$params['print'] : true;
$advance = (isset($params['advance'])) ? (bool)$params['advance'] : true;
$reset = (isset($params['reset'])) ? (bool)$params['reset'] : false;
if (!in_array('values', array_keys($params))) {
if(!isset($cycle_vars[$name]['values'])) {
trigger_error("cycle: missing 'values' parameter");
return;
}
} else {
if(isset($cycle_vars[$name]['values'])
&& $cycle_vars[$name]['values'] != $params['values'] ) {
$cycle_vars[$name]['index'] = 0;
}
$cycle_vars[$name]['values'] = $params['values'];
}
if (isset($params['delimiter'])) {
$cycle_vars[$name]['delimiter'] = $params['delimiter'];
} elseif (!isset($cycle_vars[$name]['delimiter'])) {
$cycle_vars[$name]['delimiter'] = ',';
}
if(is_array($cycle_vars[$name]['values'])) {
$cycle_array = $cycle_vars[$name]['values'];
} else {
$cycle_array = explode($cycle_vars[$name]['delimiter'],$cycle_vars[$name]['values']);
}
if(!isset($cycle_vars[$name]['index']) || $reset ) {
$cycle_vars[$name]['index'] = 0;
}
if (isset($params['assign'])) {
$print = false;
$template->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]);
}
if($print) {
$retval = $cycle_array[$cycle_vars[$name]['index']];
} else {
$retval = null;
}
if($advance) {
if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
$cycle_vars[$name]['index'] = 0;
} else {
$cycle_vars[$name]['index']++;
}
}
return $retval;
}
?>

View file

@ -0,0 +1,216 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {fetch} plugin
*
* Type: function<br>
* Name: fetch<br>
* Purpose: fetch file, web or ftp data and display results
* @link http://smarty.php.net/manual/en/language.function.fetch.php {fetch}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param array $params parameters
* @param object $template template object
* @return string|null if the assign parameter is passed, Smarty assigns the
* result to a template variable
*/
function smarty_function_fetch($params, $template)
{
if (empty($params['file'])) {
trigger_error("[plugin] fetch parameter 'file' cannot be empty",E_USER_NOTICE);
return;
}
$content = '';
if (isset($template->security_policy) && !preg_match('!^(http|ftp)://!i', $params['file'])) {
if(!$template->security_policy->isTrustedResourceDir($params['file'])) {
return;
}
// fetch the file
if($fp = @fopen($params['file'],'r')) {
while(!feof($fp)) {
$content .= fgets ($fp,4096);
}
fclose($fp);
} else {
trigger_error('[plugin] fetch cannot read file \'' . $params['file'] . '\'',E_USER_NOTICE);
return;
}
} else {
// not a local file
if(preg_match('!^http://!i',$params['file'])) {
// http fetch
if($uri_parts = parse_url($params['file'])) {
// set defaults
$host = $server_name = $uri_parts['host'];
$timeout = 30;
$accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
$agent = "Smarty Template Engine ".$template->_version;
$referer = "";
$uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/';
$uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : '';
$_is_proxy = false;
if(empty($uri_parts['port'])) {
$port = 80;
} else {
$port = $uri_parts['port'];
}
if(!empty($uri_parts['user'])) {
$user = $uri_parts['user'];
}
if(!empty($uri_parts['pass'])) {
$pass = $uri_parts['pass'];
}
// loop through parameters, setup headers
foreach($params as $param_key => $param_value) {
switch($param_key) {
case "file":
case "assign":
case "assign_headers":
break;
case "user":
if(!empty($param_value)) {
$user = $param_value;
}
break;
case "pass":
if(!empty($param_value)) {
$pass = $param_value;
}
break;
case "accept":
if(!empty($param_value)) {
$accept = $param_value;
}
break;
case "header":
if(!empty($param_value)) {
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
trigger_error("[plugin] invalid header format '".$param_value."'",E_USER_NOTICE);
return;
} else {
$extra_headers[] = $param_value;
}
}
break;
case "proxy_host":
if(!empty($param_value)) {
$proxy_host = $param_value;
}
break;
case "proxy_port":
if(!preg_match('!\D!', $param_value)) {
$proxy_port = (int) $param_value;
} else {
trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE);
return;
}
break;
case "agent":
if(!empty($param_value)) {
$agent = $param_value;
}
break;
case "referer":
if(!empty($param_value)) {
$referer = $param_value;
}
break;
case "timeout":
if(!preg_match('!\D!', $param_value)) {
$timeout = (int) $param_value;
} else {
trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE);
return;
}
break;
default:
trigger_error("[plugin] unrecognized attribute '".$param_key."'",E_USER_NOTICE);
return;
}
}
if(!empty($proxy_host) && !empty($proxy_port)) {
$_is_proxy = true;
$fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout);
} else {
$fp = fsockopen($server_name,$port,$errno,$errstr,$timeout);
}
if(!$fp) {
trigger_error("[plugin] unable to fetch: $errstr ($errno)",E_USER_NOTICE);
return;
} else {
if($_is_proxy) {
fputs($fp, 'GET ' . $params['file'] . " HTTP/1.0\r\n");
} else {
fputs($fp, "GET $uri HTTP/1.0\r\n");
}
if(!empty($host)) {
fputs($fp, "Host: $host\r\n");
}
if(!empty($accept)) {
fputs($fp, "Accept: $accept\r\n");
}
if(!empty($agent)) {
fputs($fp, "User-Agent: $agent\r\n");
}
if(!empty($referer)) {
fputs($fp, "Referer: $referer\r\n");
}
if(isset($extra_headers) && is_array($extra_headers)) {
foreach($extra_headers as $curr_header) {
fputs($fp, $curr_header."\r\n");
}
}
if(!empty($user) && !empty($pass)) {
fputs($fp, "Authorization: BASIC ".base64_encode("$user:$pass")."\r\n");
}
fputs($fp, "\r\n");
while(!feof($fp)) {
$content .= fgets($fp,4096);
}
fclose($fp);
$csplit = preg_split("!\r\n\r\n!",$content,2);
$content = $csplit[1];
if(!empty($params['assign_headers'])) {
$template->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0]));
}
}
} else {
trigger_error("[plugin fetch] unable to parse URL, check syntax",E_USER_NOTICE);
return;
}
} else {
// ftp fetch
if($fp = @fopen($params['file'],'r')) {
while(!feof($fp)) {
$content .= fgets ($fp,4096);
}
fclose($fp);
} else {
trigger_error('[plugin] fetch cannot read file \'' . $params['file'] .'\'',E_USER_NOTICE);
return;
}
}
}
if (!empty($params['assign'])) {
$template->assign($params['assign'],$content);
} else {
return $content;
}
}
?>

View file

@ -0,0 +1,143 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {html_checkboxes} function plugin
*
* File: function.html_checkboxes.php<br>
* Type: function<br>
* Name: html_checkboxes<br>
* Date: 24.Feb.2003<br>
* Purpose: Prints out a list of checkbox input types<br>
* Examples:
* <pre>
* {html_checkboxes values=$ids output=$names}
* {html_checkboxes values=$ids name='box' separator='<br>' output=$names}
* {html_checkboxes values=$ids checked=$checked separator='<br>' output=$names}
* </pre>
* @link http://smarty.php.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
* (Smarty online manual)
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
* @author credits to Monte Ohrt <monte at ohrt dot com>
* @version 1.0
* @param array $params parameters
* Input:<br>
* - name (optional) - string default "checkbox"
* - values (required) - array
* - options (optional) - associative array
* - checked (optional) - array default not set
* - separator (optional) - ie <br> or &nbsp;
* - output (optional) - the output next to each checkbox
* - assign (optional) - assign the output as an array to this variable
* @param object $template template object
* @return string
* @uses smarty_function_escape_special_chars()
*/
function smarty_function_html_checkboxes($params, $template)
{
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
$name = 'checkbox';
$values = null;
$options = null;
$selected = null;
$separator = '';
$labels = true;
$output = null;
$extra = '';
foreach($params as $_key => $_val) {
switch($_key) {
case 'name':
case 'separator':
$$_key = $_val;
break;
case 'labels':
$$_key = (bool)$_val;
break;
case 'options':
$$_key = (array)$_val;
break;
case 'values':
case 'output':
$$_key = array_values((array)$_val);
break;
case 'checked':
case 'selected':
$selected = array_map('strval', array_values((array)$_val));
break;
case 'checkboxes':
trigger_error('html_checkboxes: the use of the "checkboxes" attribute is deprecated, use "options" instead', E_USER_WARNING);
$options = (array)$_val;
break;
case 'assign':
break;
default:
if(!is_array($_val)) {
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
} else {
trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
}
}
if (!isset($options) && !isset($values))
return ''; /* raise error here? */
settype($selected, 'array');
$_html_result = array();
if (isset($options)) {
foreach ($options as $_key=>$_val)
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
} else {
foreach ($values as $_i=>$_key) {
$_val = isset($output[$_i]) ? $output[$_i] : '';
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels);
}
}
if(!empty($params['assign'])) {
$template->assign($params['assign'], $_html_result);
} else {
return implode("\n",$_html_result);
}
}
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels) {
$_output = '';
if ($labels) $_output .= '<label>';
$_output .= '<input type="checkbox" name="'
. smarty_function_escape_special_chars($name) . '[]" value="'
. smarty_function_escape_special_chars($value) . '"';
if (in_array((string)$value, $selected)) {
$_output .= ' checked="checked"';
}
$_output .= $extra . ' />' . $output;
if ($labels) $_output .= '</label>';
$_output .= $separator;
return $_output;
}
?>

View file

@ -0,0 +1,137 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {html_image} function plugin
*
* Type: function<br>
* Name: html_image<br>
* Date: Feb 24, 2003<br>
* Purpose: format HTML tags for the image<br>
* Examples: {html_image file="/images/masthead.gif"}
* Output: <img src="/images/masthead.gif" width=400 height=23>
*
* @link http://smarty.php.net/manual/en/language.function.html.image.php {html_image}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @author credits to Duda <duda@big.hu>
* @version 1.0
* @param array $params parameters
* Input:<br>
* - file = file (and path) of image (required)
* - height = image height (optional, default actual height)
* - width = image width (optional, default actual width)
* - basedir = base directory for absolute paths, default
* is environment variable DOCUMENT_ROOT
* - path_prefix = prefix for path output (optional, default empty)
* @param object $template template object
* @return string
* @uses smarty_function_escape_special_chars()
*/
function smarty_function_html_image($params, $template)
{
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
$alt = '';
$file = '';
$height = '';
$width = '';
$extra = '';
$prefix = '';
$suffix = '';
$path_prefix = '';
$server_vars = $_SERVER;
$basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : '';
foreach($params as $_key => $_val) {
switch ($_key) {
case 'file':
case 'height':
case 'width':
case 'dpi':
case 'path_prefix':
case 'basedir':
$$_key = $_val;
break;
case 'alt':
if (!is_array($_val)) {
$$_key = smarty_function_escape_special_chars($_val);
} else {
throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
case 'link':
case 'href':
$prefix = '<a href="' . $_val . '">';
$suffix = '</a>';
break;
default:
if (!is_array($_val)) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
} else {
throw new SmartyException ("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
}
}
if (empty($file)) {
trigger_error("html_image: missing 'file' parameter", E_USER_NOTICE);
return;
}
if (substr($file, 0, 1) == '/') {
$_image_path = $basedir . $file;
} else {
$_image_path = $file;
}
if (!isset($params['width']) || !isset($params['height'])) {
if (!$_image_data = @getimagesize($_image_path)) {
if (!file_exists($_image_path)) {
trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE);
return;
} else if (!is_readable($_image_path)) {
trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE);
return;
} else {
trigger_error("html_image: '$_image_path' is not a valid image file", E_USER_NOTICE);
return;
}
}
if (isset($template->security_policy)) {
if (!$template->security_policy->isTrustedResourceDir($_image_path)) {
return;
}
}
if (!isset($params['width'])) {
$width = $_image_data[0];
}
if (!isset($params['height'])) {
$height = $_image_data[1];
}
}
if (isset($params['dpi'])) {
if (strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) {
$dpi_default = 72;
} else {
$dpi_default = 96;
}
$_resize = $dpi_default / $params['dpi'];
$width = round($width * $_resize);
$height = round($height * $_resize);
}
return $prefix . '<img src="' . $path_prefix . $file . '" alt="' . $alt . '" width="' . $width . '" height="' . $height . '"' . $extra . ' />' . $suffix;
}
?>

View file

@ -0,0 +1,133 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {html_options} function plugin
*
* Type: function<br>
* Name: html_options<br>
* Purpose: Prints the list of <option> tags generated from
* the passed parameters
*
* @link http://smarty.php.net/manual/en/language.function.html.options.php {html_image}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param array $params parameters
* Input:<br>
* - name (optional) - string default "select"
* - values (required if no options supplied) - array
* - options (required if no values supplied) - associative array
* - selected (optional) - string default not set
* - output (required if not options supplied) - array
* @param object $template template object
* @return string
* @uses smarty_function_escape_special_chars()
*/
function smarty_function_html_options($params, $template)
{
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
$name = null;
$values = null;
$options = null;
$selected = array();
$output = null;
$id = null;
$class = null;
$extra = '';
$options_extra = '';
foreach($params as $_key => $_val) {
switch ($_key) {
case 'name':
case 'class':
case 'id':
$$_key = (string)$_val;
break;
case 'options':
$$_key = (array)$_val;
break;
case 'values':
case 'output':
$$_key = array_values((array)$_val);
break;
case 'selected':
$$_key = array_map('strval', array_values((array)$_val));
break;
default:
if (!is_array($_val)) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
} else {
trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
}
}
if (!isset($options) && !isset($values))
return '';
/* raise error here? */
$_html_result = '';
$_idx = 0;
if (isset($options)) {
foreach ($options as $_key => $_val) {
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx);
}
} else {
foreach ($values as $_i => $_key) {
$_val = isset($output[$_i]) ? $output[$_i] : '';
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected, $id, $class, $_idx);
}
}
if (!empty($name)) {
$_html_class = !empty($class) ? ' class="'.$class.'"' : '';
$_html_id = !empty($id) ? ' id="'.$id.'"' : '';
$_html_result = '<select name="' . $name . '"' . $_html_class . $_html_id . $extra . '>' . "\n" . $_html_result . '</select>' . "\n";
}
return $_html_result;
}
function smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, &$idx)
{
if (!is_array($value)) {
$_html_result = '<option value="' .
smarty_function_escape_special_chars($key) . '"';
if (in_array((string)$key, $selected))
$_html_result .= ' selected="selected"';
$_html_class = !empty($class) ? ' class="'.$class.' option"' : '';
$_html_id = !empty($id) ? ' id="'.$id.'-'.$idx.'"' : '';
$_html_result .= $_html_class . $_html_id . '>' . smarty_function_escape_special_chars($value) . '</option>' . "\n";
$idx++;
} else {
$_idx = 0;
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected, $id.'-'.$idx, $class, $_idx);
$idx++;
}
return $_html_result;
}
function smarty_function_html_options_optgroup($key, $values, $selected, $id, $class, &$idx)
{
$optgroup_html = '<optgroup label="' . smarty_function_escape_special_chars($key) . '">' . "\n";
foreach ($values as $key => $value) {
$optgroup_html .= smarty_function_html_options_optoutput($key, $value, $selected, $id, $class, $idx);
}
$optgroup_html .= "</optgroup>\n";
return $optgroup_html;
}
?>

View file

@ -0,0 +1,154 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {html_radios} function plugin
*
* File: function.html_radios.php<br>
* Type: function<br>
* Name: html_radios<br>
* Date: 24.Feb.2003<br>
* Purpose: Prints out a list of radio input types<br>
* Examples:
* <pre>
* {html_radios values=$ids output=$names}
* {html_radios values=$ids name='box' separator='<br>' output=$names}
* {html_radios values=$ids checked=$checked separator='<br>' output=$names}
* </pre>
*
* @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
* (Smarty online manual)
* @author Christopher Kvarme <christopher.kvarme@flashjab.com>
* @author credits to Monte Ohrt <monte at ohrt dot com>
* @version 1.0
* @param array $params parameters
* Input:<br>
* - name (optional) - string default "radio"
* - values (required) - array
* - options (optional) - associative array
* - checked (optional) - array default not set
* - separator (optional) - ie <br> or &nbsp;
* - output (optional) - the output next to each radio button
* - assign (optional) - assign the output as an array to this variable
* @param object $template template object
* @return string
* @uses smarty_function_escape_special_chars()
*/
function smarty_function_html_radios($params, $template)
{
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
$name = 'radio';
$values = null;
$options = null;
$selected = null;
$separator = '';
$labels = true;
$label_ids = false;
$output = null;
$extra = '';
foreach($params as $_key => $_val) {
switch ($_key) {
case 'name':
case 'separator':
$$_key = (string)$_val;
break;
case 'checked':
case 'selected':
if (is_array($_val)) {
trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
} else {
$selected = (string)$_val;
}
break;
case 'labels':
case 'label_ids':
$$_key = (bool)$_val;
break;
case 'options':
$$_key = (array)$_val;
break;
case 'values':
case 'output':
$$_key = array_values((array)$_val);
break;
case 'radios':
trigger_error('html_radios: the use of the "radios" attribute is deprecated, use "options" instead', E_USER_WARNING);
$options = (array)$_val;
break;
case 'assign':
break;
default:
if (!is_array($_val)) {
$extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
} else {
trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
}
}
if (!isset($options) && !isset($values))
return '';
/* raise error here? */
$_html_result = array();
if (isset($options)) {
foreach ($options as $_key => $_val)
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
} else {
foreach ($values as $_i => $_key) {
$_val = isset($output[$_i]) ? $output[$_i] : '';
$_html_result[] = smarty_function_html_radios_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids);
}
}
if (!empty($params['assign'])) {
$template->assign($params['assign'], $_html_result);
} else {
return implode("\n", $_html_result);
}
}
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids)
{
$_output = '';
if ($labels) {
if ($label_ids) {
$_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!', '_', $name . '_' . $value));
$_output .= '<label for="' . $_id . '">';
} else {
$_output .= '<label>';
}
}
$_output .= '<input type="radio" name="'
. smarty_function_escape_special_chars($name) . '" value="'
. smarty_function_escape_special_chars($value) . '"';
if ($labels && $label_ids) $_output .= ' id="' . $_id . '"';
if ((string)$value == $selected) {
$_output .= ' checked="checked"';
}
$_output .= $extra . ' />' . $output;
if ($labels) $_output .= '</label>';
$_output .= $separator;
return $_output;
}
?>

View file

@ -0,0 +1,330 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {html_select_date} plugin
*
* Type: function<br>
* Name: html_select_date<br>
* Purpose: Prints the dropdowns for date selection.
*
* ChangeLog:<br>
* - 1.0 initial release
* - 1.1 added support for +/- N syntax for begin
* and end year values. (Monte)
* - 1.2 added support for yyyy-mm-dd syntax for
* time value. (Jan Rosier)
* - 1.3 added support for choosing format for
* month values (Gary Loescher)
* - 1.3.1 added support for choosing format for
* day values (Marcus Bointon)
* - 1.3.2 support negative timestamps, force year
* dropdown to include given date unless explicitly set (Monte)
* - 1.3.4 fix behaviour of 0000-00-00 00:00:00 dates to match that
* of 0000-00-00 dates (cybot, boots)
*
* @link http://smarty.php.net/manual/en/language.function.html.select.date.php {html_select_date}
* (Smarty online manual)
* @version 1.3.4
* @author Andrei Zmievski
* @author Monte Ohrt <monte at ohrt dot com>
* @param array $params parameters
* @param object $template template object
* @return string
*/
function smarty_function_html_select_date($params, $template)
{
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
require_once(SMARTY_PLUGINS_DIR . 'function.html_options.php');
/* Default values. */
$prefix = "Date_";
$start_year = strftime("%Y");
$end_year = $start_year;
$display_days = true;
$display_months = true;
$display_years = true;
$month_format = "%B";
/* Write months as numbers by default GL */
$month_value_format = "%m";
$day_format = "%02d";
/* Write day values using this format MB */
$day_value_format = "%d";
$year_as_text = false;
/* Display years in reverse order? Ie. 2000,1999,.... */
$reverse_years = false;
/* Should the select boxes be part of an array when returned from PHP?
e.g. setting it to "birthday", would create "birthday[Day]",
"birthday[Month]" & "birthday[Year]". Can be combined with prefix */
$field_array = null;
/* <select size>'s of the different <select> tags.
If not set, uses default dropdown. */
$day_size = null;
$month_size = null;
$year_size = null;
/* Unparsed attributes common to *ALL* the <select>/<input> tags.
An example might be in the template: all_extra ='class ="foo"'. */
$all_extra = null;
/* Separate attributes for the tags. */
$day_extra = null;
$month_extra = null;
$year_extra = null;
/* Order in which to display the fields.
"D" -> day, "M" -> month, "Y" -> year. */
$field_order = 'MDY';
/* String printed between the different fields. */
$field_separator = "\n";
$time = time();
$all_empty = null;
$day_empty = null;
$month_empty = null;
$year_empty = null;
$extra_attrs = '';
foreach ($params as $_key => $_value) {
switch ($_key) {
case 'prefix':
case 'time':
case 'start_year':
case 'end_year':
case 'month_format':
case 'day_format':
case 'day_value_format':
case 'field_array':
case 'day_size':
case 'month_size':
case 'year_size':
case 'all_extra':
case 'day_extra':
case 'month_extra':
case 'year_extra':
case 'field_order':
case 'field_separator':
case 'month_value_format':
case 'month_empty':
case 'day_empty':
case 'year_empty':
$$_key = (string)$_value;
break;
case 'all_empty':
$$_key = (string)$_value;
$day_empty = $month_empty = $year_empty = $all_empty;
break;
case 'display_days':
case 'display_months':
case 'display_years':
case 'year_as_text':
case 'reverse_years':
$$_key = (bool)$_value;
break;
default:
if (!is_array($_value)) {
$extra_attrs .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_value) . '"';
} else {
trigger_error("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
}
break;
}
}
if (preg_match('!^-\d+$!', $time)) {
// negative timestamp, use date()
$time = date('Y-m-d', $time);
}
// If $time is not in format yyyy-mm-dd
if (preg_match('/^(\d{0,4}-\d{0,2}-\d{0,2})/', $time, $found)) {
$time = $found[1];
} else {
// use smarty_make_timestamp to get an unix timestamp and
// strftime to make yyyy-mm-dd
$time = strftime('%Y-%m-%d', smarty_make_timestamp($time));
}
// Now split this in pieces, which later can be used to set the select
$time = explode("-", $time);
// make syntax "+N" or "-N" work with start_year and end_year
if (preg_match('!^(\+|\-)\s*(\d+)$!', $end_year, $match)) {
if ($match[1] == '+') {
$end_year = strftime('%Y') + $match[2];
} else {
$end_year = strftime('%Y') - $match[2];
}
}
if (preg_match('!^(\+|\-)\s*(\d+)$!', $start_year, $match)) {
if ($match[1] == '+') {
$start_year = strftime('%Y') + $match[2];
} else {
$start_year = strftime('%Y') - $match[2];
}
}
if (strlen($time[0]) > 0) {
if ($start_year > $time[0] && !isset($params['start_year'])) {
// force start year to include given date if not explicitly set
$start_year = $time[0];
}
if ($end_year < $time[0] && !isset($params['end_year'])) {
// force end year to include given date if not explicitly set
$end_year = $time[0];
}
}
$field_order = strtoupper($field_order);
$html_result = $month_result = $day_result = $year_result = "";
$field_separator_count = -1;
if ($display_months) {
$field_separator_count++;
$month_names = array();
$month_values = array();
if (isset($month_empty)) {
$month_names[''] = $month_empty;
$month_values[''] = '';
}
for ($i = 1; $i <= 12; $i++) {
$month_names[$i] = strftime($month_format, mktime(0, 0, 0, $i, 1, 2000));
$month_values[$i] = strftime($month_value_format, mktime(0, 0, 0, $i, 1, 2000));
}
$month_result .= '<select name=';
if (null !== $field_array) {
$month_result .= '"' . $field_array . '[' . $prefix . 'Month]"';
} else {
$month_result .= '"' . $prefix . 'Month"';
}
if (null !== $month_size) {
$month_result .= ' size="' . $month_size . '"';
}
if (null !== $month_extra) {
$month_result .= ' ' . $month_extra;
}
if (null !== $all_extra) {
$month_result .= ' ' . $all_extra;
}
$month_result .= $extra_attrs . '>' . "\n";
$month_result .= smarty_function_html_options(array('output' => $month_names,
'values' => $month_values,
'selected' => (int)$time[1] ? strftime($month_value_format, mktime(0, 0, 0, (int)$time[1], 1, 2000)) : '',
'print_result' => false),
$template);
$month_result .= '</select>';
}
if ($display_days) {
$field_separator_count++;
$days = array();
if (isset($day_empty)) {
$days[''] = $day_empty;
$day_values[''] = '';
}
for ($i = 1; $i <= 31; $i++) {
$days[] = sprintf($day_format, $i);
$day_values[] = sprintf($day_value_format, $i);
}
$day_result .= '<select name=';
if (null !== $field_array) {
$day_result .= '"' . $field_array . '[' . $prefix . 'Day]"';
} else {
$day_result .= '"' . $prefix . 'Day"';
}
if (null !== $day_size) {
$day_result .= ' size="' . $day_size . '"';
}
if (null !== $all_extra) {
$day_result .= ' ' . $all_extra;
}
if (null !== $day_extra) {
$day_result .= ' ' . $day_extra;
}
$day_result .= $extra_attrs . '>' . "\n";
$day_result .= smarty_function_html_options(array('output' => $days,
'values' => $day_values,
'selected' => $time[2],
'print_result' => false),
$template);
$day_result .= '</select>';
}
if ($display_years) {
$field_separator_count++;
if (null !== $field_array) {
$year_name = $field_array . '[' . $prefix . 'Year]';
} else {
$year_name = $prefix . 'Year';
}
if ($year_as_text) {
$year_result .= '<input type="text" name="' . $year_name . '" value="' . $time[0] . '" size="4" maxlength="4"';
if (null !== $all_extra) {
$year_result .= ' ' . $all_extra;
}
if (null !== $year_extra) {
$year_result .= ' ' . $year_extra;
}
$year_result .= ' />';
} else {
$years = range((int)$start_year, (int)$end_year);
if ($reverse_years) {
rsort($years, SORT_NUMERIC);
} else {
sort($years, SORT_NUMERIC);
}
$yearvals = $years;
if (isset($year_empty)) {
array_unshift($years, $year_empty);
array_unshift($yearvals, '');
}
$year_result .= '<select name="' . $year_name . '"';
if (null !== $year_size) {
$year_result .= ' size="' . $year_size . '"';
}
if (null !== $all_extra) {
$year_result .= ' ' . $all_extra;
}
if (null !== $year_extra) {
$year_result .= ' ' . $year_extra;
}
$year_result .= $extra_attrs . '>' . "\n";
$year_result .= smarty_function_html_options(array('output' => $years,
'values' => $yearvals,
'selected' => $time[0],
'print_result' => false),
$template);
$year_result .= '</select>';
}
}
// Loop thru the field_order field
for ($i = 0; $i <= 2; $i++) {
$c = substr($field_order, $i, 1);
switch ($c) {
case 'D':
$html_result .= $day_result;
break;
case 'M':
$html_result .= $month_result;
break;
case 'Y':
$html_result .= $year_result;
break;
}
// Add the field seperator
if ($i < $field_separator_count) {
$html_result .= $field_separator;
}
}
return $html_result;
}
?>

View file

@ -0,0 +1,194 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {html_select_time} function plugin
*
* Type: function<br>
* Name: html_select_time<br>
* Purpose: Prints the dropdowns for time selection
*
* @link http://smarty.php.net/manual/en/language.function.html.select.time.php {html_select_time}
* (Smarty online manual)
* @author Roberto Berto <roberto@berto.net>
* @credits Monte Ohrt <monte AT ohrt DOT com>
* @param array $params parameters
* @param object $template template object
* @return string
* @uses smarty_make_timestamp()
*/
function smarty_function_html_select_time($params, $template)
{
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
require_once(SMARTY_PLUGINS_DIR . 'function.html_options.php');
/* Default values. */
$prefix = "Time_";
$time = time();
$display_hours = true;
$display_minutes = true;
$display_seconds = true;
$display_meridian = true;
$use_24_hours = true;
$minute_interval = 1;
$second_interval = 1;
/* Should the select boxes be part of an array when returned from PHP?
e.g. setting it to "birthday", would create "birthday[Hour]",
"birthday[Minute]", "birthday[Seconds]" & "birthday[Meridian]".
Can be combined with prefix. */
$field_array = null;
$all_extra = null;
$hour_extra = null;
$minute_extra = null;
$second_extra = null;
$meridian_extra = null;
foreach ($params as $_key => $_value) {
switch ($_key) {
case 'prefix':
case 'time':
case 'field_array':
case 'all_extra':
case 'hour_extra':
case 'minute_extra':
case 'second_extra':
case 'meridian_extra':
$$_key = (string)$_value;
break;
case 'display_hours':
case 'display_minutes':
case 'display_seconds':
case 'display_meridian':
case 'use_24_hours':
$$_key = (bool)$_value;
break;
case 'minute_interval':
case 'second_interval':
$$_key = (int)$_value;
break;
default:
trigger_error("[html_select_time] unknown parameter $_key", E_USER_WARNING);
}
}
$time = smarty_make_timestamp($time);
$html_result = '';
if ($display_hours) {
$hours = $use_24_hours ? range(0, 23) : range(1, 12);
$hour_fmt = $use_24_hours ? '%H' : '%I';
for ($i = 0, $for_max = count($hours); $i < $for_max; $i++)
$hours[$i] = sprintf('%02d', $hours[$i]);
$html_result .= '<select name=';
if (null !== $field_array) {
$html_result .= '"' . $field_array . '[' . $prefix . 'Hour]"';
} else {
$html_result .= '"' . $prefix . 'Hour"';
}
if (null !== $hour_extra) {
$html_result .= ' ' . $hour_extra;
}
if (null !== $all_extra) {
$html_result .= ' ' . $all_extra;
}
$html_result .= '>' . "\n";
$html_result .= smarty_function_html_options(array('output' => $hours,
'values' => $hours,
'selected' => strftime($hour_fmt, $time),
'print_result' => false),
$template);
$html_result .= "</select>\n";
}
if ($display_minutes) {
$all_minutes = range(0, 59);
for ($i = 0, $for_max = count($all_minutes); $i < $for_max; $i += $minute_interval)
$minutes[] = sprintf('%02d', $all_minutes[$i]);
$selected = intval(floor(strftime('%M', $time) / $minute_interval) * $minute_interval);
$html_result .= '<select name=';
if (null !== $field_array) {
$html_result .= '"' . $field_array . '[' . $prefix . 'Minute]"';
} else {
$html_result .= '"' . $prefix . 'Minute"';
}
if (null !== $minute_extra) {
$html_result .= ' ' . $minute_extra;
}
if (null !== $all_extra) {
$html_result .= ' ' . $all_extra;
}
$html_result .= '>' . "\n";
$html_result .= smarty_function_html_options(array('output' => $minutes,
'values' => $minutes,
'selected' => $selected,
'print_result' => false),
$template);
$html_result .= "</select>\n";
}
if ($display_seconds) {
$all_seconds = range(0, 59);
for ($i = 0, $for_max = count($all_seconds); $i < $for_max; $i += $second_interval)
$seconds[] = sprintf('%02d', $all_seconds[$i]);
$selected = intval(floor(strftime('%S', $time) / $second_interval) * $second_interval);
$html_result .= '<select name=';
if (null !== $field_array) {
$html_result .= '"' . $field_array . '[' . $prefix . 'Second]"';
} else {
$html_result .= '"' . $prefix . 'Second"';
}
if (null !== $second_extra) {
$html_result .= ' ' . $second_extra;
}
if (null !== $all_extra) {
$html_result .= ' ' . $all_extra;
}
$html_result .= '>' . "\n";
$html_result .= smarty_function_html_options(array('output' => $seconds,
'values' => $seconds,
'selected' => $selected,
'print_result' => false),
$template);
$html_result .= "</select>\n";
}
if ($display_meridian && !$use_24_hours) {
$html_result .= '<select name=';
if (null !== $field_array) {
$html_result .= '"' . $field_array . '[' . $prefix . 'Meridian]"';
} else {
$html_result .= '"' . $prefix . 'Meridian"';
}
if (null !== $meridian_extra) {
$html_result .= ' ' . $meridian_extra;
}
if (null !== $all_extra) {
$html_result .= ' ' . $all_extra;
}
$html_result .= '>' . "\n";
$html_result .= smarty_function_html_options(array('output' => array('AM', 'PM'),
'values' => array('am', 'pm'),
'selected' => strtolower(strftime('%p', $time)),
'print_result' => false),
$template);
$html_result .= "</select>\n";
}
return $html_result;
}
?>

View file

@ -0,0 +1,177 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {html_table} function plugin
*
* Type: function<br>
* Name: html_table<br>
* Date: Feb 17, 2003<br>
* Purpose: make an html table from an array of data<br>
*
*
* Examples:
* <pre>
* {table loop=$data}
* {table loop=$data cols=4 tr_attr='"bgcolor=red"'}
* {table loop=$data cols="first,second,third" tr_attr=$colors}
* </pre>
*
* @author Monte Ohrt <monte at ohrt dot com>
* @author credit to Messju Mohr <messju at lammfellpuschen dot de>
* @author credit to boots <boots dot smarty at yahoo dot com>
* @version 1.1
* @link http://smarty.php.net/manual/en/language.function.html.table.php {html_table}
* (Smarty online manual)
* @param array $params parameters
* Input:<br>
* - loop = array to loop through
* - cols = number of columns, comma separated list of column names
* or array of column names
* - rows = number of rows
* - table_attr = table attributes
* - th_attr = table heading attributes (arrays are cycled)
* - tr_attr = table row attributes (arrays are cycled)
* - td_attr = table cell attributes (arrays are cycled)
* - trailpad = value to pad trailing cells with
* - caption = text for caption element
* - vdir = vertical direction (default: "down", means top-to-bottom)
* - hdir = horizontal direction (default: "right", means left-to-right)
* - inner = inner loop (default "cols": print $loop line by line,
* $loop will be printed column by column otherwise)
* @param object $template template object
* @return string
*/
function smarty_function_html_table($params, $template)
{
$table_attr = 'border="1"';
$tr_attr = '';
$th_attr = '';
$td_attr = '';
$cols = $cols_count = 3;
$rows = 3;
$trailpad = '&nbsp;';
$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 : '';
}
?>

View file

@ -0,0 +1,156 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {mailto} function plugin
*
* Type: function<br>
* Name: mailto<br>
* Date: May 21, 2002
* Purpose: automate mailto address link creation, and optionally
* encode them.<br>
*
* Examples:
* <pre>
* {mailto address="me@domain.com"}
* {mailto address="me@domain.com" encode="javascript"}
* {mailto address="me@domain.com" encode="hex"}
* {mailto address="me@domain.com" subject="Hello to you!"}
* {mailto address="me@domain.com" cc="you@domain.com,they@domain.com"}
* {mailto address="me@domain.com" extra='class="mailto"'}
* </pre>
*
* @link http://smarty.php.net/manual/en/language.function.mailto.php {mailto}
* (Smarty online manual)
* @version 1.2
* @author Monte Ohrt <monte at ohrt dot com>
* @author credits to Jason Sweat (added cc, bcc and subject functionality)
* @param array $params parameters
* Input:<br>
* - address = e-mail address
* - text = (optional) text to display, default is address
* - encode = (optional) can be one of:
* * none : no encoding (default)
* * javascript : encode with javascript
* * javascript_charcode : encode with javascript charcode
* * hex : encode with hexidecimal (no javascript)
* - cc = (optional) address(es) to carbon copy
* - bcc = (optional) address(es) to blind carbon copy
* - subject = (optional) e-mail subject
* - newsgroups = (optional) newsgroup(s) to post to
* - followupto = (optional) address(es) to follow up to
* - extra = (optional) extra tags for the href link
* @param object $template template object
* @return string
*/
function smarty_function_mailto($params, $template)
{
$extra = '';
if (empty($params['address'])) {
trigger_error("mailto: missing 'address' parameter",E_USER_WARNING);
return;
} else {
$address = $params['address'];
}
$text = $address;
// netscape and mozilla do not decode %40 (@) in BCC field (bug?)
// so, don't encode it.
$search = array('%40', '%2C');
$replace = array('@', ',');
$mail_parms = array();
foreach ($params as $var => $value) {
switch ($var) {
case 'cc':
case 'bcc':
case 'followupto':
if (!empty($value))
$mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value));
break;
case 'subject':
case 'newsgroups':
$mail_parms[] = $var . '=' . rawurlencode($value);
break;
case 'extra':
case 'text':
$$var = $value;
default:
}
}
$mail_parm_vals = '';
for ($i = 0; $i < count($mail_parms); $i++) {
$mail_parm_vals .= (0 == $i) ? '?' : '&';
$mail_parm_vals .= $mail_parms[$i];
}
$address .= $mail_parm_vals;
$encode = (empty($params['encode'])) ? 'none' : $params['encode'];
if (!in_array($encode, array('javascript', 'javascript_charcode', 'hex', 'none'))) {
trigger_error("mailto: 'encode' parameter must be none, javascript or hex",E_USER_WARNING);
return;
}
if ($encode == 'javascript') {
$string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');';
$js_encode = '';
for ($x = 0; $x < strlen($string); $x++) {
$js_encode .= '%' . bin2hex($string[$x]);
}
return '<script type="text/javascript">eval(unescape(\'' . $js_encode . '\'))</script>';
} elseif ($encode == 'javascript_charcode') {
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
for($x = 0, $y = strlen($string); $x < $y; $x++) {
$ord[] = ord($string[$x]);
}
$_ret = "<script type=\"text/javascript\" language=\"javascript\">\n";
$_ret .= "<!--\n";
$_ret .= "{document.write(String.fromCharCode(";
$_ret .= implode(',', $ord);
$_ret .= "))";
$_ret .= "}\n";
$_ret .= "//-->\n";
$_ret .= "</script>\n";
return $_ret;
} elseif ($encode == 'hex') {
preg_match('!^(.*)(\?.*)$!', $address, $match);
if (!empty($match[2])) {
trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.",E_USER_WARNING);
return;
}
$address_encode = '';
for ($x = 0; $x < strlen($address); $x++) {
if (preg_match('!\w!', $address[$x])) {
$address_encode .= '%' . bin2hex($address[$x]);
} else {
$address_encode .= $address[$x];
}
}
$text_encode = '';
for ($x = 0; $x < strlen($text); $x++) {
$text_encode .= '&#x' . bin2hex($text[$x]) . ';';
}
$mailto = "&#109;&#97;&#105;&#108;&#116;&#111;&#58;";
return '<a href="' . $mailto . $address_encode . '" ' . $extra . '>' . $text_encode . '</a>';
} else {
// no encoding
return '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
}
}
?>

View file

@ -0,0 +1,83 @@
<?php
/**
* Smarty plugin
*
* This plugin is only for Smarty2 BC
* @package Smarty
* @subpackage PluginsFunction
*/
/**
* Smarty {math} function plugin
*
* Type: function<br>
* Name: math<br>
* Purpose: handle math computations in template<br>
* @link http://smarty.php.net/manual/en/language.function.math.php {math}
* (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param array $params parameters
* @param object $template template object
* @return string|null
*/
function smarty_function_math($params, $template)
{
// be sure equation parameter is present
if (empty($params['equation'])) {
trigger_error("math: missing equation parameter",E_USER_WARNING);
return;
}
$equation = $params['equation'];
// make sure parenthesis are balanced
if (substr_count($equation,"(") != substr_count($equation,")")) {
trigger_error("math: unbalanced parenthesis",E_USER_WARNING);
return;
}
// match all vars in equation, make sure all are passed
preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!",$equation, $match);
$allowed_funcs = array('int','abs','ceil','cos','exp','floor','log','log10',
'max','min','pi','pow','rand','round','sin','sqrt','srand','tan');
foreach($match[1] as $curr_var) {
if ($curr_var && !in_array($curr_var, array_keys($params)) && !in_array($curr_var, $allowed_funcs)) {
trigger_error("math: function call $curr_var not allowed",E_USER_WARNING);
return;
}
}
foreach($params as $key => $val) {
if ($key != "equation" && $key != "format" && $key != "assign") {
// make sure value is not empty
if (strlen($val)==0) {
trigger_error("math: parameter $key is empty",E_USER_WARNING);
return;
}
if (!is_numeric($val)) {
trigger_error("math: parameter $key: is not numeric",E_USER_WARNING);
return;
}
$equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
}
}
$smarty_math_result = null;
eval("\$smarty_math_result = ".$equation.";");
if (empty($params['format'])) {
if (empty($params['assign'])) {
return $smarty_math_result;
} else {
$template->assign($params['assign'],$smarty_math_result);
}
} else {
if (empty($params['assign'])){
printf($params['format'],$smarty_math_result);
} else {
$template->assign($params['assign'],sprintf($params['format'],$smarty_math_result));
}
}
}
?>

View 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;
}
?>

View file

@ -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);
}
}
?>

View 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"]);
}
}
?>

View file

@ -0,0 +1,37 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsModifier
*/
/**
* Smarty capitalize modifier plugin
*
* Type: modifier<br>
* Name: capitalize<br>
* Purpose: capitalize words in the string
*
* @link
* @author Monte Ohrt <monte at ohrt dot com>
* @param string $
* @return string
*/
function smarty_modifier_capitalize($string, $uc_digits = false)
{
// uppercase with php function ucwords
$upper_string = ucwords($string);
// check for any missed hyphenated words
$upper_string = preg_replace("!(^|[^\p{L}'])([\p{Ll}])!ue", "'\\1'.ucfirst('\\2')", $upper_string);
// check uc_digits case
if (!$uc_digits) {
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!u", $string, $matches, PREG_OFFSET_CAPTURE)) {
foreach($matches[1] as $match)
$upper_string = substr_replace($upper_string, $match[0], $match[1], strlen($match[0]));
}
}
return $upper_string;
}
?>

View 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;
}
?>

View file

@ -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);
}
?>

View file

@ -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));
}
?>

View file

@ -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);
}
?>

View file

@ -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);
}
?>

View 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;
}
?>

View file

@ -0,0 +1,61 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsModifier
*/
/**
* Smarty date_format modifier plugin
*
* Type: modifier<br>
* Name: date_format<br>
* Purpose: format datestamps via strftime<br>
* Input:<br>
* - string: input date string
* - format: strftime format for output
* - default_date: default date if $string is empty
*
* @link http://smarty.php.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param string $
* @param string $
* @param string $
* @return string |void
* @uses smarty_make_timestamp()
*/
function smarty_modifier_date_format($string, $format = SMARTY_RESOURCE_DATE_FORMAT, $default_date = '',$formatter='auto')
{
/**
* Include the {@link shared.make_timestamp.php} plugin
*/
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
if ($string != '') {
$timestamp = smarty_make_timestamp($string);
} elseif ($default_date != '') {
$timestamp = smarty_make_timestamp($default_date);
} else {
return;
}
if($formatter=='strftime'||($formatter=='auto'&&strpos($format,'%')!==false)) {
if (DS == '\\') {
$_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
if (strpos($format, '%e') !== false) {
$_win_from[] = '%e';
$_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
}
if (strpos($format, '%l') !== false) {
$_win_from[] = '%l';
$_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
}
$format = str_replace($_win_from, $_win_to, $format);
}
return strftime($format, $timestamp);
} else {
return date($format, $timestamp);
}
}
?>

View file

@ -0,0 +1,87 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage Debug
*/
/**
* Smarty debug_print_var modifier plugin
*
* Type: modifier<br>
* Name: debug_print_var<br>
* Purpose: formats variable contents for display in the console
*
* @link http://smarty.php.net/manual/en/language.modifier.debug.print.var.php debug_print_var (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param array $ |object
* @param integer $
* @param integer $
* @return string
*/
function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40)
{
$_replace = array("\n" => '<i>\n</i>',
"\r" => '<i>\r</i>',
"\t" => '<i>\t</i>'
);
switch (gettype($var)) {
case 'array' :
$results = '<b>Array (' . count($var) . ')</b>';
foreach ($var as $curr_key => $curr_val) {
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2)
. '<b>' . strtr($curr_key, $_replace) . '</b> =&gt; '
. 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('&nbsp;', $depth * 2)
. '<b> -&gt;' . strtr($curr_key, $_replace) . '</b> = '
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
$depth--;
}
break;
case 'boolean' :
case 'NULL' :
case 'resource' :
if (true === $var) {
$results = 'true';
} elseif (false === $var) {
$results = 'false';
} elseif (null === $var) {
$results = 'null';
} else {
$results = htmlspecialchars((string) $var);
}
$results = '<i>' . $results . '</i>';
break;
case 'integer' :
case 'float' :
$results = htmlspecialchars((string) $var);
break;
case 'string' :
$results = strtr($var, $_replace);
if (strlen($var) > $length) {
$results = substr($var, 0, $length - 3) . '...';
}
$results = htmlspecialchars('"' . $results . '"');
break;
case 'unknown type' :
default :
$results = strtr((string) $var, $_replace);
if (strlen($results) > $length) {
$results = substr($results, 0, $length - 3) . '...';
}
$results = htmlspecialchars($results);
}
return $results;
}
?>

View 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;
}
?>

View 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"));
}
?>

View 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: */
?>

View file

@ -0,0 +1,91 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsModifier
*/
/**
* Smarty escape modifier plugin
*
* Type: modifier<br>
* Name: escape<br>
* Purpose: escape string for output
*
* @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 string $esc_type escape type
* @param string $char_set character set
* @return string escaped input string
*/
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = SMARTY_RESOURCE_CHAR_SET)
{
switch ($esc_type) {
case 'html':
return htmlspecialchars($string, ENT_QUOTES, $char_set);
case 'htmlall':
return htmlentities($string, ENT_QUOTES, $char_set);
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 character into hex
$return = '';
for ($x = 0; $x < strlen($string); $x++) {
$return .= '%' . bin2hex($string[$x]);
}
return $return;
case 'hexentity':
$return = '';
for ($x = 0; $x < strlen($string); $x++) {
$return .= '&#x' . bin2hex($string[$x]) . ';';
}
return $return;
case 'decentity':
$return = '';
for ($x = 0; $x < strlen($string); $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':
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
return smarty_mb_str_replace(array('@', '.'), array(' [AT] ', ' [DOT] '), $string);
case 'nonstd':
// escape non-standard chars, such as ms document quotes
$_res = '';
for($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) {
$_ord = ord(substr($string, $_i, 1));
// non-standard char, escape it
if ($_ord >= 126) {
$_res .= '&#' . $_ord . ';';
} else {
$_res .= substr($string, $_i, 1);
}
}
return $_res;
default:
return $string;
}
}
?>

View file

@ -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: */
?>

View 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: */
?>

View 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);
}
?>

View 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);
}
}
?>

View 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: */
?>

View 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: */
?>

View 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 '';
}
?>

View file

@ -0,0 +1,46 @@
<?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
* @param string|array
* @param string|array
* @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);
}
function _smarty_regex_replace_check($search)
{
if (($pos = strpos($search,"\0")) !== false)
$search = substr($search,0,$pos);
if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
/* remove eval-modifier from $search */
$search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]);
}
return $search;
}
?>

View file

@ -0,0 +1,29 @@
<?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 $
* @param string $
* @param string $
* @return string
*/
function smarty_modifier_replace($string, $search, $replace)
{
require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
return smarty_mb_str_replace($search, $replace, $string);
}
?>

View file

@ -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: */
?>

View file

@ -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, ',', ' ');
}
?>

View file

@ -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, ',', ' ');
}
?>

View file

@ -0,0 +1,37 @@
<?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 $
* @param string $
* @return string
*/
function smarty_modifier_spacify($string, $spacify_char = ' ')
{
// mb_ functions available?
if (function_exists('mb_strlen') && mb_detect_encoding($string, 'UTF-8, ISO-8859-1') === 'UTF-8') {
$strlen = mb_strlen($string);
while ($strlen) {
$array[] = mb_substr($string, 0, 1, "UTF-8");
$string = mb_substr($string, 1, $strlen, "UTF-8");
$strlen = mb_strlen($string);
}
return implode($spacify_char, $array);
} else {
return implode($spacify_char, preg_split('//', $string, -1));
}
}
?>

View file

@ -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];
}
?>

View 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: */
?>

View 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: */
?>

View file

@ -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);
}
?>

View 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:"&nbsp;"}
* 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);
}
?>

View file

@ -0,0 +1,31 @@
<?php
/**
* Smarty plugin
*
* @package Smarty
* @subpackage PluginsModifier
*/
/**
* Smarty strip_tags modifier plugin
*
* Type: modifier<br>
* Name: strip_tags<br>
* Purpose: strip html tags from text
*
* @link http://smarty.php.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com>
* @param string $
* @param boolean $
* @return string
*/
function smarty_modifier_strip_tags($string, $replace_with_space = true)
{
if ($replace_with_space) {
return preg_replace('!<[^>]*?>!', ' ', $string);
} else {
return strip_tags($string);
}
}
?>

Some files were not shown because too many files have changed in this diff Show more