Compare commits

..

79 Commits

Author SHA1 Message Date
Michael Kaufmann (d00p)
7680cd441c force integer conversion for domainimport-offset-field, as POST sends it as string; filter IP-addresses that are unknown to froxlor when importing domains.
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-30 17:55:27 +01:00
Michael Kaufmann (d00p)
d7f8586413 allow language-check against a specific language file
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-30 17:54:06 +01:00
Michael Kaufmann (d00p)
83e062c845 remove unused Minify_HTML class
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-30 17:53:43 +01:00
Michael Kaufmann (d00p)
c6c950596a use better error-message for misuse of froxlor.hostname
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-28 22:01:16 +01:00
Michael Kaufmann (d00p)
4714a458fe don't allow a customer to add the froxlor-hostname as subdomain in case the froxlor-hostname is sub.dom.tld and the customer has dom.tld assigned, thx to chrisalexthomas for 'finding' this :)
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-28 21:55:46 +01:00
Michael Kaufmann (d00p)
1672b01426 Merge branch 'master' of github.com:Froxlor/Froxlor 2015-01-28 13:25:08 +01:00
Michael Kaufmann (d00p)
36c7527b2a add function to validate different password-hashes and update them to the currently set hash if login successfull and hash differs, set default hash to SHA256, fixes #1289 - add custom-notes field to admin/customer, fixes #1471 - set version to 0.9.33-rc2 for upcoming second release-candidate
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-28 13:24:36 +01:00
Roman Schmerold (BNoiZe)
00e74a05cb Disable input if unlimited is checked
Signed-off-by: Roman Schmerold (BNoiZe) <bnoize@froxlor.org>
2015-01-28 04:54:00 +01:00
Michael Kaufmann (d00p)
7904946862 push some upcoming changes (still holding back db changes b/c of version jump to rc2)
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-27 23:04:46 +01:00
Roman Schmerold (BNoiZe)
88ace5785e Fix broken custom newsfeed, newsfeed redesign
Signed-off-by: Roman Schmerold (BNoiZe) <bnoize@froxlor.org>
2015-01-27 22:43:52 +01:00
Robert Förster (Dessa)
614d9c127b fix mail delivery for dovecot, closes #1465 2015-01-27 17:55:46 +01:00
Dessa
f0551ac122 Merge pull request #212 from junkpad92/master
Fixing deprecated Postfix templates & Providing Dovecot2 Sieve-Configs
2015-01-27 17:52:36 +01:00
Michael Kaufmann (d00p)
bdfbe4947a fix undefined variables introduced in commit #b1acc9a8efc01a5139b042f8f9e97881e4a52b83
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-27 11:23:03 +01:00
Michael Kaufmann (d00p)
7b8341d826 add function to validate different password-hashes and update them to the currently set hash if login successfull and hash differs (unimplemented yet because of required db-updates which are hold back until 0.9.33-rc2), refs #1289
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-27 11:09:27 +01:00
Michael Kaufmann
9d008efabc Merge pull request #224 from heaven73/master
Pure-FTPd template for FreeBSD
2015-01-26 22:15:35 +01:00
Chris Energia Positiva
6c3f6fd57f Update freebsd.inc.php 2015-01-26 22:09:47 +01:00
Chris Energia Positiva
533279ec25 Create usr_local_etc_pureftpd-mysql.conf 2015-01-26 22:07:39 +01:00
Chris Energia Positiva
68d678aff8 Create usr_local_etc_pure-ftpd.conf 2015-01-26 22:06:12 +01:00
Roman Schmerold (BNoiZe)
6767edfaff Merge branch 'master' of github.com:Froxlor/Froxlor 2015-01-26 17:20:05 +01:00
Roman Schmerold (BNoiZe)
b1acc9a8ef Make the side navigation more styleable
Signed-off-by: Roman Schmerold (BNoiZe) <bnoize@froxlor.org>
2015-01-26 17:19:40 +01:00
Michael Kaufmann (d00p)
16dde03f96 get rid of almost never used HTMLPurifier library and beautify subject display on ticket-overview
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-25 08:34:03 +01:00
Michael Kaufmann (d00p)
5a7462972f revert commit 84ff476dfa from Lednerb, as the cron-reload command is being read from the settings (and can be adjusted)
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-22 08:19:50 +01:00
Dessa
4c60b40c64 Merge pull request #220 from Lednerb/master
Ubuntu 14.04 Integration
2015-01-22 07:51:12 +01:00
Dessa
90bcaee2c9 Merge pull request #202 from antedaxara/rhel7
Added RHEL 7 configfiles
2015-01-22 07:50:56 +01:00
Michael Kaufmann (d00p)
a4973c9c38 don't add rewritecond for https off if this is a ssl-vhost
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-21 16:51:36 +01:00
Roman Schmerold (BNoiZe)
6c39ac80e6 Optimized images
Signed-off-by: Roman Schmerold (BNoiZe) <bnoize@froxlor.org>
2015-01-16 21:16:50 +01:00
Roman Schmerold (BNoiZe)
979c5e7c0c Tidied up the code
Signed-off-by: Roman Schmerold (BNoiZe) <bnoize@froxlor.org>
2015-01-16 21:11:17 +01:00
Michael Kaufmann (d00p)
2250b3c37a show custom-notes correctly on admin/customer index when activated + tiny fixes, refs #1471
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-15 22:19:28 +01:00
Michael Kaufmann (d00p)
e578a29058 add option to display the custom-notes to the user and actually save the custom-note
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-15 22:10:37 +01:00
Michael Kaufmann (d00p)
4c50d35945 Merge branch 'master' of github.com:Froxlor/Froxlor 2015-01-15 21:30:35 +01:00
Michael Kaufmann (d00p)
7b8885c05e add custom-notes field to admins and customers, fixes #1471
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-15 21:30:15 +01:00
Roman Schmerold (BNoiZe)
1e6df86b7b Add new small info icon
Signed-off-by: Roman Schmerold (BNoiZe) <bnoize@froxlor.org>
2015-01-15 20:27:11 +01:00
Michael Kaufmann (d00p)
4e9b2d0e97 replace DB_SRV with the hostname/ip and not the caption of the mysql-server, thx to rzeka for noticing
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-15 17:29:49 +01:00
Roman Schmerold (BNoiZe)
67f3263a2e Don't remove custom comments, add newline after blocks
Signed-off-by: Roman Schmerold (BNoiZe) <bnoize@froxlor.org>
2015-01-14 00:20:04 +01:00
Roman Schmerold (BNoiZe)
f61567be81 Changed the way php-fpm is included, fixes #1427
Signed-off-by: Roman Schmerold (BNoiZe) <bnoize@froxlor.org>
2015-01-13 20:37:57 +01:00
Michael Kaufmann (d00p)
3ee8f6ac25 use generatePassword() for generating passwords as it respects the settings; fix user-modification under freebsd as there is no 'usermod'
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-12 20:24:55 +01:00
Sascha Brendel
5eb630d858 Merge pull request #6 from Lednerb/testing-1
Testing 1
2015-01-12 14:36:14 +01:00
Lednerb
e7d07c7924 Deleted unnecessary config template 2015-01-12 14:32:00 +01:00
Lednerb
ab44d27914 Deleted unnecessary config prompts 2015-01-12 14:25:10 +01:00
Lednerb
1889958e2b added missing php5-cli to installation script 2015-01-11 22:19:49 +01:00
Michael Kaufmann (d00p)
b78729319c added logging to integry-check so admins know what exactly was wrong when monkeys ate the integrity :)
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-11 20:32:18 +01:00
Lednerb
7d478fd378 dovecot Installation angepasst 2015-01-11 16:36:50 +01:00
Lednerb
1cb237e8e1 Test zum Entfernen 2015-01-11 16:01:58 +01:00
Lednerb
8a3745aee8 updated service restart at courier imap/pop3 server 2015-01-11 15:42:01 +01:00
Lednerb
84ff476dfa check Cron reload config 2015-01-11 13:22:35 +01:00
Michael Kaufmann (d00p)
b3935bfda8 Merge branch 'master' of github.com:Froxlor/Froxlor 2015-01-11 09:31:49 +01:00
Lednerb
2ae64d0abe Added Trusty 2015-01-11 00:06:14 +01:00
Lednerb
e21b923194 Added Ubuntu 14.04 Trusty, didn't check if the configfiles are working 2015-01-10 23:46:37 +01:00
Michael Kaufmann
9ab90aa3b9 Merge pull request #219 from Lednerb/master
Updated language files
2015-01-10 18:19:14 +01:00
Sascha Brendel
797db9aa8b Merge pull request #5 from Lednerb/patch-8
Update swedish.lng.php
2015-01-10 18:15:04 +01:00
Sascha Brendel
982421b9b3 Merge pull request #4 from Lednerb/patch-7
Update portugues.lng.php
2015-01-10 18:14:44 +01:00
Sascha Brendel
d0d7e7f369 Merge pull request #3 from Lednerb/patch-4
Update french.lng.php
2015-01-10 18:14:25 +01:00
Sascha Brendel
0b35c833f3 Merge pull request #2 from Lednerb/patch-5
Update italian.lng.php
2015-01-10 18:14:03 +01:00
Sascha Brendel
aef58921ce Merge pull request #1 from Lednerb/patch-6
Patch 6
2015-01-10 18:13:36 +01:00
Sascha Brendel
b681d9ba90 Update swedish.lng.php 2015-01-10 18:11:26 +01:00
Sascha Brendel
caedb34d00 Update portugues.lng.php
removed duplicated entry
2015-01-10 18:09:37 +01:00
Sascha Brendel
251fa70228 Update english.lng.php 2015-01-10 18:06:12 +01:00
Sascha Brendel
ced2f0c3d4 Update italian.lng.php
Removed duplicated entries
2015-01-10 17:58:04 +01:00
Michael Kaufmann
25514e1030 Merge pull request #217 from Lednerb/patch-2
Update english.lng.php
2015-01-10 17:28:31 +01:00
Michael Kaufmann
196454c7ab Merge pull request #216 from Lednerb/patch-1
Update german.lng.php
2015-01-10 17:22:01 +01:00
Sascha Brendel
331b65e384 Update french.lng.php
Commented & Removed doubled entries.
The uncommented versions were the newer ones.
2015-01-10 17:20:49 +01:00
Sascha Brendel
794140f3c1 Update english.lng.php
Removed multiple definitions.
If in doubt, more recent entries have been used.
2015-01-10 16:52:40 +01:00
Sascha Brendel
22eeeaf231 Update german.lng.php
Doppelte Einträge entfernt, im Zweifelsfall aktuellere Einträge übernommen.
2015-01-10 15:48:14 +01:00
Michael Kaufmann (d00p)
aff531a274 set from and reply to from settings in usage-report-mails
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-10 07:33:40 +01:00
Michael Kaufmann (d00p)
c1ff010283 allow 'localhost' or any local-hostname for db-connection
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-08 14:39:52 +01:00
Michael Kaufmann (d00p)
bb3376d1aa update Smarty to version 3.1.21
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-07 18:18:16 +01:00
Michael Kaufmann (d00p)
bcd49186fb update phpMailer to 5.2.9
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-07 18:12:27 +01:00
Michael Kaufmann (d00p)
c0f2745d30 of course, still allow localhost/127.0.0.1 as valid-ip xD
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-07 16:34:58 +01:00
Michael Kaufmann (d00p)
64959c75fe clear out whether pcntl extension is not installed or just pcntl_fork is unavailable, fixes #1469
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-07 15:36:35 +01:00
Michael Kaufmann (d00p)
82fdb84e61 give possibility to specify a socket-file as 'host' in userdata.inc.php to connect via mysql-socket instead of hostname; not a setting because this might break some other stuff (mysql-access-hosts -> problems when adding mysql-users/databases, etc.)
Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
2015-01-07 15:13:32 +01:00
Michael Kaufmann
10acd16e17 Merge pull request #215 from junkpad92/patch-1
Fixing spelling mistake
2015-01-06 16:05:41 +01:00
junkpad92
21adfeed89 Update german.lng.php 2015-01-06 15:31:51 +01:00
junkpad92
791f12401f Fixing spelling mistake 2015-01-06 15:31:08 +01:00
junkpad92
d78fde88ce Merge branch 'master' of https://github.com/junkpad92/Froxlor 2014-12-17 17:22:23 +01:00
junkpad92
56b652d185 Fixing deprecated Postfix templates & Providing Dovecot2 Sieve-Configs 2014-12-17 17:21:28 +01:00
junkpad92
c69d023685 Install dovecot-managesieved and dovecot-sieve 2014-12-17 17:18:21 +01:00
junkpad92
99a249ac5c Install dovecot-managesieved and dovecot-sieve
Added also config files.
2014-12-17 17:13:22 +01:00
junkpad92
060f10f064 Fixing deprecated Postfix templates & Providing Dovecot2 Sieve-Configs 2014-12-16 21:42:16 +01:00
Ante
34f20ffd1a Added RHEL 7 configfiles 2014-09-30 11:07:37 +02:00
793 changed files with 15462 additions and 35330 deletions

1
.gitignore vendored
View File

@@ -1,4 +1,3 @@
lib/classes/htmlpurifier/library/HTMLPurifier/DefinitionCache/Serializer/*/
templates/* templates/*
logs/* logs/*
install/update.log install/update.log

View File

@@ -29,6 +29,14 @@ return array(
'default' => '/etc/cron.d/froxlor', 'default' => '/etc/cron.d/froxlor',
'save_method' => 'storeSettingField', 'save_method' => 'storeSettingField',
), ),
'system_send_cron_errors' => array(
'label' => $lng['serversettings']['system_send_cron_errors'],
'settinggroup' => 'system',
'varname' => 'send_cron_errors',
'type' => 'bool',
'default' => false,
'save_method' => 'storeSettingField',
),
'system_croncmdline' => array( 'system_croncmdline' => array(
'label' => $lng['serversettings']['system_croncmdline'], 'label' => $lng['serversettings']['system_croncmdline'],
'settinggroup' => 'system', 'settinggroup' => 'system',

View File

@@ -93,6 +93,9 @@ if ($page == 'admins'
$row = str_replace_array('-1', 'UL', $row, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps subdomains tickets'); $row = str_replace_array('-1', 'UL', $row, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps subdomains tickets');
$row = htmlentities_array($row); $row = htmlentities_array($row);
$row['custom_notes'] = ($row['custom_notes'] != '') ? nl2br($row['custom_notes']) : '';
eval("\$admins.=\"" . getTemplate("admins/admins_admin") . "\";"); eval("\$admins.=\"" . getTemplate("admins/admins_admin") . "\";");
$count++; $count++;
} }
@@ -198,6 +201,9 @@ if ($page == 'admins'
$name = validate($_POST['name'], 'name'); $name = validate($_POST['name'], 'name');
$email = $idna_convert->encode(validate($_POST['email'], 'email')); $email = $idna_convert->encode(validate($_POST['email'], 'email'));
$custom_notes = validate(str_replace("\r\n", "\n", $_POST['custom_notes']), 'custom_notes', '/^[^\0]*$/');
$custom_notes_show = intval_ressource($_POST['custom_notes_show']);
$loginname = validate($_POST['loginname'], 'loginname'); $loginname = validate($_POST['loginname'], 'loginname');
$password = validate($_POST['admin_password'], 'password'); $password = validate($_POST['admin_password'], 'password');
$password = validatePassword($password); $password = validatePassword($password);
@@ -388,7 +394,9 @@ if ($page == 'admins'
'tickets_see_all' => $tickets_see_all, 'tickets_see_all' => $tickets_see_all,
'mysqls' => $mysqls, 'mysqls' => $mysqls,
'ip' => $ipaddress, 'ip' => $ipaddress,
'theme' => $_theme 'theme' => $_theme,
'custom_notes' => $custom_notes,
'custom_notes_show' => $custom_notes_show
); );
$ins_stmt = Database::prepare(" $ins_stmt = Database::prepare("
@@ -416,7 +424,9 @@ if ($page == 'admins'
`tickets_see_all` = :tickets_see_all, `tickets_see_all` = :tickets_see_all,
`mysqls` = :mysqls, `mysqls` = :mysqls,
`ip` = :ip, `ip` = :ip,
`theme` = :theme `theme` = :theme,
`custom_notes` = :custom_notes,
`custom_notes_show` = :custom_notes_show
"); ");
Database::pexecute($ins_stmt, $ins_data); Database::pexecute($ins_stmt, $ins_data);
@@ -487,6 +497,9 @@ if ($page == 'admins'
$name = validate($_POST['name'], 'name'); $name = validate($_POST['name'], 'name');
$email = $idna_convert->encode(validate($_POST['email'], 'email')); $email = $idna_convert->encode(validate($_POST['email'], 'email'));
$custom_notes = validate(str_replace("\r\n", "\n", $_POST['custom_notes']), 'custom_notes', '/^[^\0]*$/');
$custom_notes_show = intval_ressource($_POST['custom_notes_show']);
if ($result['adminid'] == $userinfo['userid']) { if ($result['adminid'] == $userinfo['userid']) {
$password = ''; $password = '';
@@ -721,6 +734,8 @@ if ($page == 'admins'
'mysqls' => $mysqls, 'mysqls' => $mysqls,
'ip' => $ipaddress, 'ip' => $ipaddress,
'deactivated' => $deactivated, 'deactivated' => $deactivated,
'custom_notes' => $custom_notes,
'custom_notes_show' => $custom_notes_show,
'adminid' => $id 'adminid' => $id
); );
@@ -748,7 +763,9 @@ if ($page == 'admins'
`tickets_see_all` = :tickets_see_all, `tickets_see_all` = :tickets_see_all,
`mysqls` = :mysqls, `mysqls` = :mysqls,
`ip` = :ip, `ip` = :ip,
`deactivated` = :deactivated `deactivated` = :deactivated,
`custom_notes` = :custom_notes,
`custom_notes_show` = :custom_notes_show
WHERE `adminid` = :adminid WHERE `adminid` = :adminid
"); ");
Database::pexecute($upd_stmt, $upd_data); Database::pexecute($upd_stmt, $upd_data);

View File

@@ -128,6 +128,8 @@ if ($page == 'customers'
$traffic_percent = 100; $traffic_percent = 100;
} }
$row['custom_notes'] = ($row['custom_notes'] != '') ? nl2br($row['custom_notes']) : '';
eval("\$customers.=\"" . getTemplate("customers/customers_customer") . "\";"); eval("\$customers.=\"" . getTemplate("customers/customers_customer") . "\";");
$count++; $count++;
} }
@@ -417,6 +419,9 @@ if ($page == 'customers'
$def_language = validate($_POST['def_language'], 'default language'); $def_language = validate($_POST['def_language'], 'default language');
$gender = intval_ressource($_POST['gender']); $gender = intval_ressource($_POST['gender']);
$custom_notes = validate(str_replace("\r\n", "\n", $_POST['custom_notes']), 'custom_notes', '/^[^\0]*$/');
$custom_notes_show = intval_ressource($_POST['custom_notes_show']);
$diskspace = intval_ressource($_POST['diskspace']); $diskspace = intval_ressource($_POST['diskspace']);
if (isset($_POST['diskspace_ul'])) { if (isset($_POST['diskspace_ul'])) {
$diskspace = - 1; $diskspace = - 1;
@@ -632,7 +637,7 @@ if ($page == 'customers'
} }
if ($password == '') { if ($password == '') {
$password = substr(md5(uniqid(microtime(), 1)), 12, 6); $password = generatePassword();
} }
$_theme = Settings::Get('panel.default_theme'); $_theme = Settings::Get('panel.default_theme');
@@ -669,7 +674,9 @@ if ($page == 'customers'
'imap' => $email_imap, 'imap' => $email_imap,
'pop3' => $email_pop3, 'pop3' => $email_pop3,
'perlenabled' => $perlenabled, 'perlenabled' => $perlenabled,
'theme' => $_theme 'theme' => $_theme,
'custom_notes' => $custom_notes,
'custom_notes_show' => $custom_notes_show
); );
$ins_stmt = Database::prepare(" $ins_stmt = Database::prepare("
@@ -706,7 +713,9 @@ if ($page == 'customers'
`imap` = :imap, `imap` = :imap,
`pop3` = :pop3, `pop3` = :pop3,
`perlenabled` = :perlenabled, `perlenabled` = :perlenabled,
`theme` = :theme" `theme` = :theme,
`custom_notes` = :custom_notes,
`custom_notes_show` = :custom_notes_show"
); );
Database::pexecute($ins_stmt, $ins_data); Database::pexecute($ins_stmt, $ins_data);
@@ -1063,6 +1072,9 @@ if ($page == 'customers'
$move_to_admin = isset($_POST['move_to_admin']) ? intval_ressource($_POST['move_to_admin']) : 0; $move_to_admin = isset($_POST['move_to_admin']) ? intval_ressource($_POST['move_to_admin']) : 0;
$custom_notes = validate(str_replace("\r\n", "\n", $_POST['custom_notes']), 'custom_notes', '/^[^\0]*$/');
$custom_notes_show = intval_ressource($_POST['custom_notes_show']);
$diskspace = intval_ressource($_POST['diskspace']); $diskspace = intval_ressource($_POST['diskspace']);
if (isset($_POST['diskspace_ul'])) { if (isset($_POST['diskspace_ul'])) {
$diskspace = - 1; $diskspace = - 1;
@@ -1398,7 +1410,9 @@ if ($page == 'customers'
'phpenabled' => $phpenabled, 'phpenabled' => $phpenabled,
'imap' => $email_imap, 'imap' => $email_imap,
'pop3' => $email_pop3, 'pop3' => $email_pop3,
'perlenabled' => $perlenabled 'perlenabled' => $perlenabled,
'custom_notes' => $custom_notes,
'custom_notes_show' => $custom_notes_show
); );
$upd_stmt = Database::prepare(" $upd_stmt = Database::prepare("
UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET UPDATE `" . TABLE_PANEL_CUSTOMERS . "` SET
@@ -1429,7 +1443,9 @@ if ($page == 'customers'
`email_quota` = :email_quota, `email_quota` = :email_quota,
`imap` = :imap, `imap` = :imap,
`pop3` = :pop3, `pop3` = :pop3,
`perlenabled` = :perlenabled `perlenabled` = :perlenabled,
`custom_notes` = :custom_notes,
`custom_notes_show` = :custom_notes_show
WHERE `customerid` = :customerid" WHERE `customerid` = :customerid"
); );
Database::pexecute($upd_stmt, $upd_data); Database::pexecute($upd_stmt, $upd_data);

View File

@@ -1911,7 +1911,7 @@ if ($page == 'domains'
$customerid = intval($_POST['customerid']); $customerid = intval($_POST['customerid']);
$separator = validate($_POST['separator'], 'separator'); $separator = validate($_POST['separator'], 'separator');
$offset = validate($_POST['offset'], 'offset', "/[0-9]/i"); $offset = (int)validate($_POST['offset'], 'offset', "/[0-9]/i");
$file_name = $_FILES['file']['tmp_name']; $file_name = $_FILES['file']['tmp_name'];

View File

@@ -140,6 +140,8 @@ if ($page == 'overview') {
$userinfo['traffic_used'] = round($userinfo['traffic_used'] / (1024 * 1024), $dec_places); $userinfo['traffic_used'] = round($userinfo['traffic_used'] / (1024 * 1024), $dec_places);
$userinfo = str_replace_array('-1', $lng['customer']['unlimited'], $userinfo, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps tickets subdomains'); $userinfo = str_replace_array('-1', $lng['customer']['unlimited'], $userinfo, 'customers domains diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps tickets subdomains');
$userinfo['custom_notes'] = ($userinfo['custom_notes'] != '') ? nl2br($userinfo['custom_notes']) : '';
$cron_last_runs = getCronjobsLastRun(); $cron_last_runs = getCronjobsLastRun();
$outstanding_tasks = getOutstandingTasks(); $outstanding_tasks = getOutstandingTasks();

View File

@@ -158,8 +158,10 @@ if ($page == 'tickets'
} }
$row['subject'] = html_entity_decode($row['subject']); $row['subject'] = html_entity_decode($row['subject']);
if (strlen($row['subject']) > 20) { if (strlen($row['subject']) > 30) {
$row['subject'] = substr($row['subject'], 0, 17) . '...'; $ts = wordwrap($row['subject'], 30, "|");
$ts = explode("|", $ts);
$row['subject'] = $ts[0]. '...';
} }
eval("\$tickets.=\"" . getTemplate("tickets/tickets_tickets") . "\";"); eval("\$tickets.=\"" . getTemplate("tickets/tickets_tickets") . "\";");

Binary file not shown.

Before

Width:  |  Height:  |  Size: 491 B

After

Width:  |  Height:  |  Size: 369 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 336 B

After

Width:  |  Height:  |  Size: 232 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 421 B

After

Width:  |  Height:  |  Size: 321 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 353 B

After

Width:  |  Height:  |  Size: 246 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 401 B

After

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.7 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.5 KiB

After

Width:  |  Height:  |  Size: 4.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 6.2 KiB

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@@ -230,6 +230,12 @@ if ($page == 'overview') {
$domain_check = Database::pexecute_first($domain_stmt, array("domain" => $domain, "customerid" => $userinfo['customerid'])); $domain_check = Database::pexecute_first($domain_stmt, array("domain" => $domain, "customerid" => $userinfo['customerid']));
$completedomain = $subdomain . '.' . $domain; $completedomain = $subdomain . '.' . $domain;
if ($completedomain == Settings::Get('system.hostname')) {
standard_error('admin_domain_emailsystemhostname');
exit;
}
$completedomain_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAINS . "` $completedomain_stmt = Database::prepare("SELECT * FROM `" . TABLE_PANEL_DOMAINS . "`
WHERE `domain` = :domain WHERE `domain` = :domain
AND `customerid` = :customerid AND `customerid` = :customerid

View File

@@ -85,6 +85,8 @@ if ($page == 'overview') {
$userinfo['traffic_used'] = round($userinfo['traffic_used'] / (1024 * 1024), Settings::Get('panel.decimal_places')); $userinfo['traffic_used'] = round($userinfo['traffic_used'] / (1024 * 1024), Settings::Get('panel.decimal_places'));
$userinfo = str_replace_array('-1', $lng['customer']['unlimited'], $userinfo, 'diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps tickets subdomains'); $userinfo = str_replace_array('-1', $lng['customer']['unlimited'], $userinfo, 'diskspace traffic mysqls emails email_accounts email_forwarders email_quota ftps tickets subdomains');
$userinfo['custom_notes'] = ($userinfo['custom_notes'] != '') ? nl2br($userinfo['custom_notes']) : '';
$services_enabled = ""; $services_enabled = "";
$se = array(); $se = array();
if ($userinfo['imap'] == '1') $se[] = "IMAP"; if ($userinfo['imap'] == '1') $se[] = "IMAP";

View File

@@ -219,7 +219,7 @@ if ($page == 'overview') {
'DB_NAME' => $username, 'DB_NAME' => $username,
'DB_PASS' => $password, 'DB_PASS' => $password,
'DB_DESC' => $databasedescription, 'DB_DESC' => $databasedescription,
'DB_SRV' => $sql_root['caption'], 'DB_SRV' => $sql_root['host'],
'PMA_URI' => $pma 'PMA_URI' => $pma
); );

View File

@@ -92,8 +92,10 @@ if ($page == 'overview') {
} }
$row['subject'] = html_entity_decode($row['subject']); $row['subject'] = html_entity_decode($row['subject']);
if (strlen($row['subject']) > 20) { if (strlen($row['subject']) > 30) {
$row['subject'] = substr($row['subject'], 0, 17) . '...'; $ts = wordwrap($row['subject'], 30, "|");
$ts = explode("|", $ts);
$row['subject'] = $ts[0]. '...';
} }
eval("\$tickets.=\"" . getTemplate("tickets/tickets_tickets") . "\";"); eval("\$tickets.=\"" . getTemplate("tickets/tickets_tickets") . "\";");

View File

@@ -118,7 +118,7 @@ if ($action == 'login') {
if ($userinfo['loginfail_count'] >= Settings::Get('login.maxloginattempts') && $userinfo['lastlogin_fail'] > (time() - Settings::Get('login.deactivatetime'))) { if ($userinfo['loginfail_count'] >= Settings::Get('login.maxloginattempts') && $userinfo['lastlogin_fail'] > (time() - Settings::Get('login.deactivatetime'))) {
redirectTo('index.php', array('showmessage' => '3')); redirectTo('index.php', array('showmessage' => '3'));
exit; exit;
} elseif ($userinfo['password'] == md5($password)) { } elseif (validatePasswordLogin($userinfo, $password, $table, $uid)) {
// login correct // login correct
// reset loginfail_counter, set lastlogin_succ // reset loginfail_counter, set lastlogin_succ
$stmt = Database::prepare("UPDATE $table $stmt = Database::prepare("UPDATE $table

View File

@@ -91,7 +91,7 @@ DROP TABLE IF EXISTS `panel_admins`;
CREATE TABLE `panel_admins` ( CREATE TABLE `panel_admins` (
`adminid` int(11) unsigned NOT NULL auto_increment, `adminid` int(11) unsigned NOT NULL auto_increment,
`loginname` varchar(50) NOT NULL default '', `loginname` varchar(50) NOT NULL default '',
`password` varchar(50) NOT NULL default '', `password` varchar(255) NOT NULL default '',
`name` varchar(255) NOT NULL default '', `name` varchar(255) NOT NULL default '',
`email` varchar(255) NOT NULL default '', `email` varchar(255) NOT NULL default '',
`def_language` varchar(255) NOT NULL default '', `def_language` varchar(255) NOT NULL default '',
@@ -131,6 +131,8 @@ CREATE TABLE `panel_admins` (
`loginfail_count` int(11) unsigned NOT NULL default '0', `loginfail_count` int(11) unsigned NOT NULL default '0',
`reportsent` tinyint(4) unsigned NOT NULL default '0', `reportsent` tinyint(4) unsigned NOT NULL default '0',
`theme` varchar(255) NOT NULL default 'Sparkle', `theme` varchar(255) NOT NULL default 'Sparkle',
`custom_notes` text,
`custom_notes_show` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`adminid`), PRIMARY KEY (`adminid`),
UNIQUE KEY `loginname` (`loginname`) UNIQUE KEY `loginname` (`loginname`)
) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_general_ci;
@@ -141,7 +143,7 @@ DROP TABLE IF EXISTS `panel_customers`;
CREATE TABLE `panel_customers` ( CREATE TABLE `panel_customers` (
`customerid` int(11) unsigned NOT NULL auto_increment, `customerid` int(11) unsigned NOT NULL auto_increment,
`loginname` varchar(50) NOT NULL default '', `loginname` varchar(50) NOT NULL default '',
`password` varchar(50) NOT NULL default '', `password` varchar(255) NOT NULL default '',
`adminid` int(11) unsigned NOT NULL default '0', `adminid` int(11) unsigned NOT NULL default '0',
`name` varchar(255) NOT NULL default '', `name` varchar(255) NOT NULL default '',
`firstname` varchar(255) NOT NULL default '', `firstname` varchar(255) NOT NULL default '',
@@ -190,6 +192,8 @@ CREATE TABLE `panel_customers` (
`imap` tinyint(1) NOT NULL default '1', `imap` tinyint(1) NOT NULL default '1',
`perlenabled` tinyint(1) NOT NULL default '0', `perlenabled` tinyint(1) NOT NULL default '0',
`theme` varchar(255) NOT NULL default 'Sparkle', `theme` varchar(255) NOT NULL default 'Sparkle',
`custom_notes` text,
`custom_notes_show` tinyint(1) NOT NULL default '0',
PRIMARY KEY (`customerid`), PRIMARY KEY (`customerid`),
UNIQUE KEY `loginname` (`loginname`) UNIQUE KEY `loginname` (`loginname`)
) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_general_ci; ) ENGINE=MyISAM CHARSET=utf8 COLLATE=utf8_general_ci;
@@ -488,7 +492,7 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES
('system', 'phpreload_command', ''), ('system', 'phpreload_command', ''),
('system', 'apache24', '0'), ('system', 'apache24', '0'),
('system', 'documentroot_use_default_value', '0'), ('system', 'documentroot_use_default_value', '0'),
('system', 'passwordcryptfunc', '1'), ('system', 'passwordcryptfunc', '3'),
('system', 'axfrservers', ''), ('system', 'axfrservers', ''),
('system', 'customer_ssl_path', '/etc/ssl/froxlor-custom/'), ('system', 'customer_ssl_path', '/etc/ssl/froxlor-custom/'),
('system', 'allow_error_report_admin', '1'), ('system', 'allow_error_report_admin', '1'),
@@ -503,6 +507,7 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES
('system', 'croncmdline', '/usr/bin/nice -n 5 /usr/bin/php5 -q'), ('system', 'croncmdline', '/usr/bin/nice -n 5 /usr/bin/php5 -q'),
('system', 'cron_allowautoupdate', '0'), ('system', 'cron_allowautoupdate', '0'),
('system', 'dns_createhostnameentry', '0'), ('system', 'dns_createhostnameentry', '0'),
('system', 'send_cron_errors', '0'),
('panel', 'decimal_places', '4'), ('panel', 'decimal_places', '4'),
('panel', 'adminmail', 'admin@SERVERNAME'), ('panel', 'adminmail', 'admin@SERVERNAME'),
('panel', 'phpmyadmin_url', ''), ('panel', 'phpmyadmin_url', ''),
@@ -532,8 +537,8 @@ INSERT INTO `panel_settings` (`settinggroup`, `varname`, `value`) VALUES
('panel', 'password_alpha_upper', '1'), ('panel', 'password_alpha_upper', '1'),
('panel', 'password_numeric', '0'), ('panel', 'password_numeric', '0'),
('panel', 'password_special_char_required', '0'), ('panel', 'password_special_char_required', '0'),
('panel', 'password_special_char', '!?<>§$%&+#=@'), ('panel', 'password_special_char', '!?<>§$%+#=@'),
('panel', 'version', '0.9.33-rc1'); ('panel', 'version', '0.9.33-rc2');
DROP TABLE IF EXISTS `panel_tasks`; DROP TABLE IF EXISTS `panel_tasks`;

View File

@@ -27,13 +27,16 @@ if(@php_sapi_name() != 'cli'
} }
// Check argument count // Check argument count
/*
if (sizeof($argv) != 2) { if (sizeof($argv) != 2) {
print_help($argv); print_help($argv);
exit; exit;
} }
*/
// Load the contents of the given path // Load the contents of the given path
$path = $argv[1]; $path = $argv[1];
$_f = isset($argv[2]) ? $argv[2] : null;
$files = array(); $files = array();
if ($dh = opendir($path)) { if ($dh = opendir($path)) {
@@ -43,7 +46,9 @@ if ($dh = opendir($path)) {
&& !is_dir($file) && !is_dir($file)
&& preg_match('/(.+)\.lng\.php/i', $file) && preg_match('/(.+)\.lng\.php/i', $file)
) { ) {
$files[$file] = str_replace('//', '/', $path . '/' . $file); if (is_null($_f) || (!is_null($_f) && ($file == $_f || $file == $baseLanguage))) {
$files[$file] = str_replace('//', '/', $path . '/' . $file);
}
} }
} }

BIN
install/templates/assets/img/password.png Executable file → Normal file

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -2852,3 +2852,27 @@ if (isFroxlorVersion('0.9.33-dev3')) {
updateToVersion('0.9.33-rc1'); updateToVersion('0.9.33-rc1');
} }
if (isFroxlorVersion('0.9.33-rc1')) {
showUpdateStep("Updating from 0.9.33-rc1 to 0.9.33-rc2", false);
showUpdateStep("Add new setting for sending cron-errors via mail");
$sendcronerrors = isset($_POST['system_send_cron_errors']) ? (int)$_POST['system_send_cron_errors'] : "0";
Settings::addNew('system.send_cron_errors', $sendcronerrors);
lastStepStatus(0);
showUpdateStep("Add new custom-notes field for admins and customer");
Database::query("ALTER TABLE `".TABLE_PANEL_ADMINS."` ADD `custom_notes` text AFTER `theme`");
Database::query("ALTER TABLE `".TABLE_PANEL_ADMINS."` ADD `custom_notes_show` tinyint(1) NOT NULL default '0' AFTER `custom_notes`");
Database::query("ALTER TABLE `".TABLE_PANEL_CUSTOMERS."` ADD `custom_notes` text AFTER `theme`");
Database::query("ALTER TABLE `".TABLE_PANEL_CUSTOMERS."` ADD `custom_notes_show` tinyint(1) NOT NULL default '0' AFTER `custom_notes`");
lastStepStatus(0);
// go from varchar(50) to varchar(255) because of some hashes that are longer than that
showUpdateStep("Updating table structure of admins and customers");
Database::query("ALTER TABLE `".TABLE_PANEL_ADMINS."` MODIFY `password` varchar(255) NOT NULL default ''");
Database::query("ALTER TABLE `".TABLE_PANEL_CUSTOMERS."` MODIFY `password` varchar(255) NOT NULL default ''");
lastStepStatus(0);
updateToVersion('0.9.33-rc2');
}

View File

@@ -679,4 +679,11 @@ function parseAndOutputPreconfig(&$has_preconfig, &$return, $current_version) {
} }
} }
if (versionInUpdate($current_version, '0.9.33-rc2')) {
$has_preconfig = true;
$description = 'You can chose whether you want to receive an e-mail on cronjob errors. Keep in mind that this can lead to an e-mail being sent every 5 minutes.<br /><br />';
$question = '<strong>Do you want to receive cron-errors via mail? (default: no):</strong>&nbsp;';
$question.= makeyesno('system_send_cron_errors', '1', '0', '0').'<br />';
eval("\$return.=\"" . getTemplate("update/preconfigitem") . "\";");
}
} }

View File

