Fix linting
This commit is contained in:
parent
5b17a7dbd7
commit
1614145b18
262 changed files with 45324 additions and 42695 deletions
|
|
@ -1,60 +1,61 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
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;
|
||||
}
|
||||
?>
|
||||
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" />';
|
||||
|
||||
// no break
|
||||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,29 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
switch($OPT['type'])
|
||||
{
|
||||
switch ($OPT['type']) {
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
|
||||
$api = array('mysql' => 'mysqli_connect', 'postgresql' => 'pg_connect');
|
||||
if(!function_exists($api[$OPT['type']])) trigger_error('API introuvable',E_USER_ERROR);
|
||||
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));
|
||||
}
|
||||
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']);
|
||||
define('DB_TYPE', $OPT['type']);
|
||||
break;
|
||||
|
||||
default: trigger_error('Base de donnee inconnue',E_USER_ERROR);
|
||||
default: trigger_error('Base de donnee inconnue', E_USER_ERROR);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,163 +1,196 @@
|
|||
<?php
|
||||
|
||||
class BDD
|
||||
{
|
||||
public $connected;
|
||||
|
||||
private $session;
|
||||
|
||||
private $reponse;
|
||||
|
||||
public $host;
|
||||
|
||||
public $user;
|
||||
|
||||
private $password;
|
||||
|
||||
public $database;
|
||||
|
||||
public $num_rows;
|
||||
|
||||
public $nodb;
|
||||
|
||||
|
||||
public function __construct($profile=null)
|
||||
{
|
||||
var $connected;
|
||||
if ($profile === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
private $session;
|
||||
global $db_config;
|
||||
|
||||
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);
|
||||
if (empty($profile)) {
|
||||
if (!$db_config['profile']) {
|
||||
return false;
|
||||
}
|
||||
$profile = &$db_config['profile'];
|
||||
}
|
||||
|
||||
function connexion($host,$user,$pass,$db=NULL)
|
||||
{
|
||||
if($this->session) $this->deconnexion();
|
||||
if (!ctype_alnum($profile)) {
|
||||
trigger_error('Le nom du profil contient des caracteres illegaux', E_USER_ERROR);
|
||||
}
|
||||
|
||||
$this->reponse = NULL;
|
||||
if ($db_config['profile']) {
|
||||
require(ONYX.'db/'.$profile.'.profile.php');
|
||||
|
||||
$this->session = mysqli_connect($host,$user,$pass);
|
||||
$db = &$___profile['db'];
|
||||
$host = &$___profile['host'];
|
||||
$user = &$___profile['user'];
|
||||
$pass = &$___profile['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;
|
||||
}
|
||||
if ($db_config['crypt']) {
|
||||
$pass = dbpass($pass, $db_config['crypt']);
|
||||
}
|
||||
|
||||
mysqli_query($this->session,'SET CHARACTER SET "utf8"');
|
||||
|
||||
$this->host = $host;
|
||||
$this->user = $user;
|
||||
$this->password = $pass;
|
||||
if($db) $this->db($db);
|
||||
|
||||
$this->connected = TRUE;
|
||||
}
|
||||
|
||||
function reconnexion()
|
||||
{
|
||||
if(!empty($this->host) && !empty($this->user) && !empty($this->password) && !empty($this->database)) $this->connexion($this->host,$this->user,$this->password,$this->database);
|
||||
}
|
||||
|
||||
function deconnexion()
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
$r = mysqli_close($this->session);
|
||||
$this->session = FALSE;
|
||||
$this->connected = FALSE;
|
||||
return $r;
|
||||
}
|
||||
|
||||
function erreur()
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
return mysqli_error($this->session);
|
||||
}
|
||||
|
||||
function db($db=NULL)
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
return $this->database = mysqli_select_db($this->session,$db) ? $db : $this->database;
|
||||
}
|
||||
|
||||
function escape(&$var)
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
$var = mysqli_real_escape_string($this->session,$var);
|
||||
return $var;
|
||||
}
|
||||
|
||||
function query($query)
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
$this->reponse = mysqli_query($this->session,$query);
|
||||
|
||||
global $db_config;
|
||||
|
||||
if(!$this->reponse && $db_config['log']) elog('Erreur Mysql: " '.$this->erreur().' ", avec la requète: { '.$query.' }.',1);
|
||||
|
||||
$this->num_rows = @mysqli_num_rows($this->reponse);
|
||||
|
||||
if($this->num_rows == 0) return NULL;
|
||||
|
||||
elseif($this->num_rows >= 1)
|
||||
{
|
||||
for($i=0; $var = mysqli_fetch_assoc($this->reponse); $i++) $sortie[$i] = $var;
|
||||
return $sortie;
|
||||
}
|
||||
|
||||
else return FALSE;
|
||||
}
|
||||
|
||||
function unique_query($query)
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
$this->reponse = mysqli_query($this->session,$query);
|
||||
|
||||
global $db_config;
|
||||
|
||||
if(!$this->reponse && $db_config['log']) elog('Erreur Mysql: " '.$this->erreur().' ", avec la requète: { '.$query.' }.',1);
|
||||
|
||||
$this->num_rows = @mysqli_num_rows($this->reponse);
|
||||
|
||||
if($this->num_rows == 0) return NULL;
|
||||
|
||||
elseif($this->num_rows >= 1) return mysqli_fetch_assoc($this->reponse);
|
||||
|
||||
else return FALSE;
|
||||
}
|
||||
|
||||
function affected()
|
||||
{
|
||||
if(!$this->session) return FALSE;
|
||||
|
||||
return mysqli_affected_rows($this->session);
|
||||
}
|
||||
return $this->connexion($host, $user, $pass, $db);
|
||||
}
|
||||
?>
|
||||
|
||||
public function connexion($host, $user, $pass, $db=null)
|
||||
{
|
||||
if ($this->session) {
|
||||
$this->deconnexion();
|
||||
}
|
||||
|
||||
$this->reponse = null;
|
||||
|
||||
$this->session = mysqli_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;
|
||||
}
|
||||
|
||||
mysqli_query($this->session, 'SET CHARACTER SET "utf8"');
|
||||
|
||||
$this->host = $host;
|
||||
$this->user = $user;
|
||||
$this->password = $pass;
|
||||
if ($db) {
|
||||
$this->db($db);
|
||||
}
|
||||
|
||||
$this->connected = true;
|
||||
}
|
||||
|
||||
public function reconnexion()
|
||||
{
|
||||
if (!empty($this->host) && !empty($this->user) && !empty($this->password) && !empty($this->database)) {
|
||||
$this->connexion($this->host, $this->user, $this->password, $this->database);
|
||||
}
|
||||
}
|
||||
|
||||
public function deconnexion()
|
||||
{
|
||||
if (!$this->session) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$r = mysqli_close($this->session);
|
||||
$this->session = false;
|
||||
$this->connected = false;
|
||||
return $r;
|
||||
}
|
||||
|
||||
public function erreur()
|
||||
{
|
||||
if (!$this->session) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mysqli_error($this->session);
|
||||
}
|
||||
|
||||
public function db($db=null)
|
||||
{
|
||||
if (!$this->session) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->database = mysqli_select_db($this->session, $db) ? $db : $this->database;
|
||||
}
|
||||
|
||||
public function escape(&$var)
|
||||
{
|
||||
if (!$this->session) {
|
||||
return false;
|
||||
}
|
||||
$var = mysqli_real_escape_string($this->session, $var);
|
||||
return $var;
|
||||
}
|
||||
|
||||
public function query($query)
|
||||
{
|
||||
if (!$this->session) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->reponse = mysqli_query($this->session, $query);
|
||||
|
||||
global $db_config;
|
||||
|
||||
if (!$this->reponse && $db_config['log']) {
|
||||
elog('Erreur Mysql: " '.$this->erreur().' ", avec la requète: { '.$query.' }.', 1);
|
||||
}
|
||||
|
||||
$this->num_rows = @mysqli_num_rows($this->reponse);
|
||||
|
||||
if ($this->num_rows == 0) {
|
||||
return null;
|
||||
} elseif ($this->num_rows >= 1) {
|
||||
for ($i=0; $var = mysqli_fetch_assoc($this->reponse); $i++) {
|
||||
$sortie[$i] = $var;
|
||||
}
|
||||
return $sortie;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function unique_query($query)
|
||||
{
|
||||
if (!$this->session) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$this->reponse = mysqli_query($this->session, $query);
|
||||
|
||||
global $db_config;
|
||||
|
||||
if (!$this->reponse && $db_config['log']) {
|
||||
elog('Erreur Mysql: " '.$this->erreur().' ", avec la requète: { '.$query.' }.', 1);
|
||||
}
|
||||
|
||||
$this->num_rows = @mysqli_num_rows($this->reponse);
|
||||
|
||||
if ($this->num_rows == 0) {
|
||||
return null;
|
||||
} elseif ($this->num_rows >= 1) {
|
||||
return mysqli_fetch_assoc($this->reponse);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public function affected()
|
||||
{
|
||||
if (!$this->session) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return mysqli_affected_rows($this->session);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,168 +1,199 @@
|
|||
<?php
|
||||
|
||||
class BDD
|
||||
{
|
||||
public $connected;
|
||||
|
||||
private $session;
|
||||
|
||||
private $reponse;
|
||||
|
||||
public $host;
|
||||
|
||||
public $user;
|
||||
|
||||
private $password;
|
||||
|
||||
public $database;
|
||||
|
||||
public $num_rows;
|
||||
|
||||
public $nodb;
|
||||
|
||||
|
||||
public function __construct($profile=null)
|
||||
{
|
||||
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;
|
||||
if ($profile === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
global $db_config;
|
||||
global $db_config;
|
||||
|
||||
if(empty($profile))
|
||||
{
|
||||
if(!$db_config['profile']) return FALSE;
|
||||
$profile = &$db_config['profile'];
|
||||
}
|
||||
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 (!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');
|
||||
if ($db_config['profile']) {
|
||||
require(ONYX.'db/'.$profile.'.profile.php');
|
||||
|
||||
$db = &$___profile['db'];
|
||||
$host = &$___profile['host'];
|
||||
$user = &$___profile['user'];
|
||||
$pass = &$___profile['pass'];
|
||||
}
|
||||
$db = &$___profile['db'];
|
||||
$host = &$___profile['host'];
|
||||
$user = &$___profile['user'];
|
||||
$pass = &$___profile['pass'];
|
||||
}
|
||||
|
||||
if($db_config['crypt']) $pass = dbpass($pass,$db_config['crypt']);
|
||||
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;
|
||||
}
|
||||
|
||||
function reconnexion()
|
||||
{
|
||||
if(!empty($this->host) && !empty($this->user) && !empty($this->password) && !empty($this->database)) $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);
|
||||
}
|
||||
return $this->connexion($host, $user, $pass, $db);
|
||||
}
|
||||
?>
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
public function reconnexion()
|
||||
{
|
||||
if (!empty($this->host) && !empty($this->user) && !empty($this->password) && !empty($this->database)) {
|
||||
$this->connexion($this->host, $this->user, $this->password, $this->database);
|
||||
}
|
||||
}
|
||||
|
||||
public function deconnexion()
|
||||
{
|
||||
if (!$this->session) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$r = pg_close($this->session);
|
||||
$this->session = false;
|
||||
$this->connected = false;
|
||||
return $r;
|
||||
}
|
||||
|
||||
public function erreur()
|
||||
{
|
||||
if (!$this->session) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return pg_last_error($this->session);
|
||||
}
|
||||
|
||||
public function db($db)
|
||||
{
|
||||
if (!$this->session) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->database = pg_query($this->session, "\\connect ".pg_escape_string($db)) ? $db : $this->database;
|
||||
}
|
||||
|
||||
public function escape(&$var)
|
||||
{
|
||||
if (!$this->session) {
|
||||
return false;
|
||||
}
|
||||
$var = pg_escape_string($this->session, $var);
|
||||
return $var;
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
}
|
||||
|
||||
public 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;
|
||||
}
|
||||
}
|
||||
|
||||
public function affected()
|
||||
{
|
||||
if (!$this->session) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return pg_affected_rows($this->reponse);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,42 +1,41 @@
|
|||
<?php
|
||||
|
||||
if(!defined("ONYX")) exit;
|
||||
|
||||
if(!empty($OPT["type"]) && time() > $OPT["start"] && (empty($OPT["auto_end"]) || time() <= $OPT["start"] + $OPT["duree"]))
|
||||
{
|
||||
$template = new Template();
|
||||
$template->assign('date', utf8_encode(strftime("%A %d %B %Y %H:%M")));
|
||||
$template->assign('datehb', utf8_encode(str_replace('.', '', strftime("/%a %d %b %Y/%H%M %S"))));
|
||||
$template->assign("link", array_map("url", $VAR["link"]));
|
||||
$template->assign("url_serveur", $_SERVER["HTTP_HOST"]);
|
||||
$template->assign("url_images", $VAR["url_images"]);
|
||||
$template->assign("header", Cache::read("headerNB"));
|
||||
$template->assign("LANG", $LANG);
|
||||
|
||||
$template->assign('titre', $LANG["modules"]["fermerServeur"][$OPT['type']]["titre"]);
|
||||
if (!empty($OPT['auto_end']))
|
||||
{
|
||||
$reste = ($OPT["start"] + $OPT["duree"]) - time();
|
||||
$min = floor($reste/60);
|
||||
if ($min > 1)
|
||||
$reste = "Il reste ".$min." minutes";
|
||||
elseif ($min == 1)
|
||||
$reste = "Il reste ".$min." minute";
|
||||
else
|
||||
$reste = "Il reste ".$reste." secondes";
|
||||
$reste .= " de maintenance";
|
||||
}
|
||||
else
|
||||
{
|
||||
if (empty($OPT["duree"]))
|
||||
$reste = "La maintenance doit durer quelques minutes";
|
||||
else
|
||||
$reste = "La maintenance doit durer environ ".ceil($OPT["duree"]/60)." minutes";
|
||||
}
|
||||
|
||||
$template->assign('texte', str_replace('$main_serveur', $VAR["main_serveur"], str_replace('$server_name', $VAR["serveur_name"], str_replace('$reste', $reste, $LANG["modules"]["fermerServeur"][$OPT['type']]["texte"]))));
|
||||
|
||||
$template->display('cms/maj.tpl');
|
||||
exit;
|
||||
if (!defined("ONYX")) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($OPT["type"]) && time() > $OPT["start"] && (empty($OPT["auto_end"]) || time() <= $OPT["start"] + $OPT["duree"])) {
|
||||
$template = new Template();
|
||||
$template->assign('date', utf8_encode(strftime("%A %d %B %Y %H:%M")));
|
||||
$template->assign('datehb', utf8_encode(str_replace('.', '', strftime("/%a %d %b %Y/%H%M %S"))));
|
||||
$template->assign("link", array_map("url", $VAR["link"]));
|
||||
$template->assign("url_serveur", $_SERVER["HTTP_HOST"]);
|
||||
$template->assign("url_images", $VAR["url_images"]);
|
||||
$template->assign("header", Cache::read("headerNB"));
|
||||
$template->assign("LANG", $LANG);
|
||||
|
||||
$template->assign('titre', $LANG["modules"]["fermerServeur"][$OPT['type']]["titre"]);
|
||||
if (!empty($OPT['auto_end'])) {
|
||||
$reste = ($OPT["start"] + $OPT["duree"]) - time();
|
||||
$min = floor($reste/60);
|
||||
if ($min > 1) {
|
||||
$reste = "Il reste ".$min." minutes";
|
||||
} elseif ($min == 1) {
|
||||
$reste = "Il reste ".$min." minute";
|
||||
} else {
|
||||
$reste = "Il reste ".$reste." secondes";
|
||||
}
|
||||
$reste .= " de maintenance";
|
||||
} else {
|
||||
if (empty($OPT["duree"])) {
|
||||
$reste = "La maintenance doit durer quelques minutes";
|
||||
} else {
|
||||
$reste = "La maintenance doit durer environ ".ceil($OPT["duree"]/60)." minutes";
|
||||
}
|
||||
}
|
||||
|
||||
$template->assign('texte', str_replace('$main_serveur', $VAR["main_serveur"], str_replace('$server_name', $VAR["serveur_name"], str_replace('$reste', $reste, $LANG["modules"]["fermerServeur"][$OPT['type']]["texte"]))));
|
||||
|
||||
$template->display('cms/maj.tpl');
|
||||
exit;
|
||||
}
|
||||
?>
|
||||
|
|
@ -1,26 +1,27 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if(!is_readable(ONYX.'lang/'.$OPT['type'].'.xml')) trigger_error('Fichier de langue introuvable',E_USER_ERROR);
|
||||
if (!is_readable(ONYX.'lang/'.$OPT['type'].'.xml')) {
|
||||
trigger_error('Fichier de langue introuvable', E_USER_ERROR);
|
||||
}
|
||||
|
||||
define('LANG', $OPT['type']);
|
||||
|
||||
$langdoc = Cache::read('traduction'.LANG);
|
||||
if ($langdoc['check'] != md5_file(ONYX.'lang/'.LANG.'.xml'))
|
||||
{
|
||||
$langdoc = new DOMDocument();
|
||||
if ($langdoc['check'] != md5_file(ONYX.'lang/'.LANG.'.xml')) {
|
||||
$langdoc = new DOMDocument();
|
||||
|
||||
$langdoc->load(ONYX.'lang/'.LANG.'.xml') or trigger_error('Erreur du fichier de langue',E_USER_ERROR);
|
||||
$langdoc->normalizeDocument();
|
||||
$langdoc->load(ONYX.'lang/'.LANG.'.xml') or trigger_error('Erreur du fichier de langue', E_USER_ERROR);
|
||||
$langdoc->normalizeDocument();
|
||||
|
||||
$LANG = parse_config($langdoc->documentElement);
|
||||
$LANG = parse_config($langdoc->documentElement);
|
||||
|
||||
Cache::set('traduction'.LANG, array(LANG => $LANG, 'check' => md5_file(ONYX.'lang/'.LANG.'.xml')));
|
||||
}
|
||||
else
|
||||
Cache::set('traduction'.LANG, array(LANG => $LANG, 'check' => md5_file(ONYX.'lang/'.LANG.'.xml')));
|
||||
} else {
|
||||
$LANG = $langdoc[LANG];
|
||||
}
|
||||
|
||||
unset($langdoc);
|
||||
|
||||
?>
|
||||
|
|
@ -8,4 +8,3 @@ $auth->acl($user->data);
|
|||
$user->setup();
|
||||
|
||||
unset($phpbb_root_path, $phpEx);
|
||||
?>
|
||||
|
|
@ -1,31 +1,31 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
$pistage = false;
|
||||
$file = null;
|
||||
|
||||
if (!empty($OPT['ips']))
|
||||
{
|
||||
$ips = explode(';', $OPT['ips']);
|
||||
if (in_array($_SERVER["REMOTE_ADDR"], $ips))
|
||||
$pistage = true;
|
||||
if (!empty($OPT['ips'])) {
|
||||
$ips = explode(';', $OPT['ips']);
|
||||
if (in_array($_SERVER["REMOTE_ADDR"], $ips)) {
|
||||
$pistage = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($OPT['ids']))
|
||||
{
|
||||
$SESS = new Session();
|
||||
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";
|
||||
}
|
||||
$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);
|
||||
if ($pistage) {
|
||||
elog(var_export($_REQUEST, true), 0, ONYX."log/users", $file);
|
||||
}
|
||||
|
||||
unset($pistage, $SESS, $ips, $ids);
|
||||
?>
|
||||
|
|
@ -1,11 +1,11 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if(defined('DB_TYPE'))
|
||||
{
|
||||
switch(DB_TYPE)
|
||||
{
|
||||
if (defined('DB_TYPE')) {
|
||||
switch (DB_TYPE) {
|
||||
case 'mysql':
|
||||
case 'postgresql':
|
||||
|
||||
|
|
@ -14,7 +14,6 @@ if(defined('DB_TYPE'))
|
|||
require_once(DB_TYPE.'.class.php');
|
||||
break;
|
||||
|
||||
default: trigger_error('Base de donnee inconnue',E_USER_ERROR);
|
||||
default: trigger_error('Base de donnee inconnue', E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
?>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,153 +1,163 @@
|
|||
<?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= 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,uid,time,ip,var,level,active) VALUES(0x$sess_cookie,0x00,$time,0x$ip,$level,0,1) ");
|
||||
setcookie($session_config['cookie'],base64_encode(hexstr($this->cookie)),time() + $session_config['time'], '/');
|
||||
}
|
||||
class Session
|
||||
{
|
||||
private $cookie;
|
||||
|
||||
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");
|
||||
|
||||
$this->db->deconnexion();
|
||||
}
|
||||
private $db;
|
||||
|
||||
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");
|
||||
public $level = 0;
|
||||
|
||||
public $values = array();
|
||||
|
||||
public 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= 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,uid,time,ip,var,level,active) VALUES(0x$sess_cookie,0x00,$time,0x$ip,$level,0,1) ");
|
||||
setcookie($session_config['cookie'], base64_encode(hexstr($this->cookie)), time() + $session_config['time'], '/');
|
||||
}
|
||||
|
||||
public 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");
|
||||
|
||||
$this->db->deconnexion();
|
||||
}
|
||||
|
||||
public 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;
|
||||
|
||||
}
|
||||
$this->db->deconnexion();
|
||||
|
||||
setcookie($session_config['cookie'], '', 0);
|
||||
|
||||
$this->values = array();
|
||||
$this->level = 0;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,153 +1,163 @@
|
|||
<?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']);
|
||||
}
|
||||
class Session
|
||||
{
|
||||
private $cookie;
|
||||
|
||||
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();
|
||||
}
|
||||
private $db;
|
||||
|
||||
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");
|
||||
public $level = 0;
|
||||
|
||||
public $values = array();
|
||||
|
||||
public 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']);
|
||||
}
|
||||
|
||||
public 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();
|
||||
}
|
||||
|
||||
public 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;
|
||||
|
||||
}
|
||||
$this->db->deconnexion();
|
||||
|
||||
setcookie($session_config['cookie'], '', 0);
|
||||
|
||||
$this->values = array();
|
||||
$this->level = 0;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,27 +1,29 @@
|
|||
<?php
|
||||
|
||||
if(!defined('ONYX')) exit;
|
||||
if (!defined('ONYX')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
define('SMARTY_DIR',ONYX.'modules/templates/smarty/');
|
||||
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']);
|
||||
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 $template_dir = _TEMPLATE_DIR;
|
||||
var $compile_dir = _TEMPLATE_COMPILE;
|
||||
var $config_dir = _TEMPLATE_CONFIG;
|
||||
var $cache_dir = _TEMPLATE_CACHE;
|
||||
{
|
||||
public $template_dir = _TEMPLATE_DIR;
|
||||
public $compile_dir = _TEMPLATE_COMPILE;
|
||||
public $config_dir = _TEMPLATE_CONFIG;
|
||||
public $cache_dir = _TEMPLATE_CACHE;
|
||||
|
||||
var $compile_check = false;
|
||||
var $force_compile = true;
|
||||
|
||||
function set_template($i = null) {}
|
||||
}
|
||||
|
||||
?>
|
||||
public $compile_check = false;
|
||||
public $force_compile = true;
|
||||
|
||||
public function set_template($i = null)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
*
|
||||
* For questions, help, comments, discussion, etc., please join the
|
||||
* Smarty mailing list. Send a blank e-mail to
|
||||
* smarty-discussion-subscribe@googlegroups.com
|
||||
* smarty-discussion-subscribe@googlegroups.com
|
||||
*
|
||||
* @link http://www.smarty.net/
|
||||
* @version 2.6.25-dev
|
||||
|
|
@ -35,7 +35,8 @@
|
|||
* Config file reading class
|
||||
* @package Smarty
|
||||
*/
|
||||
class Config_File {
|
||||
class Config_File
|
||||
{
|
||||
/**#@+
|
||||
* Options
|
||||
* @var boolean
|
||||
|
|
@ -43,29 +44,29 @@ class Config_File {
|
|||
/**
|
||||
* Controls whether variables with the same name overwrite each other.
|
||||
*/
|
||||
var $overwrite = true;
|
||||
public $overwrite = true;
|
||||
|
||||
/**
|
||||
* Controls whether config values of on/true/yes and off/false/no get
|
||||
* converted to boolean values automatically.
|
||||
*/
|
||||
var $booleanize = true;
|
||||
public $booleanize = true;
|
||||
|
||||
/**
|
||||
* Controls whether hidden config sections/vars are read from the file.
|
||||
*/
|
||||
var $read_hidden = true;
|
||||
public $read_hidden = true;
|
||||
|
||||
/**
|
||||
* Controls whether or not to fix mac or dos formatted newlines.
|
||||
* If set to true, \r or \r\n will be changed to \n.
|
||||
*/
|
||||
var $fix_newlines = true;
|
||||
public $fix_newlines = true;
|
||||
/**#@-*/
|
||||
|
||||
/** @access private */
|
||||
var $_config_path = "";
|
||||
var $_config_data = array();
|
||||
public $_config_path = "";
|
||||
public $_config_data = array();
|
||||
/**#@-*/
|
||||
|
||||
/**
|
||||
|
|
@ -73,10 +74,11 @@ class Config_File {
|
|||
*
|
||||
* @param string $config_path (optional) path to the config files
|
||||
*/
|
||||
public function __construct($config_path = NULL)
|
||||
public function __construct($config_path = null)
|
||||
{
|
||||
if (isset($config_path))
|
||||
if (isset($config_path)) {
|
||||
$this->set_path($config_path);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -85,14 +87,14 @@ class Config_File {
|
|||
*
|
||||
* @param string $config_path path to the config files
|
||||
*/
|
||||
function set_path($config_path)
|
||||
public function set_path($config_path)
|
||||
{
|
||||
if (!empty($config_path)) {
|
||||
if (!is_string($config_path) || !file_exists($config_path) || !is_dir($config_path)) {
|
||||
$this->_trigger_error_msg("Bad config file path '$config_path'");
|
||||
return;
|
||||
}
|
||||
if(substr($config_path, -1) != DIRECTORY_SEPARATOR) {
|
||||
if (substr($config_path, -1) != DIRECTORY_SEPARATOR) {
|
||||
$config_path .= DIRECTORY_SEPARATOR;
|
||||
}
|
||||
|
||||
|
|
@ -109,34 +111,37 @@ class Config_File {
|
|||
* @param string $var_name (optional) variable to get info for
|
||||
* @return string|array a value or array of values
|
||||
*/
|
||||
function get($file_name, $section_name = NULL, $var_name = NULL)
|
||||
public function get($file_name, $section_name = null, $var_name = null)
|
||||
{
|
||||
if (empty($file_name)) {
|
||||
$this->_trigger_error_msg('Empty config file name');
|
||||
return;
|
||||
} else {
|
||||
$file_name = $this->_config_path . $file_name;
|
||||
if (!isset($this->_config_data[$file_name]))
|
||||
if (!isset($this->_config_data[$file_name])) {
|
||||
$this->load_file($file_name, false);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($var_name)) {
|
||||
if (empty($section_name)) {
|
||||
return $this->_config_data[$file_name]["vars"][$var_name];
|
||||
} else {
|
||||
if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]))
|
||||
if (isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name])) {
|
||||
return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name];
|
||||
else
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (empty($section_name)) {
|
||||
return (array)$this->_config_data[$file_name]["vars"];
|
||||
} else {
|
||||
if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"]))
|
||||
if (isset($this->_config_data[$file_name]["sections"][$section_name]["vars"])) {
|
||||
return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"];
|
||||
else
|
||||
} else {
|
||||
return array();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -149,7 +154,7 @@ class Config_File {
|
|||
* @return string|array same as get()
|
||||
* @uses get() retrieves information from config file and returns it
|
||||
*/
|
||||
function &get_key($config_key)
|
||||
public function &get_key($config_key)
|
||||
{
|
||||
list($file_name, $section_name, $var_name) = explode('/', $config_key, 3);
|
||||
$result = &$this->get($file_name, $section_name, $var_name);
|
||||
|
|
@ -161,7 +166,7 @@ class Config_File {
|
|||
*
|
||||
* @return array an array of loaded config file names
|
||||
*/
|
||||
function get_file_names()
|
||||
public function get_file_names()
|
||||
{
|
||||
return array_keys($this->_config_data);
|
||||
}
|
||||
|
|
@ -173,7 +178,7 @@ class Config_File {
|
|||
* @param string $file_name config file to get section names from
|
||||
* @return array an array of section names from the specified file
|
||||
*/
|
||||
function get_section_names($file_name)
|
||||
public function get_section_names($file_name)
|
||||
{
|
||||
$file_name = $this->_config_path . $file_name;
|
||||
if (!isset($this->_config_data[$file_name])) {
|
||||
|
|
@ -192,20 +197,21 @@ class Config_File {
|
|||
* @param string $section_name (optional) section to get info for
|
||||
* @return array an array of variables names from the specified file/section
|
||||
*/
|
||||
function get_var_names($file_name, $section = NULL)
|
||||
public function get_var_names($file_name, $section = null)
|
||||
{
|
||||
if (empty($file_name)) {
|
||||
$this->_trigger_error_msg('Empty config file name');
|
||||
return;
|
||||
} else if (!isset($this->_config_data[$file_name])) {
|
||||
} elseif (!isset($this->_config_data[$file_name])) {
|
||||
$this->_trigger_error_msg("Unknown config file '$file_name'");
|
||||
return;
|
||||
}
|
||||
|
||||
if (empty($section))
|
||||
if (empty($section)) {
|
||||
return array_keys($this->_config_data[$file_name]["vars"]);
|
||||
else
|
||||
} else {
|
||||
return array_keys($this->_config_data[$file_name]["sections"][$section]["vars"]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -214,12 +220,13 @@ class Config_File {
|
|||
*
|
||||
* @param string $file_name file to clear config data for
|
||||
*/
|
||||
function clear($file_name = NULL)
|
||||
public function clear($file_name = null)
|
||||
{
|
||||
if ($file_name === NULL)
|
||||
if ($file_name === null) {
|
||||
$this->_config_data = array();
|
||||
else if (isset($this->_config_data[$file_name]))
|
||||
} elseif (isset($this->_config_data[$file_name])) {
|
||||
$this->_config_data[$file_name] = array();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -230,12 +237,13 @@ class Config_File {
|
|||
* @param boolean $prepend_path whether current config path should be
|
||||
* prepended to the filename
|
||||
*/
|
||||
function load_file($file_name, $prepend_path = true)
|
||||
public function load_file($file_name, $prepend_path = true)
|
||||
{
|
||||
if ($prepend_path && $this->_config_path != "")
|
||||
if ($prepend_path && $this->_config_path != "") {
|
||||
$config_file = $this->_config_path . $file_name;
|
||||
else
|
||||
} else {
|
||||
$config_file = $file_name;
|
||||
}
|
||||
|
||||
ini_set('track_errors', true);
|
||||
$fp = @fopen($config_file, "r");
|
||||
|
|
@ -257,7 +265,7 @@ class Config_File {
|
|||
* @param string $config_file file name of the related contents
|
||||
* @param string $contents the file-contents to parse
|
||||
*/
|
||||
function set_file_contents($config_file, $contents)
|
||||
public function set_file_contents($config_file, $contents)
|
||||
{
|
||||
$this->_config_data[$config_file] = $this->parse_contents($contents);
|
||||
return true;
|
||||
|
|
@ -268,9 +276,9 @@ class Config_File {
|
|||
*
|
||||
* @param string $contents the file-contents to parse
|
||||
*/
|
||||
function parse_contents($contents)
|
||||
public function parse_contents($contents)
|
||||
{
|
||||
if($this->fix_newlines) {
|
||||
if ($this->fix_newlines) {
|
||||
// fix mac/dos formatted newlines
|
||||
$contents = preg_replace('!\r\n?!', "\n", $contents);
|
||||
}
|
||||
|
|
@ -287,9 +295,11 @@ class Config_File {
|
|||
$lines = $match[0];
|
||||
for ($i=0, $count=count($lines); $i<$count; $i++) {
|
||||
$line = $lines[$i];
|
||||
if (empty($line)) continue;
|
||||
if (empty($line)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ( substr($line, 0, 1) == '[' && preg_match('!^\[(.*?)\]!', $line, $match) ) {
|
||||
if (substr($line, 0, 1) == '[' && preg_match('!^\[(.*?)\]!', $line, $match)) {
|
||||
/* section found */
|
||||
if (substr($match[1], 0, 1) == '.') {
|
||||
/* hidden section */
|
||||
|
|
@ -301,11 +311,12 @@ class Config_File {
|
|||
$vars = array();
|
||||
continue;
|
||||
}
|
||||
} else {
|
||||
} else {
|
||||
$section_name = $match[1];
|
||||
}
|
||||
if (!isset($config_data['sections'][$section_name]))
|
||||
if (!isset($config_data['sections'][$section_name])) {
|
||||
$config_data['sections'][$section_name] = array('vars' => array());
|
||||
}
|
||||
$vars =& $config_data['sections'][$section_name]['vars'];
|
||||
continue;
|
||||
}
|
||||
|
|
@ -327,12 +338,10 @@ class Config_File {
|
|||
}
|
||||
}
|
||||
$booleanize = false;
|
||||
|
||||
} else {
|
||||
/* handle simple value */
|
||||
$var_value = preg_replace('/^([\'"])(.*)\1$/', '\2', rtrim($match[2]));
|
||||
$booleanize = $this->booleanize;
|
||||
|
||||
}
|
||||
$this->_set_config_var($vars, $var_name, $var_value, $booleanize);
|
||||
}
|
||||
|
|
@ -349,13 +358,14 @@ class Config_File {
|
|||
* @param boolean $booleanize determines whether $var_value is converted to
|
||||
* to true/false
|
||||
*/
|
||||
function _set_config_var(&$container, $var_name, $var_value, $booleanize)
|
||||
public function _set_config_var(&$container, $var_name, $var_value, $booleanize)
|
||||
{
|
||||
if (substr($var_name, 0, 1) == '.') {
|
||||
if (!$this->read_hidden)
|
||||
if (!$this->read_hidden) {
|
||||
return;
|
||||
else
|
||||
} else {
|
||||
$var_name = substr($var_name, 1);
|
||||
}
|
||||
}
|
||||
|
||||
if (!preg_match("/^[a-zA-Z_]\w*$/", $var_name)) {
|
||||
|
|
@ -364,15 +374,16 @@ class Config_File {
|
|||
}
|
||||
|
||||
if ($booleanize) {
|
||||
if (preg_match("/^(on|true|yes)$/i", $var_value))
|
||||
if (preg_match("/^(on|true|yes)$/i", $var_value)) {
|
||||
$var_value = true;
|
||||
else if (preg_match("/^(off|false|no)$/i", $var_value))
|
||||
} elseif (preg_match("/^(off|false|no)$/i", $var_value)) {
|
||||
$var_value = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($container[$var_name]) || $this->overwrite)
|
||||
if (!isset($container[$var_name]) || $this->overwrite) {
|
||||
$container[$var_name] = $var_value;
|
||||
else {
|
||||
} else {
|
||||
settype($container[$var_name], 'array');
|
||||
$container[$var_name][] = $var_value;
|
||||
}
|
||||
|
|
@ -383,11 +394,9 @@ class Config_File {
|
|||
* @param string $error_msg
|
||||
* @param integer $error_type one of
|
||||
*/
|
||||
function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING)
|
||||
public function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING)
|
||||
{
|
||||
trigger_error("Config_File error: $error_msg", $error_type);
|
||||
}
|
||||
/**#@-*/
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
File diff suppressed because it is too large
Load diff
|
|
@ -21,7 +21,6 @@ function smarty_core_assemble_plugin_filepath($params, &$smarty)
|
|||
$_return = false;
|
||||
|
||||
foreach ((array)$smarty->plugins_dir as $_plugin_dir) {
|
||||
|
||||
$_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
|
||||
|
||||
// see if path is relative
|
||||
|
|
@ -40,16 +39,15 @@ function smarty_core_assemble_plugin_filepath($params, &$smarty)
|
|||
}
|
||||
}
|
||||
|
||||
if($_return === false) {
|
||||
if ($_return === false) {
|
||||
// still not found, try PHP include_path
|
||||
if(isset($_relative_paths)) {
|
||||
if (isset($_relative_paths)) {
|
||||
foreach ((array)$_relative_paths as $_plugin_dir) {
|
||||
|
||||
$_plugin_filepath = $_plugin_dir . DIRECTORY_SEPARATOR . $_plugin_filename;
|
||||
|
||||
$_params = array('file_path' => $_plugin_filepath);
|
||||
require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
|
||||
if(smarty_core_get_include_path($_params, $smarty)) {
|
||||
if (smarty_core_get_include_path($_params, $smarty)) {
|
||||
$_return = $_params['new_file_path'];
|
||||
break;
|
||||
}
|
||||
|
|
@ -61,5 +59,3 @@ function smarty_core_assemble_plugin_filepath($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -16,28 +16,26 @@
|
|||
*/
|
||||
function smarty_core_assign_smarty_interface($params, &$smarty)
|
||||
{
|
||||
if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars['request'])) {
|
||||
return;
|
||||
}
|
||||
if (isset($smarty->_smarty_vars) && isset($smarty->_smarty_vars['request'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$_globals_map = array('g' => 'HTTP_GET_VARS',
|
||||
$_globals_map = array('g' => 'HTTP_GET_VARS',
|
||||
'p' => 'HTTP_POST_VARS',
|
||||
'c' => 'HTTP_COOKIE_VARS',
|
||||
's' => 'HTTP_SERVER_VARS',
|
||||
'e' => 'HTTP_ENV_VARS');
|
||||
|
||||
$_smarty_vars_request = array();
|
||||
$_smarty_vars_request = array();
|
||||
|
||||
foreach (preg_split('!!', strtolower($smarty->request_vars_order)) as $_c) {
|
||||
if (isset($_globals_map[$_c])) {
|
||||
$_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]);
|
||||
}
|
||||
foreach (preg_split('!!', strtolower($smarty->request_vars_order)) as $_c) {
|
||||
if (isset($_globals_map[$_c])) {
|
||||
$_smarty_vars_request = array_merge($_smarty_vars_request, $GLOBALS[$_globals_map[$_c]]);
|
||||
}
|
||||
$_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']);
|
||||
}
|
||||
$_smarty_vars_request = @array_merge($_smarty_vars_request, $GLOBALS['HTTP_SESSION_VARS']);
|
||||
|
||||
$smarty->_smarty_vars['request'] = $_smarty_vars_request;
|
||||
$smarty->_smarty_vars['request'] = $_smarty_vars_request;
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -23,29 +23,27 @@ function smarty_core_create_dir_structure($params, &$smarty)
|
|||
$_dir = $params['dir'];
|
||||
$_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY);
|
||||
$_new_dir = (substr($_dir, 0, 1)=='/') ? '/' : getcwd().'/';
|
||||
if($_use_open_basedir = !empty($_open_basedir_ini)) {
|
||||
if ($_use_open_basedir = !empty($_open_basedir_ini)) {
|
||||
$_open_basedirs = explode(':', $_open_basedir_ini);
|
||||
}
|
||||
|
||||
} else {
|
||||
/* other-style paths */
|
||||
$_dir = str_replace('\\','/', $params['dir']);
|
||||
$_dir = str_replace('\\', '/', $params['dir']);
|
||||
$_dir_parts = preg_split('!/+!', $_dir, -1, PREG_SPLIT_NO_EMPTY);
|
||||
if (preg_match('!^((//)|([a-zA-Z]:/))!', $_dir, $_root_dir)) {
|
||||
/* leading "//" for network volume, or "[letter]:/" for full path */
|
||||
$_new_dir = $_root_dir[1];
|
||||
/* remove drive-letter from _dir_parts */
|
||||
if (isset($_root_dir[3])) array_shift($_dir_parts);
|
||||
|
||||
if (isset($_root_dir[3])) {
|
||||
array_shift($_dir_parts);
|
||||
}
|
||||
} else {
|
||||
$_new_dir = str_replace('\\', '/', getcwd()).'/';
|
||||
|
||||
}
|
||||
|
||||
if($_use_open_basedir = !empty($_open_basedir_ini)) {
|
||||
if ($_use_open_basedir = !empty($_open_basedir_ini)) {
|
||||
$_open_basedirs = explode(';', str_replace('\\', '/', $_open_basedir_ini));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* all paths use "/" only from here */
|
||||
|
|
@ -75,5 +73,3 @@ function smarty_core_create_dir_structure($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -19,10 +19,10 @@ function smarty_core_display_debug_console($params, &$smarty)
|
|||
// we must force compile the debug template in case the environment
|
||||
// changed between separate applications.
|
||||
|
||||
if(empty($smarty->debug_tpl)) {
|
||||
if (empty($smarty->debug_tpl)) {
|
||||
// set path to debug template from SMARTY_DIR
|
||||
$smarty->debug_tpl = SMARTY_DIR . 'debug.tpl';
|
||||
if($smarty->security && is_file($smarty->debug_tpl)) {
|
||||
if ($smarty->security && is_file($smarty->debug_tpl)) {
|
||||
$smarty->secure_dir[] = realpath($smarty->debug_tpl);
|
||||
}
|
||||
$smarty->debug_tpl = 'file:' . SMARTY_DIR . 'debug.tpl';
|
||||
|
|
@ -38,8 +38,7 @@ function smarty_core_display_debug_console($params, &$smarty)
|
|||
$smarty->_compile_id = null;
|
||||
|
||||
$_compile_path = $smarty->_get_compile_path($smarty->debug_tpl);
|
||||
if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path))
|
||||
{
|
||||
if ($smarty->_compile_resource($smarty->debug_tpl, $_compile_path)) {
|
||||
ob_start();
|
||||
$smarty->_include($_compile_path);
|
||||
$_results = ob_get_contents();
|
||||
|
|
@ -57,5 +56,3 @@ function smarty_core_display_debug_console($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -20,19 +20,19 @@ function smarty_core_get_include_path(&$params, &$smarty)
|
|||
{
|
||||
static $_path_array = null;
|
||||
|
||||
if(!isset($_path_array)) {
|
||||
if (!isset($_path_array)) {
|
||||
$_ini_include_path = ini_get('include_path');
|
||||
|
||||
if(strstr($_ini_include_path,';')) {
|
||||
if (strstr($_ini_include_path, ';')) {
|
||||
// windows pathnames
|
||||
$_path_array = explode(';',$_ini_include_path);
|
||||
$_path_array = explode(';', $_ini_include_path);
|
||||
} else {
|
||||
$_path_array = explode(':',$_ini_include_path);
|
||||
$_path_array = explode(':', $_ini_include_path);
|
||||
}
|
||||
}
|
||||
foreach ($_path_array as $_include_path) {
|
||||
if (@is_readable($_include_path . DIRECTORY_SEPARATOR . $params['file_path'])) {
|
||||
$params['new_file_path'] = $_include_path . DIRECTORY_SEPARATOR . $params['file_path'];
|
||||
$params['new_file_path'] = $_include_path . DIRECTORY_SEPARATOR . $params['file_path'];
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
@ -40,5 +40,3 @@ function smarty_core_get_include_path(&$params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -19,5 +19,3 @@ function smarty_core_get_microtime($params, &$smarty)
|
|||
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -17,7 +17,6 @@
|
|||
|
||||
function smarty_core_get_php_resource(&$params, &$smarty)
|
||||
{
|
||||
|
||||
$params['resource_base_path'] = $smarty->trusted_dir;
|
||||
$smarty->_parse_resource_name($params, $smarty);
|
||||
|
||||
|
|
@ -27,22 +26,24 @@ function smarty_core_get_php_resource(&$params, &$smarty)
|
|||
|
||||
if ($params['resource_type'] == 'file') {
|
||||
$_readable = false;
|
||||
if(file_exists($params['resource_name']) && is_readable($params['resource_name'])) {
|
||||
if (file_exists($params['resource_name']) && is_readable($params['resource_name'])) {
|
||||
$_readable = true;
|
||||
} else {
|
||||
// test for file in include_path
|
||||
$_params = array('file_path' => $params['resource_name']);
|
||||
require_once(SMARTY_CORE_DIR . 'core.get_include_path.php');
|
||||
if(smarty_core_get_include_path($_params, $smarty)) {
|
||||
if (smarty_core_get_include_path($_params, $smarty)) {
|
||||
$_include_path = $_params['new_file_path'];
|
||||
$_readable = true;
|
||||
}
|
||||
}
|
||||
} else if ($params['resource_type'] != 'file') {
|
||||
} elseif ($params['resource_type'] != 'file') {
|
||||
$_template_source = null;
|
||||
$_readable = is_callable($smarty->_plugins['resource'][$params['resource_type']][0][0])
|
||||
&& call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][0],
|
||||
array($params['resource_name'], &$_template_source, &$smarty));
|
||||
&& call_user_func_array(
|
||||
$smarty->_plugins['resource'][$params['resource_type']][0][0],
|
||||
array($params['resource_name'], &$_template_source, &$smarty)
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -76,5 +77,3 @@ function smarty_core_get_php_resource(&$params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -25,17 +25,17 @@ function smarty_core_is_secure($params, &$smarty)
|
|||
$_rp = realpath($params['resource_name']);
|
||||
if (isset($params['resource_base_path'])) {
|
||||
foreach ((array)$params['resource_base_path'] as $curr_dir) {
|
||||
if ( ($_cd = realpath($curr_dir)) !== false &&
|
||||
if (($_cd = realpath($curr_dir)) !== false &&
|
||||
strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
|
||||
substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) {
|
||||
substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!empty($smarty->secure_dir)) {
|
||||
foreach ((array)$smarty->secure_dir as $curr_dir) {
|
||||
if ( ($_cd = realpath($curr_dir)) !== false) {
|
||||
if($_cd == $_rp) {
|
||||
if (($_cd = realpath($curr_dir)) !== false) {
|
||||
if ($_cd == $_rp) {
|
||||
return true;
|
||||
} elseif (strncmp($_rp, $_cd, strlen($_cd)) == 0 &&
|
||||
substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR) {
|
||||
|
|
@ -48,12 +48,11 @@ function smarty_core_is_secure($params, &$smarty)
|
|||
// resource is not on local file system
|
||||
return call_user_func_array(
|
||||
$smarty->_plugins['resource'][$params['resource_type']][0][2],
|
||||
array($params['resource_name'], &$smarty));
|
||||
array($params['resource_name'], &$smarty)
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -22,26 +22,25 @@ function smarty_core_is_trusted($params, &$smarty)
|
|||
if (!empty($smarty->trusted_dir)) {
|
||||
$_rp = realpath($params['resource_name']);
|
||||
foreach ((array)$smarty->trusted_dir as $curr_dir) {
|
||||
if (!empty($curr_dir) && is_readable ($curr_dir)) {
|
||||
if (!empty($curr_dir) && is_readable($curr_dir)) {
|
||||
$_cd = realpath($curr_dir);
|
||||
if (strncmp($_rp, $_cd, strlen($_cd)) == 0
|
||||
&& substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR ) {
|
||||
&& substr($_rp, strlen($_cd), 1) == DIRECTORY_SEPARATOR) {
|
||||
$_smarty_trusted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// resource is not on local file system
|
||||
$_smarty_trusted = call_user_func_array($smarty->_plugins['resource'][$params['resource_type']][0][3],
|
||||
array($params['resource_name'], $smarty));
|
||||
$_smarty_trusted = call_user_func_array(
|
||||
$smarty->_plugins['resource'][$params['resource_type']][0][3],
|
||||
array($params['resource_name'], $smarty)
|
||||
);
|
||||
}
|
||||
|
||||
return $_smarty_trusted;
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
function smarty_core_load_plugins($params, &$smarty)
|
||||
{
|
||||
|
||||
foreach ($params['plugins'] as $_plugin_info) {
|
||||
list($_type, $_name, $_tpl_file, $_tpl_line, $_delayed_loading) = $_plugin_info;
|
||||
$_plugin = &$smarty->_plugins[$_type][$_name];
|
||||
|
|
@ -38,11 +37,13 @@ function smarty_core_load_plugins($params, &$smarty)
|
|||
$_plugin[1] = $_tpl_file;
|
||||
$_plugin[2] = $_tpl_line;
|
||||
$_plugin[3] = true;
|
||||
if (!isset($_plugin[4])) $_plugin[4] = true; /* cacheable */
|
||||
if (!isset($_plugin[4])) {
|
||||
$_plugin[4] = true;
|
||||
} /* cacheable */
|
||||
}
|
||||
}
|
||||
continue;
|
||||
} else if ($_type == 'insert') {
|
||||
} elseif ($_type == 'insert') {
|
||||
/*
|
||||
* For backwards compatibility, we check for insert functions in
|
||||
* the symbol table before trying to load them as a plugin.
|
||||
|
|
@ -78,7 +79,7 @@ function smarty_core_load_plugins($params, &$smarty)
|
|||
* In case of insert plugins, their code may be loaded later via
|
||||
* 'script' attribute.
|
||||
*/
|
||||
else if ($_type == 'insert' && $_delayed_loading) {
|
||||
elseif ($_type == 'insert' && $_delayed_loading) {
|
||||
$_plugin_func = 'smarty_' . $_type . '_' . $_name;
|
||||
$_found = true;
|
||||
}
|
||||
|
|
@ -103,7 +104,7 @@ function smarty_core_load_plugins($params, &$smarty)
|
|||
$_found = true;
|
||||
}
|
||||
}
|
||||
} else if ($_type == 'function') {
|
||||
} elseif ($_type == 'function') {
|
||||
/*
|
||||
* This is a catch-all situation.
|
||||
*/
|
||||
|
|
@ -121,5 +122,3 @@ function smarty_core_load_plugins($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -70,5 +70,3 @@ function smarty_core_load_resource_plugin($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -13,8 +13,11 @@
|
|||
*/
|
||||
function smarty_core_process_cached_inserts($params, &$smarty)
|
||||
{
|
||||
preg_match_all('!'.$smarty->_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis',
|
||||
$params['results'], $match);
|
||||
preg_match_all(
|
||||
'!'.$smarty->_smarty_md5.'{insert_cache (.*)}'.$smarty->_smarty_md5.'!Uis',
|
||||
$params['results'],
|
||||
$match
|
||||
);
|
||||
list($cached_inserts, $insert_args) = $match;
|
||||
|
||||
for ($i = 0, $for_max = count($cached_inserts); $i < $for_max; $i++) {
|
||||
|
|
@ -30,7 +33,7 @@ function smarty_core_process_cached_inserts($params, &$smarty)
|
|||
if (isset($args['script'])) {
|
||||
$_params = array('resource_name' => $smarty->_dequote($args['script']));
|
||||
require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
|
||||
if(!smarty_core_get_php_resource($_params, $smarty)) {
|
||||
if (!smarty_core_get_php_resource($_params, $smarty)) {
|
||||
return false;
|
||||
}
|
||||
$resource_type = $_params['resource_type'];
|
||||
|
|
@ -67,5 +70,3 @@ function smarty_core_process_cached_inserts($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -26,12 +26,12 @@ function smarty_core_process_compiled_include($params, &$smarty)
|
|||
}
|
||||
|
||||
foreach ($smarty->_cache_info['cache_serials'] as $_include_file_path=>$_cache_serial) {
|
||||
$_return = preg_replace_callback('!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s',
|
||||
array(&$smarty, '_process_compiled_include_callback'),
|
||||
$_return);
|
||||
$_return = preg_replace_callback(
|
||||
'!(\{nocache\:('.$_cache_serial.')#(\d+)\})!s',
|
||||
array(&$smarty, '_process_compiled_include_callback'),
|
||||
$_return
|
||||
);
|
||||
}
|
||||
$smarty->_cache_including = $_cache_including;
|
||||
return $_return;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -34,8 +34,10 @@ function smarty_core_read_cache_file(&$params, &$smarty)
|
|||
|
||||
if (!empty($smarty->cache_handler_func)) {
|
||||
// use cache_handler function
|
||||
call_user_func_array($smarty->cache_handler_func,
|
||||
array('read', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null));
|
||||
call_user_func_array(
|
||||
$smarty->cache_handler_func,
|
||||
array('read', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], null)
|
||||
);
|
||||
} else {
|
||||
// use local cache file
|
||||
$_auto_id = $smarty->_get_auto_id($params['cache_id'], $params['compile_id']);
|
||||
|
|
@ -54,7 +56,7 @@ function smarty_core_read_cache_file(&$params, &$smarty)
|
|||
$_cache_info = unserialize(substr($_contents, $_info_start, $_info_len));
|
||||
$params['results'] = substr($_contents, $_info_start + $_info_len);
|
||||
|
||||
if ($smarty->caching == 2 && isset ($_cache_info['expires'])){
|
||||
if ($smarty->caching == 2 && isset($_cache_info['expires'])) {
|
||||
// caching by expiration time
|
||||
if ($_cache_info['expires'] > -1 && (time() > $_cache_info['expires'])) {
|
||||
// cache expired, regenerate
|
||||
|
|
@ -97,5 +99,3 @@ function smarty_core_read_cache_file(&$params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -19,10 +19,11 @@
|
|||
|
||||
function smarty_core_rm_auto($params, &$smarty)
|
||||
{
|
||||
if (!@is_dir($params['auto_base']))
|
||||
return false;
|
||||
if (!@is_dir($params['auto_base'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!isset($params['auto_id']) && !isset($params['auto_source'])) {
|
||||
if (!isset($params['auto_id']) && !isset($params['auto_source'])) {
|
||||
$_params = array(
|
||||
'dirname' => $params['auto_base'],
|
||||
'level' => 0,
|
||||
|
|
@ -33,11 +34,12 @@ function smarty_core_rm_auto($params, &$smarty)
|
|||
} else {
|
||||
$_tname = $smarty->_get_auto_filename($params['auto_base'], $params['auto_source'], $params['auto_id']);
|
||||
|
||||
if(isset($params['auto_source'])) {
|
||||
if (isset($params['auto_source'])) {
|
||||
if (isset($params['extensions'])) {
|
||||
$_res = false;
|
||||
foreach ((array)$params['extensions'] as $_extension)
|
||||
foreach ((array)$params['extensions'] as $_extension) {
|
||||
$_res |= $smarty->_unlink($_tname.$_extension, $params['exp_time']);
|
||||
}
|
||||
} else {
|
||||
$_res = $smarty->_unlink($_tname, $params['exp_time']);
|
||||
}
|
||||
|
|
@ -54,7 +56,7 @@ function smarty_core_rm_auto($params, &$smarty)
|
|||
$_handle = opendir($params['auto_base']);
|
||||
$_res = true;
|
||||
while (false !== ($_filename = readdir($_handle))) {
|
||||
if($_filename == '.' || $_filename == '..') {
|
||||
if ($_filename == '.' || $_filename == '..') {
|
||||
continue;
|
||||
} elseif (substr($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, 0, strlen($_tname)) == $_tname) {
|
||||
$_res &= (bool)$smarty->_unlink($params['auto_base'] . DIRECTORY_SEPARATOR . $_filename, $params['exp_time']);
|
||||
|
|
@ -67,5 +69,3 @@ function smarty_core_rm_auto($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -19,11 +19,14 @@
|
|||
|
||||
function smarty_core_rmdir($params, &$smarty)
|
||||
{
|
||||
if(!isset($params['level'])) { $params['level'] = 1; }
|
||||
if(!isset($params['exp_time'])) { $params['exp_time'] = null; }
|
||||
|
||||
if($_handle = @opendir($params['dirname'])) {
|
||||
if (!isset($params['level'])) {
|
||||
$params['level'] = 1;
|
||||
}
|
||||
if (!isset($params['exp_time'])) {
|
||||
$params['exp_time'] = null;
|
||||
}
|
||||
|
||||
if ($_handle = @opendir($params['dirname'])) {
|
||||
while (false !== ($_entry = readdir($_handle))) {
|
||||
if ($_entry != '.' && $_entry != '..') {
|
||||
if (@is_dir($params['dirname'] . DIRECTORY_SEPARATOR . $_entry)) {
|
||||
|
|
@ -33,22 +36,18 @@ function smarty_core_rmdir($params, &$smarty)
|
|||
'exp_time' => $params['exp_time']
|
||||
);
|
||||
smarty_core_rmdir($_params, $smarty);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$smarty->_unlink($params['dirname'] . DIRECTORY_SEPARATOR . $_entry, $params['exp_time']);
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($_handle);
|
||||
}
|
||||
|
||||
if ($params['level']) {
|
||||
return @rmdir($params['dirname']);
|
||||
}
|
||||
return (bool)$_handle;
|
||||
}
|
||||
|
||||
if ($params['level']) {
|
||||
return @rmdir($params['dirname']);
|
||||
}
|
||||
return (bool)$_handle;
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@
|
|||
*/
|
||||
function smarty_core_run_insert_handler($params, &$smarty)
|
||||
{
|
||||
|
||||
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
|
||||
if ($smarty->debugging) {
|
||||
$_params = array();
|
||||
|
|
@ -35,7 +34,7 @@ function smarty_core_run_insert_handler($params, &$smarty)
|
|||
if (isset($params['args']['script'])) {
|
||||
$_params = array('resource_name' => $smarty->_dequote($params['args']['script']));
|
||||
require_once(SMARTY_CORE_DIR . 'core.get_php_resource.php');
|
||||
if(!smarty_core_get_php_resource($_params, $smarty)) {
|
||||
if (!smarty_core_get_php_resource($_params, $smarty)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -67,5 +66,3 @@ function smarty_core_run_insert_handler($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -46,5 +46,3 @@ function smarty_core_smarty_include_php($params, &$smarty)
|
|||
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ function smarty_core_write_cache_file($params, &$smarty)
|
|||
|
||||
// put timestamp in cache header
|
||||
$smarty->_cache_info['timestamp'] = time();
|
||||
if ($smarty->cache_lifetime > -1){
|
||||
if ($smarty->cache_lifetime > -1) {
|
||||
// expiration set
|
||||
$smarty->_cache_info['expires'] = $smarty->_cache_info['timestamp'] + $smarty->cache_lifetime;
|
||||
} else {
|
||||
|
|
@ -50,7 +50,9 @@ function smarty_core_write_cache_file($params, &$smarty)
|
|||
$level--;
|
||||
unset($results[$i]);
|
||||
} else { // opening tag
|
||||
if ($level++ > 0) unset($results[$i]);
|
||||
if ($level++ > 0) {
|
||||
unset($results[$i]);
|
||||
}
|
||||
}
|
||||
$j++;
|
||||
} elseif ($level > 0) {
|
||||
|
|
@ -67,14 +69,16 @@ function smarty_core_write_cache_file($params, &$smarty)
|
|||
|
||||
if (!empty($smarty->cache_handler_func)) {
|
||||
// use cache_handler function
|
||||
call_user_func_array($smarty->cache_handler_func,
|
||||
array('write', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], $smarty->_cache_info['expires']));
|
||||
call_user_func_array(
|
||||
$smarty->cache_handler_func,
|
||||
array('write', &$smarty, &$params['results'], $params['tpl_file'], $params['cache_id'], $params['compile_id'], $smarty->_cache_info['expires'])
|
||||
);
|
||||
} else {
|
||||
// use local cache file
|
||||
|
||||
if(!@is_writable($smarty->cache_dir)) {
|
||||
if (!@is_writable($smarty->cache_dir)) {
|
||||
// cache_dir not writable, see if it exists
|
||||
if(!@is_dir($smarty->cache_dir)) {
|
||||
if (!@is_dir($smarty->cache_dir)) {
|
||||
$smarty->trigger_error('the $cache_dir \'' . $smarty->cache_dir . '\' does not exist, or is not a directory.', E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -92,5 +96,3 @@ function smarty_core_write_cache_file($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -18,11 +18,17 @@ function smarty_core_write_compiled_include($params, &$smarty)
|
|||
$_tag_start = 'if \(\$this->caching && \!\$this->_cache_including\)\: echo \'\{nocache\:('.$params['cache_serial'].')#(\d+)\}\'; endif;';
|
||||
$_tag_end = 'if \(\$this->caching && \!\$this->_cache_including\)\: echo \'\{/nocache\:(\\2)#(\\3)\}\'; endif;';
|
||||
|
||||
preg_match_all('!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
|
||||
$params['compiled_content'], $_match_source, PREG_SET_ORDER);
|
||||
preg_match_all(
|
||||
'!('.$_tag_start.'(.*)'.$_tag_end.')!Us',
|
||||
$params['compiled_content'],
|
||||
$_match_source,
|
||||
PREG_SET_ORDER
|
||||
);
|
||||
|
||||
// no nocache-parts found: done
|
||||
if (count($_match_source)==0) return;
|
||||
if (count($_match_source)==0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// convert the matched php-code to functions
|
||||
$_include_compiled = "<?php /* Smarty version ".$smarty->_version.", created on ".strftime("%Y-%m-%d %H:%M:%S")."\n";
|
||||
|
|
@ -53,7 +59,9 @@ function smarty_core_write_compiled_include($params, &$smarty)
|
|||
} else {
|
||||
$open_tag .= $token;
|
||||
}
|
||||
if ($open_tag == '<?php ') break;
|
||||
if ($open_tag == '<?php ') {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for ($i=0, $count = count($tokens); $i < $count; $i++) {
|
||||
|
|
@ -62,7 +70,7 @@ function smarty_core_write_compiled_include($params, &$smarty)
|
|||
$tokens[$i] = '$' . $this_varname;
|
||||
} else {
|
||||
$tokens[$i] = $tokens[$i][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$source = implode('', $tokens);
|
||||
|
|
@ -86,6 +94,3 @@ $source
|
|||
smarty_core_write_file($_params, $smarty);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -14,9 +14,9 @@
|
|||
*/
|
||||
function smarty_core_write_compiled_resource($params, &$smarty)
|
||||
{
|
||||
if(!@is_writable($smarty->compile_dir)) {
|
||||
if (!@is_writable($smarty->compile_dir)) {
|
||||
// compile_dir not writable, see if it exists
|
||||
if(!@is_dir($smarty->compile_dir)) {
|
||||
if (!@is_dir($smarty->compile_dir)) {
|
||||
$smarty->trigger_error('the $compile_dir \'' . $smarty->compile_dir . '\' does not exist, or is not a directory.', E_USER_ERROR);
|
||||
return false;
|
||||
}
|
||||
|
|
@ -31,5 +31,3 @@ function smarty_core_write_compiled_resource($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ function smarty_core_write_file($params, &$smarty)
|
|||
fclose($fd);
|
||||
|
||||
if (DIRECTORY_SEPARATOR == '\\' || !@rename($_tmp_file, $params['filename'])) {
|
||||
// On platforms and filesystems that cannot overwrite with rename()
|
||||
// On platforms and filesystems that cannot overwrite with rename()
|
||||
// delete the file before renaming it -- because windows always suffers
|
||||
// this, it is short-circuited to avoid the initial rename() attempt
|
||||
@unlink($params['filename']);
|
||||
|
|
@ -50,5 +50,3 @@ function smarty_core_write_file($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
@ -72,32 +72,29 @@ function smarty_block_textformat($params, $content, &$smarty)
|
|||
}
|
||||
|
||||
// split into paragraphs
|
||||
$_paragraphs = preg_split('![\r\n][\r\n]!',$content);
|
||||
$_paragraphs = preg_split('![\r\n][\r\n]!', $content);
|
||||
$_output = '';
|
||||
|
||||
for($_x = 0, $_y = count($_paragraphs); $_x < $_y; $_x++) {
|
||||
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) {
|
||||
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) {
|
||||
if ($indent > 0) {
|
||||
$_paragraphs[$_x] = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraphs[$_x]);
|
||||
}
|
||||
}
|
||||
$_output = implode($wrap_char . $wrap_char, $_paragraphs);
|
||||
|
||||
return $assign ? $smarty->assign($assign, $_output) : $_output;
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -36,5 +36,3 @@ function smarty_compiler_assign($tag_attrs, &$compiler)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -36,5 +36,3 @@ function smarty_function_assign_debug_info($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -26,117 +26,117 @@
|
|||
*/
|
||||
function smarty_function_config_load($params, &$smarty)
|
||||
{
|
||||
if ($smarty->debugging) {
|
||||
$_params = array();
|
||||
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
|
||||
$_debug_start_time = smarty_core_get_microtime($_params, $smarty);
|
||||
}
|
||||
if ($smarty->debugging) {
|
||||
$_params = array();
|
||||
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
|
||||
$_debug_start_time = smarty_core_get_microtime($_params, $smarty);
|
||||
}
|
||||
|
||||
$_file = isset($params['file']) ? $smarty->_dequote($params['file']) : null;
|
||||
$_section = isset($params['section']) ? $smarty->_dequote($params['section']) : null;
|
||||
$_scope = isset($params['scope']) ? $smarty->_dequote($params['scope']) : 'global';
|
||||
$_global = isset($params['global']) ? $smarty->_dequote($params['global']) : false;
|
||||
$_file = isset($params['file']) ? $smarty->_dequote($params['file']) : null;
|
||||
$_section = isset($params['section']) ? $smarty->_dequote($params['section']) : null;
|
||||
$_scope = isset($params['scope']) ? $smarty->_dequote($params['scope']) : 'global';
|
||||
$_global = isset($params['global']) ? $smarty->_dequote($params['global']) : false;
|
||||
|
||||
if (!isset($_file) || strlen($_file) == 0) {
|
||||
$smarty->trigger_error("missing 'file' attribute in config_load tag", E_USER_ERROR, __FILE__, __LINE__);
|
||||
}
|
||||
if (!isset($_file) || strlen($_file) == 0) {
|
||||
$smarty->trigger_error("missing 'file' attribute in config_load tag", E_USER_ERROR, __FILE__, __LINE__);
|
||||
}
|
||||
|
||||
if (isset($_scope)) {
|
||||
if ($_scope != 'local' &&
|
||||
if (isset($_scope)) {
|
||||
if ($_scope != 'local' &&
|
||||
$_scope != 'parent' &&
|
||||
$_scope != 'global') {
|
||||
$smarty->trigger_error("invalid 'scope' attribute value", E_USER_ERROR, __FILE__, __LINE__);
|
||||
}
|
||||
$smarty->trigger_error("invalid 'scope' attribute value", E_USER_ERROR, __FILE__, __LINE__);
|
||||
}
|
||||
} else {
|
||||
if ($_global) {
|
||||
$_scope = 'parent';
|
||||
} else {
|
||||
if ($_global) {
|
||||
$_scope = 'parent';
|
||||
} else {
|
||||
$_scope = 'local';
|
||||
}
|
||||
$_scope = 'local';
|
||||
}
|
||||
}
|
||||
|
||||
$_params = array('resource_name' => $_file,
|
||||
'resource_base_path' => $smarty->config_dir,
|
||||
'get_source' => false);
|
||||
$smarty->_parse_resource_name($_params);
|
||||
$_file_path = $_params['resource_type'] . ':' . $_params['resource_name'];
|
||||
if (isset($_section)) {
|
||||
$_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section);
|
||||
} else {
|
||||
$_compile_file = $smarty->_get_compile_path($_file_path);
|
||||
}
|
||||
|
||||
if ($smarty->force_compile || !file_exists($_compile_file)) {
|
||||
$_compile = true;
|
||||
} elseif ($smarty->compile_check) {
|
||||
$_params = array('resource_name' => $_file,
|
||||
'resource_base_path' => $smarty->config_dir,
|
||||
'get_source' => false);
|
||||
$_compile = $smarty->_fetch_resource_info($_params) &&
|
||||
$_params['resource_timestamp'] > filemtime($_compile_file);
|
||||
} else {
|
||||
$_compile = false;
|
||||
}
|
||||
|
||||
if ($_compile) {
|
||||
// compile config file
|
||||
if (!is_object($smarty->_conf_obj)) {
|
||||
require_once SMARTY_DIR . $smarty->config_class . '.class.php';
|
||||
$smarty->_conf_obj = new $smarty->config_class();
|
||||
$smarty->_conf_obj->overwrite = $smarty->config_overwrite;
|
||||
$smarty->_conf_obj->booleanize = $smarty->config_booleanize;
|
||||
$smarty->_conf_obj->read_hidden = $smarty->config_read_hidden;
|
||||
$smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines;
|
||||
}
|
||||
|
||||
$_params = array('resource_name' => $_file,
|
||||
'resource_base_path' => $smarty->config_dir,
|
||||
'get_source' => false);
|
||||
$smarty->_parse_resource_name($_params);
|
||||
$_file_path = $_params['resource_type'] . ':' . $_params['resource_name'];
|
||||
if (isset($_section))
|
||||
$_compile_file = $smarty->_get_compile_path($_file_path.'|'.$_section);
|
||||
else
|
||||
$_compile_file = $smarty->_get_compile_path($_file_path);
|
||||
|
||||
if($smarty->force_compile || !file_exists($_compile_file)) {
|
||||
$_compile = true;
|
||||
} elseif ($smarty->compile_check) {
|
||||
$_params = array('resource_name' => $_file,
|
||||
'resource_base_path' => $smarty->config_dir,
|
||||
'get_source' => false);
|
||||
$_compile = $smarty->_fetch_resource_info($_params) &&
|
||||
$_params['resource_timestamp'] > filemtime($_compile_file);
|
||||
} else {
|
||||
$_compile = false;
|
||||
}
|
||||
|
||||
if($_compile) {
|
||||
// compile config file
|
||||
if(!is_object($smarty->_conf_obj)) {
|
||||
require_once SMARTY_DIR . $smarty->config_class . '.class.php';
|
||||
$smarty->_conf_obj = new $smarty->config_class();
|
||||
$smarty->_conf_obj->overwrite = $smarty->config_overwrite;
|
||||
$smarty->_conf_obj->booleanize = $smarty->config_booleanize;
|
||||
$smarty->_conf_obj->read_hidden = $smarty->config_read_hidden;
|
||||
$smarty->_conf_obj->fix_newlines = $smarty->config_fix_newlines;
|
||||
}
|
||||
|
||||
$_params = array('resource_name' => $_file,
|
||||
'resource_base_path' => $smarty->config_dir,
|
||||
$_params['get_source'] = true);
|
||||
if (!$smarty->_fetch_resource_info($_params)) {
|
||||
return;
|
||||
}
|
||||
$smarty->_conf_obj->set_file_contents($_file, $_params['source_content']);
|
||||
$_config_vars = array_merge($smarty->_conf_obj->get($_file),
|
||||
$smarty->_conf_obj->get($_file, $_section));
|
||||
if(function_exists('var_export')) {
|
||||
$_output = '<?php $_config_vars = ' . var_export($_config_vars, true) . '; ?>';
|
||||
} else {
|
||||
$_output = '<?php $_config_vars = unserialize(\'' . strtr(serialize($_config_vars),array('\''=>'\\\'', '\\'=>'\\\\')) . '\'); ?>';
|
||||
}
|
||||
$_params = (array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => $_params['resource_timestamp']));
|
||||
require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php');
|
||||
smarty_core_write_compiled_resource($_params, $smarty);
|
||||
if (!$smarty->_fetch_resource_info($_params)) {
|
||||
return;
|
||||
}
|
||||
$smarty->_conf_obj->set_file_contents($_file, $_params['source_content']);
|
||||
$_config_vars = array_merge(
|
||||
$smarty->_conf_obj->get($_file),
|
||||
$smarty->_conf_obj->get($_file, $_section)
|
||||
);
|
||||
if (function_exists('var_export')) {
|
||||
$_output = '<?php $_config_vars = ' . var_export($_config_vars, true) . '; ?>';
|
||||
} else {
|
||||
include($_compile_file);
|
||||
$_output = '<?php $_config_vars = unserialize(\'' . strtr(serialize($_config_vars), array('\''=>'\\\'', '\\'=>'\\\\')) . '\'); ?>';
|
||||
}
|
||||
$_params = (array('compile_path' => $_compile_file, 'compiled_content' => $_output, 'resource_timestamp' => $_params['resource_timestamp']));
|
||||
require_once(SMARTY_CORE_DIR . 'core.write_compiled_resource.php');
|
||||
smarty_core_write_compiled_resource($_params, $smarty);
|
||||
} else {
|
||||
include($_compile_file);
|
||||
}
|
||||
|
||||
if ($smarty->caching) {
|
||||
$smarty->_cache_info['config'][$_file] = true;
|
||||
if ($smarty->caching) {
|
||||
$smarty->_cache_info['config'][$_file] = true;
|
||||
}
|
||||
|
||||
$smarty->_config[0]['vars'] = @array_merge($smarty->_config[0]['vars'], $_config_vars);
|
||||
$smarty->_config[0]['files'][$_file] = true;
|
||||
|
||||
if ($_scope == 'parent') {
|
||||
$smarty->_config[1]['vars'] = @array_merge($smarty->_config[1]['vars'], $_config_vars);
|
||||
$smarty->_config[1]['files'][$_file] = true;
|
||||
} elseif ($_scope == 'global') {
|
||||
for ($i = 1, $for_max = count($smarty->_config); $i < $for_max; $i++) {
|
||||
$smarty->_config[$i]['vars'] = @array_merge($smarty->_config[$i]['vars'], $_config_vars);
|
||||
$smarty->_config[$i]['files'][$_file] = true;
|
||||
}
|
||||
}
|
||||
|
||||
$smarty->_config[0]['vars'] = @array_merge($smarty->_config[0]['vars'], $_config_vars);
|
||||
$smarty->_config[0]['files'][$_file] = true;
|
||||
|
||||
if ($_scope == 'parent') {
|
||||
$smarty->_config[1]['vars'] = @array_merge($smarty->_config[1]['vars'], $_config_vars);
|
||||
$smarty->_config[1]['files'][$_file] = true;
|
||||
} else if ($_scope == 'global') {
|
||||
for ($i = 1, $for_max = count($smarty->_config); $i < $for_max; $i++) {
|
||||
$smarty->_config[$i]['vars'] = @array_merge($smarty->_config[$i]['vars'], $_config_vars);
|
||||
$smarty->_config[$i]['files'][$_file] = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ($smarty->debugging) {
|
||||
$_params = array();
|
||||
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
|
||||
$smarty->_smarty_debug_info[] = array('type' => 'config',
|
||||
if ($smarty->debugging) {
|
||||
$_params = array();
|
||||
require_once(SMARTY_CORE_DIR . 'core.get_microtime.php');
|
||||
$smarty->_smarty_debug_info[] = array('type' => 'config',
|
||||
'filename' => $_file.' ['.$_section.'] '.$_scope,
|
||||
'depth' => $smarty->_inclusion_depth,
|
||||
'exec_time' => smarty_core_get_microtime($_params, $smarty) - $_debug_start_time);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -66,15 +66,13 @@ function smarty_function_counter($params, &$smarty)
|
|||
$counter['direction'] = $params['direction'];
|
||||
}
|
||||
|
||||
if ($counter['direction'] == "down")
|
||||
if ($counter['direction'] == "down") {
|
||||
$counter['count'] -= $counter['skip'];
|
||||
else
|
||||
} else {
|
||||
$counter['count'] += $counter['skip'];
|
||||
}
|
||||
|
||||
return $retval;
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -51,13 +51,13 @@ function smarty_function_cycle($params, &$smarty)
|
|||
$reset = (isset($params['reset'])) ? (bool)$params['reset'] : false;
|
||||
|
||||
if (!in_array('values', array_keys($params))) {
|
||||
if(!isset($cycle_vars[$name]['values'])) {
|
||||
if (!isset($cycle_vars[$name]['values'])) {
|
||||
$smarty->trigger_error("cycle: missing 'values' parameter");
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
if(isset($cycle_vars[$name]['values'])
|
||||
&& $cycle_vars[$name]['values'] != $params['values'] ) {
|
||||
if (isset($cycle_vars[$name]['values'])
|
||||
&& $cycle_vars[$name]['values'] != $params['values']) {
|
||||
$cycle_vars[$name]['index'] = 0;
|
||||
}
|
||||
$cycle_vars[$name]['values'] = $params['values'];
|
||||
|
|
@ -66,16 +66,16 @@ function smarty_function_cycle($params, &$smarty)
|
|||
if (isset($params['delimiter'])) {
|
||||
$cycle_vars[$name]['delimiter'] = $params['delimiter'];
|
||||
} elseif (!isset($cycle_vars[$name]['delimiter'])) {
|
||||
$cycle_vars[$name]['delimiter'] = ',';
|
||||
$cycle_vars[$name]['delimiter'] = ',';
|
||||
}
|
||||
|
||||
if(is_array($cycle_vars[$name]['values'])) {
|
||||
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']);
|
||||
$cycle_array = explode($cycle_vars[$name]['delimiter'], $cycle_vars[$name]['values']);
|
||||
}
|
||||
|
||||
if(!isset($cycle_vars[$name]['index']) || $reset ) {
|
||||
if (!isset($cycle_vars[$name]['index']) || $reset) {
|
||||
$cycle_vars[$name]['index'] = 0;
|
||||
}
|
||||
|
||||
|
|
@ -84,14 +84,14 @@ function smarty_function_cycle($params, &$smarty)
|
|||
$smarty->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]);
|
||||
}
|
||||
|
||||
if($print) {
|
||||
if ($print) {
|
||||
$retval = $cycle_array[$cycle_vars[$name]['index']];
|
||||
} else {
|
||||
$retval = null;
|
||||
}
|
||||
|
||||
if($advance) {
|
||||
if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) {
|
||||
if ($advance) {
|
||||
if ($cycle_vars[$name]['index'] >= count($cycle_array) -1) {
|
||||
$cycle_vars[$name]['index'] = 0;
|
||||
} else {
|
||||
$cycle_vars[$name]['index']++;
|
||||
|
|
@ -102,5 +102,3 @@ function smarty_function_cycle($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -31,5 +31,3 @@ function smarty_function_debug($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -20,13 +20,12 @@
|
|||
*/
|
||||
function smarty_function_eval($params, &$smarty)
|
||||
{
|
||||
|
||||
if (!isset($params['var'])) {
|
||||
$smarty->trigger_error("eval: missing 'var' parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
if($params['var'] == '') {
|
||||
if ($params['var'] == '') {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -45,5 +44,3 @@ function smarty_function_eval($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -31,15 +31,15 @@ function smarty_function_fetch($params, &$smarty)
|
|||
if ($smarty->security && !preg_match('!^(http|ftp)://!i', $params['file'])) {
|
||||
$_params = array('resource_type' => 'file', 'resource_name' => $params['file']);
|
||||
require_once(SMARTY_CORE_DIR . 'core.is_secure.php');
|
||||
if(!smarty_core_is_secure($_params, $smarty)) {
|
||||
if (!smarty_core_is_secure($_params, $smarty)) {
|
||||
$smarty->_trigger_fatal_error('[plugin] (secure mode) fetch \'' . $params['file'] . '\' is not allowed');
|
||||
return;
|
||||
}
|
||||
|
||||
// fetch the file
|
||||
if($fp = @fopen($params['file'],'r')) {
|
||||
while(!feof($fp)) {
|
||||
$content .= fgets ($fp,4096);
|
||||
if ($fp = @fopen($params['file'], 'r')) {
|
||||
while (!feof($fp)) {
|
||||
$content .= fgets($fp, 4096);
|
||||
}
|
||||
fclose($fp);
|
||||
} else {
|
||||
|
|
@ -48,9 +48,9 @@ function smarty_function_fetch($params, &$smarty)
|
|||
}
|
||||
} else {
|
||||
// not a local file
|
||||
if(preg_match('!^http://!i',$params['file'])) {
|
||||
if (preg_match('!^http://!i', $params['file'])) {
|
||||
// http fetch
|
||||
if($uri_parts = parse_url($params['file'])) {
|
||||
if ($uri_parts = parse_url($params['file'])) {
|
||||
// set defaults
|
||||
$host = $server_name = $uri_parts['host'];
|
||||
$timeout = 30;
|
||||
|
|
@ -60,42 +60,42 @@ function smarty_function_fetch($params, &$smarty)
|
|||
$uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/';
|
||||
$uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : '';
|
||||
$_is_proxy = false;
|
||||
if(empty($uri_parts['port'])) {
|
||||
if (empty($uri_parts['port'])) {
|
||||
$port = 80;
|
||||
} else {
|
||||
$port = $uri_parts['port'];
|
||||
}
|
||||
if(!empty($uri_parts['user'])) {
|
||||
if (!empty($uri_parts['user'])) {
|
||||
$user = $uri_parts['user'];
|
||||
}
|
||||
if(!empty($uri_parts['pass'])) {
|
||||
if (!empty($uri_parts['pass'])) {
|
||||
$pass = $uri_parts['pass'];
|
||||
}
|
||||
// loop through parameters, setup headers
|
||||
foreach($params as $param_key => $param_value) {
|
||||
switch($param_key) {
|
||||
foreach ($params as $param_key => $param_value) {
|
||||
switch ($param_key) {
|
||||
case "file":
|
||||
case "assign":
|
||||
case "assign_headers":
|
||||
break;
|
||||
case "user":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$user = $param_value;
|
||||
}
|
||||
break;
|
||||
case "pass":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$pass = $param_value;
|
||||
}
|
||||
break;
|
||||
case "accept":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$accept = $param_value;
|
||||
}
|
||||
break;
|
||||
case "header":
|
||||
if(!empty($param_value)) {
|
||||
if(!preg_match('![\w\d-]+: .+!',$param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
if (!preg_match('![\w\d-]+: .+!', $param_value)) {
|
||||
$smarty->_trigger_fatal_error("[plugin] invalid header format '".$param_value."'");
|
||||
return;
|
||||
} else {
|
||||
|
|
@ -104,12 +104,12 @@ function smarty_function_fetch($params, &$smarty)
|
|||
}
|
||||
break;
|
||||
case "proxy_host":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$proxy_host = $param_value;
|
||||
}
|
||||
break;
|
||||
case "proxy_port":
|
||||
if(!preg_match('!\D!', $param_value)) {
|
||||
if (!preg_match('!\D!', $param_value)) {
|
||||
$proxy_port = (int) $param_value;
|
||||
} else {
|
||||
$smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'");
|
||||
|
|
@ -117,17 +117,17 @@ function smarty_function_fetch($params, &$smarty)
|
|||
}
|
||||
break;
|
||||
case "agent":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$agent = $param_value;
|
||||
}
|
||||
break;
|
||||
case "referer":
|
||||
if(!empty($param_value)) {
|
||||
if (!empty($param_value)) {
|
||||
$referer = $param_value;
|
||||
}
|
||||
break;
|
||||
case "timeout":
|
||||
if(!preg_match('!\D!', $param_value)) {
|
||||
if (!preg_match('!\D!', $param_value)) {
|
||||
$timeout = (int) $param_value;
|
||||
} else {
|
||||
$smarty->_trigger_fatal_error("[plugin] invalid value for attribute '".$param_key."'");
|
||||
|
|
@ -139,54 +139,54 @@ function smarty_function_fetch($params, &$smarty)
|
|||
return;
|
||||
}
|
||||
}
|
||||
if(!empty($proxy_host) && !empty($proxy_port)) {
|
||||
if (!empty($proxy_host) && !empty($proxy_port)) {
|
||||
$_is_proxy = true;
|
||||
$fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout);
|
||||
$fp = fsockopen($proxy_host, $proxy_port, $errno, $errstr, $timeout);
|
||||
} else {
|
||||
$fp = fsockopen($server_name,$port,$errno,$errstr,$timeout);
|
||||
$fp = fsockopen($server_name, $port, $errno, $errstr, $timeout);
|
||||
}
|
||||
|
||||
if(!$fp) {
|
||||
if (!$fp) {
|
||||
$smarty->_trigger_fatal_error("[plugin] unable to fetch: $errstr ($errno)");
|
||||
return;
|
||||
} else {
|
||||
if($_is_proxy) {
|
||||
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)) {
|
||||
if (!empty($host)) {
|
||||
fputs($fp, "Host: $host\r\n");
|
||||
}
|
||||
if(!empty($accept)) {
|
||||
if (!empty($accept)) {
|
||||
fputs($fp, "Accept: $accept\r\n");
|
||||
}
|
||||
if(!empty($agent)) {
|
||||
if (!empty($agent)) {
|
||||
fputs($fp, "User-Agent: $agent\r\n");
|
||||
}
|
||||
if(!empty($referer)) {
|
||||
if (!empty($referer)) {
|
||||
fputs($fp, "Referer: $referer\r\n");
|
||||
}
|
||||
if(isset($extra_headers) && is_array($extra_headers)) {
|
||||
foreach($extra_headers as $curr_header) {
|
||||
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)) {
|
||||
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);
|
||||
while (!feof($fp)) {
|
||||
$content .= fgets($fp, 4096);
|
||||
}
|
||||
fclose($fp);
|
||||
$csplit = preg_split("!\r\n\r\n!",$content,2);
|
||||
$csplit = preg_split("!\r\n\r\n!", $content, 2);
|
||||
|
||||
$content = $csplit[1];
|
||||
|
||||
if(!empty($params['assign_headers'])) {
|
||||
$smarty->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0]));
|
||||
if (!empty($params['assign_headers'])) {
|
||||
$smarty->assign($params['assign_headers'], preg_split("!\r\n!", $csplit[0]));
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
|
@ -195,9 +195,9 @@ function smarty_function_fetch($params, &$smarty)
|
|||
}
|
||||
} else {
|
||||
// ftp fetch
|
||||
if($fp = @fopen($params['file'],'r')) {
|
||||
while(!feof($fp)) {
|
||||
$content .= fgets ($fp,4096);
|
||||
if ($fp = @fopen($params['file'], 'r')) {
|
||||
while (!feof($fp)) {
|
||||
$content .= fgets($fp, 4096);
|
||||
}
|
||||
fclose($fp);
|
||||
} else {
|
||||
|
|
@ -205,17 +205,14 @@ function smarty_function_fetch($params, &$smarty)
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
if (!empty($params['assign'])) {
|
||||
$smarty->assign($params['assign'],$content);
|
||||
$smarty->assign($params['assign'], $content);
|
||||
} else {
|
||||
return $content;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
*/
|
||||
function smarty_function_html_checkboxes($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
|
||||
require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
|
||||
|
||||
$name = 'checkbox';
|
||||
$values = null;
|
||||
|
|
@ -52,8 +52,8 @@ function smarty_function_html_checkboxes($params, &$smarty)
|
|||
|
||||
$extra = '';
|
||||
|
||||
foreach($params as $_key => $_val) {
|
||||
switch($_key) {
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'name':
|
||||
case 'separator':
|
||||
$$_key = $_val;
|
||||
|
|
@ -86,7 +86,7 @@ function smarty_function_html_checkboxes($params, &$smarty)
|
|||
break;
|
||||
|
||||
default:
|
||||
if(!is_array($_val)) {
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
} else {
|
||||
$smarty->trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
|
|
@ -95,37 +95,37 @@ function smarty_function_html_checkboxes($params, &$smarty)
|
|||
}
|
||||
}
|
||||
|
||||
if (!isset($options) && !isset($values))
|
||||
return ''; /* raise error here? */
|
||||
if (!isset($options) && !isset($values)) {
|
||||
return '';
|
||||
} /* raise error here? */
|
||||
|
||||
settype($selected, 'array');
|
||||
$_html_result = array();
|
||||
|
||||
if (isset($options)) {
|
||||
|
||||
foreach ($options as $_key=>$_val)
|
||||
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'])) {
|
||||
if (!empty($params['assign'])) {
|
||||
$smarty->assign($params['assign'], $_html_result);
|
||||
} else {
|
||||
return implode("\n",$_html_result);
|
||||
return implode("\n", $_html_result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels) {
|
||||
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels)
|
||||
{
|
||||
$_output = '';
|
||||
if ($labels) $_output .= '<label>';
|
||||
if ($labels) {
|
||||
$_output .= '<label>';
|
||||
}
|
||||
$_output .= '<input type="checkbox" name="'
|
||||
. smarty_function_escape_special_chars($name) . '[]" value="'
|
||||
. smarty_function_escape_special_chars($value) . '"';
|
||||
|
|
@ -134,10 +134,10 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
|
|||
$_output .= ' checked="checked"';
|
||||
}
|
||||
$_output .= $extra . ' />' . $output;
|
||||
if ($labels) $_output .= '</label>';
|
||||
if ($labels) {
|
||||
$_output .= '</label>';
|
||||
}
|
||||
$_output .= $separator;
|
||||
|
||||
return $_output;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
function smarty_function_html_image($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
|
||||
require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
|
||||
|
||||
$alt = '';
|
||||
$file = '';
|
||||
|
|
@ -48,8 +48,8 @@ function smarty_function_html_image($params, &$smarty)
|
|||
$path_prefix = '';
|
||||
$server_vars = ($smarty->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS'];
|
||||
$basedir = isset($server_vars['DOCUMENT_ROOT']) ? $server_vars['DOCUMENT_ROOT'] : '';
|
||||
foreach($params as $_key => $_val) {
|
||||
switch($_key) {
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'file':
|
||||
case 'height':
|
||||
case 'width':
|
||||
|
|
@ -60,7 +60,7 @@ function smarty_function_html_image($params, &$smarty)
|
|||
break;
|
||||
|
||||
case 'alt':
|
||||
if(!is_array($_val)) {
|
||||
if (!is_array($_val)) {
|
||||
$$_key = smarty_function_escape_special_chars($_val);
|
||||
} else {
|
||||
$smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
|
|
@ -74,7 +74,7 @@ function smarty_function_html_image($params, &$smarty)
|
|||
break;
|
||||
|
||||
default:
|
||||
if(!is_array($_val)) {
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
} else {
|
||||
$smarty->trigger_error("html_image: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
|
|
@ -88,18 +88,18 @@ function smarty_function_html_image($params, &$smarty)
|
|||
return;
|
||||
}
|
||||
|
||||
if (substr($file,0,1) == '/') {
|
||||
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)) {
|
||||
if (!isset($params['width']) || !isset($params['height'])) {
|
||||
if (!$_image_data = @getimagesize($_image_path)) {
|
||||
if (!file_exists($_image_path)) {
|
||||
$smarty->trigger_error("html_image: unable to find '$_image_path'", E_USER_NOTICE);
|
||||
return;
|
||||
} else if(!is_readable($_image_path)) {
|
||||
} elseif (!is_readable($_image_path)) {
|
||||
$smarty->trigger_error("html_image: unable to read '$_image_path'", E_USER_NOTICE);
|
||||
return;
|
||||
} else {
|
||||
|
|
@ -110,21 +110,20 @@ function smarty_function_html_image($params, &$smarty)
|
|||
if ($smarty->security &&
|
||||
($_params = array('resource_type' => 'file', 'resource_name' => $_image_path)) &&
|
||||
(require_once(SMARTY_CORE_DIR . 'core.is_secure.php')) &&
|
||||
(!smarty_core_is_secure($_params, $smarty)) ) {
|
||||
(!smarty_core_is_secure($_params, $smarty))) {
|
||||
$smarty->trigger_error("html_image: (secure) '$_image_path' not in secure directory", E_USER_NOTICE);
|
||||
}
|
||||
}
|
||||
|
||||
if(!isset($params['width'])) {
|
||||
if (!isset($params['width'])) {
|
||||
$width = $_image_data[0];
|
||||
}
|
||||
if(!isset($params['height'])) {
|
||||
if (!isset($params['height'])) {
|
||||
$height = $_image_data[1];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(isset($params['dpi'])) {
|
||||
if(strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) {
|
||||
if (isset($params['dpi'])) {
|
||||
if (strstr($server_vars['HTTP_USER_AGENT'], 'Mac')) {
|
||||
$dpi_default = 72;
|
||||
} else {
|
||||
$dpi_default = 96;
|
||||
|
|
@ -138,5 +137,3 @@ function smarty_function_html_image($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@
|
|||
*/
|
||||
function smarty_function_html_options($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
|
||||
require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
|
||||
|
||||
$name = null;
|
||||
$values = null;
|
||||
|
|
@ -39,8 +39,8 @@ function smarty_function_html_options($params, &$smarty)
|
|||
|
||||
$extra = '';
|
||||
|
||||
foreach($params as $_key => $_val) {
|
||||
switch($_key) {
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'name':
|
||||
$$_key = (string)$_val;
|
||||
break;
|
||||
|
|
@ -59,7 +59,7 @@ function smarty_function_html_options($params, &$smarty)
|
|||
break;
|
||||
|
||||
default:
|
||||
if(!is_array($_val)) {
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
} else {
|
||||
$smarty->trigger_error("html_options: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
|
|
@ -68,39 +68,38 @@ function smarty_function_html_options($params, &$smarty)
|
|||
}
|
||||
}
|
||||
|
||||
if (!isset($options) && !isset($values))
|
||||
return ''; /* raise error here? */
|
||||
if (!isset($options) && !isset($values)) {
|
||||
return '';
|
||||
} /* raise error here? */
|
||||
|
||||
$_html_result = '';
|
||||
|
||||
if (isset($options)) {
|
||||
|
||||
foreach ($options as $_key=>$_val)
|
||||
foreach ($options as $_key=>$_val) {
|
||||
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
foreach ($values as $_i=>$_key) {
|
||||
$_val = isset($output[$_i]) ? $output[$_i] : '';
|
||||
$_html_result .= smarty_function_html_options_optoutput($_key, $_val, $selected);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(!empty($name)) {
|
||||
if (!empty($name)) {
|
||||
$_html_result = '<select name="' . $name . '"' . $extra . '>' . "\n" . $_html_result . '</select>' . "\n";
|
||||
}
|
||||
|
||||
return $_html_result;
|
||||
|
||||
}
|
||||
|
||||
function smarty_function_html_options_optoutput($key, $value, $selected) {
|
||||
if(!is_array($value)) {
|
||||
function smarty_function_html_options_optoutput($key, $value, $selected)
|
||||
{
|
||||
if (!is_array($value)) {
|
||||
$_html_result = '<option label="' . smarty_function_escape_special_chars($value) . '" value="' .
|
||||
smarty_function_escape_special_chars($key) . '"';
|
||||
if (in_array((string)$key, $selected))
|
||||
if (in_array((string)$key, $selected)) {
|
||||
$_html_result .= ' selected="selected"';
|
||||
}
|
||||
$_html_result .= '>' . smarty_function_escape_special_chars($value) . '</option>' . "\n";
|
||||
} else {
|
||||
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected);
|
||||
|
|
@ -108,7 +107,8 @@ function smarty_function_html_options_optoutput($key, $value, $selected) {
|
|||
return $_html_result;
|
||||
}
|
||||
|
||||
function smarty_function_html_options_optgroup($key, $values, $selected) {
|
||||
function smarty_function_html_options_optgroup($key, $values, $selected)
|
||||
{
|
||||
$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);
|
||||
|
|
@ -118,5 +118,3 @@ function smarty_function_html_options_optgroup($key, $values, $selected) {
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
*/
|
||||
function smarty_function_html_radios($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
|
||||
require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
|
||||
|
||||
$name = 'radio';
|
||||
$values = null;
|
||||
|
|
@ -52,8 +52,8 @@ function smarty_function_html_radios($params, &$smarty)
|
|||
$output = null;
|
||||
$extra = '';
|
||||
|
||||
foreach($params as $_key => $_val) {
|
||||
switch($_key) {
|
||||
foreach ($params as $_key => $_val) {
|
||||
switch ($_key) {
|
||||
case 'name':
|
||||
case 'separator':
|
||||
$$_key = (string)$_val;
|
||||
|
|
@ -61,7 +61,7 @@ function smarty_function_html_radios($params, &$smarty)
|
|||
|
||||
case 'checked':
|
||||
case 'selected':
|
||||
if(is_array($_val)) {
|
||||
if (is_array($_val)) {
|
||||
$smarty->trigger_error('html_radios: the "' . $_key . '" attribute cannot be an array', E_USER_WARNING);
|
||||
} else {
|
||||
$selected = (string)$_val;
|
||||
|
|
@ -91,7 +91,7 @@ function smarty_function_html_radios($params, &$smarty)
|
|||
break;
|
||||
|
||||
default:
|
||||
if(!is_array($_val)) {
|
||||
if (!is_array($_val)) {
|
||||
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"';
|
||||
} else {
|
||||
$smarty->trigger_error("html_radios: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
|
|
@ -100,57 +100,57 @@ function smarty_function_html_radios($params, &$smarty)
|
|||
}
|
||||
}
|
||||
|
||||
if (!isset($options) && !isset($values))
|
||||
return ''; /* raise error here? */
|
||||
if (!isset($options) && !isset($values)) {
|
||||
return '';
|
||||
} /* raise error here? */
|
||||
|
||||
$_html_result = array();
|
||||
|
||||
if (isset($options)) {
|
||||
|
||||
foreach ($options as $_key=>$_val)
|
||||
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'])) {
|
||||
if (!empty($params['assign'])) {
|
||||
$smarty->assign($params['assign'], $_html_result);
|
||||
} else {
|
||||
return implode("\n",$_html_result);
|
||||
return implode("\n", $_html_result);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function smarty_function_html_radios_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids) {
|
||||
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="'
|
||||
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 ($labels && $label_ids) {
|
||||
$_output .= ' id="' . $_id . '"';
|
||||
}
|
||||
|
||||
if ((string)$value==$selected) {
|
||||
$_output .= ' checked="checked"';
|
||||
}
|
||||
$_output .= $extra . ' />' . $output;
|
||||
if ($labels) $_output .= '</label>';
|
||||
if ($labels) {
|
||||
$_output .= '</label>';
|
||||
}
|
||||
$_output .= $separator;
|
||||
|
||||
return $_output;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -37,9 +37,9 @@
|
|||
*/
|
||||
function smarty_function_html_select_date($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('shared','escape_special_chars');
|
||||
require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
|
||||
require_once $smarty->_get_plugin_filepath('function','html_options');
|
||||
require_once $smarty->_get_plugin_filepath('shared', 'escape_special_chars');
|
||||
require_once $smarty->_get_plugin_filepath('shared', 'make_timestamp');
|
||||
require_once $smarty->_get_plugin_filepath('function', 'html_options');
|
||||
/* Default values. */
|
||||
$prefix = "Date_";
|
||||
$start_year = strftime("%Y");
|
||||
|
|
@ -124,7 +124,7 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
break;
|
||||
|
||||
default:
|
||||
if(!is_array($_value)) {
|
||||
if (!is_array($_value)) {
|
||||
$extra_attrs .= ' '.$_key.'="'.smarty_function_escape_special_chars($_value).'"';
|
||||
} else {
|
||||
$smarty->trigger_error("html_select_date: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
|
||||
|
|
@ -168,7 +168,7 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
// force start year to include given date if not explicitly set
|
||||
$start_year = $time[0];
|
||||
}
|
||||
if($end_year < $time[0] && !isset($params['end_year'])) {
|
||||
if ($end_year < $time[0] && !isset($params['end_year'])) {
|
||||
// force end year to include given date if not explicitly set
|
||||
$end_year = $time[0];
|
||||
}
|
||||
|
|
@ -180,10 +180,10 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
|
||||
$field_separator_count = -1;
|
||||
if ($display_months) {
|
||||
$field_separator_count++;
|
||||
$field_separator_count++;
|
||||
$month_names = array();
|
||||
$month_values = array();
|
||||
if(isset($month_empty)) {
|
||||
if (isset($month_empty)) {
|
||||
$month_names[''] = $month_empty;
|
||||
$month_values[''] = '';
|
||||
}
|
||||
|
|
@ -193,32 +193,34 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
}
|
||||
|
||||
$month_result .= '<select name=';
|
||||
if (null !== $field_array){
|
||||
if (null !== $field_array) {
|
||||
$month_result .= '"' . $field_array . '[' . $prefix . 'Month]"';
|
||||
} else {
|
||||
$month_result .= '"' . $prefix . 'Month"';
|
||||
}
|
||||
if (null !== $month_size){
|
||||
if (null !== $month_size) {
|
||||
$month_result .= ' size="' . $month_size . '"';
|
||||
}
|
||||
if (null !== $month_extra){
|
||||
if (null !== $month_extra) {
|
||||
$month_result .= ' ' . $month_extra;
|
||||
}
|
||||
if (null !== $all_extra){
|
||||
if (null !== $all_extra) {
|
||||
$month_result .= ' ' . $all_extra;
|
||||
}
|
||||
$month_result .= $extra_attrs . '>'."\n";
|
||||
|
||||
$month_result .= smarty_function_html_options(array('output' => $month_names,
|
||||
$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),
|
||||
$smarty);
|
||||
$smarty
|
||||
);
|
||||
$month_result .= '</select>';
|
||||
}
|
||||
|
||||
if ($display_days) {
|
||||
$field_separator_count++;
|
||||
$field_separator_count++;
|
||||
$days = array();
|
||||
if (isset($day_empty)) {
|
||||
$days[''] = $day_empty;
|
||||
|
|
@ -230,42 +232,44 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
}
|
||||
|
||||
$day_result .= '<select name=';
|
||||
if (null !== $field_array){
|
||||
if (null !== $field_array) {
|
||||
$day_result .= '"' . $field_array . '[' . $prefix . 'Day]"';
|
||||
} else {
|
||||
$day_result .= '"' . $prefix . 'Day"';
|
||||
}
|
||||
if (null !== $day_size){
|
||||
if (null !== $day_size) {
|
||||
$day_result .= ' size="' . $day_size . '"';
|
||||
}
|
||||
if (null !== $all_extra){
|
||||
if (null !== $all_extra) {
|
||||
$day_result .= ' ' . $all_extra;
|
||||
}
|
||||
if (null !== $day_extra){
|
||||
if (null !== $day_extra) {
|
||||
$day_result .= ' ' . $day_extra;
|
||||
}
|
||||
$day_result .= $extra_attrs . '>'."\n";
|
||||
$day_result .= smarty_function_html_options(array('output' => $days,
|
||||
$day_result .= smarty_function_html_options(
|
||||
array('output' => $days,
|
||||
'values' => $day_values,
|
||||
'selected' => $time[2],
|
||||
'print_result' => false),
|
||||
$smarty);
|
||||
$smarty
|
||||
);
|
||||
$day_result .= '</select>';
|
||||
}
|
||||
|
||||
if ($display_years) {
|
||||
$field_separator_count++;
|
||||
if (null !== $field_array){
|
||||
$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){
|
||||
if (null !== $all_extra) {
|
||||
$year_result .= ' ' . $all_extra;
|
||||
}
|
||||
if (null !== $year_extra){
|
||||
if (null !== $year_extra) {
|
||||
$year_result .= ' ' . $year_extra;
|
||||
}
|
||||
$year_result .= ' />';
|
||||
|
|
@ -277,34 +281,36 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
sort($years, SORT_NUMERIC);
|
||||
}
|
||||
$yearvals = $years;
|
||||
if(isset($year_empty)) {
|
||||
if (isset($year_empty)) {
|
||||
array_unshift($years, $year_empty);
|
||||
array_unshift($yearvals, '');
|
||||
}
|
||||
$year_result .= '<select name="' . $year_name . '"';
|
||||
if (null !== $year_size){
|
||||
if (null !== $year_size) {
|
||||
$year_result .= ' size="' . $year_size . '"';
|
||||
}
|
||||
if (null !== $all_extra){
|
||||
if (null !== $all_extra) {
|
||||
$year_result .= ' ' . $all_extra;
|
||||
}
|
||||
if (null !== $year_extra){
|
||||
if (null !== $year_extra) {
|
||||
$year_result .= ' ' . $year_extra;
|
||||
}
|
||||
$year_result .= $extra_attrs . '>'."\n";
|
||||
$year_result .= smarty_function_html_options(array('output' => $years,
|
||||
$year_result .= smarty_function_html_options(
|
||||
array('output' => $years,
|
||||
'values' => $yearvals,
|
||||
'selected' => $time[0],
|
||||
'print_result' => false),
|
||||
$smarty);
|
||||
$smarty
|
||||
);
|
||||
$year_result .= '</select>';
|
||||
}
|
||||
}
|
||||
|
||||
// Loop thru the field_order field
|
||||
for ($i = 0; $i <= 2; $i++){
|
||||
for ($i = 0; $i <= 2; $i++) {
|
||||
$c = substr($field_order, $i, 1);
|
||||
switch ($c){
|
||||
switch ($c) {
|
||||
case 'D':
|
||||
$html_result .= $day_result;
|
||||
break;
|
||||
|
|
@ -318,7 +324,7 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
break;
|
||||
}
|
||||
// Add the field seperator
|
||||
if($i < $field_separator_count) {
|
||||
if ($i < $field_separator_count) {
|
||||
$html_result .= $field_separator;
|
||||
}
|
||||
}
|
||||
|
|
@ -327,5 +333,3 @@ function smarty_function_html_select_date($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@
|
|||
*/
|
||||
function smarty_function_html_select_time($params, &$smarty)
|
||||
{
|
||||
require_once $smarty->_get_plugin_filepath('shared','make_timestamp');
|
||||
require_once $smarty->_get_plugin_filepath('function','html_options');
|
||||
require_once $smarty->_get_plugin_filepath('shared', 'make_timestamp');
|
||||
require_once $smarty->_get_plugin_filepath('function', 'html_options');
|
||||
/* Default values. */
|
||||
$prefix = "Time_";
|
||||
$time = time();
|
||||
|
|
@ -84,33 +84,37 @@ function smarty_function_html_select_time($params, &$smarty)
|
|||
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++)
|
||||
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){
|
||||
if (null !== $hour_extra) {
|
||||
$html_result .= ' ' . $hour_extra;
|
||||
}
|
||||
if (null !== $all_extra){
|
||||
if (null !== $all_extra) {
|
||||
$html_result .= ' ' . $all_extra;
|
||||
}
|
||||
$html_result .= '>'."\n";
|
||||
$html_result .= smarty_function_html_options(array('output' => $hours,
|
||||
$html_result .= smarty_function_html_options(
|
||||
array('output' => $hours,
|
||||
'values' => $hours,
|
||||
'selected' => strftime($hour_fmt, $time),
|
||||
'print_result' => false),
|
||||
$smarty);
|
||||
$smarty
|
||||
);
|
||||
$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)
|
||||
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) {
|
||||
|
|
@ -118,26 +122,29 @@ function smarty_function_html_select_time($params, &$smarty)
|
|||
} else {
|
||||
$html_result .= '"' . $prefix . 'Minute"';
|
||||
}
|
||||
if (null !== $minute_extra){
|
||||
if (null !== $minute_extra) {
|
||||
$html_result .= ' ' . $minute_extra;
|
||||
}
|
||||
if (null !== $all_extra){
|
||||
if (null !== $all_extra) {
|
||||
$html_result .= ' ' . $all_extra;
|
||||
}
|
||||
$html_result .= '>'."\n";
|
||||
|
||||
$html_result .= smarty_function_html_options(array('output' => $minutes,
|
||||
$html_result .= smarty_function_html_options(
|
||||
array('output' => $minutes,
|
||||
'values' => $minutes,
|
||||
'selected' => $selected,
|
||||
'print_result' => false),
|
||||
$smarty);
|
||||
$smarty
|
||||
);
|
||||
$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)
|
||||
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) {
|
||||
|
|
@ -146,19 +153,21 @@ function smarty_function_html_select_time($params, &$smarty)
|
|||
$html_result .= '"' . $prefix . 'Second"';
|
||||
}
|
||||
|
||||
if (null !== $second_extra){
|
||||
if (null !== $second_extra) {
|
||||
$html_result .= ' ' . $second_extra;
|
||||
}
|
||||
if (null !== $all_extra){
|
||||
if (null !== $all_extra) {
|
||||
$html_result .= ' ' . $all_extra;
|
||||
}
|
||||
$html_result .= '>'."\n";
|
||||
|
||||
$html_result .= smarty_function_html_options(array('output' => $seconds,
|
||||
$html_result .= smarty_function_html_options(
|
||||
array('output' => $seconds,
|
||||
'values' => $seconds,
|
||||
'selected' => $selected,
|
||||
'print_result' => false),
|
||||
$smarty);
|
||||
$smarty
|
||||
);
|
||||
$html_result .= "</select>\n";
|
||||
}
|
||||
|
||||
|
|
@ -170,19 +179,21 @@ function smarty_function_html_select_time($params, &$smarty)
|
|||
$html_result .= '"' . $prefix . 'Meridian"';
|
||||
}
|
||||
|
||||
if (null !== $meridian_extra){
|
||||
if (null !== $meridian_extra) {
|
||||
$html_result .= ' ' . $meridian_extra;
|
||||
}
|
||||
if (null !== $all_extra){
|
||||
if (null !== $all_extra) {
|
||||
$html_result .= ' ' . $all_extra;
|
||||
}
|
||||
$html_result .= '>'."\n";
|
||||
|
||||
$html_result .= smarty_function_html_options(array('output' => array('AM', 'PM'),
|
||||
$html_result .= smarty_function_html_options(
|
||||
array('output' => array('AM', 'PM'),
|
||||
'values' => array('am', 'pm'),
|
||||
'selected' => strtolower(strftime('%p', $time)),
|
||||
'print_result' => false),
|
||||
$smarty);
|
||||
$smarty
|
||||
);
|
||||
$html_result .= "</select>\n";
|
||||
}
|
||||
|
||||
|
|
@ -190,5 +201,3 @@ function smarty_function_html_select_time($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@
|
|||
* - 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
|
||||
* - 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,
|
||||
|
|
@ -161,8 +161,9 @@ function smarty_function_html_table($params, &$smarty)
|
|||
return $output;
|
||||
}
|
||||
|
||||
function smarty_function_html_table_cycle($name, $var, $no) {
|
||||
if(!is_array($var)) {
|
||||
function smarty_function_html_table_cycle($name, $var, $no)
|
||||
{
|
||||
if (!is_array($var)) {
|
||||
$ret = $var;
|
||||
} else {
|
||||
$ret = $var[$no % count($var)];
|
||||
|
|
@ -173,5 +174,3 @@ function smarty_function_html_table_cycle($name, $var, $no) {
|
|||
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -70,8 +70,9 @@ function smarty_function_mailto($params, &$smarty)
|
|||
case 'cc':
|
||||
case 'bcc':
|
||||
case 'followupto':
|
||||
if (!empty($value))
|
||||
$mail_parms[] = $var.'='.str_replace($search,$replace,rawurlencode($value));
|
||||
if (!empty($value)) {
|
||||
$mail_parms[] = $var.'='.str_replace($search, $replace, rawurlencode($value));
|
||||
}
|
||||
break;
|
||||
|
||||
case 'subject':
|
||||
|
|
@ -83,6 +84,7 @@ function smarty_function_mailto($params, &$smarty)
|
|||
case 'text':
|
||||
$$var = $value;
|
||||
|
||||
// no break
|
||||
default:
|
||||
}
|
||||
}
|
||||
|
|
@ -95,12 +97,12 @@ function smarty_function_mailto($params, &$smarty)
|
|||
$address .= $mail_parm_vals;
|
||||
|
||||
$encode = (empty($params['encode'])) ? 'none' : $params['encode'];
|
||||
if (!in_array($encode,array('javascript','javascript_charcode','hex','none')) ) {
|
||||
if (!in_array($encode, array('javascript','javascript_charcode','hex','none'))) {
|
||||
$smarty->trigger_error("mailto: 'encode' parameter must be none, javascript or hex");
|
||||
return;
|
||||
}
|
||||
|
||||
if ($encode == 'javascript' ) {
|
||||
if ($encode == 'javascript') {
|
||||
$string = 'document.write(\'<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>\');';
|
||||
|
||||
$js_encode = '';
|
||||
|
|
@ -109,36 +111,32 @@ function smarty_function_mailto($params, &$smarty)
|
|||
}
|
||||
|
||||
return '<script type="text/javascript">eval(unescape(\''.$js_encode.'\'))</script>';
|
||||
|
||||
} elseif ($encode == 'javascript_charcode' ) {
|
||||
} 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]);
|
||||
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 .= implode(',', $ord);
|
||||
$_ret .= "))";
|
||||
$_ret .= "}\n";
|
||||
$_ret .= "//-->\n";
|
||||
$_ret .= "</script>\n";
|
||||
|
||||
return $_ret;
|
||||
|
||||
|
||||
} elseif ($encode == 'hex') {
|
||||
|
||||
preg_match('!^(.*)(\?.*)$!',$address,$match);
|
||||
if(!empty($match[2])) {
|
||||
preg_match('!^(.*)(\?.*)$!', $address, $match);
|
||||
if (!empty($match[2])) {
|
||||
$smarty->trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.");
|
||||
return;
|
||||
}
|
||||
$address_encode = '';
|
||||
for ($x=0; $x < strlen($address); $x++) {
|
||||
if(preg_match('!\w!',$address[$x])) {
|
||||
if (preg_match('!\w!', $address[$x])) {
|
||||
$address_encode .= '%' . bin2hex($address[$x]);
|
||||
} else {
|
||||
$address_encode .= $address[$x];
|
||||
|
|
@ -151,15 +149,10 @@ function smarty_function_mailto($params, &$smarty)
|
|||
|
||||
$mailto = "mailto:";
|
||||
return '<a href="'.$mailto.$address_encode.'" '.$extra.'>'.$text_encode.'</a>';
|
||||
|
||||
} else {
|
||||
// no encoding
|
||||
return '<a href="mailto:'.$address.'" '.$extra.'>'.$text.'</a>';
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -29,14 +29,15 @@ function smarty_function_popup($params, &$smarty)
|
|||
case 'function':
|
||||
case 'inarray':
|
||||
$$_key = (string)$_value;
|
||||
if ($_key == 'function' || $_key == 'inarray')
|
||||
if ($_key == 'function' || $_key == 'inarray') {
|
||||
$append .= ',' . strtoupper($_key) . ",'$_value'";
|
||||
}
|
||||
break;
|
||||
|
||||
case 'caption':
|
||||
case 'closetext':
|
||||
case 'status':
|
||||
$append .= ',' . strtoupper($_key) . ",'" . str_replace("'","\'",$_value) . "'";
|
||||
$append .= ',' . strtoupper($_key) . ",'" . str_replace("'", "\'", $_value) . "'";
|
||||
break;
|
||||
|
||||
case 'fgcolor':
|
||||
|
|
@ -90,7 +91,9 @@ function smarty_function_popup($params, &$smarty)
|
|||
case 'mouseoff':
|
||||
case 'followmouse':
|
||||
case 'closeclick':
|
||||
if ($_value) $append .= ',' . strtoupper($_key);
|
||||
if ($_value) {
|
||||
$append .= ',' . strtoupper($_key);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -103,17 +106,18 @@ function smarty_function_popup($params, &$smarty)
|
|||
return false;
|
||||
}
|
||||
|
||||
if (empty($trigger)) { $trigger = "onmouseover"; }
|
||||
if (empty($trigger)) {
|
||||
$trigger = "onmouseover";
|
||||
}
|
||||
|
||||
$retval = $trigger . '="return overlib(\''.preg_replace(array("!'!","![\r\n]!"),array("\'",'\r'),$text).'\'';
|
||||
$retval = $trigger . '="return overlib(\''.preg_replace(array("!'!","![\r\n]!"), array("\'",'\r'), $text).'\'';
|
||||
$retval .= $append . ');"';
|
||||
if ($trigger == 'onmouseover')
|
||||
$retval .= ' onmouseout="nd();"';
|
||||
if ($trigger == 'onmouseover') {
|
||||
$retval .= ' onmouseout="nd();"';
|
||||
}
|
||||
|
||||
|
||||
return $retval;
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -36,5 +36,3 @@ function smarty_function_popup_init($params, &$smarty)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -28,16 +28,14 @@ function smarty_modifier_capitalize_ucfirst($string, $uc_digits = null)
|
|||
{
|
||||
static $_uc_digits = false;
|
||||
|
||||
if(isset($uc_digits)) {
|
||||
if (isset($uc_digits)) {
|
||||
$_uc_digits = $uc_digits;
|
||||
return;
|
||||
}
|
||||
|
||||
if(substr($string[0],0,1) != "'" && !preg_match("!\d!",$string[0]) || $_uc_digits)
|
||||
if (substr($string[0], 0, 1) != "'" && !preg_match("!\d!", $string[0]) || $_uc_digits) {
|
||||
return ucfirst($string[0]);
|
||||
else
|
||||
} else {
|
||||
return $string[0];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -29,5 +29,3 @@ function smarty_modifier_cat($string, $cat)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,12 +21,11 @@
|
|||
*/
|
||||
function smarty_modifier_count_characters($string, $include_spaces = false)
|
||||
{
|
||||
if ($include_spaces)
|
||||
return(strlen($string));
|
||||
if ($include_spaces) {
|
||||
return(strlen($string));
|
||||
}
|
||||
|
||||
return preg_match_all("/[^\s]/",$string, $match);
|
||||
return preg_match_all("/[^\s]/", $string, $match);
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -25,5 +25,3 @@ function smarty_modifier_count_paragraphs($string)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -25,5 +25,3 @@ function smarty_modifier_count_sentences($string)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@
|
|||
function smarty_modifier_count_words($string)
|
||||
{
|
||||
// split text by ' ',\r,\n,\f,\t
|
||||
$split_array = preg_split('/\s+/',$string);
|
||||
$split_array = preg_split('/\s+/', $string);
|
||||
// count matches that contain alphanumerics
|
||||
$word_count = preg_grep('/[a-zA-Z0-9\\x80-\\xff]/', $split_array);
|
||||
|
||||
|
|
@ -29,5 +29,3 @@ function smarty_modifier_count_words($string)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -20,11 +20,9 @@
|
|||
*/
|
||||
function smarty_modifier_countdown($timer)
|
||||
{
|
||||
if ($timer > 3600)
|
||||
if ($timer > 3600) {
|
||||
return intVal($timer/3600) . ":" . intVal(($timer%3600)/60) . ":" . ($timer%3600)%60;
|
||||
else
|
||||
} else {
|
||||
return intVal($timer/60) . ":" . $timer%60;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -54,5 +54,3 @@ function smarty_modifier_date_format($string, $format = '%b %e, %Y', $default_da
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -29,28 +29,28 @@ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
|
|||
);
|
||||
|
||||
switch (gettype($var)) {
|
||||
case 'array' :
|
||||
case 'array':
|
||||
$results = '<b>Array (' . count($var) . ')</b>';
|
||||
foreach ($var as $curr_key => $curr_val) {
|
||||
$results .= '<br>' . str_repeat(' ', $depth * 2)
|
||||
. '<b>' . strtr($curr_key, $_replace) . '</b> => '
|
||||
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
|
||||
$depth--;
|
||||
$depth--;
|
||||
}
|
||||
break;
|
||||
case 'object' :
|
||||
case 'object':
|
||||
$object_vars = get_object_vars($var);
|
||||
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
|
||||
foreach ($object_vars as $curr_key => $curr_val) {
|
||||
$results .= '<br>' . str_repeat(' ', $depth * 2)
|
||||
. '<b> ->' . strtr($curr_key, $_replace) . '</b> = '
|
||||
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
|
||||
$depth--;
|
||||
$depth--;
|
||||
}
|
||||
break;
|
||||
case 'boolean' :
|
||||
case 'NULL' :
|
||||
case 'resource' :
|
||||
case 'boolean':
|
||||
case 'NULL':
|
||||
case 'resource':
|
||||
if (true === $var) {
|
||||
$results = 'true';
|
||||
} elseif (false === $var) {
|
||||
|
|
@ -62,21 +62,21 @@ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
|
|||
}
|
||||
$results = '<i>' . $results . '</i>';
|
||||
break;
|
||||
case 'integer' :
|
||||
case 'float' :
|
||||
case 'integer':
|
||||
case 'float':
|
||||
$results = htmlspecialchars((string) $var);
|
||||
break;
|
||||
case 'string' :
|
||||
case 'string':
|
||||
$results = strtr($var, $_replace);
|
||||
if (strlen($var) > $length ) {
|
||||
if (strlen($var) > $length) {
|
||||
$results = substr($var, 0, $length - 3) . '...';
|
||||
}
|
||||
$results = htmlspecialchars('"' . $results . '"');
|
||||
break;
|
||||
case 'unknown type' :
|
||||
default :
|
||||
case 'unknown type':
|
||||
default:
|
||||
$results = strtr((string) $var, $_replace);
|
||||
if (strlen($results) > $length ) {
|
||||
if (strlen($results) > $length) {
|
||||
$results = substr($results, 0, $length - 3) . '...';
|
||||
}
|
||||
$results = htmlspecialchars($results);
|
||||
|
|
@ -86,5 +86,3 @@ function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,12 +21,11 @@
|
|||
*/
|
||||
function smarty_modifier_default($string, $default = '')
|
||||
{
|
||||
if (!isset($string) || $string === '')
|
||||
if (!isset($string) || $string === '') {
|
||||
return $default;
|
||||
else
|
||||
} else {
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = 'ISO-88
|
|||
return rawurlencode($string);
|
||||
|
||||
case 'urlpathinfo':
|
||||
return str_replace('%2F','/',rawurlencode($string));
|
||||
return str_replace('%2F', '/', rawurlencode($string));
|
||||
|
||||
case 'quotes':
|
||||
// escape unescaped single quotes
|
||||
|
|
@ -66,18 +66,17 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = 'ISO-88
|
|||
|
||||
case 'mail':
|
||||
// safe way to display e-mail address on a web page
|
||||
return str_replace(array('@', '.'),array(' [AT] ', ' [DOT] '), $string);
|
||||
return 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++) {
|
||||
for ($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) {
|
||||
$_ord = ord(substr($string, $_i, 1));
|
||||
// non-standard char, escape it
|
||||
if($_ord >= 126){
|
||||
if ($_ord >= 126) {
|
||||
$_res .= '&#' . $_ord . ';';
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$_res .= substr($string, $_i, 1);
|
||||
}
|
||||
}
|
||||
|
|
@ -89,5 +88,3 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = 'ISO-88
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -20,9 +20,7 @@
|
|||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_indent($string,$chars=4,$char=" ")
|
||||
function smarty_modifier_indent($string, $chars=4, $char=" ")
|
||||
{
|
||||
return preg_replace('!^!m',str_repeat($char,$chars),$string);
|
||||
return preg_replace('!^!m', str_repeat($char, $chars), $string);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -22,5 +22,3 @@ function smarty_modifier_lower($string)
|
|||
{
|
||||
return strtolower($string);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -31,5 +31,3 @@ function smarty_modifier_nl2br($string)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,10 +21,8 @@
|
|||
*/
|
||||
function smarty_modifier_nom($string, $type)
|
||||
{
|
||||
global ${$type};
|
||||
global ${$type};
|
||||
return ${$type}[$string];
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
@ -22,20 +22,22 @@
|
|||
*/
|
||||
function smarty_modifier_regex_replace($string, $search, $replace)
|
||||
{
|
||||
if(is_array($search)) {
|
||||
foreach($search as $idx => $s)
|
||||
$search[$idx] = _smarty_regex_replace_check($s);
|
||||
if (is_array($search)) {
|
||||
foreach ($search as $idx => $s) {
|
||||
$search[$idx] = _smarty_regex_replace_check($s);
|
||||
}
|
||||
} else {
|
||||
$search = _smarty_regex_replace_check($search);
|
||||
}
|
||||
$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 (($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]);
|
||||
|
|
@ -44,5 +46,3 @@ function _smarty_regex_replace_check($search)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -26,5 +26,3 @@ function smarty_modifier_replace($string, $search, $replace)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -25,5 +25,3 @@ function smarty_modifier_separerNombres($string)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,10 +21,10 @@
|
|||
*/
|
||||
function smarty_modifier_spacify($string, $spacify_char = ' ')
|
||||
{
|
||||
return implode($spacify_char,
|
||||
preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY));
|
||||
return implode(
|
||||
$spacify_char,
|
||||
preg_split('//', $string, -1, PREG_SPLIT_NO_EMPTY)
|
||||
);
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,23 +21,35 @@
|
|||
*/
|
||||
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;
|
||||
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;
|
||||
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: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -25,5 +25,3 @@ function smarty_modifier_string_format($string, $format)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -29,5 +29,3 @@ function smarty_modifier_strip($text, $replace = ' ')
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,12 +21,11 @@
|
|||
*/
|
||||
function smarty_modifier_strip_tags($string, $replace_with_space = true)
|
||||
{
|
||||
if ($replace_with_space)
|
||||
if ($replace_with_space) {
|
||||
return preg_replace('!<[^>]*?>!', ' ', $string);
|
||||
else
|
||||
} else {
|
||||
return strip_tags($string);
|
||||
}
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -25,5 +25,3 @@ function smarty_modifier_temps($secondes)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -24,18 +24,23 @@
|
|||
* @param boolean
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_truncate($string, $length = 80, $etc = '...',
|
||||
$break_words = false, $middle = false)
|
||||
{
|
||||
if ($length == 0)
|
||||
function smarty_modifier_truncate(
|
||||
$string,
|
||||
$length = 80,
|
||||
$etc = '...',
|
||||
$break_words = false,
|
||||
$middle = false
|
||||
) {
|
||||
if ($length == 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
if (strlen($string) > $length) {
|
||||
$length -= min($length, strlen($etc));
|
||||
if (!$break_words && !$middle) {
|
||||
$string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
|
||||
}
|
||||
if(!$middle) {
|
||||
if (!$middle) {
|
||||
return substr($string, 0, $length) . $etc;
|
||||
} else {
|
||||
return substr($string, 0, $length/2) . $etc . substr($string, -$length/2);
|
||||
|
|
@ -46,5 +51,3 @@ function smarty_modifier_truncate($string, $length = 80, $etc = '...',
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,11 +21,9 @@
|
|||
function smarty_modifier_ucfirst($chaine)
|
||||
{
|
||||
$chaineS = strtr($chaine, "áà âäãéèêëẽÃìîïĩóòôöõúùûüũýỳŷÿỹ", "ÃÃÃÃÃÃÃÃÃẼÃÃÃÃĨÃÃÃÃÃÃÃÃÃŨÃỲŶŸỸ");
|
||||
if ($chaineS[0].$chaineS[1] != $chaine[0].$chaine[1])
|
||||
if ($chaineS[0].$chaineS[1] != $chaine[0].$chaine[1]) {
|
||||
return $chaineS[0].$chaineS[1].substr($chaine, 2);
|
||||
else
|
||||
} else {
|
||||
return ucfirst($chaine);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -22,5 +22,3 @@ function smarty_modifier_upper($string)
|
|||
{
|
||||
return strtoupper($string);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -21,9 +21,7 @@
|
|||
* @param boolean
|
||||
* @return string
|
||||
*/
|
||||
function smarty_modifier_wordwrap($string,$length=80,$break="\n",$cut=false)
|
||||
function smarty_modifier_wordwrap($string, $length=80, $break="\n", $cut=false)
|
||||
{
|
||||
return wordwrap($string,$length,$break,$cut);
|
||||
return wordwrap($string, $length, $break, $cut);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -30,46 +30,55 @@ function smarty_outputfilter_trimwhitespace($source, &$smarty)
|
|||
// Pull out the script blocks
|
||||
preg_match_all("!<script[^>]*?>.*?</script>!is", $source, $match);
|
||||
$_script_blocks = $match[0];
|
||||
$source = preg_replace("!<script[^>]*?>.*?</script>!is",
|
||||
'@@@SMARTY:TRIM:SCRIPT@@@', $source);
|
||||
$source = preg_replace(
|
||||
"!<script[^>]*?>.*?</script>!is",
|
||||
'@@@SMARTY:TRIM:SCRIPT@@@',
|
||||
$source
|
||||
);
|
||||
|
||||
// Pull out the pre blocks
|
||||
preg_match_all("!<pre[^>]*?>.*?</pre>!is", $source, $match);
|
||||
$_pre_blocks = $match[0];
|
||||
$source = preg_replace("!<pre[^>]*?>.*?</pre>!is",
|
||||
'@@@SMARTY:TRIM:PRE@@@', $source);
|
||||
$source = preg_replace(
|
||||
"!<pre[^>]*?>.*?</pre>!is",
|
||||
'@@@SMARTY:TRIM:PRE@@@',
|
||||
$source
|
||||
);
|
||||
|
||||
// Pull out the textarea blocks
|
||||
preg_match_all("!<textarea[^>]*?>.*?</textarea>!is", $source, $match);
|
||||
$_textarea_blocks = $match[0];
|
||||
$source = preg_replace("!<textarea[^>]*?>.*?</textarea>!is",
|
||||
'@@@SMARTY:TRIM:TEXTAREA@@@', $source);
|
||||
$source = preg_replace(
|
||||
"!<textarea[^>]*?>.*?</textarea>!is",
|
||||
'@@@SMARTY:TRIM:TEXTAREA@@@',
|
||||
$source
|
||||
);
|
||||
|
||||
// remove all leading spaces, tabs and carriage returns NOT
|
||||
// preceeded by a php close tag.
|
||||
$source = trim(preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $source));
|
||||
|
||||
// replace textarea blocks
|
||||
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source);
|
||||
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@", $_textarea_blocks, $source);
|
||||
|
||||
// replace pre blocks
|
||||
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source);
|
||||
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@", $_pre_blocks, $source);
|
||||
|
||||
// replace script blocks
|
||||
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source);
|
||||
smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@", $_script_blocks, $source);
|
||||
|
||||
return $source;
|
||||
}
|
||||
|
||||
function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) {
|
||||
function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject)
|
||||
{
|
||||
$_len = strlen($search_str);
|
||||
$_pos = 0;
|
||||
for ($_i=0, $_count=count($replace); $_i<$_count; $_i++)
|
||||
if (($_pos=strpos($subject, $search_str, $_pos))!==false)
|
||||
for ($_i=0, $_count=count($replace); $_i<$_count; $_i++) {
|
||||
if (($_pos=strpos($subject, $search_str, $_pos))!==false) {
|
||||
$subject = substr_replace($subject, $replace[$_i], $_pos, $_len);
|
||||
else
|
||||
} else {
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
function smarty_function_escape_special_chars($string)
|
||||
{
|
||||
if(!is_array($string)) {
|
||||
if (!is_array($string)) {
|
||||
$string = preg_replace('!&(#?\w+);!', '%%%SMARTY_START%%%\\1%%%SMARTY_END%%%', $string);
|
||||
$string = htmlspecialchars($string);
|
||||
$string = str_replace(array('%%%SMARTY_START%%%','%%%SMARTY_END%%%'), array('&',';'), $string);
|
||||
|
|
@ -27,5 +27,3 @@ function smarty_function_escape_special_chars($string)
|
|||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -16,19 +16,22 @@
|
|||
*/
|
||||
function smarty_make_timestamp($string)
|
||||
{
|
||||
if(empty($string)) {
|
||||
if (empty($string)) {
|
||||
// use "now":
|
||||
$time = time();
|
||||
|
||||
} elseif (preg_match('/^\d{14}$/', $string)) {
|
||||
// it is mysql timestamp format of YYYYMMDDHHMMSS?
|
||||
$time = mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2),
|
||||
substr($string, 4, 2),substr($string, 6, 2),substr($string, 0, 4));
|
||||
|
||||
// it is mysql timestamp format of YYYYMMDDHHMMSS?
|
||||
$time = mktime(
|
||||
substr($string, 8, 2),
|
||||
substr($string, 10, 2),
|
||||
substr($string, 12, 2),
|
||||
substr($string, 4, 2),
|
||||
substr($string, 6, 2),
|
||||
substr($string, 0, 4)
|
||||
);
|
||||
} elseif (is_numeric($string)) {
|
||||
// it is a numeric string, we handle it as timestamp
|
||||
$time = (int)$string;
|
||||
|
||||
} else {
|
||||
// strtotime should handle it
|
||||
$time = strtotime($string);
|
||||
|
|
@ -38,9 +41,6 @@ function smarty_make_timestamp($string)
|
|||
}
|
||||
}
|
||||
return $time;
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab: */
|
||||
|
||||
?>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,3 @@
|
|||
<?php
|
||||
|
||||
echo $OPT['t'];
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue