├── LICENSE
├── README.md
├── bootstrap
├── css
│ ├── bootstrap.css
│ └── bootstrap.min.css
├── fonts
│ ├── FontAwesome.otf
│ ├── fontawesome-webfont.eot
│ ├── fontawesome-webfont.svg
│ ├── fontawesome-webfont.ttf
│ ├── fontawesome-webfont.woff
│ ├── glyphicons-halflings-regular.eot
│ ├── glyphicons-halflings-regular.svg
│ ├── glyphicons-halflings-regular.ttf
│ └── glyphicons-halflings-regular.woff
├── img
│ ├── alpha.png
│ ├── hue.png
│ ├── prettyCheckable-blue.png
│ ├── prettyCheckable-gray.png
│ ├── prettyCheckable-green.png
│ ├── prettyCheckable-red.png
│ ├── prettyCheckable-yellow.png
│ └── saturation.png
├── index.php
└── js
│ ├── bootstrap.js
│ └── bootstrap.min.js
├── config.php
├── cron.php
├── db
├── db-acl.json
├── db-activitylog.json
├── db-backupjobs.json
├── db-backuplog.json
├── db-backups.json
├── db-backupservers.json
├── db-users.json
└── index.php
├── htaccess.txt
├── includes
├── backupjobs.php
├── backuprestore.php
├── backupservers.php
├── home.php
├── index.php
├── login.php
├── useracl.php
├── users.php
└── viewbackups.php
├── index.php
├── libs
├── cpanelxmlapi-php
│ └── xmlapi.php
├── googleauthenticator
│ └── GoogleAuthenticator.php
├── index.php
├── php-gpg-master
│ ├── .gitignore
│ ├── .project
│ ├── GPG.php
│ └── GPG
│ │ ├── AES.php
│ │ ├── Cipher.php
│ │ ├── Expanded_Key.php
│ │ ├── Public_Key.php
│ │ ├── Utility.php
│ │ └── globals.php
├── phpmailer
│ ├── PHPMailerAutoload.php
│ ├── class.phpmailer.php
│ ├── class.pop3.php
│ └── class.smtp.php
├── phpseclib
│ ├── Crypt
│ │ ├── AES.php
│ │ ├── Base.php
│ │ ├── Blowfish.php
│ │ ├── DES.php
│ │ ├── Hash.php
│ │ ├── RC2.php
│ │ ├── RC4.php
│ │ ├── RSA.php
│ │ ├── Random.php
│ │ ├── Rijndael.php
│ │ ├── TripleDES.php
│ │ └── Twofish.php
│ ├── File
│ │ ├── ANSI.php
│ │ ├── ASN1.php
│ │ └── X509.php
│ ├── Math
│ │ └── BigInteger.php
│ ├── Net
│ │ ├── SCP.php
│ │ ├── SFTP.php
│ │ ├── SFTP
│ │ │ └── Stream.php
│ │ ├── SSH1.php
│ │ └── SSH2.php
│ ├── System
│ │ ├── SSH
│ │ │ └── Agent.php
│ │ └── SSH_Agent.php
│ └── openssl.cnf
├── simplehtml
│ └── simple_html_dom.php
└── smarty
│ ├── Smarty.class.php
│ ├── SmartyBC.class.php
│ ├── debug.tpl
│ ├── plugins
│ ├── block.textformat.php
│ ├── function.counter.php
│ ├── function.cycle.php
│ ├── function.fetch.php
│ ├── function.html_checkboxes.php
│ ├── function.html_image.php
│ ├── function.html_options.php
│ ├── function.html_radios.php
│ ├── function.html_select_date.php
│ ├── function.html_select_time.php
│ ├── function.html_table.php
│ ├── function.mailto.php
│ ├── function.math.php
│ ├── modifier.capitalize.php
│ ├── modifier.date_format.php
│ ├── modifier.debug_print_var.php
│ ├── modifier.escape.php
│ ├── modifier.regex_replace.php
│ ├── modifier.replace.php
│ ├── modifier.spacify.php
│ ├── modifier.truncate.php
│ ├── modifiercompiler.cat.php
│ ├── modifiercompiler.count_characters.php
│ ├── modifiercompiler.count_paragraphs.php
│ ├── modifiercompiler.count_sentences.php
│ ├── modifiercompiler.count_words.php
│ ├── modifiercompiler.default.php
│ ├── modifiercompiler.escape.php
│ ├── modifiercompiler.from_charset.php
│ ├── modifiercompiler.indent.php
│ ├── modifiercompiler.lower.php
│ ├── modifiercompiler.noprint.php
│ ├── modifiercompiler.string_format.php
│ ├── modifiercompiler.strip.php
│ ├── modifiercompiler.strip_tags.php
│ ├── modifiercompiler.to_charset.php
│ ├── modifiercompiler.unescape.php
│ ├── modifiercompiler.upper.php
│ ├── modifiercompiler.wordwrap.php
│ ├── outputfilter.trimwhitespace.php
│ ├── shared.escape_special_chars.php
│ ├── shared.literal_compiler_param.php
│ ├── shared.make_timestamp.php
│ ├── shared.mb_str_replace.php
│ ├── shared.mb_unicode.php
│ ├── shared.mb_wordwrap.php
│ └── variablefilter.htmlspecialchars.php
│ └── sysplugins
│ ├── smarty_cacheresource.php
│ ├── smarty_cacheresource_custom.php
│ ├── smarty_cacheresource_keyvaluestore.php
│ ├── smarty_config_source.php
│ ├── smarty_internal_cacheresource_file.php
│ ├── smarty_internal_compile_append.php
│ ├── smarty_internal_compile_assign.php
│ ├── smarty_internal_compile_block.php
│ ├── smarty_internal_compile_break.php
│ ├── smarty_internal_compile_call.php
│ ├── smarty_internal_compile_capture.php
│ ├── smarty_internal_compile_config_load.php
│ ├── smarty_internal_compile_continue.php
│ ├── smarty_internal_compile_debug.php
│ ├── smarty_internal_compile_eval.php
│ ├── smarty_internal_compile_extends.php
│ ├── smarty_internal_compile_for.php
│ ├── smarty_internal_compile_foreach.php
│ ├── smarty_internal_compile_function.php
│ ├── smarty_internal_compile_if.php
│ ├── smarty_internal_compile_include.php
│ ├── smarty_internal_compile_include_php.php
│ ├── smarty_internal_compile_insert.php
│ ├── smarty_internal_compile_ldelim.php
│ ├── smarty_internal_compile_nocache.php
│ ├── smarty_internal_compile_private_block_plugin.php
│ ├── smarty_internal_compile_private_function_plugin.php
│ ├── smarty_internal_compile_private_modifier.php
│ ├── smarty_internal_compile_private_object_block_function.php
│ ├── smarty_internal_compile_private_object_function.php
│ ├── smarty_internal_compile_private_print_expression.php
│ ├── smarty_internal_compile_private_registered_block.php
│ ├── smarty_internal_compile_private_registered_function.php
│ ├── smarty_internal_compile_private_special_variable.php
│ ├── smarty_internal_compile_rdelim.php
│ ├── smarty_internal_compile_section.php
│ ├── smarty_internal_compile_setfilter.php
│ ├── smarty_internal_compile_while.php
│ ├── smarty_internal_compilebase.php
│ ├── smarty_internal_config.php
│ ├── smarty_internal_config_file_compiler.php
│ ├── smarty_internal_configfilelexer.php
│ ├── smarty_internal_configfileparser.php
│ ├── smarty_internal_data.php
│ ├── smarty_internal_debug.php
│ ├── smarty_internal_filter_handler.php
│ ├── smarty_internal_function_call_handler.php
│ ├── smarty_internal_get_include_path.php
│ ├── smarty_internal_nocache_insert.php
│ ├── smarty_internal_parsetree.php
│ ├── smarty_internal_resource_eval.php
│ ├── smarty_internal_resource_extends.php
│ ├── smarty_internal_resource_file.php
│ ├── smarty_internal_resource_php.php
│ ├── smarty_internal_resource_registered.php
│ ├── smarty_internal_resource_stream.php
│ ├── smarty_internal_resource_string.php
│ ├── smarty_internal_smartytemplatecompiler.php
│ ├── smarty_internal_template.php
│ ├── smarty_internal_templatebase.php
│ ├── smarty_internal_templatecompilerbase.php
│ ├── smarty_internal_templatelexer.php
│ ├── smarty_internal_templateparser.php
│ ├── smarty_internal_utility.php
│ ├── smarty_internal_write_file.php
│ ├── smarty_resource.php
│ ├── smarty_resource_custom.php
│ ├── smarty_resource_recompiled.php
│ ├── smarty_resource_uncompiled.php
│ └── smarty_security.php
├── restore.php
└── templates
├── backupjobs.tpl
├── backuprestore.tpl
├── backupservers.tpl
├── footer.tpl
├── header.tpl
├── home.tpl
├── index.php
├── login.tpl
├── useracl.tpl
└── users.tpl
/README.md:
--------------------------------------------------------------------------------
1 | CDP.me (Continuous Data Protection)
2 | ===
3 | ---------------------------------------
4 | #### About
5 | CDP.me is a backup script designed for Linux Server backups.
6 |
7 | CDP.me is released under GNU GPL v2. By downloading, using and editing CDP.me you must agree to the terms set forth in the license provided.
8 |
9 | ---------------------------------------
10 | #### Features
11 | * Web Based Administration Panel
12 | * Add Backup Servers
13 | * Add Backup Jobs
14 | * Add Users
15 | * Add ACL's
16 | * View Backups
17 | * Download Backups
18 | * Restore Backups
19 | * Session security (IP Check + inactivity timeout)
20 | * Json Flat File Database (no MySQL database involved)
21 | * Backups ran using cron
22 | * Server authentication using password or RSA key
23 | * Email notifications (sendmail / SMTP)
24 | * Backup rotation / auto delete
25 | * Full Backups
26 | * Incremental Backups
27 | * MySQL Backups
28 | * OpenVZ Node Backups
29 | * cPanel Account Backups
30 | * 2-Factor Authentication (Google Authenticator)
31 | * Backup Encryption (AES-256/GPG)
32 | * User accounts / ACL's
33 |
34 | ---------------------------------------
35 | #### Installation
36 | You may use one of the following commands to install CDP.me on your storage/backup server.
37 | The backup server **has** to be running CentOS/Debian/Ubuntu, but the server(s) to be backed up may run any linux distrubution.
38 |
39 | `/usr/bin/env bash <((wget -qO - cdp.me/install.sh))`
40 |
41 | or
42 |
43 | `/usr/bin/env bash <((curl -sL cdp.me/install.sh))`
44 |
45 | If your backup server is running a distribution other than the ones above or you do not want to use Apache, you may install CDP.me manually using the wiki guide here https://github.com/PetaByet/cdp/wiki/Manual-Installation
46 |
47 | The latest version available can be found [here](https://github.com/PetaByet/cdp/releases). The change log is available here https://github.com/PetaByet/cdp/blob/master/CHANGELOG.txt
48 |
49 | ---------------------------------------
50 | #### System/Software Requirements
51 | * Backup Server (the server to store all backups)
52 | * Minimal / Fresh OS Installation
53 | * Linux
54 |
55 | * Host Server (the server to be backed up)
56 | * File
57 | * SSH + SFTP
58 | * tar
59 | * *99% of servers meet this requirement*
60 | * MySQL
61 | * MySQL 5
62 | * OpenVZ
63 | * SSH + SFTP
64 | * vzdump
65 | * lvm2
66 | * It is recommended that /vz is a logical volume
67 |
68 | ---------------------------------------
69 | For more information about CDP.me, please visit our wiki at https://github.com/PetaByet/cdp/wiki
70 | Please report any bugs that you have found here https://github.com/PetaByet/cdp/issues
71 | We no longer maintain a change log, however you may look at the release notes for changes.
72 |
--------------------------------------------------------------------------------
/bootstrap/fonts/FontAwesome.otf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PetaByet/cdp/1ee0e4b2ec5bedb5473b6ded731d10f8d2c4c1e7/bootstrap/fonts/FontAwesome.otf
--------------------------------------------------------------------------------
/bootstrap/fonts/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PetaByet/cdp/1ee0e4b2ec5bedb5473b6ded731d10f8d2c4c1e7/bootstrap/fonts/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/bootstrap/fonts/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PetaByet/cdp/1ee0e4b2ec5bedb5473b6ded731d10f8d2c4c1e7/bootstrap/fonts/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/bootstrap/fonts/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PetaByet/cdp/1ee0e4b2ec5bedb5473b6ded731d10f8d2c4c1e7/bootstrap/fonts/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/bootstrap/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PetaByet/cdp/1ee0e4b2ec5bedb5473b6ded731d10f8d2c4c1e7/bootstrap/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/bootstrap/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PetaByet/cdp/1ee0e4b2ec5bedb5473b6ded731d10f8d2c4c1e7/bootstrap/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/bootstrap/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PetaByet/cdp/1ee0e4b2ec5bedb5473b6ded731d10f8d2c4c1e7/bootstrap/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/bootstrap/img/alpha.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PetaByet/cdp/1ee0e4b2ec5bedb5473b6ded731d10f8d2c4c1e7/bootstrap/img/alpha.png
--------------------------------------------------------------------------------
/bootstrap/img/hue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PetaByet/cdp/1ee0e4b2ec5bedb5473b6ded731d10f8d2c4c1e7/bootstrap/img/hue.png
--------------------------------------------------------------------------------
/bootstrap/img/prettyCheckable-blue.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PetaByet/cdp/1ee0e4b2ec5bedb5473b6ded731d10f8d2c4c1e7/bootstrap/img/prettyCheckable-blue.png
--------------------------------------------------------------------------------
/bootstrap/img/prettyCheckable-gray.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PetaByet/cdp/1ee0e4b2ec5bedb5473b6ded731d10f8d2c4c1e7/bootstrap/img/prettyCheckable-gray.png
--------------------------------------------------------------------------------
/bootstrap/img/prettyCheckable-green.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PetaByet/cdp/1ee0e4b2ec5bedb5473b6ded731d10f8d2c4c1e7/bootstrap/img/prettyCheckable-green.png
--------------------------------------------------------------------------------
/bootstrap/img/prettyCheckable-red.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PetaByet/cdp/1ee0e4b2ec5bedb5473b6ded731d10f8d2c4c1e7/bootstrap/img/prettyCheckable-red.png
--------------------------------------------------------------------------------
/bootstrap/img/prettyCheckable-yellow.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PetaByet/cdp/1ee0e4b2ec5bedb5473b6ded731d10f8d2c4c1e7/bootstrap/img/prettyCheckable-yellow.png
--------------------------------------------------------------------------------
/bootstrap/img/saturation.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/PetaByet/cdp/1ee0e4b2ec5bedb5473b6ded731d10f8d2c4c1e7/bootstrap/img/saturation.png
--------------------------------------------------------------------------------
/bootstrap/index.php:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/config.php:
--------------------------------------------------------------------------------
1 | = 5)
6 | {
7 | if (count(get_included_files()) == 1)
8 | {
9 | header("HTTP/1.1 404 File Not Found", 404);
10 | exit;
11 | }
12 | }
13 | else
14 | {
15 | if (count(get_included_files()) == 0) //stop file from being directly acessed
16 | {
17 | header("HTTP/1.1 404 File Not Found", 404);
18 | exit;
19 | }
20 | }
21 |
22 |
23 | /**
24 | CDP.me | Data Backups
25 | Copyright (C) 2014 CDP.me / PetaByet.com
26 |
27 | This program is free software; you can redistribute it and/or modify
28 | it under the terms of the GNU General Public License as published by
29 | the Free Software Foundation; either version 2 of the License, or
30 | (at your option) any later version.
31 |
32 | This program is distributed in the hope that it will be useful,
33 | but WITHOUT ANY WARRANTY; without even the implied warranty of
34 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
35 | GNU General Public License for more details.
36 |
37 | You should have received a copy of the GNU General Public License along
38 | with this program; if not, write to the Free Software Foundation, Inc.,
39 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
40 | **/
41 |
42 | // edit the configuration below to meet your needs
43 |
44 | $config = array();
45 | $config['adminemail'] = 'someone@test.com'; //the email address to send notifications to
46 | $config['sendnotification'] = true; //send email notification (recommended)
47 | $config['emailfrom'] = 'someone@test.com'; //send email from
48 | $config['smtp'] = false; //use smtp to send emails
49 | $config['smtpserver'] = ''; //smtp server (only enter if smtp is true)
50 | $config['smtpusername'] = ''; //smtp username (only enter if smtp is true)
51 | $config['smtppassword'] = ''; //smtp password (only enter if smtp is true)
52 | $config['smtpsecure'] = 'tls'; //smtp encryption (tls / ssl)
53 | $config['smtpport'] = 587; //smtp port (only enter if smtp is true)
54 | $config['path'] = dirname(__FILE__); //script root path
55 | $config['version'] = '1.0'; //script version
56 | $config['logintimeout'] = '1800'; //inactivity timeout in seconds
57 | $config['debug'] = false; //debug mode
58 | $config['debuglevel'] = 2; //0 for just show errors, 1 for just log errors or 2 for show and log errors
59 | $config['errorlevels'] = 'E_ALL | E_STRICT'; //error reporting level
60 | $config['logerrors'] = true; //log errors to the syslog even when debug is set to false
61 | $config['timezone'] = 'UTC'; //default time zone to use
62 |
63 | // DON'T EDIT BELOW THIS LINE
64 |
65 | error_reporting($config['errorlevels']); //set error reporting level
66 | date_default_timezone_set($config['timezone']); //set time zone
67 |
68 | if ($config['debug']) //enable or disable debug mode
69 | {
70 | switch ($config['debuglevel'])
71 | {
72 | case 0:
73 | ini_set('display_errors', 1);
74 | ini_set('log_errors', 0);
75 | break;
76 | case 1:
77 | ini_set('display_errors', 0);
78 | ini_set('log_errors', 1);
79 | break;
80 | case 2:
81 | ini_set('display_errors', 1);
82 | ini_set('log_errors', 1);
83 | break;
84 | default:
85 | ini_set('display_errors', 1);
86 | ini_set('log_errors', 1);
87 | break;
88 | }
89 | }
90 | else
91 | {
92 | ini_set('display_errors', 0);
93 | }
94 |
95 | if ($config['logerrors']) //enable or disable error logging for the syslog
96 | {
97 | ini_set('log_errors', 1);
98 | ini_set('error_log', 'syslog');
99 | }
100 |
101 | ?>
102 |
--------------------------------------------------------------------------------
/db/db-acl.json:
--------------------------------------------------------------------------------
1 | [{"id":"1","perms":{"backupjobs":"true","servers":"true","backups":"true","disk":"true","loadavg":"true","alog":"true","blog":"true","bjpaccess":"true","addjob":"true","viewbackup":"true","backnow":"true","deljob":"true","downloadb":"true","restoreb":"true","deleteb":"true","spaccess":"true","addserver":"true","delserver":"true","upaccess":"true","adduser":"true","edituser":"true","deluser":"true","apaccess":"true","addacl":"true","editacl":"true","delacl":"true"},"name":"Administrators"}]
--------------------------------------------------------------------------------
/db/db-activitylog.json:
--------------------------------------------------------------------------------
1 | []
2 |
--------------------------------------------------------------------------------
/db/db-backupjobs.json:
--------------------------------------------------------------------------------
1 | []
2 |
--------------------------------------------------------------------------------
/db/db-backuplog.json:
--------------------------------------------------------------------------------
1 | []
2 |
--------------------------------------------------------------------------------
/db/db-backups.json:
--------------------------------------------------------------------------------
1 | []
2 |
--------------------------------------------------------------------------------
/db/db-backupservers.json:
--------------------------------------------------------------------------------
1 | []
2 |
--------------------------------------------------------------------------------
/db/db-users.json:
--------------------------------------------------------------------------------
1 | [{"id":"1","username":"admin","password":"5f4dcc3b5aa765d61d8327deb882cf99","acl":"1"}]
--------------------------------------------------------------------------------
/db/index.php:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/htaccess.txt:
--------------------------------------------------------------------------------
1 | Options -Indexes
2 |
3 |
4 | order allow,deny
5 | deny from all
6 |
7 |
8 |
9 | order allow,deny
10 | deny from all
11 |
12 |
13 |
14 | order allow,deny
15 | deny from all
16 |
17 |
18 |
19 | order allow,deny
20 | deny from all
21 |
22 |
23 |
24 | order allow,deny
25 | deny from all
26 |
27 |
28 |
29 | order allow,deny
30 | deny from all
31 |
32 |
33 |
34 | order allow,deny
35 | deny from all
36 |
--------------------------------------------------------------------------------
/includes/backupjobs.php:
--------------------------------------------------------------------------------
1 | = 5) {
5 | if (count(get_included_files()) == 1) {
6 | die();
7 | }
8 | }
9 | else {
10 | if (count(get_included_files()) == 0) {
11 | die();
12 | }
13 | }
14 | if (!defined('FILEACCESS')) {
15 | die();
16 | }
17 | checkacl('bjpaccess');
18 | $backupjobs = json_decode(file_get_contents($config['path'] . '/db/db-backupjobs.json'), true);
19 | $backupservers = json_decode(file_get_contents($config['path'] . '/db/db-backupservers.json'), true);
20 | if (isset($_REQUEST['backupjob'])) {
21 | if ($_REQUEST['backupjob'] == 'add' && isset($_REQUEST['source']) && isset($_REQUEST['directory']) && isset($_REQUEST['expiry']) && isset($_REQUEST['encryption'])) {
22 | checkacl('addjob');
23 | $id = md5(rand() . time() . $_REQUEST['source']);
24 | if (!isset($_REQUEST['encryptionkey'])) {
25 | $_REQUEST['encryptionkey'] = null;
26 | }
27 | $backupjobs[count($backupjobs)] = array(
28 | 'id' => $id,
29 | 'source' => $_REQUEST['source'],
30 | 'directory' => $_REQUEST['directory'],
31 | 'expiry' => $_REQUEST['expiry'],
32 | 'encryption' => $_REQUEST['encryption'],
33 | 'encryptionkey' => $_REQUEST['encryptionkey'],
34 | 'type' => $_REQUEST['type']
35 | );
36 | file_put_contents($config['path'] . '/db/db-backupjobs.json', json_encode($backupjobs));
37 | logevent('User ' . $_SESSION['user'] . ' added backup job', 'activity');
38 | header('Location: index.php?action=backupjobs&created=true&id=' . $id);
39 | } elseif ($_REQUEST['backupjob'] == 'remove' && isset($_REQUEST['id'])) {
40 | checkacl('deljob');
41 | foreach ($backupjobs as $key => $backupjob) {
42 | if ($backupjob['id'] == $_REQUEST['id']) {
43 | unset($backupjobs[$key]);
44 | }
45 | }
46 | file_put_contents($config['path'] . '/db/db-backupjobs.json', json_encode($backupjobs));
47 | logevent('User ' . $_SESSION['user'] . ' removed backup job', 'activity');
48 | header('Location: index.php?action=backupjobs');
49 | }
50 | } else {
51 | $fileservers = array();
52 | $sqlservers = array();
53 | $cpanelservers = array();
54 | foreach ($backupservers as $backupserver) {
55 | if ($backupserver['authtype'] == 'password' || $backupserver['authtype'] == 'key') {
56 | $fileservers[count($fileservers)] = $backupserver;
57 | } elseif ($backupserver['authtype'] == 'mysql') {
58 | $sqlservers[count($sqlservers)] = $backupserver;
59 | } elseif ($backupserver['authtype'] == 'cpanel') {
60 | $cpanelservers[count($cpanelservers)] = $backupserver;
61 | }
62 | }
63 | $smarty->assign('backupjobs',$backupjobs);
64 | $smarty->assign('fileservers',$fileservers);
65 | $smarty->assign('sqlservers',$sqlservers);
66 | $smarty->assign('cpanelservers',$cpanelservers);
67 | $smarty->display($config['path'].'/templates/header.tpl');
68 | $smarty->display($config['path'].'/templates/backupjobs.tpl');
69 | $smarty->display($config['path'].'/templates/footer.tpl');
70 | }
71 |
72 | ?>
--------------------------------------------------------------------------------
/includes/backuprestore.php:
--------------------------------------------------------------------------------
1 | = 5) {
5 | if (count(get_included_files()) == 1) {
6 | die();
7 | }
8 | }
9 | else {
10 | if (count(get_included_files()) == 0) {
11 | die();
12 | }
13 | }
14 | if (!defined('FILEACCESS')) {
15 | die();
16 | }
17 | checkacl('restoreb');
18 | if (isset($_GET['restoreaction']) && $_GET['restoreaction'] == 'initiate') {
19 | $tmpfilename = 'cdp-restore-'.md5(rand().time()).'.txt';
20 | shell_exec('php ' . $config['path'] . '/restore.php ' . escapeshellcmd($_GET['id']) . ' ' . escapeshellcmd($_GET['host']) . ' > ' . $config['path'] . '/files/' . $tmpfilename . ' 2>&1 &');
21 | echo $tmpfilename;
22 | } elseif (isset($_GET['restoreaction']) && $_GET['restoreaction'] == 'readtmpfile' && isset($_GET['tmpfilename'])) {
23 | $tmpfile = file_get_contents($config['path'] . '/files/' . $_GET['tmpfilename']);
24 | if (!empty($tmpfile)) {
25 | echo $tmpfile;
26 | }
27 | } elseif (isset($_GET['id'])) {
28 | $backups = json_decode(file_get_contents($config['path'] . '/db/db-backups.json'), true);
29 | $backupjobs = json_decode(file_get_contents($config['path'] . '/db/db-backupjobs.json'), true);
30 | $backupservers = json_decode(file_get_contents($config['path'] . '/db/db-backupservers.json'), true);
31 | function GetBackupDetails($backupdata)
32 | {
33 | global $backups;
34 | foreach ($backups as $backup) {
35 | if ($backup['file'] == $backupdata) {
36 | return $backup;
37 | }
38 | }
39 | return false;
40 | }
41 | $backupdetail = GetBackupDetails($_GET['id']);
42 | function GetJobDetails($jobid)
43 | {
44 | global $backupjobs;
45 | foreach ($backupjobs as $backupjob) {
46 | if ($backupjob['id'] == $jobid) {
47 | return $backupjob;
48 | }
49 | }
50 | return false;
51 | }
52 | $jobdetail = GetJobDetails($backupdetail['id']);
53 | $smarty->assign('backupservers',$backupservers);
54 | $smarty->assign('backupdetail',$backupdetail);
55 | $smarty->assign('jobdetail',$jobdetail);
56 | $smarty->display($config['path'].'/templates/header.tpl');
57 | $smarty->display($config['path'].'/templates/backuprestore.tpl');
58 | $smarty->display($config['path'].'/templates/footer.tpl');
59 | }
60 |
61 | ?>
--------------------------------------------------------------------------------
/includes/backupservers.php:
--------------------------------------------------------------------------------
1 | = 5) {
5 | if (count(get_included_files()) == 1) {
6 | die();
7 | }
8 | }
9 | else {
10 | if (count(get_included_files()) == 0) {
11 | die();
12 | }
13 | }
14 | if (!defined('FILEACCESS')) {
15 | die();
16 | }
17 | checkacl('spaccess');
18 | $backupservers = json_decode(file_get_contents($config['path'] . '/db/db-backupservers.json'), true);
19 | if (isset($_REQUEST['backupserver'])) {
20 | if ($_REQUEST['backupserver'] == 'add' && isset($_REQUEST['host']) && isset($_REQUEST['port']) && isset($_REQUEST['authtype']) && isset($_REQUEST['username']) && isset($_REQUEST['password'])) {
21 | checkacl('addserver');
22 | $id = md5(rand() . time() . $_REQUEST['host']);
23 | $backupservers[count($backupservers)] = array(
24 | 'id' => $id,
25 | 'host' => trim($_REQUEST['host']),
26 | 'port' => trim($_REQUEST['port']),
27 | 'authtype' => $_REQUEST['authtype'],
28 | 'username' => $_REQUEST['username'],
29 | 'password' => $_REQUEST['password']
30 | );
31 | file_put_contents($config['path'] . '/db/db-backupservers.json', json_encode($backupservers));
32 | logevent('User ' . $_SESSION['user'] . ' added server', 'activity');
33 | header('Location: index.php?action=backupservers');
34 | } elseif ($_REQUEST['backupserver'] == 'remove' && isset($_REQUEST['id'])) {
35 | checkacl('delserver');
36 | foreach ($backupservers as $key => $backupserver) {
37 | if ($backupserver['id'] == $_REQUEST['id']) {
38 | unset($backupservers[$key]);
39 | }
40 | }
41 | file_put_contents($config['path'] . '/db/db-backupservers.json', json_encode($backupservers));
42 | logevent('User ' . $_SESSION['user'] . ' removed server', 'activity');
43 | header('Location: index.php?action=backupservers');
44 | }
45 | } else {
46 | $smarty->assign('backupservers',$backupservers);
47 | $smarty->display($config['path'].'/templates/header.tpl');
48 | $smarty->display($config['path'].'/templates/backupservers.tpl');
49 | $smarty->display($config['path'].'/templates/footer.tpl');
50 | }
51 |
52 | ?>
--------------------------------------------------------------------------------
/includes/home.php:
--------------------------------------------------------------------------------
1 | = 5) {
5 | if (count(get_included_files()) == 1) {
6 | die();
7 | }
8 | }
9 | else {
10 | if (count(get_included_files()) == 0) {
11 | die();
12 | }
13 | }
14 | if (!defined('FILEACCESS')) {
15 | die();
16 | }
17 | $backups = json_decode(file_get_contents($config['path'] . '/db/db-backups.json'), true);
18 | $backupjobs = json_decode(file_get_contents($config['path'] . '/db/db-backupjobs.json'), true);
19 | $backupservers = json_decode(file_get_contents($config['path'] . '/db/db-backupservers.json'), true);
20 | $smarty->assign('path',$config['path']);
21 | $smarty->assign('backupjobscount',count($backupjobs));
22 | $smarty->assign('backupserverscount',count($backupservers));
23 | $smarty->assign('backupscount',count($backups));
24 | $smarty->assign('disk',round((disk_total_space($config['path']) - disk_free_space($config['path'])) / disk_total_space($config['path']) * 100, 2));
25 | $loadavg = sys_getloadavg();
26 | $smarty->assign('loadavg',$loadavg[0] . '/' . $loadavg[1] . '/' . $loadavg[2]);
27 | $activitylogs = json_decode(file_get_contents($config['path'] . '/db/db-activitylog.json'), true);
28 | $activitylogs = array_reverse($activitylogs);
29 | $activitylogentries = array();
30 | for ($i = 0; $i < 10; $i++) {
31 | if (isset($activitylogs[$i]) && is_array($activitylogs[$i])) {
32 | if (strlen($activitylogs[$i]['data']) > 50) {
33 | $stringCut = substr($activitylogs[$i]['data'], 0, 50);
34 | $activitylogdata = substr($stringCut, 0, strrpos($stringCut, ' ')).'...';
35 | } else {
36 | $activitylogdata = $activitylogs[$i]['data'];
37 | }
38 | $activitylogentries[count($activitylogentries)] = array(
39 | 'data' => $activitylogdata,
40 | 'time' => date("Y-m-d H:i:s", $activitylogs[$i]['time']),
41 | 'ip' => $activitylogs[$i]['ip']
42 | );
43 | } else {
44 | $activitylogentries[count($activitylogentries)] = array(
45 | 'data' => '-',
46 | 'time' => '-',
47 | 'ip' => '-'
48 | );
49 | }
50 | }
51 | $smarty->assign('activitylogentries',$activitylogentries);
52 | $backuplogs = json_decode(file_get_contents($config['path'] . '/db/db-backuplog.json'), true);
53 | $backuplogs = array_reverse($backuplogs);
54 | $backuplogentries = array();
55 | for ($i = 0; $i < 10; $i++) {
56 | if (isset($backuplogs[$i]) && is_array($backuplogs[$i])) {
57 | if (strlen($backuplogs[$i]['data']) > 50) {
58 | $stringCut = substr($backuplogs[$i]['data'], 0, 50);
59 | $backuplogdata = substr($stringCut, 0, strrpos($stringCut, ' ')).'...';
60 | } else {
61 | $backuplogdata = $backuplogs[$i]['data'];
62 | }
63 | $backuplogentries[count($backuplogentries)] = array(
64 | 'data' => $backuplogdata,
65 | 'time' => date("Y-m-d H:i:s", $backuplogs[$i]['time']),
66 | 'ip' => $backuplogs[$i]['ip']
67 | );
68 | } else {
69 | $backuplogentries[count($backuplogentries)] = array(
70 | 'data' => '-',
71 | 'time' => '-',
72 | 'ip' => '-'
73 | );
74 | }
75 | }
76 | $smarty->assign('backuplogentries',$backuplogentries);
77 | $smarty->display($config['path'].'/templates/header.tpl');
78 | $smarty->display($config['path'].'/templates/home.tpl');
79 | $smarty->display($config['path'].'/templates/footer.tpl');
80 | ?>
--------------------------------------------------------------------------------
/includes/index.php:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/includes/login.php:
--------------------------------------------------------------------------------
1 | = 5) {
5 | if (count(get_included_files()) == 1) {
6 | die();
7 | }
8 | }
9 | else {
10 | if (count(get_included_files()) == 0) {
11 | die();
12 | }
13 | }
14 | if (!defined('FILEACCESS')) {
15 | die();
16 | }
17 | if (isset($_POST['username']) && isset($_POST['password'])) {
18 | $users = json_decode(file_get_contents($config['path'] . '/db/db-users.json'), true);
19 | $acls = json_decode(file_get_contents($config['path'] . '/db/db-acl.json'), true);
20 | foreach ($users as $user) {
21 | if ($user['username'] == $_POST['username']) {
22 | $userdetails = $user;
23 | }
24 | }
25 | if (is_array($userdetails) && md5($_POST['password']) == $userdetails['password']) {
26 | if ($userdetails['2fo'] && !isset($userdetails['2fo'])) {
27 | header('Location: index.php?login=failed&pwfail');
28 | die();
29 | }
30 | if (isset($userdetails['2fo']) && $userdetails['2fo'] == 'true') {
31 | if (!isset($_POST['2fokey'])) {
32 | $_POST['2fokey'] = 0;
33 | }
34 | require($config['path'] . '/libs/googleauthenticator/GoogleAuthenticator.php');
35 | $ga = new PHPGangsta_GoogleAuthenticator();
36 | if (!$ga->verifyCode($userdetails['2fokey'], $_POST['2fokey'], 2)) {
37 | header('Location: index.php?login=failed&2fofail');
38 | die();
39 | }
40 | }
41 | foreach ($acls as $acl) {
42 | if ($acl['id'] == $user['acl']) {
43 | $_SESSION['acl'] = $acl['perms'];
44 | }
45 | }
46 | $_SESSION['user'] = $_POST['username'];
47 | $_SESSION['ip'] = $_SERVER['REMOTE_ADDR'];
48 | $_SESSION['time'] = time();
49 | logevent('User ' . $_SESSION['user'] . ' logged in', 'activity');
50 | header('Location: index.php');
51 | die();
52 | } else {
53 | header('Location: index.php?login=failed&fail');
54 | }
55 | } else {
56 | $smarty->display($config['path'].'/templates/header.tpl');
57 | $smarty->display($config['path'].'/templates/login.tpl');
58 | $smarty->display($config['path'].'/templates/footer.tpl');
59 | }
60 |
61 | ?>
--------------------------------------------------------------------------------
/includes/useracl.php:
--------------------------------------------------------------------------------
1 | = 5) {
5 | if (count(get_included_files()) == 1) {
6 | die();
7 | }
8 | }
9 | else {
10 | if (count(get_included_files()) == 0) {
11 | die();
12 | }
13 | }
14 | if (!defined('FILEACCESS')) {
15 | die();
16 | }
17 | checkacl('apaccess');
18 | $aclarray = array(
19 | //in format of slug => text
20 | "Dashboard" => array(
21 | "backupjobs" => "Backup Jobs",
22 | "servers" => "Servers",
23 | "backups" => "Backups",
24 | "disk" => "Disk",
25 | "loadavg" => "Load Average",
26 | "alog" => "Activity Log",
27 | "blog" => "Backup Log"
28 | ),
29 | "Backup Jobs" => array(
30 | "bjpaccess" => "Page Access",
31 | "addjob" => "Add Backup Job",
32 | "viewbackup" => "View Backup",
33 | "backnow" => "Backup Now",
34 | "deljob" => "Backup Job Delete",
35 | "downloadb" => "Download Backup",
36 | "restoreb" => "Restore Backup",
37 | "deleteb" => "Backup Delete"
38 | ),
39 | "Servers" => array(
40 | "spaccess" => "Page Access",
41 | "addserver" => "Add Server",
42 | "delserver" => "Delete Server"
43 | ),
44 | "Users" => array(
45 | "upaccess" => "Page Access",
46 | "adduser" => "Add User",
47 | "edituser" => "Edit User",
48 | "deluser" => "Delete User"
49 | ),
50 | "User ACLs" => array(
51 | "apaccess" => "Page Access",
52 | "addacl" => "Add ACL",
53 | "editacl" => "Edit ACL",
54 | "delacl" => "Delete ACL"
55 | )
56 | );
57 |
58 | $acls = json_decode(file_get_contents($config['path'] . '/db/db-acl.json'), true);
59 | if (isset($_REQUEST['acl'])) {
60 | if ($_REQUEST['acl'] == 'add' && isset($_REQUEST['perms']) && isset($_REQUEST['name']) && is_array($_REQUEST['perms'])) {
61 | checkacl('addacl');
62 | $acls[count($acls)] = array(
63 | 'id' => count($acls) + 1,
64 | 'perms' => $_REQUEST['perms'],
65 | 'name' => trim($_REQUEST['name'])
66 | );
67 |
68 | file_put_contents($config['path'] . '/db/db-acl.json', json_encode($acls));
69 | logevent('User ' . $_SESSION['user'] . ' added ACL', 'activity');
70 | header('Location: index.php?action=useracl');
71 | } elseif ($_REQUEST['acl'] == 'edit' && isset($_REQUEST['perms']) && isset($_REQUEST['name']) && isset($_REQUEST['aclid']) && is_array($_REQUEST['perms'])) {
72 | checkacl('editacl');
73 | foreach ($acls as $aclkey => $acl) {
74 | if ($acl['id'] == $_REQUEST['aclid']) {
75 | $acls[$aclkey] = array(
76 | 'id' => $_REQUEST['aclid'],
77 | 'perms' => $_REQUEST['perms'],
78 | 'name' => trim($_REQUEST['name'])
79 | );
80 | }
81 | }
82 | file_put_contents($config['path'] . '/db/db-acl.json', json_encode($acls));
83 | logevent('User ' . $_SESSION['user'] . ' edited ACL ' . $_REQUEST['aclid'], 'activity');
84 | header('Location: index.php?action=useracl');
85 | } elseif ($_REQUEST['acl'] == 'remove' && isset($_REQUEST['id'])) {
86 | checkacl('delacl');
87 | foreach ($acls as $aclkey => $acl) {
88 | if ($acl['id'] == $_REQUEST['id']) {
89 | unset($acls[$aclkey]);
90 | }
91 | }
92 | file_put_contents($config['path'] . '/db/db-acl.json', json_encode($acls));
93 | logevent('User ' . $_SESSION['user'] . ' removed ACL ' . $_REQUEST['id'], 'activity');
94 | header('Location: index.php?action=useracl');
95 | }
96 | } else {
97 | $smarty->assign('acls',$acls);
98 | $smarty->assign('aclarray',$aclarray);
99 | if (isset($_REQUEST['id']) && is_array($acls)) {
100 | foreach ($acls as $acl) {
101 | if ($acl['id'] == $_REQUEST['id']) {
102 | $smarty->assign('acldetails',$acl);
103 | }
104 | }
105 | }
106 | $smarty->display($config['path'].'/templates/header.tpl');
107 | $smarty->display($config['path'].'/templates/useracl.tpl');
108 | $smarty->display($config['path'].'/templates/footer.tpl');
109 | }
110 |
111 | ?>
--------------------------------------------------------------------------------
/includes/users.php:
--------------------------------------------------------------------------------
1 | = 5) {
5 | if (count(get_included_files()) == 1) {
6 | die();
7 | }
8 | }
9 | else {
10 | if (count(get_included_files()) == 0) {
11 | die();
12 | }
13 | }
14 | if (!defined('FILEACCESS')) {
15 | die();
16 | }
17 | checkacl('upaccess');
18 | $users = json_decode(file_get_contents($config['path'] . '/db/db-users.json'), true);
19 | $acls = json_decode(file_get_contents($config['path'] . '/db/db-acl.json'), true);
20 | if (isset($_REQUEST['users'])) {
21 | if ($_REQUEST['users'] == '2focreatekey') {
22 | require($config['path'] . '/libs/googleauthenticator/GoogleAuthenticator.php');
23 | $ga = new PHPGangsta_GoogleAuthenticator();
24 | echo $ga->createSecret();
25 | die();
26 | } elseif ($_REQUEST['users'] == 'generateqr' && isset($_REQUEST['generateqr'])) {
27 | require($config['path'] . '/libs/googleauthenticator/GoogleAuthenticator.php');
28 | $ga = new PHPGangsta_GoogleAuthenticator();
29 | echo '
';
30 | die();
31 | } elseif ($_REQUEST['users'] == 'add' && isset($_REQUEST['username']) && isset($_REQUEST['password']) && isset($_REQUEST['acl'])) {
32 | checkacl('adduser');
33 | if (!isset($_REQUEST['2fokey'])) {
34 | $_REQUEST['2fokey'] = null;
35 | }
36 | $users[count($users)] = array(
37 | 'id' => count($users) + 1,
38 | 'username' => trim($_REQUEST['username']),
39 | 'password' => md5($_REQUEST['password']),
40 | 'acl' => $_REQUEST['acl'],
41 | '2fo' => $_REQUEST['2fo'],
42 | '2fokey' => $_REQUEST['2fokey']
43 | );
44 | file_put_contents($config['path'] . '/db/db-users.json', json_encode($users));
45 | logevent('User ' . $_SESSION['user'] . ' added user ' . $_REQUEST['username'], 'activity');
46 | header('Location: index.php?action=users');
47 | } elseif ($_REQUEST['users'] == 'edit' && isset($_REQUEST['username']) && isset($_REQUEST['userid']) && isset($_REQUEST['acl'])) {
48 | checkacl('edituser');
49 | foreach ($users as $userkey => $user) {
50 | if ($user['id'] == $_REQUEST['userid']) {
51 | if (!isset($_REQUEST['2fokey'])) {
52 | $_REQUEST['2fokey'] = null;
53 | }
54 | $users[$userkey]['username'] = $_REQUEST['username'];
55 | $users[$userkey]['acl'] = $_REQUEST['acl'];
56 | $users[$userkey]['2fo'] = $_REQUEST['2fo'];
57 | $users[$userkey]['2fokey'] = $_REQUEST['2fokey'];
58 | if (isset($_REQUEST['password']) && !empty($_REQUEST['password'])) {
59 | $users[$userkey]['password'] = md5($_REQUEST['password']);
60 | }
61 | else $users[$userkey]['password'] = $user['password'];
62 | }
63 | }
64 | file_put_contents($config['path'] . '/db/db-users.json', json_encode($users));
65 | logevent('User ' . $_SESSION['user'] . ' edited user ' . $_REQUEST['username'], 'activity');
66 | header('Location: index.php?action=users');
67 | } elseif ($_REQUEST['users'] == 'remove' && isset($_REQUEST['id'])) {
68 | checkacl('deluser');
69 | foreach ($users as $userkey => $user) {
70 | if ($user['id'] == $_REQUEST['id']) {
71 | unset($users[$userkey]);
72 | }
73 | }
74 | file_put_contents($config['path'] . '/db/db-users.json', json_encode($users));
75 | logevent('User ' . $_SESSION['user'] . ' removed user', 'activity');
76 | header('Location: index.php?action=users');
77 | }
78 | } else {
79 | $smarty->assign('users',$users);
80 | $smarty->assign('acls',$acls);
81 | if (isset($_REQUEST['id']) && is_array($users)) {
82 | foreach ($users as $user) {
83 | if ($user['id'] == $_REQUEST['id']) {
84 | $smarty->assign('userdetails',$user);
85 | }
86 | }
87 | }
88 | $smarty->display($config['path'].'/templates/header.tpl');
89 | $smarty->display($config['path'].'/templates/users.tpl');
90 | $smarty->display($config['path'].'/templates/footer.tpl');
91 | }
92 |
93 | ?>
94 |
--------------------------------------------------------------------------------
/includes/viewbackups.php:
--------------------------------------------------------------------------------
1 | = 5) {
5 | if (count(get_included_files()) == 1) {
6 | die();
7 | }
8 | }
9 | else {
10 | if (count(get_included_files()) == 0) {
11 | die();
12 | }
13 | }
14 | if (!defined('FILEACCESS')) {
15 | die();
16 | }
17 | checkacl('viewbackup');
18 | function formatBytes($size, $precision = 2)
19 | {
20 | $base = log($size) / log(1024);
21 | $suffixes = array(
22 | 'b',
23 | 'k',
24 | 'M',
25 | 'G',
26 | 'T'
27 | );
28 | return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
29 | }
30 | $backups = json_decode(file_get_contents($config['path'] . '/db/db-backups.json'), true);
31 | $backups = array_reverse($backups); //reverse the array to make newest backups at the top
32 | $backupjobs = json_decode(file_get_contents($config['path'] . '/db/db-backupjobs.json'), true);
33 | $backupservers = json_decode(file_get_contents($config['path'] . '/db/db-backupservers.json'), true);
34 | function GetJobDetails($jobid)
35 | {
36 | global $backupjobs;
37 | foreach ($backupjobs as $backupjob) {
38 | if ($backupjob['id'] == $jobid) {
39 | return $backupjob;
40 | }
41 | }
42 | return false;
43 | }
44 | $backupjob = GetJobDetails($_GET['id']);
45 | $smarty->display($config['path'].'/templates/header.tpl');
46 | echo '
View Backups
';
47 | if ($backupjob['encryption'] == 'AES-256') {
48 | echo '
It may take a little longer to download decrypted files, please be patient!
';
49 | }
50 | echo '
';
51 | echo 'File | Size | Time | Actions | ';
52 | foreach ($backups as $backup) {
53 | if (isset($_GET['id']) && $_GET['id'] == $backup['id']) {
54 | echo '
---|
' . $backup['file'] . ' | ';
55 | echo '' . formatBytes($backup['size']) . ' | ';
56 | echo '' . date("Y-m-d H:i:s", $backup['time']) . ' | ';
57 | echo 'Download ';
58 | if ($backupjob['encryption'] == 'AES-256') {
59 | echo 'Download (Decrypted) ';
60 | }
61 | echo 'Restore
62 | Delete |
';
63 | }
64 | }
65 | echo '
';
66 | echo '
';
67 | ?>
68 |
75 | display($config['path'].'/templates/footer.tpl');
77 | ?>
--------------------------------------------------------------------------------
/libs/index.php:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/libs/php-gpg-master/.gitignore:
--------------------------------------------------------------------------------
1 | /.buildpath
2 | /.settings
3 | .DS_Store
--------------------------------------------------------------------------------
/libs/php-gpg-master/.project:
--------------------------------------------------------------------------------
1 |
2 |
3 | php-gpg
4 |
5 |
6 |
7 |
8 |
9 | org.eclipse.wst.validation.validationbuilder
10 |
11 |
12 |
13 |
14 | org.eclipse.dltk.core.scriptbuilder
15 |
16 |
17 |
18 |
19 |
20 | org.eclipse.php.core.PHPNature
21 |
22 |
23 |
--------------------------------------------------------------------------------
/libs/php-gpg-master/GPG/AES.php:
--------------------------------------------------------------------------------
1 | rounds;
30 | $b0 = $b[0];
31 | $b1 = $b[1];
32 | $b2 = $b[2];
33 | $b3 = $b[3];
34 |
35 | for($r = 0; $r < $rounds - 1; $r++) {
36 | $t0 = $b0 ^ $ctx->rk[$r][0];
37 | $t1 = $b1 ^ $ctx->rk[$r][1];
38 | $t2 = $b2 ^ $ctx->rk[$r][2];
39 | $t3 = $b3 ^ $ctx->rk[$r][3];
40 |
41 | $b0 = $T1[$t0 & 255] ^ $T2[($t1 >> 8) & 255] ^ $T3[($t2 >> 16) & 255] ^ $T4[GPG_Utility::zshift($t3, 24)];
42 | $b1 = $T1[$t1 & 255] ^ $T2[($t2 >> 8) & 255] ^ $T3[($t3 >> 16) & 255] ^ $T4[GPG_Utility::zshift($t0, 24)];
43 | $b2 = $T1[$t2 & 255] ^ $T2[($t3 >> 8) & 255] ^ $T3[($t0 >> 16) & 255] ^ $T4[GPG_Utility::zshift($t1, 24)];
44 | $b3 = $T1[$t3 & 255] ^ $T2[($t0 >> 8) & 255] ^ $T3[($t1 >> 16) & 255] ^ $T4[GPG_Utility::zshift($t2, 24)];
45 | }
46 |
47 | $r = $rounds - 1;
48 |
49 | $t0 = $b0 ^ $ctx->rk[$r][0];
50 | $t1 = $b1 ^ $ctx->rk[$r][1];
51 | $t2 = $b2 ^ $ctx->rk[$r][2];
52 | $t3 = $b3 ^ $ctx->rk[$r][3];
53 |
54 | $b[0] = GPG_Cipher::F1($t0, $t1, $t2, $t3) ^ $ctx->rk[$rounds][0];
55 | $b[1] = GPG_Cipher::F1($t1, $t2, $t3, $t0) ^ $ctx->rk[$rounds][1];
56 | $b[2] = GPG_Cipher::F1($t2, $t3, $t0, $t1) ^ $ctx->rk[$rounds][2];
57 | $b[3] = GPG_Cipher::F1($t3, $t0, $t1, $t2) ^ $ctx->rk[$rounds][3];
58 |
59 | return GPG_Utility::unpack_octets($b);
60 | }
61 | }
62 |
63 | ?>
--------------------------------------------------------------------------------
/libs/php-gpg-master/GPG/Expanded_Key.php:
--------------------------------------------------------------------------------
1 | = 0; $j--) $tk[$j] = $k[$j];
56 |
57 | $r = 0;
58 | $t = 0;
59 | for($j = 0; ($j < $kc) && ($r < $rounds + 1); ) {
60 | for(; ($j < $kc) && ($t < 4); $j++, $t++) {
61 | $keySched[$r][$t] = $tk[$j];
62 | }
63 | if($t == 4) {
64 | $r++;
65 | $t = 0;
66 | }
67 | }
68 |
69 | while($r < $rounds + 1) {
70 | $temp = $tk[$kc - 1];
71 |
72 | $tk[0] ^= $S[GPG_Utility::B1($temp)] | ($S[GPG_Utility::B2($temp)] << 0x8) |
73 | ($S[GPG_Utility::B3($temp)] << 0x10) | ($S[GPG_Utility::B0($temp)] << 0x18);
74 | $tk[0] ^= $RCON[$rconpointer++];
75 |
76 | if ($kc != 8) {
77 | for($j = 1; $j < $kc; $j++) $tk[$j] ^= $tk[$j - 1];
78 | } else {
79 | for($j = 1; $j < $kc / 2; $j++) $tk[$j] ^= $tk[$j - 1];
80 |
81 | $temp = $tk[$kc / 2 - 1];
82 | $tk[$kc / 2] ^= $S[GPG_Utility::B0($temp)] | ($S[GPG_Utility::B1($temp)] << 0x8) |
83 | ($S[GPG_Utility::B2($temp)] << 0x10) | ($S[GPG_Utility::B3($temp)] << 0x18);
84 |
85 | for($j = $kc / 2 + 1; $j < $kc; $j++) $tk[$j] ^= $tk[$j - 1];
86 | }
87 |
88 | for($j = 0; ($j < $kc) && ($r < $rounds + 1); ) {
89 | for(; ($j < $kc) && ($t < 4); $j++, $t++) {
90 | $keySched[$r][$t] = $tk[$j];
91 | }
92 | if($t == 4) {
93 | $r++;
94 | $t = 0;
95 | }
96 | }
97 | }
98 |
99 | $this->rounds = $rounds;
100 | $this->rk = $keySched;
101 | return $this;
102 | }
103 | }
104 |
105 | ?>
--------------------------------------------------------------------------------
/libs/php-gpg-master/GPG/Utility.php:
--------------------------------------------------------------------------------
1 | > 0x8) & 0xff);
25 | }
26 |
27 | static function B2($x) {
28 | return (($x >> 0x10) & 0xff);
29 | }
30 |
31 | static function B3($x) {
32 | return (($x >> 0x18) & 0xff);
33 | }
34 |
35 | static function zshift($x, $s) {
36 | $res = $x >> $s;
37 |
38 | $pad = 0;
39 | for ($i = 0; $i < 32 - $s; $i++) $pad += (1 << $i);
40 |
41 | return $res & $pad;
42 | }
43 |
44 | static function pack_octets($octets)
45 | {
46 | $i = 0;
47 | $j = 0;
48 | $len = count($octets);
49 | $b = array_fill(0, $len / 4, 0);
50 |
51 | if (!$octets || $len % 4) return;
52 |
53 | for ($i = 0, $j = 0; $j < $len; $j += 4) {
54 | $b[$i++] = $octets[$j] | ($octets[$j + 1] << 0x8) | ($octets[$j + 2] << 0x10) | ($octets[$j + 3] << 0x18);
55 |
56 | }
57 |
58 | return $b;
59 | }
60 |
61 | static function unpack_octets($packed)
62 | {
63 | $j = 0;
64 | $i = 0;
65 | $l = count($packed);
66 | $r = array_fill(0, $l * 4, 0);
67 |
68 | for ($j = 0; $j < $l; $j++) {
69 | $r[$i++] = GPG_Utility::B0($packed[$j]);
70 | $r[$i++] = GPG_Utility::B1($packed[$j]);
71 | $r[$i++] = GPG_Utility::B2($packed[$j]);
72 | $r[$i++] = GPG_Utility::B3($packed[$j]);
73 | }
74 |
75 | return $r;
76 | }
77 |
78 |
79 |
80 |
81 | static function hex2bin($h)
82 | {
83 | if(strlen($h) % 2) $h += "0";
84 |
85 | $r = "";
86 | for($i = 0; $i < strlen($h); $i += 2) {
87 | $r .= chr(intval($h[$i], 16) * 16 + intval($h[$i + 1], 16));
88 | }
89 |
90 | return $r;
91 | }
92 |
93 | static function crc24($data)
94 | {
95 | $crc = 0xb704ce;
96 |
97 | for($n = 0; $n < strlen($data); $n++) {
98 | $crc ^= (ord($data[$n]) & 0xff) << 0x10;
99 | for($i = 0; $i < 8; $i++) {
100 | $crc <<= 1;
101 | if($crc & 0x1000000) $crc ^= 0x1864cfb;
102 | }
103 | }
104 |
105 | return
106 | chr(($crc >> 0x10) & 0xff) .
107 | chr(($crc >> 0x8) & 0xff) .
108 | chr($crc & 0xff);
109 | }
110 |
111 | static function s_random($len, $textmode)
112 | {
113 | $r = "";
114 | for($i = 0; $i < $len;)
115 | {
116 | $t = rand(0, 0xff);
117 | if($t == 0 && $textmode) continue;
118 | $i++;
119 |
120 | $r .= chr($t);
121 | }
122 |
123 | return $r;
124 | }
125 |
126 | static function c_random() {
127 | return round(rand(0, 0xff));
128 | }
129 |
130 | }
131 | ?>
--------------------------------------------------------------------------------
/libs/phpmailer/PHPMailerAutoload.php:
--------------------------------------------------------------------------------
1 |
8 | * @author Jim Jagielski (jimjag)
9 | * @author Andy Prevost (codeworxtech)
10 | * @author Brent R. Matzelle (original founder)
11 | * @copyright 2012 - 2014 Marcus Bointon
12 | * @copyright 2010 - 2012 Jim Jagielski
13 | * @copyright 2004 - 2009 Andy Prevost
14 | * @license http://www.gnu.org/copyleft/lesser.html GNU Lesser General Public License
15 | * @note This program is distributed in the hope that it will be useful - WITHOUT
16 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 | * FITNESS FOR A PARTICULAR PURPOSE.
18 | */
19 |
20 | /**
21 | * PHPMailer SPL autoloader.
22 | * @param string $classname The name of the class to load
23 | */
24 | function PHPMailerAutoload($classname)
25 | {
26 | //Can't use __DIR__ as it's only in PHP 5.3+
27 | $filename = dirname(__FILE__).DIRECTORY_SEPARATOR.'class.'.strtolower($classname).'.php';
28 | if (is_readable($filename)) {
29 | require $filename;
30 | }
31 | }
32 |
33 | if (version_compare(PHP_VERSION, '5.1.2', '>=')) {
34 | //SPL autoloading was introduced in PHP 5.1.2
35 | if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
36 | spl_autoload_register('PHPMailerAutoload', true, true);
37 | } else {
38 | spl_autoload_register('PHPMailerAutoload');
39 | }
40 | } else {
41 | /**
42 | * Fall back to traditional autoload for old PHP versions
43 | * @param string $classname The name of the class to load
44 | */
45 | function __autoload($classname)
46 | {
47 | PHPMailerAutoload($classname);
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/libs/phpseclib/System/SSH_Agent.php:
--------------------------------------------------------------------------------
1 |
33 | * @copyright MMXIV Jim Wigginton
34 | * @license http://www.opensource.org/licenses/mit-license.html MIT License
35 | * @link http://phpseclib.sourceforge.net
36 | * @internal See http://api.libssh.org/rfc/PROTOCOL.agent
37 | */
38 |
39 | require_once 'SSH/Agent.php';
40 |
--------------------------------------------------------------------------------
/libs/phpseclib/openssl.cnf:
--------------------------------------------------------------------------------
1 | # minimalist openssl.cnf file for use with phpseclib
2 |
3 | HOME = .
4 | RANDFILE = $ENV::HOME/.rnd
5 |
6 | [ v3_ca ]
7 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/block.textformat.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: textformat
13 | * Purpose: format text a certain way with preset styles
14 | * or custom wrap/indent settings
15 | * Params:
16 | *
17 | * - style - string (email)
18 | * - indent - integer (0)
19 | * - wrap - integer (80)
20 | * - wrap_char - string ("\n")
21 | * - indent_char - string (" ")
22 | * - wrap_boundary - boolean (true)
23 | *
24 | *
25 | * @link http://www.smarty.net/manual/en/language.function.textformat.php {textformat}
26 | * (Smarty online manual)
27 | *
28 | * @param array $params parameters
29 | * @param string $content contents of the block
30 | * @param Smarty_Internal_Template $template template object
31 | * @param boolean &$repeat repeat flag
32 | *
33 | * @return string content re-formatted
34 | * @author Monte Ohrt
35 | */
36 | function smarty_block_textformat($params, $content, $template, &$repeat)
37 | {
38 | if (is_null($content)) {
39 | return;
40 | }
41 |
42 | $style = null;
43 | $indent = 0;
44 | $indent_first = 0;
45 | $indent_char = ' ';
46 | $wrap = 80;
47 | $wrap_char = "\n";
48 | $wrap_cut = false;
49 | $assign = null;
50 |
51 | foreach ($params as $_key => $_val) {
52 | switch ($_key) {
53 | case 'style':
54 | case 'indent_char':
55 | case 'wrap_char':
56 | case 'assign':
57 | $$_key = (string) $_val;
58 | break;
59 |
60 | case 'indent':
61 | case 'indent_first':
62 | case 'wrap':
63 | $$_key = (int) $_val;
64 | break;
65 |
66 | case 'wrap_cut':
67 | $$_key = (bool) $_val;
68 | break;
69 |
70 | default:
71 | trigger_error("textformat: unknown attribute '$_key'");
72 | }
73 | }
74 |
75 | if ($style == 'email') {
76 | $wrap = 72;
77 | }
78 | // split into paragraphs
79 | $_paragraphs = preg_split('![\r\n]{2}!', $content);
80 |
81 | foreach ($_paragraphs as &$_paragraph) {
82 | if (!$_paragraph) {
83 | continue;
84 | }
85 | // convert mult. spaces & special chars to single space
86 | $_paragraph = preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER, '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER), array(' ', ''), $_paragraph);
87 | // indent first line
88 | if ($indent_first > 0) {
89 | $_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph;
90 | }
91 | // wordwrap sentences
92 | if (Smarty::$_MBSTRING) {
93 | require_once(SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php');
94 | $_paragraph = smarty_mb_wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
95 | } else {
96 | $_paragraph = wordwrap($_paragraph, $wrap - $indent, $wrap_char, $wrap_cut);
97 | }
98 | // indent lines
99 | if ($indent > 0) {
100 | $_paragraph = preg_replace('!^!m', str_repeat($indent_char, $indent), $_paragraph);
101 | }
102 | }
103 | $_output = implode($wrap_char . $wrap_char, $_paragraphs);
104 |
105 | if ($assign) {
106 | $template->assign($assign, $_output);
107 | } else {
108 | return $_output;
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/function.counter.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: counter
13 | * Purpose: print out a counter value
14 | *
15 | * @author Monte Ohrt
16 | * @link http://www.smarty.net/manual/en/language.function.counter.php {counter}
17 | * (Smarty online manual)
18 | *
19 | * @param array $params parameters
20 | * @param Smarty_Internal_Template $template template object
21 | *
22 | * @return string|null
23 | */
24 | function smarty_function_counter($params, $template)
25 | {
26 | static $counters = array();
27 |
28 | $name = (isset($params['name'])) ? $params['name'] : 'default';
29 | if (!isset($counters[$name])) {
30 | $counters[$name] = array(
31 | 'start' => 1,
32 | 'skip' => 1,
33 | 'direction' => 'up',
34 | 'count' => 1
35 | );
36 | }
37 | $counter =& $counters[$name];
38 |
39 | if (isset($params['start'])) {
40 | $counter['start'] = $counter['count'] = (int) $params['start'];
41 | }
42 |
43 | if (!empty($params['assign'])) {
44 | $counter['assign'] = $params['assign'];
45 | }
46 |
47 | if (isset($counter['assign'])) {
48 | $template->assign($counter['assign'], $counter['count']);
49 | }
50 |
51 | if (isset($params['print'])) {
52 | $print = (bool) $params['print'];
53 | } else {
54 | $print = empty($counter['assign']);
55 | }
56 |
57 | if ($print) {
58 | $retval = $counter['count'];
59 | } else {
60 | $retval = null;
61 | }
62 |
63 | if (isset($params['skip'])) {
64 | $counter['skip'] = $params['skip'];
65 | }
66 |
67 | if (isset($params['direction'])) {
68 | $counter['direction'] = $params['direction'];
69 | }
70 |
71 | if ($counter['direction'] == "down") {
72 | $counter['count'] -= $counter['skip'];
73 | } else {
74 | $counter['count'] += $counter['skip'];
75 | }
76 |
77 | return $retval;
78 | }
79 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/function.cycle.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: cycle
13 | * Date: May 3, 2002
14 | * Purpose: cycle through given values
15 | * Params:
16 | *
17 | * - name - name of cycle (optional)
18 | * - values - comma separated list of values to cycle, or an array of values to cycle
19 | * (this can be left out for subsequent calls)
20 | * - reset - boolean - resets given var to true
21 | * - print - boolean - print var or not. default is true
22 | * - advance - boolean - whether or not to advance the cycle
23 | * - delimiter - the value delimiter, default is ","
24 | * - assign - boolean, assigns to template var instead of printed.
25 | *
26 | * Examples:
27 | *
28 | * {cycle values="#eeeeee,#d0d0d0d"}
29 | * {cycle name=row values="one,two,three" reset=true}
30 | * {cycle name=row}
31 | *
32 | *
33 | * @link http://www.smarty.net/manual/en/language.function.cycle.php {cycle}
34 | * (Smarty online manual)
35 | * @author Monte Ohrt
36 | * @author credit to Mark Priatel
37 | * @author credit to Gerard
38 | * @author credit to Jason Sweat
39 | * @version 1.3
40 | *
41 | * @param array $params parameters
42 | * @param Smarty_Internal_Template $template template object
43 | *
44 | * @return string|null
45 | */
46 |
47 | function smarty_function_cycle($params, $template)
48 | {
49 | static $cycle_vars;
50 |
51 | $name = (empty($params['name'])) ? 'default' : $params['name'];
52 | $print = (isset($params['print'])) ? (bool) $params['print'] : true;
53 | $advance = (isset($params['advance'])) ? (bool) $params['advance'] : true;
54 | $reset = (isset($params['reset'])) ? (bool) $params['reset'] : false;
55 |
56 | if (!isset($params['values'])) {
57 | if (!isset($cycle_vars[$name]['values'])) {
58 | trigger_error("cycle: missing 'values' parameter");
59 |
60 | return;
61 | }
62 | } else {
63 | if (isset($cycle_vars[$name]['values'])
64 | && $cycle_vars[$name]['values'] != $params['values']
65 | ) {
66 | $cycle_vars[$name]['index'] = 0;
67 | }
68 | $cycle_vars[$name]['values'] = $params['values'];
69 | }
70 |
71 | if (isset($params['delimiter'])) {
72 | $cycle_vars[$name]['delimiter'] = $params['delimiter'];
73 | } elseif (!isset($cycle_vars[$name]['delimiter'])) {
74 | $cycle_vars[$name]['delimiter'] = ',';
75 | }
76 |
77 | if (is_array($cycle_vars[$name]['values'])) {
78 | $cycle_array = $cycle_vars[$name]['values'];
79 | } else {
80 | $cycle_array = explode($cycle_vars[$name]['delimiter'], $cycle_vars[$name]['values']);
81 | }
82 |
83 | if (!isset($cycle_vars[$name]['index']) || $reset) {
84 | $cycle_vars[$name]['index'] = 0;
85 | }
86 |
87 | if (isset($params['assign'])) {
88 | $print = false;
89 | $template->assign($params['assign'], $cycle_array[$cycle_vars[$name]['index']]);
90 | }
91 |
92 | if ($print) {
93 | $retval = $cycle_array[$cycle_vars[$name]['index']];
94 | } else {
95 | $retval = null;
96 | }
97 |
98 | if ($advance) {
99 | if ($cycle_vars[$name]['index'] >= count($cycle_array) - 1) {
100 | $cycle_vars[$name]['index'] = 0;
101 | } else {
102 | $cycle_vars[$name]['index'] ++;
103 | }
104 | }
105 |
106 | return $retval;
107 | }
108 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/function.math.php:
--------------------------------------------------------------------------------
1 |
13 | * Name: math
14 | * Purpose: handle math computations in template
15 | *
16 | * @link http://www.smarty.net/manual/en/language.function.math.php {math}
17 | * (Smarty online manual)
18 | * @author Monte Ohrt
19 | *
20 | * @param array $params parameters
21 | * @param Smarty_Internal_Template $template template object
22 | *
23 | * @return string|null
24 | */
25 | function smarty_function_math($params, $template)
26 | {
27 | static $_allowed_funcs = array(
28 | 'int' => true, 'abs' => true, 'ceil' => true, 'cos' => true, 'exp' => true, 'floor' => true,
29 | 'log' => true, 'log10' => true, 'max' => true, 'min' => true, 'pi' => true, 'pow' => true,
30 | 'rand' => true, 'round' => true, 'sin' => true, 'sqrt' => true, 'srand' => true, 'tan' => true
31 | );
32 | // be sure equation parameter is present
33 | if (empty($params['equation'])) {
34 | trigger_error("math: missing equation parameter", E_USER_WARNING);
35 |
36 | return;
37 | }
38 |
39 | $equation = $params['equation'];
40 |
41 | // make sure parenthesis are balanced
42 | if (substr_count($equation, "(") != substr_count($equation, ")")) {
43 | trigger_error("math: unbalanced parenthesis", E_USER_WARNING);
44 |
45 | return;
46 | }
47 |
48 | // match all vars in equation, make sure all are passed
49 | preg_match_all("!(?:0x[a-fA-F0-9]+)|([a-zA-Z][a-zA-Z0-9_]*)!", $equation, $match);
50 |
51 | foreach ($match[1] as $curr_var) {
52 | if ($curr_var && !isset($params[$curr_var]) && !isset($_allowed_funcs[$curr_var])) {
53 | trigger_error("math: function call $curr_var not allowed", E_USER_WARNING);
54 |
55 | return;
56 | }
57 | }
58 |
59 | foreach ($params as $key => $val) {
60 | if ($key != "equation" && $key != "format" && $key != "assign") {
61 | // make sure value is not empty
62 | if (strlen($val) == 0) {
63 | trigger_error("math: parameter $key is empty", E_USER_WARNING);
64 |
65 | return;
66 | }
67 | if (!is_numeric($val)) {
68 | trigger_error("math: parameter $key: is not numeric", E_USER_WARNING);
69 |
70 | return;
71 | }
72 | $equation = preg_replace("/\b$key\b/", " \$params['$key'] ", $equation);
73 | }
74 | }
75 | $smarty_math_result = null;
76 | eval("\$smarty_math_result = " . $equation . ";");
77 |
78 | if (empty($params['format'])) {
79 | if (empty($params['assign'])) {
80 | return $smarty_math_result;
81 | } else {
82 | $template->assign($params['assign'], $smarty_math_result);
83 | }
84 | } else {
85 | if (empty($params['assign'])) {
86 | printf($params['format'], $smarty_math_result);
87 | } else {
88 | $template->assign($params['assign'], sprintf($params['format'], $smarty_math_result));
89 | }
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifier.capitalize.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: capitalize
13 | * Purpose: capitalize words in the string
14 | * {@internal {$string|capitalize:true:true} is the fastest option for MBString enabled systems }}
15 | *
16 | * @param string $string string to capitalize
17 | * @param boolean $uc_digits also capitalize "x123" to "X123"
18 | * @param boolean $lc_rest capitalize first letters, lowercase all following letters "aAa" to "Aaa"
19 | *
20 | * @return string capitalized string
21 | * @author Monte Ohrt
22 | * @author Rodney Rehm
23 | */
24 | function smarty_modifier_capitalize($string, $uc_digits = false, $lc_rest = false)
25 | {
26 | if (Smarty::$_MBSTRING) {
27 | if ($lc_rest) {
28 | // uppercase (including hyphenated words)
29 | $upper_string = mb_convert_case($string, MB_CASE_TITLE, Smarty::$_CHARSET);
30 | } else {
31 | // uppercase word breaks
32 | $upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert_cb', $string);
33 | }
34 | // check uc_digits case
35 | if (!$uc_digits) {
36 | if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) {
37 | foreach ($matches[1] as $match) {
38 | $upper_string = substr_replace($upper_string, mb_strtolower($match[0], Smarty::$_CHARSET), $match[1], strlen($match[0]));
39 | }
40 | }
41 | }
42 | $upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_mbconvert2_cb', $upper_string);
43 | return $upper_string;
44 | }
45 |
46 | // lowercase first
47 | if ($lc_rest) {
48 | $string = strtolower($string);
49 | }
50 | // uppercase (including hyphenated words)
51 | $upper_string = preg_replace_callback("!(^|[^\p{L}'])([\p{Ll}])!S" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst_cb', $string);
52 | // check uc_digits case
53 | if (!$uc_digits) {
54 | if (preg_match_all("!\b([\p{L}]*[\p{N}]+[\p{L}]*)\b!" . Smarty::$_UTF8_MODIFIER, $string, $matches, PREG_OFFSET_CAPTURE)) {
55 | foreach ($matches[1] as $match) {
56 | $upper_string = substr_replace($upper_string, strtolower($match[0]), $match[1], strlen($match[0]));
57 | }
58 | }
59 | }
60 | $upper_string = preg_replace_callback("!((^|\s)['\"])(\w)!" . Smarty::$_UTF8_MODIFIER, 'smarty_mod_cap_ucfirst2_cb', $upper_string);
61 | return $upper_string;
62 | }
63 |
64 | /*
65 | *
66 | * Bug: create_function() use exhausts memory when used in long loops
67 | * Fix: use declared functions for callbacks instead of using create_function()
68 | * Note: This can be fixed using anonymous functions instead, but that requires PHP >= 5.3
69 | *
70 | * @author Kyle Renfrow
71 | */
72 | function smarty_mod_cap_mbconvert_cb($matches)
73 | {
74 | return stripslashes($matches[1]) . mb_convert_case(stripslashes($matches[2]), MB_CASE_UPPER, Smarty::$_CHARSET);
75 | }
76 |
77 | function smarty_mod_cap_mbconvert2_cb($matches)
78 | {
79 | return stripslashes($matches[1]) . mb_convert_case(stripslashes($matches[3]), MB_CASE_UPPER, Smarty::$_CHARSET);
80 | }
81 |
82 | function smarty_mod_cap_ucfirst_cb($matches)
83 | {
84 | return stripslashes($matches[1]) . ucfirst(stripslashes($matches[2]));
85 | }
86 |
87 | function smarty_mod_cap_ucfirst2_cb($matches)
88 | {
89 | return stripslashes($matches[1]) . ucfirst(stripslashes($matches[3]));
90 | }
91 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifier.date_format.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: date_format
13 | * Purpose: format datestamps via strftime
14 | * Input:
15 | * - string: input date string
16 | * - format: strftime format for output
17 | * - default_date: default date if $string is empty
18 | *
19 | * @link http://www.smarty.net/manual/en/language.modifier.date.format.php date_format (Smarty online manual)
20 | * @author Monte Ohrt
21 | *
22 | * @param string $string input date string
23 | * @param string $format strftime format for output
24 | * @param string $default_date default date if $string is empty
25 | * @param string $formatter either 'strftime' or 'auto'
26 | *
27 | * @return string |void
28 | * @uses smarty_make_timestamp()
29 | */
30 | function smarty_modifier_date_format($string, $format = null, $default_date = '', $formatter = 'auto')
31 | {
32 | if ($format === null) {
33 | $format = Smarty::$_DATE_FORMAT;
34 | }
35 | /**
36 | * Include the {@link shared.make_timestamp.php} plugin
37 | */
38 | require_once(SMARTY_PLUGINS_DIR . 'shared.make_timestamp.php');
39 | if ($string != '' && $string != '0000-00-00' && $string != '0000-00-00 00:00:00') {
40 | $timestamp = smarty_make_timestamp($string);
41 | } elseif ($default_date != '') {
42 | $timestamp = smarty_make_timestamp($default_date);
43 | } else {
44 | return;
45 | }
46 | if ($formatter == 'strftime' || ($formatter == 'auto' && strpos($format, '%') !== false)) {
47 | if (DS == '\\') {
48 | $_win_from = array('%D', '%h', '%n', '%r', '%R', '%t', '%T');
49 | $_win_to = array('%m/%d/%y', '%b', "\n", '%I:%M:%S %p', '%H:%M', "\t", '%H:%M:%S');
50 | if (strpos($format, '%e') !== false) {
51 | $_win_from[] = '%e';
52 | $_win_to[] = sprintf('%\' 2d', date('j', $timestamp));
53 | }
54 | if (strpos($format, '%l') !== false) {
55 | $_win_from[] = '%l';
56 | $_win_to[] = sprintf('%\' 2d', date('h', $timestamp));
57 | }
58 | $format = str_replace($_win_from, $_win_to, $format);
59 | }
60 |
61 | return strftime($format, $timestamp);
62 | } else {
63 | return date($format, $timestamp);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifier.debug_print_var.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: debug_print_var
13 | * Purpose: formats variable contents for display in the console
14 | *
15 | * @author Monte Ohrt
16 | *
17 | * @param array|object $var variable to be formatted
18 | * @param integer $depth maximum recursion depth if $var is an array
19 | * @param integer $length maximum string length if $var is a string
20 | *
21 | * @return string
22 | */
23 | function smarty_modifier_debug_print_var($var, $depth = 0, $length = 40)
24 | {
25 | $_replace = array("\n" => '\n',
26 | "\r" => '\r',
27 | "\t" => '\t'
28 | );
29 |
30 | switch (gettype($var)) {
31 | case 'array' :
32 | $results = 'Array (' . count($var) . ')';
33 | foreach ($var as $curr_key => $curr_val) {
34 | $results .= '
' . str_repeat(' ', $depth * 2)
35 | . '' . strtr($curr_key, $_replace) . ' => '
36 | . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
37 | $depth --;
38 | }
39 | break;
40 |
41 | case 'object' :
42 | $object_vars = get_object_vars($var);
43 | $results = '' . get_class($var) . ' Object (' . count($object_vars) . ')';
44 | foreach ($object_vars as $curr_key => $curr_val) {
45 | $results .= '
' . str_repeat(' ', $depth * 2)
46 | . ' ->' . strtr($curr_key, $_replace) . ' = '
47 | . smarty_modifier_debug_print_var($curr_val, ++$depth, $length);
48 | $depth --;
49 | }
50 | break;
51 |
52 | case 'boolean' :
53 | case 'NULL' :
54 | case 'resource' :
55 | if (true === $var) {
56 | $results = 'true';
57 | } elseif (false === $var) {
58 | $results = 'false';
59 | } elseif (null === $var) {
60 | $results = 'null';
61 | } else {
62 | $results = htmlspecialchars((string) $var);
63 | }
64 | $results = '' . $results . '';
65 | break;
66 |
67 | case 'integer' :
68 | case 'float' :
69 | $results = htmlspecialchars((string) $var);
70 | break;
71 |
72 | case 'string' :
73 | $results = strtr($var, $_replace);
74 | if (Smarty::$_MBSTRING) {
75 | if (mb_strlen($var, Smarty::$_CHARSET) > $length) {
76 | $results = mb_substr($var, 0, $length - 3, Smarty::$_CHARSET) . '...';
77 | }
78 | } else {
79 | if (isset($var[$length])) {
80 | $results = substr($var, 0, $length - 3) . '...';
81 | }
82 | }
83 |
84 | $results = htmlspecialchars('"' . $results . '"');
85 | break;
86 |
87 | case 'unknown type' :
88 | default :
89 | $results = strtr((string) $var, $_replace);
90 | if (Smarty::$_MBSTRING) {
91 | if (mb_strlen($results, Smarty::$_CHARSET) > $length) {
92 | $results = mb_substr($results, 0, $length - 3, Smarty::$_CHARSET) . '...';
93 | }
94 | } else {
95 | if (strlen($results) > $length) {
96 | $results = substr($results, 0, $length - 3) . '...';
97 | }
98 | }
99 |
100 | $results = htmlspecialchars($results);
101 | }
102 |
103 | return $results;
104 | }
105 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifier.regex_replace.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: regex_replace
13 | * Purpose: regular expression search/replace
14 | *
15 | * @link http://smarty.php.net/manual/en/language.modifier.regex.replace.php
16 | * regex_replace (Smarty online manual)
17 | * @author Monte Ohrt
18 | *
19 | * @param string $string input string
20 | * @param string|array $search regular expression(s) to search for
21 | * @param string|array $replace string(s) that should be replaced
22 | *
23 | * @return string
24 | */
25 | function smarty_modifier_regex_replace($string, $search, $replace)
26 | {
27 | if (is_array($search)) {
28 | foreach ($search as $idx => $s) {
29 | $search[$idx] = _smarty_regex_replace_check($s);
30 | }
31 | } else {
32 | $search = _smarty_regex_replace_check($search);
33 | }
34 |
35 | return preg_replace($search, $replace, $string);
36 | }
37 |
38 | /**
39 | * @param string $search string(s) that should be replaced
40 | *
41 | * @return string
42 | * @ignore
43 | */
44 | function _smarty_regex_replace_check($search)
45 | {
46 | // null-byte injection detection
47 | // anything behind the first null-byte is ignored
48 | if (($pos = strpos($search, "\0")) !== false) {
49 | $search = substr($search, 0, $pos);
50 | }
51 | // remove eval-modifier from $search
52 | if (preg_match('!([a-zA-Z\s]+)$!s', $search, $match) && (strpos($match[1], 'e') !== false)) {
53 | $search = substr($search, 0, - strlen($match[1])) . preg_replace('![e\s]+!', '', $match[1]);
54 | }
55 |
56 | return $search;
57 | }
58 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifier.replace.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: replace
13 | * Purpose: simple search/replace
14 | *
15 | * @link http://smarty.php.net/manual/en/language.modifier.replace.php replace (Smarty online manual)
16 | * @author Monte Ohrt
17 | * @author Uwe Tews
18 | *
19 | * @param string $string input string
20 | * @param string $search text to search for
21 | * @param string $replace replacement text
22 | *
23 | * @return string
24 | */
25 | function smarty_modifier_replace($string, $search, $replace)
26 | {
27 | if (Smarty::$_MBSTRING) {
28 | require_once(SMARTY_PLUGINS_DIR . 'shared.mb_str_replace.php');
29 |
30 | return smarty_mb_str_replace($search, $replace, $string);
31 | }
32 |
33 | return str_replace($search, $replace, $string);
34 | }
35 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifier.spacify.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: spacify
13 | * Purpose: add spaces between characters in a string
14 | *
15 | * @link http://smarty.php.net/manual/en/language.modifier.spacify.php spacify (Smarty online manual)
16 | * @author Monte Ohrt
17 | *
18 | * @param string $string input string
19 | * @param string $spacify_char string to insert between characters.
20 | *
21 | * @return string
22 | */
23 | function smarty_modifier_spacify($string, $spacify_char = ' ')
24 | {
25 | // well… what about charsets besides latin and UTF-8?
26 | return implode($spacify_char, preg_split('//' . Smarty::$_UTF8_MODIFIER, $string, - 1, PREG_SPLIT_NO_EMPTY));
27 | }
28 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifier.truncate.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: truncate
13 | * Purpose: Truncate a string to a certain length if necessary,
14 | * optionally splitting in the middle of a word, and
15 | * appending the $etc string or inserting $etc into the middle.
16 | *
17 | * @link http://smarty.php.net/manual/en/language.modifier.truncate.php truncate (Smarty online manual)
18 | * @author Monte Ohrt
19 | *
20 | * @param string $string input string
21 | * @param integer $length length of truncated text
22 | * @param string $etc end string
23 | * @param boolean $break_words truncate at word boundary
24 | * @param boolean $middle truncate in the middle of text
25 | *
26 | * @return string truncated string
27 | */
28 | function smarty_modifier_truncate($string, $length = 80, $etc = '...', $break_words = false, $middle = false)
29 | {
30 | if ($length == 0) {
31 | return '';
32 | }
33 |
34 | if (Smarty::$_MBSTRING) {
35 | if (mb_strlen($string, Smarty::$_CHARSET) > $length) {
36 | $length -= min($length, mb_strlen($etc, Smarty::$_CHARSET));
37 | if (!$break_words && !$middle) {
38 | $string = preg_replace('/\s+?(\S+)?$/' . Smarty::$_UTF8_MODIFIER, '', mb_substr($string, 0, $length + 1, Smarty::$_CHARSET));
39 | }
40 | if (!$middle) {
41 | return mb_substr($string, 0, $length, Smarty::$_CHARSET) . $etc;
42 | }
43 |
44 | return mb_substr($string, 0, $length / 2, Smarty::$_CHARSET) . $etc . mb_substr($string, - $length / 2, $length, Smarty::$_CHARSET);
45 | }
46 |
47 | return $string;
48 | }
49 |
50 | // no MBString fallback
51 | if (isset($string[$length])) {
52 | $length -= min($length, strlen($etc));
53 | if (!$break_words && !$middle) {
54 | $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length + 1));
55 | }
56 | if (!$middle) {
57 | return substr($string, 0, $length) . $etc;
58 | }
59 |
60 | return substr($string, 0, $length / 2) . $etc . substr($string, - $length / 2);
61 | }
62 |
63 | return $string;
64 | }
65 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.cat.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: cat
13 | * Date: Feb 24, 2003
14 | * Purpose: catenate a value to a variable
15 | * Input: string to catenate
16 | * Example: {$var|cat:"foo"}
17 | *
18 | * @link http://smarty.php.net/manual/en/language.modifier.cat.php cat
19 | * (Smarty online manual)
20 | * @author Uwe Tews
21 | *
22 | * @param array $params parameters
23 | *
24 | * @return string with compiled code
25 | */
26 | function smarty_modifiercompiler_cat($params)
27 | {
28 | return '(' . implode(').(', $params) . ')';
29 | }
30 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.count_characters.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: count_characteres
13 | * Purpose: count the number of characters in a text
14 | *
15 | * @link http://www.smarty.net/manual/en/language.modifier.count.characters.php count_characters (Smarty online manual)
16 | * @author Uwe Tews
17 | *
18 | * @param array $params parameters
19 | *
20 | * @return string with compiled code
21 | */
22 | function smarty_modifiercompiler_count_characters($params)
23 | {
24 | if (!isset($params[1]) || $params[1] != 'true') {
25 | return 'preg_match_all(\'/[^\s]/' . Smarty::$_UTF8_MODIFIER . '\',' . $params[0] . ', $tmp)';
26 | }
27 | if (Smarty::$_MBSTRING) {
28 | return 'mb_strlen(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
29 | }
30 | // no MBString fallback
31 | return 'strlen(' . $params[0] . ')';
32 | }
33 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.count_paragraphs.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: count_paragraphs
13 | * Purpose: count the number of paragraphs in a text
14 | *
15 | * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
16 | * count_paragraphs (Smarty online manual)
17 | * @author Uwe Tews
18 | *
19 | * @param array $params parameters
20 | *
21 | * @return string with compiled code
22 | */
23 | function smarty_modifiercompiler_count_paragraphs($params)
24 | {
25 | // count \r or \n characters
26 | return '(preg_match_all(\'#[\r\n]+#\', ' . $params[0] . ', $tmp)+1)';
27 | }
28 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.count_sentences.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: count_sentences
13 | * Purpose: count the number of sentences in a text
14 | *
15 | * @link http://www.smarty.net/manual/en/language.modifier.count.paragraphs.php
16 | * count_sentences (Smarty online manual)
17 | * @author Uwe Tews
18 | *
19 | * @param array $params parameters
20 | *
21 | * @return string with compiled code
22 | */
23 | function smarty_modifiercompiler_count_sentences($params)
24 | {
25 | // find periods, question marks, exclamation marks with a word before but not after.
26 | return 'preg_match_all("#\w[\.\?\!](\W|$)#S' . Smarty::$_UTF8_MODIFIER . '", ' . $params[0] . ', $tmp)';
27 | }
28 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.count_words.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: count_words
13 | * Purpose: count the number of words in a text
14 | *
15 | * @link http://www.smarty.net/manual/en/language.modifier.count.words.php count_words (Smarty online manual)
16 | * @author Uwe Tews
17 | *
18 | * @param array $params parameters
19 | *
20 | * @return string with compiled code
21 | */
22 | function smarty_modifiercompiler_count_words($params)
23 | {
24 | if (Smarty::$_MBSTRING) {
25 | // return 'preg_match_all(\'#[\w\pL]+#' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
26 | // expression taken from http://de.php.net/manual/en/function.str-word-count.php#85592
27 | return 'preg_match_all(\'/\p{L}[\p{L}\p{Mn}\p{Pd}\\\'\x{2019}]*/' . Smarty::$_UTF8_MODIFIER . '\', ' . $params[0] . ', $tmp)';
28 | }
29 | // no MBString fallback
30 | return 'str_word_count(' . $params[0] . ')';
31 | }
32 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.default.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: default
13 | * Purpose: designate default value for empty variables
14 | *
15 | * @link http://www.smarty.net/manual/en/language.modifier.default.php default (Smarty online manual)
16 | * @author Uwe Tews
17 | *
18 | * @param array $params parameters
19 | *
20 | * @return string with compiled code
21 | */
22 | function smarty_modifiercompiler_default($params)
23 | {
24 | $output = $params[0];
25 | if (!isset($params[1])) {
26 | $params[1] = "''";
27 | }
28 |
29 | array_shift($params);
30 | foreach ($params as $param) {
31 | $output = '(($tmp = @' . $output . ')===null||$tmp===\'\' ? ' . $param . ' : $tmp)';
32 | }
33 |
34 | return $output;
35 | }
36 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.from_charset.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: from_charset
13 | * Purpose: convert character encoding from $charset to internal encoding
14 | *
15 | * @author Rodney Rehm
16 | *
17 | * @param array $params parameters
18 | *
19 | * @return string with compiled code
20 | */
21 | function smarty_modifiercompiler_from_charset($params)
22 | {
23 | if (!Smarty::$_MBSTRING) {
24 | // FIXME: (rodneyrehm) shouldn't this throw an error?
25 | return $params[0];
26 | }
27 |
28 | if (!isset($params[1])) {
29 | $params[1] = '"ISO-8859-1"';
30 | }
31 |
32 | return 'mb_convert_encoding(' . $params[0] . ', "' . addslashes(Smarty::$_CHARSET) . '", ' . $params[1] . ')';
33 | }
34 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.indent.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: indent
13 | * Purpose: indent lines of text
14 | *
15 | * @link http://www.smarty.net/manual/en/language.modifier.indent.php indent (Smarty online manual)
16 | * @author Uwe Tews
17 | *
18 | * @param array $params parameters
19 | *
20 | * @return string with compiled code
21 | */
22 |
23 | function smarty_modifiercompiler_indent($params)
24 | {
25 | if (!isset($params[1])) {
26 | $params[1] = 4;
27 | }
28 | if (!isset($params[2])) {
29 | $params[2] = "' '";
30 | }
31 |
32 | return 'preg_replace(\'!^!m\',str_repeat(' . $params[2] . ',' . $params[1] . '),' . $params[0] . ')';
33 | }
34 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.lower.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: lower
13 | * Purpose: convert string to lowercase
14 | *
15 | * @link http://www.smarty.net/manual/en/language.modifier.lower.php lower (Smarty online manual)
16 | * @author Monte Ohrt
17 | * @author Uwe Tews
18 | *
19 | * @param array $params parameters
20 | *
21 | * @return string with compiled code
22 | */
23 |
24 | function smarty_modifiercompiler_lower($params)
25 | {
26 | if (Smarty::$_MBSTRING) {
27 | return 'mb_strtolower(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
28 | }
29 | // no MBString fallback
30 | return 'strtolower(' . $params[0] . ')';
31 | }
32 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.noprint.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: noprint
13 | * Purpose: return an empty string
14 | *
15 | * @author Uwe Tews
16 | * @return string with compiled code
17 | */
18 | function smarty_modifiercompiler_noprint()
19 | {
20 | return "''";
21 | }
22 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.string_format.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: string_format
13 | * Purpose: format strings via sprintf
14 | *
15 | * @link http://www.smarty.net/manual/en/language.modifier.string.format.php string_format (Smarty online manual)
16 | * @author Uwe Tews
17 | *
18 | * @param array $params parameters
19 | *
20 | * @return string with compiled code
21 | */
22 | function smarty_modifiercompiler_string_format($params)
23 | {
24 | return 'sprintf(' . $params[1] . ',' . $params[0] . ')';
25 | }
26 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.strip.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: strip
13 | * Purpose: Replace all repeated spaces, newlines, tabs
14 | * with a single space or supplied replacement string.
15 | * Example: {$var|strip} {$var|strip:" "}
16 | * Date: September 25th, 2002
17 | *
18 | * @link http://www.smarty.net/manual/en/language.modifier.strip.php strip (Smarty online manual)
19 | * @author Uwe Tews
20 | *
21 | * @param array $params parameters
22 | *
23 | * @return string with compiled code
24 | */
25 |
26 | function smarty_modifiercompiler_strip($params)
27 | {
28 | if (!isset($params[1])) {
29 | $params[1] = "' '";
30 | }
31 |
32 | return "preg_replace('!\s+!" . Smarty::$_UTF8_MODIFIER . "', {$params[1]},{$params[0]})";
33 | }
34 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.strip_tags.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: strip_tags
13 | * Purpose: strip html tags from text
14 | *
15 | * @link http://www.smarty.net/manual/en/language.modifier.strip.tags.php strip_tags (Smarty online manual)
16 | * @author Uwe Tews
17 | *
18 | * @param array $params parameters
19 | *
20 | * @return string with compiled code
21 | */
22 | function smarty_modifiercompiler_strip_tags($params)
23 | {
24 | if (!isset($params[1]) || $params[1] === true || trim($params[1], '"') == 'true') {
25 | return "preg_replace('!<[^>]*?>!', ' ', {$params[0]})";
26 | } else {
27 | return 'strip_tags(' . $params[0] . ')';
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.to_charset.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: to_charset
13 | * Purpose: convert character encoding from internal encoding to $charset
14 | *
15 | * @author Rodney Rehm
16 | *
17 | * @param array $params parameters
18 | *
19 | * @return string with compiled code
20 | */
21 | function smarty_modifiercompiler_to_charset($params)
22 | {
23 | if (!Smarty::$_MBSTRING) {
24 | // FIXME: (rodneyrehm) shouldn't this throw an error?
25 | return $params[0];
26 | }
27 |
28 | if (!isset($params[1])) {
29 | $params[1] = '"ISO-8859-1"';
30 | }
31 |
32 | return 'mb_convert_encoding(' . $params[0] . ', ' . $params[1] . ', "' . addslashes(Smarty::$_CHARSET) . '")';
33 | }
34 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.unescape.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: unescape
13 | * Purpose: unescape html entities
14 | *
15 | * @author Rodney Rehm
16 | *
17 | * @param array $params parameters
18 | *
19 | * @return string with compiled code
20 | */
21 | function smarty_modifiercompiler_unescape($params)
22 | {
23 | if (!isset($params[1])) {
24 | $params[1] = 'html';
25 | }
26 | if (!isset($params[2])) {
27 | $params[2] = '\'' . addslashes(Smarty::$_CHARSET) . '\'';
28 | } else {
29 | $params[2] = "'" . $params[2] . "'";
30 | }
31 |
32 | switch (trim($params[1], '"\'')) {
33 | case 'entity':
34 | case 'htmlall':
35 | if (Smarty::$_MBSTRING) {
36 | return 'mb_convert_encoding(' . $params[0] . ', ' . $params[2] . ', \'HTML-ENTITIES\')';
37 | }
38 |
39 | return 'html_entity_decode(' . $params[0] . ', ENT_NOQUOTES, ' . $params[2] . ')';
40 |
41 | case 'html':
42 | return 'htmlspecialchars_decode(' . $params[0] . ', ENT_QUOTES)';
43 |
44 | case 'url':
45 | return 'rawurldecode(' . $params[0] . ')';
46 |
47 | default:
48 | return $params[0];
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.upper.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: lower
13 | * Purpose: convert string to uppercase
14 | *
15 | * @link http://smarty.php.net/manual/en/language.modifier.upper.php lower (Smarty online manual)
16 | * @author Uwe Tews
17 | *
18 | * @param array $params parameters
19 | *
20 | * @return string with compiled code
21 | */
22 | function smarty_modifiercompiler_upper($params)
23 | {
24 | if (Smarty::$_MBSTRING) {
25 | return 'mb_strtoupper(' . $params[0] . ', \'' . addslashes(Smarty::$_CHARSET) . '\')';
26 | }
27 | // no MBString fallback
28 | return 'strtoupper(' . $params[0] . ')';
29 | }
30 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/modifiercompiler.wordwrap.php:
--------------------------------------------------------------------------------
1 |
12 | * Name: wordwrap
13 | * Purpose: wrap a string of text at a given length
14 | *
15 | * @link http://smarty.php.net/manual/en/language.modifier.wordwrap.php wordwrap (Smarty online manual)
16 | * @author Uwe Tews
17 | *
18 | * @param array $params parameters
19 | * @param $compiler
20 | *
21 | * @return string with compiled code
22 | */
23 | function smarty_modifiercompiler_wordwrap($params, $compiler)
24 | {
25 | if (!isset($params[1])) {
26 | $params[1] = 80;
27 | }
28 | if (!isset($params[2])) {
29 | $params[2] = '"\n"';
30 | }
31 | if (!isset($params[3])) {
32 | $params[3] = 'false';
33 | }
34 | $function = 'wordwrap';
35 | if (Smarty::$_MBSTRING) {
36 | if ($compiler->template->caching && ($compiler->tag_nocache | $compiler->nocache)) {
37 | $compiler->template->required_plugins['nocache']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php';
38 | $compiler->template->required_plugins['nocache']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
39 | } else {
40 | $compiler->template->required_plugins['compiled']['wordwrap']['modifier']['file'] = SMARTY_PLUGINS_DIR . 'shared.mb_wordwrap.php';
41 | $compiler->template->required_plugins['compiled']['wordwrap']['modifier']['function'] = 'smarty_mb_wordwrap';
42 | }
43 | $function = 'smarty_mb_wordwrap';
44 | }
45 |
46 | return $function . '(' . $params[0] . ',' . $params[1] . ',' . $params[2] . ',' . $params[3] . ')';
47 | }
48 |
--------------------------------------------------------------------------------
/libs/smarty/plugins/outputfilter.trimwhitespace.php:
--------------------------------------------------------------------------------
1 | .*?#is', $source, $matches, PREG_OFFSET_CAPTURE | PREG_SET_ORDER)) {
31 | foreach ($matches as $match) {
32 | $store[] = $match[0][0];
33 | $_length = strlen($match[0][0]);
34 | $replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
35 | $source = substr_replace($source, $replace, $match[0][1] - $_offset, $_length);
36 |
37 | $_offset += $_length - strlen($replace);
38 | $_store ++;
39 | }
40 | }
41 |
42 | // Strip all HTML-Comments
43 | // yes, even the ones in
50 | {/literal}
51 | {/if}
52 |
--------------------------------------------------------------------------------
/templates/footer.tpl:
--------------------------------------------------------------------------------
1 |
2 |