@@ -25,6 +25,8 @@ require './userdata.inc.php';
require './tables.inc.php'; require './tables.inc.php';
require './classes/database/class.Database.php'; require './classes/database/class.Database.php';
require './classes/settings/class.Settings.php'; require './classes/settings/class.Settings.php';
require './functions/validate/function.validate_ip.php';
require './functions/validate/function.validateDomain.php';
if(isset($_POST['action'])) { if(isset($_POST['action'])) {
$action = $_POST['action']; $action = $_POST['action'];
@@ -72,7 +74,19 @@ if ($action == "newsfeed") {
$content = preg_replace("/[\r\n]+/", " ", strip_tags($item->description)); $content = preg_replace("/[\r\n]+/", " ", strip_tags($item->description));
$content = substr($content, 0, 150) . "..."; $content = substr($content, 0, 150) . "...";
echo "<tr class=\"newsitem\"><td><small>" . $date . "</small><br /><a href=\"" . $link . "\" target=\"_blank\"><b>" . $title . "</b><br />" . $content . "</a></td></tr>"; echo "<li class=\"clearfix\">
<div class=\"newsfeed-body clearfix\">
<div class=\"header\">
<strong class=\"primary-font\"><a href=\"{$link}\" target=\"_blank\">{$title}</a></strong>
<small class=\"pull-right text-muted\">
<i class=\"fa fa-clock-o fa-fw\"></i> {$date}
</small>
</div>
<p>
{$content}
</p>
</div>
</li>";
} }
} else { } else {
echo ""; echo "";

View File

@@ -1 +1 @@
Smarty-3.1.15/libs/ Smarty-3.1.21/libs/

View File

@@ -1,30 +0,0 @@
<?php
/**
* Example Application
* @package Example-application
*/
require '../libs/Smarty.class.php';
$smarty = new Smarty;
//$smarty->force_compile = true;
$smarty->debugging = true;
$smarty->caching = true;
$smarty->cache_lifetime = 120;
$smarty->assign("Name","Fred Irving Johnathan Bradley Peppergill",true);
$smarty->assign("FirstName",array("John","Mary","James","Henry"));
$smarty->assign("LastName",array("Doe","Smith","Johnson","Case"));
$smarty->assign("Class",array(array("A","B","C","D"), array("E", "F", "G", "H"),
array("I", "J", "K", "L"), array("M", "N", "O", "P")));
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
$smarty->assign("option_values", array("NY","NE","KS","IA","OK","TX"));
$smarty->assign("option_output", array("New York","Nebraska","Kansas","Iowa","Oklahoma","Texas"));
$smarty->assign("option_selected", "NE");
$smarty->display('index.tpl');

View File

@@ -1,82 +0,0 @@
{config_load file="test.conf" section="setup"}
{include file="header.tpl" title=foo}
<PRE>
{* bold and title are read from the config file *}
{if #bold#}<b>{/if}
{* capitalize the first letters of each word of the title *}
Title: {#title#|capitalize}
{if #bold#}</b>{/if}
The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
The value of {ldelim}$Name{rdelim} is <b>{$Name}</b>
variable modifier example of {ldelim}$Name|upper{rdelim}
<b>{$Name|upper}</b>
An example of a section loop:
{section name=outer
loop=$FirstName}
{if $smarty.section.outer.index is odd by 2}
{$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
{else}
{$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
{/if}
{sectionelse}
none
{/section}
An example of section looped key values:
{section name=sec1 loop=$contacts}
phone: {$contacts[sec1].phone}<br>
fax: {$contacts[sec1].fax}<br>
cell: {$contacts[sec1].cell}<br>
{/section}
<p>
testing strip tags
{strip}
<table border=0>
<tr>
<td>
<A HREF="{$SCRIPT_NAME}">
<font color="red">This is a test </font>
</A>
</td>
</tr>
</table>
{/strip}
</PRE>
This is an example of the html_select_date function:
<form>
{html_select_date start_year=1998 end_year=2010}
</form>
This is an example of the html_select_time function:
<form>
{html_select_time use_24_hours=false}
</form>
This is an example of the html_options function:
<form>
<select name=states>
{html_options values=$option_values selected=$option_selected output=$option_output}
</select>
</form>
{include file="footer.tpl"}

View File

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

View File

@@ -1,277 +0,0 @@
<?php
/**
* Smarty Internal Plugin CacheResource File
*
* @package Smarty
* @subpackage Cacher
* @author Uwe Tews
* @author Rodney Rehm
*/
/**
* This class does contain all necessary methods for the HTML cache on file system
*
* Implements the file system as resource for the HTML cache Version ussing nocache inserts.
*
* @package Smarty
* @subpackage Cacher
*/
class Smarty_Internal_CacheResource_File extends Smarty_CacheResource
{
/**
* populate Cached Object with meta data from Resource
*
* @param Smarty_Template_Cached $cached cached object
* @param Smarty_Internal_Template $_template template object
* @return void
*/
public function populate(Smarty_Template_Cached $cached, Smarty_Internal_Template $_template)
{
$_source_file_path = str_replace(':', '.', $_template->source->filepath);
$_cache_id = isset($_template->cache_id) ? preg_replace('![^\w\|]+!', '_', $_template->cache_id) : null;
$_compile_id = isset($_template->compile_id) ? preg_replace('![^\w\|]+!', '_', $_template->compile_id) : null;
$_filepath = $_template->source->uid;
// if use_sub_dirs, break file into directories
if ($_template->smarty->use_sub_dirs) {
$_filepath = substr($_filepath, 0, 2) . DS
. substr($_filepath, 2, 2) . DS
. substr($_filepath, 4, 2) . DS
. $_filepath;
}
$_compile_dir_sep = $_template->smarty->use_sub_dirs ? DS : '^';
if (isset($_cache_id)) {
$_cache_id = str_replace('|', $_compile_dir_sep, $_cache_id) . $_compile_dir_sep;
} else {
$_cache_id = '';
}
if (isset($_compile_id)) {
$_compile_id = $_compile_id . $_compile_dir_sep;
} else {
$_compile_id = '';
}
$_cache_dir = $_template->smarty->getCacheDir();
if ($_template->smarty->cache_locking) {
// create locking file name
// relative file name?
if (!preg_match('/^([\/\\\\]|[a-zA-Z]:[\/\\\\])/', $_cache_dir)) {
$_lock_dir = rtrim(getcwd(), '/\\') . DS . $_cache_dir;
} else {
$_lock_dir = $_cache_dir;
}
$cached->lock_id = $_lock_dir.sha1($_cache_id.$_compile_id.$_template->source->uid).'.lock';
}
$cached->filepath = $_cache_dir . $_cache_id . $_compile_id . $_filepath . '.' . basename($_source_file_path) . '.php';
$cached->timestamp = @filemtime($cached->filepath);
$cached->exists = !!$cached->timestamp;
}
/**
* populate Cached Object with timestamp and exists from Resource
*
* @param Smarty_Template_Cached $cached cached object
* @return void
*/
public function populateTimestamp(Smarty_Template_Cached $cached)
{
$cached->timestamp = @filemtime($cached->filepath);
$cached->exists = !!$cached->timestamp;
}
/**
* Read the cached template and process its header
*
* @param Smarty_Internal_Template $_template template object
* @param Smarty_Template_Cached $cached cached object
* @return booelan true or false if the cached content does not exist
*/
public function process(Smarty_Internal_Template $_template, Smarty_Template_Cached $cached=null)
{
$_smarty_tpl = $_template;
return @include $_template->cached->filepath;
}
/**
* Write the rendered template output to cache
*
* @param Smarty_Internal_Template $_template template object
* @param string $content content to cache
* @return boolean success
*/
public function writeCachedContent(Smarty_Internal_Template $_template, $content)
{
if (Smarty_Internal_Write_File::writeFile($_template->cached->filepath, $content, $_template->smarty) === true) {
$_template->cached->timestamp = @filemtime($_template->cached->filepath);
$_template->cached->exists = !!$_template->cached->timestamp;
if ($_template->cached->exists) {
return true;
}
}
return false;
}
/**
* Empty cache
*
* @param Smarty_Internal_Template $_template template object
* @param integer $exp_time expiration time (number of seconds, not timestamp)
* @return integer number of cache files deleted
*/
public function clearAll(Smarty $smarty, $exp_time = null)
{
return $this->clear($smarty, null, null, null, $exp_time);
}
/**
* Empty cache for a specific template
*
* @param Smarty $_template template object
* @param string $resource_name template name
* @param string $cache_id cache id
* @param string $compile_id compile id
* @param integer $exp_time expiration time (number of seconds, not timestamp)
* @return integer number of cache files deleted
*/
public function clear(Smarty $smarty, $resource_name, $cache_id, $compile_id, $exp_time)
{
$_cache_id = isset($cache_id) ? preg_replace('![^\w\|]+!', '_', $cache_id) : null;
$_compile_id = isset($compile_id) ? preg_replace('![^\w\|]+!', '_', $compile_id) : null;
$_dir_sep = $smarty->use_sub_dirs ? '/' : '^';
$_compile_id_offset = $smarty->use_sub_dirs ? 3 : 0;
$_dir = $smarty->getCacheDir();
$_dir_length = strlen($_dir);
if (isset($_cache_id)) {
$_cache_id_parts = explode('|', $_cache_id);
$_cache_id_parts_count = count($_cache_id_parts);
if ($smarty->use_sub_dirs) {
foreach ($_cache_id_parts as $id_part) {
$_dir .= $id_part . DS;
}
}
}
if (isset($resource_name)) {
$_save_stat = $smarty->caching;
$smarty->caching = true;
$tpl = new $smarty->template_class($resource_name, $smarty);
$smarty->caching = $_save_stat;
// remove from template cache
$tpl->source; // have the template registered before unset()
if ($smarty->allow_ambiguous_resources) {
$_templateId = $tpl->source->unique_resource . $tpl->cache_id . $tpl->compile_id;
} else {
$_templateId = $smarty->joined_template_dir . '#' . $resource_name . $tpl->cache_id . $tpl->compile_id;
}
if (isset($_templateId[150])) {
$_templateId = sha1($_templateId);
}
unset($smarty->template_objects[$_templateId]);
if ($tpl->source->exists) {
$_resourcename_parts = basename(str_replace('^', '/', $tpl->cached->filepath));
} else {
return 0;
}
}
$_count = 0;
$_time = time();
if (file_exists($_dir)) {
$_cacheDirs = new RecursiveDirectoryIterator($_dir);
$_cache = new RecursiveIteratorIterator($_cacheDirs, RecursiveIteratorIterator::CHILD_FIRST);
foreach ($_cache as $_file) {
if (substr(basename($_file->getPathname()),0,1) == '.' || strpos($_file, '.svn') !== false) continue;
// directory ?
if ($_file->isDir()) {
if (!$_cache->isDot()) {
// delete folder if empty
@rmdir($_file->getPathname());
}
} else {
$_parts = explode($_dir_sep, str_replace('\\', '/', substr((string) $_file, $_dir_length)));
$_parts_count = count($_parts);
// check name
if (isset($resource_name)) {
if ($_parts[$_parts_count-1] != $_resourcename_parts) {
continue;
}
}
// check compile id
if (isset($_compile_id) && (!isset($_parts[$_parts_count-2 - $_compile_id_offset]) || $_parts[$_parts_count-2 - $_compile_id_offset] != $_compile_id)) {
continue;
}
// check cache id
if (isset($_cache_id)) {
// count of cache id parts
$_parts_count = (isset($_compile_id)) ? $_parts_count - 2 - $_compile_id_offset : $_parts_count - 1 - $_compile_id_offset;
if ($_parts_count < $_cache_id_parts_count) {
continue;
}
for ($i = 0; $i < $_cache_id_parts_count; $i++) {
if ($_parts[$i] != $_cache_id_parts[$i]) continue 2;
}
}
// expired ?
if (isset($exp_time)) {
if ($exp_time < 0) {
preg_match('#\'cache_lifetime\' =>\s*(\d*)#', file_get_contents($_file), $match);
if ($_time < (@filemtime($_file) + $match[1])) {
continue;
}
} else {
if ($_time - @filemtime($_file) < $exp_time) {
continue;
}
}
}
$_count += @unlink((string) $_file) ? 1 : 0;
}
}
}
return $_count;
}
/**
* Check is cache is locked for this template
*
* @param Smarty $smarty Smarty object
* @param Smarty_Template_Cached $cached cached object
* @return booelan true or false if cache is locked
*/
public function hasLock(Smarty $smarty, Smarty_Template_Cached $cached)
{
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
clearstatcache(true, $cached->lock_id);
} else {
clearstatcache();
}
$t = @filemtime($cached->lock_id);
return $t && (time() - $t < $smarty->locking_timeout);
}
/**
* Lock cache for this template
*
* @param Smarty $smarty Smarty object
* @param Smarty_Template_Cached $cached cached object
*/
public function acquireLock(Smarty $smarty, Smarty_Template_Cached $cached)
{
$cached->is_locked = true;
touch($cached->lock_id);
}
/**
* Unlock cache for this template
*
* @param Smarty $smarty Smarty object
* @param Smarty_Template_Cached $cached cached object
*/
public function releaseLock(Smarty $smarty, Smarty_Template_Cached $cached)
{
$cached->is_locked = false;
@unlink($cached->lock_id);
}
}

View File

@@ -1,80 +0,0 @@
<?php
/**
* Smarty Internal Plugin Resource Stream
*
* Implements the streams as resource for Smarty template
*
* @package Smarty
* @subpackage TemplateResources
* @author Uwe Tews
* @author Rodney Rehm
*/
/**
* Smarty Internal Plugin Resource Stream
*
* Implements the streams as resource for Smarty template
*
* @link http://php.net/streams
* @package Smarty
* @subpackage TemplateResources
*/
class Smarty_Internal_Resource_Stream extends Smarty_Resource_Recompiled
{
/**
* populate Source Object with meta data from Resource
*
* @param Smarty_Template_Source $source source object
* @param Smarty_Internal_Template $_template template object
* @return void
*/
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null)
{
if (strpos($source->resource, '://') !== false) {
$source->filepath = $source->resource;
} else {
$source->filepath = str_replace(':', '://', $source->resource);
}
$source->uid = false;
$source->content = $this->getContent($source);
$source->timestamp = false;
$source->exists = !!$source->content;
}
/**
* Load template's source from stream into current template object
*
* @param Smarty_Template_Source $source source object
* @return string template source
* @throws SmartyException if source cannot be loaded
*/
public function getContent(Smarty_Template_Source $source)
{
$t = '';
// the availability of the stream has already been checked in Smarty_Resource::fetch()
$fp = fopen($source->filepath, 'r+');
if ($fp) {
while (!feof($fp) && ($current_line = fgets($fp)) !== false) {
$t .= $current_line;
}
fclose($fp);
return $t;
} else {
return false;
}
}
/**
* modify resource_name according to resource handlers specifications
*
* @param Smarty $smarty Smarty instance
* @param string $resource_name resource_name to make unique
* @param boolean $is_config flag for config resource
* @return string unique resource name
*/
protected function buildUniqueResourceName(Smarty $smarty, $resource_name, $is_config = false)
{
return get_class($this) . '#' . $resource_name;
}
}

View File

@@ -1,4 +1,4 @@
Smarty 3.1.15 Smarty 3.1.21
Author: Monte Ohrt <monte at ohrt dot com > Author: Monte Ohrt <monte at ohrt dot com >
Author: Uwe Tews Author: Uwe Tews

View File

@@ -1,5 +1,169 @@
===== trunk ===== ===== 3.1.22-dev ===== (xx.xx.2014)
===== Smarty-3.1.15 ===== ===== 3.1.21 ===== (18.10.2014)
18.10.2014
- composer moved to github
- add COMPOSER_RELEASE_NOTES
17.10.2014
- bugfix on $php_handling security and optimization of smarty_internal_parsetree (Thue Kristensen)
16.10.2014
- bugfix composer.json update
15.10.2014
- bugfix calling a new created cache file with fetch() and Smarty::CACHING_LIFETIME_SAVED multiple times did fail (forum 22350)
14.10.2014
- bugfix any tag placed within "<script language=php>" will throw a security exception to close all thinkable holes
- bugfix classmap in root composer.json should start at "libs/..."
- improvement cache is_file(file_exists) results of loadPlugin() to avoid unnecessary calls during compilation (Issue 201}
12.10.2014
- bugfix a comment like "<script{*foo*} language=php>" bypassed $php_handling checking (Thue Kristensen)
- bugfix change of 08.10.2014 could create E_NOTICE meassage when using "<?php" tags
- bugfix "<script language=php>" with $php_handling PHP_PASSTHRU was executed in {nocache} sections
===== 3.1.20 ===== (09.10.2014)
08.10.2014
- bugfix security mode of "<script language=php>" must be controlled by $php_handling property (Thue Kristensen)
01.10.2014
- bugfix template resource of inheritance blocks could get invalid if the default resource type is not 'file'(Issue 202)
- bugfix existing child {block} tag must override parent {block} tag append / prepend setting (topic 25259)
02.08.2014
- bugfix modifier wordwrap did output break string wrong if first word was exceeding length with cut = true (topic 25193)
24.07.2014
- bugfix cache clear when cache folder does not exist
16.07.2014
- enhancement remove BOM automatically from template source (topic 25161)
04.07.2014
- bugfix the bufix of 02.06.2014 broke correct handling of child templates with same name but different template folders in extends resource (issue 194 and topic 25099)
===== 3.1.19 ===== (06.30.2014)
20.06.2014
- bugfix template variables could not be passed as parameter in {include} when the include was in a {nocache} section (topic 25131)
17.06.2014
- bugfix large template text of some charsets could cause parsing errors (topic 24630)
08.06.2014
- bugfix registered objects did not work after spelling fixes of 06.06.2014
- bugfix {block} tags within {literal} .. {/literal} got not displayed correctly (topic 25024)
- bugfix UNC WINDOWS PATH like "\\psf\path\to\dir" did not work as template directory (Issue 192)
- bugfix {html_image} security check did fail on files relative to basedir (Issue 191)
06.06.2014
- fixed PHPUnit outputFilterTrimWhitespaceTests.php assertion of test result
- fixed spelling, PHPDoc , minor errors, code cleanup
02.06.2014
- using multiple cwd with relative template dirs could result in identical compiled file names. (issue 194 and topic 25099)
19.04.2014
- bugfix calling createTemplate(template, data) with empty data array caused notice of array to string conversion (Issue 189)
- bugfix clearCompiledTemplate() did not delete files on WINDOWS when a compile_id was specified
18.04.2014
- revert bugfix of 5.4.2014 because %-e date format is not supported on all operating systems
===== 3.1.18 ===== (07.04.2014)
06.04.2014
- bugfix template inheritance fail when using custom resource after patch of 8.3.2014 (Issue 187)
- bugfix update of composer file (Issue 168 and 184)
05.04.2014
- bugfix default date format leads to extra spaces when displaying dates with single digit days (Issue 165)
26.03.2014
- bugfix Smart_Resource_Custom should not lowercase the resource name (Issue 183)
24.03.2014
- bugfix using a {foreach} property like @iteration could fail when used in inheritance parent templates (Issue 182)
20.03.2014
- bugfix $smarty->auto_literal and mbsting.func_overload 2, 6 or 7 did fail (forum topic 24899)
18.03.2014
- revert change of 17.03.2014
17.03.2014
- bugfix $smarty->auto_literal and mbsting.func_overload 2, 6 or 7 did fail (forum topic 24899)
15.03.2014
- bugfix Smarty_CacheResource_Keyvaluestore did use different keys on read/writes and clearCache() calls (Issue 169)
13.03.2014
- bugfix clearXxx() change of 27.1.2014 did not work when specifing cache_id or compile_id (forum topic 24868 and 24867)
===== 3.1.17 =====
08.03.2014
- bugfix relative file path {include} within {block} of child templates did throw exception on first call (Issue 177)
17.02.2014
- bugfix Smarty failed when executing PHP on HHVM (Hip Hop 2.4) because uniqid('',true) does return string with ',' (forum topic 20343)
16.02.2014
- bugfix a '//' or '\\' in template_dir path could produce wrong path on relative filepath in {include} (Issue 175)
05.02.2014
- bugfix shared.literal_compiler_param.php did throw an exception when literal did contain a '-' (smarty-developers group)
27.01.2014
- bugfix $smarty->debugging = true; did show the variable of the $smarty object not the variables used in display() call (forum topic 24764)
- bugfix clearCompiledTemplate(), clearAll() and clear() should use realpath to avoid possible exception from RecursiveDirectoryIterator (Issue 171)
26.01.2014
- bugfix undo block nesting checks for {nocache} for reasons like forum topic 23280 (forum topic 24762)
18.01.2014
- bugfix the compiler did fail when using template inheritance and recursive {include} (smarty-developers group)
11.01.2014
- bugfix "* }" (spaces before right delimiter) was interpreted by mistake as comment end tag (Issue 170)
- internals content cache should be clear when updating cache file
08.01.2014
- bugfix Smarty_CacheResource_Custom did not handle template resource type specifications on clearCache() calls (Issue 169)
- bugfix SmartyBC.class.php should use require_once to load Smarty.class.php (forum topic 24683)
===== 3.1.16 =====
15.12.2013
- bugfix {include} with {block} tag handling (forum topic 24599, 24594, 24682) (Issue 161)
Read 3.1.16_RELEASE_NOTES for more details
- enhancement additional debug output at $smarty->_parserdebug = true;
07.11.2013
- bugfix too restrictive handling of {include} within {block} tags. 3.1.15 did throw errors where 3.1.14 did not (forum topic 24599)
- bugfix compiler could fail if PHP mbstring.func_overload is enabled (Issue 164)
28.10.2013
- bugfix variable resource name at custom resource plugin did not work within {block} tags (Issue 163)
- bugfix notice "Trying to get property of non-object" removed (Issue 163)
- bugfix correction of modifier capitalize fix from 3.10.2013 (issue 159)
- bugfix multiple {block}s with same name in parent did not work (forum topic 24631)
20.10.2013
- bugfix a variable file name at {extends} tag did fail (forum topic 24618)
14.10.2013
- bugfix yesterdays fix could result in an undefined variable
13.10.2013
- bugfix variable names on {include} in template inheritance did unextepted error message (forum topic 24594) (Issue 161)
.- bugfix relative includes with same name like {include './foo.tpl'} from different folder failed (forum topic 24590)(Issue 161)
04.10.2013
- bugfix variable file names at {extends} had been disbabled by mistake with the rewrite of
template inheritance of 24.08.2013 (forum topic 24585)
03.10.2013
- bugfix loops using modifier capitalize did eat up memory (issue 159)
===== Smarty 3.1.15 =====
01.10.2013 01.10.2013
- use current delimiters in compiler error messages (issue 157) - use current delimiters in compiler error messages (issue 157)
- improvement on performance when using error handler and multiple template folders (issue 152) - improvement on performance when using error handler and multiple template folders (issue 152)

View File

@@ -0,0 +1,30 @@
<?php
/**
* Example Application
*
* @package Example-application
*/
require '../libs/Smarty.class.php';
$smarty = new Smarty;
//$smarty->force_compile = true;
$smarty->debugging = true;
$smarty->caching = true;
$smarty->cache_lifetime = 120;
$smarty->assign("Name", "Fred Irving Johnathan Bradley Peppergill", true);
$smarty->assign("FirstName", array("John", "Mary", "James", "Henry"));
$smarty->assign("LastName", array("Doe", "Smith", "Johnson", "Case"));
$smarty->assign("Class", array(array("A", "B", "C", "D"), array("E", "F", "G", "H"),
array("I", "J", "K", "L"), array("M", "N", "O", "P")));
$smarty->assign("contacts", array(array("phone" => "1", "fax" => "2", "cell" => "3"),
array("phone" => "555-4444", "fax" => "555-3333", "cell" => "760-1234")));
$smarty->assign("option_values", array("NY", "NE", "KS", "IA", "OK", "TX"));
$smarty->assign("option_output", array("New York", "Nebraska", "Kansas", "Iowa", "Oklahoma", "Texas"));
$smarty->assign("option_selected", "NE");
$smarty->display('index.tpl');

View File

@@ -2,12 +2,12 @@
/** /**
* APC CacheResource * APC CacheResource
*
* CacheResource Implementation based on the KeyValueStore API to use * CacheResource Implementation based on the KeyValueStore API to use
* memcache as the storage resource for Smarty's output caching. * memcache as the storage resource for Smarty's output caching.
* * * *
*
* @package CacheResource-examples * @package CacheResource-examples
* @author Uwe Tews * @author Uwe Tews
*/ */
class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
{ {
@@ -22,7 +22,8 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
/** /**
* Read values for a set of keys from cache * Read values for a set of keys from cache
* *
* @param array $keys list of keys to fetch * @param array $keys list of keys to fetch
*
* @return array list of values with the given keys used as indexes * @return array list of values with the given keys used as indexes
* @return boolean true on success, false on failure * @return boolean true on success, false on failure
*/ */
@@ -40,11 +41,12 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
/** /**
* Save values for a set of keys to cache * Save values for a set of keys to cache
* *
* @param array $keys list of values to save * @param array $keys list of values to save
* @param int $expire expiration time * @param int $expire expiration time
*
* @return boolean true on success, false on failure * @return boolean true on success, false on failure
*/ */
protected function write(array $keys, $expire=null) protected function write(array $keys, $expire = null)
{ {
foreach ($keys as $k => $v) { foreach ($keys as $k => $v) {
apc_store($k, $v, $expire); apc_store($k, $v, $expire);
@@ -56,7 +58,8 @@ class Smarty_CacheResource_Apc extends Smarty_CacheResource_KeyValueStore
/** /**
* Remove values from cache * Remove values from cache
* *
* @param array $keys list of keys to delete * @param array $keys list of keys to delete
*
* @return boolean true on success, false on failure * @return boolean true on success, false on failure
*/ */
protected function delete(array $keys) protected function delete(array $keys)

View File

@@ -2,20 +2,19 @@
/** /**
* Memcache CacheResource * Memcache CacheResource
*
* CacheResource Implementation based on the KeyValueStore API to use * CacheResource Implementation based on the KeyValueStore API to use
* memcache as the storage resource for Smarty's output caching. * memcache as the storage resource for Smarty's output caching.
*
* Note that memcache has a limitation of 256 characters per cache-key. * Note that memcache has a limitation of 256 characters per cache-key.
* To avoid complications all cache-keys are translated to a sha1 hash. * To avoid complications all cache-keys are translated to a sha1 hash.
* *
* @package CacheResource-examples * @package CacheResource-examples
* @author Rodney Rehm * @author Rodney Rehm
*/ */
class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
{ {
/** /**
* memcache instance * memcache instance
*
* @var Memcache * @var Memcache
*/ */
protected $memcache = null; protected $memcache = null;
@@ -23,13 +22,14 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
public function __construct() public function __construct()
{ {
$this->memcache = new Memcache(); $this->memcache = new Memcache();
$this->memcache->addServer( '127.0.0.1', 11211 ); $this->memcache->addServer('127.0.0.1', 11211);
} }
/** /**
* Read values for a set of keys from cache * Read values for a set of keys from cache
* *
* @param array $keys list of keys to fetch * @param array $keys list of keys to fetch
*
* @return array list of values with the given keys used as indexes * @return array list of values with the given keys used as indexes
* @return boolean true on success, false on failure * @return boolean true on success, false on failure
*/ */
@@ -53,11 +53,12 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
/** /**
* Save values for a set of keys to cache * Save values for a set of keys to cache
* *
* @param array $keys list of values to save * @param array $keys list of values to save
* @param int $expire expiration time * @param int $expire expiration time
*
* @return boolean true on success, false on failure * @return boolean true on success, false on failure
*/ */
protected function write(array $keys, $expire=null) protected function write(array $keys, $expire = null)
{ {
foreach ($keys as $k => $v) { foreach ($keys as $k => $v) {
$k = sha1($k); $k = sha1($k);
@@ -70,7 +71,8 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
/** /**
* Remove values from cache * Remove values from cache
* *
* @param array $keys list of keys to delete * @param array $keys list of keys to delete
*
* @return boolean true on success, false on failure * @return boolean true on success, false on failure
*/ */
protected function delete(array $keys) protected function delete(array $keys)
@@ -90,6 +92,6 @@ class Smarty_CacheResource_Memcache extends Smarty_CacheResource_KeyValueStore
*/ */
protected function purge() protected function purge()
{ {
return $this->memcache->flush(); $this->memcache->flush();
} }
} }

View File

@@ -2,10 +2,8 @@
/** /**
* MySQL CacheResource * MySQL CacheResource
*
* CacheResource Implementation based on the Custom API to use * CacheResource Implementation based on the Custom API to use
* MySQL as the storage resource for Smarty's output caching. * MySQL as the storage resource for Smarty's output caching.
*
* Table definition: * Table definition:
* <pre>CREATE TABLE IF NOT EXISTS `output_cache` ( * <pre>CREATE TABLE IF NOT EXISTS `output_cache` (
* `id` CHAR(40) NOT NULL COMMENT 'sha1 hash', * `id` CHAR(40) NOT NULL COMMENT 'sha1 hash',
@@ -22,7 +20,7 @@
* ) ENGINE = InnoDB;</pre> * ) ENGINE = InnoDB;</pre>
* *
* @package CacheResource-examples * @package CacheResource-examples
* @author Rodney Rehm * @author Rodney Rehm
*/ */
class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
{ {
@@ -36,7 +34,8 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
{ {
try { try {
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
} catch (PDOException $e) { }
catch (PDOException $e) {
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
} }
$this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id'); $this->fetch = $this->db->prepare('SELECT modified, content FROM output_cache WHERE id = :id');
@@ -54,6 +53,7 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
* @param string $compile_id compile id * @param string $compile_id compile id
* @param string $content cached content * @param string $content cached content
* @param integer $mtime cache modification timestamp (epoch) * @param integer $mtime cache modification timestamp (epoch)
*
* @return void * @return void
*/ */
protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime) protected function fetch($id, $name, $cache_id, $compile_id, &$content, &$mtime)
@@ -74,10 +74,12 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
* Fetch cached content's modification timestamp from data source * Fetch cached content's modification timestamp from data source
* *
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the complete cached content. * @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the complete cached content.
* @param string $id unique cache content identifier *
* @param string $name template name * @param string $id unique cache content identifier
* @param string $cache_id cache id * @param string $name template name
* @param string $compile_id compile id * @param string $cache_id cache id
* @param string $compile_id compile id
*
* @return integer|boolean timestamp (epoch) the template was modified, or false if not found * @return integer|boolean timestamp (epoch) the template was modified, or false if not found
*/ */
protected function fetchTimestamp($id, $name, $cache_id, $compile_id) protected function fetchTimestamp($id, $name, $cache_id, $compile_id)
@@ -98,17 +100,18 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
* @param string $compile_id compile id * @param string $compile_id compile id
* @param integer|null $exp_time seconds till expiration time in seconds or null * @param integer|null $exp_time seconds till expiration time in seconds or null
* @param string $content content to cache * @param string $content content to cache
*
* @return boolean success * @return boolean success
*/ */
protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content) protected function save($id, $name, $cache_id, $compile_id, $exp_time, $content)
{ {
$this->save->execute(array( $this->save->execute(array(
'id' => $id, 'id' => $id,
'name' => $name, 'name' => $name,
'cache_id' => $cache_id, 'cache_id' => $cache_id,
'compile_id' => $compile_id, 'compile_id' => $compile_id,
'content' => $content, 'content' => $content,
)); ));
return !!$this->save->rowCount(); return !!$this->save->rowCount();
} }
@@ -120,6 +123,7 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
* @param string $cache_id cache id * @param string $cache_id cache id
* @param string $compile_id compile id * @param string $compile_id compile id
* @param integer|null $exp_time seconds till expiration or null * @param integer|null $exp_time seconds till expiration or null
*
* @return integer number of deleted caches * @return integer number of deleted caches
*/ */
protected function delete($name, $cache_id, $compile_id, $exp_time) protected function delete($name, $cache_id, $compile_id, $exp_time)
@@ -129,7 +133,7 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
// returning the number of deleted caches would require a second query to count them // returning the number of deleted caches would require a second query to count them
$query = $this->db->query('TRUNCATE TABLE output_cache'); $query = $this->db->query('TRUNCATE TABLE output_cache');
return -1; return - 1;
} }
// build the filter // build the filter
$where = array(); $where = array();
@@ -147,8 +151,8 @@ class Smarty_CacheResource_Mysql extends Smarty_CacheResource_Custom
} }
// equal test cache_id and match sub-groups // equal test cache_id and match sub-groups
if ($cache_id !== null) { if ($cache_id !== null) {
$where[] = '(cache_id = '. $this->db->quote($cache_id) $where[] = '(cache_id = ' . $this->db->quote($cache_id)
. ' OR cache_id LIKE '. $this->db->quote($cache_id .'|%') .')'; . ' OR cache_id LIKE ' . $this->db->quote($cache_id . '|%') . ')';
} }
// run delete query // run delete query
$query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where)); $query = $this->db->query('DELETE FROM output_cache WHERE ' . join(' AND ', $where));

View File

@@ -2,12 +2,11 @@
/** /**
* Extends All Resource * Extends All Resource
*
* Resource Implementation modifying the extends-Resource to walk * Resource Implementation modifying the extends-Resource to walk
* through the template_dirs and inherit all templates of the same name * through the template_dirs and inherit all templates of the same name
* *
* @package Resource-examples * @package Resource-examples
* @author Rodney Rehm * @author Rodney Rehm
*/ */
class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends
{ {
@@ -16,22 +15,25 @@ class Smarty_Resource_Extendsall extends Smarty_Internal_Resource_Extends
* *
* @param Smarty_Template_Source $source source object * @param Smarty_Template_Source $source source object
* @param Smarty_Internal_Template $_template template object * @param Smarty_Internal_Template $_template template object
*
* @return void * @return void
*/ */
public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template=null) public function populate(Smarty_Template_Source $source, Smarty_Internal_Template $_template = null)
{ {
$uid = ''; $uid = '';
$sources = array(); $sources = array();
$exists = true; $exists = true;
foreach ($_template->smarty->getTemplateDir() as $key => $directory) { foreach ($_template->smarty->getTemplateDir() as $key => $directory) {
try { try {
$s = Smarty_Resource::source(null, $source->smarty, '[' . $key . ']' . $source->name ); $s = Smarty_Resource::source(null, $source->smarty, '[' . $key . ']' . $source->name);
if (!$s->exists) { if (!$s->exists) {
continue; continue;
} }
$sources[$s->uid] = $s; $sources[$s->uid] = $s;
$uid .= $s->filepath; $uid .= $s->filepath;
} catch (SmartyException $e) {} }
catch (SmartyException $e) {
}
} }
if (!$sources) { if (!$sources) {

View File

@@ -2,10 +2,8 @@
/** /**
* MySQL Resource * MySQL Resource
*
* Resource Implementation based on the Custom API to use * Resource Implementation based on the Custom API to use
* MySQL as the storage resource for Smarty's templates and configs. * MySQL as the storage resource for Smarty's templates and configs.
*
* Table definition: * Table definition:
* <pre>CREATE TABLE IF NOT EXISTS `templates` ( * <pre>CREATE TABLE IF NOT EXISTS `templates` (
* `name` varchar(100) NOT NULL, * `name` varchar(100) NOT NULL,
@@ -13,12 +11,11 @@
* `source` text, * `source` text,
* PRIMARY KEY (`name`) * PRIMARY KEY (`name`)
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre> * ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
*
* Demo data: * Demo data:
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre> * <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
* *
* @package Resource-examples * @package Resource-examples
* @author Rodney Rehm * @author Rodney Rehm
*/ */
class Smarty_Resource_Mysql extends Smarty_Resource_Custom class Smarty_Resource_Mysql extends Smarty_Resource_Custom
{ {
@@ -33,7 +30,8 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom
{ {
try { try {
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
} catch (PDOException $e) { }
catch (PDOException $e) {
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
} }
$this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name'); $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
@@ -46,6 +44,7 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom
* @param string $name template name * @param string $name template name
* @param string $source template source * @param string $source template source
* @param integer $mtime template modification timestamp (epoch) * @param integer $mtime template modification timestamp (epoch)
*
* @return void * @return void
*/ */
protected function fetch($name, &$source, &$mtime) protected function fetch($name, &$source, &$mtime)
@@ -66,7 +65,9 @@ class Smarty_Resource_Mysql extends Smarty_Resource_Custom
* Fetch a template's modification time from database * Fetch a template's modification time from database
* *
* @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source. * @note implementing this method is optional. Only implement it if modification times can be accessed faster than loading the comple template source.
* @param string $name template name *
* @param string $name template name
*
* @return integer timestamp (epoch) the template was modified * @return integer timestamp (epoch) the template was modified
*/ */
protected function fetchTimestamp($name) protected function fetchTimestamp($name)

View File

@@ -2,13 +2,10 @@
/** /**
* MySQL Resource * MySQL Resource
*
* Resource Implementation based on the Custom API to use * Resource Implementation based on the Custom API to use
* MySQL as the storage resource for Smarty's templates and configs. * MySQL as the storage resource for Smarty's templates and configs.
*
* Note that this MySQL implementation fetches the source and timestamps in * Note that this MySQL implementation fetches the source and timestamps in
* a single database query, instead of two separate like resource.mysql.php does. * a single database query, instead of two separate like resource.mysql.php does.
*
* Table definition: * Table definition:
* <pre>CREATE TABLE IF NOT EXISTS `templates` ( * <pre>CREATE TABLE IF NOT EXISTS `templates` (
* `name` varchar(100) NOT NULL, * `name` varchar(100) NOT NULL,
@@ -16,12 +13,11 @@
* `source` text, * `source` text,
* PRIMARY KEY (`name`) * PRIMARY KEY (`name`)
* ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre> * ) ENGINE=InnoDB DEFAULT CHARSET=utf8;</pre>
*
* Demo data: * Demo data:
* <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre> * <pre>INSERT INTO `templates` (`name`, `modified`, `source`) VALUES ('test.tpl', "2010-12-25 22:00:00", '{$x="hello world"}{$x}');</pre>
* *
* @package Resource-examples * @package Resource-examples
* @author Rodney Rehm * @author Rodney Rehm
*/ */
class Smarty_Resource_Mysqls extends Smarty_Resource_Custom class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
{ {
@@ -34,7 +30,8 @@ class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
{ {
try { try {
$this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty"); $this->db = new PDO("mysql:dbname=test;host=127.0.0.1", "smarty");
} catch (PDOException $e) { }
catch (PDOException $e) {
throw new SmartyException('Mysql Resource failed: ' . $e->getMessage()); throw new SmartyException('Mysql Resource failed: ' . $e->getMessage());
} }
$this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name'); $this->fetch = $this->db->prepare('SELECT modified, source FROM templates WHERE name = :name');
@@ -46,6 +43,7 @@ class Smarty_Resource_Mysqls extends Smarty_Resource_Custom
* @param string $name template name * @param string $name template name
* @param string $source template source * @param string $source template source
* @param integer $mtime template modification timestamp (epoch) * @param integer $mtime template modification timestamp (epoch)
*
* @return void * @return void
*/ */
protected function fetch($name, &$source, &$mtime) protected function fetch($name, &$source, &$mtime)

View File

@@ -1,5 +1,5 @@
<HTML> <HTML>
<HEAD> <HEAD>
<TITLE>{$title} - {$Name}</TITLE> <TITLE>{$title} - {$Name}</TITLE>
</HEAD> </HEAD>
<BODY bgcolor="#ffffff"> <BODY bgcolor="#ffffff">

View File

@@ -0,0 +1,87 @@
{config_load file="test.conf" section="setup"}
{include file="header.tpl" title=foo}
<PRE>
{* bold and title are read from the config file *}
{if #bold#}<b>{/if}
{* capitalize the first letters of each word of the title *}
Title: {#title#|capitalize}
{if #bold#}</b>{/if}
The current date and time is {$smarty.now|date_format:"%Y-%m-%d %H:%M:%S"}
The value of global assigned variable $SCRIPT_NAME is {$SCRIPT_NAME}
Example of accessing server environment variable SERVER_NAME: {$smarty.server.SERVER_NAME}
The value of {ldelim}$Name{rdelim} is <b>{$Name}</b>
variable modifier example of {ldelim}$Name|upper{rdelim}
<b>{$Name|upper}</b>
An example of a section loop:
{section name=outer
loop=$FirstName}
{if $smarty.section.outer.index is odd by 2}
{$smarty.section.outer.rownum} . {$FirstName[outer]} {$LastName[outer]}
{else}
{$smarty.section.outer.rownum} * {$FirstName[outer]} {$LastName[outer]}
{/if}
{sectionelse}
none
{/section}
An example of section looped key values:
{section name=sec1 loop=$contacts}
phone: {$contacts[sec1].phone}
<br>
fax: {$contacts[sec1].fax}
<br>
cell: {$contacts[sec1].cell}
<br>
{/section}
<p>
testing strip tags
{strip}
<table border=0>
<tr>
<td>
<A HREF="{$SCRIPT_NAME}">
<font color="red">This is a test </font>
</A>
</td>
</tr>
</table>
{/strip}
</PRE>
This is an example of the html_select_date function:
<form>
{html_select_date start_year=1998 end_year=2010}
</form>
This is an example of the html_select_time function:
<form>
{html_select_time use_24_hours=false}
</form>
This is an example of the html_options function:
<form>
<select name=states>
{html_options values=$option_values selected=$option_selected output=$option_output}
</select>
</form>
{include file="footer.tpl"}

View File

@@ -3,36 +3,32 @@
* Project: Smarty: the PHP compiling template engine * Project: Smarty: the PHP compiling template engine
* File: SmartyBC.class.php * File: SmartyBC.class.php
* SVN: $Id: $ * SVN: $Id: $
*
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either * License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version. * version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful, * This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details. * Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public * You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software * License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* For questions, help, comments, discussion, etc., please join the * For questions, help, comments, discussion, etc., please join the
* Smarty mailing list. Send a blank e-mail to * Smarty mailing list. Send a blank e-mail to
* smarty-discussion-subscribe@googlegroups.com * smarty-discussion-subscribe@googlegroups.com
* *
* @link http://www.smarty.net/ * @link http://www.smarty.net/
* @copyright 2008 New Digital Group, Inc. * @copyright 2008 New Digital Group, Inc.
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @author Uwe Tews * @author Uwe Tews
* @author Rodney Rehm * @author Rodney Rehm
* @package Smarty * @package Smarty
*/ */
/** /**
* @ignore * @ignore
*/ */
require(dirname(__FILE__) . '/Smarty.class.php'); require_once(dirname(__FILE__) . '/Smarty.class.php');
/** /**
* Smarty Backward Compatability Wrapper Class * Smarty Backward Compatability Wrapper Class
@@ -43,6 +39,7 @@ class SmartyBC extends Smarty
{ {
/** /**
* Smarty 2 BC * Smarty 2 BC
*
* @var string * @var string
*/ */
public $_version = self::SMARTY_VERSION; public $_version = self::SMARTY_VERSION;
@@ -52,7 +49,7 @@ class SmartyBC extends Smarty
* *
* @param array $options options to set during initialization, e.g. array( 'forceCompile' => false ) * @param array $options options to set during initialization, e.g. array( 'forceCompile' => false )
*/ */
public function __construct(array $options=array()) public function __construct(array $options = array())
{ {
parent::__construct($options); parent::__construct($options);
// register {php} tag // register {php} tag
@@ -100,7 +97,7 @@ class SmartyBC extends Smarty
* @param bool $cacheable * @param bool $cacheable
* @param mixed $cache_attrs * @param mixed $cache_attrs
*/ */
public function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null) public function register_function($function, $function_impl, $cacheable = true, $cache_attrs = null)
{ {
$this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs); $this->registerPlugin('function', $function, $function_impl, $cacheable, $cache_attrs);
} }
@@ -118,11 +115,14 @@ class SmartyBC extends Smarty
/** /**
* Registers object to be used in templates * Registers object to be used in templates
* *
* @param string $object name of template object * @param string $object name of template object
* @param object $object_impl the referenced PHP object to register * @param object $object_impl the referenced PHP object to register
* @param array $allowed list of allowed methods (empty = all) * @param array $allowed list of allowed methods (empty = all)
* @param boolean $smarty_args smarty argument format, else traditional * @param boolean $smarty_args smarty argument format, else traditional
* @param array $block_functs list of methods that are block format * @param array $block_methods list of methods that are block format
*
* @throws SmartyException
* @internal param array $block_functs list of methods that are block format
*/ */
public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array()) public function register_object($object, $object_impl, $allowed = array(), $smarty_args = true, $block_methods = array())
{ {
@@ -144,12 +144,12 @@ class SmartyBC extends Smarty
/** /**
* Registers block function to be used in templates * Registers block function to be used in templates
* *
* @param string $block name of template block * @param string $block name of template block
* @param string $block_impl PHP function to register * @param string $block_impl PHP function to register
* @param bool $cacheable * @param bool $cacheable
* @param mixed $cache_attrs * @param mixed $cache_attrs
*/ */
public function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null) public function register_block($block, $block_impl, $cacheable = true, $cache_attrs = null)
{ {
$this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs); $this->registerPlugin('block', $block, $block_impl, $cacheable, $cache_attrs);
} }
@@ -171,7 +171,7 @@ class SmartyBC extends Smarty
* @param string $function_impl name of PHP function to register * @param string $function_impl name of PHP function to register
* @param bool $cacheable * @param bool $cacheable
*/ */
public function register_compiler_function($function, $function_impl, $cacheable=true) public function register_compiler_function($function, $function_impl, $cacheable = true)
{ {
$this->registerPlugin('compiler', $function, $function_impl, $cacheable); $this->registerPlugin('compiler', $function, $function_impl, $cacheable);
} }
@@ -305,10 +305,11 @@ class SmartyBC extends Smarty
/** /**
* clear cached content for the given template and cache id * clear cached content for the given template and cache id
* *
* @param string $tpl_file name of template file * @param string $tpl_file name of template file
* @param string $cache_id name of cache_id * @param string $cache_id name of cache_id
* @param string $compile_id name of compile_id * @param string $compile_id name of compile_id
* @param string $exp_time expiration time * @param string $exp_time expiration time
*
* @return boolean * @return boolean
*/ */
public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null) public function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null)
@@ -319,7 +320,8 @@ class SmartyBC extends Smarty
/** /**
* clear the entire contents of cache (all templates) * clear the entire contents of cache (all templates)
* *
* @param string $exp_time expire time * @param string $exp_time expire time
*
* @return boolean * @return boolean
*/ */
public function clear_all_cache($exp_time = null) public function clear_all_cache($exp_time = null)
@@ -330,9 +332,10 @@ class SmartyBC extends Smarty
/** /**
* test to see if valid cache exists for this template * test to see if valid cache exists for this template
* *
* @param string $tpl_file name of template file * @param string $tpl_file name of template file
* @param string $cache_id * @param string $cache_id
* @param string $compile_id * @param string $compile_id
*
* @return boolean * @return boolean
*/ */
public function is_cached($tpl_file, $cache_id = null, $compile_id = null) public function is_cached($tpl_file, $cache_id = null, $compile_id = null)
@@ -353,9 +356,10 @@ class SmartyBC extends Smarty
* or all compiled template files if one is not specified. * or all compiled template files if one is not specified.
* This function is for advanced use only, not normally needed. * This function is for advanced use only, not normally needed.
* *
* @param string $tpl_file * @param string $tpl_file
* @param string $compile_id * @param string $compile_id
* @param string $exp_time * @param string $exp_time
*
* @return boolean results of {@link smarty_core_rm_auto()} * @return boolean results of {@link smarty_core_rm_auto()}
*/ */
public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null) public function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null)
@@ -366,7 +370,8 @@ class SmartyBC extends Smarty
/** /**
* Checks whether requested template exists. * Checks whether requested template exists.
* *
* @param string $tpl_file * @param string $tpl_file
*
* @return boolean * @return boolean
*/ */
public function template_exists($tpl_file) public function template_exists($tpl_file)
@@ -378,9 +383,10 @@ class SmartyBC extends Smarty
* Returns an array containing template variables * Returns an array containing template variables
* *
* @param string $name * @param string $name
*
* @return array * @return array
*/ */
public function get_template_vars($name=null) public function get_template_vars($name = null)
{ {
return $this->getTemplateVars($name); return $this->getTemplateVars($name);
} }
@@ -389,9 +395,10 @@ class SmartyBC extends Smarty
* Returns an array containing config variables * Returns an array containing config variables
* *
* @param string $name * @param string $name
*
* @return array * @return array
*/ */
public function get_config_vars($name=null) public function get_config_vars($name = null)
{ {
return $this->getConfigVars($name); return $this->getConfigVars($name);
} }
@@ -412,6 +419,7 @@ class SmartyBC extends Smarty
* return a reference to a registered object * return a reference to a registered object
* *
* @param string $name * @param string $name
*
* @return object * @return object
*/ */
public function get_registered_object($name) public function get_registered_object($name)
@@ -439,7 +447,6 @@ class SmartyBC extends Smarty
{ {
trigger_error("Smarty error: $error_msg", $error_type); trigger_error("Smarty error: $error_msg", $error_type);
} }
} }
/** /**
@@ -449,6 +456,7 @@ class SmartyBC extends Smarty
* @param string $content contents of the block * @param string $content contents of the block
* @param object $template template object * @param object $template template object
* @param boolean &$repeat repeat flag * @param boolean &$repeat repeat flag
*
* @return string content re-formatted * @return string content re-formatted
*/ */
function smarty_php_tag($params, $content, $template, &$repeat) function smarty_php_tag($params, $content, $template, &$repeat)

View File

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

View File

@@ -2,13 +2,12 @@
/** /**
* Smarty plugin to format text blocks * Smarty plugin to format text blocks
* *
* @package Smarty * @package Smarty
* @subpackage PluginsBlock * @subpackage PluginsBlock
*/ */
/** /**
* Smarty {textformat}{/textformat} block plugin * Smarty {textformat}{/textformat} block plugin
*
* Type: block function<br> * Type: block function<br>
* Name: textformat<br> * Name: textformat<br>
* Purpose: format text a certain way with preset styles * Purpose: format text a certain way with preset styles
@@ -23,12 +22,14 @@
* - wrap_boundary - boolean (true) * - wrap_boundary - boolean (true)
* </pre> * </pre>
* *
* @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat} * @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
* (Smarty online manual) * (Smarty online manual)
*
* @param array $params parameters * @param array $params parameters
* @param string $content contents of the block * @param string $content contents of the block
* @param Smarty_Internal_Template $template template object * @param Smarty_Internal_Template $template template object
* @param boolean &$repeat repeat flag * @param boolean &$repeat repeat flag
*
* @return string content re-formatted * @return string content re-formatted
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
*/ */
@@ -76,7 +77,6 @@ function smarty_block_textformat($params, $content, $template, &$repeat)
} }
// split into paragraphs // split into paragraphs
$_paragraphs = preg_split('![\r\n]{2}!', $content); $_paragraphs = preg_split('![\r\n]{2}!', $content);
$_output = '';
foreach ($_paragraphs as &$_paragraph) { foreach ($_paragraphs as &$_paragraph) {
if (!$_paragraph) { if (!$_paragraph) {

View File

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

View File

@@ -2,13 +2,12 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsFunction * @subpackage PluginsFunction
*/ */
/** /**
* Smarty {cycle} function plugin * Smarty {cycle} function plugin
*
* Type: function<br> * Type: function<br>
* Name: cycle<br> * Name: cycle<br>
* Date: May 3, 2002<br> * Date: May 3, 2002<br>
@@ -31,15 +30,17 @@
* {cycle name=row} * {cycle name=row}
* </pre> * </pre>
* *
* @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle} * @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
* (Smarty online manual) * (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @author credit to Mark Priatel <mpriatel@rogers.com> * @author credit to Mark Priatel <mpriatel@rogers.com>
* @author credit to Gerard <gerard@interfold.com> * @author credit to Gerard <gerard@interfold.com>
* @author credit to Jason Sweat <jsweat_php@yahoo.com> * @author credit to Jason Sweat <jsweat_php@yahoo.com>
* @version 1.3 * @version 1.3
*
* @param array $params parameters * @param array $params parameters
* @param Smarty_Internal_Template $template template object * @param Smarty_Internal_Template $template template object
*
* @return string|null * @return string|null
*/ */
@@ -59,8 +60,9 @@ function smarty_function_cycle($params, $template)
return; return;
} }
} else { } else {
if(isset($cycle_vars[$name]['values']) if (isset($cycle_vars[$name]['values'])
&& $cycle_vars[$name]['values'] != $params['values'] ) { && $cycle_vars[$name]['values'] != $params['values']
) {
$cycle_vars[$name]['index'] = 0; $cycle_vars[$name]['index'] = 0;
} }
$cycle_vars[$name]['values'] = $params['values']; $cycle_vars[$name]['values'] = $params['values'];
@@ -75,10 +77,10 @@ function smarty_function_cycle($params, $template)
if (is_array($cycle_vars[$name]['values'])) { if (is_array($cycle_vars[$name]['values'])) {
$cycle_array = $cycle_vars[$name]['values']; $cycle_array = $cycle_vars[$name]['values'];
} else { } 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; $cycle_vars[$name]['index'] = 0;
} }
@@ -94,10 +96,10 @@ function smarty_function_cycle($params, $template)
} }
if ($advance) { if ($advance) {
if ( $cycle_vars[$name]['index'] >= count($cycle_array) -1 ) { if ($cycle_vars[$name]['index'] >= count($cycle_array) - 1) {
$cycle_vars[$name]['index'] = 0; $cycle_vars[$name]['index'] = 0;
} else { } else {
$cycle_vars[$name]['index']++; $cycle_vars[$name]['index'] ++;
} }
} }

View File

@@ -2,28 +2,30 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsFunction * @subpackage PluginsFunction
*/ */
/** /**
* Smarty {fetch} plugin * Smarty {fetch} plugin
*
* Type: function<br> * Type: function<br>
* Name: fetch<br> * Name: fetch<br>
* Purpose: fetch file, web or ftp data and display results * Purpose: fetch file, web or ftp data and display results
* *
* @link http://www.smarty.net/manual/en/language.function.fetch.php {fetch} * @link http://www.smarty.net/manual/en/language.function.fetch.php {fetch}
* (Smarty online manual) * (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
*
* @param array $params parameters * @param array $params parameters
* @param Smarty_Internal_Template $template template object * @param Smarty_Internal_Template $template template object
*
* @throws SmartyException
* @return string|null if the assign parameter is passed, Smarty assigns the result to a template variable * @return string|null if the assign parameter is passed, Smarty assigns the result to a template variable
*/ */
function smarty_function_fetch($params, $template) function smarty_function_fetch($params, $template)
{ {
if (empty($params['file'])) { if (empty($params['file'])) {
trigger_error("[plugin] fetch parameter 'file' cannot be empty",E_USER_NOTICE); trigger_error("[plugin] fetch parameter 'file' cannot be empty", E_USER_NOTICE);
return; return;
} }
@@ -60,7 +62,7 @@ function smarty_function_fetch($params, $template)
$host = $server_name = $uri_parts['host']; $host = $server_name = $uri_parts['host'];
$timeout = 30; $timeout = 30;
$accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*"; $accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, */*";
$agent = "Smarty Template Engine ". Smarty::SMARTY_VERSION; $agent = "Smarty Template Engine " . Smarty::SMARTY_VERSION;
$referer = ""; $referer = "";
$uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/'; $uri = !empty($uri_parts['path']) ? $uri_parts['path'] : '/';
$uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : ''; $uri .= !empty($uri_parts['query']) ? '?' . $uri_parts['query'] : '';
@@ -100,8 +102,8 @@ function smarty_function_fetch($params, $template)
break; break;
case "header": case "header":
if (!empty($param_value)) { if (!empty($param_value)) {
if (!preg_match('![\w\d-]+: .+!',$param_value)) { if (!preg_match('![\w\d-]+: .+!', $param_value)) {
trigger_error("[plugin] invalid header format '".$param_value."'",E_USER_NOTICE); trigger_error("[plugin] invalid header format '" . $param_value . "'", E_USER_NOTICE);
return; return;
} else { } else {
@@ -118,7 +120,7 @@ function smarty_function_fetch($params, $template)
if (!preg_match('!\D!', $param_value)) { if (!preg_match('!\D!', $param_value)) {
$proxy_port = (int) $param_value; $proxy_port = (int) $param_value;
} else { } else {
trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE); trigger_error("[plugin] invalid value for attribute '" . $param_key . "'", E_USER_NOTICE);
return; return;
} }
@@ -137,26 +139,26 @@ function smarty_function_fetch($params, $template)
if (!preg_match('!\D!', $param_value)) { if (!preg_match('!\D!', $param_value)) {
$timeout = (int) $param_value; $timeout = (int) $param_value;
} else { } else {
trigger_error("[plugin] invalid value for attribute '".$param_key."'",E_USER_NOTICE); trigger_error("[plugin] invalid value for attribute '" . $param_key . "'", E_USER_NOTICE);
return; return;
} }
break; break;
default: default:
trigger_error("[plugin] unrecognized attribute '".$param_key."'",E_USER_NOTICE); trigger_error("[plugin] unrecognized attribute '" . $param_key . "'", E_USER_NOTICE);
return; return;
} }
} }
if (!empty($proxy_host) && !empty($proxy_port)) { if (!empty($proxy_host) && !empty($proxy_port)) {
$_is_proxy = true; $_is_proxy = true;
$fp = fsockopen($proxy_host,$proxy_port,$errno,$errstr,$timeout); $fp = fsockopen($proxy_host, $proxy_port, $errno, $errstr, $timeout);
} else { } else {
$fp = fsockopen($server_name,$port,$errno,$errstr,$timeout); $fp = fsockopen($server_name, $port, $errno, $errstr, $timeout);
} }
if (!$fp) { if (!$fp) {
trigger_error("[plugin] unable to fetch: $errstr ($errno)",E_USER_NOTICE); trigger_error("[plugin] unable to fetch: $errstr ($errno)", E_USER_NOTICE);
return; return;
} else { } else {
@@ -179,35 +181,35 @@ function smarty_function_fetch($params, $template)
} }
if (isset($extra_headers) && is_array($extra_headers)) { if (isset($extra_headers) && is_array($extra_headers)) {
foreach ($extra_headers as $curr_header) { foreach ($extra_headers as $curr_header) {
fputs($fp, $curr_header."\r\n"); 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, "Authorization: BASIC " . base64_encode("$user:$pass") . "\r\n");
} }
fputs($fp, "\r\n"); fputs($fp, "\r\n");
while (!feof($fp)) { while (!feof($fp)) {
$content .= fgets($fp,4096); $content .= fgets($fp, 4096);
} }
fclose($fp); fclose($fp);
$csplit = preg_split("!\r\n\r\n!",$content,2); $csplit = preg_split("!\r\n\r\n!", $content, 2);
$content = $csplit[1]; $content = $csplit[1];
if (!empty($params['assign_headers'])) { if (!empty($params['assign_headers'])) {
$template->assign($params['assign_headers'],preg_split("!\r\n!",$csplit[0])); $template->assign($params['assign_headers'], preg_split("!\r\n!", $csplit[0]));
} }
} }
} else { } else {
trigger_error("[plugin fetch] unable to parse URL, check syntax",E_USER_NOTICE); trigger_error("[plugin fetch] unable to parse URL, check syntax", E_USER_NOTICE);
return; return;
} }
} else { } else {
$content = @file_get_contents($params['file']); $content = @file_get_contents($params['file']);
if ($content === false) { if ($content === false) {
throw new SmartyException("{fetch} cannot read resource '" . $params['file'] ."'"); throw new SmartyException("{fetch} cannot read resource '" . $params['file'] . "'");
} }
} }

View File

@@ -2,13 +2,12 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsFunction * @subpackage PluginsFunction
*/ */
/** /**
* Smarty {html_checkboxes} function plugin * Smarty {html_checkboxes} function plugin
*
* File: function.html_checkboxes.php<br> * File: function.html_checkboxes.php<br>
* Type: function<br> * Type: function<br>
* Name: html_checkboxes<br> * Name: html_checkboxes<br>
@@ -32,15 +31,17 @@
* - escape (optional) - escape the content (not value), defaults to true * - escape (optional) - escape the content (not value), defaults to true
* </pre> * </pre>
* *
* @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes} * @link http://www.smarty.net/manual/en/language.function.html.checkboxes.php {html_checkboxes}
* (Smarty online manual) * (Smarty online manual)
* @author Christopher Kvarme <christopher.kvarme@flashjab.com> * @author Christopher Kvarme <christopher.kvarme@flashjab.com>
* @author credits to Monte Ohrt <monte at ohrt dot com> * @author credits to Monte Ohrt <monte at ohrt dot com>
* @version 1.0 * @version 1.0
* @param array $params parameters *
* @param array $params parameters
* @param object $template template object * @param object $template template object
*
* @return string * @return string
* @uses smarty_function_escape_special_chars() * @uses smarty_function_escape_special_chars()
*/ */
function smarty_function_html_checkboxes($params, $template) function smarty_function_html_checkboxes($params, $template)
{ {
@@ -89,7 +90,7 @@ function smarty_function_html_checkboxes($params, $template)
if (method_exists($_sel, "__toString")) { if (method_exists($_sel, "__toString")) {
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString()); $_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
} else { } else {
trigger_error("html_checkboxes: selected attribute contains an object of class '". get_class($_sel) ."' without __toString() method", E_USER_NOTICE); trigger_error("html_checkboxes: selected attribute contains an object of class '" . get_class($_sel) . "' without __toString() method", E_USER_NOTICE);
continue; continue;
} }
} else { } else {
@@ -101,7 +102,7 @@ function smarty_function_html_checkboxes($params, $template)
if (method_exists($_val, "__toString")) { if (method_exists($_val, "__toString")) {
$selected = smarty_function_escape_special_chars((string) $_val->__toString()); $selected = smarty_function_escape_special_chars((string) $_val->__toString());
} else { } else {
trigger_error("html_checkboxes: selected attribute is an object of class '". get_class($_val) ."' without __toString() method", E_USER_NOTICE); trigger_error("html_checkboxes: selected attribute is an object of class '" . get_class($_val) . "' without __toString() method", E_USER_NOTICE);
} }
} else { } else {
$selected = smarty_function_escape_special_chars((string) $_val); $selected = smarty_function_escape_special_chars((string) $_val);
@@ -116,7 +117,8 @@ function smarty_function_html_checkboxes($params, $template)
case 'assign': case 'assign':
break; break;
case 'strict': break; case 'strict':
break;
case 'disabled': case 'disabled':
case 'readonly': case 'readonly':
@@ -131,11 +133,11 @@ function smarty_function_html_checkboxes($params, $template)
break; break;
} }
// omit break; to fall through! // omit break; to fall through!
default: default:
if (!is_array($_val)) { if (!is_array($_val)) {
$extra .= ' '.$_key.'="'.smarty_function_escape_special_chars($_val).'"'; $extra .= ' ' . $_key . '="' . smarty_function_escape_special_chars($_val) . '"';
} else { } else {
trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE); trigger_error("html_checkboxes: extra attribute '$_key' cannot be an array", E_USER_NOTICE);
} }
@@ -143,17 +145,18 @@ function smarty_function_html_checkboxes($params, $template)
} }
} }
if (!isset($options) && !isset($values)) if (!isset($options) && !isset($values)) {
return ''; /* raise error here? */ return '';
} /* raise error here? */
$_html_result = array(); $_html_result = array();
if (isset($options)) { 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, $label_ids, $escape); $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape);
} }
} else { } else {
foreach ($values as $_i=>$_key) { foreach ($values as $_i => $_key) {
$_val = isset($output[$_i]) ? $output[$_i] : ''; $_val = isset($output[$_i]) ? $output[$_i] : '';
$_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape); $_html_result[] = smarty_function_html_checkboxes_output($name, $_key, $_val, $selected, $extra, $separator, $labels, $label_ids, $escape);
} }
@@ -164,10 +167,9 @@ function smarty_function_html_checkboxes($params, $template)
} else { } else {
return implode("\n", $_html_result); return implode("\n", $_html_result);
} }
} }
function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape=true) function smarty_function_html_checkboxes_output($name, $value, $output, $selected, $extra, $separator, $labels, $label_ids, $escape = true)
{ {
$_output = ''; $_output = '';
@@ -175,7 +177,7 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
if (method_exists($value, "__toString")) { if (method_exists($value, "__toString")) {
$value = (string) $value->__toString(); $value = (string) $value->__toString();
} else { } else {
trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE); trigger_error("html_options: value is an object of class '" . get_class($value) . "' without __toString() method", E_USER_NOTICE);
return ''; return '';
} }
@@ -187,7 +189,7 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
if (method_exists($output, "__toString")) { if (method_exists($output, "__toString")) {
$output = (string) $output->__toString(); $output = (string) $output->__toString();
} else { } else {
trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE); trigger_error("html_options: output is an object of class '" . get_class($output) . "' without __toString() method", E_USER_NOTICE);
return ''; return '';
} }
@@ -229,7 +231,7 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte
$_output .= '</label>'; $_output .= '</label>';
} }
$_output .= $separator; $_output .= $separator;
return $_output; return $_output;
} }

