├── .gitignore ├── CHANGELOG ├── LICENSE ├── README.md ├── composer.json ├── config ├── config.php.sample ├── constants.php ├── index.html ├── init.php └── langs.php ├── contrib ├── additional_indexes.sql ├── mysql │ └── mysql4.0_compat.diff └── mysql_innodb_fk.sql ├── css.css ├── docs ├── AD_README ├── CREDITS ├── EXCHANGE_5.5_README ├── FAQ ├── IMAP_README ├── INSTALL ├── LDAP_README └── SQL_README ├── functions.js ├── get_attachment.php ├── help.php ├── img ├── blocked_img.png ├── en.blocked_img.png ├── favicon.ico ├── it.blocked_img.png ├── mailzu-x4-192x192-icon.png └── mailzu.gif ├── index.php ├── lang ├── cs.help.php ├── cs.lang.php ├── de.help.php ├── de.lang.php ├── en.help.php ├── en_GB.lang.php ├── en_US.lang.php ├── es.help.php ├── es.lang.php ├── fr.help.php ├── fr.lang.php ├── it.help.php ├── it.lang.php ├── no.help.php ├── no_NB.lang.php ├── pl.help.php ├── pl.lang.php └── pt_BR.lang.php ├── lib ├── Quarantine.lib.php ├── autoload.php ├── classes │ ├── AmavisdEngine.class.php │ ├── Auth.class.php │ ├── CmnFns.class.php │ ├── DBAuth.class.php │ ├── DBEngine.class.php │ ├── ExchAuth.class.php │ ├── IMAPAuth.class.php │ ├── LDAPEngine.class.php │ ├── Link.class.php │ ├── MailEngine.class.php │ ├── MailMime.class.php │ ├── Pager.class.php │ ├── Template.class.php │ └── mailzuMailer.class.php ├── htmlfilter.lib.php ├── index.html └── pear │ ├── Mail │ ├── mime.php │ ├── mimeDecode.php │ └── mimePart.php │ ├── Net │ └── Socket.php │ ├── OS │ └── Guess.php │ ├── PEAR.php │ ├── PEAR │ ├── Builder.php │ ├── ChannelFile.php │ ├── ChannelFile │ │ └── Parser.php │ ├── Command.php │ ├── Command │ │ ├── Auth.php │ │ ├── Auth.xml │ │ ├── Build.php │ │ ├── Build.xml │ │ ├── Channels.php │ │ ├── Channels.xml │ │ ├── Common.php │ │ ├── Config.php │ │ ├── Config.xml │ │ ├── Install.php │ │ ├── Install.xml │ │ ├── Mirror.php │ │ ├── Mirror.xml │ │ ├── Package.php │ │ ├── Package.xml │ │ ├── Pickle.php │ │ ├── Pickle.xml │ │ ├── Registry.php │ │ ├── Registry.xml │ │ ├── Remote.php │ │ ├── Remote.xml │ │ ├── Test.php │ │ └── Test.xml │ ├── Common.php │ ├── Config.php │ ├── Dependency2.php │ ├── DependencyDB.php │ ├── Downloader.php │ ├── Downloader │ │ └── Package.php │ ├── ErrorStack.php │ ├── Exception.php │ ├── Frontend.php │ ├── Frontend │ │ └── CLI.php │ ├── Installer.php │ ├── Installer │ │ ├── Role.php │ │ └── Role │ │ │ ├── Cfg.php │ │ │ ├── Cfg.xml │ │ │ ├── Common.php │ │ │ ├── Data.php │ │ │ ├── Data.xml │ │ │ ├── Doc.php │ │ │ ├── Doc.xml │ │ │ ├── Ext.php │ │ │ ├── Ext.xml │ │ │ ├── Man.php │ │ │ ├── Man.xml │ │ │ ├── Php.php │ │ │ ├── Php.xml │ │ │ ├── Script.php │ │ │ ├── Script.xml │ │ │ ├── Src.php │ │ │ ├── Src.xml │ │ │ ├── Test.php │ │ │ ├── Test.xml │ │ │ ├── Www.php │ │ │ └── Www.xml │ ├── PackageFile.php │ ├── PackageFile │ │ ├── Generator │ │ │ ├── v1.php │ │ │ └── v2.php │ │ ├── Parser │ │ │ ├── v1.php │ │ │ └── v2.php │ │ ├── v1.php │ │ ├── v2.php │ │ └── v2 │ │ │ ├── Validator.php │ │ │ └── rw.php │ ├── Packager.php │ ├── Proxy.php │ ├── REST.php │ ├── REST │ │ ├── 10.php │ │ ├── 11.php │ │ └── 13.php │ ├── Registry.php │ ├── RunTest.php │ ├── Task │ │ ├── Common.php │ │ ├── Postinstallscript.php │ │ ├── Postinstallscript │ │ │ └── rw.php │ │ ├── Replace.php │ │ ├── Replace │ │ │ └── rw.php │ │ ├── Unixeol.php │ │ ├── Unixeol │ │ │ └── rw.php │ │ ├── Windowseol.php │ │ └── Windowseol │ │ │ └── rw.php │ ├── Validate.php │ ├── Validator │ │ └── PECL.php │ └── XMLParser.php │ └── license.txt ├── log └── .gitignore ├── messagesAdmin.php ├── messagesIndex.php ├── messagesPending.php ├── messagesPendingAdmin.php ├── messagesProcessing.php ├── messagesSummary.php ├── read_mail.php ├── read_original.php ├── scripts └── mailzu-db-cleanup.php ├── sendErrorReport.php ├── send_mail.php ├── summary.php └── templates ├── auth.template.php ├── common.template.php ├── index.html ├── quarantine.template.php ├── sendmail.template.php ├── summary.template.php └── viewmail.template.php /.gitignore: -------------------------------------------------------------------------------- 1 | # composer stuff 2 | /vendor/ 3 | composer.lock 4 | # below ignores the config in the right place 5 | /config/config.php 6 | # this should work for everywhere placed config.php 7 | config.php 8 | 9 | # experiments that left a backup 10 | *.bak.php 11 | 12 | # these are private files for a private implementation 13 | /msgview.php 14 | msgview.php 15 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnanet/mailzu/84f409cd7898f540d7963ae2cb99e0f33f5f576b/CHANGELOG -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | mailzu-ng 2 | ====== 3 | 4 | Rewritten MailZu-ng 5 | Compatible PHP 7.2+, PHP-PDO 6 | 7 | Please use `composer install` to load phpmailer package, and generate class autoloader 8 | 9 | based on gnanet's fork from https://github.com/zedzedtop/mailzu 10 | based on zedzedtop's fork from http://sourceforge.net/projects/mailzu/ 11 | 12 | MailZu is a simple and intuitive web interface to manage Amavisd-new quarantine. Users can view their own quarantine, release/delete messages or request the release of messages. MailZu is written in PHP and requires Amavisd-new version greater than 2.7.0 13 | 14 | 15 | MailZu is a quarantine management interface for amavisd-new 16 | ( http://www.ijs.si/software/amavisd/ ). 17 | 18 | It provides users and administrators access to email that is suspected to be spam or contain banned contents and gives users the ability to release, request, or delete these messages from their quarantine. 19 | 20 | Users can access their personal quarantine by authenticating to various pre-existent backends such as LDAP ( or Active Directory ) or any PHP PDO supported database. 21 | 22 | This rewrite includes changes that enable displaying utf8 content, releasing spam from localhost, German language, Polish language, full database schema for MySQL 5.6 with InnoDB storage, and amavisd-new 2.7.0 23 | 24 | This rewrite is compatible with PHP 7, tested with PHP 7.2, 25 | 26 | *Planned changes are: cleanup code, removing obsolete content, and scripts; replacing HTML tables with CSS tables; creating mobile view using CSS media queries; updated database cleanup script; script that sends daily report about quarantined items to users; step-by-step installation guide for a common postfix-dovecot-amavis-spamassassin setup* 27 | 28 | See the INSTALL file in the docs/ directory included with this distribution. 29 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "gnanet/mailzu-ng", 3 | "description": "mailzu-ng - rewrite of MailZu to be compatible with PHP 7.2+ use PDO for database", 4 | "homepage": "https://github.com/gnanet/mailzu", 5 | "readme": "README.md", 6 | "type": "project", 7 | "authors": [ 8 | { 9 | "name": "GNa", 10 | "email": "gna@r-us.hu" 11 | } 12 | ], 13 | "minimum-stability": "stable", 14 | "require": { 15 | "php": ">=7.2", 16 | "ext-pdo": "*", 17 | "phpmailer/phpmailer": "^6.5" 18 | }, 19 | "autoload": { 20 | "classmap": [ "lib/classes/" ], 21 | "files": [ "lib/htmlfilter.lib.php", "lib/Quarantine.lib.php" ] 22 | } 23 | 24 | } 25 | -------------------------------------------------------------------------------- /config/constants.php: -------------------------------------------------------------------------------- 1 | 17 | -------------------------------------------------------------------------------- /config/index.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnanet/mailzu/84f409cd7898f540d7963ae2cb99e0f33f5f576b/config/index.html -------------------------------------------------------------------------------- /config/init.php: -------------------------------------------------------------------------------- 1 | 6 | * @version 2021-11-08 7 | * @package mailzu-ng 8 | * 9 | * Copyright (C) 2021 mailzu-ng 10 | * License: GPL, see LICENSE 11 | */ 12 | 13 | /** 14 | * Please refer to readme.html and LICENSE for any additional information 15 | * 16 | * Copyright (C) 2003 - 2021 MailZu 17 | * This program is free software; you can redistribute it and/or modify it 18 | * under the terms of the GNU General Public License as published by the 19 | * Free Software Foundation; either version 2 of the License, or (at your option) 20 | * any later version. 21 | * 22 | * This program is distributed in the hope that it will be useful, but WITHOUT 23 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 24 | * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. 25 | * 26 | * You should have received a copy of the GNU General Public License along with 27 | * this program; if not, write to the 28 | * Free Software Foundation, Inc. 29 | * 59 Temple Place 30 | * Suite 330 31 | * Boston, MA 32 | * 02111-1307 33 | * USA 34 | */ 35 | 36 | /********************************************************************/ 37 | /* DO NOT CHANGE THIS SECTION */ 38 | /********************************************************************/ 39 | // Start the session (do not edit!) 40 | if (! headers_sent()) { 41 | if(session_status() !== PHP_SESSION_ACTIVE) session_start(); 42 | } 43 | 44 | $conf['app']['version'] = '0.11.mailzu-ng-php72-b1e7e3e+1'; 45 | $conf['app']['footlink'] = 'https://github.com/gnanet/mailzu'; 46 | 47 | include_once('constants.php'); 48 | include_once('langs.php'); 49 | 50 | if ($lang = determine_language()) { // Functions exist in the langs.php file 51 | set_language($lang); 52 | load_language_file($lang); 53 | } 54 | 55 | 56 | ?> 57 | -------------------------------------------------------------------------------- /contrib/additional_indexes.sql: -------------------------------------------------------------------------------- 1 | -- Index the content field, improves summary queries 2 | CREATE INDEX msgs_idx_content ON msgs (content); 3 | -------------------------------------------------------------------------------- /contrib/mysql/mysql4.0_compat.diff: -------------------------------------------------------------------------------- 1 | Index: lib/DBEngine.class.php 2 | =================================================================== 3 | --- lib/DBEngine.class.php (revision 176) 4 | +++ lib/DBEngine.class.php (working copy) 5 | @@ -316,11 +316,18 @@ 6 | $msg_status = $cur_msg_array[0]; 7 | if ($msg_status['rs'] == 'p' && $flag == 'v') return true; 8 | 9 | + $query0 = 'SELECT id FROM maddr WHERE email=?'; 10 | + $values0 = array($mail_rcpt); 11 | + $q0 = $this->db->prepare($query0); 12 | + $result0 = $this->db->execute($q0, $values0); 13 | + $rs0 = $result0->fetchRow(); 14 | + $id = $rs0['id']; 15 | + 16 | $query = 'UPDATE msgrcpt SET rs=?' 17 | . ' WHERE mail_id=?' 18 | - . ' AND rid=(SELECT id FROM maddr WHERE email=?)'; 19 | + . ' AND rid=?'; 20 | 21 | - $values = array($flag, $mail_id, $mail_rcpt); 22 | + $values = array($flag, $mail_id, $id); 23 | 24 | // Prepare query 25 | $q = $this->db->prepare($query); 26 | @@ -329,6 +336,8 @@ 27 | // Check if error 28 | $this->check_for_error($result, $query); 29 | 30 | + $result0->free(); 31 | + 32 | return true; 33 | } 34 | 35 | -------------------------------------------------------------------------------- /docs/AD_README: -------------------------------------------------------------------------------- 1 | Active Directory Autentication Settings 2 | ---------------------------------------- 3 | 4 | To configure MailZu to authenticate users against Active Directory. 5 | Edit the config/config.php and tailor the variables mentioned here for your 6 | environment. 7 | 8 | // Set an authentication method: 'ldap','ad', or 'sql' 9 | $conf['auth']['serverType'] = 'ad'; 10 | 11 | Set the AD host(s) and search base 12 | 13 | // List of AD Domain controllers 14 | $conf['auth']['ad_hosts'] = array( 'dc1.example.com' ); 15 | // if set to true, LDAP connection over SSL (PHP 4.0.4 minimum) 16 | // if set to false or not set, unencrypted LDAP connection on port 389 17 | $conf['auth']['ad_ssl'] = false; 18 | 19 | // AD base dn, e.g. 'dc=example,dc=com' 20 | $conf['auth']['ad_basedn'] = 'dc=example,dc=com'; 21 | 22 | Set the Active Directory domain: 23 | 24 | // AD domain, e.g. 'example.com' 25 | $conf['auth']['ad_domain'] = 'example.com'; 26 | 27 | Set the attribute usually used to identify a user in Active Directory: 28 | 29 | // AD attribute used to identify a person 30 | $conf['auth']['ad_user_identifier'] = 'samaccoutname'; 31 | 32 | Now we must set the login format. For AD the default is the 'samaccountname' 33 | attribute, or if you want a fully qualified email address as the login, it 34 | could be 'mail'. 35 | 36 | // AD attribute used as login, e.g. 'samaccountname' or 'mail' 37 | $conf['auth']['ad_login'] = 'samaccountname'; 38 | 39 | At the login page of MailZu, with this setting the user would use the login 40 | 'user', or if the configuration variable was set to the 'mail' attribute, the 41 | login would be 'user@example.com'. 42 | 43 | These two attributes are enough to be authenticated to the MailZu interface, 44 | but the third attribute is what determines which messages the authenticated 45 | user is permitted to view. This attribute is the final recipient address. It is 46 | the email address that amavisd-new reports as the envelope recipient. 47 | 48 | For example, if the login used was 'user', than there must be an attribute or 49 | field that determines the email address associated with this user. Even if the 50 | login was 'user@example.com' the third attribute may or may not be the same. 51 | The address might have been aliased to an internal address 52 | 'user@internal.example.com'. 53 | 54 | // AD mail attribute used as the final recipient address 55 | // Could be the actual mail attribute or another attribute 56 | // (in the latter case look for the "%m" token in the ldap query filter in 57 | // amavisd.conf) 58 | $conf['auth']['ad_mailAttr'] = 'mail'; 59 | 60 | If the attribute listed for the login format is not the same as the binding 61 | username, we must be able to search the directory. The settings below binds 62 | using this account to search the directory. AD does not allow anonymous 63 | binds. 64 | 65 | $conf['auth']['ad_searchUsername'] = 'manager'; 66 | $conf['auth']['ad_searchPassword'] = 'secret'; 67 | 68 | If you want to specify the name of the user in the welcome message, you need to set the parameter below. AD attribute such as 'g 69 | ivenName', 'cn' or 'displayName' can be used: 70 | $conf['auth']['ad_name'] = 'givenName'; 71 | -------------------------------------------------------------------------------- /docs/CREDITS: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnanet/mailzu/84f409cd7898f540d7963ae2cb99e0f33f5f576b/docs/CREDITS -------------------------------------------------------------------------------- /docs/EXCHANGE_5.5_README: -------------------------------------------------------------------------------- 1 | Exchange 5.5 Autentication Settings 2 | ----------------------------------- 3 | 4 | To configure MailZu to authenticate users against Exchange 5.5, 5 | edit the config/config.php and tailor the variables mentioned here for your 6 | environment. 7 | 8 | // Set an authentication method: 'ldap','ad', 'sql' or 'exchange' (Exchange 5.5) 9 | $conf['auth']['serverType'] = 'exchange'; 10 | 11 | 12 | These three attributes are enough to be authenticated to the MailZu interface: 13 | 14 | // Exchange 5.5 server host and IMAP port 15 | $conf['auth']['exch_host'] = '10.1.1.20:143'; 16 | 17 | 18 | // Exchange's LDAP server, it usually has the same IP as the Exchange server 19 | $conf['auth']['exch_ldap'] = '10.1.1.20'; 20 | 21 | 22 | // Exchange default NT domain 23 | $conf['auth']['exch_domain'] = 'mycorp'; 24 | 25 | 26 | At the MailZu login, enter the user NT login as username. 27 | This code may not work if the user's Exchange alias is different from the NT login. 28 | 29 | Thanks to Bogdan Baliuci for his code contribution. 30 | -------------------------------------------------------------------------------- /docs/FAQ: -------------------------------------------------------------------------------- 1 | 2 | Frequently Asked Questions 3 | ======================================= 4 | 5 | 1) What is MailZu? 6 | 7 | MailZu is a quarantine management interface for amavisd-new. It allows 8 | users to view their quarantined items and request release (for suspect malware), 9 | release, or mark them for deletion. 10 | 11 | 2) What version of amavisd-new do I need? 12 | 13 | MailZu will work with amavisd-new greater than 2.3.0. 14 | 15 | 3) Does MailZu support multiple amavisd-new instances? 16 | 17 | Yes. If every amavisd-new instance in your environment stores its data into 18 | the same SQL database there should be no problem. The only limitation is that 19 | the AM.PDP protocol must listen on the same port for each amavisd-new 20 | instance. 21 | 22 | 4) Do I have to configure amavisd-new to quarantine email to SQL? 23 | 24 | No. MailZu does not require that the actual message bodies be kept in SQL. 25 | Release is handled by amavisd-new, so MailZu need not be aware of the location 26 | of the quarantine. Quarantine to SQL is only neccessary if you want your users 27 | to be able to view spam in the MailZu interface, otherwise they will only see 28 | the basic headers of the quarantined message. 29 | 30 | 5) Why do some or all messages in the MailZu message index not viewable? 31 | 32 | The reason might be that email is not quarantined to SQL. This can be enabled 33 | by setting these variables in amavisd-new: 34 | 35 | $banned_files_quarantine_method = 'sql:'; 36 | $spam_quarantine_method = 'sql:'; 37 | 38 | 6) Releasing messages does not seem to work. What is wrong? 39 | 40 | There may be a couple of reasons for this behavior. The most common problems 41 | is that PHP is not built with sockets enabled ( --enable-sockets ), or it is 42 | a network related issue. 43 | 44 | The first problem is easy to diagnose and fix. If releasing emails is still 45 | not working, then we have to diagnose the network problem. 46 | 47 | It is important to understand that in order for MailZu to support more than 48 | one amavisd-new instance, it must connect to the appropriate host. The correct 49 | host is retrieved from the SQL record inserted by amavisd-new. Check the 'host' 50 | column of the 'msgs' table. Please make sure that you can connect to the AM.PDP 51 | port of the host listed in that record from the host that runs MailZu. 52 | 53 | user@mailzuhost# telnet 54 | 55 | If a connection is not made, then review your amavisd-new configuration regarding 56 | the interfaces it listens on, and the ACLs regarding connecting clients. Be 57 | careful, the AM.PDP protocol does not send a greeting or any data whatsoever on 58 | a successful connection. It may appear that a connecion did not work, when in fact 59 | it did. 60 | 61 | 7) Where can I get support? 62 | 63 | If you are having a problem with MailZu and the solution is not obvious, take 64 | a look at the mailing list archive at: 65 | 66 | http://sourceforge.net/mailarchive/forum.php?forum=mailzu-users 67 | 68 | and/or subscribe at this URL: 69 | 70 | https://lists.sourceforge.net/lists/listinfo/mailzu-users 71 | -------------------------------------------------------------------------------- /docs/IMAP_README: -------------------------------------------------------------------------------- 1 | IMAP Autentication Settings 2 | --------------------------- 3 | 4 | To configure MailZu to authenticate users against IMAP, 5 | edit the config/config.php and tailor the variables mentioned here for your 6 | environment. 7 | 8 | Select the IMAP authentication method: 9 | 10 | /* Options are: 11 | ldap -> Standard LDAP server, e.g. OpenLDAP 12 | ad -> MS Active Directory 13 | sql -> PHP PEAR compatible database 14 | exchange -> MS Exchange 5.5 15 | imap -> IMAP protocol 16 | */ 17 | $conf['auth']['serverType'] = 'imap'; 18 | 19 | 20 | These three attributes are enough to be authenticated to the MailZu interface: 21 | 22 | /*** IMAP Authentication Settings ***/ 23 | // List of IMAP servers and ports (e.g.: 10.1.1.20:143) 24 | $conf['auth']['imap_hosts'] = array( 'imap.example.com:993' ); 25 | 26 | // IMAP type 27 | /* Options are: 28 | imap -> default 29 | imaptls -> do not do start-TLS to encrypt the session, even with servers that support it 30 | imapssl -> use the Secure Socket Layer to encrypt the session 31 | imapcert -> use the Secure Socket Layer to encrypt the session, 32 | do not validate certificates from TLS/SSL server, needed if server uses self-signed certificates 33 | */ 34 | $conf['auth']['imap_type'] = 'imapssl'; 35 | 36 | // Domain name part of the email address, (e.g.: example.com) 37 | $conf['auth']['imap_domain_name'] = 'example.com'; 38 | -------------------------------------------------------------------------------- /docs/LDAP_README: -------------------------------------------------------------------------------- 1 | LDAP Autentication Settings 2 | ------------------------------- 3 | 4 | To configure MailZu to authenticate users against LDAP. 5 | Edit the config/config.php and tailor the variables mentioned here for your 6 | environment. 7 | 8 | // Set an authentication method: 'ldap','ad', or 'sql' 9 | $conf['auth']['serverType'] = 'ldap'; 10 | 11 | Set the LDAP host(s) and search base 12 | 13 | // List of LDAP servers 14 | $conf['auth']['ldap_hosts'] = array( 'ldaphost' ); 15 | // if set to true, LDAP connection over SSL (PHP 4.0.4 minimum) 16 | // if set to false or not set, unencrypted LDAP connection on port 389 17 | $conf['auth']['ldap_ssl'] = false; 18 | 19 | // LDAP base dn, e.g. 'dc=example,dc=com' 20 | $conf['auth']['ldap_basedn'] = 'dc=example,dc=com'; 21 | 22 | Set the LDAP attribute used for the RDN to identify a person: 23 | 24 | // LDAP attribute used for the RDN to identify a person 25 | // For instance if the DN for a given user is uid=joesmith,ou=people,dc=example,dc=com 26 | // the attribute would be 'uid' 27 | $conf['auth']['ldap_user_identifier'] = 'uid'; 28 | 29 | Set the container where all users are kept. If users are stored in multiple 30 | containers leave this option blank. 31 | 32 | // Container where all users are kept, e.g. 'ou=people' 33 | // If you have users in multiple containers, leave this option blank. 34 | // In this particular case you will need to allow anonymous binding 35 | // or specify a user/password to bind with 36 | $conf['auth']['ldap_user_container'] = 'ou=people'; 37 | 38 | Now we must set the login format. For LDAP it is usually the 'uid' 39 | attribute, or if you want a fully qualified email address as the login, it 40 | could be 'mail'. 41 | 42 | // LDAP attribute used as login, e.g. 'uid', 'mail' or 'uidNumber' 43 | $conf['auth']['ldap_login'] = 'uid'; 44 | 45 | At the login page of MailZu, with this setting the user would use the login 46 | 'user', or if the configuration variable was set to the 'mail' attribute, the 47 | login would be 'user@example.com'. 48 | 49 | These two attributes are enough to be authenticated to the MailZu interface, 50 | but the third attribute is what determines which messages the authenticated 51 | user is permitted to view. This configuration variable is a list of 52 | attributes that contain recipient addresses. In most cases this will be a 53 | list with one item such as the attribute 'mail'. But if you want to include 54 | more address you can add more attribute names to the list. 55 | 56 | For example, if the login used was 'user', than there must be an attribute or 57 | field that determines the email address associated with this user. Even if the 58 | login was 'user@example.com' the third attribute may or may not be the same. 59 | The address might have been aliased to an internal address 60 | 'user@internal.example.com'. 61 | 62 | // LDAP mail attributes used as the final recipient address 63 | // Could be the actual mail attribute or another attribute 64 | // (in the latter case look for the "%m" token in the ldap query filter in 65 | // amavisd.conf) 66 | $conf['auth']['ldap_mailAttr'] = array('mailRoutingAddress'); 67 | 68 | If the attribute listed for the login format is not the same as the binding 69 | username or if no user container is not specified, we must be able to search the directory. 70 | The settings below binds using this account to search the directory. 71 | Set them to empty string ('') for anonymous bind. 72 | 73 | $conf['auth']['ldap_searchUsername'] = 'manager'; 74 | $conf['auth']['ldap_searchPassword'] = 'secret'; 75 | 76 | If you want to specify the name of the user in the welcome message, you need to set the parameter below. LDAP attribute such as 'givenName', 'cn' or 'displayName' can be used: 77 | $conf['auth']['ldap_name'] = 'givenName'; 78 | -------------------------------------------------------------------------------- /docs/SQL_README: -------------------------------------------------------------------------------- 1 | SQL Autentication Settings 2 | ------------------------------- 3 | 4 | To configure MailZu to authenticate users against a PDO compatible SQL 5 | database... 6 | 7 | // Set an authentication method: 'ldap','ad', or 'sql' 8 | $conf['auth']['serverType'] = 'sql'; 9 | 10 | Set the type of database to authenticate to... 11 | /*** Database Authentication Settings ***/ 12 | // Database type to be used by PDO 13 | /* Options are: 14 | mysql -> MySQL 15 | pgsql -> PostgreSQL 16 | */ 17 | $conf['auth']['dbType'] = 'mysql'; 18 | 19 | Set the SQL host with optional port 20 | 21 | // Database host specification (hostname[:port]) 22 | $conf['auth']['dbHostSpec'] = 'dbhost'; 23 | 24 | Specify the credentials needed to access the database 25 | 26 | // Database user who can access the auth database 27 | $conf['auth']['dbUser'] = 'user'; 28 | 29 | // Password for above user to auth database 30 | $conf['auth']['dbPass'] = 'pass'; 31 | 32 | // Name for auth database 33 | $conf['auth']['dbName'] = 'dbname'; 34 | 35 | // Name for auth table that contains usernames and passwords 36 | $conf['auth']['dbTable'] = 'dbtablename'; 37 | 38 | // Name of the 'first name' or 'full name' field of the SQL table 39 | // If such a field does not exist, leave it blank 40 | $conf['auth']['dbTableName'] = 'givennamefield'; 41 | 42 | Now we must set the login format. 43 | 44 | // Name of the Username field of the SQL table 45 | $conf['auth']['dbTableUsername'] = 'usernamefield'; 46 | 47 | At the login page of MailZu, with this setting the user would use the value 48 | listed in the above field, which may or may not be the fully qualified email 49 | address. 50 | 51 | Now we must set the field for the password. 52 | 53 | // Name of the password field of the SQL table 54 | $conf['auth']['dbTablePassword'] = 'passwordfield'; 55 | 56 | Is the password stored in the database the MD5 digest? 57 | 58 | // true = passwords are stored md5 encrypted in database 59 | // false = passwords are stored cleartext in database 60 | $conf['auth']['dbIsMd5'] = true; 61 | 62 | These two attributes are enough to be authenticated to the MailZu interface, 63 | but the third attribute is what determines which messages the authenticated 64 | user is permitted to view. This attribute is the final recipient address. It is 65 | the email address that amavisd-new reports as the envelope recipient. 66 | 67 | For example, if the login used was 'user', than there must be an attribute or 68 | field that determines the email address associated with this user. Even if the 69 | login was 'user@example.com' the third attribute may or may not be the same. 70 | The address might have been aliased to an internal address 71 | 'user@internal.example.com'. 72 | 73 | // Name of the 'mail address' field of the SQL table 74 | $conf['auth']['dbTableMail'] = 'mailaddress'; 75 | -------------------------------------------------------------------------------- /functions.js: -------------------------------------------------------------------------------- 1 | // Last modified: 03-04-05 2 | 3 | function checkBrowser() { 4 | if ((navigator.appName.indexOf("Netscape") != -1) && (parseFloat(navigator.appVersion) <= 4.79)) { 5 | newWin = window.open("", "message", "height=200,width=300"); 6 | newWin.document.writeln("
This system is optimized for Netscape version 6.0 or higher.
" + 7 | "Please visit Netscape.com to obtain an update."); 8 | newWin.document.close(); 9 | } 10 | } 11 | 12 | function help(file) { 13 | window.open("help.php#" + file, "", "width=500,height=500,scrollbars"); 14 | void(0); 15 | } 16 | 17 | function isIE() { 18 | return document.all; 19 | } 20 | 21 | function resOver(cell, color) { 22 | cell.style.backgroundColor = color; 23 | cell.style.cursor = 'hand' 24 | } 25 | 26 | function resOut(cell, color) { 27 | cell.style.backgroundColor = color; 28 | } 29 | 30 | function showHideSearch(element) { 31 | var expires = new Date(); 32 | var time = expires.getTime() + 2592000000; 33 | expires.setTime(time); 34 | var showHide = ""; 35 | if (document.getElementById(element).style.display == "none") { 36 | document.getElementById(element).style.display = 'block'; 37 | if (document.getElementById(element + '_closed')) { 38 | document.getElementById(element + '_closed').style.display = 'none'; 39 | document.getElementById(element + '_td').style.width = '16vw'; 40 | } 41 | showHide = "show"; 42 | } else { 43 | document.getElementById(element).style.display = 'none'; 44 | if (document.getElementById(element + '_closed')) { 45 | document.getElementById(element + '_closed').style.display = 'block'; 46 | document.getElementById(element + '_td').style.width = '3vw'; 47 | } 48 | showHide = "hide"; 49 | } 50 | 51 | document.cookie = element + "=" + showHide + ";expires=" + expires.toGMTString(); 52 | } 53 | 54 | function showHideFullHeaders(table) { 55 | var expires = new Date(); 56 | var time = expires.getTime() + 2592000000; 57 | expires.setTime(time); 58 | var showHide = ""; 59 | var cnames = 'visiblehidden'; 60 | var i = 0; 61 | var rows = document.getElementById(table).rows; 62 | 63 | for (i = 0; i < rows.length; i++) { 64 | rows[i].className = cnames.replace(rows[i].className, ''); 65 | showHide = rows[i].className; 66 | } 67 | 68 | document.cookie = table + "=" + showHide + ";EXpires=" + expires.toGMTString(); 69 | } 70 | 71 | function changeLanguage(opt) { 72 | var expires = new Date(); 73 | var time = expires.getTime() + 2592000000; 74 | var cpath = document.location.href.replace(/\\/g, '/').replace(/\/[^\/]*$/, '').replace(/\\/g, '/').replace(/.*\//, ''); 75 | expires.setTime(time); 76 | document.cookie = "lang=" + opt.options[opt.selectedIndex].value + ";expires=" + expires.toGMTString() + ";path=/" + cpath; 77 | document.location.href = document.URL; 78 | } 79 | 80 | function clickTab(tabid, panel_to_show) { 81 | document.getElementById(tabid.getAttribute("id")).className = "tab-selected"; 82 | rows = document.getElementById("tab-container").getElementsByTagName("td"); 83 | for (i = 0; i < rows.length; i++) { 84 | if (rows[i].className == "tab-selected" && rows[i] != tabid) { 85 | rows[i].className = "tab-not-selected"; 86 | } 87 | } 88 | 89 | div_to_display = document.getElementById(panel_to_show); 90 | div_to_display.style.display = isIE() ? "inline" : "table"; 91 | divs = document.getElementById("main-tab-panel").getElementsByTagName("div"); 92 | 93 | for (i = 0; i < divs.length; i++) { 94 | // only hide panels with prefix "pnl" 95 | if (divs[i] != div_to_display && divs[i].getAttribute("id").substring(0, 3) == "pnl") { 96 | divs[i].style.display = "none"; 97 | } 98 | } 99 | } 100 | 101 | function showHideMinMax(chk) { 102 | document.getElementById("minH").disabled = document.getElementById("minM").disabled = document.getElementById("maxH").disabled = document.getElementById("maxM").disabled = chk.checked 103 | } 104 | 105 | function CheckAll(frm) { 106 | var elmts = frm.elements; 107 | for (i = 0; i < elmts.length; i++) { 108 | if (elmts[i].type == "checkbox") { 109 | elmts[i].checked = true; 110 | ColorRow(elmts[i], "lightyellow"); 111 | } 112 | } 113 | } 114 | 115 | function CheckNone(frm) { 116 | var elmts = frm.elements; 117 | for (i = 0; i < elmts.length; i++) { 118 | elmts[i].checked = false; 119 | ColorRow(elmts[i], "lightyellow"); 120 | } 121 | } 122 | 123 | 124 | function ColorRow(obj, color) { 125 | obj.checked == true ? bg = color : bg = ''; 126 | while (obj.nodeName != 'TR') { 127 | obj = obj.parentNode; 128 | } 129 | obj.style.backgroundColor = bg; 130 | } 131 | 132 | function ViewOriginal(enc_mail_id, enc_recip_email) { 133 | var url = "read_original.php?mail_id=" + enc_mail_id + "&recip_email=" + enc_recip_email; 134 | window.open(url, 'OriginalMessage', 'width=800,height=600,scrollbars=1'); 135 | } 136 | 137 | -------------------------------------------------------------------------------- /get_attachment.php: -------------------------------------------------------------------------------- 1 | 7 | * @version 2021-11-08 8 | * @package mailzu-ng 9 | * 10 | * Copyright (C) 2021 mailzu-ng 11 | * License: GPL, see LICENSE 12 | */ 13 | 14 | /** 15 | * Include autoloader 16 | */ 17 | include_once('lib/autoload.php'); 18 | 19 | if (!Auth::is_logged_in()) { 20 | Auth::print_login_msg(); // Check if user is logged in 21 | } 22 | 23 | $mail_id = CmnFns::get_mail_id(); 24 | $content_type = CmnFns::getGlobalVar('ctype', GET); 25 | $recip_email = CmnFns::getGlobalVar('recip_email', GET); 26 | $query_string = CmnFns::querystring_exclude_vars(array('mail_id', 'recip_email')); 27 | 28 | if (!Auth::isMailAdmin() && !in_array($recip_email, $_SESSION['sessionMail'])) { 29 | CmnFns::do_error_box(translate('Access Denied')); 30 | } else { 31 | 32 | $m = new MailEngine($mail_id, $recip_email); 33 | 34 | if (!$m->msg_found) { 35 | CmnFns::do_error_box(translate('Message Unavailable')); 36 | 37 | } else { 38 | 39 | MailMime::MsgParseBody($m->struct, true); 40 | 41 | if (isset($fileContent[$_GET['fileid']])) { 42 | 43 | if (isset($_GET['d_inline'])) { 44 | header('Content-Type: '.$fileContent[$_GET['fileid']]['ctype']); 45 | header("Content-Transfer-Encoding: Binary"); 46 | echo $fileContent[$_GET['fileid']]['body']; 47 | exit; 48 | } else if (isset($_GET['virustotal'])) { 49 | header('Location: https://www.virustotal.com/#/file/' . hash('sha256', $fileContent[$_GET['fileid']]) . '/detection'); 50 | exit; 51 | } else { 52 | header('Content-Type: application/octet-stream'); 53 | header("Content-Transfer-Encoding: Binary"); 54 | header("Content-disposition: attachment; filename=\"" . basename($filelist[$_GET['fileid']]) . "\""); 55 | echo $fileContent[$_GET['fileid']]; 56 | } 57 | } else 58 | echo "Error: Attachment not found"; 59 | 60 | } 61 | } 62 | 63 | -------------------------------------------------------------------------------- /help.php: -------------------------------------------------------------------------------- 1 | 8 | * @version 2021-11-08 9 | * @package mailzu-ng 10 | * 11 | * Copyright (C) 2021 mailzu-ng 12 | * License: GPL, see LICENSE 13 | */ 14 | 15 | include_once('config/config.php'); 16 | 17 | global $languages; 18 | global $lang; 19 | global $charset; 20 | if (file_exists('css.css')) { 21 | $path = ''; 22 | } 23 | 24 | echo "\n"; 25 | ?> 26 | 28 | 30 | 31 | MailZu <?php echo translate('Help') ?> 32 | 33 | 72 | 75 | 76 | 77 | 78 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /img/blocked_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnanet/mailzu/84f409cd7898f540d7963ae2cb99e0f33f5f576b/img/blocked_img.png -------------------------------------------------------------------------------- /img/en.blocked_img.png: -------------------------------------------------------------------------------- 1 | blocked_img.png -------------------------------------------------------------------------------- /img/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnanet/mailzu/84f409cd7898f540d7963ae2cb99e0f33f5f576b/img/favicon.ico -------------------------------------------------------------------------------- /img/it.blocked_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnanet/mailzu/84f409cd7898f540d7963ae2cb99e0f33f5f576b/img/it.blocked_img.png -------------------------------------------------------------------------------- /img/mailzu-x4-192x192-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnanet/mailzu/84f409cd7898f540d7963ae2cb99e0f33f5f576b/img/mailzu-x4-192x192-icon.png -------------------------------------------------------------------------------- /img/mailzu.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnanet/mailzu/84f409cd7898f540d7963ae2cb99e0f33f5f576b/img/mailzu.gif -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | 8 | * @version 2021-11-08 9 | * @package mailzu-ng 10 | * 11 | * Copyright (C) 2021 mailzu-ng 12 | * License: GPL, see LICENSE 13 | */ 14 | 15 | /** 16 | * Include autoloader 17 | */ 18 | include_once('lib/autoload.php'); 19 | 20 | $auth = new Auth(); 21 | $t = new Template(); 22 | $msg = ''; 23 | 24 | $resume = (isset($_POST['resume'])) ? $_POST['resume'] : ''; 25 | 26 | // Logging user out 27 | if (isset($_GET['logout'])) { 28 | $auth->doLogout(); 29 | } else if (isset($_POST['login'])) { 30 | $msg = $auth->doLogin($_POST['email'], $_POST['password'], (isset($_POST['setCookie']) ? 'y' : null), false, $resume, $_POST['language'], isset($_POST['domain']) ? $_POST['domain'] : ''); 31 | } else if (isset($_COOKIE['ID'])) { 32 | $msg = $auth->doLogin($_COOKIE['ID'], '', 'y', $_COOKIE['ID'], $resume); // Check if user has cookies set up. If so, log them in automatically 33 | } 34 | 35 | $t->printHTMLHeader(); 36 | 37 | // Print out logoImage if it exists 38 | echo (!empty($conf['ui']['logoImage'])) 39 | ? '
logo
' 40 | : ''; 41 | 42 | $t->startMain(); 43 | 44 | if (isset($_GET['auth'])) { 45 | $auth->printLoginForm(translate('You are not logged in!'), $_GET['resume']); 46 | } else { 47 | $auth->printLoginForm($msg); 48 | } 49 | 50 | $t->endMain(); 51 | // Print HTML footer 52 | $t->printHTMLFooter(); 53 | ?> 54 | -------------------------------------------------------------------------------- /lib/autoload.php: -------------------------------------------------------------------------------- 1 | 6 | * @version 2024-12-24 7 | * @package mailzu-ng 8 | * 9 | * 10 | * Copyright (C) 2024 mailzu-ng 11 | * License: GPL, see LICENSE 12 | */ 13 | 14 | /** 15 | * Base directory of application 16 | */ 17 | if ( ! defined('BASE_DIR') ) { 18 | @define('BASE_DIR', realpath(__DIR__ . '/..')); 19 | } 20 | 21 | 22 | 23 | /** 24 | * Include configuration file 25 | **/ 26 | require_once(BASE_DIR . '/config/config.php'); 27 | if (!( isset($conf) && is_array($conf) )) { 28 | echo "conf from ".BASE_DIR."/config/config.php not loaded".PHP_EOL; 29 | exit(); 30 | } 31 | 32 | /** 33 | * Pear 34 | */ 35 | if ($conf['app']['safeMode']) { 36 | ini_set('include_path', (dirname(realpath(__FILE__)) . '/pear/' . PATH_SEPARATOR . ini_get('include_path'))); 37 | include_once('pear/PEAR.php'); 38 | include_once('pear/Net/Socket.php'); 39 | include_once('pear/Mail/mimeDecode.php'); 40 | } else { 41 | /* 42 | if ( @file_exists(BASE_DIR.'/lib/pear/'.'PEAR.php') ) { 43 | include_once(BASE_DIR.'/lib/pear/'.'PEAR.php'); 44 | } else { 45 | include_once('PEAR.php'); 46 | } 47 | */ 48 | if ( @file_exists(BASE_DIR.'/lib/pear/'.'Net/Socket.php') ) { 49 | include_once(BASE_DIR.'/lib/pear/'.'Net/Socket.php'); 50 | } else { 51 | include_once('Net/Socket.php'); 52 | } 53 | if ( @file_exists(BASE_DIR.'/lib/pear/'.'Mail/mimeDecode.php') ) { 54 | include_once(BASE_DIR.'/lib/pear/'.'Mail/mimeDecode.php'); 55 | } else { 56 | include_once('Mail/mimeDecode.php'); 57 | } 58 | } 59 | 60 | /* 61 | * Require composer autoloader 62 | */ 63 | if ( @file_exists('../vendor/autoload.php') ) { 64 | require '../vendor/autoload.php'; 65 | } else if ( @file_exists(BASE_DIR . '/vendor/autoload.php') ) { 66 | require BASE_DIR . '/vendor/autoload.php'; 67 | } 68 | 69 | /* 70 | * This has to be placed AFTER composer autoloader! 71 | * Import PHPMailer classes into the global namespace 72 | * 73 | */ 74 | use PHPMailer\PHPMailer\PHPMailer; 75 | use PHPMailer\PHPMailer\SMTP; 76 | use PHPMailer\PHPMailer\Exception; 77 | 78 | 79 | if (!function_exists('is_countable')) { 80 | /** 81 | * Verify that the content of a variable is an array or an object 82 | * implementing Countable 83 | * 84 | * @param mixed $var The value to check. 85 | * @return bool Returns TRUE if var is countable, FALSE otherwise. 86 | */ 87 | function is_countable($var) { 88 | return is_array($var) 89 | || $var instanceof \Countable 90 | || $var instanceof \SimpleXMLElement 91 | || $var instanceof \ResourceBundle; 92 | } 93 | } 94 | 95 | if (!function_exists('str_starts_with')) { 96 | function str_starts_with($haystack, $needle) { 97 | return (string)$needle !== '' && strncmp($haystack, $needle, strlen($needle)) === 0; 98 | } 99 | } 100 | if (!function_exists('str_ends_with')) { 101 | function str_ends_with($haystack, $needle) { 102 | return $needle !== '' && substr($haystack, -strlen($needle)) === (string)$needle; 103 | } 104 | } 105 | if (!function_exists('str_contains')) { 106 | function str_contains($haystack, $needle) { 107 | return $needle !== '' && mb_strpos($haystack, $needle) !== false; 108 | } 109 | } 110 | 111 | -------------------------------------------------------------------------------- /lib/classes/AmavisdEngine.class.php: -------------------------------------------------------------------------------- 1 | socket = new Net_Socket(); 41 | $this->port = $conf['conf']['amavisd']['spam_release_port']; 42 | $this->connected = false; 43 | $this->last_error = ''; 44 | 45 | // Connect to the Amavisd Port or wait 5 seconds and timeout 46 | $result = $this->socket->connect($host, $this->port, true, 5); 47 | 48 | if (PEAR::isError($result)) { 49 | $this->last_error = "Error connecting to $host:$this->port, " . $result->getMessage(); 50 | } else { 51 | $this->connected = true; 52 | } 53 | } 54 | 55 | /** 56 | * Shutdown and close socket 57 | * @param none 58 | */ 59 | function disconnect() 60 | { 61 | $this->socket->disconnect(); 62 | } 63 | 64 | /** 65 | * Release message from quarantine 66 | * @param $mail_id 67 | * @param $secret_id 68 | * @param $recipient 69 | * @result response 70 | */ 71 | 72 | function release_message($mail_id, $secret_id, $recipient, $quar_type, $quar_loc) 73 | { 74 | if (!$this->connected) { 75 | return $this->last_error; 76 | } 77 | 78 | $in = "request=release\r\n"; 79 | $in .= "mail_id=$mail_id\r\n"; 80 | $in .= "secret_id=$secret_id\r\n"; 81 | $in .= "quar_type=$quar_type\r\n"; 82 | 83 | # If it is file-based quarantine, lets provide the filename on the host 84 | if ($quar_type == 'F') { 85 | $in .= "mail_file=$quar_loc\r\n"; 86 | } 87 | 88 | $in .= "recipient=<$recipient>\r\n"; 89 | $in .= "\r\n"; 90 | 91 | // Sending request ... 92 | $out = $this->socket->write($in); 93 | 94 | if (PEAR::isError($out)) { 95 | $this->last_error = 'Error writing to socket: ' . $out->getMessage(); 96 | return $this->last_error; 97 | } 98 | 99 | // Set timeout of 5 seconds 100 | $this->socket->setTimeout(5); 101 | 102 | // Reading response 103 | $out = $this->socket->read(512); 104 | 105 | if (PEAR::isError($out)) { 106 | $this->last_error = 'Error reading from socket: ' . $out->getMessage(); 107 | return $this->last_error; 108 | } 109 | 110 | return $out; 111 | } 112 | } 113 | 114 | ?> 115 | -------------------------------------------------------------------------------- /lib/classes/ExchAuth.class.php: -------------------------------------------------------------------------------- 1 | 6 | * @package ExchAuth 7 | * 8 | * Copyright (C) 2021 mailzu-ng 9 | * License: GPL, see LICENSE 10 | */ 11 | /** 12 | * Base directory of application 13 | */ 14 | if ( ! defined('BASE_DIR') ) { 15 | @define('BASE_DIR', __DIR__ . '/../..'); 16 | } 17 | /** 18 | * Provide all database access/manipulation functionality for Exchange Auth 19 | */ 20 | class ExchAuth 21 | { 22 | // The exchange hostname with port (hostname[:port]) 23 | var $exchHost; 24 | // The exchange LDAP URI (ldap://hostname[:port]) 25 | var $exchLDAP; 26 | // The user's logon name 27 | var $logonName; 28 | // The user's first name 29 | var $firstName; 30 | // The user's mail address(es) 31 | var $emailAddress; 32 | 33 | var $err_msg = ''; 34 | 35 | /** 36 | * Constructor to initialize object 37 | * @param none 38 | */ 39 | function __construct() 40 | { 41 | global $conf; 42 | 43 | $this->exchHost = $conf['auth']['exch_host']; 44 | $this->exchLDAP = $conf['auth']['exch_ldap']; 45 | } 46 | 47 | // User methods ------------------------------------------- 48 | 49 | /** 50 | * Authenticates user 51 | * @param string $username 52 | * @param string $password 53 | * @param string $domain 54 | * @return boolean 55 | */ 56 | function authUser($username, $password, $domain) 57 | { 58 | $fulluser = $domain . '/' . $username; 59 | $mbox = imap_open('{' . $this->exchHost . '/imap}Inbox', $fulluser, $password); 60 | if ($mbox === false) { 61 | $this->err_msg = translate('Invalid Username/Password'); 62 | return false; 63 | } else { 64 | $ignore = imap_errors(); 65 | imap_close($mbox); 66 | } 67 | $ldapconn = ldap_connect($this->exchLDAP); 68 | if ($ldapconn === false) { 69 | $this->err_msg = translate('Can not connect to LDAP server'); 70 | return false; 71 | } 72 | ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3); 73 | ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0); 74 | $ldapbind = ldap_bind($ldapconn); 75 | if ($ldapbind === false) { 76 | $this->err_msg = translate('Can not bind to LDAP server'); 77 | return false; 78 | } 79 | $ldapattr = array('cn', 'rfc822Mailbox', 'otherMailbox'); 80 | $read = ldap_search($ldapconn, '', '(uid=' . $username . ')', $ldapattr); 81 | if ($read === false) { 82 | $this->err_msg = translate('Unable to search LDAP server'); 83 | return false; 84 | } 85 | $info = ldap_get_entries($ldapconn, $read); 86 | $this->logonName = strtolower($username); 87 | $this->firstName = $info[0]['cn'][0]; 88 | $this->emailAddress[] = strtolower($info[0]['rfc822mailbox'][0]); 89 | for ($i = 0; $i < $info[0]['othermailbox']['count']; $i++) { 90 | $data = $info[0]['othermailbox'][$i]; 91 | if (strncasecmp($data, 'smtp$', 5) == 0) { 92 | $this->emailAddress[] = strtolower(substr($data, 5)); 93 | } 94 | } 95 | ldap_close($ldapconn); 96 | return true; 97 | } 98 | 99 | /** 100 | * Returns the last error message 101 | * @param none 102 | * @return last error message generated 103 | */ 104 | function get_err() 105 | { 106 | return $this->err_msg; 107 | } 108 | 109 | // Helper methods ------------------------------------------- 110 | 111 | /** 112 | * Returns user information 113 | * @return array containing user information 114 | */ 115 | function getUserData() 116 | { 117 | $return = array( 118 | 'logonName' => $this->logonName, 119 | 'firstName' => $this->firstName, 120 | 'emailAddress' => $this->emailAddress 121 | ); 122 | return $return; 123 | } 124 | } 125 | 126 | ?> 127 | -------------------------------------------------------------------------------- /lib/classes/IMAPAuth.class.php: -------------------------------------------------------------------------------- 1 | 8 | * @version 2024-12-24 9 | * @package IMAPAuth 10 | * 11 | * Copyright (C) 2024 mailzu-ng 12 | * License: GPL, see LICENSE 13 | */ 14 | /** 15 | * Base directory of application 16 | */ 17 | if ( ! defined('BASE_DIR') ) { 18 | @define('BASE_DIR', __DIR__ . '/../..'); 19 | } 20 | /** 21 | * Provide all database access/manipulation functionality for IMAP Auth 22 | */ 23 | class IMAPAuth 24 | { 25 | // The IMAP hosts with port (hostname[:port]) 26 | var $imapHosts; 27 | // IMAP authentication type 28 | var $imapType; 29 | 30 | // Username 31 | var $imapUsername; 32 | 33 | // 34 | var $imapDomainName; 35 | 36 | // Alias Emails of User 37 | var $imapUserAliases = array(); 38 | 39 | // Query Amavis SQL for Alias Emails 40 | var $imapAliasesFromDB; 41 | 42 | var $err_msg = ''; 43 | 44 | /** 45 | * Constructor to initialize object 46 | * @param none 47 | */ 48 | function __construct() 49 | { 50 | global $conf; 51 | 52 | $this->imapHosts = $conf['auth']['imap_hosts']; 53 | $this->imapType = $conf['auth']['imap_type']; 54 | if ( isset($conf['auth']['imap_domain_name']) ) { 55 | $this->imapDomainName = $conf['auth']['imap_domain_name']; 56 | } 57 | $this->imapAliasesFromDB = $conf['auth']['imap_use_aliasdb']; 58 | } 59 | 60 | // User methods ------------------------------------------- 61 | 62 | /** 63 | * Authenticates user 64 | * @param string $username 65 | * @param string $password 66 | * @return boolean 67 | */ 68 | 69 | function authUser($username, $password) 70 | { 71 | // Returns true if the username and password work 72 | // and false if they are wrong or don't exist. 73 | 74 | $this->imapUsername = $username; 75 | 76 | foreach ($this->imapHosts as $host) { // Try each host in turn 77 | $host = trim($host); 78 | 79 | switch ($this->imapType) { 80 | case "imapssl": 81 | $host = '{' . $host . "/imap/ssl}INBOX"; 82 | break; 83 | 84 | case "imapcert": 85 | $host = '{' . $host . "/imap/ssl/novalidate-cert}INBOX"; 86 | break; 87 | 88 | case "imaptls": 89 | $host = '{' . $host . "/imap/tls}INBOX"; 90 | break; 91 | 92 | case "imaptlscert": 93 | $host = '{' . $host . "/imap/tls/novalidate-cert}INBOX"; 94 | break; 95 | 96 | default: 97 | $host = '{' . $host . "/imap/notls}INBOX"; 98 | } 99 | 100 | //error_reporting(0); 101 | $connection = imap_open($host, $username, $password, OP_HALFOPEN); 102 | 103 | if ($connection) { 104 | imap_close($connection); 105 | return true; 106 | } 107 | } 108 | 109 | $this->err_msg = translate('IMAP Authentication: no match'); 110 | return false; // No match 111 | } 112 | 113 | /** 114 | * Returns the last error message 115 | * @param none 116 | * @return last error message generated 117 | */ 118 | function get_err() 119 | { 120 | return $this->err_msg; 121 | } 122 | 123 | // Helper methods ------------------------------------------- 124 | 125 | /** 126 | * Returns user information 127 | * @return array containing user information 128 | */ 129 | function getUserData() 130 | { 131 | $rval=array(); 132 | $logonEmail = $this->imapUsername . (empty($this->imapDomainName) ? '' : '@' . $this->imapDomainName); 133 | if ( $this->imapAliasesFromDB === true ) 134 | { 135 | $db = new DBEngine(); 136 | $this->imapUserAliases = $db->get_useraliases($logonEmail); 137 | } 138 | if ( empty($this->imapUserAliases) !== true ) 139 | { 140 | $emailAddress = array_merge(array($logonEmail), $this->imapUserAliases); 141 | } else { 142 | $emailAddress = array($logonEmail); 143 | } 144 | $rval = array( 145 | 'logonName' => $logonEmail, 146 | 'firstName' => $this->imapUsername, 147 | 'emailAddress' => $emailAddress, 148 | ); 149 | return $rval; 150 | } 151 | } 152 | 153 | ?> 154 | -------------------------------------------------------------------------------- /lib/classes/MailEngine.class.php: -------------------------------------------------------------------------------- 1 | 5 | * @version 2021-11-08 6 | * @package MailEngine 7 | * 8 | * Copyright (C) 2021 mailzu-ng 9 | * License: GPL, see LICENSE 10 | */ 11 | /** 12 | * Base directory of application 13 | */ 14 | if ( ! defined('BASE_DIR') ) { 15 | @define('BASE_DIR', __DIR__ . '/../..'); 16 | } 17 | /** 18 | * Provide all mail access/manipulation functionality 19 | */ 20 | class MailEngine 21 | { 22 | var $raw; // Raw mail contents 23 | var $struct; // The top-level MIME structure 24 | var $recipient; // The recipient of the email 25 | var $msg_found; // Msg found in database 26 | var $msg_error; // Msg has MIME error 27 | var $last_error; // PEAR Error Messages 28 | 29 | /** 30 | * MailEngine object constructor 31 | * $param string The unique mail_id 32 | * $param string The mail addr of the reader 33 | * $return object MailEngine object 34 | */ 35 | function __construct($mail_id, $recip) 36 | { 37 | $this->recipient = $recip; 38 | $this->getRawContent($mail_id); 39 | $this->msg_error = false; 40 | if ($this->raw) { 41 | $this->msg_found = true; 42 | $this->struct = $this->getDecodedStruct($this->raw); 43 | if (PEAR::isError($this->struct)) { 44 | $this->msg_error = true; 45 | $this->last_error = $this->struct->getMessage(); 46 | } 47 | } else { 48 | $this->msg_found = false; 49 | } 50 | 51 | return $this->struct; 52 | } 53 | 54 | /** 55 | * Decode the raw contents to get the MIME structure 56 | * $param string The complete raw message returned by get_raw_mail 57 | * $return object Mail_mimeDecode::decode object 58 | */ 59 | function getDecodedStruct($contents) 60 | { 61 | $message = new Mail_mimeDecode($contents); 62 | $msg_struct = $message->decode(array('include_bodies' => true, 63 | 'decode_bodies' => true, 64 | 'decode_headers' => 'UTF8//IGNORE') 65 | ); 66 | return $msg_struct; 67 | } 68 | 69 | /** 70 | * Get the raw content through a DB call 71 | * $param string The unique mail_id 72 | * $return string The complete raw email 73 | */ 74 | function getRawContent($mail_id) 75 | { 76 | $db = new DBEngine(); 77 | $this->raw = $db->get_raw_mail($mail_id, $this->recipient); 78 | 79 | // Mark read 80 | if (in_array($this->recipient, $_SESSION['sessionMail']) && $this->raw) { 81 | $db->update_msgrcpt_rs($mail_id, $this->recipient, 'v'); 82 | } 83 | } 84 | } 85 | 86 | ?> 87 | -------------------------------------------------------------------------------- /lib/classes/Template.class.php: -------------------------------------------------------------------------------- 1 | 7 | * @version 2024-12-24 8 | * @package Template 9 | * 10 | * Copyright (C) 2024 mailzu-ng 11 | * License: GPL, see LICENSE 12 | */ 13 | /** 14 | * Base directory of application 15 | */ 16 | if ( ! defined('BASE_DIR') ) { 17 | @define('BASE_DIR', __DIR__ . '/../..'); 18 | } 19 | /** 20 | * Provides functions for outputting template HTML 21 | */ 22 | class Template 23 | { 24 | var $title; 25 | var $link; 26 | var $dir_path; 27 | 28 | /** 29 | * Set the page's title 30 | * @param string $title title of page 31 | * @param int $depth depth of the current page relative to MailZu root 32 | */ 33 | function __construct($title = '', $depth = 0) 34 | { 35 | global $conf; 36 | 37 | $this->title = (!empty($title)) ? $title : $conf['ui']['welcome']; 38 | $this->dir_path = str_repeat('../', $depth); 39 | $this->link = CmnFns::getNewLink(); 40 | //Auth::Auth(); // Starts session 41 | } 42 | 43 | /** 44 | * Print all HTML5 headers 45 | * This function prints the HTML header code, CSS link, and JavaScript link 46 | * 47 | * DOCTYPE is HTML, with viewport defined to allow responsive display 48 | * @param none 49 | */ 50 | function printHTMLHeader() 51 | { 52 | global $conf; 53 | global $languages; 54 | global $lang; 55 | global $charset; 56 | 57 | $path = $this->dir_path; 58 | ?> 59 | 60 | 61 | 62 | 63 | <?php echo $this->title ?> 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 75 | 76 | 77 | logo' . "\n" 96 | : ''; 97 | ?> 98 | 99 | 100 | 101 | 110 | 117 | 118 |
102 |