View File

@@ -2,13 +2,12 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsFunction * @subpackage PluginsFunction
*/ */
/** /**
* Smarty {html_image} function plugin * Smarty {html_image} function plugin
*
* Type: function<br> * Type: function<br>
* Name: html_image<br> * Name: html_image<br>
* Date: Feb 24, 2003<br> * Date: Feb 24, 2003<br>
@@ -24,15 +23,18 @@
* - path_prefix - prefix for path output (optional, default empty) * - path_prefix - prefix for path output (optional, default empty)
* </pre> * </pre>
* *
* @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image} * @link http://www.smarty.net/manual/en/language.function.html.image.php {html_image}
* (Smarty online manual) * (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @author credits to Duda <duda@big.hu> * @author credits to Duda <duda@big.hu>
* @version 1.0 * @version 1.0
*
* @param array $params parameters * @param array $params parameters
* @param Smarty_Internal_Template $template template object * @param Smarty_Internal_Template $template template object
*
* @throws SmartyException
* @return string * @return string
* @uses smarty_function_escape_special_chars() * @uses smarty_function_escape_special_chars()
*/ */
function smarty_function_html_image($params, $template) function smarty_function_html_image($params, $template)
{ {
@@ -112,7 +114,7 @@ function smarty_function_html_image($params, $template)
} }
} else { } else {
// local file // local file
if (!$template->smarty->security_policy->isTrustedResourceDir($params['file'])) { if (!$template->smarty->security_policy->isTrustedResourceDir($_image_path)) {
return; return;
} }
} }

View File

@@ -2,13 +2,12 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsFunction * @subpackage PluginsFunction
*/ */
/** /**
* Smarty {html_options} function plugin * Smarty {html_options} function plugin
*
* Type: function<br> * Type: function<br>
* Name: html_options<br> * Name: html_options<br>
* Purpose: Prints the list of <option> tags generated from * Purpose: Prints the list of <option> tags generated from
@@ -24,16 +23,17 @@
* - class (optional) - string default not set * - class (optional) - string default not set
* </pre> * </pre>
* *
* @link http://www.smarty.net/manual/en/language.function.html.options.php {html_image} * @link http://www.smarty.net/manual/en/language.function.html.options.php {html_image}
* (Smarty online manual) * (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de> * @author Ralf Strehle (minor optimization) <ralf dot strehle at yahoo dot de>
* @param array $params parameters *
* @param Smarty_Internal_Template $template template object * @param array $params parameters
*
* @return string * @return string
* @uses smarty_function_escape_special_chars() * @uses smarty_function_escape_special_chars()
*/ */
function smarty_function_html_options($params, $template) function smarty_function_html_options($params)
{ {
require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php'); require_once(SMARTY_PLUGINS_DIR . 'shared.escape_special_chars.php');
@@ -72,7 +72,7 @@ function smarty_function_html_options($params, $template)
if (method_exists($_sel, "__toString")) { if (method_exists($_sel, "__toString")) {
$_sel = smarty_function_escape_special_chars((string) $_sel->__toString()); $_sel = smarty_function_escape_special_chars((string) $_sel->__toString());
} else { } else {
trigger_error("html_options: selected attribute contains an object of class '". get_class($_sel) ."' without __toString() method", E_USER_NOTICE); trigger_error("html_options: selected attribute contains an object of class '" . get_class($_sel) . "' without __toString() method", E_USER_NOTICE);
continue; continue;
} }
} else { } else {
@@ -84,14 +84,15 @@ function smarty_function_html_options($params, $template)
if (method_exists($_val, "__toString")) { if (method_exists($_val, "__toString")) {
$selected = smarty_function_escape_special_chars((string) $_val->__toString()); $selected = smarty_function_escape_special_chars((string) $_val->__toString());
} else { } else {
trigger_error("html_options: selected attribute is an object of class '". get_class($_val) ."' without __toString() method", E_USER_NOTICE); trigger_error("html_options: selected attribute is an object of class '" . get_class($_val) . "' without __toString() method", E_USER_NOTICE);
} }
} else { } else {
$selected = smarty_function_escape_special_chars((string) $_val); $selected = smarty_function_escape_special_chars((string) $_val);
} }
break; break;
case 'strict': break; case 'strict':
break;
case 'disabled': case 'disabled':
case 'readonly': case 'readonly':
@@ -106,7 +107,7 @@ function smarty_function_html_options($params, $template)
break; break;
} }
// omit break; to fall through! // omit break; to fall through!
default: default:
if (!is_array($_val)) { if (!is_array($_val)) {
@@ -139,8 +140,8 @@ function smarty_function_html_options($params, $template)
} }
if (!empty($name)) { if (!empty($name)) {
$_html_class = !empty($class) ? ' class="'.$class.'"' : ''; $_html_class = !empty($class) ? ' class="' . $class . '"' : '';
$_html_id = !empty($id) ? ' id="'.$id.'"' : ''; $_html_id = !empty($id) ? ' id="' . $id . '"' : '';
$_html_result = '<select name="' . $name . '"' . $_html_class . $_html_id . $extra . '>' . "\n" . $_html_result . '</select>' . "\n"; $_html_result = '<select name="' . $name . '"' . $_html_class . $_html_id . $extra . '>' . "\n" . $_html_result . '</select>' . "\n";
} }
@@ -159,13 +160,13 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
} elseif ($_key === $selected) { } elseif ($_key === $selected) {
$_html_result .= ' selected="selected"'; $_html_result .= ' selected="selected"';
} }
$_html_class = !empty($class) ? ' class="'.$class.' option"' : ''; $_html_class = !empty($class) ? ' class="' . $class . ' option"' : '';
$_html_id = !empty($id) ? ' id="'.$id.'-'.$idx.'"' : ''; $_html_id = !empty($id) ? ' id="' . $id . '-' . $idx . '"' : '';
if (is_object($value)) { if (is_object($value)) {
if (method_exists($value, "__toString")) { if (method_exists($value, "__toString")) {
$value = smarty_function_escape_special_chars((string) $value->__toString()); $value = smarty_function_escape_special_chars((string) $value->__toString());
} else { } else {
trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE); trigger_error("html_options: value is an object of class '" . get_class($value) . "' without __toString() method", E_USER_NOTICE);
return ''; return '';
} }
@@ -173,11 +174,11 @@ function smarty_function_html_options_optoutput($key, $value, $selected, $id, $c
$value = smarty_function_escape_special_chars((string) $value); $value = smarty_function_escape_special_chars((string) $value);
} }
$_html_result .= $_html_class . $_html_id . '>' . $value . '</option>' . "\n"; $_html_result .= $_html_class . $_html_id . '>' . $value . '</option>' . "\n";
$idx++; $idx ++;
} else { } else {
$_idx = 0; $_idx = 0;
$_html_result = smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id.'-'.$idx) : null, $class, $_idx); $_html_result = smarty_function_html_options_optgroup($key, $value, $selected, !empty($id) ? ($id . '-' . $idx) : null, $class, $_idx);
$idx++; $idx ++;
} }
return $_html_result; return $_html_result;

View File