103 | 108 |

109 |
111 |
112 |

113 | 114 |

115 |
116 |
119 | 120 | 130 |

 

131 | 132 | 133 | 134 | 148 | 149 |
135 | 136 | 146 | 147 |
150 | 151 | 164 |

165 | v

166 | 167 | 168 | link = CmnFns::getNewLink(); 178 | } 179 | 180 | /** 181 | * Returns the link object 182 | * @param none 183 | * @return link object for this class 184 | */ 185 | function get_link() 186 | { 187 | return $this->link; 188 | } 189 | 190 | /** 191 | * Sets a new title for the template page 192 | * @param string $title title of page 193 | */ 194 | function set_title($title) 195 | { 196 | $this->title = $title; 197 | } 198 | } 199 | -------------------------------------------------------------------------------- /lib/classes/mailzuMailer.class.php: -------------------------------------------------------------------------------- 1 | 7 | * @version 2024-12-24 8 | * @package mailzuMailer 9 | * 10 | */ 11 | class mailzuMailer extends PHPMailer 12 | { 13 | /** 14 | * mailzuMailer constructor. 15 | * 16 | * @param bool|null $exceptions 17 | * 18 | */ 19 | public function __construct($exceptions) 20 | { 21 | global $conf; 22 | global $charset; 23 | 24 | //Don't forget to do this or other things may not be set correctly! 25 | parent::__construct($exceptions); 26 | $this->CharSet = $charset; 27 | 28 | if ($lang = determine_language()) { // Functions exist in the langs.php file 29 | $this->setLanguage($lang); 30 | } 31 | 32 | switch ($conf['app']['emailType']) { 33 | case 'smtp': 34 | $this->isSMTP(); 35 | $this->Mailer = 'smtp'; 36 | $this->Host = $conf['app']['smtpHost']; 37 | $this->Port = $conf['app']['smtpPort']; 38 | break; 39 | case 'sendmail': 40 | $this->isSendmail(); 41 | $this->Mailer = 'sendmail'; 42 | $this->Sendmail = $conf['app']['sendmailPath']; 43 | break; 44 | case 'qmail': 45 | $this->isQmail(); 46 | $this->Mailer = 'qmail'; 47 | $this->Sendmail = $conf['app']['qmailPath']; 48 | break; 49 | case 'mail': 50 | default: 51 | $this->isMail(); 52 | $this->Mailer = 'mail'; 53 | } 54 | } 55 | 56 | //Create the Send() function 57 | public function Send() 58 | { 59 | $this->XMailer = 'mailzu-ng mailer'; 60 | $r = parent::send(); 61 | return $r; 62 | } 63 | 64 | //Create the AddAddress() function 65 | public function AddAddress($address, $name = '') 66 | { 67 | return parent::addAddress($address, $name); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /lib/index.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnanet/mailzu/84f409cd7898f540d7963ae2cb99e0f33f5f576b/lib/index.html -------------------------------------------------------------------------------- /lib/pear/PEAR/ChannelFile/Parser.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a1 14 | */ 15 | 16 | /** 17 | * base xml parser class 18 | */ 19 | require_once 'PEAR/XMLParser.php'; 20 | require_once 'PEAR/ChannelFile.php'; 21 | /** 22 | * Parser for channel.xml 23 | * @category pear 24 | * @package PEAR 25 | * @author Greg Beaver 26 | * @copyright 1997-2009 The Authors 27 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 28 | * @version Release: 1.10.6 29 | * @link http://pear.php.net/package/PEAR 30 | * @since Class available since Release 1.4.0a1 31 | */ 32 | class PEAR_ChannelFile_Parser extends PEAR_XMLParser 33 | { 34 | var $_config; 35 | var $_logger; 36 | var $_registry; 37 | 38 | function setConfig(&$c) 39 | { 40 | $this->_config = &$c; 41 | $this->_registry = &$c->getRegistry(); 42 | } 43 | 44 | function setLogger(&$l) 45 | { 46 | $this->_logger = &$l; 47 | } 48 | 49 | function parse($data, $file) 50 | { 51 | if (PEAR::isError($err = parent::parse($data, $file))) { 52 | return $err; 53 | } 54 | 55 | $ret = new PEAR_ChannelFile; 56 | $ret->setConfig($this->_config); 57 | if (isset($this->_logger)) { 58 | $ret->setLogger($this->_logger); 59 | } 60 | 61 | $ret->fromArray($this->_unserializedData); 62 | // make sure the filelist is in the easy to read format needed 63 | $ret->flattenFilelist(); 64 | $ret->setPackagefile($file, $archive); 65 | return $ret; 66 | } 67 | } -------------------------------------------------------------------------------- /lib/pear/PEAR/Command/Auth.php: -------------------------------------------------------------------------------- 1 | 10 | * @author Greg Beaver 11 | * @copyright 1997-2009 The Authors 12 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 13 | * @link http://pear.php.net/package/PEAR 14 | * @since File available since Release 0.1 15 | * @deprecated since 1.8.0alpha1 16 | */ 17 | 18 | /** 19 | * base class 20 | */ 21 | require_once 'PEAR/Command/Channels.php'; 22 | 23 | /** 24 | * PEAR commands for login/logout 25 | * 26 | * @category pear 27 | * @package PEAR 28 | * @author Stig Bakken 29 | * @author Greg Beaver 30 | * @copyright 1997-2009 The Authors 31 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 32 | * @version Release: 1.10.6 33 | * @link http://pear.php.net/package/PEAR 34 | * @since Class available since Release 0.1 35 | * @deprecated since 1.8.0alpha1 36 | */ 37 | class PEAR_Command_Auth extends PEAR_Command_Channels 38 | { 39 | var $commands = array( 40 | 'login' => array( 41 | 'summary' => 'Connects and authenticates to remote server [Deprecated in favor of channel-login]', 42 | 'shortcut' => 'li', 43 | 'function' => 'doLogin', 44 | 'options' => array(), 45 | 'doc' => ' 46 | WARNING: This function is deprecated in favor of using channel-login 47 | 48 | Log in to a remote channel server. If is not supplied, 49 | the default channel is used. To use remote functions in the installer 50 | that require any kind of privileges, you need to log in first. The 51 | username and password you enter here will be stored in your per-user 52 | PEAR configuration (~/.pearrc on Unix-like systems). After logging 53 | in, your username and password will be sent along in subsequent 54 | operations on the remote server.', 55 | ), 56 | 'logout' => array( 57 | 'summary' => 'Logs out from the remote server [Deprecated in favor of channel-logout]', 58 | 'shortcut' => 'lo', 59 | 'function' => 'doLogout', 60 | 'options' => array(), 61 | 'doc' => ' 62 | WARNING: This function is deprecated in favor of using channel-logout 63 | 64 | Logs out from the remote server. This command does not actually 65 | connect to the remote server, it only deletes the stored username and 66 | password from your user configuration.', 67 | ) 68 | 69 | ); 70 | 71 | /** 72 | * PEAR_Command_Auth constructor. 73 | * 74 | * @access public 75 | */ 76 | function __construct(&$ui, &$config) 77 | { 78 | parent::__construct($ui, $config); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Command/Auth.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Connects and authenticates to remote server [Deprecated in favor of channel-login] 4 | doLogin 5 | li 6 | 7 | <channel name> 8 | WARNING: This function is deprecated in favor of using channel-login 9 | 10 | Log in to a remote channel server. If <channel name> is not supplied, 11 | the default channel is used. To use remote functions in the installer 12 | that require any kind of privileges, you need to log in first. The 13 | username and password you enter here will be stored in your per-user 14 | PEAR configuration (~/.pearrc on Unix-like systems). After logging 15 | in, your username and password will be sent along in subsequent 16 | operations on the remote server. 17 | 18 | 19 | Logs out from the remote server [Deprecated in favor of channel-logout] 20 | doLogout 21 | lo 22 | 23 | 24 | WARNING: This function is deprecated in favor of using channel-logout 25 | 26 | Logs out from the remote server. This command does not actually 27 | connect to the remote server, it only deletes the stored username and 28 | password from your user configuration. 29 | 30 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Command/Build.php: -------------------------------------------------------------------------------- 1 | 10 | * @author Tomas V.V.Cox 11 | * @author Greg Beaver 12 | * @copyright 1997-2009 The Authors 13 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 14 | * @link http://pear.php.net/package/PEAR 15 | * @since File available since Release 0.1 16 | */ 17 | 18 | /** 19 | * base class 20 | */ 21 | require_once 'PEAR/Command/Common.php'; 22 | 23 | /** 24 | * PEAR commands for building extensions. 25 | * 26 | * @category pear 27 | * @package PEAR 28 | * @author Stig Bakken 29 | * @author Tomas V.V.Cox 30 | * @author Greg Beaver 31 | * @copyright 1997-2009 The Authors 32 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 33 | * @version Release: 1.10.6 34 | * @link http://pear.php.net/package/PEAR 35 | * @since Class available since Release 0.1 36 | */ 37 | class PEAR_Command_Build extends PEAR_Command_Common 38 | { 39 | var $commands = array( 40 | 'build' => array( 41 | 'summary' => 'Build an Extension From C Source', 42 | 'function' => 'doBuild', 43 | 'shortcut' => 'b', 44 | 'options' => array(), 45 | 'doc' => '[package.xml] 46 | Builds one or more extensions contained in a package.' 47 | ), 48 | ); 49 | 50 | /** 51 | * PEAR_Command_Build constructor. 52 | * 53 | * @access public 54 | */ 55 | function __construct(&$ui, &$config) 56 | { 57 | parent::__construct($ui, $config); 58 | } 59 | 60 | function doBuild($command, $options, $params) 61 | { 62 | require_once 'PEAR/Builder.php'; 63 | if (sizeof($params) < 1) { 64 | $params[0] = 'package.xml'; 65 | } 66 | 67 | $builder = new PEAR_Builder($this->ui); 68 | $this->debug = $this->config->get('verbose'); 69 | $err = $builder->build($params[0], array(&$this, 'buildCallback')); 70 | if (PEAR::isError($err)) { 71 | return $err; 72 | } 73 | 74 | return true; 75 | } 76 | 77 | function buildCallback($what, $data) 78 | { 79 | if (($what == 'cmdoutput' && $this->debug > 1) || 80 | ($what == 'output' && $this->debug > 0)) { 81 | $this->ui->outputData(rtrim($data), 'build'); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Command/Build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Build an Extension From C Source 4 | doBuild 5 | b 6 | 7 | [package.xml] 8 | Builds one or more extensions contained in a package. 9 | 10 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Command/Channels.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | List Available Channels 4 | doList 5 | lc 6 | 7 | 8 | List all available channels for installation. 9 | 10 | 11 | 12 | Update the Channel List 13 | doUpdateAll 14 | uc 15 | 16 | 17 | List all installed packages in all channels. 18 | 19 | 20 | 21 | Remove a Channel From the List 22 | doDelete 23 | cde 24 | 25 | <channel name> 26 | Delete a channel from the registry. You may not 27 | remove any channel that has installed packages. 28 | 29 | 30 | 31 | Add a Channel 32 | doAdd 33 | ca 34 | 35 | <channel.xml> 36 | Add a private channel to the channel list. Note that all 37 | public channels should be synced using "update-channels". 38 | Parameter may be either a local file or remote URL to a 39 | channel.xml. 40 | 41 | 42 | 43 | Update an Existing Channel 44 | doUpdate 45 | cu 46 | 47 | 48 | f 49 | will force download of new channel.xml if an existing channel name is used 50 | 51 | 52 | c 53 | will force download of new channel.xml if an existing channel name is used 54 | CHANNEL 55 | 56 | 57 | [<channel.xml>|<channel name>] 58 | Update a channel in the channel list directly. Note that all 59 | public channels can be synced using "update-channels". 60 | Parameter may be a local or remote channel.xml, or the name of 61 | an existing channel. 62 | 63 | 64 | 65 | Retrieve Information on a Channel 66 | doInfo 67 | ci 68 | 69 | <package> 70 | List the files in an installed package. 71 | 72 | 73 | 74 | Specify an alias to a channel name 75 | doAlias 76 | cha 77 | 78 | <channel> <alias> 79 | Specify a specific alias to use for a channel name. 80 | The alias may not be an existing channel name or 81 | alias. 82 | 83 | 84 | 85 | Initialize a Channel from its server 86 | doDiscover 87 | di 88 | 89 | [<channel.xml>|<channel name>] 90 | Initialize a channel from its server and create a local channel.xml. 91 | If <channel name> is in the format "<username>:<password>@<channel>" then 92 | <username> and <password> will be set as the login username/password for 93 | <channel>. Use caution when passing the username/password in this way, as 94 | it may allow other users on your computer to briefly view your username/ 95 | password via the system's process list. 96 | 97 | 98 | 99 | Connects and authenticates to remote channel server 100 | doLogin 101 | cli 102 | 103 | <channel name> 104 | Log in to a remote channel server. If <channel name> is not supplied, 105 | the default channel is used. To use remote functions in the installer 106 | that require any kind of privileges, you need to log in first. The 107 | username and password you enter here will be stored in your per-user 108 | PEAR configuration (~/.pearrc on Unix-like systems). After logging 109 | in, your username and password will be sent along in subsequent 110 | operations on the remote server. 111 | 112 | 113 | Logs out from the remote channel server 114 | doLogout 115 | clo 116 | 117 | <channel name> 118 | Logs out from a remote channel server. If <channel name> is not supplied, 119 | the default channel is used. This command does not actually connect to the 120 | remote server, it only deletes the stored username and password from your user 121 | configuration. 122 | 123 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Command/Config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Show All Settings 4 | doConfigShow 5 | csh 6 | 7 | 8 | c 9 | show configuration variables for another channel 10 | CHAN 11 | 12 | 13 | [layer] 14 | Displays all configuration values. An optional argument 15 | may be used to tell which configuration layer to display. Valid 16 | configuration layers are "user", "system" and "default". To display 17 | configurations for different channels, set the default_channel 18 | configuration variable and run config-show again. 19 | 20 | 21 | 22 | Show One Setting 23 | doConfigGet 24 | cg 25 | 26 | 27 | c 28 | show configuration variables for another channel 29 | CHAN 30 | 31 | 32 | <parameter> [layer] 33 | Displays the value of one configuration parameter. The 34 | first argument is the name of the parameter, an optional second argument 35 | may be used to tell which configuration layer to look in. Valid configuration 36 | layers are "user", "system" and "default". If no layer is specified, a value 37 | will be picked from the first layer that defines the parameter, in the order 38 | just specified. The configuration value will be retrieved for the channel 39 | specified by the default_channel configuration variable. 40 | 41 | 42 | 43 | Change Setting 44 | doConfigSet 45 | cs 46 | 47 | 48 | c 49 | show configuration variables for another channel 50 | CHAN 51 | 52 | 53 | <parameter> <value> [layer] 54 | Sets the value of one configuration parameter. The first argument is 55 | the name of the parameter, the second argument is the new value. Some 56 | parameters are subject to validation, and the command will fail with 57 | an error message if the new value does not make sense. An optional 58 | third argument may be used to specify in which layer to set the 59 | configuration parameter. The default layer is "user". The 60 | configuration value will be set for the current channel, which 61 | is controlled by the default_channel configuration variable. 62 | 63 | 64 | 65 | Show Information About Setting 66 | doConfigHelp 67 | ch 68 | 69 | [parameter] 70 | Displays help for a configuration parameter. Without arguments it 71 | displays help for all configuration parameters. 72 | 73 | 74 | 75 | Create a Default configuration file 76 | doConfigCreate 77 | coc 78 | 79 | 80 | w 81 | create a config file for a windows install 82 | 83 | 84 | <root path> <filename> 85 | Create a default configuration file with all directory configuration 86 | variables set to subdirectories of <root path>, and save it as <filename>. 87 | This is useful especially for creating a configuration file for a remote 88 | PEAR installation (using the --remoteconfig option of install, upgrade, 89 | and uninstall). 90 | 91 | 92 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Command/Mirror.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.2.0 14 | */ 15 | 16 | /** 17 | * base class 18 | */ 19 | require_once 'PEAR/Command/Common.php'; 20 | 21 | /** 22 | * PEAR commands for providing file mirrors 23 | * 24 | * @category pear 25 | * @package PEAR 26 | * @author Alexander Merz 27 | * @copyright 1997-2009 The Authors 28 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 29 | * @version Release: 1.10.6 30 | * @link http://pear.php.net/package/PEAR 31 | * @since Class available since Release 1.2.0 32 | */ 33 | class PEAR_Command_Mirror extends PEAR_Command_Common 34 | { 35 | var $commands = array( 36 | 'download-all' => array( 37 | 'summary' => 'Downloads each available package from the default channel', 38 | 'function' => 'doDownloadAll', 39 | 'shortcut' => 'da', 40 | 'options' => array( 41 | 'channel' => 42 | array( 43 | 'shortopt' => 'c', 44 | 'doc' => 'specify a channel other than the default channel', 45 | 'arg' => 'CHAN', 46 | ), 47 | ), 48 | 'doc' => ' 49 | Requests a list of available packages from the default channel ({config default_channel}) 50 | and downloads them to current working directory. Note: only 51 | packages within preferred_state ({config preferred_state}) will be downloaded' 52 | ), 53 | ); 54 | 55 | /** 56 | * PEAR_Command_Mirror constructor. 57 | * 58 | * @access public 59 | * @param object PEAR_Frontend a reference to an frontend 60 | * @param object PEAR_Config a reference to the configuration data 61 | */ 62 | function __construct(&$ui, &$config) 63 | { 64 | parent::__construct($ui, $config); 65 | } 66 | 67 | /** 68 | * For unit-testing 69 | */ 70 | function &factory($a) 71 | { 72 | $a = &PEAR_Command::factory($a, $this->config); 73 | return $a; 74 | } 75 | 76 | /** 77 | * retrieves a list of avaible Packages from master server 78 | * and downloads them 79 | * 80 | * @access public 81 | * @param string $command the command 82 | * @param array $options the command options before the command 83 | * @param array $params the stuff after the command name 84 | * @return bool true if successful 85 | * @throw PEAR_Error 86 | */ 87 | function doDownloadAll($command, $options, $params) 88 | { 89 | $savechannel = $this->config->get('default_channel'); 90 | $reg = &$this->config->getRegistry(); 91 | $channel = isset($options['channel']) ? $options['channel'] : 92 | $this->config->get('default_channel'); 93 | if (!$reg->channelExists($channel)) { 94 | $this->config->set('default_channel', $savechannel); 95 | return $this->raiseError('Channel "' . $channel . '" does not exist'); 96 | } 97 | $this->config->set('default_channel', $channel); 98 | 99 | $this->ui->outputData('Using Channel ' . $this->config->get('default_channel')); 100 | $chan = $reg->getChannel($channel); 101 | if (PEAR::isError($chan)) { 102 | return $this->raiseError($chan); 103 | } 104 | 105 | if ($chan->supportsREST($this->config->get('preferred_mirror')) && 106 | $base = $chan->getBaseURL('REST1.0', $this->config->get('preferred_mirror'))) { 107 | $rest = &$this->config->getREST('1.0', array()); 108 | $remoteInfo = array_flip($rest->listPackages($base, $channel)); 109 | } 110 | 111 | if (PEAR::isError($remoteInfo)) { 112 | return $remoteInfo; 113 | } 114 | 115 | $cmd = &$this->factory("download"); 116 | if (PEAR::isError($cmd)) { 117 | return $cmd; 118 | } 119 | 120 | $this->ui->outputData('Using Preferred State of ' . 121 | $this->config->get('preferred_state')); 122 | $this->ui->outputData('Gathering release information, please wait...'); 123 | 124 | /** 125 | * Error handling not necessary, because already done by 126 | * the download command 127 | */ 128 | PEAR::staticPushErrorHandling(PEAR_ERROR_RETURN); 129 | $err = $cmd->run('download', array('downloadonly' => true), array_keys($remoteInfo)); 130 | PEAR::staticPopErrorHandling(); 131 | $this->config->set('default_channel', $savechannel); 132 | if (PEAR::isError($err)) { 133 | $this->ui->outputData($err->getMessage()); 134 | } 135 | 136 | return true; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Command/Mirror.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Downloads each available package from the default channel 4 | doDownloadAll 5 | da 6 | 7 | 8 | c 9 | specify a channel other than the default channel 10 | CHAN 11 | 12 | 13 | 14 | Requests a list of available packages from the default channel ({config default_channel}) 15 | and downloads them to current working directory. Note: only 16 | packages within preferred_state ({config preferred_state}) will be downloaded 17 | 18 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Command/Pickle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Build PECL Package 4 | doPackage 5 | pi 6 | 7 | 8 | Z 9 | Do not gzip the package file 10 | 11 | 12 | n 13 | Print the name of the packaged file. 14 | 15 | 16 | [descfile] 17 | Creates a PECL package from its package2.xml file. 18 | 19 | An automatic conversion will be made to a package.xml 1.0 and written out to 20 | disk in the current directory as "package.xml". Note that 21 | only simple package.xml 2.0 will be converted. package.xml 2.0 with: 22 | 23 | - dependency types other than required/optional PECL package/ext/php/pearinstaller 24 | - more than one extsrcrelease or zendextsrcrelease 25 | - zendextbinrelease, extbinrelease, phprelease, or bundle release type 26 | - dependency groups 27 | - ignore tags in release filelist 28 | - tasks other than replace 29 | - custom roles 30 | 31 | will cause pickle to fail, and output an error message. If your package2.xml 32 | uses any of these features, you are best off using PEAR_PackageFileManager to 33 | generate both package.xml. 34 | 35 | 36 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Command/Registry.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | List Installed Packages In The Default Channel 4 | doList 5 | l 6 | 7 | 8 | c 9 | list installed packages from this channel 10 | CHAN 11 | 12 | 13 | a 14 | list installed packages from all channels 15 | 16 | 17 | i 18 | output fully channel-aware data, even on failure 19 | 20 | 21 | <package> 22 | If invoked without parameters, this command lists the PEAR packages 23 | installed in your php_dir ({config php_dir}). With a parameter, it 24 | lists the files in a package. 25 | 26 | 27 | 28 | List Files In Installed Package 29 | doFileList 30 | fl 31 | 32 | <package> 33 | List the files in an installed package. 34 | 35 | 36 | 37 | Shell Script Test 38 | doShellTest 39 | st 40 | 41 | <package> [[relation] version] 42 | Tests if a package is installed in the system. Will exit(1) if it is not. 43 | <relation> The version comparison operator. One of: 44 | <, lt, <=, le, >, gt, >=, ge, ==, =, eq, !=, <>, ne 45 | <version> The version to compare with 46 | 47 | 48 | 49 | Display information about a package 50 | doInfo 51 | in 52 | 53 | <package> 54 | Displays information about a package. The package argument may be a 55 | local package file, an URL to a package file, or the name of an 56 | installed package. 57 | 58 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Command/Remote.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Information About Remote Packages 4 | doRemoteInfo 5 | ri 6 | 7 | <package> 8 | Get details on a package from the server. 9 | 10 | 11 | List Available Upgrades 12 | doListUpgrades 13 | lu 14 | 15 | 16 | i 17 | output fully channel-aware data, even on failure 18 | 19 | 20 | [preferred_state] 21 | List releases on the server of packages you have installed where 22 | a newer version is available with the same release state (stable etc.) 23 | or the state passed as the second parameter. 24 | 25 | 26 | List Remote Packages 27 | doRemoteList 28 | rl 29 | 30 | 31 | c 32 | specify a channel other than the default channel 33 | CHAN 34 | 35 | 36 | 37 | Lists the packages available on the configured server along with the 38 | latest stable release of each package. 39 | 40 | 41 | Search remote package database 42 | doSearch 43 | sp 44 | 45 | 46 | c 47 | specify a channel other than the default channel 48 | CHAN 49 | 50 | 51 | a 52 | search packages from all known channels 53 | 54 | 55 | i 56 | output fully channel-aware data, even on failure 57 | 58 | 59 | [packagename] [packageinfo] 60 | Lists all packages which match the search parameters. The first 61 | parameter is a fragment of a packagename. The default channel 62 | will be used unless explicitly overridden. The second parameter 63 | will be used to match any portion of the summary/description 64 | 65 | 66 | List All Packages 67 | doListAll 68 | la 69 | 70 | 71 | c 72 | specify a channel other than the default channel 73 | CHAN 74 | 75 | 76 | i 77 | output fully channel-aware data, even on failure 78 | 79 | 80 | 81 | Lists the packages available on the configured server along with the 82 | latest stable release of each package. 83 | 84 | 85 | Download Package 86 | doDownload 87 | d 88 | 89 | 90 | Z 91 | download an uncompressed (.tar) file 92 | 93 | 94 | <package>... 95 | Download package tarballs. The files will be named as suggested by the 96 | server, for example if you download the DB package and the latest stable 97 | version of DB is 1.6.5, the downloaded file will be DB-1.6.5.tgz. 98 | 99 | 100 | Clear Web Services Cache 101 | doClearCache 102 | cc 103 | 104 | 105 | Clear the XML-RPC/REST cache. See also the cache_ttl configuration 106 | parameter. 107 | 108 | 109 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Command/Test.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | Run Regression Tests 4 | doRunTests 5 | rt 6 | 7 | 8 | r 9 | Run tests in child directories, recursively. 4 dirs deep maximum 10 | 11 | 12 | i 13 | actual string of settings to pass to php in format " -d setting=blah" 14 | SETTINGS 15 | 16 | 17 | l 18 | Log test runs/results as they are run 19 | 20 | 21 | q 22 | Only display detail for failed tests 23 | 24 | 25 | s 26 | Display simple output for all tests 27 | 28 | 29 | p 30 | Treat parameters as installed packages from which to run tests 31 | 32 | 33 | u 34 | Search parameters for AllTests.php, and use that to run phpunit-based tests 35 | If none is found, all .phpt tests will be tried instead. 36 | 37 | 38 | t 39 | Output run-tests.log in TAP-compliant format 40 | 41 | 42 | c 43 | CGI php executable (needed for tests with POST/GET section) 44 | PHPCGI 45 | 46 | 47 | x 48 | Generate a code coverage report (requires Xdebug 2.0.0+) 49 | 50 | 51 | [testfile|dir ...] 52 | Run regression tests with PHP's regression testing script (run-tests.php). 53 | 54 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Frontend.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a1 14 | */ 15 | 16 | /** 17 | * Include error handling 18 | */ 19 | //require_once 'PEAR.php'; 20 | 21 | /** 22 | * Which user interface class is being used. 23 | * @var string class name 24 | */ 25 | $GLOBALS['_PEAR_FRONTEND_CLASS'] = 'PEAR_Frontend_CLI'; 26 | 27 | /** 28 | * Instance of $_PEAR_Command_uiclass. 29 | * @var object 30 | */ 31 | $GLOBALS['_PEAR_FRONTEND_SINGLETON'] = null; 32 | 33 | /** 34 | * Singleton-based frontend for PEAR user input/output 35 | * 36 | * @category pear 37 | * @package PEAR 38 | * @author Greg Beaver 39 | * @copyright 1997-2009 The Authors 40 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 41 | * @version Release: 1.10.6 42 | * @link http://pear.php.net/package/PEAR 43 | * @since Class available since Release 1.4.0a1 44 | */ 45 | class PEAR_Frontend extends PEAR 46 | { 47 | /** 48 | * Retrieve the frontend object 49 | * @return PEAR_Frontend_CLI|PEAR_Frontend_Web|PEAR_Frontend_Gtk 50 | */ 51 | public static function &singleton($type = null) 52 | { 53 | if ($type === null) { 54 | if (!isset($GLOBALS['_PEAR_FRONTEND_SINGLETON'])) { 55 | $a = false; 56 | return $a; 57 | } 58 | return $GLOBALS['_PEAR_FRONTEND_SINGLETON']; 59 | } 60 | 61 | $a = PEAR_Frontend::setFrontendClass($type); 62 | return $a; 63 | } 64 | 65 | /** 66 | * Set the frontend class that will be used by calls to {@link singleton()} 67 | * 68 | * Frontends are expected to conform to the PEAR naming standard of 69 | * _ => DIRECTORY_SEPARATOR (PEAR_Frontend_CLI is in PEAR/Frontend/CLI.php) 70 | * @param string $uiclass full class name 71 | * @return PEAR_Frontend 72 | */ 73 | public static function &setFrontendClass($uiclass) 74 | { 75 | if (is_object($GLOBALS['_PEAR_FRONTEND_SINGLETON']) && 76 | is_a($GLOBALS['_PEAR_FRONTEND_SINGLETON'], $uiclass)) { 77 | return $GLOBALS['_PEAR_FRONTEND_SINGLETON']; 78 | } 79 | 80 | if (!class_exists($uiclass)) { 81 | $file = str_replace('_', '/', $uiclass) . '.php'; 82 | if (PEAR_Frontend::isIncludeable($file)) { 83 | include_once $file; 84 | } 85 | } 86 | 87 | if (class_exists($uiclass)) { 88 | $obj = new $uiclass; 89 | // quick test to see if this class implements a few of the most 90 | // important frontend methods 91 | if (is_a($obj, 'PEAR_Frontend')) { 92 | $GLOBALS['_PEAR_FRONTEND_SINGLETON'] = &$obj; 93 | $GLOBALS['_PEAR_FRONTEND_CLASS'] = $uiclass; 94 | return $obj; 95 | } 96 | 97 | $err = PEAR::raiseError("not a frontend class: $uiclass"); 98 | return $err; 99 | } 100 | 101 | $err = PEAR::raiseError("no such class: $uiclass"); 102 | return $err; 103 | } 104 | 105 | /** 106 | * Set the frontend class that will be used by calls to {@link singleton()} 107 | * 108 | * Frontends are expected to be a descendant of PEAR_Frontend 109 | * @param PEAR_Frontend 110 | * @return PEAR_Frontend 111 | */ 112 | public static function &setFrontendObject($uiobject) 113 | { 114 | if (is_object($GLOBALS['_PEAR_FRONTEND_SINGLETON']) && 115 | is_a($GLOBALS['_PEAR_FRONTEND_SINGLETON'], get_class($uiobject))) { 116 | return $GLOBALS['_PEAR_FRONTEND_SINGLETON']; 117 | } 118 | 119 | if (!is_a($uiobject, 'PEAR_Frontend')) { 120 | $err = PEAR::raiseError('not a valid frontend class: (' . 121 | get_class($uiobject) . ')'); 122 | return $err; 123 | } 124 | 125 | $GLOBALS['_PEAR_FRONTEND_SINGLETON'] = &$uiobject; 126 | $GLOBALS['_PEAR_FRONTEND_CLASS'] = get_class($uiobject); 127 | return $uiobject; 128 | } 129 | 130 | /** 131 | * @param string $path relative or absolute include path 132 | * @return boolean 133 | */ 134 | public static function isIncludeable($path) 135 | { 136 | if (file_exists($path) && is_readable($path)) { 137 | return true; 138 | } 139 | 140 | $fp = @fopen($path, 'r', true); 141 | if ($fp) { 142 | fclose($fp); 143 | return true; 144 | } 145 | 146 | return false; 147 | } 148 | 149 | /** 150 | * @param PEAR_Config 151 | */ 152 | function setConfig(&$config) 153 | { 154 | } 155 | 156 | /** 157 | * This can be overridden to allow session-based temporary file management 158 | * 159 | * By default, all files are deleted at the end of a session. The web installer 160 | * needs to be able to sustain a list over many sessions in order to support 161 | * user interaction with install scripts 162 | */ 163 | function addTempFile($file) 164 | { 165 | $GLOBALS['_PEAR_Common_tempfiles'][] = $file; 166 | } 167 | 168 | /** 169 | * Log an action 170 | * 171 | * @param string $msg the message to log 172 | * @param boolean $append_crlf 173 | * @return boolean true 174 | * @abstract 175 | */ 176 | function log($msg, $append_crlf = true) 177 | { 178 | } 179 | 180 | /** 181 | * Run a post-installation script 182 | * 183 | * @param array $scripts array of post-install scripts 184 | * @abstract 185 | */ 186 | function runPostinstallScripts(&$scripts) 187 | { 188 | } 189 | 190 | /** 191 | * Display human-friendly output formatted depending on the 192 | * $command parameter. 193 | * 194 | * This should be able to handle basic output data with no command 195 | * @param mixed $data data structure containing the information to display 196 | * @param string $command command from which this method was called 197 | * @abstract 198 | */ 199 | function outputData($data, $command = '_default') 200 | { 201 | } 202 | 203 | /** 204 | * Display a modal form dialog and return the given input 205 | * 206 | * A frontend that requires multiple requests to retrieve and process 207 | * data must take these needs into account, and implement the request 208 | * handling code. 209 | * @param string $command command from which this method was called 210 | * @param array $prompts associative array. keys are the input field names 211 | * and values are the description 212 | * @param array $types array of input field types (text, password, 213 | * etc.) keys have to be the same like in $prompts 214 | * @param array $defaults array of default values. again keys have 215 | * to be the same like in $prompts. Do not depend 216 | * on a default value being set. 217 | * @return array input sent by the user 218 | * @abstract 219 | */ 220 | function userDialog($command, $prompts, $types = array(), $defaults = array()) 221 | { 222 | } 223 | } -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Cfg.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 2007-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.7.0 14 | */ 15 | 16 | /** 17 | * @category pear 18 | * @package PEAR 19 | * @author Greg Beaver 20 | * @copyright 2007-2009 The Authors 21 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 22 | * @version Release: 1.10.6 23 | * @link http://pear.php.net/package/PEAR 24 | * @since Class available since Release 1.7.0 25 | */ 26 | class PEAR_Installer_Role_Cfg extends PEAR_Installer_Role_Common 27 | { 28 | /** 29 | * @var PEAR_Installer 30 | */ 31 | var $installer; 32 | 33 | /** 34 | * the md5 of the original file 35 | * 36 | * @var unknown_type 37 | */ 38 | var $md5 = null; 39 | 40 | /** 41 | * Do any unusual setup here 42 | * @param PEAR_Installer 43 | * @param PEAR_PackageFile_v2 44 | * @param array file attributes 45 | * @param string file name 46 | */ 47 | function setup(&$installer, $pkg, $atts, $file) 48 | { 49 | $this->installer = &$installer; 50 | $reg = &$this->installer->config->getRegistry(); 51 | $package = $reg->getPackage($pkg->getPackage(), $pkg->getChannel()); 52 | if ($package) { 53 | $filelist = $package->getFilelist(); 54 | if (isset($filelist[$file]) && isset($filelist[$file]['md5sum'])) { 55 | $this->md5 = $filelist[$file]['md5sum']; 56 | } 57 | } 58 | } 59 | 60 | function processInstallation($pkg, $atts, $file, $tmp_path, $layer = null) 61 | { 62 | $test = parent::processInstallation($pkg, $atts, $file, $tmp_path, $layer); 63 | if (@file_exists($test[2]) && @file_exists($test[3])) { 64 | $md5 = md5_file($test[2]); 65 | // configuration has already been installed, check for mods 66 | if ($md5 !== $this->md5 && $md5 !== md5_file($test[3])) { 67 | // configuration has been modified, so save our version as 68 | // configfile-version 69 | $old = $test[2]; 70 | $test[2] .= '.new-' . $pkg->getVersion(); 71 | // backup original and re-install it 72 | PEAR::pushErrorHandling(PEAR_ERROR_RETURN); 73 | $tmpcfg = $this->config->get('temp_dir'); 74 | $newloc = System::mkdir(array('-p', $tmpcfg)); 75 | if (!$newloc) { 76 | // try temp_dir 77 | $newloc = System::mktemp(array('-d')); 78 | if (!$newloc || PEAR::isError($newloc)) { 79 | PEAR::popErrorHandling(); 80 | return PEAR::raiseError('Could not save existing configuration file '. 81 | $old . ', unable to install. Please set temp_dir ' . 82 | 'configuration variable to a writeable location and try again'); 83 | } 84 | } else { 85 | $newloc = $tmpcfg; 86 | } 87 | 88 | $temp_file = $newloc . DIRECTORY_SEPARATOR . uniqid('savefile'); 89 | if (!@copy($old, $temp_file)) { 90 | PEAR::popErrorHandling(); 91 | return PEAR::raiseError('Could not save existing configuration file '. 92 | $old . ', unable to install. Please set temp_dir ' . 93 | 'configuration variable to a writeable location and try again'); 94 | } 95 | 96 | PEAR::popErrorHandling(); 97 | $this->installer->log(0, "WARNING: configuration file $old is being installed as $test[2], you should manually merge in changes to the existing configuration file"); 98 | $this->installer->addFileOperation('rename', array($temp_file, $old, false)); 99 | $this->installer->addFileOperation('delete', array($temp_file)); 100 | } 101 | } 102 | 103 | return $test; 104 | } 105 | } -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Cfg.xml: -------------------------------------------------------------------------------- 1 | 2 | php 3 | extsrc 4 | extbin 5 | zendextsrc 6 | zendextbin 7 | 1 8 | cfg_dir 9 | 10 | 1 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Common.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 1997-2006 The PHP Group 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a1 14 | */ 15 | /** 16 | * Base class for all installation roles. 17 | * 18 | * This class allows extensibility of file roles. Packages with complex 19 | * customization can now provide custom file roles along with the possibility of 20 | * adding configuration values to match. 21 | * @category pear 22 | * @package PEAR 23 | * @author Greg Beaver 24 | * @copyright 1997-2006 The PHP Group 25 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 26 | * @version Release: 1.10.6 27 | * @link http://pear.php.net/package/PEAR 28 | * @since Class available since Release 1.4.0a1 29 | */ 30 | class PEAR_Installer_Role_Common 31 | { 32 | /** 33 | * @var PEAR_Config 34 | * @access protected 35 | */ 36 | var $config; 37 | 38 | /** 39 | * @param PEAR_Config 40 | */ 41 | function __construct(&$config) 42 | { 43 | $this->config = $config; 44 | } 45 | 46 | /** 47 | * Retrieve configuration information about a file role from its XML info 48 | * 49 | * @param string $role Role Classname, as in "PEAR_Installer_Role_Data" 50 | * @return array 51 | */ 52 | function getInfo($role) 53 | { 54 | if (empty($GLOBALS['_PEAR_INSTALLER_ROLES'][$role])) { 55 | return PEAR::raiseError('Unknown Role class: "' . $role . '"'); 56 | } 57 | return $GLOBALS['_PEAR_INSTALLER_ROLES'][$role]; 58 | } 59 | 60 | /** 61 | * This is called for each file to set up the directories and files 62 | * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 63 | * @param array attributes from the tag 64 | * @param string file name 65 | * @return array an array consisting of: 66 | * 67 | * 1 the original, pre-baseinstalldir installation directory 68 | * 2 the final installation directory 69 | * 3 the full path to the final location of the file 70 | * 4 the location of the pre-installation file 71 | */ 72 | function processInstallation($pkg, $atts, $file, $tmp_path, $layer = null) 73 | { 74 | $roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' . 75 | ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this))))); 76 | if (PEAR::isError($roleInfo)) { 77 | return $roleInfo; 78 | } 79 | if (!$roleInfo['locationconfig']) { 80 | return false; 81 | } 82 | if ($roleInfo['honorsbaseinstall']) { 83 | $dest_dir = $save_destdir = $this->config->get($roleInfo['locationconfig'], $layer, 84 | $pkg->getChannel()); 85 | if (!empty($atts['baseinstalldir'])) { 86 | $dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir']; 87 | } 88 | } elseif ($roleInfo['unusualbaseinstall']) { 89 | $dest_dir = $save_destdir = $this->config->get($roleInfo['locationconfig'], 90 | $layer, $pkg->getChannel()) . DIRECTORY_SEPARATOR . $pkg->getPackage(); 91 | if (!empty($atts['baseinstalldir'])) { 92 | $dest_dir .= DIRECTORY_SEPARATOR . $atts['baseinstalldir']; 93 | } 94 | } else { 95 | $dest_dir = $save_destdir = $this->config->get($roleInfo['locationconfig'], 96 | $layer, $pkg->getChannel()) . DIRECTORY_SEPARATOR . $pkg->getPackage(); 97 | } 98 | if (dirname($file) != '.' && empty($atts['install-as'])) { 99 | $dest_dir .= DIRECTORY_SEPARATOR . dirname($file); 100 | } 101 | if (empty($atts['install-as'])) { 102 | $dest_file = $dest_dir . DIRECTORY_SEPARATOR . basename($file); 103 | } else { 104 | $dest_file = $dest_dir . DIRECTORY_SEPARATOR . $atts['install-as']; 105 | } 106 | $orig_file = $tmp_path . DIRECTORY_SEPARATOR . $file; 107 | 108 | // Clean up the DIRECTORY_SEPARATOR mess 109 | $ds2 = DIRECTORY_SEPARATOR . DIRECTORY_SEPARATOR; 110 | 111 | list($dest_dir, $dest_file, $orig_file) = preg_replace(array('!\\\\+!', '!/!', "!$ds2+!"), 112 | array(DIRECTORY_SEPARATOR, DIRECTORY_SEPARATOR, 113 | DIRECTORY_SEPARATOR), 114 | array($dest_dir, $dest_file, $orig_file)); 115 | return array($save_destdir, $dest_dir, $dest_file, $orig_file); 116 | } 117 | 118 | /** 119 | * Get the name of the configuration variable that specifies the location of this file 120 | * @return string|false 121 | */ 122 | function getLocationConfig() 123 | { 124 | $roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' . 125 | ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this))))); 126 | if (PEAR::isError($roleInfo)) { 127 | return $roleInfo; 128 | } 129 | return $roleInfo['locationconfig']; 130 | } 131 | 132 | /** 133 | * Do any unusual setup here 134 | * @param PEAR_Installer 135 | * @param PEAR_PackageFile_v2 136 | * @param array file attributes 137 | * @param string file name 138 | */ 139 | function setup(&$installer, $pkg, $atts, $file) 140 | { 141 | } 142 | 143 | function isExecutable() 144 | { 145 | $roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' . 146 | ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this))))); 147 | if (PEAR::isError($roleInfo)) { 148 | return $roleInfo; 149 | } 150 | return $roleInfo['executable']; 151 | } 152 | 153 | function isInstallable() 154 | { 155 | $roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' . 156 | ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this))))); 157 | if (PEAR::isError($roleInfo)) { 158 | return $roleInfo; 159 | } 160 | return $roleInfo['installable']; 161 | } 162 | 163 | function isExtension() 164 | { 165 | $roleInfo = PEAR_Installer_Role_Common::getInfo('PEAR_Installer_Role_' . 166 | ucfirst(str_replace('pear_installer_role_', '', strtolower(get_class($this))))); 167 | if (PEAR::isError($roleInfo)) { 168 | return $roleInfo; 169 | } 170 | return $roleInfo['phpextension']; 171 | } 172 | } 173 | ?> 174 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Data.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a1 14 | */ 15 | 16 | /** 17 | * @category pear 18 | * @package PEAR 19 | * @author Greg Beaver 20 | * @copyright 1997-2009 The Authors 21 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 22 | * @version Release: 1.10.6 23 | * @link http://pear.php.net/package/PEAR 24 | * @since Class available since Release 1.4.0a1 25 | */ 26 | class PEAR_Installer_Role_Data extends PEAR_Installer_Role_Common {} 27 | ?> -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Data.xml: -------------------------------------------------------------------------------- 1 | 2 | php 3 | extsrc 4 | extbin 5 | zendextsrc 6 | zendextbin 7 | 1 8 | data_dir 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Doc.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a1 14 | */ 15 | 16 | /** 17 | * @category pear 18 | * @package PEAR 19 | * @author Greg Beaver 20 | * @copyright 1997-2009 The Authors 21 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 22 | * @version Release: 1.10.6 23 | * @link http://pear.php.net/package/PEAR 24 | * @since Class available since Release 1.4.0a1 25 | */ 26 | class PEAR_Installer_Role_Doc extends PEAR_Installer_Role_Common {} 27 | ?> -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Doc.xml: -------------------------------------------------------------------------------- 1 | 2 | php 3 | extsrc 4 | extbin 5 | zendextsrc 6 | zendextbin 7 | 1 8 | doc_dir 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Ext.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a1 14 | */ 15 | 16 | /** 17 | * @category pear 18 | * @package PEAR 19 | * @author Greg Beaver 20 | * @copyright 1997-2009 The Authors 21 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 22 | * @version Release: 1.10.6 23 | * @link http://pear.php.net/package/PEAR 24 | * @since Class available since Release 1.4.0a1 25 | */ 26 | class PEAR_Installer_Role_Ext extends PEAR_Installer_Role_Common {} 27 | ?> -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Ext.xml: -------------------------------------------------------------------------------- 1 | 2 | extbin 3 | zendextbin 4 | 1 5 | ext_dir 6 | 1 7 | 8 | 9 | 10 | 1 11 | 12 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Man.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 2011 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @version SVN: $Id: $ 13 | * @link http://pear.php.net/package/PEAR 14 | * @since File available since Release 1.10.0 15 | */ 16 | 17 | /** 18 | * @category pear 19 | * @package PEAR 20 | * @author Hannes Magnusson 21 | * @copyright 2011 The Authors 22 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 23 | * @version Release: 1.10.6 24 | * @link http://pear.php.net/package/PEAR 25 | * @since Class available since Release 1.10.0 26 | */ 27 | class PEAR_Installer_Role_Man extends PEAR_Installer_Role_Common {} 28 | ?> 29 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Man.xml: -------------------------------------------------------------------------------- 1 | 2 | php 3 | extsrc 4 | extbin 5 | zendextsrc 6 | zendextbin 7 | 1 8 | man_dir 9 | 1 10 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Php.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a1 14 | */ 15 | 16 | /** 17 | * @category pear 18 | * @package PEAR 19 | * @author Greg Beaver 20 | * @copyright 1997-2009 The Authors 21 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 22 | * @version Release: 1.10.6 23 | * @link http://pear.php.net/package/PEAR 24 | * @since Class available since Release 1.4.0a1 25 | */ 26 | class PEAR_Installer_Role_Php extends PEAR_Installer_Role_Common {} 27 | ?> -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Php.xml: -------------------------------------------------------------------------------- 1 | 2 | php 3 | extsrc 4 | extbin 5 | zendextsrc 6 | zendextbin 7 | 1 8 | php_dir 9 | 1 10 | 11 | 1 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Script.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a1 14 | */ 15 | 16 | /** 17 | * @category pear 18 | * @package PEAR 19 | * @author Greg Beaver 20 | * @copyright 1997-2009 The Authors 21 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 22 | * @version Release: 1.10.6 23 | * @link http://pear.php.net/package/PEAR 24 | * @since Class available since Release 1.4.0a1 25 | */ 26 | class PEAR_Installer_Role_Script extends PEAR_Installer_Role_Common {} 27 | ?> -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Script.xml: -------------------------------------------------------------------------------- 1 | 2 | php 3 | extsrc 4 | extbin 5 | zendextsrc 6 | zendextbin 7 | 1 8 | bin_dir 9 | 1 10 | 11 | 12 | 1 13 | 14 | 15 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Src.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a1 14 | */ 15 | 16 | /** 17 | * @category pear 18 | * @package PEAR 19 | * @author Greg Beaver 20 | * @copyright 1997-2009 The Authors 21 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 22 | * @version Release: 1.10.6 23 | * @link http://pear.php.net/package/PEAR 24 | * @since Class available since Release 1.4.0a1 25 | */ 26 | class PEAR_Installer_Role_Src extends PEAR_Installer_Role_Common 27 | { 28 | function setup(&$installer, $pkg, $atts, $file) 29 | { 30 | $installer->source_files++; 31 | } 32 | } 33 | ?> -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Src.xml: -------------------------------------------------------------------------------- 1 | 2 | extsrc 3 | zendextsrc 4 | 1 5 | temp_dir 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Test.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a1 14 | */ 15 | 16 | /** 17 | * @category pear 18 | * @package PEAR 19 | * @author Greg Beaver 20 | * @copyright 1997-2009 The Authors 21 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 22 | * @version Release: 1.10.6 23 | * @link http://pear.php.net/package/PEAR 24 | * @since Class available since Release 1.4.0a1 25 | */ 26 | class PEAR_Installer_Role_Test extends PEAR_Installer_Role_Common {} 27 | ?> -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Test.xml: -------------------------------------------------------------------------------- 1 | 2 | php 3 | extsrc 4 | extbin 5 | zendextsrc 6 | zendextbin 7 | 1 8 | test_dir 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Www.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 2007-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.7.0 14 | */ 15 | 16 | /** 17 | * @category pear 18 | * @package PEAR 19 | * @author Greg Beaver 20 | * @copyright 2007-2009 The Authors 21 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 22 | * @version Release: 1.10.6 23 | * @link http://pear.php.net/package/PEAR 24 | * @since Class available since Release 1.7.0 25 | */ 26 | class PEAR_Installer_Role_Www extends PEAR_Installer_Role_Common {} 27 | ?> -------------------------------------------------------------------------------- /lib/pear/PEAR/Installer/Role/Www.xml: -------------------------------------------------------------------------------- 1 | 2 | php 3 | extsrc 4 | extbin 5 | zendextsrc 6 | zendextbin 7 | 1 8 | www_dir 9 | 1 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /lib/pear/PEAR/PackageFile/Parser/v2.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a1 14 | */ 15 | /** 16 | * base xml parser class 17 | */ 18 | require_once 'PEAR/XMLParser.php'; 19 | require_once 'PEAR/PackageFile/v2.php'; 20 | /** 21 | * Parser for package.xml version 2.0 22 | * @category pear 23 | * @package PEAR 24 | * @author Greg Beaver 25 | * @copyright 1997-2009 The Authors 26 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 27 | * @version Release: @PEAR-VER@ 28 | * @link http://pear.php.net/package/PEAR 29 | * @since Class available since Release 1.4.0a1 30 | */ 31 | class PEAR_PackageFile_Parser_v2 extends PEAR_XMLParser 32 | { 33 | var $_config; 34 | var $_logger; 35 | var $_registry; 36 | 37 | function setConfig(&$c) 38 | { 39 | $this->_config = &$c; 40 | $this->_registry = &$c->getRegistry(); 41 | } 42 | 43 | function setLogger(&$l) 44 | { 45 | $this->_logger = &$l; 46 | } 47 | /** 48 | * Unindent given string 49 | * 50 | * @param string $str The string that has to be unindented. 51 | * @return string 52 | * @access private 53 | */ 54 | function _unIndent($str) 55 | { 56 | // remove leading newlines 57 | $str = preg_replace('/^[\r\n]+/', '', $str); 58 | // find whitespace at the beginning of the first line 59 | $indent_len = strspn($str, " \t"); 60 | $indent = substr($str, 0, $indent_len); 61 | $data = ''; 62 | // remove the same amount of whitespace from following lines 63 | foreach (explode("\n", $str) as $line) { 64 | if (substr($line, 0, $indent_len) == $indent) { 65 | $data .= substr($line, $indent_len) . "\n"; 66 | } else { 67 | $data .= $line . "\n"; 68 | } 69 | } 70 | return $data; 71 | } 72 | 73 | /** 74 | * post-process data 75 | * 76 | * @param string $data 77 | * @param string $element element name 78 | */ 79 | function postProcess($data, $element) 80 | { 81 | if ($element == 'notes') { 82 | return trim($this->_unIndent($data)); 83 | } 84 | return trim($data); 85 | } 86 | 87 | /** 88 | * @param string 89 | * @param string file name of the package.xml 90 | * @param string|false name of the archive this package.xml came from, if any 91 | * @param string class name to instantiate and return. This must be PEAR_PackageFile_v2 or 92 | * a subclass 93 | * @return PEAR_PackageFile_v2 94 | */ 95 | function parse($data, $file = null, $archive = false, $class = 'PEAR_PackageFile_v2') 96 | { 97 | if (PEAR::isError($err = parent::parse($data))) { 98 | return $err; 99 | } 100 | 101 | $ret = new $class; 102 | $ret->encoding = $this->encoding; 103 | $ret->setConfig($this->_config); 104 | if (isset($this->_logger)) { 105 | $ret->setLogger($this->_logger); 106 | } 107 | 108 | $ret->fromArray($this->_unserializedData); 109 | $ret->setPackagefile($file, $archive); 110 | return $ret; 111 | } 112 | } -------------------------------------------------------------------------------- /lib/pear/PEAR/Proxy.php: -------------------------------------------------------------------------------- 1 | config = $config; 43 | $this->_parseProxyInfo(); 44 | } 45 | 46 | /** 47 | * @access private 48 | */ 49 | function _parseProxyInfo() 50 | { 51 | $this->proxy_host = $this->proxy_port = $this->proxy_user = $this->proxy_pass = ''; 52 | if ($this->config->get('http_proxy')&& 53 | $proxy = parse_url($this->config->get('http_proxy')) 54 | ) { 55 | $this->proxy_host = isset($proxy['host']) ? $proxy['host'] : null; 56 | 57 | $this->proxy_port = isset($proxy['port']) ? $proxy['port'] : 8080; 58 | $this->proxy_user = isset($proxy['user']) ? urldecode($proxy['user']) : null; 59 | $this->proxy_pass = isset($proxy['pass']) ? urldecode($proxy['pass']) : null; 60 | $this->proxy_schema = (isset($proxy['scheme']) && $proxy['scheme'] == 'https') ? 'https' : 'http'; 61 | } 62 | } 63 | 64 | /** 65 | * @access private 66 | */ 67 | function _httpConnect($fp, $host, $port) 68 | { 69 | fwrite($fp, "CONNECT $host:$port HTTP/1.1\r\n"); 70 | fwrite($fp, "Host: $host:$port\r\n"); 71 | if ($this->getProxyAuth()) { 72 | fwrite($fp, 'Proxy-Authorization: Basic ' . $this->getProxyAuth() . "\r\n"); 73 | } 74 | fwrite($fp, "\r\n"); 75 | 76 | while ($line = trim(fgets($fp, 1024))) { 77 | if (preg_match('|^HTTP/1.[01] ([0-9]{3}) |', $line, $matches)) { 78 | $code = (int)$matches[1]; 79 | 80 | /* as per RFC 2817 */ 81 | if ($code < 200 || $code >= 300) { 82 | return PEAR::raiseError("Establishing a CONNECT tunnel through proxy failed with response code $code"); 83 | } 84 | } 85 | } 86 | 87 | // connection was successful -- establish SSL through 88 | // the tunnel 89 | $crypto_method = STREAM_CRYPTO_METHOD_TLS_CLIENT; 90 | 91 | if (defined('STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT')) { 92 | $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_2_CLIENT; 93 | $crypto_method |= STREAM_CRYPTO_METHOD_TLSv1_1_CLIENT; 94 | } 95 | 96 | // set the correct hostname for working hostname 97 | // verification 98 | stream_context_set_option($fp, 'ssl', 'peer_name', $host); 99 | 100 | // blocking socket needed for 101 | // stream_socket_enable_crypto() 102 | // see 103 | // 104 | stream_set_blocking ($fp, true); 105 | $crypto_res = stream_socket_enable_crypto($fp, true, $crypto_method); 106 | if (!$crypto_res) { 107 | return PEAR::raiseError("Could not establish SSL connection through proxy $proxy_host:$proxy_port: $crypto_res"); 108 | } 109 | 110 | return true; 111 | } 112 | 113 | /** 114 | * get the authorization information for the proxy, encoded to be 115 | * passed in the Proxy-Authentication HTTP header. 116 | * @return null|string the encoded authentication information if a 117 | * proxy and authentication is configured, null 118 | * otherwise. 119 | */ 120 | function getProxyAuth() 121 | { 122 | if ($this->isProxyConfigured() && $this->proxy_user != '') { 123 | return base64_encode($this->proxy_user . ':' . $this->proxy_pass); 124 | } 125 | return null; 126 | } 127 | 128 | function getProxyUser() 129 | { 130 | return $this->proxy_user; 131 | } 132 | 133 | /** 134 | * Check if we are configured to use a proxy. 135 | * 136 | * @return boolean true if we are configured to use a proxy, false 137 | * otherwise. 138 | * @access public 139 | */ 140 | function isProxyConfigured() 141 | { 142 | return $this->proxy_host != ''; 143 | } 144 | 145 | /** 146 | * Open a socket to a remote server, possibly involving a HTTP 147 | * proxy. 148 | * 149 | * If an HTTP proxy has been configured (http_proxy PEAR_Config 150 | * setting), the proxy will be used. 151 | * 152 | * @param string $host the host to connect to 153 | * @param string $port the port to connect to 154 | * @param boolean $secure if true, establish a secure connection 155 | * using TLS. 156 | * @access public 157 | */ 158 | function openSocket($host, $port, $secure = false) 159 | { 160 | if ($this->isProxyConfigured()) { 161 | $fp = @fsockopen( 162 | $this->proxy_host, $this->proxy_port, 163 | $errno, $errstr, 15 164 | ); 165 | 166 | if (!$fp) { 167 | return PEAR::raiseError("Connection to `$proxy_host:$proxy_port' failed: $errstr", -9276); 168 | } 169 | 170 | /* HTTPS is to be used and we have a proxy, use CONNECT verb */ 171 | if ($secure) { 172 | $res = $this->_httpConnect($fp, $host, $port); 173 | 174 | if (PEAR::isError($res)) { 175 | return $res; 176 | } 177 | } 178 | } else { 179 | if ($secure) { 180 | $host = 'ssl://' . $host; 181 | } 182 | 183 | $fp = @fsockopen($host, $port, $errno, $errstr); 184 | if (!$fp) { 185 | return PEAR::raiseError("Connection to `$host:$port' failed: $errstr", $errno); 186 | } 187 | } 188 | 189 | return $fp; 190 | } 191 | } 192 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Task/Common.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a1 14 | */ 15 | /**#@+ 16 | * Error codes for task validation routines 17 | */ 18 | define('PEAR_TASK_ERROR_NOATTRIBS', 1); 19 | define('PEAR_TASK_ERROR_MISSING_ATTRIB', 2); 20 | define('PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE', 3); 21 | define('PEAR_TASK_ERROR_INVALID', 4); 22 | /**#@-*/ 23 | define('PEAR_TASK_PACKAGE', 1); 24 | define('PEAR_TASK_INSTALL', 2); 25 | define('PEAR_TASK_PACKAGEANDINSTALL', 3); 26 | /** 27 | * A task is an operation that manipulates the contents of a file. 28 | * 29 | * Simple tasks operate on 1 file. Multiple tasks are executed after all files have been 30 | * processed and installed, and are designed to operate on all files containing the task. 31 | * The Post-install script task simply takes advantage of the fact that it will be run 32 | * after installation, replace is a simple task. 33 | * 34 | * Combining tasks is possible, but ordering is significant. 35 | * 36 | * 37 | * 38 | * 39 | * 40 | * 41 | * This will first replace any instance of @data-dir@ in the test.php file 42 | * with the path to the current data directory. Then, it will include the 43 | * test.php file and run the script it contains to configure the package post-installation. 44 | * 45 | * @category pear 46 | * @package PEAR 47 | * @author Greg Beaver 48 | * @copyright 1997-2009 The Authors 49 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 50 | * @version Release: 1.10.6 51 | * @link http://pear.php.net/package/PEAR 52 | * @since Class available since Release 1.4.0a1 53 | * @abstract 54 | */ 55 | class PEAR_Task_Common 56 | { 57 | /** 58 | * Valid types for this version are 'simple' and 'multiple' 59 | * 60 | * - simple tasks operate on the contents of a file and write out changes to disk 61 | * - multiple tasks operate on the contents of many files and write out the 62 | * changes directly to disk 63 | * 64 | * Child task classes must override this property. 65 | * 66 | * @access protected 67 | */ 68 | protected $type = 'simple'; 69 | /** 70 | * Determines which install phase this task is executed under 71 | */ 72 | public $phase = PEAR_TASK_INSTALL; 73 | /** 74 | * @access protected 75 | */ 76 | protected $config; 77 | /** 78 | * @access protected 79 | */ 80 | protected $registry; 81 | /** 82 | * @access protected 83 | */ 84 | public $logger; 85 | /** 86 | * @access protected 87 | */ 88 | protected $installphase; 89 | /** 90 | * @param PEAR_Config 91 | * @param PEAR_Common 92 | */ 93 | function __construct(&$config, &$logger, $phase) 94 | { 95 | $this->config = &$config; 96 | $this->registry = &$config->getRegistry(); 97 | $this->logger = &$logger; 98 | $this->installphase = $phase; 99 | if ($this->type == 'multiple') { 100 | $GLOBALS['_PEAR_TASK_POSTINSTANCES'][get_class($this)][] = &$this; 101 | } 102 | } 103 | 104 | /** 105 | * Validate the basic contents of a task tag. 106 | * 107 | * @param PEAR_PackageFile_v2 108 | * @param array 109 | * @param PEAR_Config 110 | * @param array the entire parsed tag 111 | * 112 | * @return true|array On error, return an array in format: 113 | * array(PEAR_TASK_ERROR_???[, param1][, param2][, ...]) 114 | * 115 | * For PEAR_TASK_ERROR_MISSING_ATTRIB, pass the attribute name in 116 | * For PEAR_TASK_ERROR_WRONG_ATTRIB_VALUE, pass the attribute name and 117 | * an array of legal values in 118 | * 119 | * @abstract 120 | */ 121 | public static function validateXml($pkg, $xml, $config, $fileXml) 122 | { 123 | } 124 | 125 | /** 126 | * Initialize a task instance with the parameters 127 | * 128 | * @param array raw, parsed xml 129 | * @param array attributes from the tag containing this task 130 | * @param string|null last installed version of this package 131 | * @abstract 132 | */ 133 | public function init($xml, $fileAttributes, $lastVersion) 134 | { 135 | } 136 | 137 | /** 138 | * Begin a task processing session. All multiple tasks will be processed 139 | * after each file has been successfully installed, all simple tasks should 140 | * perform their task here and return any errors using the custom 141 | * throwError() method to allow forward compatibility 142 | * 143 | * This method MUST NOT write out any changes to disk 144 | * 145 | * @param PEAR_PackageFile_v2 146 | * @param string file contents 147 | * @param string the eventual final file location (informational only) 148 | * @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail 149 | * (use $this->throwError), otherwise return the new contents 150 | * @abstract 151 | */ 152 | public function startSession($pkg, $contents, $dest) 153 | { 154 | } 155 | 156 | /** 157 | * This method is used to process each of the tasks for a particular 158 | * multiple class type. Simple tasks need not implement this method. 159 | * 160 | * @param array an array of tasks 161 | * @access protected 162 | */ 163 | public static function run($tasks) 164 | { 165 | } 166 | 167 | /** 168 | * @final 169 | */ 170 | public static function hasPostinstallTasks() 171 | { 172 | return isset($GLOBALS['_PEAR_TASK_POSTINSTANCES']); 173 | } 174 | 175 | /** 176 | * @final 177 | */ 178 | public static function runPostinstallTasks() 179 | { 180 | foreach ($GLOBALS['_PEAR_TASK_POSTINSTANCES'] as $class => $tasks) { 181 | $err = call_user_func( 182 | array($class, 'run'), 183 | $GLOBALS['_PEAR_TASK_POSTINSTANCES'][$class] 184 | ); 185 | if ($err) { 186 | return PEAR_Task_Common::throwError($err); 187 | } 188 | } 189 | unset($GLOBALS['_PEAR_TASK_POSTINSTANCES']); 190 | } 191 | 192 | /** 193 | * Determines whether a role is a script 194 | * @return bool 195 | */ 196 | public function isScript() 197 | { 198 | return $this->type == 'script'; 199 | } 200 | 201 | public function throwError($msg, $code = -1) 202 | { 203 | include_once 'PEAR.php'; 204 | 205 | return PEAR::raiseError($msg, $code); 206 | } 207 | } 208 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Task/Postinstallscript/rw.php: -------------------------------------------------------------------------------- 1 | - read/write version 4 | * 5 | * PHP versions 4 and 5 6 | * 7 | * @category pear 8 | * @package PEAR 9 | * @author Greg Beaver 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a10 14 | */ 15 | /** 16 | * Base class 17 | */ 18 | require_once 'PEAR/Task/Postinstallscript.php'; 19 | /** 20 | * Abstracts the postinstallscript file task xml. 21 | * @category pear 22 | * @package PEAR 23 | * @author Greg Beaver 24 | * @copyright 1997-2009 The Authors 25 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 26 | * @version Release: 1.10.6 27 | * @link http://pear.php.net/package/PEAR 28 | * @since Class available since Release 1.4.0a10 29 | */ 30 | class PEAR_Task_Postinstallscript_rw extends PEAR_Task_Postinstallscript 31 | { 32 | /** 33 | * parent package file object 34 | * 35 | * @var PEAR_PackageFile_v2_rw 36 | */ 37 | public $_pkg; 38 | /** 39 | * Enter description here... 40 | * 41 | * @param PEAR_PackageFile_v2_rw $pkg Package 42 | * @param PEAR_Config $config Config 43 | * @param PEAR_Frontend $logger Logger 44 | * @param array $fileXml XML 45 | * 46 | * @return PEAR_Task_Postinstallscript_rw 47 | */ 48 | function __construct(&$pkg, &$config, &$logger, $fileXml) 49 | { 50 | parent::__construct($config, $logger, PEAR_TASK_PACKAGE); 51 | $this->_contents = $fileXml; 52 | $this->_pkg = &$pkg; 53 | $this->_params = array(); 54 | } 55 | 56 | public function validate() 57 | { 58 | return $this->validateXml($this->_pkg, $this->_params, $this->config, $this->_contents); 59 | } 60 | 61 | public function getName() 62 | { 63 | return 'postinstallscript'; 64 | } 65 | 66 | /** 67 | * add a simple to the post-install script 68 | * 69 | * Order is significant, so call this method in the same 70 | * sequence the users should see the paramgroups. The $params 71 | * parameter should either be the result of a call to {@link getParam()} 72 | * or an array of calls to getParam(). 73 | * 74 | * Use {@link addConditionTypeGroup()} to add a containing 75 | * a tag 76 | * 77 | * @param string $id id as seen by the script 78 | * @param array|false $params array of getParam() calls, or false for no params 79 | * @param string|false $instructions 80 | */ 81 | public function addParamGroup($id, $params = false, $instructions = false) 82 | { 83 | if ($params && isset($params[0]) && !isset($params[1])) { 84 | $params = $params[0]; 85 | } 86 | $stuff = 87 | array( 88 | $this->_pkg->getTasksNs().':id' => $id, 89 | ); 90 | if ($instructions) { 91 | $stuff[$this->_pkg->getTasksNs().':instructions'] = $instructions; 92 | } 93 | if ($params) { 94 | $stuff[$this->_pkg->getTasksNs().':param'] = $params; 95 | } 96 | $this->_params[$this->_pkg->getTasksNs().':paramgroup'][] = $stuff; 97 | } 98 | 99 | /** 100 | * Add a complex to the post-install script with conditions 101 | * 102 | * This inserts a with 103 | * 104 | * Order is significant, so call this method in the same 105 | * sequence the users should see the paramgroups. The $params 106 | * parameter should either be the result of a call to {@link getParam()} 107 | * or an array of calls to getParam(). 108 | * 109 | * Use {@link addParamGroup()} to add a simple 110 | * 111 | * @param string $id id as seen by the script 112 | * @param string $oldgroup id of the section referenced by 113 | * 114 | * @param string $param name of the from the older section referenced 115 | * by 116 | * @param string $value value to match of the parameter 117 | * @param string $conditiontype one of '=', '!=', 'preg_match' 118 | * @param array|false $params array of getParam() calls, or false for no params 119 | * @param string|false $instructions 120 | */ 121 | public function addConditionTypeGroup($id, 122 | $oldgroup, 123 | $param, 124 | $value, 125 | $conditiontype = '=', 126 | $params = false, 127 | $instructions = false 128 | ) { 129 | if ($params && isset($params[0]) && !isset($params[1])) { 130 | $params = $params[0]; 131 | } 132 | $stuff = array( 133 | $this->_pkg->getTasksNs().':id' => $id, 134 | ); 135 | if ($instructions) { 136 | $stuff[$this->_pkg->getTasksNs().':instructions'] = $instructions; 137 | } 138 | $stuff[$this->_pkg->getTasksNs().':name'] = $oldgroup.'::'.$param; 139 | $stuff[$this->_pkg->getTasksNs().':conditiontype'] = $conditiontype; 140 | $stuff[$this->_pkg->getTasksNs().':value'] = $value; 141 | if ($params) { 142 | $stuff[$this->_pkg->getTasksNs().':param'] = $params; 143 | } 144 | $this->_params[$this->_pkg->getTasksNs().':paramgroup'][] = $stuff; 145 | } 146 | 147 | public function getXml() 148 | { 149 | return $this->_params; 150 | } 151 | 152 | /** 153 | * Use to set up a param tag for use in creating a paramgroup 154 | * 155 | * @param mixed $name Name of parameter 156 | * @param mixed $prompt Prompt 157 | * @param string $type Type, defaults to 'string' 158 | * @param mixed $default Default value 159 | * 160 | * @return array 161 | */ 162 | public function getParam( 163 | $name, $prompt, $type = 'string', $default = null 164 | ) { 165 | if ($default !== null) { 166 | return 167 | array( 168 | $this->_pkg->getTasksNs().':name' => $name, 169 | $this->_pkg->getTasksNs().':prompt' => $prompt, 170 | $this->_pkg->getTasksNs().':type' => $type, 171 | $this->_pkg->getTasksNs().':default' => $default, 172 | ); 173 | } 174 | 175 | return 176 | array( 177 | $this->_pkg->getTasksNs().':name' => $name, 178 | $this->_pkg->getTasksNs().':prompt' => $prompt, 179 | $this->_pkg->getTasksNs().':type' => $type, 180 | ); 181 | } 182 | } 183 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Task/Replace/rw.php: -------------------------------------------------------------------------------- 1 | - read/write version 4 | * 5 | * PHP versions 4 and 5 6 | * 7 | * @category pear 8 | * @package PEAR 9 | * @author Greg Beaver 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a10 14 | */ 15 | /** 16 | * Base class 17 | */ 18 | require_once 'PEAR/Task/Replace.php'; 19 | /** 20 | * Abstracts the replace task xml. 21 | * @category pear 22 | * @package PEAR 23 | * @author Greg Beaver 24 | * @copyright 1997-2009 The Authors 25 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 26 | * @version Release: 1.10.6 27 | * @link http://pear.php.net/package/PEAR 28 | * @since Class available since Release 1.4.0a10 29 | */ 30 | class PEAR_Task_Replace_rw extends PEAR_Task_Replace 31 | { 32 | public function __construct(&$pkg, &$config, &$logger, $fileXml) 33 | { 34 | parent::__construct($config, $logger, PEAR_TASK_PACKAGE); 35 | $this->_contents = $fileXml; 36 | $this->_pkg = &$pkg; 37 | $this->_params = array(); 38 | } 39 | 40 | public function validate() 41 | { 42 | return $this->validateXml($this->_pkg, $this->_params, $this->config, $this->_contents); 43 | } 44 | 45 | public function setInfo($from, $to, $type) 46 | { 47 | $this->_params = array('attribs' => array('from' => $from, 'to' => $to, 'type' => $type)); 48 | } 49 | 50 | public function getName() 51 | { 52 | return 'replace'; 53 | } 54 | 55 | public function getXml() 56 | { 57 | return $this->_params; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Task/Unixeol.php: -------------------------------------------------------------------------------- 1 | 4 | * 5 | * PHP versions 4 and 5 6 | * 7 | * @category pear 8 | * @package PEAR 9 | * @author Greg Beaver 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a1 14 | */ 15 | /** 16 | * Base class 17 | */ 18 | require_once 'PEAR/Task/Common.php'; 19 | /** 20 | * Implements the unix line endings file task. 21 | * @category pear 22 | * @package PEAR 23 | * @author Greg Beaver 24 | * @copyright 1997-2009 The Authors 25 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 26 | * @version Release: 1.10.6 27 | * @link http://pear.php.net/package/PEAR 28 | * @since Class available since Release 1.4.0a1 29 | */ 30 | class PEAR_Task_Unixeol extends PEAR_Task_Common 31 | { 32 | public $type = 'simple'; 33 | public $phase = PEAR_TASK_PACKAGE; 34 | public $_replacements; 35 | 36 | /** 37 | * Validate the raw xml at parsing-time. 38 | * 39 | * @param PEAR_PackageFile_v2 40 | * @param array raw, parsed xml 41 | * @param PEAR_Config 42 | */ 43 | public static function validateXml($pkg, $xml, $config, $fileXml) 44 | { 45 | if ($xml != '') { 46 | return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed'); 47 | } 48 | 49 | return true; 50 | } 51 | 52 | /** 53 | * Initialize a task instance with the parameters 54 | * @param array raw, parsed xml 55 | * @param unused 56 | * @param unused 57 | */ 58 | public function init($xml, $attribs, $lastVersion = null) 59 | { 60 | } 61 | 62 | /** 63 | * Replace all line endings with line endings customized for the current OS 64 | * 65 | * See validateXml() source for the complete list of allowed fields 66 | * 67 | * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 68 | * @param string file contents 69 | * @param string the eventual final file location (informational only) 70 | * @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail 71 | * (use $this->throwError), otherwise return the new contents 72 | */ 73 | public function startSession($pkg, $contents, $dest) 74 | { 75 | $this->logger->log(3, "replacing all line endings with \\n in $dest"); 76 | 77 | return preg_replace("/\r\n|\n\r|\r|\n/", "\n", $contents); 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Task/Unixeol/rw.php: -------------------------------------------------------------------------------- 1 | - read/write version 4 | * 5 | * PHP versions 4 and 5 6 | * 7 | * @category pear 8 | * @package PEAR 9 | * @author Greg Beaver 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a10 14 | */ 15 | /** 16 | * Base class 17 | */ 18 | require_once 'PEAR/Task/Unixeol.php'; 19 | /** 20 | * Abstracts the unixeol task xml. 21 | * @category pear 22 | * @package PEAR 23 | * @author Greg Beaver 24 | * @copyright 1997-2009 The Authors 25 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 26 | * @version Release: 1.10.6 27 | * @link http://pear.php.net/package/PEAR 28 | * @since Class available since Release 1.4.0a10 29 | */ 30 | class PEAR_Task_Unixeol_rw extends PEAR_Task_Unixeol 31 | { 32 | function __construct(&$pkg, &$config, &$logger, $fileXml) 33 | { 34 | parent::__construct($config, $logger, PEAR_TASK_PACKAGE); 35 | $this->_contents = $fileXml; 36 | $this->_pkg = &$pkg; 37 | $this->_params = array(); 38 | } 39 | 40 | public function validate() 41 | { 42 | return true; 43 | } 44 | 45 | public function getName() 46 | { 47 | return 'unixeol'; 48 | } 49 | 50 | public function getXml() 51 | { 52 | return ''; 53 | } 54 | } 55 | ?> 56 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Task/Windowseol.php: -------------------------------------------------------------------------------- 1 | 4 | * 5 | * PHP versions 4 and 5 6 | * 7 | * @category pear 8 | * @package PEAR 9 | * @author Greg Beaver 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a1 14 | */ 15 | /** 16 | * Base class 17 | */ 18 | require_once 'PEAR/Task/Common.php'; 19 | /** 20 | * Implements the windows line endsings file task. 21 | * 22 | * @category pear 23 | * @package PEAR 24 | * @author Greg Beaver 25 | * @copyright 1997-2009 The Authors 26 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 27 | * @version Release: 1.10.6 28 | * @link http://pear.php.net/package/PEAR 29 | * @since Class available since Release 1.4.0a1 30 | */ 31 | class PEAR_Task_Windowseol extends PEAR_Task_Common 32 | { 33 | public $type = 'simple'; 34 | public $phase = PEAR_TASK_PACKAGE; 35 | public $_replacements; 36 | 37 | /** 38 | * Validate the raw xml at parsing-time. 39 | * 40 | * @param PEAR_PackageFile_v2 41 | * @param array raw, parsed xml 42 | * @param PEAR_Config 43 | */ 44 | public static function validateXml($pkg, $xml, $config, $fileXml) 45 | { 46 | if ($xml != '') { 47 | return array(PEAR_TASK_ERROR_INVALID, 'no attributes allowed'); 48 | } 49 | 50 | return true; 51 | } 52 | 53 | /** 54 | * Initialize a task instance with the parameters 55 | * @param array raw, parsed xml 56 | * @param unused 57 | * @param unused 58 | */ 59 | public function init($xml, $attribs, $lastVersion = null) 60 | { 61 | } 62 | 63 | /** 64 | * Replace all line endings with windows line endings 65 | * 66 | * See validateXml() source for the complete list of allowed fields 67 | * 68 | * @param PEAR_PackageFile_v1|PEAR_PackageFile_v2 69 | * @param string file contents 70 | * @param string the eventual final file location (informational only) 71 | * @return string|false|PEAR_Error false to skip this file, PEAR_Error to fail 72 | * (use $this->throwError), otherwise return the new contents 73 | */ 74 | public function startSession($pkg, $contents, $dest) 75 | { 76 | $this->logger->log(3, "replacing all line endings with \\r\\n in $dest"); 77 | 78 | return preg_replace("/\r\n|\n\r|\r|\n/", "\r\n", $contents); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Task/Windowseol/rw.php: -------------------------------------------------------------------------------- 1 | - read/write version 4 | * 5 | * PHP versions 4 and 5 6 | * 7 | * @category pear 8 | * @package PEAR 9 | * @author Greg Beaver 10 | * @copyright 1997-2009 The Authors 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a10 14 | */ 15 | /** 16 | * Base class 17 | */ 18 | require_once 'PEAR/Task/Windowseol.php'; 19 | /** 20 | * Abstracts the windowseol task xml. 21 | * 22 | * @category pear 23 | * @package PEAR 24 | * @author Greg Beaver 25 | * @copyright 1997-2009 The Authors 26 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 27 | * @version Release: 1.10.6 28 | * @link http://pear.php.net/package/PEAR 29 | * @since Class available since Release 1.4.0a10 30 | */ 31 | class PEAR_Task_Windowseol_rw extends PEAR_Task_Windowseol 32 | { 33 | function __construct(&$pkg, &$config, &$logger, $fileXml) 34 | { 35 | parent::__construct($config, $logger, PEAR_TASK_PACKAGE); 36 | $this->_contents = $fileXml; 37 | $this->_pkg = &$pkg; 38 | $this->_params = array(); 39 | } 40 | 41 | public function validate() 42 | { 43 | return true; 44 | } 45 | 46 | public function getName() 47 | { 48 | return 'windowseol'; 49 | } 50 | 51 | public function getXml() 52 | { 53 | return ''; 54 | } 55 | } 56 | ?> 57 | -------------------------------------------------------------------------------- /lib/pear/PEAR/Validator/PECL.php: -------------------------------------------------------------------------------- 1 | 10 | * @copyright 1997-2006 The PHP Group 11 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 12 | * @link http://pear.php.net/package/PEAR 13 | * @since File available since Release 1.4.0a5 14 | */ 15 | /** 16 | * This is the parent class for all validators 17 | */ 18 | require_once 'PEAR/Validate.php'; 19 | /** 20 | * Channel Validator for the pecl.php.net channel 21 | * @category pear 22 | * @package PEAR 23 | * @author Greg Beaver 24 | * @copyright 1997-2009 The Authors 25 | * @license http://opensource.org/licenses/bsd-license.php New BSD License 26 | * @version Release: 1.10.6 27 | * @link http://pear.php.net/package/PEAR 28 | * @since Class available since Release 1.4.0a5 29 | */ 30 | class PEAR_Validator_PECL extends PEAR_Validate 31 | { 32 | function validateVersion() 33 | { 34 | if ($this->_state == PEAR_VALIDATE_PACKAGING) { 35 | $version = $this->_packagexml->getVersion(); 36 | $versioncomponents = explode('.', $version); 37 | $last = array_pop($versioncomponents); 38 | if (substr($last, 1, 2) == 'rc') { 39 | $this->_addFailure('version', 'Release Candidate versions must have ' . 40 | 'upper-case RC, not lower-case rc'); 41 | return false; 42 | } 43 | } 44 | return true; 45 | } 46 | 47 | function validatePackageName() 48 | { 49 | $ret = parent::validatePackageName(); 50 | if ($this->_packagexml->getPackageType() == 'extsrc' || 51 | $this->_packagexml->getPackageType() == 'zendextsrc') { 52 | if (strtolower($this->_packagexml->getPackage()) != 53 | strtolower($this->_packagexml->getProvidesExtension())) { 54 | $this->_addWarning('providesextension', 'package name "' . 55 | $this->_packagexml->getPackage() . '" is different from extension name "' . 56 | $this->_packagexml->getProvidesExtension() . '"'); 57 | } 58 | } 59 | return $ret; 60 | } 61 | } 62 | ?> -------------------------------------------------------------------------------- /lib/pear/license.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------- 2 | The PHP License, version 2.02 3 | Copyright (c) 1999 - 2002 The PHP Group. All rights reserved. 4 | -------------------------------------------------------------------- 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, is permitted provided that the following conditions 8 | are met: 9 | 10 | 1. Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | 13 | 2. Redistributions in binary form must reproduce the above 14 | copyright notice, this list of conditions and the following 15 | disclaimer in the documentation and/or other materials provided 16 | with the distribution. 17 | 18 | 3. The name "PHP" must not be used to endorse or promote products 19 | derived from this software without prior permission from the 20 | PHP Group. This does not apply to add-on libraries or tools 21 | that work in conjunction with PHP. In such a case the PHP 22 | name may be used to indicate that the product supports PHP. 23 | 24 | 4. The PHP Group may publish revised and/or new versions of the 25 | license from time to time. Each version will be given a 26 | distinguishing version number. 27 | Once covered code has been published under a particular version 28 | of the license, you may always continue to use it under the 29 | terms of that version. You may also choose to use such covered 30 | code under the terms of any subsequent version of the license 31 | published by the PHP Group. No one other than the PHP Group has 32 | the right to modify the terms applicable to covered code created 33 | under this License. 34 | 35 | 5. Redistributions of any form whatsoever must retain the following 36 | acknowledgment: 37 | "This product includes PHP, freely available from 38 | http://www.php.net/". 39 | 40 | 6. The software incorporates the Zend Engine, a product of Zend 41 | Technologies, Ltd. ("Zend"). The Zend Engine is licensed to the 42 | PHP Association (pursuant to a grant from Zend that can be 43 | found at http://www.php.net/license/ZendGrant/) for 44 | distribution to you under this license agreement, only as a 45 | part of PHP. In the event that you separate the Zend Engine 46 | (or any portion thereof) from the rest of the software, or 47 | modify the Zend Engine, or any portion thereof, your use of the 48 | separated or modified Zend Engine software shall not be governed 49 | by this license, and instead shall be governed by the license 50 | set forth at http://www.zend.com/license/ZendLicense/. 51 | 52 | 53 | 54 | THIS SOFTWARE IS PROVIDED BY THE PHP DEVELOPMENT TEAM ``AS IS'' AND 55 | ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 56 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A 57 | PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE PHP 58 | DEVELOPMENT TEAM OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 59 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 60 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 61 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 62 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 63 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 64 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 65 | OF THE POSSIBILITY OF SUCH DAMAGE. 66 | 67 | -------------------------------------------------------------------- 68 | 69 | This software consists of voluntary contributions made by many 70 | individuals on behalf of the PHP Group. 71 | 72 | The PHP Group can be contacted via Email at group@php.net. 73 | 74 | For more information on the PHP Group and the PHP project, 75 | please see . 76 | -------------------------------------------------------------------------------- /log/.gitignore: -------------------------------------------------------------------------------- 1 | # Ignore everything in this directory 2 | * 3 | # Except this file 4 | !.gitignore 5 | -------------------------------------------------------------------------------- /messagesAdmin.php: -------------------------------------------------------------------------------- 1 | 9 | * @version 2021-11-08 10 | * @package mailzu-ng 11 | * 12 | * Copyright (C) 2021 mailzu-ng 13 | * License: GPL, see LICENSE 14 | */ 15 | 16 | /** 17 | * Include autoloader 18 | */ 19 | include_once('lib/autoload.php'); 20 | /** 21 | * Include common output functions 22 | */ 23 | include_once('templates/common.template.php'); 24 | /** 25 | * Include quarantine-specific output functions 26 | */ 27 | include_once('templates/quarantine.template.php'); 28 | 29 | if (!Auth::is_logged_in()) { 30 | (new Auth())->print_login_msg(); // Check if user is logged in 31 | } 32 | 33 | // grab the display size limit set in config.php 34 | $sizeLimit = isset ($conf['app']['displaySizeLimitAdmin']) && is_numeric($conf['app']['displaySizeLimitAdmin']) ? 35 | $conf['app']['displaySizeLimitAdmin'] : 50; 36 | // Get current page number 37 | $requestedPage = CmnFns::getGlobalVar('page', GET); 38 | 39 | $_SESSION['sessionNav'] = "Site Quarantine"; 40 | 41 | $db = new DBEngine(); 42 | 43 | $t = new Template(translate('Site Quarantine')); 44 | 45 | $t->printHTMLHeader(); 46 | $t->printWelcome(); 47 | $t->startMain(); 48 | 49 | // Break table into 2 columns, put quick links on left side and all other tables on the right 50 | startQuickLinksCol(); 51 | showQuickLinks(); // Print out My Quick Links 52 | startDataDisplayCol(); 53 | 54 | if (!Auth::isMailAdmin()) { 55 | CmnFns::do_error_box(translate('Access Denied')); 56 | } else { 57 | // Draw search engine 58 | $content_type = (CmnFns::get_ctype() ?: 'A'); 59 | printSearchEngine($content_type, $_SERVER['PHP_SELF'], 1); 60 | echo '
'; 61 | 62 | if (CmnFns::getGlobalVar('search_action', GET) == translate('Clear search results')) { 63 | CmnFns::redirect_js($_SERVER['PHP_SELF'] . '?searchOnly=' . $conf['app']['searchOnly']); 64 | } 65 | 66 | $search_array1 = $db->convertSearch2SQL('msgs.from_addr', CmnFns::getGlobalVar('f_criterion', GET), CmnFns::getGlobalVar('f_string', GET)); 67 | $search_array2 = $db->convertSearch2SQL('msgs.subject', CmnFns::getGlobalVar('s_criterion', GET), CmnFns::getGlobalVar('s_string', GET)); 68 | $search_array3 = $db->convertSearch2SQL('recip.email', CmnFns::getGlobalVar('t_criterion', GET), CmnFns::getGlobalVar('t_string', GET)); 69 | $search_array4 = $db->convertSearch2SQL('msgs.mail_id', CmnFns::getGlobalVar('m_criterion', GET), CmnFns::getGlobalVar('m_string', GET)); 70 | 71 | $search_array = array_merge($search_array1, $search_array2, $search_array3, $search_array4); 72 | 73 | $order = array('msgs.time_num', 'from_addr', 'msgs.subject', 'spam_level', 'recip.email', 'msgs.content', 'mail_id'); 74 | // Arbitrary type for Admin 75 | //$content_type = (CmnFns::get_ctype() ? CmnFns::get_ctype() : 'A'); 76 | 77 | //echo "Before query: " . date("l dS of F Y h:i:s A") . "

"; 78 | 79 | if (CmnFns::getGlobalVar('searchOnly', GET) != 1) { 80 | // Print a loading message until database returns... 81 | printMessage(translate('Retrieving Messages...')); 82 | 83 | $messages = $db->get_user_messages($content_type, $_SESSION['sessionMail'], CmnFns::get_value_order($order), CmnFns::get_vert_order(), $search_array, 1, 0, $requestedPage); 84 | } 85 | 86 | // Compute maximum number of pages 87 | $maxPage = (ceil($db->numRows / $sizeLimit) - 1); 88 | 89 | // If $requestedPage > $maxPage, then redirect to $maxPage instead of $requestedPage 90 | if ($requestedPage > $maxPage) { 91 | $query_string = CmnFns::array_to_query_string($_GET, array('page')); 92 | $query_string = str_replace('&', '&', $query_string); 93 | CmnFns::redirect_js($_SERVER['PHP_SELF'] . '?' . $query_string . '&page=' . $maxPage); 94 | } 95 | 96 | if (CmnFns::getGlobalVar('searchOnly', GET) != 1) { 97 | showMessagesTable($content_type, $messages, $requestedPage, CmnFns::get_value_order($order), CmnFns::get_vert_order(), $db->numRows); 98 | 99 | // Hide the message after the table loads. 100 | hideMessage(translate('Retrieving Messages...')); 101 | } 102 | 103 | } 104 | 105 | endDataDisplayCol(); 106 | $t->endMain(); 107 | $t->printHTMLFooter(); 108 | ?> 109 | -------------------------------------------------------------------------------- /messagesIndex.php: -------------------------------------------------------------------------------- 1 | 9 | * @version 2021-11-08 10 | * @package mailzu-ng 11 | * 12 | * Copyright (C) 2021 mailzu-ng 13 | * License: GPL, see LICENSE 14 | */ 15 | 16 | /** 17 | * Include autoloader 18 | */ 19 | include_once('lib/autoload.php'); 20 | /** 21 | * Include common output functions 22 | */ 23 | include_once('templates/common.template.php'); 24 | /** 25 | * Include quarantine-specific output functions 26 | */ 27 | include_once('templates/quarantine.template.php'); 28 | 29 | if (!Auth::is_logged_in()) { 30 | (new Auth())->print_login_msg(); // Check if user is logged in 31 | } 32 | 33 | // grab the display size limit set in config.php 34 | $sizeLimit = isset ($conf['app']['displaySizeLimit']) && is_numeric($conf['app']['displaySizeLimit']) ? 35 | $conf['app']['displaySizeLimit'] : 50; 36 | 37 | //Get content type 38 | $content_type = (CmnFns::get_ctype() ?: 'A'); 39 | 40 | $order = array('msgs.time_num', 'from_addr', 'msgs.subject', 'spam_level', 'recip.email', 'msgs.content', 'mail_id'); 41 | // Get current page number 42 | $requestedPage = CmnFns::getGlobalVar('page', GET); 43 | 44 | $_SESSION['sessionNav'] = "My Quarantine"; 45 | $t = new Template(translate('My Quarantine')); 46 | 47 | $db = new DBEngine(); 48 | 49 | $t->printHTMLHeader(); 50 | $t->printWelcome(); 51 | $t->startMain(); 52 | 53 | // Break table into 2 columns, put quick links on left side and all other tables on the right 54 | startQuickLinksCol(); 55 | showQuickLinks(); // Print out My Quick Links 56 | startDataDisplayCol(); 57 | 58 | // Draw search engine 59 | printSearchEngine($content_type, $_SERVER['PHP_SELF'], (count($_SESSION['sessionMail']) > 1)); 60 | echo '
'; 61 | 62 | if (CmnFns::getGlobalVar('search_action', GET) == translate('Clear search results')) CmnFns::redirect_js($_SERVER['PHP_SELF']); 63 | 64 | $search_array1 = $db->convertSearch2SQL('msgs.from_addr', CmnFns::getGlobalVar('f_criterion', GET), CmnFns::getGlobalVar('f_string', GET)); 65 | $search_array2 = $db->convertSearch2SQL('msgs.subject', CmnFns::getGlobalVar('s_criterion', GET), CmnFns::getGlobalVar('s_string', GET)); 66 | $search_array3 = $db->convertSearch2SQL('recip.email', CmnFns::getGlobalVar('t_criterion', GET), CmnFns::getGlobalVar('t_string', GET)); 67 | $search_array4 = $db->convertSearch2SQL('msgs.mail_id', CmnFns::getGlobalVar('m_criterion', GET), CmnFns::getGlobalVar('m_string', GET)); 68 | $search_array = array_merge($search_array1, $search_array2, $search_array3, $search_array4); 69 | 70 | // Print a loading message until database returns... 71 | printMessage(translate('Retrieving Messages...')); 72 | 73 | $messages = $db->get_user_messages($content_type, $_SESSION['sessionMail'], CmnFns::get_value_order($order), CmnFns::get_vert_order(), $search_array, 0, 0, $requestedPage); 74 | 75 | // Compute maximum number of pages 76 | $maxPage = (ceil($db->numRows / $sizeLimit) - 1); 77 | 78 | // If $requestedPage > $maxPage, then redirect to $maxPage instead of $requestedPage 79 | if ($requestedPage > $maxPage) { 80 | $query_string = CmnFns::array_to_query_string($_GET, array('page')); 81 | $query_string = str_replace('&', '&', $query_string); 82 | CmnFns::redirect_js($_SERVER['PHP_SELF'] . '?' . $query_string . '&page=' . $maxPage); 83 | } 84 | 85 | showMessagesTable($content_type, $messages, $requestedPage, CmnFns::get_value_order($order), CmnFns::get_vert_order(), $db->numRows); 86 | 87 | // Hide the message after the table loads. 88 | hideMessage(translate('Retrieving Messages...')); 89 | 90 | endDataDisplayCol(); 91 | $t->endMain(); 92 | $t->printHTMLFooter(); 93 | ?> 94 | -------------------------------------------------------------------------------- /messagesPending.php: -------------------------------------------------------------------------------- 1 | 6 | * @version 2021-11-08 7 | * @package mailzu-ng 8 | * 9 | * Copyright (C) 2021 mailzu-ng 10 | * License: GPL, see LICENSE 11 | */ 12 | 13 | /** 14 | * Include autoloader 15 | */ 16 | include_once('lib/autoload.php'); 17 | /** 18 | * Include common output functions 19 | */ 20 | include_once('templates/common.template.php'); 21 | /** 22 | * Include quarantine-specific output functions 23 | */ 24 | include_once('templates/quarantine.template.php'); 25 | 26 | if (!Auth::is_logged_in()) { 27 | (new Auth())->print_login_msg(); // Check if user is logged in 28 | } 29 | 30 | // grab the display size limit set in config.php 31 | $sizeLimit = isset ($conf['app']['displaySizeLimit']) && is_numeric($conf['app']['displaySizeLimit']) ? 32 | $conf['app']['displaySizeLimit'] : 50; 33 | 34 | //Get content type 35 | $content_type = (CmnFns::get_ctype() ?: 'A'); 36 | 37 | $order = array('msgs.time_num', 'from_addr', 'msgs.subject', 'spam_level', 'recip.email', 'msgs.content', 'mail_id'); 38 | // Get current page number 39 | $requestedPage = CmnFns::getGlobalVar('page', GET); 40 | 41 | $_SESSION['sessionNav'] = "My Pending Requests"; 42 | $t = new Template(translate('My Pending Requests')); 43 | 44 | $db = new DBEngine(); 45 | 46 | $t->printHTMLHeader(); 47 | $t->printWelcome(); 48 | $t->startMain(); 49 | 50 | // Break table into 2 columns, put quick links on left side and all other tables on the right 51 | startQuickLinksCol(); 52 | showQuickLinks(); // Print out My Quick Links 53 | startDataDisplayCol(); 54 | 55 | // Draw search engine 56 | printSearchEngine($content_type, $_SERVER['PHP_SELF'], (count($_SESSION['sessionMail']) > 1)); 57 | echo '
'; 58 | 59 | if (CmnFns::getGlobalVar('search_action', GET) == translate('Clear search results')) CmnFns::redirect_js($_SERVER['PHP_SELF']); 60 | 61 | $search_array1 = $db->convertSearch2SQL('msgs.from_addr', CmnFns::getGlobalVar('f_criterion', GET), CmnFns::getGlobalVar('f_string', GET)); 62 | $search_array2 = $db->convertSearch2SQL('msgs.subject', CmnFns::getGlobalVar('s_criterion', GET), CmnFns::getGlobalVar('s_string', GET)); 63 | $search_array3 = $db->convertSearch2SQL('recip.email', CmnFns::getGlobalVar('t_criterion', GET), CmnFns::getGlobalVar('t_string', GET)); 64 | $search_array4 = $db->convertSearch2SQL('msgs.mail_id', CmnFns::getGlobalVar('m_criterion', GET), CmnFns::getGlobalVar('m_string', GET)); 65 | $search_array = array_merge($search_array1, $search_array2, $search_array3, $search_array4); 66 | 67 | // Print a loading message until database returns... 68 | printMessage(translate('Retrieving Messages...')); 69 | 70 | $messages = $db->get_user_messages($content_type, $_SESSION['sessionMail'], CmnFns::get_value_order($order), CmnFns::get_vert_order(), $search_array, false, 1, $requestedPage); 71 | 72 | // Compute maximum number of pages 73 | $maxPage = (ceil($db->numRows / $sizeLimit) - 1); 74 | 75 | // If $requestedPage > $maxPage, then redirect to $maxPage instead of $requestedPage 76 | if ($requestedPage > $maxPage) { 77 | $query_string = CmnFns::array_to_query_string($_GET, array('page')); 78 | $query_string = str_replace('&', '&', $query_string); 79 | CmnFns::redirect_js($_SERVER['PHP_SELF'] . '?' . $query_string . '&page=' . $maxPage); 80 | } 81 | 82 | showMessagesTable($content_type, $messages, $requestedPage, CmnFns::get_value_order($order), CmnFns::get_vert_order()); 83 | 84 | // Hide the message after the table loads. 85 | hideMessage(translate('Retrieving Messages...')); 86 | 87 | endDataDisplayCol(); 88 | $t->endMain(); 89 | $t->printHTMLFooter(); 90 | ?> 91 | -------------------------------------------------------------------------------- /messagesPendingAdmin.php: -------------------------------------------------------------------------------- 1 | 6 | * @version 2021-11-08 7 | * @package mailzu-ng 8 | * 9 | * Copyright (C) 2021 mailzu-ng 10 | * License: GPL, see LICENSE 11 | */ 12 | 13 | /** 14 | * Include autoloader 15 | */ 16 | include_once('lib/autoload.php'); 17 | /** 18 | * Include common output functions 19 | */ 20 | include_once('templates/common.template.php'); 21 | /** 22 | * Include quarantine-specific output functions 23 | */ 24 | include_once('templates/quarantine.template.php'); 25 | 26 | if (!Auth::is_logged_in()) { 27 | (new Auth())->print_login_msg(); // Check if user is logged in 28 | } 29 | 30 | // grab the display size limit set in config.php 31 | $sizeLimit = isset ($conf['app']['displaySizeLimit']) && is_numeric($conf['app']['displaySizeLimit']) ? 32 | $conf['app']['displaySizeLimit'] : 50; 33 | 34 | $_SESSION['sessionNav'] = "Site Pending Requests"; 35 | 36 | // Get current page number 37 | $requestedPage = CmnFns::getGlobalVar('page', GET); 38 | 39 | $db = new DBEngine(); 40 | 41 | $t = new Template(translate('Site Quarantine')); 42 | 43 | $t->printHTMLHeader(); 44 | $t->printWelcome(); 45 | $t->startMain(); 46 | 47 | // Break table into 2 columns, put quick links on left side and all other tables on the right 48 | startQuickLinksCol(); 49 | showQuickLinks(); // Print out My Quick Links 50 | startDataDisplayCol(); 51 | 52 | if (!Auth::isMailAdmin()) { 53 | CmnFns::do_error_box(translate('Access Denied')); 54 | } else { 55 | // Arbitrary type for Admin 56 | $content_type = (CmnFns::get_ctype() ?: 'A'); 57 | // Draw search engine 58 | printSearchEngine($content_type, $_SERVER['PHP_SELF'], 1); 59 | echo '
'; 60 | 61 | if (CmnFns::getGlobalVar('search_action', GET) == translate('Clear search results')) CmnFns::redirect_js($_SERVER['PHP_SELF']); 62 | 63 | $search_array1 = $db->convertSearch2SQL('msgs.from_addr', CmnFns::getGlobalVar('f_criterion', GET), CmnFns::getGlobalVar('f_string', GET)); 64 | $search_array2 = $db->convertSearch2SQL('msgs.subject', CmnFns::getGlobalVar('s_criterion', GET), CmnFns::getGlobalVar('s_string', GET)); 65 | $search_array3 = $db->convertSearch2SQL('recip.email', CmnFns::getGlobalVar('t_criterion', GET), CmnFns::getGlobalVar('t_string', GET)); 66 | $search_array4 = $db->convertSearch2SQL('msgs.mail_id', CmnFns::getGlobalVar('m_criterion', GET), CmnFns::getGlobalVar('m_string', GET)); 67 | 68 | $search_array = array_merge($search_array1, $search_array2, $search_array3, $search_array4); 69 | 70 | $order = array('msgs.time_num', 'from_addr', 'msgs.subject', 'spam_level', 'recip.email', 'msgs.content', 'mail_id'); 71 | 72 | // Print a loading message until database returns... 73 | printMessage(translate('Retrieving Messages...')); 74 | 75 | $messages = $db->get_user_messages($content_type, $_SESSION['sessionMail'], CmnFns::get_value_order($order), CmnFns::get_vert_order(), $search_array, 1, 1, $requestedPage); 76 | 77 | // Compute maximum number of pages 78 | $maxPage = (ceil($db->numRows / $sizeLimit) - 1); 79 | 80 | // If $requestedPage > $maxPage, then redirect to $maxPage instead of $requestedPage 81 | if ($requestedPage > $maxPage) { 82 | $query_string = CmnFns::array_to_query_string($_GET, array('page')); 83 | $query_string = str_replace('&', '&', $query_string); 84 | CmnFns::redirect_js($_SERVER['PHP_SELF'] . '?' . $query_string . '&page=' . $maxPage); 85 | } 86 | 87 | showMessagesTable($content_type, $messages, $requestedPage, CmnFns::get_value_order($order), CmnFns::get_vert_order()); 88 | 89 | // Hide the message after the table loads. 90 | hideMessage(translate('Retrieving Messages...')); 91 | } 92 | 93 | endDataDisplayCol(); 94 | $t->endMain(); 95 | $t->printHTMLFooter(); 96 | ?> 97 | -------------------------------------------------------------------------------- /messagesProcessing.php: -------------------------------------------------------------------------------- 1 | 7 | * @version 2021-11-08 8 | * @package mailzu-ng 9 | * 10 | * Copyright (C) 2021 mailzu-ng 11 | * License: GPL, see LICENSE 12 | */ 13 | 14 | /** 15 | * Include autoloader 16 | */ 17 | include_once('lib/autoload.php'); 18 | /** 19 | * Include common output functions 20 | */ 21 | include_once('templates/common.template.php'); 22 | /** 23 | * Include quarantine-specific output functions 24 | */ 25 | include_once('templates/quarantine.template.php'); 26 | 27 | if (!Auth::is_logged_in()) { 28 | (new Auth())->print_login_msg(); // Check if user is logged in 29 | } 30 | 31 | //Turn off all error reporting, useless for users 32 | error_reporting(0); 33 | 34 | $db = new DBEngine(); 35 | 36 | $t = new Template(translate('Message Processing')); 37 | 38 | $t->printHTMLHeader(); 39 | $t->printWelcome(); 40 | $t->startMain(); 41 | 42 | // Break table into 2 columns, put quick links on left side and all other tables on the right 43 | startQuickLinksCol(); 44 | showQuickLinks(); // Print out My Quick Links 45 | startDataDisplayCol(); 46 | 47 | $action = CmnFns::get_action(); 48 | $content_type = CmnFns::get_ctype(); 49 | $query_string = CmnFns::get_query_string(); 50 | $mail_id_array = CmnFns::getGlobalVar('mail_id_array', POST); 51 | 52 | switch ($_SESSION['sessionNav']) { 53 | case 'My Quarantine': 54 | $referral = 'messagesIndex.php'; 55 | break; 56 | case 'Site Quarantine': 57 | $referral = 'messagesAdmin.php'; 58 | break; 59 | case 'My Pending Requests': 60 | case 'Site Pending Requests': 61 | $referral = 'messagesPending.php'; 62 | break; 63 | } 64 | 65 | // If no message was selected and the action is not "Delete All" 66 | if (!isset($mail_id_array) && $action != translate('Delete All')) 67 | 68 | printNoMesgWarning(); 69 | 70 | elseif (isset($action)) { 71 | 72 | switch ($action) { 73 | case translate('Release'): 74 | case translate('Release/Request release'): 75 | $failed_array = releaseMessages($_SESSION['sessionMail'], $mail_id_array); 76 | if (is_array($failed_array) && !empty($failed_array)) { 77 | showFailedMessagesTable($action, $content_type, $failed_array); 78 | printCpanelBr(); 79 | printReportButtons($query_string, $failed_array, $action); 80 | } else { 81 | CmnFns::redirect_js($referral . '?' . $query_string); 82 | } 83 | break; 84 | case translate('Cancel Request'): 85 | $failed_array = updateMessages('', $content_type, $_SESSION['sessionMail'], $mail_id_array); 86 | if (is_array($failed_array) && !empty($failed_array)) { 87 | showFailedMessagesTable($action, $content_type, $failed_array); 88 | printCpanelBr(); 89 | printReportButtons($query_string, $failed_array, $action); 90 | } else { 91 | CmnFns::redirect_js($referral . '?' . $query_string); 92 | } 93 | break; 94 | case translate('Delete'): 95 | $failed_array = updateMessages('D', $content_type, $_SESSION['sessionMail'], $mail_id_array); 96 | if (is_array($failed_array) && !empty($failed_array)) { 97 | showFailedMessagesTable($action, $content_type, $failed_array); 98 | printCpanelBr(); 99 | printReportButtons($query_string, $failed_array, $action); 100 | } else { 101 | CmnFns::redirect_js($referral . '?' . $query_string); 102 | } 103 | break; 104 | case translate('Delete All'): 105 | $failed_array = updateMessages('D', $content_type, $_SESSION['sessionMail'], '', true); 106 | if (is_array($failed_array) && !empty($failed_array)) { 107 | showFailedMessagesTable($action, $content_type, $failed_array); 108 | printCpanelBr(); 109 | printReportButtons($query_string, $failed_array, $action); 110 | } else { 111 | CmnFns::redirect_js($referral . '?' . $query_string); 112 | } 113 | break; 114 | default: 115 | CmnFns::do_error_box(translate('Unknown action type'), '', false); 116 | } 117 | 118 | } 119 | 120 | endDataDisplayCol(); 121 | $t->endMain(); 122 | $t->printHTMLFooter(); 123 | ?> 124 | -------------------------------------------------------------------------------- /messagesSummary.php: -------------------------------------------------------------------------------- 1 | 11 | * @version 2021-11-08 12 | * @package mailzu-ng 13 | * 14 | * Copyright (C) 2021 mailzu-ng 15 | * License: GPL, see LICENSE 16 | */ 17 | 18 | /** 19 | * Include autoloader 20 | */ 21 | include_once('lib/autoload.php'); 22 | /** 23 | * Include common output functions 24 | */ 25 | include_once('templates/common.template.php'); 26 | /** 27 | * Include quarantine-specific output functions 28 | */ 29 | include_once('templates/summary.template.php'); 30 | 31 | if (!Auth::is_logged_in()) { 32 | (new Auth())->print_login_msg(); // Check if user is logged in 33 | } 34 | 35 | $_SESSION['sessionNav'] = "Site Quarantine Summary"; 36 | $t = new Template(translate('Site Quarantine Summary')); 37 | 38 | $db = new DBEngine(); 39 | 40 | $t->printHTMLHeader(); 41 | $t->printWelcome(); 42 | $t->startMain(); 43 | 44 | // Break table into 2 columns, put quick links on left side and all other tables on the right 45 | startQuickLinksCol(); 46 | showQuickLinks(); // Print out My Quick Links 47 | startDataDisplayCol(); 48 | 49 | if (!Auth::isMailAdmin() || !$conf['app']['siteSummary']) { 50 | CmnFns::do_error_box(translate('Access Denied')); 51 | 52 | } else { 53 | 54 | // Print a loading message until database returns... 55 | printMessage(translate('Loading Summary...')); 56 | 57 | $count_array = $db->get_site_summary(); 58 | 59 | showSummary($count_array); 60 | 61 | // Hide the message after the table loads. 62 | hideMessage(translate('Loading Summary...')); 63 | 64 | } 65 | 66 | endDataDisplayCol(); 67 | $t->endMain(); 68 | $t->printHTMLFooter(); 69 | ?> 70 | -------------------------------------------------------------------------------- /read_mail.php: -------------------------------------------------------------------------------- 1 | 10 | * @version 2021-11-08 11 | * @package mailzu-ng 12 | * 13 | * Copyright (C) 2021 mailzu-ng 14 | * License: GPL, see LICENSE 15 | */ 16 | 17 | /** 18 | * Include autoloader 19 | */ 20 | include_once('lib/autoload.php'); 21 | /** 22 | * Include control panel-specific output functions 23 | */ 24 | include_once('templates/common.template.php'); 25 | /** 26 | * Include viewmail template class 27 | */ 28 | include_once('templates/viewmail.template.php'); 29 | 30 | if (!Auth::is_logged_in()) { 31 | (new Auth())->print_login_msg(); // Check if user is logged in 32 | } 33 | 34 | $t = new Template(translate('Message View')); 35 | 36 | $t->printHTMLHeader(); 37 | $t->printWelcome(); 38 | $t->startMain(); 39 | 40 | // Break table into 2 columns, put quick links on left side and all other tables on the right 41 | startQuickLinksCol(); 42 | showQuickLinks(); // Print out My Quick Links 43 | startDataDisplayCol(); 44 | 45 | $mail_id = CmnFns::get_mail_id(); 46 | $content_type = CmnFns::getGlobalVar('ctype', GET); 47 | $recip_email = CmnFns::getGlobalVar('recip_email', GET); 48 | $load_images_var = CmnFns::getGlobalVar('load_images', GET); 49 | $query_string = CmnFns::querystring_exclude_vars(array('mail_id', 'recip_email', 'load_images')); 50 | 51 | 52 | if (!Auth::isMailAdmin() && !in_array($recip_email, $_SESSION['sessionMail'])) { 53 | CmnFns::do_error_box(translate('Access Denied')); 54 | } else { 55 | $m = new MailEngine($mail_id, $recip_email); 56 | 57 | if (!$m->msg_found) { 58 | CmnFns::do_error_box(translate('Message Unavailable')); 59 | 60 | } else { 61 | 62 | echo '
'; 63 | echo ' '; 64 | echo ' '; 65 | printActionButtons(false); 66 | echo '
'; 67 | 68 | MsgDisplayOptions(CmnFns::get_mail_id(), $recip_email); 69 | startMessage(); 70 | MsgDisplayHeaders($m->struct); 71 | // Give a space before the body displays 72 | echo '
' . "\n"; 73 | if (!$m->msg_error) { 74 | MsgDisplayBody($m->struct); 75 | } else { 76 | echo "

$m->last_error

"; 77 | } 78 | endMessage(); 79 | } 80 | } 81 | endDataDisplayCol(); 82 | $t->endMain(); 83 | $t->printHTMLFooter(); 84 | ?> 85 | -------------------------------------------------------------------------------- /read_original.php: -------------------------------------------------------------------------------- 1 | 6 | * @version 2021-11-08 7 | * @package mailzu-ng 8 | * 9 | * Copyright (C) 2021 mailzu-ng 10 | * License: GPL, see LICENSE 11 | */ 12 | 13 | /** 14 | * Include autoloader 15 | */ 16 | include_once('lib/autoload.php'); 17 | /** 18 | * Include control panel-specific output functions 19 | */ 20 | include_once('templates/common.template.php'); 21 | /** 22 | * Include viewmail template class 23 | */ 24 | include_once('templates/viewmail.template.php'); 25 | 26 | if (!Auth::is_logged_in()) { 27 | (new Auth())->print_login_msg(); // Check if user is logged in 28 | } 29 | 30 | $t = new Template(translate('ViewOriginal')); 31 | 32 | $t->printHTMLHeader(); 33 | $t->startMain(); 34 | 35 | //$mail_id = CmnFns::get_mail_id(); 36 | $mail_id = CmnFns::getGlobalVar('mail_id', GET); 37 | $recip_email = CmnFns::getGlobalVar('recip_email', GET); 38 | 39 | if (!Auth::isMailAdmin() && !in_array($recip_email, $_SESSION['sessionMail'])) { 40 | CmnFns::do_error_box(translate('Access Denied')); 41 | } else { 42 | $m = new MailEngine($mail_id, $recip_email); 43 | 44 | MsgOriginalOptions(); 45 | MailMime::MsgBodyPlainText($m->raw); 46 | } 47 | 48 | $t->endMain(); 49 | $t->printHTMLFooter(); 50 | ?> 51 | -------------------------------------------------------------------------------- /scripts/mailzu-db-cleanup.php: -------------------------------------------------------------------------------- 1 | #!/usr/bin/php 2 | 10 | * 11 | **/ 12 | 13 | /** 14 | * Base directory of application 15 | */ 16 | @define('BASE_DIR', __DIR__ . '/..'); 17 | 18 | /** 19 | * Include configuration file 20 | **/ 21 | 22 | if ( file_exists(BASE_DIR . '/config/config.php') ) { 23 | include_once(BASE_DIR . '/config/config.php'); 24 | } else { 25 | die('Unable to load database configuration data from '. BASE_DIR . '/config/config.php'.PHP_EOL); 26 | } 27 | 28 | $dbType = $conf['db']['dbType']; 29 | $dbName = $conf['db']['dbName']; 30 | $dbUser = $conf['db']['dbUser']; 31 | $dbPass = $conf['db']['dbPass']; 32 | $dbHost = $conf['db']['hostSpec']; 33 | 34 | // Declare max days to keep quarantine items 35 | $keep_days = 14; 36 | 37 | // Calculate the timestamp 38 | $prune_older_then = time() - ($keep_days * 24 * 60 * 60); 39 | 40 | // Connect to the database 41 | switch ($dbType) { 42 | case "mysql": 43 | $dsn = $dbType . ':host=' . $dbHost . ';dbname=' . $dbName.';charset=utf8'; 44 | break; 45 | default: 46 | $dsn = $dbType . ':host=' . $dbHost . ';dbname=' . $dbName; 47 | break; 48 | } 49 | 50 | try { 51 | $db = new PDO($dsn, $dbUser, $dbPass); 52 | } catch (PDOException $e) { 53 | die ('Error connecting to database: ' . $e->getMessage()); 54 | } 55 | // Set fetch mode to return associatve array 56 | $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE,PDO::FETCH_ASSOC); 57 | 58 | 59 | // Delete old msgs records based on timestamps only (for time_iso see next), 60 | // and delete leftover msgs records from aborted mail checking operations 61 | $query="DELETE FROM msgs WHERE time_num < ".$prune_older_then.";"; 62 | // Prepare query 63 | $q = $db->prepare($query); 64 | // Execute query 65 | $result = $q->execute(); 66 | if ( $result === false ) { 67 | $err_array = $q->errorInfo(); 68 | $err_msg = 'Error['.$err_array[1].']: '.$err_array[2].' SQLSTATE='.$err_array[0]; 69 | die ('There was an error executing your query ' . $err_msg . PHP_EOL); 70 | } 71 | $q->closeCursor(); 72 | 73 | $query="DELETE FROM msgs WHERE time_num < 60*60 AND content IS NULL;"; 74 | // Prepare query 75 | $q = $db->prepare($query); 76 | // Execute query 77 | $result = $q->execute(); 78 | if ( $result === false ) { 79 | $err_array = $q->errorInfo(); 80 | $err_msg = 'Error['.$err_array[1].']: '.$err_array[2].' SQLSTATE='.$err_array[0]; 81 | die ('There was an error executing your query ' . $err_msg . PHP_EOL); 82 | } 83 | $q->closeCursor(); 84 | 85 | $query="DELETE msgs FROM msgs LEFT JOIN msgrcpt ON msgrcpt.mail_id = msgs.mail_id WHERE msgrcpt.rs = 'D';"; 86 | // Prepare query 87 | $q = $db->prepare($query); 88 | // Execute query 89 | $result = $q->execute(); 90 | if ( $result === false ) { 91 | $err_array = $q->errorInfo(); 92 | $err_msg = 'Error['.$err_array[1].']: '.$err_array[2].' SQLSTATE='.$err_array[0]; 93 | die ('There was an error executing your query ' . $err_msg . PHP_EOL); 94 | } 95 | $q->closeCursor(); 96 | 97 | $query="DELETE FROM quarantine WHERE mail_id IN (SELECT mail_id FROM msgrcpt WHERE rs = 'D');"; 98 | // Prepare query 99 | $q = $db->prepare($query); 100 | // Execute query 101 | $result = $q->execute(); 102 | if ( $result === false ) { 103 | $err_array = $q->errorInfo(); 104 | $err_msg = 'Error['.$err_array[1].']: '.$err_array[2].' SQLSTATE='.$err_array[0]; 105 | die ('There was an error executing your query ' . $err_msg . PHP_EOL); 106 | } 107 | $q->closeCursor(); 108 | 109 | 110 | $query="DELETE FROM msgrcpt WHERE rs = 'D';"; 111 | // Prepare query 112 | $q = $db->prepare($query); 113 | // Execute query 114 | $result = $q->execute(); 115 | if ( $result === false ) { 116 | $err_array = $q->errorInfo(); 117 | $err_msg = 'Error['.$err_array[1].']: '.$err_array[2].' SQLSTATE='.$err_array[0]; 118 | die ('There was an error executing your query ' . $err_msg . PHP_EOL); 119 | } 120 | $q->closeCursor(); 121 | 122 | // Delete unreferenced e-mail addresses 123 | $query="DELETE FROM maddr WHERE id NOT IN (SELECT sid FROM msgs) AND id NOT IN (SELECT rid FROM msgrcpt);"; 124 | // Prepare query 125 | $q = $db->prepare($query); 126 | // Execute query 127 | $result = $q->execute(); 128 | if ( $result === false ) { 129 | $err_array = $q->errorInfo(); 130 | $err_msg = 'Error['.$err_array[1].']: '.$err_array[2].' SQLSTATE='.$err_array[0]; 131 | die ('There was an error executing your query ' . $err_msg . PHP_EOL); 132 | } 133 | $q->closeCursor(); 134 | 135 | // When a FOREIGN KEY ... ON DELETE CASCADE is not used, tables msgrcpt 136 | // and quarantine need to be purged explicitly, e.g.: 137 | $query="DELETE FROM quarantine WHERE NOT EXISTS (SELECT 1 FROM msgs WHERE mail_id=quarantine.mail_id);"; 138 | // Prepare query 139 | $q = $db->prepare($query); 140 | // Execute query 141 | $result = $q->execute(); 142 | if ( $result === false ) { 143 | $err_array = $q->errorInfo(); 144 | $err_msg = 'Error['.$err_array[1].']: '.$err_array[2].' SQLSTATE='.$err_array[0]; 145 | die ('There was an error executing your query ' . $err_msg . PHP_EOL); 146 | } 147 | $q->closeCursor(); 148 | 149 | $query="DELETE FROM msgrcpt WHERE NOT EXISTS (SELECT 1 FROM msgs WHERE mail_id=msgrcpt.mail_id);"; 150 | // Prepare query 151 | $q = $db->prepare($query); 152 | // Execute query 153 | $result = $q->execute(); 154 | if ( $result === false ) { 155 | $err_array = $q->errorInfo(); 156 | $err_msg = 'Error['.$err_array[1].']: '.$err_array[2].' SQLSTATE='.$err_array[0]; 157 | die ('There was an error executing your query ' . $err_msg . PHP_EOL); 158 | } 159 | $q->closeCursor(); 160 | 161 | // Optimize tables 162 | $query="OPTIMIZE TABLE msgs, msgrcpt, quarantine, maddr;"; 163 | // Prepare query 164 | $q = $db->prepare($query); 165 | // Execute query 166 | $result = $q->execute(); 167 | if ( $result === false ) { 168 | $err_array = $q->errorInfo(); 169 | $err_msg = 'Error['.$err_array[1].']: '.$err_array[2].' SQLSTATE='.$err_array[0]; 170 | die ('There was an error executing your query ' . $err_msg . PHP_EOL); 171 | } 172 | $q->closeCursor(); 173 | 174 | // Close the database 175 | $q = null; 176 | $db = null; 177 | -------------------------------------------------------------------------------- /sendErrorReport.php: -------------------------------------------------------------------------------- 1 | 7 | * @version 2021-11-08 8 | * @package mailzu-ng 9 | * 10 | * Copyright (C) 2021 mailzu-ng 11 | * License: GPL, see LICENSE 12 | */ 13 | 14 | /** 15 | * Include autoloader 16 | */ 17 | include_once('lib/autoload.php'); 18 | /** 19 | * Include common output functions 20 | */ 21 | include_once('templates/common.template.php'); 22 | /** 23 | * Include quarantine-specific output functions 24 | */ 25 | include_once('templates/quarantine.template.php'); 26 | 27 | if (!Auth::is_logged_in()) { 28 | (new Auth())->print_login_msg(); // Check if user is logged in 29 | } 30 | 31 | //Turn off all error reporting, useless for users 32 | error_reporting(0); 33 | 34 | $t = new Template(translate('Message Processing')); 35 | 36 | $t->printHTMLHeader(); 37 | $t->printWelcome(); 38 | $t->startMain(); 39 | 40 | // Break table into 2 columns, put quick links on left side and all other tables on the right 41 | startQuickLinksCol(); 42 | showQuickLinks(); // Print out My Quick Links 43 | startDataDisplayCol(); 44 | 45 | $action = CmnFns::getGlobalVar('action', POST); 46 | $query_string = CmnFns::get_query_string(); 47 | 48 | if (isset($action)) { 49 | switch ($action) { 50 | case translate('Send report and go back'): 51 | $process_action = CmnFns::getGlobalVar('process_action', POST); 52 | $error_array = unserialize(urldecode(CmnFns::getGlobalVar('serialized_error_array', POST))); 53 | sendMailToAdmin($process_action, $error_array); 54 | CmnFns::redirect_js('messagesIndex.php?' . $query_string); 55 | break; 56 | case translate('Go back'): 57 | CmnFns::redirect_js('messagesIndex.php?' . $query_string); 58 | break; 59 | default: 60 | CmnFns::do_error_box(translate('Unknown action type'), '', false); 61 | } 62 | } 63 | 64 | endDataDisplayCol(); 65 | $t->endMain(); 66 | $t->printHTMLFooter(); 67 | ?> 68 | -------------------------------------------------------------------------------- /send_mail.php: -------------------------------------------------------------------------------- 1 | 10 | * @version 2021-11-08 11 | * @package mailzu-ng 12 | * 13 | * Copyright (C) 2021 mailzu-ng 14 | * License: GPL, see LICENSE 15 | */ 16 | 17 | /** 18 | * Include autoloader 19 | */ 20 | include_once('lib/autoload.php'); 21 | /** 22 | * Include control panel-specific output functions 23 | */ 24 | include_once('templates/common.template.php'); 25 | /** 26 | * Include sendmail to admin specific output functions 27 | */ 28 | include_once('templates/sendmail.template.php'); 29 | 30 | if (!Auth::is_logged_in()) { 31 | (new Auth())->print_login_msg(); // Check if user is logged in 32 | } 33 | 34 | $_SESSION['sessionNav'] = "Email Administrator"; 35 | 36 | $t = new Template(translate('Email Administrator')); 37 | 38 | $t->printHTMLHeader(); 39 | $t->printWelcome(); 40 | $t->startMain(); 41 | 42 | // Break table into 2 columns, put quick links on left side and all other tables on the right 43 | startQuickLinksCol(); 44 | showQuickLinks(); // Print out My Quick Links 45 | startDataDisplayCol(); 46 | 47 | $action = CmnFns::getGlobalVar('action', POST); 48 | 49 | if (isset($action)) { 50 | verifyAndSendMail(); 51 | } else { 52 | printsendmail(); 53 | } 54 | 55 | endDataDisplayCol(); 56 | $t->endMain(); 57 | $t->printHTMLFooter(); 58 | ?> 59 | -------------------------------------------------------------------------------- /summary.php: -------------------------------------------------------------------------------- 1 | 11 | * @version 2021-11-08 12 | * @package mailzu-ng 13 | * 14 | * Copyright (C) 2021 mailzu-ng 15 | * License: GPL, see LICENSE 16 | */ 17 | /** 18 | * Include autoloader 19 | */ 20 | include_once('lib/autoload.php'); 21 | /** 22 | * Include common output functions 23 | */ 24 | include_once('templates/common.template.php'); 25 | /** 26 | * Include quarantine-specific output functions 27 | */ 28 | include_once('templates/summary.template.php'); 29 | 30 | if (!Auth::is_logged_in()) { 31 | (new Auth())->print_login_msg(); // Check if user is logged in 32 | } 33 | 34 | $_SESSION['sessionNav'] = "Quarantine Summary"; 35 | $t = new Template(translate('Quarantine Summary')); 36 | 37 | $db = new DBEngine(); 38 | 39 | $t->printHTMLHeader(); 40 | $t->printWelcome(); 41 | $t->startMain(); 42 | 43 | // Break table into 2 columns, put quick links on left side and all other tables on the right 44 | startQuickLinksCol(); 45 | showQuickLinks(); // Print out My Quick Links 46 | startDataDisplayCol(); 47 | 48 | // Print a loading message until database returns... 49 | printMessage(translate('Loading Summary...')); 50 | 51 | $count_array = $db->get_user_summary($_SESSION['sessionMail']); 52 | 53 | showSummary($count_array); 54 | 55 | // Hide the message after the table loads. 56 | hideMessage(translate('Loading Summary...')); 57 | 58 | endDataDisplayCol(); 59 | $t->endMain(); 60 | $t->printHTMLFooter(); 61 | ?> 62 | -------------------------------------------------------------------------------- /templates/auth.template.php: -------------------------------------------------------------------------------- 1 | 7 | * @version 2021-11-08 8 | * @package Templates 9 | * 10 | * Copyright (C) 2021 mailzu-ng 11 | * License: GPL, see LICENSE 12 | */ 13 | 14 | $link = CmnFns::getNewLink(); // Get Link object 15 | 16 | /** 17 | * Prints out a login form and any error messages 18 | * @param string $msg error messages to display for user 19 | * @param string $resume page to resume on after login 20 | */ 21 | function printLoginForm($msg = '', $resume = '') 22 | { 23 | global $conf; 24 | $link = CmnFns::getNewLink(); 25 | 26 | // Check browser information 27 | echo ''; 28 | 29 | if (!empty($msg)) 30 | CmnFns::do_error_box($msg, '', false); 31 | ?> 32 |
33 | 34 | 35 | 98 | 99 |
36 | 37 | 38 | 41 | 42 | 43 | 46 | 49 | 50 | 51 | 54 | 57 | 58 | 59 | 60 | 63 | 67 | 68 | 70 | 71 | 74 | 77 | 78 | 79 | 80 | 83 | 86 | 87 | 88 | 95 | 96 |
39 |
40 |
44 |

45 |
47 | 48 |
52 |

53 |
55 | 56 |
61 |

62 |
64 | 66 |
72 |

73 |
75 | 76 |
81 |

82 |
84 | 85 |
89 |

90 | 92 | 93 |

94 |
97 |
100 |

101 | doLink('javascript: help();', translate('Help'), '', '', translate('Get online help')) ?> 102 |

103 |
104 | 108 | -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/gnanet/mailzu/84f409cd7898f540d7963ae2cb99e0f33f5f576b/templates/index.html -------------------------------------------------------------------------------- /templates/sendmail.template.php: -------------------------------------------------------------------------------- 1 | 17 | 18 | 19 | 61 | 62 |
20 | 21 | 22 | 37 | 43 | 44 |
23 | 35 | 36 | 38 |
39 | doLink('javascript: help(\'msg_index\');', '?', '', 'color: #FFFFFF;', 40 | translate('Help') . ' - ' . translate('Email Administrator')) ?> 41 |
42 |
45 | 46 | 47 | 48 | 49 | 50 | 58 | 59 |

51 |   
52 |   

53 |   
54 |   
55 |   

56 | 57 |
60 |
63 | 64 | AddAddress($email, ''); 80 | } 81 | } else { 82 | $mailer->AddAddress($adminEmail, ''); 83 | } 84 | $mailer->FromName = $_SESSION['sessionID']; 85 | $mailer->From = $_SESSION['sessionMail'][0]; 86 | $mailer->Subject = $subject; 87 | $mailer->Body = $body; 88 | $mailer->Send(); 89 | CmnFns::redirect_js('summary.php'); 90 | } else { 91 | CmnFns::do_error_box(translate('You have to type some text'), '', false); 92 | printsendmail(); 93 | } 94 | } 95 | 96 | ?> 97 | -------------------------------------------------------------------------------- /templates/summary.template.php: -------------------------------------------------------------------------------- 1 | 7 | * @version 2021-11-08 8 | * @package Templates 9 | * 10 | * Copyright (C) 2021 mailzu-ng 11 | * License: GPL, see LICENSE 12 | */ 13 | 14 | 15 | /** 16 | * Print table listing messages in quarantine : 17 | * - spam (content type = 'S') 18 | * - attachment (content type = 'B') 19 | * - viruses (content type = 'V') 20 | * - bad headers (content type = H) 21 | * - pending requests ( RS = 'P') 22 | * @param array $res containing spam and attachments of logged in user 23 | */ 24 | function showSummary($count_array) 25 | { 26 | global $link; 27 | 28 | ?> 29 | 30 | 31 | 91 | 92 |
32 | 33 | 34 | 35 | 36 | 39 | 40 | 46 | 47 |
37 | 38 | 41 |
42 | doLink('javascript: help(\'msg_summary\');', '?', '', 'color: #FFFFFF;', 43 | translate('Help') . ' - ' . translate($_SESSION['sessionNav'])) ?> 44 |
45 |
48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 58 | 61 | 64 | 67 | 70 | 73 | 76 | 77 | 78 | $val) { 80 | echo ''; 81 | echo ($key == 'Total' ? ' \n"; 82 | foreach ($val as $subval) { 83 | echo ($key == 'Total' ? ' \n"; 84 | } 85 | echo ''; 86 | } 87 | ?> 88 | 89 |
56 | 57 | 59 | 60 | 62 | 63 | 65 | 66 | 68 | 69 | 71 | 72 | 74 | 75 |
' : '') . "$key' : '') . "$subval
90 |
93 | 97 | --------------------------------------------------------------------------------