@@ -2,13 +2,12 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsFunction * @subpackage PluginsFunction
*/ */
/** /**
* Smarty {html_radios} function plugin * Smarty {html_radios} function plugin
*
* File: function.html_radios.php<br> * File: function.html_radios.php<br>
* Type: function<br> * Type: function<br>
* Name: html_radios<br> * Name: html_radios<br>
@@ -32,15 +31,17 @@
* {html_radios values=$ids checked=$checked separator='<br>' output=$names} * {html_radios values=$ids checked=$checked separator='<br>' output=$names}
* </pre> * </pre>
* *
* @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios} * @link http://smarty.php.net/manual/en/language.function.html.radios.php {html_radios}
* (Smarty online manual) * (Smarty online manual)
* @author Christopher Kvarme <christopher.kvarme@flashjab.com> * @author Christopher Kvarme <christopher.kvarme@flashjab.com>
* @author credits to Monte Ohrt <monte at ohrt dot com> * @author credits to Monte Ohrt <monte at ohrt dot com>
* @version 1.0 * @version 1.0
*
* @param array $params parameters * @param array $params parameters
* @param Smarty_Internal_Template $template template object * @param Smarty_Internal_Template $template template object
*
* @return string * @return string
* @uses smarty_function_escape_special_chars() * @uses smarty_function_escape_special_chars()
*/ */
function smarty_function_html_radios($params, $template) function smarty_function_html_radios($params, $template)
{ {
@@ -72,7 +73,7 @@ function smarty_function_html_radios($params, $template)
if (method_exists($_val, "__toString")) { if (method_exists($_val, "__toString")) {
$selected = smarty_function_escape_special_chars((string) $_val->__toString()); $selected = smarty_function_escape_special_chars((string) $_val->__toString());
} else { } else {
trigger_error("html_radios: selected attribute is an object of class '". get_class($_val) ."' without __toString() method", E_USER_NOTICE); trigger_error("html_radios: selected attribute is an object of class '" . get_class($_val) . "' without __toString() method", E_USER_NOTICE);
} }
} else { } else {
$selected = (string) $_val; $selected = (string) $_val;
@@ -102,7 +103,8 @@ function smarty_function_html_radios($params, $template)
case 'assign': case 'assign':
break; break;
case 'strict': break; case 'strict':
break;
case 'disabled': case 'disabled':
case 'readonly': case 'readonly':
@@ -117,7 +119,7 @@ function smarty_function_html_radios($params, $template)
break; break;
} }
// omit break; to fall through! // omit break; to fall through!
default: default:
if (!is_array($_val)) { if (!is_array($_val)) {
@@ -163,7 +165,7 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
if (method_exists($value, "__toString")) { if (method_exists($value, "__toString")) {
$value = (string) $value->__toString(); $value = (string) $value->__toString();
} else { } else {
trigger_error("html_options: value is an object of class '". get_class($value) ."' without __toString() method", E_USER_NOTICE); trigger_error("html_options: value is an object of class '" . get_class($value) . "' without __toString() method", E_USER_NOTICE);
return ''; return '';
} }
@@ -175,7 +177,7 @@ function smarty_function_html_radios_output($name, $value, $output, $selected, $
if (method_exists($output, "__toString")) { if (method_exists($output, "__toString")) {
$output = (string) $output->__toString(); $output = (string) $output->__toString();
} else { } else {
trigger_error("html_options: output is an object of class '". get_class($output) ."' without __toString() method", E_USER_NOTICE); trigger_error("html_options: output is an object of class '" . get_class($output) . "' without __toString() method", E_USER_NOTICE);
return ''; return '';
} }

View File

@@ -2,7 +2,7 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsFunction * @subpackage PluginsFunction
*/ */
@@ -17,11 +17,9 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
/** /**
* Smarty {html_select_date} plugin * Smarty {html_select_date} plugin
*
* Type: function<br> * Type: function<br>
* Name: html_select_date<br> * Name: html_select_date<br>
* Purpose: Prints the dropdowns for date selection. * Purpose: Prints the dropdowns for date selection.
*
* ChangeLog: * ChangeLog:
* <pre> * <pre>
* - 1.0 initial release * - 1.0 initial release
@@ -41,17 +39,18 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
* added attributes month_names, *_id * added attributes month_names, *_id
* </pre> * </pre>
* *
* @link http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date} * @link http://www.smarty.net/manual/en/language.function.html.select.date.php {html_select_date}
* (Smarty online manual) * (Smarty online manual)
* @version 2.0 * @version 2.0
* @author Andrei Zmievski * @author Andrei Zmievski
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @author Rodney Rehm * @author Rodney Rehm
* @param array $params parameters *
* @param Smarty_Internal_Template $template template object * @param array $params parameters
*
* @return string * @return string
*/ */
function smarty_function_html_select_date($params, $template) function smarty_function_html_select_date($params)
{ {
// generate timestamps used for month names only // generate timestamps used for month names only
static $_month_timestamps = null; static $_month_timestamps = null;
@@ -59,7 +58,7 @@ function smarty_function_html_select_date($params, $template)
if ($_month_timestamps === null) { if ($_month_timestamps === null) {
$_current_year = date('Y'); $_current_year = date('Y');
$_month_timestamps = array(); $_month_timestamps = array();
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i ++) {
$_month_timestamps[$i] = mktime(0, 0, 0, $i, 1, 2000); $_month_timestamps[$i] = mktime(0, 0, 0, $i, 1, 2000);
} }
} }
@@ -181,22 +180,20 @@ function smarty_function_html_select_date($params, $template)
if (isset($params['time']) && is_array($params['time'])) { if (isset($params['time']) && is_array($params['time'])) {
if (isset($params['time'][$prefix . 'Year'])) { if (isset($params['time'][$prefix . 'Year'])) {
// $_REQUEST[$field_array] given // $_REQUEST[$field_array] given
foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) { foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) {
$_variableName = '_' . strtolower($_elementName); $_variableName = '_' . strtolower($_elementName);
$$_variableName = isset($params['time'][$prefix . $_elementName]) $$_variableName = isset($params['time'][$prefix . $_elementName])
? $params['time'][$prefix . $_elementName] ? $params['time'][$prefix . $_elementName]
: date($_elementKey); : date($_elementKey);
} }
$time = mktime(0, 0, 0, $_month, $_day, $_year);
} elseif (isset($params['time'][$field_array][$prefix . 'Year'])) { } elseif (isset($params['time'][$field_array][$prefix . 'Year'])) {
// $_REQUEST given // $_REQUEST given
foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) { foreach (array('Y' => 'Year', 'm' => 'Month', 'd' => 'Day') as $_elementKey => $_elementName) {
$_variableName = '_' . strtolower($_elementName); $_variableName = '_' . strtolower($_elementName);
$$_variableName = isset($params['time'][$field_array][$prefix . $_elementName]) $$_variableName = isset($params['time'][$field_array][$prefix . $_elementName])
? $params['time'][$field_array][$prefix . $_elementName] ? $params['time'][$field_array][$prefix . $_elementName]
: date($_elementKey); : date($_elementKey);
} }
$time = mktime(0, 0, 0, $_month, $_day, $_year);
} else { } else {
// no date found, use NOW // no date found, use NOW
list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d')); list($_year, $_month, $_day) = $time = explode('-', date('Y-m-d'));
@@ -219,9 +216,9 @@ function smarty_function_html_select_date($params, $template)
if ($t === null) { if ($t === null) {
$$key = (int) $_current_year; $$key = (int) $_current_year;
} elseif ($t[0] == '+') { } elseif ($t[0] == '+') {
$$key = (int) ($_current_year + trim(substr($t, 1))); $$key = (int) ($_current_year + (int)trim(substr($t, 1)));
} elseif ($t[0] == '-') { } elseif ($t[0] == '-') {
$$key = (int) ($_current_year - trim(substr($t, 1))); $$key = (int) ($_current_year - (int)trim(substr($t, 1)));
} else { } else {
$$key = (int) $$key; $$key = (int) $$key;
} }
@@ -236,7 +233,6 @@ function smarty_function_html_select_date($params, $template)
// generate year <select> or <input> // generate year <select> or <input>
if ($display_years) { if ($display_years) {
$_html_years = '';
$_extra = ''; $_extra = '';
$_name = $field_array ? ($field_array . '[' . $prefix . 'Year]') : ($prefix . 'Year'); $_name = $field_array ? ($field_array . '[' . $prefix . 'Year]') : ($prefix . 'Year');
if ($all_extra) { if ($all_extra) {
@@ -252,8 +248,8 @@ function smarty_function_html_select_date($params, $template)
$_html_years = '<select name="' . $_name . '"'; $_html_years = '<select name="' . $_name . '"';
if ($year_id !== null || $all_id !== null) { if ($year_id !== null || $all_id !== null) {
$_html_years .= ' id="' . smarty_function_escape_special_chars( $_html_years .= ' id="' . smarty_function_escape_special_chars(
$year_id !== null ? ( $year_id ? $year_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name ) $year_id !== null ? ($year_id ? $year_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
) . '"'; ) . '"';
} }
if ($year_size) { if ($year_size) {
$_html_years .= ' size="' . $year_size . '"'; $_html_years .= ' size="' . $year_size . '"';
@@ -261,11 +257,11 @@ function smarty_function_html_select_date($params, $template)
$_html_years .= $_extra . $extra_attrs . '>' . $option_separator; $_html_years .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($year_empty) || isset($all_empty)) { if (isset($year_empty) || isset($all_empty)) {
$_html_years .= '<option value="">' . ( isset($year_empty) ? $year_empty : $all_empty ) . '</option>' . $option_separator; $_html_years .= '<option value="">' . (isset($year_empty) ? $year_empty : $all_empty) . '</option>' . $option_separator;
} }
$op = $start_year > $end_year ? -1 : 1; $op = $start_year > $end_year ? - 1 : 1;
for ($i=$start_year; $op > 0 ? $i <= $end_year : $i >= $end_year; $i += $op) { for ($i = $start_year; $op > 0 ? $i <= $end_year : $i >= $end_year; $i += $op) {
$_html_years .= '<option value="' . $i . '"' $_html_years .= '<option value="' . $i . '"'
. ($_year == $i ? ' selected="selected"' : '') . ($_year == $i ? ' selected="selected"' : '')
. '>' . $i . '</option>' . $option_separator; . '>' . $i . '</option>' . $option_separator;
@@ -277,7 +273,6 @@ function smarty_function_html_select_date($params, $template)
// generate month <select> or <input> // generate month <select> or <input>
if ($display_months) { if ($display_months) {
$_html_month = '';
$_extra = ''; $_extra = '';
$_name = $field_array ? ($field_array . '[' . $prefix . 'Month]') : ($prefix . 'Month'); $_name = $field_array ? ($field_array . '[' . $prefix . 'Month]') : ($prefix . 'Month');
if ($all_extra) { if ($all_extra) {
@@ -290,8 +285,8 @@ function smarty_function_html_select_date($params, $template)
$_html_months = '<select name="' . $_name . '"'; $_html_months = '<select name="' . $_name . '"';
if ($month_id !== null || $all_id !== null) { if ($month_id !== null || $all_id !== null) {
$_html_months .= ' id="' . smarty_function_escape_special_chars( $_html_months .= ' id="' . smarty_function_escape_special_chars(
$month_id !== null ? ( $month_id ? $month_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name ) $month_id !== null ? ($month_id ? $month_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
) . '"'; ) . '"';
} }
if ($month_size) { if ($month_size) {
$_html_months .= ' size="' . $month_size . '"'; $_html_months .= ' size="' . $month_size . '"';
@@ -299,10 +294,10 @@ function smarty_function_html_select_date($params, $template)
$_html_months .= $_extra . $extra_attrs . '>' . $option_separator; $_html_months .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($month_empty) || isset($all_empty)) { if (isset($month_empty) || isset($all_empty)) {
$_html_months .= '<option value="">' . ( isset($month_empty) ? $month_empty : $all_empty ) . '</option>' . $option_separator; $_html_months .= '<option value="">' . (isset($month_empty) ? $month_empty : $all_empty) . '</option>' . $option_separator;
} }
for ($i = 1; $i <= 12; $i++) { for ($i = 1; $i <= 12; $i ++) {
$_val = sprintf('%02d', $i); $_val = sprintf('%02d', $i);
$_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[$i]) : ($month_format == "%m" ? $_val : strftime($month_format, $_month_timestamps[$i])); $_text = isset($month_names) ? smarty_function_escape_special_chars($month_names[$i]) : ($month_format == "%m" ? $_val : strftime($month_format, $_month_timestamps[$i]));
$_value = $month_value_format == "%m" ? $_val : strftime($month_value_format, $_month_timestamps[$i]); $_value = $month_value_format == "%m" ? $_val : strftime($month_value_format, $_month_timestamps[$i]);
@@ -316,7 +311,6 @@ function smarty_function_html_select_date($params, $template)
// generate day <select> or <input> // generate day <select> or <input>
if ($display_days) { if ($display_days) {
$_html_day = '';
$_extra = ''; $_extra = '';
$_name = $field_array ? ($field_array . '[' . $prefix . 'Day]') : ($prefix . 'Day'); $_name = $field_array ? ($field_array . '[' . $prefix . 'Day]') : ($prefix . 'Day');
if ($all_extra) { if ($all_extra) {
@@ -329,8 +323,8 @@ function smarty_function_html_select_date($params, $template)
$_html_days = '<select name="' . $_name . '"'; $_html_days = '<select name="' . $_name . '"';
if ($day_id !== null || $all_id !== null) { if ($day_id !== null || $all_id !== null) {
$_html_days .= ' id="' . smarty_function_escape_special_chars( $_html_days .= ' id="' . smarty_function_escape_special_chars(
$day_id !== null ? ( $day_id ? $day_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name ) $day_id !== null ? ($day_id ? $day_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
) . '"'; ) . '"';
} }
if ($day_size) { if ($day_size) {
$_html_days .= ' size="' . $day_size . '"'; $_html_days .= ' size="' . $day_size . '"';
@@ -338,13 +332,13 @@ function smarty_function_html_select_date($params, $template)
$_html_days .= $_extra . $extra_attrs . '>' . $option_separator; $_html_days .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($day_empty) || isset($all_empty)) { if (isset($day_empty) || isset($all_empty)) {
$_html_days .= '<option value="">' . ( isset($day_empty) ? $day_empty : $all_empty ) . '</option>' . $option_separator; $_html_days .= '<option value="">' . (isset($day_empty) ? $day_empty : $all_empty) . '</option>' . $option_separator;
} }
for ($i = 1; $i <= 31; $i++) { for ($i = 1; $i <= 31; $i ++) {
$_val = sprintf('%02d', $i); $_val = sprintf('%02d', $i);
$_text = $day_format == '%02d' ? $_val : sprintf($day_format, $i); $_text = $day_format == '%02d' ? $_val : sprintf($day_format, $i);
$_value = $day_value_format == '%02d' ? $_val : sprintf($day_value_format, $i); $_value = $day_value_format == '%02d' ? $_val : sprintf($day_value_format, $i);
$_html_days .= '<option value="' . $_value . '"' $_html_days .= '<option value="' . $_value . '"'
. ($_val == $_day ? ' selected="selected"' : '') . ($_val == $_day ? ' selected="selected"' : '')
. '>' . $_text . '</option>' . $option_separator; . '>' . $_text . '</option>' . $option_separator;
@@ -355,7 +349,7 @@ function smarty_function_html_select_date($params, $template)
// order the fields for output // order the fields for output
$_html = ''; $_html = '';
for ($i=0; $i <= 2; $i++) { for ($i = 0; $i <= 2; $i ++) {
switch ($field_order[$i]) { switch ($field_order[$i]) {
case 'Y': case 'Y':
case 'y': case 'y':
@@ -365,7 +359,7 @@ function smarty_function_html_select_date($params, $template)
} }
$_html .= $_html_years; $_html .= $_html_years;
} }
break; break;
case 'm': case 'm':
case 'M': case 'M':
@@ -375,7 +369,7 @@ function smarty_function_html_select_date($params, $template)
} }
$_html .= $_html_months; $_html .= $_html_months;
} }
break; break;
case 'd': case 'd':
case 'D': case 'D':
@@ -385,7 +379,7 @@ function smarty_function_html_select_date($params, $template)
} }
$_html .= $_html_days; $_html .= $_html_days;
} }
break; break;
} }
} }

View File

@@ -2,7 +2,7 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsFunction * @subpackage PluginsFunction
*/ */
@@ -17,21 +17,21 @@ require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
/** /**
* Smarty {html_select_time} function plugin * Smarty {html_select_time} function plugin
*
* Type: function<br> * Type: function<br>
* Name: html_select_time<br> * Name: html_select_time<br>
* Purpose: Prints the dropdowns for time selection * Purpose: Prints the dropdowns for time selection
* *
* @link http://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time} * @link http://www.smarty.net/manual/en/language.function.html.select.time.php {html_select_time}
* (Smarty online manual) * (Smarty online manual)
* @author Roberto Berto <roberto@berto.net> * @author Roberto Berto <roberto@berto.net>
* @author Monte Ohrt <monte AT ohrt DOT com> * @author Monte Ohrt <monte AT ohrt DOT com>
* @param array $params parameters *
* @param Smarty_Internal_Template $template template object * @param array $params parameters
*
* @return string * @return string
* @uses smarty_make_timestamp() * @uses smarty_make_timestamp()
*/ */
function smarty_function_html_select_time($params, $template) function smarty_function_html_select_time($params)
{ {
$prefix = "Time_"; $prefix = "Time_";
$field_array = null; $field_array = null;
@@ -151,7 +151,7 @@ function smarty_function_html_select_time($params, $template)
if (isset($params['time']) && is_array($params['time'])) { if (isset($params['time']) && is_array($params['time'])) {
if (isset($params['time'][$prefix . 'Hour'])) { if (isset($params['time'][$prefix . 'Hour'])) {
// $_REQUEST[$field_array] given // $_REQUEST[$field_array] given
foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) { foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) {
$_variableName = '_' . strtolower($_elementName); $_variableName = '_' . strtolower($_elementName);
$$_variableName = isset($params['time'][$prefix . $_elementName]) $$_variableName = isset($params['time'][$prefix . $_elementName])
? $params['time'][$prefix . $_elementName] ? $params['time'][$prefix . $_elementName]
@@ -160,11 +160,11 @@ function smarty_function_html_select_time($params, $template)
$_meridian = isset($params['time'][$prefix . 'Meridian']) $_meridian = isset($params['time'][$prefix . 'Meridian'])
? (' ' . $params['time'][$prefix . 'Meridian']) ? (' ' . $params['time'][$prefix . 'Meridian'])
: ''; : '';
$time = strtotime( $_hour . ':' . $_minute . ':' . $_second . $_meridian ); $time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian);
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time)); list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
} elseif (isset($params['time'][$field_array][$prefix . 'Hour'])) { } elseif (isset($params['time'][$field_array][$prefix . 'Hour'])) {
// $_REQUEST given // $_REQUEST given
foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) { foreach (array('H' => 'Hour', 'i' => 'Minute', 's' => 'Second') as $_elementKey => $_elementName) {
$_variableName = '_' . strtolower($_elementName); $_variableName = '_' . strtolower($_elementName);
$$_variableName = isset($params['time'][$field_array][$prefix . $_elementName]) $$_variableName = isset($params['time'][$field_array][$prefix . $_elementName])
? $params['time'][$field_array][$prefix . $_elementName] ? $params['time'][$field_array][$prefix . $_elementName]
@@ -173,7 +173,7 @@ function smarty_function_html_select_time($params, $template)
$_meridian = isset($params['time'][$field_array][$prefix . 'Meridian']) $_meridian = isset($params['time'][$field_array][$prefix . 'Meridian'])
? (' ' . $params['time'][$field_array][$prefix . 'Meridian']) ? (' ' . $params['time'][$field_array][$prefix . 'Meridian'])
: ''; : '';
$time = strtotime( $_hour . ':' . $_minute . ':' . $_second . $_meridian ); $time = strtotime($_hour . ':' . $_minute . ':' . $_second . $_meridian);
list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time)); list($_hour, $_minute, $_second) = $time = explode('-', date('H-i-s', $time));
} else { } else {
// no date found, use NOW // no date found, use NOW
@@ -204,8 +204,8 @@ function smarty_function_html_select_time($params, $template)
$_html_hours = '<select name="' . $_name . '"'; $_html_hours = '<select name="' . $_name . '"';
if ($hour_id !== null || $all_id !== null) { if ($hour_id !== null || $all_id !== null) {
$_html_hours .= ' id="' . smarty_function_escape_special_chars( $_html_hours .= ' id="' . smarty_function_escape_special_chars(
$hour_id !== null ? ( $hour_id ? $hour_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name ) $hour_id !== null ? ($hour_id ? $hour_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
) . '"'; ) . '"';
} }
if ($hour_size) { if ($hour_size) {
$_html_hours .= ' size="' . $hour_size . '"'; $_html_hours .= ' size="' . $hour_size . '"';
@@ -213,12 +213,12 @@ function smarty_function_html_select_time($params, $template)
$_html_hours .= $_extra . $extra_attrs . '>' . $option_separator; $_html_hours .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($hour_empty) || isset($all_empty)) { if (isset($hour_empty) || isset($all_empty)) {
$_html_hours .= '<option value="">' . ( isset($hour_empty) ? $hour_empty : $all_empty ) . '</option>' . $option_separator; $_html_hours .= '<option value="">' . (isset($hour_empty) ? $hour_empty : $all_empty) . '</option>' . $option_separator;
} }
$start = $use_24_hours ? 0 : 1; $start = $use_24_hours ? 0 : 1;
$end = $use_24_hours ? 23 : 12; $end = $use_24_hours ? 23 : 12;
for ($i=$start; $i <= $end; $i++) { for ($i = $start; $i <= $end; $i ++) {
$_val = sprintf('%02d', $i); $_val = sprintf('%02d', $i);
$_text = $hour_format == '%02d' ? $_val : sprintf($hour_format, $i); $_text = $hour_format == '%02d' ? $_val : sprintf($hour_format, $i);
$_value = $hour_value_format == '%02d' ? $_val : sprintf($hour_value_format, $i); $_value = $hour_value_format == '%02d' ? $_val : sprintf($hour_value_format, $i);
@@ -226,7 +226,7 @@ function smarty_function_html_select_time($params, $template)
if (!$use_24_hours) { if (!$use_24_hours) {
$_hour12 = $_hour == 0 $_hour12 = $_hour == 0
? 12 ? 12
: ($_hour <= 12 ? $_hour : $_hour -12); : ($_hour <= 12 ? $_hour : $_hour - 12);
} }
$selected = $_hour !== null ? ($use_24_hours ? $_hour == $_val : $_hour12 == $_val) : null; $selected = $_hour !== null ? ($use_24_hours ? $_hour == $_val : $_hour12 == $_val) : null;
@@ -253,8 +253,8 @@ function smarty_function_html_select_time($params, $template)
$_html_minutes = '<select name="' . $_name . '"'; $_html_minutes = '<select name="' . $_name . '"';
if ($minute_id !== null || $all_id !== null) { if ($minute_id !== null || $all_id !== null) {
$_html_minutes .= ' id="' . smarty_function_escape_special_chars( $_html_minutes .= ' id="' . smarty_function_escape_special_chars(
$minute_id !== null ? ( $minute_id ? $minute_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name ) $minute_id !== null ? ($minute_id ? $minute_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
) . '"'; ) . '"';
} }
if ($minute_size) { if ($minute_size) {
$_html_minutes .= ' size="' . $minute_size . '"'; $_html_minutes .= ' size="' . $minute_size . '"';
@@ -262,11 +262,11 @@ function smarty_function_html_select_time($params, $template)
$_html_minutes .= $_extra . $extra_attrs . '>' . $option_separator; $_html_minutes .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($minute_empty) || isset($all_empty)) { if (isset($minute_empty) || isset($all_empty)) {
$_html_minutes .= '<option value="">' . ( isset($minute_empty) ? $minute_empty : $all_empty ) . '</option>' . $option_separator; $_html_minutes .= '<option value="">' . (isset($minute_empty) ? $minute_empty : $all_empty) . '</option>' . $option_separator;
} }
$selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null; $selected = $_minute !== null ? ($_minute - $_minute % $minute_interval) : null;
for ($i=0; $i <= 59; $i += $minute_interval) { for ($i = 0; $i <= 59; $i += $minute_interval) {
$_val = sprintf('%02d', $i); $_val = sprintf('%02d', $i);
$_text = $minute_format == '%02d' ? $_val : sprintf($minute_format, $i); $_text = $minute_format == '%02d' ? $_val : sprintf($minute_format, $i);
$_value = $minute_value_format == '%02d' ? $_val : sprintf($minute_value_format, $i); $_value = $minute_value_format == '%02d' ? $_val : sprintf($minute_value_format, $i);
@@ -293,8 +293,8 @@ function smarty_function_html_select_time($params, $template)
$_html_seconds = '<select name="' . $_name . '"'; $_html_seconds = '<select name="' . $_name . '"';
if ($second_id !== null || $all_id !== null) { if ($second_id !== null || $all_id !== null) {
$_html_seconds .= ' id="' . smarty_function_escape_special_chars( $_html_seconds .= ' id="' . smarty_function_escape_special_chars(
$second_id !== null ? ( $second_id ? $second_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name ) $second_id !== null ? ($second_id ? $second_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
) . '"'; ) . '"';
} }
if ($second_size) { if ($second_size) {
$_html_seconds .= ' size="' . $second_size . '"'; $_html_seconds .= ' size="' . $second_size . '"';
@@ -302,11 +302,11 @@ function smarty_function_html_select_time($params, $template)
$_html_seconds .= $_extra . $extra_attrs . '>' . $option_separator; $_html_seconds .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($second_empty) || isset($all_empty)) { if (isset($second_empty) || isset($all_empty)) {
$_html_seconds .= '<option value="">' . ( isset($second_empty) ? $second_empty : $all_empty ) . '</option>' . $option_separator; $_html_seconds .= '<option value="">' . (isset($second_empty) ? $second_empty : $all_empty) . '</option>' . $option_separator;
} }
$selected = $_second !== null ? ($_second - $_second % $second_interval) : null; $selected = $_second !== null ? ($_second - $_second % $second_interval) : null;
for ($i=0; $i <= 59; $i += $second_interval) { for ($i = 0; $i <= 59; $i += $second_interval) {
$_val = sprintf('%02d', $i); $_val = sprintf('%02d', $i);
$_text = $second_format == '%02d' ? $_val : sprintf($second_format, $i); $_text = $second_format == '%02d' ? $_val : sprintf($second_format, $i);
$_value = $second_value_format == '%02d' ? $_val : sprintf($second_value_format, $i); $_value = $second_value_format == '%02d' ? $_val : sprintf($second_value_format, $i);
@@ -333,8 +333,8 @@ function smarty_function_html_select_time($params, $template)
$_html_meridian = '<select name="' . $_name . '"'; $_html_meridian = '<select name="' . $_name . '"';
if ($meridian_id !== null || $all_id !== null) { if ($meridian_id !== null || $all_id !== null) {
$_html_meridian .= ' id="' . smarty_function_escape_special_chars( $_html_meridian .= ' id="' . smarty_function_escape_special_chars(
$meridian_id !== null ? ( $meridian_id ? $meridian_id : $_name ) : ( $all_id ? ($all_id . $_name) : $_name ) $meridian_id !== null ? ($meridian_id ? $meridian_id : $_name) : ($all_id ? ($all_id . $_name) : $_name)
) . '"'; ) . '"';
} }
if ($meridian_size) { if ($meridian_size) {
$_html_meridian .= ' size="' . $meridian_size . '"'; $_html_meridian .= ' size="' . $meridian_size . '"';
@@ -342,11 +342,11 @@ function smarty_function_html_select_time($params, $template)
$_html_meridian .= $_extra . $extra_attrs . '>' . $option_separator; $_html_meridian .= $_extra . $extra_attrs . '>' . $option_separator;
if (isset($meridian_empty) || isset($all_empty)) { if (isset($meridian_empty) || isset($all_empty)) {
$_html_meridian .= '<option value="">' . ( isset($meridian_empty) ? $meridian_empty : $all_empty ) . '</option>' . $option_separator; $_html_meridian .= '<option value="">' . (isset($meridian_empty) ? $meridian_empty : $all_empty) . '</option>' . $option_separator;
} }
$_html_meridian .= '<option value="am"'. ($_hour > 0 && $_hour < 12 ? ' selected="selected"' : '') .'>AM</option>' . $option_separator $_html_meridian .= '<option value="am"' . ($_hour > 0 && $_hour < 12 ? ' selected="selected"' : '') . '>AM</option>' . $option_separator
. '<option value="pm"'. ($_hour < 12 ? '' : ' selected="selected"') .'>PM</option>' . $option_separator . '<option value="pm"' . ($_hour < 12 ? '' : ' selected="selected"') . '>PM</option>' . $option_separator
. '</select>'; . '</select>';
} }

View File

@@ -2,13 +2,12 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsFunction * @subpackage PluginsFunction
*/ */
/** /**
* Smarty {html_table} function plugin * Smarty {html_table} function plugin
*
* Type: function<br> * Type: function<br>
* Name: html_table<br> * Name: html_table<br>
* Date: Feb 17, 2003<br> * Date: Feb 17, 2003<br>
@@ -37,17 +36,18 @@
* {table loop=$data cols="first,second,third" tr_attr=$colors} * {table loop=$data cols="first,second,third" tr_attr=$colors}
* </pre> * </pre>
* *
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @author credit to Messju Mohr <messju at lammfellpuschen dot de> * @author credit to Messju Mohr <messju at lammfellpuschen dot de>
* @author credit to boots <boots dot smarty at yahoo dot com> * @author credit to boots <boots dot smarty at yahoo dot com>
* @version 1.1 * @version 1.1
* @link http://www.smarty.net/manual/en/language.function.html.table.php {html_table} * @link http://www.smarty.net/manual/en/language.function.html.table.php {html_table}
* (Smarty online manual) * (Smarty online manual)
* @param array $params parameters *
* @param Smarty_Internal_Template $template template object * @param array $params parameters
*
* @return string * @return string
*/ */
function smarty_function_html_table($params, $template) function smarty_function_html_table($params)
{ {
$table_attr = 'border="1"'; $table_attr = 'border="1"';
$tr_attr = ''; $tr_attr = '';
@@ -63,7 +63,7 @@ function smarty_function_html_table($params, $template)
$loop = null; $loop = null;
if (!isset($params['loop'])) { if (!isset($params['loop'])) {
trigger_error("html_table: missing 'loop' parameter",E_USER_WARNING); trigger_error("html_table: missing 'loop' parameter", E_USER_WARNING);
return; return;
} }
@@ -130,7 +130,7 @@ function smarty_function_html_table($params, $template)
$cols = ($hdir == 'right') ? $cols : array_reverse($cols); $cols = ($hdir == 'right') ? $cols : array_reverse($cols);
$output .= "<thead><tr>\n"; $output .= "<thead><tr>\n";
for ($r = 0; $r < $cols_count; $r++) { for ($r = 0; $r < $cols_count; $r ++) {
$output .= '<th' . smarty_function_html_table_cycle('th', $th_attr, $r) . '>'; $output .= '<th' . smarty_function_html_table_cycle('th', $th_attr, $r) . '>';
$output .= $cols[$r]; $output .= $cols[$r];
$output .= "</th>\n"; $output .= "</th>\n";
@@ -139,12 +139,12 @@ function smarty_function_html_table($params, $template)
} }
$output .= "<tbody>\n"; $output .= "<tbody>\n";
for ($r = 0; $r < $rows; $r++) { for ($r = 0; $r < $rows; $r ++) {
$output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n"; $output .= "<tr" . smarty_function_html_table_cycle('tr', $tr_attr, $r) . ">\n";
$rx = ($vdir == 'down') ? $r * $cols_count : ($rows-1 - $r) * $cols_count; $rx = ($vdir == 'down') ? $r * $cols_count : ($rows - 1 - $r) * $cols_count;
for ($c = 0; $c < $cols_count; $c++) { for ($c = 0; $c < $cols_count; $c ++) {
$x = ($hdir == 'right') ? $rx + $c : $rx + $cols_count-1 - $c; $x = ($hdir == 'right') ? $rx + $c : $rx + $cols_count - 1 - $c;
if ($inner != 'cols') { if ($inner != 'cols') {
/* shuffle x to loop over rows*/ /* shuffle x to loop over rows*/
$x = floor($x / $cols_count) + ($x % $cols_count) * $rows; $x = floor($x / $cols_count) + ($x % $cols_count) * $rows;

View File

@@ -2,13 +2,12 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsFunction * @subpackage PluginsFunction
*/ */
/** /**
* Smarty {mailto} function plugin * Smarty {mailto} function plugin
*
* Type: function<br> * Type: function<br>
* Name: mailto<br> * Name: mailto<br>
* Date: May 21, 2002 * Date: May 21, 2002
@@ -39,22 +38,23 @@
* {mailto address="me@domain.com" extra='class="mailto"'} * {mailto address="me@domain.com" extra='class="mailto"'}
* </pre> * </pre>
* *
* @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto} * @link http://www.smarty.net/manual/en/language.function.mailto.php {mailto}
* (Smarty online manual) * (Smarty online manual)
* @version 1.2 * @version 1.2
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @author credits to Jason Sweat (added cc, bcc and subject functionality) * @author credits to Jason Sweat (added cc, bcc and subject functionality)
* @param array $params parameters *
* @param Smarty_Internal_Template $template template object * @param array $params parameters
*
* @return string * @return string
*/ */
function smarty_function_mailto($params, $template) function smarty_function_mailto($params)
{ {
static $_allowed_encoding = array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true); static $_allowed_encoding = array('javascript' => true, 'javascript_charcode' => true, 'hex' => true, 'none' => true);
$extra = ''; $extra = '';
if (empty($params['address'])) { if (empty($params['address'])) {
trigger_error("mailto: missing 'address' parameter",E_USER_WARNING); trigger_error("mailto: missing 'address' parameter", E_USER_WARNING);
return; return;
} else { } else {
@@ -72,8 +72,9 @@ function smarty_function_mailto($params, $template)
case 'cc': case 'cc':
case 'bcc': case 'bcc':
case 'followupto': case 'followupto':
if (!empty($value)) if (!empty($value)) {
$mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value)); $mail_parms[] = $var . '=' . str_replace($search, $replace, rawurlencode($value));
}
break; break;
case 'subject': case 'subject':
@@ -104,7 +105,7 @@ function smarty_function_mailto($params, $template)
$string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');'; $string = 'document.write(\'<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>\');';
$js_encode = ''; $js_encode = '';
for ($x = 0, $_length = strlen($string); $x < $_length; $x++) { for ($x = 0, $_length = strlen($string); $x < $_length; $x ++) {
$js_encode .= '%' . bin2hex($string[$x]); $js_encode .= '%' . bin2hex($string[$x]);
} }
@@ -112,7 +113,7 @@ function smarty_function_mailto($params, $template)
} elseif ($encode == 'javascript_charcode') { } elseif ($encode == 'javascript_charcode') {
$string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>'; $string = '<a href="mailto:' . $address . '" ' . $extra . '>' . $text . '</a>';
for ($x = 0, $y = strlen($string); $x < $y; $x++) { for ($x = 0, $y = strlen($string); $x < $y; $x ++) {
$ord[] = ord($string[$x]); $ord[] = ord($string[$x]);
} }
@@ -127,12 +128,12 @@ function smarty_function_mailto($params, $template)
} elseif ($encode == 'hex') { } elseif ($encode == 'hex') {
preg_match('!^(.*)(\?.*)$!', $address, $match); preg_match('!^(.*)(\?.*)$!', $address, $match);
if (!empty($match[2])) { if (!empty($match[2])) {
trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.",E_USER_WARNING); trigger_error("mailto: hex encoding does not work with extra attributes. Try javascript.", E_USER_WARNING);
return; return;
} }
$address_encode = ''; $address_encode = '';
for ($x = 0, $_length = strlen($address); $x < $_length; $x++) { for ($x = 0, $_length = strlen($address); $x < $_length; $x ++) {
if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[$x])) { if (preg_match('!\w!' . Smarty::$_UTF8_MODIFIER, $address[$x])) {
$address_encode .= '%' . bin2hex($address[$x]); $address_encode .= '%' . bin2hex($address[$x]);
} else { } else {
@@ -140,7 +141,7 @@ function smarty_function_mailto($params, $template)
} }
} }
$text_encode = ''; $text_encode = '';
for ($x = 0, $_length = strlen($text); $x < $_length; $x++) { for ($x = 0, $_length = strlen($text); $x < $_length; $x ++) {
$text_encode .= '&#x' . bin2hex($text[$x]) . ';'; $text_encode .= '&#x' . bin2hex($text[$x]) . ';';
} }

View File

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

View File

@@ -2,22 +2,21 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifier * @subpackage PluginsModifier
*/ */
/** /**
* Smarty capitalize modifier plugin * Smarty capitalize modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: capitalize<br> * Name: capitalize<br>
* Purpose: capitalize words in the string * Purpose: capitalize words in the string
*
* {@internal {$string|capitalize:true:true} is the fastest option for MBString enabled systems }} * {@internal {$string|capitalize:true:true} is the fastest option for MBString enabled systems }}
* *
* @param string $string string to capitalize * @param string $string string to capitalize
* @param boolean $uc_digits also capitalize "x123" to "X123" * @param boolean $uc_digits also capitalize "x123" to "X123"
* @param boolean $lc_rest capitalize first letters, lowercase all following letters "aAa" to "Aaa" * @param boolean $lc_rest capitalize first letters, lowercase all following letters "aAa" to "Aaa"
*
* @return string capitalized string * @return string capitalized string
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @author Rodney Rehm * @author Rodney Rehm
@@ -27,10 +26,10 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
if (Smarty::$_MBSTRING) { if (Smarty::$_MBSTRING) {
if ($lc_rest) { if ($lc_rest) {
// uppercase (including hyphenated words) // uppercase (including hyphenated words)
$upper_string = mb_convert_case( $string, MB_CASE_TITLE, Smarty::$_CHARSET ); $upper_string = mb_convert_case($string, MB_CASE_TITLE, Smarty::$_CHARSET);
} else { } else {
// uppercase word breaks // uppercase word breaks
$upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, create_function ('$matches', 'return stripslashes($matches[1]).mb_convert_case(stripslashes($matches[2]),MB_CASE_UPPER, "' . addslashes(Smarty::$_CHARSET) . '");'), $string); $upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert_cb', $string);
} }
// check uc_digits case // check uc_digits case
if (!$uc_digits) { if (!$uc_digits) {
@@ -40,8 +39,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
} }
} }
} }
$upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, create_function ('$matches', 'return stripslashes($matches[1]).mb_convert_case(stripslashes($matches[3]),MB_CASE_UPPER, "' . addslashes(Smarty::$_CHARSET) . '");'), $upper_string); $upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert2_cb', $upper_string);
return $upper_string; return $upper_string;
} }
@@ -50,7 +48,7 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
$string = strtolower($string); $string = strtolower($string);
} }
// uppercase (including hyphenated words) // uppercase (including hyphenated words)
$upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, create_function ('$matches', 'return stripslashes($matches[1]).ucfirst(stripslashes($matches[2]));'), $string); $upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst_cb', $string);
// check uc_digits case // check uc_digits case
if (!$uc_digits) { if (!$uc_digits) {
if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) { if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) {
@@ -59,7 +57,34 @@ function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = fals
} }
} }
} }
$upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, create_function ('$matches', 'return stripslashes($matches[1]).ucfirst(stripslashes($matches[3]));'), $upper_string); $upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst2_cb', $upper_string);
return $upper_string; return $upper_string;
} }
/*
*
* Bug: create_function() use exhausts memory when used in long loops
* Fix: use declared functions for callbacks instead of using create_function()
* Note: This can be fixed using anonymous functions instead, but that requires PHP >= 5.3
*
* @author Kyle Renfrow
*/
function smarty_mod_cap_mbconvert_cb($matches)
{
return stripslashes($matches[1]) . mb_convert_case(stripslashes($matches[2]), MB_CASE_UPPER, Smarty::$_CHARSET);
}
function smarty_mod_cap_mbconvert2_cb($matches)
{
return stripslashes($matches[1]) . mb_convert_case(stripslashes($matches[3]), MB_CASE_UPPER, Smarty::$_CHARSET);
}
function smarty_mod_cap_ucfirst_cb($matches)
{
return stripslashes($matches[1]) . ucfirst(stripslashes($matches[2]));
}
function smarty_mod_cap_ucfirst2_cb($matches)
{
return stripslashes($matches[1]) . ucfirst(stripslashes($matches[3]));
}

View File

@@ -2,13 +2,12 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifier * @subpackage PluginsModifier
*/ */
/** /**
* Smarty date_format modifier plugin * Smarty date_format modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: date_format<br> * Name: date_format<br>
* Purpose: format datestamps via strftime<br> * Purpose: format datestamps via strftime<br>
@@ -17,23 +16,25 @@
* - format: strftime format for output * - format: strftime format for output
* - default_date: default date if $string is empty * - default_date: default date if $string is empty
* *
* @link http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual) * @link http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string input date string * @param string $string input date string
* @param string $format strftime format for output * @param string $format strftime format for output
* @param string $default_date default date if $string is empty * @param string $default_date default date if $string is empty
* @param string $formatter either 'strftime' or 'auto' * @param string $formatter either 'strftime' or 'auto'
*
* @return string |void * @return string |void
* @uses smarty_make_timestamp() * @uses smarty_make_timestamp()
*/ */
function smarty_modifier_date_format($string, $format=null, $default_date='', $formatter='auto') function smarty_modifier_date_format($string, $format = null, $default_date = '', $formatter = 'auto')
{ {
if ($format === null) { if ($format === null) {
$format = Smarty::$_DATE_FORMAT; $format = Smarty::$_DATE_FORMAT;
} }
/** /**
* Include the {@link shared.make_timestamp.php} plugin * Include the {@link shared.make_timestamp.php} plugin
*/ */
require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php'); require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') { if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') {
$timestamp = smarty_make_timestamp($string); $timestamp = smarty_make_timestamp($string);
@@ -42,7 +43,7 @@ function smarty_modifier_date_format($string, $format=null, $default_date='', $f
} else { } else {
return; return;
} }
if ($formatter=='strftime'||($formatter=='auto'&&strpos($format,'%')!==false)) { if ($formatter == 'strftime' || ($formatter == 'auto' && strpos($format, '%') !== false)) {
if (DS == '\\') { if (DS == '\\') {
$_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T'); $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
$_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S'); $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');

View File

@@ -2,38 +2,39 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage Debug * @subpackage Debug
*/ */
/** /**
* Smarty debug_print_var modifier plugin * Smarty debug_print_var modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: debug_print_var<br> * Name: debug_print_var<br>
* Purpose: formats variable contents for display in the console * Purpose: formats variable contents for display in the console
* *
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @param array|object $var variable to be formatted *
* @param integer $depth maximum recursion depth if $var is an array * @param array|object $var variable to be formatted
* @param integer $length maximum string length if $var is a string * @param integer $depth maximum recursion depth if $var is an array
* @param integer $length maximum string length if $var is a string
*
* @return string * @return string
*/ */
function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40) function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
{ {
$_replace = array("\n" => '<i>\n</i>', $_replace = array("\n" => '<i>\n</i>',
"\r" => '<i>\r</i>', "\r" => '<i>\r</i>',
"\t" => '<i>\t</i>' "\t" => '<i>\t</i>'
); );
switch (gettype($var)) { switch (gettype($var)) {
case 'array' : case 'array' :
$results = '<b>Array (' . count($var) . ')</b>'; $results = '<b>Array (' . count($var) . ')</b>';
foreach ($var as $curr_key => $curr_val) { foreach ($var as $curr_key => $curr_val) {
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2) $results .= '<br>' . str_repeat('&nbsp;', $depth * 2)
. '<b>' . strtr($curr_key, $_replace) . '</b> =&gt; ' . '<b>' . strtr($curr_key, $_replace) . '</b> =&gt; '
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length); . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
$depth--; $depth --;
} }
break; break;
@@ -42,9 +43,9 @@ function smarty_modifier_debug_print_var ($var, $depth = 0, $length = 40)
$results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>'; $results = '<b>' . get_class($var) . ' Object (' . count($object_vars) . ')</b>';
foreach ($object_vars as $curr_key => $curr_val) { foreach ($object_vars as $curr_key => $curr_val) {
$results .= '<br>' . str_repeat('&nbsp;', $depth * 2) $results .= '<br>' . str_repeat('&nbsp;', $depth * 2)
. '<b> -&gt;' . strtr($curr_key, $_replace) . '</b> = ' . '<b> -&gt;' . strtr($curr_key, $_replace) . '</b> = '
. smarty_modifier_debug_print_var($curr_val, ++$depth, $length); . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
$depth--; $depth --;
} }
break; break;

View File

@@ -2,23 +2,24 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifier * @subpackage PluginsModifier
*/ */
/** /**
* Smarty escape modifier plugin * Smarty escape modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: escape<br> * Name: escape<br>
* Purpose: escape string for output * Purpose: escape string for output
* *
* @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual) * @link http://www.smarty.net/docs/en/language.modifier.escape
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string input string * @param string $string input string
* @param string $esc_type escape type * @param string $esc_type escape type
* @param string $char_set character set, used for htmlspecialchars() or htmlentities() * @param string $char_set character set, used for htmlspecialchars() or htmlentities()
* @param boolean $double_encode encode already encoded entitites again, used for htmlspecialchars() or htmlentities() * @param boolean $double_encode encode already encoded entitites again, used for htmlspecialchars() or htmlentities()
*
* @return string escaped input string * @return string escaped input string
*/ */
function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true) function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $double_encode = true)
@@ -105,7 +106,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
// Note that the UTF-8 encoded character ä will be represented as %c3%a4 // Note that the UTF-8 encoded character ä will be represented as %c3%a4
$return = ''; $return = '';
$_length = strlen($string); $_length = strlen($string);
for ($x = 0; $x < $_length; $x++) { for ($x = 0; $x < $_length; $x ++) {
$return .= '%' . bin2hex($string[$x]); $return .= '%' . bin2hex($string[$x]);
} }
@@ -124,7 +125,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
} }
// no MBString fallback // no MBString fallback
$_length = strlen($string); $_length = strlen($string);
for ($x = 0; $x < $_length; $x++) { for ($x = 0; $x < $_length; $x ++) {
$return .= '&#x' . bin2hex($string[$x]) . ';'; $return .= '&#x' . bin2hex($string[$x]) . ';';
} }
@@ -143,7 +144,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
} }
// no MBString fallback // no MBString fallback
$_length = strlen($string); $_length = strlen($string);
for ($x = 0; $x < $_length; $x++) { for ($x = 0; $x < $_length; $x ++) {
$return .= '&#' . ord($string[$x]) . ';'; $return .= '&#' . ord($string[$x]) . ';';
} }
@@ -179,7 +180,7 @@ function smarty_modifier_escape($string, $esc_type = 'html', $char_set = null, $
} }
$_length = strlen($string); $_length = strlen($string);
for ($_i = 0; $_i < $_length; $_i++) { for ($_i = 0; $_i < $_length; $_i ++) {
$_ord = ord(substr($string, $_i, 1)); $_ord = ord(substr($string, $_i, 1));
// non-standard char, escape it // non-standard char, escape it
if ($_ord >= 126) { if ($_ord >= 126) {

View File

@@ -2,23 +2,24 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifier * @subpackage PluginsModifier
*/ */
/** /**
* Smarty regex_replace modifier plugin * Smarty regex_replace modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: regex_replace<br> * Name: regex_replace<br>
* Purpose: regular expression search/replace * Purpose: regular expression search/replace
* *
* @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
* regex_replace (Smarty online manual) * regex_replace (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @param string $string input string *
* @param string|array $search regular expression(s) to search for * @param string $string input string
* @param string|array $replace string(s) that should be replaced * @param string|array $search regular expression(s) to search for
* @param string|array $replace string(s) that should be replaced
*
* @return string * @return string
*/ */
function smarty_modifier_regex_replace($string, $search, $replace) function smarty_modifier_regex_replace($string, $search, $replace)
@@ -36,6 +37,7 @@ function smarty_modifier_regex_replace($string, $search, $replace)
/** /**
* @param string $search string(s) that should be replaced * @param string $search string(s) that should be replaced
*
* @return string * @return string
* @ignore * @ignore
*/ */
@@ -43,12 +45,12 @@ function _smarty_regex_replace_check($search)
{ {
// null-byte injection detection // null-byte injection detection
// anything behind the first null-byte is ignored // anything behind the first null-byte is ignored
if (($pos = strpos($search,"\0")) !== false) { if (($pos = strpos($search, "\0")) !== false) {
$search = substr($search,0,$pos); $search = substr($search, 0, $pos);
} }
// remove eval-modifier from $search // remove eval-modifier from $search
if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) { if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
$search = substr($search, 0, -strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]); $search = substr($search, 0, - strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]);
} }
return $search; return $search;

View File

@@ -1,23 +1,25 @@
<?php <?php
/** /**
* Smarty plugin * Smarty plugin
* @package Smarty *
* @package Smarty
* @subpackage PluginsModifier * @subpackage PluginsModifier
*/ */
/** /**
* Smarty replace modifier plugin * Smarty replace modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: replace<br> * Name: replace<br>
* Purpose: simple search/replace * Purpose: simple search/replace
* *
* @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual) * @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @author Uwe Tews * @author Uwe Tews
*
* @param string $string input string * @param string $string input string
* @param string $search text to search for * @param string $search text to search for
* @param string $replace replacement text * @param string $replace replacement text
*
* @return string * @return string
*/ */
function smarty_modifier_replace($string, $search, $replace) function smarty_modifier_replace($string, $search, $replace)

View File

@@ -1,25 +1,27 @@
<?php <?php
/** /**
* Smarty plugin * Smarty plugin
* @package Smarty *
* @package Smarty
* @subpackage PluginsModifier * @subpackage PluginsModifier
*/ */
/** /**
* Smarty spacify modifier plugin * Smarty spacify modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: spacify<br> * Name: spacify<br>
* Purpose: add spaces between characters in a string * Purpose: add spaces between characters in a string
* *
* @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual) * @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string input string * @param string $string input string
* @param string $spacify_char string to insert between characters. * @param string $spacify_char string to insert between characters.
*
* @return string * @return string
*/ */
function smarty_modifier_spacify($string, $spacify_char = ' ') function smarty_modifier_spacify($string, $spacify_char = ' ')
{ {
// well… what about charsets besides latin and UTF-8? // well… what about charsets besides latin and UTF-8?
return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, -1, PREG_SPLIT_NO_EMPTY)); return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, - 1, PREG_SPLIT_NO_EMPTY));
} }

View File

@@ -2,32 +2,34 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifier * @subpackage PluginsModifier
*/ */
/** /**
* Smarty truncate modifier plugin * Smarty truncate modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: truncate<br> * Name: truncate<br>
* Purpose: Truncate a string to a certain length if necessary, * Purpose: Truncate a string to a certain length if necessary,
* optionally splitting in the middle of a word, and * optionally splitting in the middle of a word, and
* appending the $etc string or inserting $etc into the middle. * appending the $etc string or inserting $etc into the middle.
* *
* @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual) * @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string input string * @param string $string input string
* @param integer $length length of truncated text * @param integer $length length of truncated text
* @param string $etc end string * @param string $etc end string
* @param boolean $break_words truncate at word boundary * @param boolean $break_words truncate at word boundary
* @param boolean $middle truncate in the middle of text * @param boolean $middle truncate in the middle of text
*
* @return string truncated string * @return string truncated string
*/ */
function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false) function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false)
{ {
if ($length == 0) if ($length == 0) {
return ''; return '';
}
if (Smarty::$_MBSTRING) { if (Smarty::$_MBSTRING) {
if (mb_strlen($string, Smarty::$_CHARSET) > $length) { if (mb_strlen($string, Smarty::$_CHARSET) > $length) {

View File

@@ -2,13 +2,12 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty cat modifier plugin * Smarty cat modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: cat<br> * Name: cat<br>
* Date: Feb 24, 2003<br> * Date: Feb 24, 2003<br>
@@ -16,13 +15,15 @@
* Input: string to catenate<br> * Input: string to catenate<br>
* Example: {$var|cat:"foo"} * Example: {$var|cat:"foo"}
* *
* @link http://smarty.php.net/manual/en/language.modifier.cat.php cat * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
* (Smarty online manual) * (Smarty online manual)
* @author Uwe Tews * @author Uwe Tews
*
* @param array $params parameters * @param array $params parameters
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_cat($params, $compiler) function smarty_modifiercompiler_cat($params)
{ {
return '('.implode(').(', $params).')'; return '(' . implode(').(', $params) . ')';
} }

View File

@@ -2,23 +2,24 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty count_characters modifier plugin * Smarty count_characters modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: count_characteres<br> * Name: count_characteres<br>
* Purpose: count the number of characters in a text * Purpose: count the number of characters in a text
* *
* @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual) * @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual)
* @author Uwe Tews * @author Uwe Tews
*
* @param array $params parameters * @param array $params parameters
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_count_characters($params, $compiler) function smarty_modifiercompiler_count_characters($params)
{ {
if (!isset($params[1]) || $params[1] != 'true') { if (!isset($params[1]) || $params[1] != 'true') {
return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[0] . ', $tmp)'; return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[0] . ', $tmp)';

View File

@@ -2,24 +2,25 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty count_paragraphs modifier plugin * Smarty count_paragraphs modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: count_paragraphs<br> * Name: count_paragraphs<br>
* Purpose: count the number of paragraphs in a text * Purpose: count the number of paragraphs in a text
* *
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
* count_paragraphs (Smarty online manual) * count_paragraphs (Smarty online manual)
* @author Uwe Tews * @author Uwe Tews
*
* @param array $params parameters * @param array $params parameters
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_count_paragraphs($params, $compiler) function smarty_modifiercompiler_count_paragraphs($params)
{ {
// count \r or \n characters // count \r or \n characters
return '(preg_match_all(\'#[\r\n]+#\', ' . $params[0] . ', $tmp)+1)'; return '(preg_match_all(\'#[\r\n]+#\', ' . $params[0] . ', $tmp)+1)';

View File

@@ -2,24 +2,25 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty count_sentences modifier plugin * Smarty count_sentences modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: count_sentences * Name: count_sentences
* Purpose: count the number of sentences in a text * Purpose: count the number of sentences in a text
* *
* @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
* count_sentences (Smarty online manual) * count_sentences (Smarty online manual)
* @author Uwe Tews * @author Uwe Tews
*
* @param array $params parameters * @param array $params parameters
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_count_sentences($params, $compiler) function smarty_modifiercompiler_count_sentences($params)
{ {
// find periods, question marks, exclamation marks with a word before but not after. // find periods, question marks, exclamation marks with a word before but not after.
return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)'; return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)';

View File

@@ -2,23 +2,24 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty count_words modifier plugin * Smarty count_words modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: count_words<br> * Name: count_words<br>
* Purpose: count the number of words in a text * Purpose: count the number of words in a text
* *
* @link http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual) * @link http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
* @author Uwe Tews * @author Uwe Tews
*
* @param array $params parameters * @param array $params parameters
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_count_words($params, $compiler) function smarty_modifiercompiler_count_words($params)
{ {
if (Smarty::$_MBSTRING) { if (Smarty::$_MBSTRING) {
// return 'preg_match_all(\'#[\w\pL]+#' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)'; // return 'preg_match_all(\'#[\w\pL]+#' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';

View File

@@ -2,23 +2,24 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty default modifier plugin * Smarty default modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: default<br> * Name: default<br>
* Purpose: designate default value for empty variables * Purpose: designate default value for empty variables
* *
* @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual) * @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
* @author Uwe Tews * @author Uwe Tews
*
* @param array $params parameters * @param array $params parameters
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_default ($params, $compiler) function smarty_modifiercompiler_default($params)
{ {
$output = $params[0]; $output = $params[0];
if (!isset($params[1])) { if (!isset($params[1])) {

View File

@@ -2,25 +2,27 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* @ignore * @ignore
*/ */
require_once( SMARTY_PLUGINS_DIR .'shared.literal_compiler_param.php' ); require_once(SMARTY_PLUGINS_DIR . 'shared.literal_compiler_param.php');
/** /**
* Smarty escape modifier plugin * Smarty escape modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: escape<br> * Name: escape<br>
* Purpose: escape string for output * Purpose: escape string for output
* *
* @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual) * @link http://www.smarty.net/docsv2/en/language.modifier.escape count_characters (Smarty online manual)
* @author Rodney Rehm * @author Rodney Rehm
*
* @param array $params parameters * @param array $params parameters
* @param $compiler
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_escape($params, $compiler) function smarty_modifiercompiler_escape($params, $compiler)
@@ -43,13 +45,13 @@ function smarty_modifiercompiler_escape($params, $compiler)
case 'html': case 'html':
if ($_double_encode) { if ($_double_encode) {
return 'htmlspecialchars(' return 'htmlspecialchars('
. $params[0] .', ENT_QUOTES, ' . $params[0] . ', ENT_QUOTES, '
. var_export($char_set, true) . ', ' . var_export($char_set, true) . ', '
. var_export($double_encode, true) . ')'; . var_export($double_encode, true) . ')';
} elseif ($double_encode) { } elseif ($double_encode) {
return 'htmlspecialchars(' return 'htmlspecialchars('
. $params[0] .', ENT_QUOTES, ' . $params[0] . ', ENT_QUOTES, '
. var_export($char_set, true) . ')'; . var_export($char_set, true) . ')';
} else { } else {
// fall back to modifier.escape.php // fall back to modifier.escape.php
} }
@@ -59,18 +61,18 @@ function smarty_modifiercompiler_escape($params, $compiler)
if ($_double_encode) { if ($_double_encode) {
// php >=5.2.3 - go native // php >=5.2.3 - go native
return 'mb_convert_encoding(htmlspecialchars(' return 'mb_convert_encoding(htmlspecialchars('
. $params[0] .', ENT_QUOTES, ' . $params[0] . ', ENT_QUOTES, '
. var_export($char_set, true) . ', ' . var_export($char_set, true) . ', '
. var_export($double_encode, true) . var_export($double_encode, true)
. '), "HTML-ENTITIES", ' . '), "HTML-ENTITIES", '
. var_export($char_set, true) . ')'; . var_export($char_set, true) . ')';
} elseif ($double_encode) { } elseif ($double_encode) {
// php <5.2.3 - only handle double encoding // php <5.2.3 - only handle double encoding
return 'mb_convert_encoding(htmlspecialchars(' return 'mb_convert_encoding(htmlspecialchars('
. $params[0] .', ENT_QUOTES, ' . $params[0] . ', ENT_QUOTES, '
. var_export($char_set, true) . var_export($char_set, true)
. '), "HTML-ENTITIES", ' . '), "HTML-ENTITIES", '
. var_export($char_set, true) . ')'; . var_export($char_set, true) . ')';
} else { } else {
// fall back to modifier.escape.php // fall back to modifier.escape.php
} }
@@ -80,14 +82,14 @@ function smarty_modifiercompiler_escape($params, $compiler)
if ($_double_encode) { if ($_double_encode) {
// php >=5.2.3 - go native // php >=5.2.3 - go native
return 'htmlentities(' return 'htmlentities('
. $params[0] .', ENT_QUOTES, ' . $params[0] . ', ENT_QUOTES, '
. var_export($char_set, true) . ', ' . var_export($char_set, true) . ', '
. var_export($double_encode, true) . ')'; . var_export($double_encode, true) . ')';
} elseif ($double_encode) { } elseif ($double_encode) {
// php <5.2.3 - only handle double encoding // php <5.2.3 - only handle double encoding
return 'htmlentities(' return 'htmlentities('
. $params[0] .', ENT_QUOTES, ' . $params[0] . ', ENT_QUOTES, '
. var_export($char_set, true) . ')'; . var_export($char_set, true) . ')';
} else { } else {
// fall back to modifier.escape.php // fall back to modifier.escape.php
} }
@@ -105,20 +107,20 @@ function smarty_modifiercompiler_escape($params, $compiler)
case 'javascript': case 'javascript':
// escape quotes and backslashes, newlines, etc. // escape quotes and backslashes, newlines, etc.
return 'strtr(' . $params[0] . ', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))'; return 'strtr(' . $params[0] . ', array("\\\\" => "\\\\\\\\", "\'" => "\\\\\'", "\"" => "\\\\\"", "\\r" => "\\\\r", "\\n" => "\\\n", "</" => "<\/" ))';
} }
} catch (SmartyException $e) { }
catch (SmartyException $e) {
// pass through to regular plugin fallback // pass through to regular plugin fallback
} }
// could not optimize |escape call, so fallback to regular plugin // could not optimize |escape call, so fallback to regular plugin
if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) { if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
$compiler->template->required_plugins['nocache']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php'; $compiler->template->required_plugins['nocache']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'modifier.escape.php';
$compiler->template->required_plugins['nocache']['escape']['modifier']['function'] = 'smarty_modifier_escape'; $compiler->template->required_plugins['nocache']['escape']['modifier']['function'] = 'smarty_modifier_escape';
} else { } else {
$compiler->template->required_plugins['compiled']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR .'modifier.escape.php'; $compiler->template->required_plugins['compiled']['escape']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'modifier.escape.php';
$compiler->template->required_plugins['compiled']['escape']['modifier']['function'] = 'smarty_modifier_escape'; $compiler->template->required_plugins['compiled']['escape']['modifier']['function'] = 'smarty_modifier_escape';
} }
return 'smarty_modifier_escape(' . join( ', ', $params ) . ')'; return 'smarty_modifier_escape(' . join(', ', $params) . ')';
} }

View File

@@ -2,22 +2,23 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty from_charset modifier plugin * Smarty from_charset modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: from_charset<br> * Name: from_charset<br>
* Purpose: convert character encoding from $charset to internal encoding * Purpose: convert character encoding from $charset to internal encoding
* *
* @author Rodney Rehm * @author Rodney Rehm
*
* @param array $params parameters * @param array $params parameters
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_from_charset($params, $compiler) function smarty_modifiercompiler_from_charset($params)
{ {
if (!Smarty::$_MBSTRING) { if (!Smarty::$_MBSTRING) {
// FIXME: (rodneyrehm) shouldn't this throw an error? // FIXME: (rodneyrehm) shouldn't this throw an error?

View File

@@ -1,24 +1,26 @@
<?php <?php
/** /**
* Smarty plugin * Smarty plugin
* @package Smarty *
* @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty indent modifier plugin * Smarty indent modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: indent<br> * Name: indent<br>
* Purpose: indent lines of text * Purpose: indent lines of text
* *
* @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual) * @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
* @author Uwe Tews * @author Uwe Tews
*
* @param array $params parameters * @param array $params parameters
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_indent($params, $compiler) function smarty_modifiercompiler_indent($params)
{ {
if (!isset($params[1])) { if (!isset($params[1])) {
$params[1] = 4; $params[1] = 4;

View File

@@ -1,28 +1,30 @@
<?php <?php
/** /**
* Smarty plugin * Smarty plugin
* @package Smarty *
* @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty lower modifier plugin * Smarty lower modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: lower<br> * Name: lower<br>
* Purpose: convert string to lowercase * Purpose: convert string to lowercase
* *
* @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual) * @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @author Uwe Tews * @author Uwe Tews
*
* @param array $params parameters * @param array $params parameters
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_lower($params, $compiler) function smarty_modifiercompiler_lower($params)
{ {
if (Smarty::$_MBSTRING) { if (Smarty::$_MBSTRING) {
return 'mb_strtolower(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')' ; return 'mb_strtolower(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
} }
// no MBString fallback // no MBString fallback
return 'strtolower(' . $params[0] . ')'; return 'strtolower(' . $params[0] . ')';

View File

@@ -2,22 +2,20 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty noprint modifier plugin * Smarty noprint modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: noprint<br> * Name: noprint<br>
* Purpose: return an empty string * Purpose: return an empty string
* *
* @author Uwe Tews * @author Uwe Tews
* @param array $params parameters
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_noprint($params, $compiler) function smarty_modifiercompiler_noprint()
{ {
return "''"; return "''";
} }

View File

@@ -2,23 +2,24 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty string_format modifier plugin * Smarty string_format modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: string_format<br> * Name: string_format<br>
* Purpose: format strings via sprintf * Purpose: format strings via sprintf
* *
* @link http://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual) * @link http://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
* @author Uwe Tews * @author Uwe Tews
*
* @param array $params parameters * @param array $params parameters
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_string_format($params, $compiler) function smarty_modifiercompiler_string_format($params)
{ {
return 'sprintf(' . $params[1] . ',' . $params[0] . ')'; return 'sprintf(' . $params[1] . ',' . $params[0] . ')';
} }

View File

@@ -2,13 +2,12 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty strip modifier plugin * Smarty strip modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: strip<br> * Name: strip<br>
* Purpose: Replace all repeated spaces, newlines, tabs * Purpose: Replace all repeated spaces, newlines, tabs
@@ -16,13 +15,15 @@
* Example: {$var|strip} {$var|strip:"&nbsp;"}<br> * Example: {$var|strip} {$var|strip:"&nbsp;"}<br>
* Date: September 25th, 2002 * Date: September 25th, 2002
* *
* @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual) * @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
* @author Uwe Tews * @author Uwe Tews
*
* @param array $params parameters * @param array $params parameters
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_strip($params, $compiler) function smarty_modifiercompiler_strip($params)
{ {
if (!isset($params[1])) { if (!isset($params[1])) {
$params[1] = "' '"; $params[1] = "' '";

View File

@@ -2,26 +2,27 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty strip_tags modifier plugin * Smarty strip_tags modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: strip_tags<br> * Name: strip_tags<br>
* Purpose: strip html tags from text * Purpose: strip html tags from text
* *
* @link http://www.smarty.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual) * @link http://www.smarty.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual)
* @author Uwe Tews * @author Uwe Tews
*
* @param array $params parameters * @param array $params parameters
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_strip_tags($params, $compiler) function smarty_modifiercompiler_strip_tags($params)
{ {
if (!isset($params[1]) || $params[1] === true || trim($params[1],'"') == 'true') { if (!isset($params[1]) || $params[1] === true || trim($params[1], '"') == 'true') {
return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})"; return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})";
} else { } else {
return 'strip_tags(' . $params[0] . ')'; return 'strip_tags(' . $params[0] . ')';
} }

View File

@@ -2,22 +2,23 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty to_charset modifier plugin * Smarty to_charset modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: to_charset<br> * Name: to_charset<br>
* Purpose: convert character encoding from internal encoding to $charset * Purpose: convert character encoding from internal encoding to $charset
* *
* @author Rodney Rehm * @author Rodney Rehm
*
* @param array $params parameters * @param array $params parameters
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_to_charset($params, $compiler) function smarty_modifiercompiler_to_charset($params)
{ {
if (!Smarty::$_MBSTRING) { if (!Smarty::$_MBSTRING) {
// FIXME: (rodneyrehm) shouldn't this throw an error? // FIXME: (rodneyrehm) shouldn't this throw an error?

View File

@@ -2,22 +2,23 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty unescape modifier plugin * Smarty unescape modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: unescape<br> * Name: unescape<br>
* Purpose: unescape html entities * Purpose: unescape html entities
* *
* @author Rodney Rehm * @author Rodney Rehm
*
* @param array $params parameters * @param array $params parameters
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_unescape($params, $compiler) function smarty_modifiercompiler_unescape($params)
{ {
if (!isset($params[1])) { if (!isset($params[1])) {
$params[1] = 'html'; $params[1] = 'html';

View File

@@ -2,26 +2,27 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty upper modifier plugin * Smarty upper modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: lower<br> * Name: lower<br>
* Purpose: convert string to uppercase * Purpose: convert string to uppercase
* *
* @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual) * @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
* @author Uwe Tews * @author Uwe Tews
*
* @param array $params parameters * @param array $params parameters
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_upper($params, $compiler) function smarty_modifiercompiler_upper($params)
{ {
if (Smarty::$_MBSTRING) { if (Smarty::$_MBSTRING) {
return 'mb_strtoupper(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')' ; return 'mb_strtoupper(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
} }
// no MBString fallback // no MBString fallback
return 'strtoupper(' . $params[0] . ')'; return 'strtoupper(' . $params[0] . ')';

View File

@@ -2,20 +2,22 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsModifierCompiler * @subpackage PluginsModifierCompiler
*/ */
/** /**
* Smarty wordwrap modifier plugin * Smarty wordwrap modifier plugin
*
* Type: modifier<br> * Type: modifier<br>
* Name: wordwrap<br> * Name: wordwrap<br>
* Purpose: wrap a string of text at a given length * Purpose: wrap a string of text at a given length
* *
* @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual) * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
* @author Uwe Tews * @author Uwe Tews
*
* @param array $params parameters * @param array $params parameters
* @param $compiler
*
* @return string with compiled code * @return string with compiled code
*/ */
function smarty_modifiercompiler_wordwrap($params, $compiler) function smarty_modifiercompiler_wordwrap($params, $compiler)
@@ -31,11 +33,11 @@ function smarty_modifiercompiler_wordwrap($params, $compiler)
} }
$function = 'wordwrap'; $function = 'wordwrap';
if (Smarty::$_MBSTRING) { if (Smarty::$_MBSTRING) {
if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) { if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
$compiler->template->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR .'shared.mb_wordwrap.php'; $compiler->template->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php';
$compiler->template->required_plugins['nocache']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap'; $compiler->template->required_plugins['nocache']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
} else { } else {
$compiler->template->required_plugins['compiled']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR .'shared.mb_wordwrap.php'; $compiler->template->required_plugins['compiled']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php';
$compiler->template->required_plugins['compiled']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap'; $compiler->template->required_plugins['compiled']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
} }
$function = 'smarty_mb_wordwrap'; $function = 'smarty_mb_wordwrap';

View File

@@ -2,22 +2,22 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsFilter * @subpackage PluginsFilter
*/ */
/** /**
* Smarty trimwhitespace outputfilter plugin * Smarty trimwhitespace outputfilter plugin
*
* Trim unnecessary whitespace from HTML markup. * Trim unnecessary whitespace from HTML markup.
* *
* @author Rodney Rehm * @author Rodney Rehm
* @param string $source input string *
* @param Smarty_Internal_Template $smarty Smarty object * @param string $source input string
*
* @return string filtered output * @return string filtered output
* @todo substr_replace() is not overloaded by mbstring.func_overload - so this function might fail! * @todo substr_replace() is not overloaded by mbstring.func_overload - so this function might fail!
*/ */
function smarty_outputfilter_trimwhitespace($source, Smarty_Internal_Template $smarty) function smarty_outputfilter_trimwhitespace($source)
{ {
$store = array(); $store = array();
$_store = 0; $_store = 0;
@@ -35,13 +35,13 @@ function smarty_outputfilter_trimwhitespace($source, Smarty_Internal_Template $s
$source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length); $source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length);
$_offset += $_length - strlen($replace); $_offset += $_length - strlen($replace);
$_store++; $_store ++;
} }
} }
// Strip all HTML-Comments // Strip all HTML-Comments
// yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124 // yes, even the ones in <script> - see http://stackoverflow.com/a/808850/515124
$source = preg_replace( '#<!--.*?-->#ms', '', $source ); $source = preg_replace('#<!--.*?-->#ms', '', $source);
// capture html elements not to be messed with // capture html elements not to be messed with
$_offset = 0; $_offset = 0;
@@ -53,23 +53,23 @@ function smarty_outputfilter_trimwhitespace($source, Smarty_Internal_Template $s
$source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length); $source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length);
$_offset += $_length - strlen($replace); $_offset += $_length - strlen($replace);
$_store++; $_store ++;
} }
} }
$expressions = array( $expressions = array(
// replace multiple spaces between tags by a single space // replace multiple spaces between tags by a single space
// can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements // can't remove them entirely, becaue that might break poorly implemented CSS display:inline-block elements
'#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2', '#(:SMARTY@!@|>)\s+(?=@!@SMARTY:|<)#s' => '\1 \2',
// remove spaces between attributes (but not in attribute values!) // remove spaces between attributes (but not in attribute values!)
'#(([a-z0-9]\s*=\s*(["\'])[^\3]*?\3)|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \4', '#(([a-z0-9]\s*=\s*(["\'])[^\3]*?\3)|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \4',
// note: for some very weird reason trim() seems to remove spaces inside attributes. // note: for some very weird reason trim() seems to remove spaces inside attributes.
// maybe a \0 byte or something is interfering? // maybe a \0 byte or something is interfering?
'#^\s+<#Ss' => '<', '#^\s+<#Ss' => '<',
'#>\s+$#Ss' => '>', '#>\s+$#Ss' => '>',
); );
$source = preg_replace( array_keys($expressions), array_values($expressions), $source ); $source = preg_replace(array_keys($expressions), array_values($expressions), $source);
// note: for some very weird reason trim() seems to remove spaces inside attributes. // note: for some very weird reason trim() seems to remove spaces inside attributes.
// maybe a \0 byte or something is interfering? // maybe a \0 byte or something is interfering?
// $source = trim( $source ); // $source = trim( $source );
@@ -82,7 +82,7 @@ function smarty_outputfilter_trimwhitespace($source, Smarty_Internal_Template $s
$source = substr_replace($source, $replace, $match[0][1] + $_offset, $_length); $source = substr_replace($source, $replace, $match[0][1] + $_offset, $_length);
$_offset += strlen($replace) - $_length; $_offset += strlen($replace) - $_length;
$_store++; $_store ++;
} }
} }

View File

@@ -2,20 +2,21 @@
/** /**
* Smarty shared plugin * Smarty shared plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsShared * @subpackage PluginsShared
*/ */
if (version_compare(PHP_VERSION, '5.2.3', '>=')) { if (version_compare(PHP_VERSION, '5.2.3', '>=')) {
/** /**
* escape_special_chars common function * escape_special_chars common function
*
* Function: smarty_function_escape_special_chars<br> * Function: smarty_function_escape_special_chars<br>
* Purpose: used by other smarty functions to escape * Purpose: used by other smarty functions to escape
* special chars except for already escaped ones * special chars except for already escaped ones
* *
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string text that should by escaped * @param string $string text that should by escaped
*
* @return string * @return string
*/ */
function smarty_function_escape_special_chars($string) function smarty_function_escape_special_chars($string)
@@ -29,13 +30,14 @@ if (version_compare(PHP_VERSION, '5.2.3', '>=')) {
} else { } else {
/** /**
* escape_special_chars common function * escape_special_chars common function
*
* Function: smarty_function_escape_special_chars<br> * Function: smarty_function_escape_special_chars<br>
* Purpose: used by other smarty functions to escape * Purpose: used by other smarty functions to escape
* special chars except for already escaped ones * special chars except for already escaped ones
* *
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
*
* @param string $string text that should by escaped * @param string $string text that should by escaped
*
* @return string * @return string
*/ */
function smarty_function_escape_special_chars($string) function smarty_function_escape_special_chars($string)

View File

@@ -2,7 +2,7 @@
/** /**
* Smarty plugin * Smarty plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsShared * @subpackage PluginsShared
*/ */
@@ -12,18 +12,19 @@
* @param array $params parameter array as given to the compiler function * @param array $params parameter array as given to the compiler function
* @param integer $index array index of the parameter to convert * @param integer $index array index of the parameter to convert
* @param mixed $default value to be returned if the parameter is not present * @param mixed $default value to be returned if the parameter is not present
*
* @return mixed evaluated value of parameter or $default * @return mixed evaluated value of parameter or $default
* @throws SmartyException if parameter is not a literal (but an expression, variable, ) * @throws SmartyException if parameter is not a literal (but an expression, variable, )
* @author Rodney Rehm * @author Rodney Rehm
*/ */
function smarty_literal_compiler_param($params, $index, $default=null) function smarty_literal_compiler_param($params, $index, $default = null)
{ {
// not set, go default // not set, go default
if (!isset($params[$index])) { if (!isset($params[$index])) {
return $default; return $default;
} }
// test if param is a literal // test if param is a literal
if (!preg_match('/^([\'"]?)[a-zA-Z0-9]+(\\1)$/', $params[$index])) { if (!preg_match('/^([\'"]?)[a-zA-Z0-9-]+(\\1)$/', $params[$index])) {
throw new SmartyException('$param[' . $index . '] is not a literal and is thus not evaluatable at compile time'); throw new SmartyException('$param[' . $index . '] is not a literal and is thus not evaluatable at compile time');
} }

View File

@@ -2,7 +2,7 @@
/** /**
* Smarty shared plugin * Smarty shared plugin
* *
* @package Smarty * @package Smarty
* @subpackage PluginsShared * @subpackage PluginsShared
*/ */
@@ -11,7 +11,9 @@
* Purpose: used by other smarty functions to make a timestamp from a string. * Purpose: used by other smarty functions to make a timestamp from a string.
* *
* @author Monte Ohrt <monte at ohrt dot com> * @author Monte Ohrt <monte at ohrt dot com>
* @param DateTime|int|string $string date object, timestamp or string that can be converted using strtotime() *
* @param DateTime|int|string $string date object, timestamp or string that can be converted using strtotime()
*
* @return int * @return int
*/ */
function smarty_make_timestamp($string) function smarty_make_timestamp($string)
@@ -23,15 +25,15 @@ function smarty_make_timestamp($string)
return $string->getTimestamp(); return $string->getTimestamp();
} elseif (strlen($string) == 14 && ctype_digit($string)) { } elseif (strlen($string) == 14 && ctype_digit($string)) {
// it is mysql timestamp format of YYYYMMDDHHMMSS? // it is mysql timestamp format of YYYYMMDDHHMMSS?
return mktime(substr($string, 8, 2),substr($string, 10, 2),substr($string, 12, 2), return 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)); substr($string, 4, 2), substr($string, 6, 2), substr($string, 0, 4));
} elseif (is_numeric($string)) { } elseif (is_numeric($string)) {
// it is a numeric string, we handle it as timestamp // it is a numeric string, we handle it as timestamp
return (int) $string; return (int) $string;
} else { } else {
// strtotime should handle it // strtotime should handle it
$time = strtotime($string); $time = strtotime($string);
if ($time == -1 || $time === false) { if ($time == - 1 || $time === false) {
// strtotime() was not able to parse $string, use "now": // strtotime() was not able to parse $string, use "now":
return time(); return time();
} }

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