postfixadmin-svn Mailing List for PostfixAdmin (Page 97)
Brought to you by:
christian_boltz,
gingerdog
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(13) |
Oct
(63) |
Nov
(79) |
Dec
(34) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(15) |
Feb
(8) |
Mar
(8) |
Apr
(44) |
May
(18) |
Jun
(20) |
Jul
(35) |
Aug
(21) |
Sep
(8) |
Oct
(9) |
Nov
(21) |
Dec
(14) |
2009 |
Jan
(53) |
Feb
(13) |
Mar
(36) |
Apr
(40) |
May
(22) |
Jun
(10) |
Jul
(18) |
Aug
(18) |
Sep
(7) |
Oct
(26) |
Nov
(32) |
Dec
(13) |
2010 |
Jan
(6) |
Feb
(7) |
Mar
(12) |
Apr
(2) |
May
(12) |
Jun
(8) |
Jul
(9) |
Aug
(12) |
Sep
(12) |
Oct
(7) |
Nov
(9) |
Dec
(42) |
2011 |
Jan
(10) |
Feb
(35) |
Mar
(43) |
Apr
(39) |
May
(8) |
Jun
(8) |
Jul
(83) |
Aug
(20) |
Sep
(20) |
Oct
(63) |
Nov
(33) |
Dec
(20) |
2012 |
Jan
(28) |
Feb
(3) |
Mar
(1) |
Apr
(37) |
May
(16) |
Jun
(7) |
Jul
(3) |
Aug
|
Sep
|
Oct
(3) |
Nov
(1) |
Dec
(4) |
2013 |
Jan
(6) |
Feb
(16) |
Mar
(9) |
Apr
(11) |
May
(9) |
Jun
(30) |
Jul
(17) |
Aug
(6) |
Sep
(2) |
Oct
(30) |
Nov
(41) |
Dec
(26) |
2014 |
Jan
(16) |
Feb
(20) |
Mar
(5) |
Apr
(4) |
May
(14) |
Jun
(4) |
Jul
(1) |
Aug
|
Sep
(8) |
Oct
(18) |
Nov
(26) |
Dec
|
2015 |
Jan
(4) |
Feb
(9) |
Mar
(12) |
Apr
(26) |
May
(3) |
Jun
(3) |
Jul
(2) |
Aug
|
Sep
(15) |
Oct
(13) |
Nov
|
Dec
(1) |
2016 |
Jan
(1) |
Feb
(5) |
Mar
(4) |
Apr
(3) |
May
(19) |
Jun
|
Jul
|
Aug
(3) |
Sep
(16) |
Oct
(4) |
Nov
(5) |
Dec
(5) |
2017 |
Jan
(1) |
Feb
(8) |
Mar
|
Apr
(7) |
May
(3) |
Jun
(16) |
Jul
(13) |
Aug
(16) |
Sep
(6) |
Oct
(4) |
Nov
(10) |
Dec
(7) |
2018 |
Jan
(16) |
Feb
(17) |
Mar
(11) |
Apr
(13) |
May
(20) |
Jun
(3) |
Jul
(10) |
Aug
|
Sep
(3) |
Oct
(1) |
Nov
(6) |
Dec
(18) |
2019 |
Jan
(18) |
Feb
(31) |
Mar
(4) |
Apr
(4) |
May
(1) |
Jun
(8) |
Jul
(7) |
Aug
(10) |
Sep
(23) |
Oct
(6) |
Nov
(3) |
Dec
(5) |
2020 |
Jan
(10) |
Feb
(18) |
Mar
(34) |
Apr
(19) |
May
(6) |
Jun
(9) |
Jul
|
Aug
(10) |
Sep
(16) |
Oct
(6) |
Nov
(3) |
Dec
(11) |
2021 |
Jan
(118) |
Feb
(22) |
Mar
(13) |
Apr
(12) |
May
(48) |
Jun
(21) |
Jul
(17) |
Aug
(12) |
Sep
(19) |
Oct
(25) |
Nov
(16) |
Dec
(7) |
2022 |
Jan
(6) |
Feb
(7) |
Mar
(14) |
Apr
(4) |
May
|
Jun
(16) |
Jul
(18) |
Aug
(5) |
Sep
(12) |
Oct
(8) |
Nov
(10) |
Dec
(13) |
2023 |
Jan
|
Feb
(3) |
Mar
(2) |
Apr
(1) |
May
(2) |
Jun
(6) |
Jul
(3) |
Aug
(3) |
Sep
(3) |
Oct
(2) |
Nov
(7) |
Dec
(13) |
2024 |
Jan
(8) |
Feb
(6) |
Mar
(5) |
Apr
(10) |
May
(8) |
Jun
(6) |
Jul
(2) |
Aug
(1) |
Sep
(2) |
Oct
(4) |
Nov
(15) |
Dec
(10) |
2025 |
Jan
(3) |
Feb
(12) |
Mar
(3) |
Apr
(7) |
May
(18) |
Jun
(10) |
Jul
(10) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <Gin...@us...> - 2009-03-13 21:48:43
|
Revision: 579 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=579&view=rev Author: GingerDog Date: 2009-03-13 21:48:38 +0000 (Fri, 13 Mar 2009) Log Message: ----------- add xmlrpc server support - TOTALLY NOT TESTED YET!!! Modified Paths: -------------- trunk/model/AliasHandler.php trunk/model/VacationHandler.php Added Paths: ----------- trunk/xmlrpc.php Modified: trunk/model/AliasHandler.php =================================================================== --- trunk/model/AliasHandler.php 2009-03-13 20:49:54 UTC (rev 578) +++ trunk/model/AliasHandler.php 2009-03-13 21:48:38 UTC (rev 579) @@ -7,12 +7,15 @@ private $username = null; + /** + * @param string $username + */ public function __construct($username) { $this->username = $username; + } - } /** - * @return list of email addresses the user's mail is forwarded to. + * @return array - list of email addresses the user's mail is forwarded to. * (may be an empty list, especially if $CONF['alias_control'] is turned off... * @param boolean - by default we don't return special addresses (e.g. vacation and mailbox alias); pass in true here if you wish to. */ Modified: trunk/model/VacationHandler.php =================================================================== --- trunk/model/VacationHandler.php 2009-03-13 20:49:54 UTC (rev 578) +++ trunk/model/VacationHandler.php 2009-03-13 21:48:38 UTC (rev 579) @@ -79,7 +79,6 @@ return false; } /** - * @param string $username * @param string $subject * @param string $body */ Added: trunk/xmlrpc.php =================================================================== --- trunk/xmlrpc.php (rev 0) +++ trunk/xmlrpc.php 2009-03-13 21:48:38 UTC (rev 579) @@ -0,0 +1,146 @@ +<?php +/** + * Requires the Zend framework is installed and in the include path. + * + * Usage example: + * require_once('Zend/XmlRpc/Client.php'); + * $xmlrpc = new Zend_XmlRpc_Client('http://server/xmlrpc.php'); + * + * $http_client = $xmlrpc->getHttpClient(); + * $http_client->setCookieJar(); + * + * $login_object = $xmlrpc->getProxy('login'); + * $success = $login_object->login($username, $password); + * + * if($success) { + * echo "We're logged in"; + * } + * else { + * die("Auth failed"); + * } + * $user = $xmlrpc->getProxy('user'); + * $alias = $xmlrpc->getProxy('alias'); + * $vacation = $xmlrpc->getProxy('vacation'); + * + * if($vacation->isEnabled()) { + * echo "Vacation turned on for user"; + * } + * + * Note, the requirement that your XmlRpc client provides cookies with each request. + * If it does not do this, then your authentication details will not persist across requests. + */ + +require_once('Zend/XmlRpc/Server.php'); +$server = new Zend_XmlRpc_Server(); +session_start(); + +function login($username, $password) { + if(UserHandler::login($username, $password)) { + session_regenerate_id(); + $_SESSION['authenticated'] = true; + $_SESSION['username'] = $username; + } +} + +if(!isset($_SESSION['authenticated'])) { + $server->addFunction('login', 'login'); +} +else { + $server->addClass('user', 'UserProxy'); + $server->addClass('vacation', 'VacationProxy'); + $server->addClass('alias', 'AliasProxy'); +} +echo $server->handle(); + + +class UserProxy { + + /** + * @param string $old_password + * @param string $new_password + * @return boolean true on success + */ + public function changePassword($old_password, $new_password) { + $uh = new UserHandler($_SESSION['username']); + return $uh->change_pass($username, $old_password, $new_password); + } +} +class VacationProxy { + /** + * @return boolean true if the vacation is removed successfully. Else false. + */ + public function remove() { + $vh = new VacationHandler($_SESSION['username']); + return $vh->remove(); + } + + /** + * @return boolean true if vacation stuff is enabled in this instance of postfixadmin + * and the user has the ability to make changes to it. + */ + public function isVacationSupported() { + $vh = new VacationHandler($_SESSION['username']); + return $vh->vacation_supported(); + } + + /** + * @return boolean true if the user has an active vacation record etc. + */ + public function checkVacation() { + $vh = new VacationHandler($_SESSION['username']); + return $vh->check_vacation(); + } + + /** + * @return struct|boolean - either array of vacation details or boolean false if the user has none. + */ + public function getDetails() { + $vh = new VacationHandler($_SESSION['username']); + return $vh->get_details(); + } + + /** + * @param string $subject + * @param string $body + * @return boolean true on success. + */ + public function setAway($subject, $body) { + $vh = new VacationHandler($_SESSION['username']); + return $vh->set_away($subject, $body); + } + + +} +class AliasProxy { + /** + * @return array - array of aliases this user has. Array may be empty. + */ + public function get() { + $ah = new AliasHandler($_SESSION['username']); + /* I see no point in returning special addresses to the user. */ + return $ah->get(false); + } + + /** + * @param array of email addresses (Strings) + * @param string flag to set ('forward_and_store' or 'remote_only') + * @return boolean true + */ + public function update($addresses, $flags) { + $ah = new AliasHandler($_SESSION['username']); + /** + * if the user is on vacation, they should use VacationProxy stuff to remove it + * and we'll never return the vacation address from here anyway + */ + return $ah->update($addresses, $flags, true); + } + + /** + * @return boolean true if the user has 'store_and_forward' set. + * (i.e. their email address is also in the alias table). IF it returns false, then it's 'remote_only' + */ + public function hasStoreAndForward() { + $ah = new AliasHandler($_SESSION['username']); + return $ah->hasStoreAndForward(); + } +} This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-03-13 20:50:00
|
Revision: 575 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=575&view=rev Author: GingerDog Date: 2009-03-13 20:48:24 +0000 (Fri, 13 Mar 2009) Log Message: ----------- refactoring of users (most app logic is now in /model) Modified Paths: -------------- trunk/users/edit-alias.php trunk/users/login.php trunk/users/main.php trunk/users/password.php trunk/users/vacation.php Added Paths: ----------- trunk/model/ trunk/model/AliasHandler.php trunk/model/UserHandler.php trunk/model/VacationHandler.php Added: trunk/model/AliasHandler.php =================================================================== --- trunk/model/AliasHandler.php (rev 0) +++ trunk/model/AliasHandler.php 2009-03-13 20:48:24 UTC (rev 575) @@ -0,0 +1,185 @@ +<?php + +/** + * Handlers User level alias actions - e.g. add alias, get aliases, update etc. + */ +class AliasHandler { + + private $username = null; + + public function __construct($username) { + $this->username = $username; + + } + /** + * @return list of email addresses the user's mail is forwarded to. + * (may be an empty list, especially if $CONF['alias_control'] is turned off... + * @param boolean - by default we don't return special addresses (e.g. vacation and mailbox alias); pass in true here if you wish to. + */ + public function get($all=false) { + $username = escape_string($this->username); + $table_alias = table_by_key('alias'); + + $sql = "SELECT * FROM $table_alias WHERE address='$username'"; + $result = db_query($sql); + if ($result['rows'] == 1) + { + $row = db_array ($result['result']); + // At the moment Postfixadmin stores aliases in it's database in a comma seperated list; this may change one day. + $list = explode(',', $row['goto']); + if($all) { + return $list; + } + + $new_list = array(); + /* if !$all, remove vacation & mailbox aliases */ + foreach($list as $address) { + if($address != '' ) { + if($this->is_vacation_address($address) || $this->is_mailbox_alias($address)) { + } + else { + $new_list[] = $address; + } + } + } + $list = $new_list; + return $list; + } + return array(); + } + + /** + * @param string $address + * @param string $username + * @return boolean true if the username is an alias for the mailbox AND we have alias_control turned off. + */ + public function is_mailbox_alias($address) { + global $CONF; + $username = $this->username; + if($address == $username) { + return true; + } + return false; + } + + /** + * @param string $address + * @return boolean true if the address contains the vacation domain + */ + public function is_vacation_address($address) { + global $CONF; + if($CONF['vacation'] == 'YES') { + if(stripos($address, '@' . $CONF['vacation_domain'])) { + return true; + } + } + return false; + } + /** + * @return boolean true on success + * @param string $username + * @param array $addresses - list of aliases to set for the user. + * @param string flags - forward_and_store or remote_only or '' + * @param boolean $vacation_persist - set to false to stop the vacation address persisting across updates + * Set the user's aliases to those provided. If $addresses ends up being empty the alias record is removed. + */ + public function update($addresses, $flags = '', $vacation_persist=true) { + // find out if the user is on vacation or not; if they are, + // then the vacation alias needs adding to the db (as we strip it out in the get method) + // likewise with the alias_control address. + + $valid_flags = array('', 'forward_and_store', 'remote_only'); + if(!in_array($flags, $valid_flags)) { + die("Invalid flag passed into update()... : $flag - valid options are :" . implode(',', $valid_flags)); + } + $addresses = array_unique($addresses); + + $original = $this->get(true); + + foreach($original as $address) { + if($vacation_persist) { + if($this->is_vacation_address($address)) { + $addresses[] = $address; + } + } + if($flags != 'remote_only') { + if($this->is_mailbox_alias($address)) { + $addresses[] = $address; + } + } + } + $addresses = array_unique($addresses); + + $new_list = array(); + if($flags == 'remote_only') { + foreach($addresses as $address) { + // strip out our username... if it's in the list given. + if($address != $this->username) { + $new_list[] = $address; + } + } + $addresses = $new_list; + } + + if($flags == 'forward_and_store') { + if(!in_array($this->username, $addresses)) { + $addresses[] = $this->username; + } + } + $new_list = array(); + foreach($addresses as $address) { + if($address != '') { + $new_list[] = $address; + } + } + $addresses = array_unique($new_list); + $username = escape_string($this->username); + $goto = escape_string(implode(',', $addresses)); + $table_alias = table_by_key('alias'); + if(sizeof($addresses) == 0) { + $sql = "DELETE FROM $table_alias WHERE address = '$username'"; + } + if($this->hasAliasRecord() == false) { + $true = db_get_boolean(True); + $tmp = preg_split('/@/', $username); + $domain = $tmp[1]; + $sql = "INSERT INTO $table_alias (address, goto, domain, created, modified, active) VALUES ('$username', '$goto', '$domain', NOW(), NOW(), $true)"; + } + else { + $sql = "UPDATE $table_alias SET goto = '$goto', modified = NOW() WHERE address = '$username'"; + } + $result = db_query($sql); + if($result['rows'] != 1) { + return false; + } + db_log($username, $domain, 'edit_alias', "$username -> $goto"); + return true; + } + + /** + * Determine whether a local delivery address is present. This is + * stores as an alias with the same name as the mailbox name (username) + * @return boolean true if local delivery is enabled + */ + public function hasStoreAndForward() { + $aliases = $this->get(true); + if(in_array($this->username, $aliases)) { + return true; + } + return false; + } + + /** + * @return boolean true if the user has an alias record (i.e row in alias table); else false. + */ + public function hasAliasRecord() { + $username = escape_string($this->username); + $table_alias = table_by_key('alias'); + $sql = "SELECT * FROM $table_alias WHERE address = '$username'"; + $result = db_query($sql); + if($result['rows'] == 1) { + return true; + } + return false; + } +} Added: trunk/model/UserHandler.php =================================================================== --- trunk/model/UserHandler.php (rev 0) +++ trunk/model/UserHandler.php 2009-03-13 20:48:24 UTC (rev 575) @@ -0,0 +1,65 @@ +<?php + +/** + * Simple class to represent a user. + */ +class UserHandler { + + /** + * @return boolean true on success; false on failure + * @param string $username + * @param string $old_password + * @param string $new_passwords + * + * All passwords need to be plain text; they'll be hashed appropriately + * as per the configuration in config.inc.php + */ + public function change_pass($username, $old_password, $new_password) { + global $config; + if(!UserHandler::login($username, $old_password)) { + return false; + } + + $tmp = preg_split ('/@/', $username); + $USERID_DOMAIN = $tmp[1]; + + $username = escape_string($username); + $table_mailbox = table_by_key('mailbox'); + + $active = db_get_boolean(True); + $result = db_query("SELECT * FROM $table_mailbox WHERE username='$username' AND active=$active"); + $new_db_password = escape_string(pacrypt($new_password)); + + $result = db_query ("UPDATE $table_mailbox SET password='$new_db_password',modified=NOW() WHERE username='$username'"); + + db_log ($username, $USERID_DOMAIN, 'edit_password', "$USERID_USERNAME"); + return true; + } + + /** + * Attempt to log a user in. + * @param string $username + * @param string $password + * @return boolean true on successful login (i.e. password matches etc) + */ + public static function login($username, $password) { + global $config; + $username = escape_string($username); + + $table_mailbox = table_by_key('mailbox'); + $active = db_get_boolean(True); + $query = "SELECT password FROM $table_mailbox WHERE username='$username' AND active=$active"; + + $result = db_query ($query); + if ($result['rows'] == 1) + { + $row = db_array ($result['result']); + $password = pacrypt ($password, $row['password']); + + if($row['password'] == $password) { + return true; + } + } + return false; + } +} Added: trunk/model/VacationHandler.php =================================================================== --- trunk/model/VacationHandler.php (rev 0) +++ trunk/model/VacationHandler.php 2009-03-13 20:48:24 UTC (rev 575) @@ -0,0 +1,126 @@ +<?php + +class VacationHandler { + protected $username = null; + function __construct($username) { + $this->username = $username; + } + + /** + * Removes the autoreply alias etc for this user; namely, if they're away we remove their vacation alias and + * set the vacation table record to false. + * @return boolean true on success. + */ + function remove() { + $ah = new AliasHandler($this->username); + $aliases = $ah->get(true); // fetch all. + $new_aliases = array(); + $table_vacation = table_by_key('vacation'); + $table_vacation_notification = table_by_key('vacation_notification'); + + /* go through the user's aliases and remove any that look like a vacation address */ + foreach($aliases as $alias) { + if(!$ah->is_vacation_address($alias)) { + $new_aliases[] = $alias; + } + } + $ah->update($new_aliases, '', false); + + // tidy up vacation table. + $active = db_get_boolean(False); + $username = escape_string($this->username); + $result = db_query("UPDATE $table_vacation SET active = $active WHERE email='$username'"); + $result = db_query("DELETE FROM $table_vacation_notification WHERE on_vacation='$username'"); + /* crap error handling; oh for exceptions... */ + return true; + } + + /** + * @return boolean true indicates this server supports vacation messages, and users are able to change their own. + * @global array $CONF + */ + function vacation_supported() { + global $CONF; + return $CONF['vacation'] == 'YES' && $CONF['vacation_control'] == 'YES'; + } + + /** + * @return boolean true if on vacation, otherwise false + * Why do we bother storing true/false in the vacation table if the alias dictates it anyway? + */ + function check_vacation() { + $ah = new AliasHandler($this->username); + $aliases = $ah->get(true); // fetch all. + foreach($aliases as $alias) { + if($ah->is_vacation_address($alias)) { + return true; + } + } + return false; + } + + /** + * Retrieve information on someone who is on vacation + * @return mixed stored information on vacation - array(subject - string, message - string, active - boolean) or false if they've never been on vacation. + */ + function get_details() { + $table_vacation = table_by_key('vacation'); + $username = escape_string($this->username); + + $sql = "SELECT * FROM $table_vacation WHERE email = '$username'"; + $result = db_query($sql); + if($result['rows'] == 1) { + $row = db_array($result['result']); + $boolean = ($row['active'] == db_get_boolean(true)); + return array( 'subject' => $row['subject'], + 'body' => $row['body'], + 'active' => $boolean ); + } + return false; + } + /** + * @param string $username + * @param string $subject + * @param string $body + */ + function set_away($subject, $body) { + $this->remove(); // clean out any notifications that might already have been sent. + // is there an entry in the vacaton table for the user, or do we need to insert? + $table_vacation = table_by_key('vacation'); + $username = escape_string($this->username); + $body = escape_string($body); + $subject = escape_string($subject); + + $result = db_query("SELECT * FROM $table_vacation WHERE email = '$username'"); + // check if the user has a vacation entry already, if so just update it + if($result['rows'] == 1) { + $active = db_get_boolean(True); + $result = db_query("UPDATE $table_vacation SET active = $active, body = '$body', subject = '$subject', created = NOW() WHERE email = '$username'"); + } + else { + $tmp = preg_split ('/@/', $username); + $domain = escape_string($tmp[1]); + $result = db_query ("INSERT INTO $table_vacation (email,subject,body,domain,created,active) VALUES ('$username','$subject','$body','$domain',NOW(),$Active)"); + } + + $ah = new AliasHandler($this->username); + $aliases = $ah->get(true); + $vacation_address = $this->getVacationAlias(); + $aliases[] = $vacation_address; + return $ah->update($aliases, '', false); + } + + /** + * Returns the vacation alias for this user. + * i.e. if this user's username was ro...@ex..., and the autoreply domain was set to + * autoreply.fish.net in config.inc.php we'd return roger#exa...@au... + * @return string an email alias. + */ + public function getVacationAlias() { + global $CONF; + $vacation_domain = $CONF['vacation_domain']; + $vacation_goto = preg_replace('/@/', '#', $this->username); + $vacation_goto = "{$vacation_goto}@{$vacation_domain}"; + return $vacation_goto; + } +} Modified: trunk/users/edit-alias.php =================================================================== --- trunk/users/edit-alias.php 2009-03-12 09:11:22 UTC (rev 574) +++ trunk/users/edit-alias.php 2009-03-13 20:48:24 UTC (rev 575) @@ -20,12 +20,12 @@ * Template Variables: * * tMessage - * tGoto + * tGotoArray + * tStoreAndForward * * Form POST \ GET Variables: * * fAddress - * fDomain * fGoto */ @@ -40,20 +40,14 @@ $vacation_domain = $CONF['vacation_domain']; $vacation_goto = preg_replace('/@/', '#', $USERID_USERNAME) . '@' . $vacation_domain; +$ah = new AliasHandler($USERID_USERNAME); + if ($_SERVER['REQUEST_METHOD'] == "GET") { $vacation_domain = $CONF['vacation_domain']; - $result = db_query ("SELECT * FROM $table_alias WHERE address='$USERID_USERNAME'"); - if ($result['rows'] == 1) - { - $row = db_array ($result['result']); - $tGoto = $row['goto']; - } - else - { - $tMessage = $PALANG['pEdit_alias_address_error']; - } + $tGotoArray = $ah->get(); + $tStoreAndForward = $ah->hasStoreAndForward(); include ("../templates/header.php"); include ("../templates/users_menu.php"); @@ -71,63 +65,42 @@ $pEdit_alias_goto = $PALANG['pEdit_alias_goto']; - if (isset ($_POST['fVacation'])) $fVacation = $_POST['fVacation']; - if (isset ($_POST['fGoto'])) $fGoto = escape_string (trim($_POST['fGoto'])); - if (isset ($_POST['fForward_and_store'])) $fForward_and_store = escape_string ($_POST['fForward_and_store']); - + if (isset($_POST['fVacation'])) $fVacation = $_POST['fVacation']; + if (isset($_POST['fGoto'])) $fGoto = escape_string (trim($_POST['fGoto'])); + if (isset($_POST['fForward_and_store'])) $fForward_and_store = escape_string ($_POST['fForward_and_store']); $goto = strtolower ($fGoto); $goto = preg_replace ('/\\\r\\\n/', ',', $goto); $goto = preg_replace ('/\r\n/', ',', $goto); $goto = preg_replace ('/[\s]+/i', '', $goto); $goto = preg_replace ('/\,*$/', '', $goto); - ( $fForward_and_store == "YES" ) ? $goto = $USERID_USERNAME . "," . $goto : ''; + $goto = explode(",",$goto); + $goto = array_merge(array_unique($goto)); - $goto = implode(",",$goto); - $array = preg_split ('/,/', $goto); - - for ($i = 0; $i < sizeof ($array); $i++) { - if (in_array ("$array[$i]", $CONF['default_aliases'])) continue; - if (empty ($array[$i]) && $fForward_and_store == "NO") - { - $error = 1; - $tGoto = $goto; - $tMessage = $PALANG['pEdit_alias_goto_text_error1']; + $good_goto = array(); + foreach($goto as $address) { + if(!check_email($address)) { + $error += 1; + $tMessage = $PALANG['pEdit_alias_goto_text_error1'] . "$address</font>"; } - if (empty ($array[$i])) continue; - if (!check_email ($array[$i])) - { - $error = 1; - $tGoto = $goto; - $tMessage = $PALANG['pEdit_alias_goto_text_error2'] . "$array[$i]</font>"; + else { + $good_goto[] = $address; } } + $goto = $good_goto; - if ($error != 1) - { - if (empty ($goto)) - { - $goto = $USERID_USERNAME; + if ($error == 0) { + $flags = 'remote_only'; + if($fForward_and_store == "YES" ) { + $flags = 'forward_and_store'; } - - if ($fVacation == "YES") - { - $goto .= "," . $vacation_goto; - } - - $result = db_query ("UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$USERID_USERNAME'"); - if ($result['rows'] != 1) - { - $tMessage = $PALANG['pEdit_alias_result_error']; - } - else - { - db_log ($USERID_USERNAME, $USERID_DOMAIN, 'edit_alias', "$USERID_USERNAME -> $goto"); - + $updated = $ah->update($goto, $flags); + if($updated) { header ("Location: main.php"); exit; } + $tMessage = $PALANG['pEdit_alias_result_error']; } include ("../templates/header.php"); Modified: trunk/users/login.php =================================================================== --- trunk/users/login.php 2009-03-12 09:11:22 UTC (rev 574) +++ trunk/users/login.php 2009-03-13 20:48:24 UTC (rev 575) @@ -40,8 +40,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { - $fUsername = escape_string ($_POST['fUsername']); - $fPassword = escape_string ($_POST['fPassword']); + $lang = safepost('lang'); if ( $lang != check_language(0) ) { # only set cookie if language selection was changed @@ -49,33 +48,10 @@ # (language preference cookie is processed even if username and/or password are invalid) } - $active = db_get_boolean(True); - $query = "SELECT password FROM $table_mailbox WHERE username='$fUsername' AND active=$active"; + $fUsername = escape_string ($_POST['fUsername']); + $fPassword = escape_string ($_POST['fPassword']); - $result = db_query ($query); - if ($result['rows'] == 1) - { - $row = db_array ($result['result']); - $password = pacrypt ($fPassword, $row['password']); - - $query = "SELECT * FROM $table_mailbox WHERE username='$fUsername' AND password='$password' AND active=$active"; - - $result = db_query ($query); - if ($result['rows'] != 1) - { - $error = 1; - $tMessage = '<span class="error_msg">' . $PALANG['pLogin_failed'] . '</span>'; - $tUsername = $fUsername; - } - } - else - { - $error = 1; - $tMessage = '<span class="error_msg">' . $PALANG['pLogin_failed'] . '</span>'; - } - - if ($error != 1) - { + if(UserHandler::login($_POST['fUsername'], $_POST['fPassword'])) { session_regenerate_id(); $_SESSION['sessid'] = array(); $_SESSION['sessid']['roles'] = array(); @@ -84,6 +60,11 @@ header("Location: main.php"); exit; } + else { + $error = 1; + $tMessage = '<span class="error_msg">' . $PALANG['pLogin_failed'] . '</span>'; + $tUsername = $fUsername; + } include ("../templates/header.php"); include ("../templates/users_login.php"); Modified: trunk/users/main.php =================================================================== --- trunk/users/main.php 2009-03-12 09:11:22 UTC (rev 574) +++ trunk/users/main.php 2009-03-13 20:48:24 UTC (rev 575) @@ -27,11 +27,8 @@ authentication_require_role('user'); $USERID_USERNAME = authentication_get_username(); -$db_active = db_get_boolean(True); -$result = db_query("SELECT * FROM $table_vacation WHERE email='$USERID_USERNAME' AND active='$db_active'"); -if ($result['rows'] == 1) -{ - $row = db_array($result['result']); +$vh = new VacationHandler($USERID_USERNAME); +if($vh->check_vacation()) { $tummVacationtext = $PALANG['pUsersMain_vacationSet']; } else @@ -39,21 +36,10 @@ $tummVacationtext = $PALANG['pUsersMain_vacation']; } -if ($_SERVER["REQUEST_METHOD"] == "GET") -{ - include ("../templates/header.php"); - include ("../templates/users_menu.php"); - include ("../templates/users_main.php"); - include ("../templates/footer.php"); -} +include ("../templates/header.php"); +include ("../templates/users_menu.php"); +include ("../templates/users_main.php"); +include ("../templates/footer.php"); -if ($_SERVER["REQUEST_METHOD"] == "POST") -{ - include ("../templates/header.php"); - include ("../templates/users_menu.php"); - include ("../templates/users_main.php"); - include ("../templates/footer.php"); -} - /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> Modified: trunk/users/password.php =================================================================== --- trunk/users/password.php 2009-03-12 09:11:22 UTC (rev 574) +++ trunk/users/password.php 2009-03-13 20:48:24 UTC (rev 575) @@ -32,9 +32,6 @@ authentication_require_role('user'); $USERID_USERNAME = authentication_get_username(); -$tmp = preg_split ('/@/', $USERID_USERNAME); -$USERID_DOMAIN = $tmp[1]; - if ($_SERVER['REQUEST_METHOD'] == "POST") { if(isset($_POST['fCancel'])) { @@ -52,25 +49,11 @@ } $username = $USERID_USERNAME; - $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$username'"); - if ($result['rows'] == 1) - { - $row = db_array ($result['result']); - $checked_password = pacrypt($fPassword_current, $row['password']); - - $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$username' AND password='$checked_password'"); - if ($result['rows'] != 1) - { - $error = 1; - $pPassword_password_current_text = $PALANG['pPassword_password_current_text_error']; - } + $uh = new UserHandler(); + if(!$uh->login($username, $fPassword_current)) { + $error += 1; + $pPassword_password_current_text = $PALANG['pPassword_password_current_text_error']; } - else - { - $error = 1; - $pPassword_email_text = $PALANG['pPassword_email_text_error']; - } - if (empty ($fPassword) or ($fPassword != $fPassword2)) { $error = 1; @@ -79,12 +62,8 @@ if ($error != 1) { - $password = pacrypt ($fPassword); - $result = db_query ("UPDATE $table_mailbox SET password='$password',modified=NOW() WHERE username='$username'"); - if ($result['rows'] == 1) - { + if($uh->change_pass($username, $fPassword_current, $fPassword)) { flash_info($PALANG['pPassword_result_success']); - db_log ($USERID_USERNAME, $USERID_DOMAIN, 'edit_password', "$USERID_USERNAME"); header("Location: main.php"); exit(0); } Modified: trunk/users/vacation.php =================================================================== --- trunk/users/vacation.php 2009-03-12 09:11:22 UTC (rev 574) +++ trunk/users/vacation.php 2009-03-13 20:48:24 UTC (rev 575) @@ -42,19 +42,20 @@ exit(0); } -$tmp = preg_split ('/@/', $USERID_USERNAME); -$USERID_DOMAIN = $tmp[1]; +$vh = new VacationHandler(authentication_get_username()); if ($_SERVER['REQUEST_METHOD'] == "GET") { - $result = db_query("SELECT * FROM $table_vacation WHERE email='$USERID_USERNAME'"); - if ($result['rows'] == 1) - { - $row = db_array($result['result']); - if ($row['active'] == db_get_boolean(True)) $tMessage = $PALANG['pUsersVacation_welcome_text']; - $tSubject = $row['subject']; - $tBody = $row['body']; + $tSubject = ''; + $tBody = ''; + + if($vh->get_details()) { + $tSubject = $details['subject']; + $tBody = $details['body']; } + if($vh->check_vacation()) { + $tMessage = $PALANG['pUsersVacation_welcome_text']; + } if ($tSubject == '') { $tSubject = html_entity_decode($PALANG['pUsersVacation_subject_text'], ENT_QUOTES, 'UTF-8'); } if ($tBody == '') { $tBody = html_entity_decode($PALANG['pUsersVacation_body_text'], ENT_QUOTES, 'UTF-8'); } @@ -67,11 +68,6 @@ exit(0); } - // We store goto addresses in the form of roger#exa...@au... - $vacation_domain = $CONF['vacation_domain']; - $vacation_goto = preg_replace('/@/', '#', $USERID_USERNAME); - $vacation_goto = "{$vacation_goto}@{$vacation_domain}"; - if (isset ($_POST['fSubject'])) $fSubject = escape_string ($_POST['fSubject']); if (isset ($_POST['fBody'])) $fBody = escape_string ($_POST['fBody']); if (isset ($_POST['fAway'])) $fAway = escape_string ($_POST['fAway']); @@ -82,104 +78,25 @@ if ($tBody == '') { $tBody = html_entity_decode($PALANG['pUsersVacation_body_text'], ENT_QUOTES, 'UTF-8'); } // if they've set themselves away OR back, delete any record of vacation emails. - if (!empty ($fBack) || !empty ($fAway)) - { - $notActive = db_get_boolean(False); - // this isn't very good, as $result['rows'] would be 0 if the user had not used vacation stuff before. - $result = db_query("UPDATE $table_vacation SET active = $notActive WHERE email='$USERID_USERNAME'"); - $result = db_query("DELETE FROM $table_vacation_notification WHERE on_vacation='$USERID_USERNAME'"); - $tMessage = $PALANG['pUsersVacation_result_error']; - // We need to see whether there is already an alias record for the user, or not. - // If not, we create one, else update the existing one. - $result = db_query ("SELECT * FROM $table_alias WHERE address='$USERID_USERNAME'"); - if ($result['rows'] == 1) - { - $row = db_array ($result['result']); - $tGoto = $row['goto']; - - //only one of these will do something, first handles address at beginning and middle, second at end, third if it's the only alias record. - $goto= preg_replace ( "/$vacation_goto,/", '', $tGoto); - $goto= preg_replace ( "/,$vacation_goto/", '', $goto); - $goto= preg_replace ( "/$vacation_goto/", '', $goto); - $query = "UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$USERID_USERNAME'"; - - if($goto == '') { - // if there are no other goto records left, remove the alias record for this user. - $query = "DELETE FROM $table_alias WHERE address = '$USERID_USERNAME'"; - } - $result = db_query($query); - } - else { - $goto = $vacation_goto; - $boolean = db_get_boolean(True); - - $result = db_query("INSERT into $table_alias (address, goto, domain, created, active) - VALUES ('$USERID_USERNAME', '', '$USERID_DOMAIN', NOW(), $boolean)"); - } - if ($result['rows'] != 1) - { - $error = 1; - $tMessage = $PALANG['pUsersVacation_result_error']; - } - else - { - $tMessage = $PALANG['pUsersVacation_result_success']; - } - - } - // the user is going away - set the goto alias and vacation table as necessary. if (!empty ($fAway)) { - // Can we ever have no alias records for a user? - $result = db_query ("SELECT * FROM $table_alias WHERE address='$USERID_USERNAME'"); - if ($result['rows'] == 1) - { - $row = db_array ($result['result']); - $tGoto = $row['goto']; - } - $Active = db_get_boolean(True); - $result = db_query("SELECT * FROM $table_vacation WHERE email = '$USERID_USERNAME'"); - if($result['rows'] == 1) { - $result = db_query("UPDATE $table_vacation SET active = $Active, body = '$fBody', subject = '$fSubject', created = NOW() WHERE email = '$USERID_USERNAME'"); - } - else { - $result = db_query ("INSERT INTO $table_vacation (email,subject,body,domain,created,active) VALUES ('$USERID_USERNAME','$fSubject','$fBody','$USERID_DOMAIN',NOW(),$Active)"); - } - - if ($result['rows'] != 1) - { + if(!$vh->set_away($fSubject, $fBody)) { $error = 1; $tMessage = $PALANG['pUsersVacation_result_error']; } - // add the goto record back in... - $comma = ''; - if(strlen($tGoto) > 1) { - $comma = ','; - } - $goto = $tGoto . $comma . $vacation_goto; - - $result = db_query ("UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$USERID_USERNAME'"); - if ($result['rows'] != 1) - { - $error = 1; - $tMessage = $PALANG['pUsersVacation_result_error']; - } - else - { - flash_info($PALANG['pVacation_result_added']); - header ("Location: main.php"); - exit; - } + flash_info($PALANG['pVacation_result_added']); + header ("Location: main.php"); + exit; } if (!empty ($fBack)) { - if ($tMessage == '' || $tMessage = $PALANG['pUsersVacation_result_success']) { - flash_info($PALANG['pVacation_result_removed']); - header ("Location: main.php"); - exit; - } + $vh->remove(); + $tMessage = $PALANG['pUsersVacation_result_success']; + flash_info($tMessage); + header ("Location: main.php"); + exit; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-03-13 20:49:57
|
Revision: 578 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=578&view=rev Author: GingerDog Date: 2009-03-13 20:49:54 +0000 (Fri, 13 Mar 2009) Log Message: ----------- remove logic from users template Modified Paths: -------------- trunk/templates/users_edit-alias.php Modified: trunk/templates/users_edit-alias.php =================================================================== --- trunk/templates/users_edit-alias.php 2009-03-13 20:49:32 UTC (rev 577) +++ trunk/templates/users_edit-alias.php 2009-03-13 20:49:54 UTC (rev 578) @@ -14,27 +14,17 @@ <td><?php print $PALANG['pEdit_alias_goto'] . ":"; ?></td> <td><textarea class="flat" rows="4" cols="50" name="fGoto"> <?php -$array = preg_split ('/,/', $tGoto); -$just_forward="YES"; # unless changed below +$just_forward = "YES"; +if($tStoreAndForward) { + $just_forward = "NO"; +} -for ($i = 0 ; $i < sizeof ($array) ; $i++) -{ - if (empty ($array[$i])) continue; - if ($array[$i] == "$vacation_goto") - { - $vacation = "YES"; - continue; - } - if ($array[$i] == $USERID_USERNAME) { - $just_forward="NO"; - continue; - } - print "$array[$i]\n"; +foreach($tGotoArray as $address) { + print "$address\n"; } ?> </textarea> - <input type="hidden" name="fVacation" value="<?php print $vacation; ?>"> </td> <td> </td> </tr> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-03-13 20:49:35
|
Revision: 577 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=577&view=rev Author: GingerDog Date: 2009-03-13 20:49:32 +0000 (Fri, 13 Mar 2009) Log Message: ----------- common.php: add autoloading for model classes Modified Paths: -------------- trunk/common.php Modified: trunk/common.php =================================================================== --- trunk/common.php 2009-03-13 20:49:05 UTC (rev 576) +++ trunk/common.php 2009-03-13 20:49:32 UTC (rev 577) @@ -59,5 +59,19 @@ require_once("$incpath/functions.inc.php"); require_once("$incpath/languages/" . check_language () . ".lang"); +/** + * @param string $class + * __autoload implementation, for use with spl_autoload_register(). + */ +function postfixadmin_autoload($class) { + $PATH = dirname(__FILE__) . '/model/' . $class . '.php'; + if(is_file($PATH)) { + require_once($PATH); + return true; + } + return false; +} +spl_autoload_register('postfixadmin_autoload'); + /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-03-13 20:49:29
|
Revision: 576 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=576&view=rev Author: GingerDog Date: 2009-03-13 20:49:05 +0000 (Fri, 13 Mar 2009) Log Message: ----------- require php5 Modified Paths: -------------- trunk/setup.php Modified: trunk/setup.php =================================================================== --- trunk/setup.php 2009-03-13 20:48:24 UTC (rev 575) +++ trunk/setup.php 2009-03-13 20:49:05 UTC (rev 576) @@ -63,9 +63,14 @@ // if ($f_phpversion == 1) { - if (phpversion() < 5) $phpversion = 4; - if (phpversion() >= 5) $phpversion = 5; - print "<li>PHP version " . phpversion () . "</li>\n"; + if (phpversion() < 5) { + print "<li><b>Error: Depends on: PHP v5</b><br /></li>\n"; + $error += 1; + } + if (phpversion() >= 5) { + $phpversion = 5; + print "<li>PHP version " . phpversion () . "</li>\n"; + } } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-03-12 09:12:05
|
Revision: 574 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=574&view=rev Author: GingerDog Date: 2009-03-12 09:11:22 +0000 (Thu, 12 Mar 2009) Log Message: ----------- INSTALL.TXT: we now require PHP5+ Modified Paths: -------------- trunk/INSTALL.TXT Modified: trunk/INSTALL.TXT =================================================================== --- trunk/INSTALL.TXT 2009-03-11 22:38:15 UTC (rev 573) +++ trunk/INSTALL.TXT 2009-03-12 09:11:22 UTC (rev 574) @@ -9,7 +9,7 @@ ---------- - You are using Postfix 2.0 or higher. - You are using Apache 1.3.27 / Lighttpd 1.3.15 or higher. -- You are using PHP 4.1 or higher (5.X recommended) +- You are using PHP 5.X - You are using MySQL 3.23 or higher (5.x recommended) OR PostgreSQL 7.4 (or higher) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-03-11 22:38:23
|
Revision: 573 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=573&view=rev Author: christian_boltz Date: 2009-03-11 22:38:15 +0000 (Wed, 11 Mar 2009) Log Message: ----------- sendmail.php: - encode Subject with mb_encode_mimeheader https://sourceforge.net/tracker2/?func=detail&atid=937964&aid=2682897&group_id=191583 Modified Paths: -------------- trunk/sendmail.php Modified: trunk/sendmail.php =================================================================== --- trunk/sendmail.php 2009-03-08 21:16:41 UTC (rev 572) +++ trunk/sendmail.php 2009-03-11 22:38:15 UTC (rev 573) @@ -45,7 +45,8 @@ $fHeaders = "To: " . $fTo . "\n"; $fHeaders .= "From: " . $fFrom . "\n"; - $fHeaders .= "Subject: " . encode_header(safepost('fSubject')) . "\n"; + mb_internal_encoding("UTF-8"); + $fHeaders .= "Subject: " . mb_encode_mimeheader( safepost('fSubject'), 'UTF-8', 'Q') . "\n"; $fHeaders .= "MIME-Version: 1.0\n"; $fHeaders .= "Content-Type: text/plain; charset=utf-8\n"; $fHeaders .= "Content-Transfer-Encoding: 8bit\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-03-08 21:16:44
|
Revision: 572 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=572&view=rev Author: GingerDog Date: 2009-03-08 21:16:41 +0000 (Sun, 08 Mar 2009) Log Message: ----------- see https://sourceforge.net/tracker/index.php?func=detail&aid=2567466&group_id=191583&atid=937966 - allow adding of an alias even if a mailbox already exists (e.g. allowing you to do keep+forward) Modified Paths: -------------- trunk/create-alias.php trunk/delete.php trunk/edit-alias.php trunk/functions.inc.php trunk/list-virtual.php Modified: trunk/create-alias.php =================================================================== --- trunk/create-alias.php 2009-02-26 22:57:11 UTC (rev 571) +++ trunk/create-alias.php 2009-03-08 21:16:41 UTC (rev 572) @@ -117,13 +117,15 @@ $fAddress = "@" . escape_string ($_POST['fDomain']); } + $append_alias = false; + $result = db_query ("SELECT * FROM $table_alias WHERE address='$fAddress'"); - if ($result['rows'] == 1) { - $error = 1; + if ($result['rows'] == 1) + { + $append_alias = true; $tAddress = escape_string ($_POST['fAddress']); $tGoto = $fGoto; $tDomain = $fDomain; - $pCreate_alias_address_text = $PALANG['pCreate_alias_address_text_error2']; } if ($fActive == "on") { @@ -133,13 +135,29 @@ $sqlActive = db_get_boolean(False); } - if ($error != 1) { + $success = false; + /* Alias (or mailbox) already present, let's add the destination to that row */ + if ($append_alias) { if (preg_match('/^\*@(.*)$/', $fGoto, $match)) { $fGoto = "@" . $match[1]; } + $array = db_array ($result['result']); + + $values ['goto'] = $array['goto'] . ',' . $fGoto; + $result = db_update ($table_alias, "address = '$fAddress'", $values, array ('modified')); + $success = ($result == 1); + + } elseif ($error != 1) { + if (preg_match('/^\*@(.*)$/', $fGoto, $match)) { + $fGoto = "@" . $match[1]; + } + $result = db_query ("INSERT INTO $table_alias (address,goto,domain,created,modified,active) VALUES ('$fAddress','$fGoto','$fDomain',NOW(),NOW(),'$sqlActive')"); - if ($result['rows'] != 1) { + $success = ($result['rows'] == 1); + } + + if (! $success) { $tDomain = $fDomain; $tMessage = $PALANG['pCreate_alias_result_error'] . "<br />($fAddress -> $fGoto)<br />\n"; } @@ -149,7 +167,6 @@ $tDomain = $fDomain; $tMessage = $PALANG['pCreate_alias_result_success'] . "<br />($fAddress -> $fGoto)<br />\n"; } - } } include ("templates/header.php"); Modified: trunk/delete.php =================================================================== --- trunk/delete.php 2009-02-26 22:57:11 UTC (rev 571) +++ trunk/delete.php 2009-03-08 21:16:41 UTC (rev 572) @@ -43,6 +43,57 @@ $error=0; +/** + * delete_alias + * Action: Delete an alias + * @param String $alias- alias to delete. + * @param String $domain - domain of the alias + * @param boolean $force_delete - deletes the alias from the table if true, + * checks if the alias is real and act accordlying if false. + * Default is false. + * @return String username (e.g. fo...@ex...) + */ +function delete_alias ($alias, $domain, $force_delete = false) +{ + global $table_alias, $table_mailbox; + $real_alias = true; + + if (! $force_delete) + { + $result = db_query ("SELECT 1 FROM $table_mailbox + WHERE username='$alias' AND domain='$domain'"); + if ($result['rows'] != 0) + { + /* If the alias is a real mailbox as well, remove all its real aliases and keep + * only the address */ + $real_alias = false; + } + } + + if ($force_delete or $real_alias) + { + $result = db_query ("DELETE FROM $table_alias WHERE address='$alias' AND domain='$domain'"); + } + else + { + $result = db_query ("UPDATE $table_alias SET goto='$alias',modified=NOW() + WHERE address='$alias' AND domain='$domain'"); + } + + if ($result['rows'] != 1) + { + $tMessage = $PALANG['pDelete_delete_error'] . "<b>$alias</b> (alias)!</span>"; + + return false; + } + else + { + db_log ($SESSID_USERNAME, $fDomain, 'delete_alias', $fDelete); + } + + return true; +} + if ($fTable == "admin") { authentication_require_role('global-admin'); @@ -98,7 +149,7 @@ } } # ($fTable == "alias_domain") -elseif ($fTable == "alias" or $fTable == "mailbox") +elseif ($fTable == "mailbox") { if (!check_owner ($SESSID_USERNAME, $fDomain)) @@ -114,52 +165,61 @@ else { if ($CONF['database_type'] == "pgsql") db_query('BEGIN'); - /* there may be no aliases to delete */ - $result = db_query("SELECT * FROM $table_alias WHERE address = '$fDelete' AND domain = '$fDomain'"); - if($result['rows'] == 1) { - $result = db_query ("DELETE FROM $table_alias WHERE address='$fDelete' AND domain='$fDomain'"); - db_log ($SESSID_USERNAME, $fDomain, 'delete_alias', $fDelete); - } - /* is there a mailbox? if do delete it from orbit; it's the only way to be sure */ - $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fDelete' AND domain='$fDomain'"); - if ($result['rows'] == 1) + $error = delete_alias ($fDelete, $fDomain, $force_delete = true) ? 0 : 1; + if (! $error) { - $result = db_query ("DELETE FROM $table_mailbox WHERE username='$fDelete' AND domain='$fDomain'"); - $postdel_res=mailbox_postdeletion($fDelete,$fDomain); - if ($result['rows'] != 1 || !$postdel_res) + /* is there a mailbox? if do delete it from orbit; it's the only way to be sure */ + $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fDelete' AND domain='$fDomain'"); + if ($result['rows'] == 1) { - $error = 1; - $tMessage = $PALANG['pDelete_delete_error'] . "<b>$fDelete</b> ("; - if ($result['rows']!=1) + $result = db_query ("DELETE FROM $table_mailbox WHERE username='$fDelete' AND domain='$fDomain'"); + $postdel_res=mailbox_postdeletion($fDelete,$fDomain); + if ($result['rows'] != 1 || !$postdel_res) { - $tMessage.='mailbox'; - if (!$postdel_res) $tMessage.=', '; + $error = 1; + $tMessage = $PALANG['pDelete_delete_error'] . "<b>$fDelete</b> ("; + if ($result['rows']!=1) + { + $tMessage.='mailbox'; + if (!$postdel_res) $tMessage.=', '; + } + if (!$postdel_res) + { + $tMessage.='post-deletion'; + } + $tMessage.=')</span>'; } - if (!$postdel_res) - { - $tMessage.='post-deletion'; - } - $tMessage.=')</span>'; } + $result = db_query("SELECT * FROM $table_vacation WHERE email = '$fDelete' AND domain = '$fDomain'"); + if($result['rows'] == 1) { + db_query ("DELETE FROM $table_vacation WHERE email='$fDelete' AND domain='$fDomain'"); + db_query ("DELETE FROM $table_vacation_notification WHERE on_vacation ='$fDelete' "); /* should be caught by cascade, if PgSQL */ + } } - $result = db_query("SELECT * FROM $table_vacation WHERE email = '$fDelete' AND domain = '$fDomain'"); - if($result['rows'] == 1) { - db_query ("DELETE FROM $table_vacation WHERE email='$fDelete' AND domain='$fDomain'"); - db_query ("DELETE FROM $table_vacation_notification WHERE on_vacation ='$fDelete' "); /* should be caught by cascade, if PgSQL */ + + if ($error != 1) + { + if ($CONF['database_type'] == "pgsql") db_query('COMMIT'); + header ("Location: list-virtual.php?domain=$fDomain"); + exit; + } else { + $tMessage = $PALANG['pDelete_delete_error'] . "<b>$fDelete</b> (physical mail)!</span>"; + if ($CONF['database_type'] == "pgsql") db_query('ROLLBACK'); } - } + } # ($fTable == "mailbox") +} +elseif ($fTable == "alias") { + $error = delete_alias ($fDelete, $fDomain) ? 0 : 1; if ($error != 1) { - if ($CONF['database_type'] == "pgsql") db_query('COMMIT'); header ("Location: list-virtual.php?domain=$fDomain"); exit; } else { - $tMessage .= $PALANG['pDelete_delete_error'] . "<b>$fDelete</b> (physical mail)!</span>"; - if ($CONF['database_type'] == "pgsql") db_query('ROLLBACK'); + $tMessage = $PALANG['pDelete_delete_error'] . "<b>$fDelete</b> (alias)!</span>"; } -} +} else { flash_error($PALANG['invalid_parameter']); Modified: trunk/edit-alias.php =================================================================== --- trunk/edit-alias.php 2009-02-26 22:57:11 UTC (rev 571) +++ trunk/edit-alias.php 2009-03-08 21:16:41 UTC (rev 572) @@ -46,6 +46,13 @@ { $row = db_array ($result['result']); $tGoto = $row['goto']; + + /* Has a mailbox as well? Remove the address from $tGoto in order to edit just the real aliases */ + $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fAddress' AND domain='$fDomain'"); + if ($result['rows'] == 1) + { + $tGoto = preg_replace ('/\s*,*\s*' . $fAddress . '\s*,*\s*/', '', $tGoto); + } } } else @@ -110,6 +117,13 @@ } } + $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fAddress' AND domain='$fDomain'"); + /* The alias has a real mailbox as well, prepend $goto with it */ + if ($result['rows'] == 1) + { + $goto = "$fAddress,$goto"; + } + if ($error != 1) { $result = db_query ("UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$fAddress' AND domain='$fDomain'"); Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2009-02-26 22:57:11 UTC (rev 571) +++ trunk/functions.inc.php 2009-03-08 21:16:41 UTC (rev 572) @@ -431,18 +431,25 @@ global $table_alias, $table_mailbox, $table_domain; $list = array (); - $result = db_query ("SELECT COUNT(*) FROM $table_alias WHERE domain='$domain'"); - $row = db_row ($result['result']); - $list['alias_count'] = $row[0]; + $result = db_query ("SELECT COUNT(*) FROM $table_alias + LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username + WHERE ($table_alias.domain='$domain' AND $table_mailbox.maildir IS NULL) + OR + ($table_alias.domain='$domain' + AND $table_alias.goto LIKE '%,%' + AND $table_mailbox.maildir IS NOT NULL)"); + $row = db_row ($result['result']); + $list['alias_count'] = $row[0]; + $result = db_query ("SELECT COUNT(*) FROM $table_mailbox WHERE domain='$domain'"); $row = db_row ($result['result']); $list['mailbox_count'] = $row[0]; - $result = db_query ("SELECT SUM(quota) FROM $table_mailbox WHERE domain='$domain'"); - $row = db_row ($result['result']); - $list['quota_sum'] = $row[0]; - $list['alias_count'] = $list['alias_count'] - $list['mailbox_count']; + $result = db_query ("SELECT SUM(quota) FROM $table_mailbox WHERE domain='$domain'"); + $row = db_row ($result['result']); + $list['quota_sum'] = $row[0]; + $list['alias_count'] = $list['alias_count']; $list['alias_pgindex']=array (); $list['mbox_pgindex']=array (); @@ -455,24 +462,40 @@ $idxlabel=""; $list['alias_pgindex_count'] = 0; - if ( $list['alias_count'] > $page_size ) - { - while ( $current < $list['alias_count'] ) - { - $limitSql=('pgsql'==$CONF['database_type']) ? "1 OFFSET $current" : "$current, 1"; - $query = "SELECT $table_alias.address FROM $table_alias LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username WHERE $table_alias.domain='$domain' AND $table_mailbox.maildir IS NULL ORDER BY $table_alias.address LIMIT $limitSql"; - $result = db_query ("$query"); - $row = db_array ($result['result']); - $tmpstr = $row['address']; - //get first 2 chars - $idxlabel = $tmpstr[0] . $tmpstr[1] . "-"; - ($current + $page_size - 1 <= $list['alias_count']) ? $current = $current + $page_size - 1 : $current = $list['alias_count'] - 1; - $limitSql=('pgsql'==$CONF['database_type']) ? "1 OFFSET $current" : "$current, 1"; - $query = "SELECT $table_alias.address FROM $table_alias LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username WHERE $table_alias.domain='$domain' AND $table_mailbox.maildir IS NULL ORDER BY $table_alias.address LIMIT $limitSql"; - $result = db_query ("$query"); - $row = db_array ($result['result']); - $tmpstr = $row['address']; - $idxlabel = $idxlabel . $tmpstr[0] . $tmpstr[1]; + if ( $list['alias_count'] > $page_size ) + { + while ( $current < $list['alias_count'] ) + { + $limitSql=('pgsql'==$CONF['database_type']) ? "1 OFFSET $current" : "$current, 1"; + $query = "SELECT $table_alias.address + FROM $table_alias + LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username + WHERE ($table_alias.domain='$domain' AND $table_mailbox.maildir IS NULL) + OR + ($table_alias.domain='$domain' + AND $table_alias.goto LIKE '%,%' + AND $table_mailbox.maildir IS NOT NULL) + ORDER BY $table_alias.address LIMIT $limitSql"; + $result = db_query ("$query"); + $row = db_array ($result['result']); + $tmpstr = $row['address']; + //get first 2 chars + $idxlabel = $tmpstr[0] . $tmpstr[1] . "-"; + ($current + $page_size - 1 <= $list['alias_count']) ? $current = $current + $page_size - 1 : $current = $list['alias_count'] - 1; + $limitSql=('pgsql'==$CONF['database_type']) ? "1 OFFSET $current" : "$current, 1"; + $query = "SELECT $table_alias.address + FROM $table_alias + LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username + WHERE ($table_alias.domain='$domain' AND $table_mailbox.maildir IS NULL) + OR + ($table_alias.domain='$domain' + AND $table_alias.goto LIKE '%,%' + AND $table_mailbox.maildir IS NOT NULL) + ORDER BY $table_alias.address LIMIT $limitSql"; + $result = db_query ("$query"); + $row = db_array ($result['result']); + $tmpstr = $row['address']; + $idxlabel = $idxlabel . $tmpstr[0] . $tmpstr[1]; $current = $current + 1; @@ -1103,11 +1126,16 @@ -// -// pacrypt -// Action: Encrypts password based on config settings -// Call: pacrypt (string cleartextpassword) -// +/** + * Encrypt a password, using the apparopriate hashing mechanism as defined in + * config.inc.php ($CONF['encrypt']). + * When wanting to compare one pw to another, it's necessary to provide the salt used - hence + * the second parameter ($pw_db), which is the existing hash from the DB. + * + * @param string $pw + * @param string $encrypted password + * @return string encrypted password. + */ function pacrypt ($pw, $pw_db="") { global $CONF; Modified: trunk/list-virtual.php =================================================================== --- trunk/list-virtual.php 2009-02-26 22:57:11 UTC (rev 571) +++ trunk/list-virtual.php 2009-03-08 21:16:41 UTC (rev 572) @@ -72,7 +72,6 @@ exit(0); } - if (boolconf('alias_domain')) { # Alias-Domains # first try to get a list of other domains pointing @@ -118,10 +117,29 @@ } } -$query = "SELECT $table_alias.address,$table_alias.goto,$table_alias.modified,$table_alias.active FROM $table_alias LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username WHERE $table_alias.domain='$fDomain' AND $table_mailbox.maildir IS NULL ORDER BY $table_alias.address LIMIT $fDisplay, $page_size"; +$query = "SELECT $table_alias.address, + $table_alias.goto, + $table_alias.modified, + $table_alias.active + FROM $table_alias LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username + WHERE ($table_alias.domain='$fDomain' AND $table_mailbox.maildir IS NULL) + OR + ($table_alias.domain='$fDomain' + AND $table_alias.goto LIKE '%,%' + AND $table_mailbox.maildir IS NOT NULL) + ORDER BY $table_alias.address LIMIT $fDisplay, $page_size"; + if ('pgsql'==$CONF['database_type']) { - $query = "SELECT address,goto,extract(epoch from modified) as modified,active FROM $table_alias WHERE domain='$fDomain' AND NOT EXISTS(SELECT 1 FROM $table_mailbox WHERE username=$table_alias.address) ORDER BY address LIMIT $page_size OFFSET $fDisplay"; + $query = "SELECT address, + goto, + modified, + active + FROM $table_alias WHERE domain='$fDomain' + AND NOT EXISTS(SELECT 1 FROM $table_mailbox + WHERE username=$table_alias.address + AND $table_alias.goto NOT LIKE '%,%') + ORDER BY address LIMIT $page_size OFFSET $fDisplay"; } $result = db_query ($query); if ($result['rows'] > 0) @@ -133,6 +151,13 @@ $row['modified']=gmstrftime('%c %Z',$row['modified']); $row['active']=('t'==$row['active']) ? 1 : 0; } + + /* Has a real mailbox as well? Remove the address from $row['goto'] in order to edit just the real aliases */ + if (strstr ($row['goto'], ',') != FALSE) + { + $row['goto'] = preg_replace ('/\s*,*\s*' . $row['address'] . '\s*,*\s*/', '', $row['goto']); + } + $tAlias[] = $row; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-02-26 22:57:19
|
Revision: 571 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=571&view=rev Author: christian_boltz Date: 2009-02-26 22:57:11 +0000 (Thu, 26 Feb 2009) Log Message: ----------- list-virtual.php - do not hide "add alias" / "add mailbox" links if domain is a backup MX (includes some whitespace changes, the "real" change removes 3 lines of code checking for the backupmx setting) edit-domain.php - do not reset aliases, mailboxes and maxquota to disabled for backup MX domains These changes should fix https://sourceforge.net/forum/forum.php?thread_id=2897067&forum_id=676076 Modified Paths: -------------- trunk/edit-domain.php trunk/list-virtual.php Modified: trunk/edit-domain.php =================================================================== --- trunk/edit-domain.php 2009-02-26 22:35:50 UTC (rev 570) +++ trunk/edit-domain.php 2009-02-26 22:57:11 UTC (rev 571) @@ -80,9 +80,6 @@ if ($fBackupmx == "on") { - $fAliases = -1; - $fMailboxes = -1; - $fMaxquota = -1; $fBackupmx = 1; $sqlBackupmx = db_get_boolean(True); } Modified: trunk/list-virtual.php =================================================================== --- trunk/list-virtual.php 2009-02-26 22:35:50 UTC (rev 570) +++ trunk/list-virtual.php 2009-02-26 22:57:11 UTC (rev 571) @@ -193,21 +193,18 @@ $tDisplay_next = $fDisplay + $page_size; } - $backup_mx = $limit['backupmx']; - if($backup_mx == 'f' || $backup_mx == 0) { - if($limit['aliases'] == 0) { - $tCanAddAlias = true; - } - elseif($limit['alias_count'] < $limit['aliases']) { - $tCanAddAlias = true; - } - if($limit['mailboxes'] == 0) { - $tCanAddMailbox = true; - } - elseif($limit['mailbox_count'] < $limit['mailboxes']) { - $tCanAddMailbox = true; - } + if($limit['aliases'] == 0) { + $tCanAddAlias = true; } + elseif($limit['alias_count'] < $limit['aliases']) { + $tCanAddAlias = true; + } + if($limit['mailboxes'] == 0) { + $tCanAddMailbox = true; + } + elseif($limit['mailbox_count'] < $limit['mailboxes']) { + $tCanAddMailbox = true; + } } // this is why we need a proper template layer. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-02-26 22:35:57
|
Revision: 570 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=570&view=rev Author: christian_boltz Date: 2009-02-26 22:35:50 +0000 (Thu, 26 Feb 2009) Log Message: ----------- broadcast-message.php: - set mb_internal_encoding("UTF-8") to avoid broken encoding in mailheaders https://sourceforge.net/tracker/?func=detail&atid=937964&aid=2641660&group_id=191583 Modified Paths: -------------- trunk/broadcast-message.php Modified: trunk/broadcast-message.php =================================================================== --- trunk/broadcast-message.php 2009-02-25 10:24:30 UTC (rev 569) +++ trunk/broadcast-message.php 2009-02-26 22:35:50 UTC (rev 570) @@ -52,6 +52,7 @@ $result = db_query ($q); if ($result['rows'] > 0) { + mb_internal_encoding("UTF-8"); $b_name = mb_encode_mimeheader( $_POST['name'], 'UTF-8', 'Q'); $b_subject = mb_encode_mimeheader( $_POST['subject'], 'UTF-8', 'Q'); $b_message = base64_encode($_POST['message']); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-02-25 10:24:32
|
Revision: 569 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=569&view=rev Author: GingerDog Date: 2009-02-25 10:24:30 +0000 (Wed, 25 Feb 2009) Log Message: ----------- create-domain.php: if the user makes a domain a backup mx, then accept whatever they type in for mailboxes/aliases Modified Paths: -------------- trunk/create-domain.php Modified: trunk/create-domain.php =================================================================== --- trunk/create-domain.php 2009-02-25 10:22:57 UTC (rev 568) +++ trunk/create-domain.php 2009-02-25 10:24:30 UTC (rev 569) @@ -108,9 +108,6 @@ if ($fBackupmx == "on") { - $fAliases = -1; - $fMailboxes = -1; - $fMaxquota = -1; $fBackupmx = 1; $sqlBackupmx = db_get_boolean(true); } @@ -119,6 +116,7 @@ $fBackupmx = 0; $sqlBackupmx = db_get_boolean(false); } + $sql_query = "INSERT INTO $table_domain (domain,description,aliases,mailboxes,maxquota,transport,backupmx,created,modified) VALUES ('$fDomain','$fDescription',$fAliases,$fMailboxes,$fMaxquota,'$fTransport',$sqlBackupmx,NOW(),NOW())"; $result = db_query($sql_query); if ($result['rows'] != 1) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-02-25 10:23:04
|
Revision: 568 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=568&view=rev Author: GingerDog Date: 2009-02-25 10:22:57 +0000 (Wed, 25 Feb 2009) Log Message: ----------- INSTALL.TXT - see https://sourceforge.net/forum/forum.php?thread_id=3026548&forum_id=676076 ; general update, and add in a note on alias expansion Modified Paths: -------------- trunk/VIRTUAL_VACATION/INSTALL.TXT Modified: trunk/VIRTUAL_VACATION/INSTALL.TXT =================================================================== --- trunk/VIRTUAL_VACATION/INSTALL.TXT 2009-02-16 12:40:15 UTC (rev 567) +++ trunk/VIRTUAL_VACATION/INSTALL.TXT 2009-02-25 10:22:57 UTC (rev 568) @@ -3,12 +3,10 @@ ################################################## # # Postfix Admin (Virtual Vacation) -# by Mischa Peters <mischa at high5 dot net> +# Originally authored by Mischa Peters <mischa at high5 dot net> # Copyright (c) 2002 - 2005 High5! # Licensed under GPL for more info check GPL-LICENSE.TXT # -# Modified by: Nicholas Paufler <npaufler at incentre dot net> (12/06/2004) -# REQUIRED! --------- @@ -20,14 +18,21 @@ It obviously relies on Perl - About Virtual Vacation ---------------------- -Virtual Vacation is today done with a local shell account that can receive -email. The email is then handled by a Perl script which sends the Vacation -message back to the sender. +The vacation script runs as service within Postfix's master.cf configuration file. +Mail is sent to the vacation service via a transport table mapping. +When users mark themselves as away on vacation, an alias is added to their account +sending a copy of all mail to them to the vacation service. +e.g. mail to bi...@go... will be delivered to + bi...@go... AND + billy#goa...@au... +Mail to @autoreply.goat.com is caught by the vacation.pl script and a reply +will be sent based on various settings. By default a reply is only sent once. + + Install Virtual Vacation ------------------------ @@ -71,13 +76,16 @@ 4. Setup the transport type --------------------- +--------------------------- Define the transport type in the Postfix master file: #/etc/postfix/master.cf: vacation unix - n n - - pipe flags=Rq user=vacation argv=/var/spool/vacation/vacation.pl -f ${sender} -- ${recipient} +5. Setup the transport maps file +-------------------------------- + Tell Postfix to use a transport maps file, so add the following to your Postfix main.cf: @@ -99,15 +107,8 @@ Execute "postfix reload" to complete the change. -5. Create the table -------------------- -The database table should have already been created for you, by running -the 'upgrade.php' script when installing Postfixadmin. -If security is an issue for you, read ../DOCUMENTS/Security.txt - - 6. Configure vacation.pl ------------------------ @@ -132,6 +133,45 @@ $db_username = 'mail'; +7. Check the alias expansion +---------------------------- + +Depending on your setup, you may have multiple 'smtpd' service definitions within +your postfix master.cf file. This is especially the case if you are also using AMAVIS or +another content filtering system when mail is re-injected into Postfix using the smtpd daemon. + +If you are, it's likely that alias expansion may happen more than once, in which case you +may see vacation-style responses duplicated. To suppress this behaviour, you need to add : + + -o receive_override_options=no_address_mappings + +For example : + +smtp inet n - - - 12 smtpd + -o content_filter=amavis:[127.0.0.50]:10024 + + ^^^ Alias expansion occurs here, so we don't want it to happen again for the other smtpd daemon (below) + which receives email out of amavis on port 10025. + +127.0.0.1:10025 inet n - - - - smtpd + -o smtpd_autorized_xforward_hosts=127.0.0.0/8 + -o smtpd_client_restrictions= + -o smtpd_helo_restrictions= + -o smtpd_sender_restrictions= + -o smtpd_recipient_restrictions=permit_mynetworks,reject + -o mynetworks=127.0.0.0/8 + -o receive_override_options=no_unknown_recipient_checks,no_header_body_checks,no_address_mappings + + + +8. Security +----------- + +If security is an issue for you, read ../DOCUMENTS/Security.txt + + + + What do these files do? ----------------------- When a user enables a vacation message on their account, the alias This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-02-16 12:40:18
|
Revision: 567 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=567&view=rev Author: GingerDog Date: 2009-02-16 12:40:15 +0000 (Mon, 16 Feb 2009) Log Message: ----------- see https://sourceforge.net/tracker/index.php?func=detail&aid=2581010&group_id=191583&atid=937964 - thanks dystopian Modified Paths: -------------- trunk/functions.inc.php Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2009-02-15 15:02:26 UTC (rev 566) +++ trunk/functions.inc.php 2009-02-16 12:40:15 UTC (rev 567) @@ -1298,7 +1298,7 @@ // smtp_mail // Action: Sends email to new account. // Call: smtp_mail (string To, string From, string Data) -// +// TODO: Replace this with something decent like PEAR::Mail or Zend_Mail. function smtp_mail ($to, $from, $data) { global $CONF; @@ -1317,6 +1317,7 @@ } else { + $res = smtp_get_response($fh); fputs ($fh, "EHLO $smtp_server\r\n"); $res = smtp_get_response($fh); fputs ($fh, "MAIL FROM:<$from>\r\n"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-02-15 15:02:30
|
Revision: 566 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=566&view=rev Author: christian_boltz Date: 2009-02-15 15:02:26 +0000 (Sun, 15 Feb 2009) Log Message: ----------- - added/fixed vim: lines to nearly all *.php files (exception: templates/*) (ts=3 or ts=4 depending on the file content) - several whitespace fixes - (no code changes) Modified Paths: -------------- trunk/create-alias.php trunk/delete.php trunk/edit-admin.php trunk/edit-alias.php trunk/edit-domain.php trunk/index.php trunk/list-admin.php trunk/login.php trunk/logout.php trunk/main.php trunk/password.php trunk/search.php trunk/setup.php trunk/templates/header.php trunk/users/edit-alias.php trunk/users/index.php trunk/users/logout.php trunk/users/main.php trunk/users/password.php trunk/variables.inc.php Modified: trunk/create-alias.php =================================================================== --- trunk/create-alias.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/create-alias.php 2009-02-15 15:02:26 UTC (rev 566) @@ -41,7 +41,7 @@ $list_domains = list_domains (); } else { - $list_domains = list_domains_for_admin ($username); + $list_domains = list_domains_for_admin ($username); } $pCreate_alias_goto_text = $PALANG['pCreate_alias_goto_text']; @@ -57,7 +57,7 @@ { if (isset ($_POST['fAddress']) && isset ($_POST['fDomain'])) { $fAddress = escape_string($_POST['fAddress']) . "@" . escape_string ($_POST['fDomain']); - $fAddress = strtolower ($fAddress); + $fAddress = strtolower ($fAddress); } if (isset ($_POST['fGoto'])) { @@ -156,4 +156,5 @@ include ("templates/menu.php"); include ("templates/create-alias.php"); include ("templates/footer.php"); +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: trunk/delete.php =================================================================== --- trunk/delete.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/delete.php 2009-02-15 15:02:26 UTC (rev 566) @@ -171,5 +171,5 @@ include ("templates/message.php"); include ("templates/footer.php"); -/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: trunk/edit-admin.php =================================================================== --- trunk/edit-admin.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/edit-admin.php 2009-02-15 15:02:26 UTC (rev 566) @@ -101,11 +101,11 @@ $sqlActive = db_get_boolean(False); } - $password_query = ''; - if ($fPassword != '') { # do not change password to empty one - $password_query = ", password='$fPassword'"; - } - $result = db_query ("UPDATE $table_admin SET modified=NOW(),active='$sqlActive' $password_query WHERE username='$username'"); + $password_query = ''; + if ($fPassword != '') { # do not change password to empty one + $password_query = ", password='$fPassword'"; + } + $result = db_query ("UPDATE $table_admin SET modified=NOW(),active='$sqlActive' $password_query WHERE username='$username'"); if ($fSadmin == "on") $fSadmin = 'ALL'; @@ -155,5 +155,5 @@ include ("templates/admin_edit-admin.php"); include ("templates/footer.php"); -/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: trunk/edit-alias.php =================================================================== --- trunk/edit-alias.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/edit-alias.php 2009-02-15 15:02:26 UTC (rev 566) @@ -99,15 +99,15 @@ $array = array(); } - for ($i = 0; $i < sizeof ($array); $i++) { - if (in_array ("$array[$i]", $CONF['default_aliases'])) continue; - if (empty ($array[$i])) continue; # TODO: should never happen - remove after 2.2 release - if (!check_email ($array[$i])) - { - $error = 1; - $tGoto = $goto; - $tMessage = $PALANG['pEdit_alias_goto_text_error2'] . "$array[$i]</span>"; - } + for ($i = 0; $i < sizeof ($array); $i++) { + if (in_array ("$array[$i]", $CONF['default_aliases'])) continue; + if (empty ($array[$i])) continue; # TODO: should never happen - remove after 2.2 release + if (!check_email ($array[$i])) + { + $error = 1; + $tGoto = $goto; + $tMessage = $PALANG['pEdit_alias_goto_text_error2'] . "$array[$i]</span>"; + } } if ($error != 1) Modified: trunk/edit-domain.php =================================================================== --- trunk/edit-domain.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/edit-domain.php 2009-02-15 15:02:26 UTC (rev 566) @@ -121,5 +121,5 @@ include ("templates/admin_edit-domain.php"); include ("templates/footer.php"); -/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: trunk/index.php =================================================================== --- trunk/index.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/index.php 2009-02-15 15:02:26 UTC (rev 566) @@ -85,3 +85,6 @@ </p> </body> </html> +<?php +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ +?> Modified: trunk/list-admin.php =================================================================== --- trunk/list-admin.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/list-admin.php 2009-02-15 15:02:26 UTC (rev 566) @@ -27,9 +27,9 @@ $list_admins = list_admins(); if ((is_array ($list_admins) and sizeof ($list_admins) > 0)) { - for ($i = 0; $i < sizeof ($list_admins); $i++) { - $admin_properties[$i] = get_admin_properties ($list_admins[$i]); - } + for ($i = 0; $i < sizeof ($list_admins); $i++) { + $admin_properties[$i] = get_admin_properties ($list_admins[$i]); + } } include ("templates/header.php"); @@ -37,4 +37,5 @@ include ("templates/admin_list-admin.php"); include ("templates/footer.php"); +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: trunk/login.php =================================================================== --- trunk/login.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/login.php 2009-02-15 15:02:26 UTC (rev 566) @@ -32,14 +32,14 @@ # force user to delete setup.php (allows creation of superadmins!) if (file_exists (realpath ("./setup.php"))) { - if (is_string($CONF['configured']) && $CONF['configured'] == 'I_know_the_risk_of_not_deleting_setup.php') - { - } - else - { + if (is_string($CONF['configured']) && $CONF['configured'] == 'I_know_the_risk_of_not_deleting_setup.php') + { + } + else + { print "Please delete setup.php before using Postfix Admin!"; exit; - } + } } if ($_SERVER['REQUEST_METHOD'] == "GET") @@ -55,12 +55,12 @@ $fPassword = ''; if (isset ($_POST['fUsername'])) $fUsername = escape_string ($_POST['fUsername']); if (isset ($_POST['fPassword'])) $fPassword = escape_string ($_POST['fPassword']); - $lang = safepost('lang'); + $lang = safepost('lang'); - if ( $lang != check_language(0) ) { # only set cookie if language selection was changed - setcookie('lang', $lang, time() + 60*60*24*30); # language cookie, lifetime 30 days - # (language preference cookie is processed even if username and/or password are invalid) - } + if ( $lang != check_language(0) ) { # only set cookie if language selection was changed + setcookie('lang', $lang, time() + 60*60*24*30); # language cookie, lifetime 30 days + # (language preference cookie is processed even if username and/or password are invalid) + } $result = db_query ("SELECT password FROM $table_admin WHERE username='$fUsername' AND active='1'"); if ($result['rows'] == 1) @@ -105,4 +105,6 @@ include ("./templates/login.php"); include ("./templates/footer.php"); } + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: trunk/logout.php =================================================================== --- trunk/logout.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/logout.php 2009-02-15 15:02:26 UTC (rev 566) @@ -28,4 +28,6 @@ header ("Location: login.php"); exit; + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: trunk/main.php =================================================================== --- trunk/main.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/main.php 2009-02-15 15:02:26 UTC (rev 566) @@ -31,4 +31,6 @@ include ("./templates/menu.php"); include ("./templates/main.php"); include ("./templates/footer.php"); + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: trunk/password.php =================================================================== --- trunk/password.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/password.php 2009-02-15 15:02:26 UTC (rev 566) @@ -93,4 +93,6 @@ include ("./templates/password.php"); include ("./templates/footer.php"); } + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: trunk/search.php =================================================================== --- trunk/search.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/search.php 2009-02-15 15:02:26 UTC (rev 566) @@ -90,7 +90,7 @@ { $row['modified']=gmstrftime('%c %Z',$row['modified']); $row['active']=('t'==$row['active']) ? 1 : 0; - } + } $tAlias[] = $row; } } @@ -129,5 +129,5 @@ include ("templates/search.php"); include ("templates/footer.php"); -// vim:ts=4:sw=4:et +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: trunk/setup.php =================================================================== --- trunk/setup.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/setup.php 2009-02-15 15:02:26 UTC (rev 566) @@ -209,8 +209,8 @@ } else { print "<li><b>Error: Can't connect to database</b><br />\n"; print "Please edit the \$CONF['database_*'] parameters in config.inc.php.\n"; - print "$error_text</li>\n"; - $error ++; + print "$error_text</li>\n"; + $error ++; } } @@ -369,3 +369,6 @@ </div> </body> </html> +<?php +/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ +?> Modified: trunk/templates/header.php =================================================================== --- trunk/templates/header.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/templates/header.php 2009-02-15 15:02:26 UTC (rev 566) @@ -14,9 +14,9 @@ <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <?php if (file_exists (realpath ("../".$CONF['theme_css']))) { - print "<link rel=\"stylesheet\" type=\"text/css\" href=\"../".htmlentities($CONF['theme_css'])."\" />\n"; + print "<link rel=\"stylesheet\" type=\"text/css\" href=\"../".htmlentities($CONF['theme_css'])."\" />\n"; } else { - print "<link rel=\"stylesheet\" type=\"text/css\" href=\"".htmlentities($CONF['theme_css'])."\" />\n"; + print "<link rel=\"stylesheet\" type=\"text/css\" href=\"".htmlentities($CONF['theme_css'])."\" />\n"; } ?> <title>Postfix Admin - <?php print $_SERVER['HTTP_HOST']; ?></title> @@ -26,14 +26,14 @@ <?php if (file_exists (realpath ("../".$CONF['theme_logo']))) { - print "<img id=\"login_header_logo\" src=\"../".htmlentities($CONF['theme_logo'])."\" />\n"; + print "<img id=\"login_header_logo\" src=\"../".htmlentities($CONF['theme_logo'])."\" />\n"; } else { - print "<img id=\"login_header_logo\" src=\"".htmlentities($CONF['theme_logo'])."\" />\n"; + print "<img id=\"login_header_logo\" src=\"".htmlentities($CONF['theme_logo'])."\" />\n"; } if (($CONF['show_header_text'] == "YES") and ($CONF['header_text'])) { - print "<h2>" . $CONF['header_text'] . "</h2>\n"; + print "<h2>" . $CONF['header_text'] . "</h2>\n"; } ?> </div> @@ -57,3 +57,6 @@ /* nuke it from orbit. It's the only way to be sure. */ $_SESSION['flash'] = array(); } + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ +?> Modified: trunk/users/edit-alias.php =================================================================== --- trunk/users/edit-alias.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/users/edit-alias.php 2009-02-15 15:02:26 UTC (rev 566) @@ -135,4 +135,6 @@ include ("../templates/users_edit-alias.php"); include ("../templates/footer.php"); } + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: trunk/users/index.php =================================================================== --- trunk/users/index.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/users/index.php 2009-02-15 15:02:26 UTC (rev 566) @@ -26,4 +26,6 @@ */ header ("Location: login.php"); exit; + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: trunk/users/logout.php =================================================================== --- trunk/users/logout.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/users/logout.php 2009-02-15 15:02:26 UTC (rev 566) @@ -29,4 +29,6 @@ header ("Location: login.php"); exit; + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: trunk/users/main.php =================================================================== --- trunk/users/main.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/users/main.php 2009-02-15 15:02:26 UTC (rev 566) @@ -54,4 +54,6 @@ include ("../templates/users_main.php"); include ("../templates/footer.php"); } + +/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> Modified: trunk/users/password.php =================================================================== --- trunk/users/password.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/users/password.php 2009-02-15 15:02:26 UTC (rev 566) @@ -32,7 +32,7 @@ authentication_require_role('user'); $USERID_USERNAME = authentication_get_username(); -$tmp = preg_split ('/@/', $USERID_USERNAME); +$tmp = preg_split ('/@/', $USERID_USERNAME); $USERID_DOMAIN = $tmp[1]; if ($_SERVER['REQUEST_METHOD'] == "POST") @@ -58,7 +58,7 @@ $row = db_array ($result['result']); $checked_password = pacrypt($fPassword_current, $row['password']); - $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$username' AND password='$checked_password'"); + $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$username' AND password='$checked_password'"); if ($result['rows'] != 1) { $error = 1; Modified: trunk/variables.inc.php =================================================================== --- trunk/variables.inc.php 2009-02-11 20:02:15 UTC (rev 565) +++ trunk/variables.inc.php 2009-02-15 15:02:26 UTC (rev 566) @@ -19,8 +19,8 @@ */ if (ereg ("variables.inc.php", $_SERVER['PHP_SELF'])) { - header ("Location: login.php"); - exit; + header ("Location: login.php"); + exit; } $error = ""; @@ -99,4 +99,6 @@ $pPassword_admin_text = " "; $pPassword_password_current_text = " "; $pPassword_password_text = " "; + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-02-11 20:02:19
|
Revision: 565 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=565&view=rev Author: christian_boltz Date: 2009-02-11 20:02:15 +0000 (Wed, 11 Feb 2009) Log Message: ----------- create-domain.php: - fixed "undefined variable $tBackupmx" on POST - fixed vim: line - create-domain.php already uses 4 spaces per tab Modified Paths: -------------- trunk/create-domain.php Modified: trunk/create-domain.php =================================================================== --- trunk/create-domain.php 2009-02-09 19:11:43 UTC (rev 564) +++ trunk/create-domain.php 2009-02-11 20:02:15 UTC (rev 565) @@ -84,6 +84,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { + $tBackupmx = ""; if ($fDomain == null or domain_exist($fDomain) or !check_domain($fDomain)) { $error = 1; @@ -139,7 +140,7 @@ if (!domain_postcreation($fDomain)) { $tMessage = $PALANG['pAdminCreate_domain_error']; - } + } } } @@ -148,5 +149,5 @@ include ("templates/admin_create-domain.php"); include ("templates/footer.php"); -/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-02-09 19:11:48
|
Revision: 564 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=564&view=rev Author: christian_boltz Date: 2009-02-09 19:11:43 +0000 (Mon, 09 Feb 2009) Log Message: ----------- functions.inc.php - added comment about courier-authlib supporting only two-character salt (see mail from Jan R?\195?\182hrich in postfixadmin-devel about r560) - fixed vim: line - functions.inc.php uses 4 spaces - replaced "else if" with "elseif" - replaced tabs with spaces Modified Paths: -------------- trunk/functions.inc.php Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2009-02-05 12:14:36 UTC (rev 563) +++ trunk/functions.inc.php 2009-02-09 19:11:43 UTC (rev 564) @@ -1128,7 +1128,7 @@ } if ($CONF['encrypt'] == 'system') { - if (ereg ("\$1\$", $pw_db)) { + if (ereg ("\$1\$", $pw_db)) { $split_salt = preg_split ('/\$/', $pw_db); $salt = $split_salt[2]; } @@ -1162,25 +1162,25 @@ } if ($CONF['encrypt'] == 'authlib') { - $flavor = $CONF['authlib_default_flavor']; - $salt = substr(create_salt(), 0, 2); - if(ereg('^{.*}', $pw_db)) { - // we have a flavor in the db -> use it instead of default flavor - $result = split('{|}', $pw_db, 3); - $flavor = $result[1]; - $salt = substr($result[2], 0, 2); - } - - if(stripos($flavor, 'md5raw') === 0) { - $password = '{' . $flavor . '}' . md5($pw); - } else if(stripos($flavor, 'md5') === 0) { - $password = '{' . $flavor . '}' . base64_encode(md5($pw, TRUE)); - } else if(stripos($flavor, 'crypt') === 0) { - $password = '{' . $flavor . '}' . crypt($pw, $salt); - } else { - die("authlib_default_flavor '" . $flavor . "' unknown. Valid flavors are 'md5raw', 'md5' and 'crypt'"); - } - } + $flavor = $CONF['authlib_default_flavor']; + $salt = substr(create_salt(), 0, 2); # courier-authlib supports only two-character salts + if(ereg('^{.*}', $pw_db)) { + // we have a flavor in the db -> use it instead of default flavor + $result = split('{|}', $pw_db, 3); + $flavor = $result[1]; + $salt = substr($result[2], 0, 2); + } + + if(stripos($flavor, 'md5raw') === 0) { + $password = '{' . $flavor . '}' . md5($pw); + } elseif(stripos($flavor, 'md5') === 0) { + $password = '{' . $flavor . '}' . base64_encode(md5($pw, TRUE)); + } elseif(stripos($flavor, 'crypt') === 0) { + $password = '{' . $flavor . '}' . crypt($pw, $salt); + } else { + die("authlib_default_flavor '" . $flavor . "' unknown. Valid flavors are 'md5raw', 'md5' and 'crypt'"); + } + } $password = escape_string ($password); @@ -2296,4 +2296,4 @@ $table_vacation = table_by_key ('vacation'); $table_vacation_notification = table_by_key('vacation_notification'); $table_quota = table_by_key ('quota'); -/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-02-05 13:22:10
|
Revision: 563 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=563&view=rev Author: GingerDog Date: 2009-02-05 12:14:36 +0000 (Thu, 05 Feb 2009) Log Message: ----------- see https://sourceforge.net/tracker/index.php?func=detail&aid=2567397&group_id=191583&atid=937966 - correct link to delete alias Modified Paths: -------------- trunk/templates/list-virtual.php Modified: trunk/templates/list-virtual.php =================================================================== --- trunk/templates/list-virtual.php 2009-02-04 21:05:08 UTC (rev 562) +++ trunk/templates/list-virtual.php 2009-02-05 12:14:36 UTC (rev 563) @@ -197,7 +197,7 @@ $active = ($tAlias[$i]['active'] == 1) ? $PALANG['YES'] : $PALANG['NO']; print " <td><a href=\"edit-active.php?alias=" . urlencode ($tAlias[$i]['address']) . "&domain=$fDomain" . "\">" . $active . "</a></td>\n"; print " <td><a href=\"edit-alias.php?address=" . urlencode ($tAlias[$i]['address']) . "&domain=$fDomain" . "\">" . $PALANG['edit'] . "</a></td>\n"; - print " <td><a href=\"delete.php?table=mailbox&delete=" . urlencode ($tAlias[$i]['address']) . "&domain=$fDomain" . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_aliases'] . ": ". $tAlias[$i]['address'] . "')\">" . $PALANG['del'] . "</a></td>\n"; + print " <td><a href=\"delete.php?table=alias&delete=" . urlencode ($tAlias[$i]['address']) . "&domain=$fDomain" . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_aliases'] . ": ". $tAlias[$i]['address'] . "')\">" . $PALANG['del'] . "</a></td>\n"; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <roe...@us...> - 2009-02-04 21:05:13
|
Revision: 562 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=562&view=rev Author: roehrijn Date: 2009-02-04 21:05:08 +0000 (Wed, 04 Feb 2009) Log Message: ----------- functions.inc.php: - fixed some remarks in pacrypt Modified Paths: -------------- trunk/functions.inc.php Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2009-02-03 21:02:04 UTC (rev 561) +++ trunk/functions.inc.php 2009-02-04 21:05:08 UTC (rev 562) @@ -256,7 +256,7 @@ flash_error("emailcheck_resolve_domain is enabled, but function (checkdnsrr) missing!"); } } - + return true; } @@ -1128,7 +1128,7 @@ } if ($CONF['encrypt'] == 'system') { - if (ereg ("\$1\$", $pw_db)) { + if (ereg ("\$1\$", $pw_db)) { $split_salt = preg_split ('/\$/', $pw_db); $salt = $split_salt[2]; } @@ -1162,23 +1162,25 @@ } if ($CONF['encrypt'] == 'authlib') { - $flavor = $CONF['authlib_default_flavor']; - $salt = ' '; - if(ereg('^{.*}', $pw_db)) { - // we have a flavor in the db -> use it instead of default flavor - $result = split('{|}', $pw_db, 3); - $flavor = $result[1]; - $salt = substr($result[2], 0, 2); - } - - if(stripos($flavor, 'md5raw') === 0) { - $password = '{' . $flavor . '}' . md5($pw); - } else if(stripos($flavor, 'md5') === 0) { - $password = '{' . $flavor . '}' . base64_encode(md5($pw, TRUE)); - } else if(stripos($flavor, 'crypt') === 0) { - $password = '{' . $flavor . '}' . crypt($pw, $salt); - } - } + $flavor = $CONF['authlib_default_flavor']; + $salt = substr(create_salt(), 0, 2); + if(ereg('^{.*}', $pw_db)) { + // we have a flavor in the db -> use it instead of default flavor + $result = split('{|}', $pw_db, 3); + $flavor = $result[1]; + $salt = substr($result[2], 0, 2); + } + + if(stripos($flavor, 'md5raw') === 0) { + $password = '{' . $flavor . '}' . md5($pw); + } else if(stripos($flavor, 'md5') === 0) { + $password = '{' . $flavor . '}' . base64_encode(md5($pw, TRUE)); + } else if(stripos($flavor, 'crypt') === 0) { + $password = '{' . $flavor . '}' . crypt($pw, $salt); + } else { + die("authlib_default_flavor '" . $flavor . "' unknown. Valid flavors are 'md5raw', 'md5' and 'crypt'"); + } + } $password = escape_string ($password); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-02-03 21:02:10
|
Revision: 561 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=561&view=rev Author: christian_boltz Date: 2009-02-03 21:02:04 +0000 (Tue, 03 Feb 2009) Log Message: ----------- CHANGELOG.TXT: - updated with latest changes functions.inc.php - whitespace fixes Modified Paths: -------------- trunk/CHANGELOG.TXT trunk/functions.inc.php Modified: trunk/CHANGELOG.TXT =================================================================== --- trunk/CHANGELOG.TXT 2009-02-03 17:50:13 UTC (rev 560) +++ trunk/CHANGELOG.TXT 2009-02-03 21:02:04 UTC (rev 561) @@ -15,13 +15,14 @@ ----------------- -Version 2.3 - 2009/01/30 - SVN r557 +Version 2.3 - 2009/02/03 - SVN r561 ----------------------------------- - vacation.pl: make it strip/discover addresses better, slightly better logging, stop it requiring a messageid - added ADDITIONS/delete-mailq-by-domain.pl (by Jose Nilton) - added ADDITIONS/quota_usage.pl (by Jose Nilton) - produces report of quota usage - - some small bugfixes + - added support for courier authlib authentication flavors ($CONF['authlib_default_flavor']) + - some small bugfixes and language updates Version 2.3 Beta - 2009/01/15 - SVN r527 Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2009-02-03 17:50:13 UTC (rev 560) +++ trunk/functions.inc.php 2009-02-03 21:02:04 UTC (rev 561) @@ -256,7 +256,7 @@ flash_error("emailcheck_resolve_domain is enabled, but function (checkdnsrr) missing!"); } } - + return true; } @@ -1162,23 +1162,23 @@ } if ($CONF['encrypt'] == 'authlib') { - $flavor = $CONF['authlib_default_flavor']; - $salt = ' '; - if(ereg('^{.*}', $pw_db)) { - // we have a flavor in the db -> use it instead of default flavor - $result = split('{|}', $pw_db, 3); - $flavor = $result[1]; - $salt = substr($result[2], 0, 2); - } - - if(stripos($flavor, 'md5raw') === 0) { - $password = '{' . $flavor . '}' . md5($pw); - } else if(stripos($flavor, 'md5') === 0) { - $password = '{' . $flavor . '}' . base64_encode(md5($pw, TRUE)); - } else if(stripos($flavor, 'crypt') === 0) { - $password = '{' . $flavor . '}' . crypt($pw, $salt); - } - } + $flavor = $CONF['authlib_default_flavor']; + $salt = ' '; + if(ereg('^{.*}', $pw_db)) { + // we have a flavor in the db -> use it instead of default flavor + $result = split('{|}', $pw_db, 3); + $flavor = $result[1]; + $salt = substr($result[2], 0, 2); + } + + if(stripos($flavor, 'md5raw') === 0) { + $password = '{' . $flavor . '}' . md5($pw); + } else if(stripos($flavor, 'md5') === 0) { + $password = '{' . $flavor . '}' . base64_encode(md5($pw, TRUE)); + } else if(stripos($flavor, 'crypt') === 0) { + $password = '{' . $flavor . '}' . crypt($pw, $salt); + } + } $password = escape_string ($password); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <roe...@us...> - 2009-02-03 17:50:21
|
Revision: 560 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=560&view=rev Author: roehrijn Date: 2009-02-03 17:50:13 +0000 (Tue, 03 Feb 2009) Log Message: ----------- config.inc.php: - Added configuration for courier authlib authentication flavors function.inc.php: - changed pa_crypt to make it handle courier authlib authentication flavors Modified Paths: -------------- trunk/config.inc.php trunk/functions.inc.php Modified: trunk/config.inc.php =================================================================== --- trunk/config.inc.php 2009-02-02 22:14:23 UTC (rev 559) +++ trunk/config.inc.php 2009-02-03 17:50:13 UTC (rev 560) @@ -89,8 +89,15 @@ // system = whatever you have set as your PHP system default // cleartext = clear text passwords (ouch!) // mysql_encrypt = useful for PAM integration +// authlib = support for courier-authlib style passwords $CONF['encrypt'] = 'md5crypt'; +// In what flavor should courier-authlib style passwords be enrypted? +// md5 = {md5} + base64 encoded md5 hash +// md5raw = {md5raw} + plain encoded md5 hash +// crypt = {crypt} + Standard UNIX DES-enrypted with 2-character salt +$CONF['authlib_default_flavor'] = 'md5raw'; + // Minimum length required for passwords. Postfixadmin will not // allow users to set passwords which are shorter than this value. $CONF['min_password_length'] = 5; Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2009-02-02 22:14:23 UTC (rev 559) +++ trunk/functions.inc.php 2009-02-03 17:50:13 UTC (rev 560) @@ -256,7 +256,7 @@ flash_error("emailcheck_resolve_domain is enabled, but function (checkdnsrr) missing!"); } } - + return true; } @@ -1160,6 +1160,27 @@ $l = db_row($res["result"]); $password = $l[0]; } + + if ($CONF['encrypt'] == 'authlib') { + $flavor = $CONF['authlib_default_flavor']; + $salt = ' '; + if(ereg('^{.*}', $pw_db)) { + // we have a flavor in the db -> use it instead of default flavor + $result = split('{|}', $pw_db, 3); + $flavor = $result[1]; + $salt = substr($result[2], 0, 2); + } + + if(stripos($flavor, 'md5raw') === 0) { + $password = '{' . $flavor . '}' . md5($pw); + } else if(stripos($flavor, 'md5') === 0) { + $password = '{' . $flavor . '}' . base64_encode(md5($pw, TRUE)); + } else if(stripos($flavor, 'crypt') === 0) { + $password = '{' . $flavor . '}' . crypt($pw, $salt); + } + } + + $password = escape_string ($password); return $password; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-02-02 22:16:20
|
Revision: 559 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=559&view=rev Author: christian_boltz Date: 2009-02-02 22:14:23 +0000 (Mon, 02 Feb 2009) Log Message: ----------- nl.lang: - language update by Johan Hendriks ( sylhouette ) https://sourceforge.net/tracker2/?func=detail&atid=937966&aid=2556927&group_id=191583 it.lang: - fix some typos, patch by Fabio Bonelli ( fabiobon ) https://sourceforge.net/tracker2/?func=detail&atid=937966&aid=2556431&group_id=191583 Modified Paths: -------------- trunk/languages/it.lang trunk/languages/nl.lang Modified: trunk/languages/it.lang =================================================================== --- trunk/languages/it.lang 2009-01-30 22:19:50 UTC (rev 558) +++ trunk/languages/it.lang 2009-02-02 22:14:23 UTC (rev 559) @@ -19,12 +19,12 @@ $PALANG['invalid_parameter'] = 'Parametro non valido!'; $PALANG['pFooter_logged_as'] = 'Collegato come %s'; -$PALANG['pLogin_welcome'] = 'GLi amministratori di posta devono effettuare il login qui per amministrare il proprio dominio.'; +$PALANG['pLogin_welcome'] = 'Gli amministratori di posta devono effettuare il login qui per amministrare il proprio dominio.'; $PALANG['pLogin_username'] = 'Nome utente (email)'; $PALANG['pLogin_password'] = 'Password'; $PALANG['pLogin_button'] = 'Entra'; $PALANG['pLogin_failed'] = 'Your email address or password are not correct.'; # XXX -$PALANG['pLogin_login_users'] = 'GLi utenti devono cliccare qui per entrare nella propria sezione.'; +$PALANG['pLogin_login_users'] = 'Gli utenti devono cliccare qui per entrare nella propria sezione.'; $PALANG['pMenu_main'] = 'Principale'; $PALANG['pMenu_overview'] = 'Resoconto'; @@ -106,7 +106,7 @@ $PALANG['pCreate_alias_welcome'] = 'Crea un nuovo alias per il tuo dominio.'; $PALANG['pCreate_alias_address'] = 'Alias'; $PALANG['pCreate_alias_address_text_error1'] = '<br /><span class="error_msg">L\' Alias non è valido!</span>'; -$PALANG['pCreate_alias_address_text_error2'] = '<br /><span class="error_msg">Questo indirizzo di post esiste già, per favore sceglierne uno diverso!</span>'; +$PALANG['pCreate_alias_address_text_error2'] = '<br /><span class="error_msg">Questo indirizzo di posta esiste già, per favore sceglierne uno diverso!</span>'; $PALANG['pCreate_alias_address_text_error3'] = '<br /><span class="error_msg">Hai raggiunto il tuo limite per creare alias!</span>'; $PALANG['pCreate_alias_goto'] = 'A'; $PALANG['pCreate_alias_active'] = 'Attivo'; @@ -115,7 +115,7 @@ $PALANG['pCreate_alias_goto_text_error'] = 'Dove l\'email deve andare.<br /><span class="error_msg">Il campo A non è valido!</span>'; $PALANG['pCreate_alias_result_error'] = '<span class="error_msg">Non sono riuscito ad aggiungere l\'alias alla tabella degli alias!</span>'; $PALANG['pCreate_alias_result_success'] = 'L\'alias è stato aggiunto alla tabella degli alias!'; -$PALANG['pCreate_alias_catchall_text'] = 'Per creare un account universale, usare "*" come alias.<br />Per inoltri da dominio a dominio, usare "*@domain.tld" come campo \"a\".'; +$PALANG['pCreate_alias_catchall_text'] = 'Per creare un account universale, usare "*" come alias.<br />Per inoltri da dominio a dominio, usare "*@domain.tld" come campo "a".'; $PALANG['pEdit_alias_welcome'] = 'Modifica un alias per il tuo dominio.<br />Un indirizzo per linea.'; $PALANG['pEdit_alias_address'] = 'Alias'; @@ -209,7 +209,7 @@ $PALANG['pSendmail_welcome'] = 'Spedisci una email.'; $PALANG['pSendmail_admin'] = 'Da'; $PALANG['pSendmail_to'] = 'A'; -$PALANG['pSendmail_to_text_error'] = '<span class="error_msg">Il campo \"A\" è vuoto o non è un indirizzo valido!</span>'; +$PALANG['pSendmail_to_text_error'] = '<span class="error_msg">Il campo "A" è vuoto o non è un indirizzo valido!</span>'; $PALANG['pSendmail_subject'] = 'Oggetto'; $PALANG['pSendmail_subject_text'] = 'Benvenuto'; $PALANG['pSendmail_body'] = 'Corpo'; Modified: trunk/languages/nl.lang =================================================================== --- trunk/languages/nl.lang 2009-01-30 22:19:50 UTC (rev 558) +++ trunk/languages/nl.lang 2009-02-02 22:14:23 UTC (rev 559) @@ -23,7 +23,7 @@ $PALANG['pLogin_username'] = 'Login (e-mail)'; $PALANG['pLogin_password'] = 'Wachtwoord'; $PALANG['pLogin_button'] = 'Login'; -$PALANG['pLogin_failed'] = 'Your email address or password are not correct.'; # XXX +$PALANG['pLogin_failed'] = 'Uw login gegevens zijn onjuist.'; $PALANG['pLogin_login_users'] = 'Gebruikers klik hier om in te loggen.'; $PALANG['pMenu_main'] = 'Start'; @@ -339,7 +339,7 @@ $PALANG['pUsersVacation_welcome_text'] = 'U heeft uw automatisch beantwoorden ingesteld.'; $PALANG['pUsersVacation_subject'] = 'Onderwerp'; $PALANG['pUsersVacation_subject_text'] = 'Out of Office'; -$PALANG['pUsersVacation_body'] = 'Bericht'; # XXX text changed to 'Message' +$PALANG['pUsersVacation_body'] = 'Bericht'; $PALANG['pUsersVacation_body_text'] = <<<EOM Ik zal afwezig zijn van <date> tot <date>. Voor belangrijke punten kunt u contact opnemen met <contact person>. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-01-30 22:40:51
|
Revision: 558 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=558&view=rev Author: christian_boltz Date: 2009-01-30 22:19:50 +0000 (Fri, 30 Jan 2009) Log Message: ----------- CHANGELOG.TXT - updated to r557 Modified Paths: -------------- trunk/CHANGELOG.TXT Modified: trunk/CHANGELOG.TXT =================================================================== --- trunk/CHANGELOG.TXT 2009-01-28 21:02:22 UTC (rev 557) +++ trunk/CHANGELOG.TXT 2009-01-30 22:19:50 UTC (rev 558) @@ -12,8 +12,18 @@ Only in SVN trunk --------------------- +----------------- + +Version 2.3 - 2009/01/30 - SVN r557 +----------------------------------- + - vacation.pl: make it strip/discover addresses better, slightly better logging, stop it + requiring a messageid + - added ADDITIONS/delete-mailq-by-domain.pl (by Jose Nilton) + - added ADDITIONS/quota_usage.pl (by Jose Nilton) - produces report of quota usage + - some small bugfixes + + Version 2.3 Beta - 2009/01/15 - SVN r527 ----------------------------------------- @@ -32,14 +42,22 @@ - allow to enter the configuration in /etc/mail/postfixadmin/vacation.conf instead of editing vacation.pl directly - bump version number of vacation.pl + - added domain-postcreation script support + - added dovecot quota support (documentation + viewing in postfixadmin) + - enhanced mailbox table to make it easier for people to customise where mailboxes live + (new column "local_part") + - enhanced fetchmail.pl script (file locking, syslog logging, configuration file etc) - added clear error message for non-resolvable domains when creating mailboxes or aliases - check for non-resolvable domains on domain creation - new option $CONF['create_mailbox_subdirs_prefix'] for compatibility with more IMAP servers + - added support for mysql encrypt() password encrpytion - fix "illegal mix of collations" problem in MySQL by explicitely setting the charset everywhere - fix: cleanup vacation_notification table when disabling vacation - fix: config and fetchmail tables now honor $CONF['database_tables'] + - fix: several table names were hardcoded in database creation/update - fix: "unlimited" and "disabled" for quota and limits were crossed at several places - fix: honor $CONF['default_transport'] even if $CONF['transport'] = "no" (patch by fabiobon) + - fix: transport field is no longer emptied on domain edit if editing transport is disabled - show links to create mailboxes or alias even on disabled domains - added support for fetchmail's "ssl" option - superadmin can now setup fetchmail for all users, not only for himself @@ -51,10 +69,6 @@ - dropped obsolete VIRTUAL_VACATION/mail-filter script - translation updates - several small bugfixes - - Added domain-postcreation script support - - Added dovecot quota support (documentation + viewing in postfixadmin) - - Enhanced mailbox table to make it easier for people to customise where mailboxes live - - Enhanced fetchmail.pl script (file locking, syslog logging, configuration file etc) Version 2.2.1.1 - 2008/07/23 - SVN r412 This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-01-28 21:02:33
|
Revision: 557 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=557&view=rev Author: GingerDog Date: 2009-01-28 21:02:22 +0000 (Wed, 28 Jan 2009) Log Message: ----------- upgrade.php: partial postgres implementation of the amavis stuff Modified Paths: -------------- branches/postfixadmin-amavis/upgrade.php Modified: branches/postfixadmin-amavis/upgrade.php =================================================================== --- branches/postfixadmin-amavis/upgrade.php 2009-01-28 21:01:55 UTC (rev 556) +++ branches/postfixadmin-amavis/upgrade.php 2009-01-28 21:02:22 UTC (rev 557) @@ -3,6 +3,8 @@ require_once('common.php'); } +error_reporting(E_ALL|E_STRICT); + /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ # Note: run with upgrade.php?debug=1 to see all SQL error messages @@ -59,13 +61,13 @@ return false; } -$table = table_by_key('config'); +$table_config = table_by_key('config'); if($CONF['database_type'] == 'pgsql') { // check if table already exists, if so, don't recreate it - $r = db_query("SELECT relname FROM pg_class WHERE relname = '$table'"); + $r = db_query("SELECT relname FROM pg_class WHERE relname = '$table_config'"); if($r['rows'] == 0) { $pgsql = " - CREATE TABLE $table ( + CREATE TABLE $table_config ( id SERIAL, name VARCHAR(20) NOT NULL UNIQUE, value VARCHAR(20) NOT NULL, @@ -76,7 +78,7 @@ } else { $mysql = " - CREATE TABLE {IF_NOT_EXISTS} $table ( + CREATE TABLE {IF_NOT_EXISTS} $table_config ( `id` {AUTOINCREMENT} {PRIMARY}, `name` VARCHAR(20) {LATIN1} NOT NULL DEFAULT '', `value` VARCHAR(20) {LATIN1} NOT NULL DEFAULT '', @@ -86,8 +88,13 @@ db_query_parsed($mysql, 0, " ENGINE = MYISAM COMMENT = 'PostfixAdmin settings'"); } -$sql = "SELECT * FROM $table WHERE name = 'version'"; +// XXX make sure this gets removed!!! +// +// DANGER WILL ROBINSON!! +db_query_parsed("update $table_config set VALUE = 546 WHERE name ='version'"); +$sql = "SELECT * FROM $table_config WHERE name = 'version'"; + // insert into config('version', '01'); $r = db_query($sql); @@ -1299,5 +1306,242 @@ function upgrade_547_pgsql() { // amavis tables + $table_awl = table_by_key('awl'); + $table_bayes_expire = table_by_key('bayes_expire'); + $table_bayes_global_vars = table_by_key('bayes_global_vars'); + $table_bayes_seen = table_by_key('bayes_seen'); + $table_bayes_token = table_by_key('bayes_token'); + $table_bayes_vars = table_by_key('bayes_vars'); + + if(!_pgsql_object_exists($table_awl)) { + db_query_parsed("CREATE TABLE $table_awl ( + username varchar(100) NOT NULL , + email varchar(200) NOT NULL, + ip varchar(10) NOT NULL , + count int(11) default '0', + totscore float default '0', + lastupdate timestamp NOT NULL default now(), + PRIMARY KEY (username,email,ip) ) "); + /* Note: we need to use triggers etc if we want lastupdate to get modified FOR US automatically; I can't be bothered to do this. */ + } + if(!_pgsql_object_exists($table_bayes_expire)) { + /* in mysql there seems to be no primary key on this table... why? */ + db_query_parsed( + "CREATE TABLE $table_bayes_expire ( + id int not null primary key, + runtime int(11) NOT NULL)"); + } + + if(!_pgsql_object_exists($table_bayes_global_vars)) { + db_query_parsed( + "CREATE TABLE $table_bayes_global_vars ( + variable varchar(30) NOT NULL primary key, + value varchar(200) NOT NULL default '')"); + } + + if(!_pgsql_object_exists($table_bayes_seen)) { + db_query_parsed("CREATE TABLE $table_bayes_seen ( + id int(11) NOT NULL default '0', + msgid varchar(200) NOT NULL default '', + flag char(1) NOT NULL default '', + PRIMARY KEY (id,msgid))"); + } + + if(!_pgsql_object_exists($table_bayes_token)) { + db_query_parsed(" + CREATE TABLE $table_bayes_token ( + id int(11) NOT NULL , + token char(5) NOT NULL default '', + spam_count int(11) NOT NULL default '0', + ham_count int(11) NOT NULL default '0', + atime int(11) NOT NULL default '0', + PRIMARY KEY (id,token))"); + db_query_parsed("CREATE INDEX bayes_token_idx1 ON $table_bayes_token (token)"); + db_query_parsed("CREATE INDEX bayes_token_idx2 ON $table_bayes_token (id, atime)"); + } + if(!_pgsql_object_exists($table_bayes_vars)) { + db_query_parsed(" + CREATE TABLE $table_bayes_vars ( + id serial, + username varchar(200) NOT NULL, + spam_count int(11) NOT NULL, + ham_count int(11) NOT NULL, + token_count int(11) NOT NULL, + last_expire int(11) NOT NULL, + last_atime_delta int(11) NOT NULL, + last_expire_reduce int(11) NOT NULL, + oldest_token_age int(11) NOT NULL default '2147483647', + newest_token_age int(11) NOT NULL default '0')"); + db_query_parsed("CREATE INDEX bayes_vars_idx1 ON $table_bayes_vars (username)"); + } + + $table_maddr = table_by_key('maddr'); + if(!_pgsql_object_exists($table_maddr)) { + db_query_parsed(" + CREATE TABLE $table_maddr ( + id serial, + email varchar(255) NOT NULL, + domain varchar(255) NOT NULL, + PRIMARY KEY (id)) "); + db_query_parsed("CREATE UNIQUE INDEX maddr_email ON $table_maddr (email)"); + } + + $table_mailaddr = table_by_key('mailaddr'); + + if(!_pgsql_object_exists($table_mailaddr)) { + db_query_parsed(" + CREATE TABLE $table_mailaddr ( + id serial, + priority int(11) NOT NULL default 7, + email varchar(255) NOT NULL, + PRIMARY KEY (id))"); + db_query_parsed("CREATE UNIQUE INDEX mailaddr_email ON $table_mailaddr (email)"); + } + + $table_msgrcpt = table_by_key('msgrcpt'); + if(!_pgsql_object_exists($table_msgrcpt)) { + db_query_parsed(" + CREATE TABLE $table_msgrcpt ( + mail_id varchar(12) NOT NULL, + rid int(11) NOT NULL, + ds char(1) NOT NULL, + rs char(1) NOT NULL, + bl char(1) default '', + wl char(1) default '', + bspam_level float default NULL, + smtp_resp varchar(255) default '')"); + db_query_parsed("CREATE INDEX msgrcpt_idx_mail_id on $table_msgrcpt (mail_id)"); + db_query_parsed("CREATE INDEX msgrcpt_idx_rid on $table_msgrcpt (rid)"); + } + + + $table_msgs = table_by_key('msgs'); + if(!_pgsql_object_exists($table_msgs)) { + db_query_parsed("CREATE TABLE $table_msgs ( + mail_id varchar(12) NOT NULL primary key, + secret_id varchar(12) default '', + am_id varchar(20) NOT NULL, + time_num int(11) NOT NULL, + time_iso timestamp NOT NULL, + sid int(11) NOT NULL, + policy varchar(255) default '', + client_addr varchar(255) default '', + size int(11) NOT NULL, + content char(1) default NULL, + quar_type char(1) default NULL, + quar_loc varchar(255) default '', + dsn_sent char(1) default NULL, + spam_level float default NULL, + message_id varchar(255) default '', + from_addr varchar(255) default '', + subject varchar(255) default '', + host varchar(255) NOT NULL)"); + db_query_parsed("CREATE INDEX msgs_idx_sid on $table_msgs (sid)"); + db_query_parsed("CREATE INDEX msgs_idx_time_iso on $table_msgs (time_iso)"); + } + /* + + $table_policy = table_by_key('policy'); + db_query_parsed("CREATE TABLE IF NOT EXISTS $table_policy ( + `id` int(10) unsigned NOT NULL auto_increment, + `policy_name` varchar(32) default NULL, + `virus_lover` char(1) default NULL, + `spam_lover` char(1) default NULL, + `banned_files_lover` char(1) default NULL, + `bad_header_lover` char(1) default NULL, + `bypass_virus_checks` char(1) default NULL, + `bypass_spam_checks` char(1) default NULL, + `bypass_banned_checks` char(1) default NULL, + `bypass_header_checks` char(1) default NULL, + `spam_modifies_subj` char(1) default NULL, + `virus_quarantine_to` varchar(64) default NULL, + `spam_quarantine_to` varchar(64) default NULL, + `banned_quarantine_to` varchar(64) default NULL, + `bad_header_quarantine_to` varchar(64) default NULL, + `spam_tag_level` float default NULL, + `spam_tag2_level` float default NULL, + `spam_kill_level` float default NULL, + `spam_dsn_cutoff_level` float default NULL, + `spam_quarantine_cutoff_level` float(10,2) default NULL, + `addr_extension_virus` varchar(64) default NULL, + `addr_extension_spam` varchar(64) default NULL, + `addr_extension_banned` varchar(64) default NULL, + `addr_extension_bad_header` varchar(64) default NULL, + `warnvirusrecip` char(1) default NULL, + `warnbannedrecip` char(1) default NULL, + `warnbadhrecip` char(1) default NULL, + `newvirus_admin` varchar(64) default NULL, + `virus_admin` varchar(64) default NULL, + `banned_admin` varchar(64) default NULL, + `bad_header_admin` varchar(64) default NULL, + `spam_admin` varchar(64) default NULL, + `spam_subject_tag` varchar(64) default NULL, + `spam_subject_tag2` varchar(64) default NULL, + `message_size_limit` int(11) default NULL, + `banned_rulenames` varchar(64) default NULL, + PRIMARY KEY (`id`) + ) ENGINE=MyISAM DEFAULT CHARSET=latin1 "); + + db_query_parsed("DELETE FROM $table_policy WHERE policy_name IN ('All Off', 'Normal', 'Virus Filtering Only', 'Spam Filtering Only', 'Low', 'High')"); + + $insert_fields = "INSERT INTO $table_policy (policy_name, virus_lover, spam_lover, banned_files_lover, bad_header_lover, bypass_virus_checks, bypass_spam_checks, bypass_banned_checks, bypass_header_checks, spam_modifies_subj, virus_quarantine_to, spam_quarantine_to, banned_quarantine_to, bad_header_quarantine_to, spam_tag_level, spam_tag2_level, spam_kill_level, spam_dsn_cutoff_level, spam_quarantine_cutoff_level, addr_extension_virus, addr_extension_spam, addr_extension_banned, addr_extension_bad_header, warnvirusrecip, warnbannedrecip, warnbadhrecip, newvirus_admin, virus_admin, banned_admin, bad_header_admin, spam_admin, spam_subject_tag, spam_subject_tag2, message_size_limit, banned_rulenames)"; + db_query_parsed("$insert_fields VALUES ('All Off', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'N', 'N', 'N', NULL, NULL, NULL, NULL, -999, 999, 999, 999, 0.00, NULL, NULL, NULL, NULL, 'N', 'N', 'N', NULL, NULL, NULL, NULL, NULL, NULL, '[SPAM]', 0, NULL)"); + + db_query_parsed("$insert_fields VALUES ('Normal', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, -999, 2.5, 4.7, 10, 20.00, NULL, NULL, NULL, NULL, 'Y', 'Y', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, '[SPAM]', 0, NULL)"); + + db_query_parsed("$insert_fields VALUES ('Virus Filtering Only', 'N', 'Y', 'Y', 'Y', 'N', 'Y', 'Y', 'Y', 'N', NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0.00, NULL, NULL, NULL, NULL, 'Y', 'N', 'N', NULL, NULL, NULL, NULL, NULL, NULL, '[SPAM]', 0, NULL)"); + + db_query_parsed("$insert_fields VALUES ('Spam Filtering Only', 'Y', 'N', 'Y', 'Y', 'Y', 'N', 'Y', 'Y', 'Y', NULL, NULL, NULL, NULL, -999, 2.5, 5, 10, 20.00, NULL, NULL, NULL, NULL, 'N', 'Y', 'Y', NULL, NULL, NULL, NULL, NULL, NULL,'[SPAM]', 0, NULL)"); + + db_query_parsed("$insert_fields VALUES ('Low', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, -999, 4.5, 7, 10, 20.00, NULL, NULL, NULL, NULL, 'Y', 'Y', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, '[SPAM]', 0, NULL)"); + + db_query_parsed("$insert_fields VALUES ('High', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, -999, 2.5, 3, 10, 20.00, NULL, NULL, NULL, NULL, 'Y', 'Y', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, '[SPAM]', 0, NULL)"); + + + $table_quarantine = table_by_key('quarantine'); + db_query_parsed("CREATE TABLE IF NOT EXISTS $table_quarantine ( + `mail_id` varchar(12) NOT NULL, + `chunk_ind` int(10) unsigned NOT NULL, + `mail_text` blob, + PRIMARY KEY (`mail_id`,`chunk_ind`) + ) ENGINE=InnoDB DEFAULT CHARSET=latin1"); + + $table_sa_rules = table_by_key('sa_rules'); + db_query_parsed("CREATE TABLE IF NOT EXISTS $table_sa_rules ( + `rule` varchar(100) NOT NULL default '', + `rule_desc` varchar(200) NOT NULL default '', + PRIMARY KEY (`rule`) + ) ENGINE=MyISAM DEFAULT CHARSET=latin1"); + + + $table_users = table_by_key('users'); + db_query_parsed("CREATE TABLE IF NOT EXISTS $table_users ( + `id` int(10) unsigned NOT NULL auto_increment, + `priority` int(11) NOT NULL default '7', + `policy_id` int(10) unsigned NOT NULL default '1', + `email` varchar(255) NOT NULL, + `fullname` varchar(255) default NULL, + `local` char(1) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `email` (`email`) + ) ENGINE=MyISAM DEFAULT CHARSET=latin1 "); + + + $table_wblist = table_by_key('wblist'); + db_query_parsed("CREATE TABLE IF NOT EXISTS $table_wblist ( + `rid` int(10) unsigned NOT NULL, + `sid` int(10) unsigned NOT NULL, + `wb` varchar(10) NOT NULL, + PRIMARY KEY (`rid`,`sid`) + ) ENGINE=MyISAM DEFAULT CHARSET=latin1"); + + db_query_parsed("ALTER TABLE $table_msgrcpt ADD CONSTRAINT `msgrcpt_maddr_fk1` FOREIGN KEY (`rid`) REFERENCES $table_maddr (`id`), + ADD CONSTRAINT `msgrcpt_msgs_fk1` FOREIGN KEY (`mail_id`) REFERENCES $table_msgs (`mail_id`) ON DELETE CASCADE"); + + db_query_parsed("ALTER TABLE $table_msgs ADD CONSTRAINT `msgs_ibfk_fk1` FOREIGN KEY (`sid`) REFERENCES $table_maddr (`id`)"); + + db_query_parsed("ALTER TABLE $table_quarantine ADD CONSTRAINT `quarantine_msgs_fk1` FOREIGN KEY (`mail_id`) REFERENCES $table_msgs (`mail_id`) ON DELETE CASCADE"); + + */ } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-01-28 21:01:59
|
Revision: 556 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=556&view=rev Author: GingerDog Date: 2009-01-28 21:01:55 +0000 (Wed, 28 Jan 2009) Log Message: ----------- functions.inc.php: make it more forgiving if we have not defined the table name in config.inc.php Modified Paths: -------------- branches/postfixadmin-amavis/functions.inc.php Modified: branches/postfixadmin-amavis/functions.inc.php =================================================================== --- branches/postfixadmin-amavis/functions.inc.php 2009-01-28 20:15:42 UTC (rev 555) +++ branches/postfixadmin-amavis/functions.inc.php 2009-01-28 21:01:55 UTC (rev 556) @@ -1700,9 +1700,12 @@ function table_by_key ($table_key) { global $CONF; - $table = $CONF['database_prefix'].$CONF['database_tables'][$table_key]; - if (empty($table)) $table = $table_key; - return $table; + if(isset($CONF['database_tables'][$table_key])) { + return $CONF['database_prefix'].$CONF['database_tables'][$table_key]; + } + else { + return $table_key; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-01-28 20:15:46
|
Revision: 555 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=555&view=rev Author: GingerDog Date: 2009-01-28 20:15:42 +0000 (Wed, 28 Jan 2009) Log Message: ----------- add amavis table structures into postfixadmins db Modified Paths: -------------- branches/postfixadmin-amavis/upgrade.php Modified: branches/postfixadmin-amavis/upgrade.php =================================================================== --- branches/postfixadmin-amavis/upgrade.php 2009-01-25 21:56:37 UTC (rev 554) +++ branches/postfixadmin-amavis/upgrade.php 2009-01-28 20:15:42 UTC (rev 555) @@ -1063,3 +1063,241 @@ db_query_parsed("ALTER TABLE `$table_mailbox` CHANGE `local_part` `local_part` VARCHAR( 255 ) {LATIN1} NOT NULL"); } +function upgrade_547_mysql() { + // amavis tables + $table_awl = table_by_key('awl'); + $table_bayes_expire = table_by_key('bayes_expire'); + $table_bayes_global_vars = table_by_key('bayes_global_vars'); + $table_bayes_seen = table_by_key('bayes_seen'); + $table_bayes_token = table_by_key('bayes_token'); + $table_bayes_vars = table_by_key('bayes_vars'); + + db_query_parsed("CREATE TABLE IF NOT EXISTS $table_awl ( + `username` varchar(100) NOT NULL default '', + `email` varchar(200) NOT NULL default '', + `ip` varchar(10) NOT NULL default '', + `count` int(11) default '0', + `totscore` float default '0', + `lastupdate` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + PRIMARY KEY (`username`,`email`,`ip`) + ) ENGINE=MyISAM DEFAULT CHARSET=latin1;"); + + db_query_parsed( + "CREATE TABLE IF NOT EXISTS $table_bayes_expire ( + `id` int(11) NOT NULL default '0', + `runtime` int(11) NOT NULL default '0', + KEY `bayes_expire_idx1` (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET=latin1;"); + + db_query_parsed( + "CREATE TABLE IF NOT EXISTS $table_bayes_global_vars ( + `variable` varchar(30) NOT NULL default '', + `value` varchar(200) NOT NULL default '', + PRIMARY KEY (`variable`) + ) ENGINE=InnoDB DEFAULT CHARSET=latin1;"); + + db_query_parsed( + "CREATE TABLE IF NOT EXISTS $table_bayes_seen ( + `id` int(11) NOT NULL default '0', + `msgid` varchar(200) character set latin1 collate latin1_bin NOT NULL default '', + `flag` char(1) NOT NULL default '', + PRIMARY KEY (`id`,`msgid`) + ) ENGINE=InnoDB DEFAULT CHARSET=latin1;"); + + db_query_parsed(" + CREATE TABLE IF NOT EXISTS $table_bayes_token ( + `id` int(11) NOT NULL default '0', + `token` char(5) NOT NULL default '', + `spam_count` int(11) NOT NULL default '0', + `ham_count` int(11) NOT NULL default '0', + `atime` int(11) NOT NULL default '0', + PRIMARY KEY (`id`,`token`), + KEY `bayes_token_idx1` (`token`), + KEY `bayes_token_idx2` (`id`,`atime`) + ) ENGINE=InnoDB DEFAULT CHARSET=latin1;"); + + db_query_parsed(" + CREATE TABLE IF NOT EXISTS $table_bayes_vars ( + `id` int(11) NOT NULL auto_increment, + `username` varchar(200) NOT NULL default '', + `spam_count` int(11) NOT NULL default '0', + `ham_count` int(11) NOT NULL default '0', + `token_count` int(11) NOT NULL default '0', + `last_expire` int(11) NOT NULL default '0', + `last_atime_delta` int(11) NOT NULL default '0', + `last_expire_reduce` int(11) NOT NULL default '0', + `oldest_token_age` int(11) NOT NULL default '2147483647', + `newest_token_age` int(11) NOT NULL default '0', + PRIMARY KEY (`id`), + UNIQUE KEY `bayes_vars_idx1` (`username`) + ) ENGINE=InnoDB DEFAULT CHARSET=latin1 "); + + $table_maddr = table_by_key('maddr'); + db_query_parsed(" + CREATE TABLE IF NOT EXISTS $table_maddr ( + `id` int(10) unsigned NOT NULL auto_increment, + `email` varchar(255) NOT NULL, + `domain` varchar(255) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `email` (`email`) + ) ENGINE=InnoDB DEFAULT CHARSET=latin1 "); + + $table_mailaddr = table_by_key('mailaddr'); + + db_query_parsed(" + CREATE TABLE IF NOT EXISTS $table_mailaddr ( + `id` int(10) unsigned NOT NULL auto_increment, + `priority` int(11) NOT NULL default '7', + `email` varchar(255) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `email` (`email`) + ) ENGINE=MyISAM DEFAULT CHARSET=latin1 "); + + $table_msgrcpt = table_by_key('msgrcpt'); + db_query_parsed(" + CREATE TABLE IF NOT EXISTS $table_msgrcpt ( + `mail_id` varchar(12) NOT NULL, + `rid` int(10) unsigned NOT NULL, + `ds` char(1) NOT NULL, + `rs` char(1) NOT NULL, + `bl` char(1) default '', + `wl` char(1) default '', + `bspam_level` float default NULL, + `smtp_resp` varchar(255) default '', + KEY `msgrcpt_idx_mail_id` (`mail_id`), + KEY `msgrcpt_idx_rid` (`rid`) + ) ENGINE=InnoDB DEFAULT CHARSET=latin1"); + + $table_msgs = table_by_key('msgs'); + db_query_parsed("CREATE TABLE IF NOT EXISTS $table_msgs ( + `mail_id` varchar(12) NOT NULL, + `secret_id` varchar(12) default '', + `am_id` varchar(20) NOT NULL, + `time_num` int(10) unsigned NOT NULL, + `time_iso` timestamp NOT NULL default '0000-00-00 00:00:00', + `sid` int(10) unsigned NOT NULL, + `policy` varchar(255) default '', + `client_addr` varchar(255) default '', + `size` int(10) unsigned NOT NULL, + `content` char(1) default NULL, + `quar_type` char(1) default NULL, + `quar_loc` varchar(255) default '', + `dsn_sent` char(1) default NULL, + `spam_level` float default NULL, + `message_id` varchar(255) default '', + `from_addr` varchar(255) default '', + `subject` varchar(255) default '', + `host` varchar(255) NOT NULL, + PRIMARY KEY (`mail_id`), + KEY `msgs_idx_sid` (`sid`), + KEY `msgs_idx_time_iso` (`time_iso`) + ) ENGINE=InnoDB DEFAULT CHARSET=latin1"); + + + $table_policy = table_by_key('policy'); + db_query_parsed("CREATE TABLE IF NOT EXISTS $table_policy ( + `id` int(10) unsigned NOT NULL auto_increment, + `policy_name` varchar(32) default NULL, + `virus_lover` char(1) default NULL, + `spam_lover` char(1) default NULL, + `banned_files_lover` char(1) default NULL, + `bad_header_lover` char(1) default NULL, + `bypass_virus_checks` char(1) default NULL, + `bypass_spam_checks` char(1) default NULL, + `bypass_banned_checks` char(1) default NULL, + `bypass_header_checks` char(1) default NULL, + `spam_modifies_subj` char(1) default NULL, + `virus_quarantine_to` varchar(64) default NULL, + `spam_quarantine_to` varchar(64) default NULL, + `banned_quarantine_to` varchar(64) default NULL, + `bad_header_quarantine_to` varchar(64) default NULL, + `spam_tag_level` float default NULL, + `spam_tag2_level` float default NULL, + `spam_kill_level` float default NULL, + `spam_dsn_cutoff_level` float default NULL, + `spam_quarantine_cutoff_level` float(10,2) default NULL, + `addr_extension_virus` varchar(64) default NULL, + `addr_extension_spam` varchar(64) default NULL, + `addr_extension_banned` varchar(64) default NULL, + `addr_extension_bad_header` varchar(64) default NULL, + `warnvirusrecip` char(1) default NULL, + `warnbannedrecip` char(1) default NULL, + `warnbadhrecip` char(1) default NULL, + `newvirus_admin` varchar(64) default NULL, + `virus_admin` varchar(64) default NULL, + `banned_admin` varchar(64) default NULL, + `bad_header_admin` varchar(64) default NULL, + `spam_admin` varchar(64) default NULL, + `spam_subject_tag` varchar(64) default NULL, + `spam_subject_tag2` varchar(64) default NULL, + `message_size_limit` int(11) default NULL, + `banned_rulenames` varchar(64) default NULL, + PRIMARY KEY (`id`) + ) ENGINE=MyISAM DEFAULT CHARSET=latin1 "); + + db_query_parsed("DELETE FROM $table_policy WHERE policy_name IN ('All Off', 'Normal', 'Virus Filtering Only', 'Spam Filtering Only', 'Low', 'High')"); + + $insert_fields = "INSERT INTO $table_policy (policy_name, virus_lover, spam_lover, banned_files_lover, bad_header_lover, bypass_virus_checks, bypass_spam_checks, bypass_banned_checks, bypass_header_checks, spam_modifies_subj, virus_quarantine_to, spam_quarantine_to, banned_quarantine_to, bad_header_quarantine_to, spam_tag_level, spam_tag2_level, spam_kill_level, spam_dsn_cutoff_level, spam_quarantine_cutoff_level, addr_extension_virus, addr_extension_spam, addr_extension_banned, addr_extension_bad_header, warnvirusrecip, warnbannedrecip, warnbadhrecip, newvirus_admin, virus_admin, banned_admin, bad_header_admin, spam_admin, spam_subject_tag, spam_subject_tag2, message_size_limit, banned_rulenames)"; + db_query_parsed("$insert_fields VALUES ('All Off', 'Y', 'Y', 'Y', 'Y', 'N', 'N', 'N', 'N', 'N', NULL, NULL, NULL, NULL, -999, 999, 999, 999, 0.00, NULL, NULL, NULL, NULL, 'N', 'N', 'N', NULL, NULL, NULL, NULL, NULL, NULL, '[SPAM]', 0, NULL)"); + + db_query_parsed("$insert_fields VALUES ('Normal', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, -999, 2.5, 4.7, 10, 20.00, NULL, NULL, NULL, NULL, 'Y', 'Y', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, '[SPAM]', 0, NULL)"); + + db_query_parsed("$insert_fields VALUES ('Virus Filtering Only', 'N', 'Y', 'Y', 'Y', 'N', 'Y', 'Y', 'Y', 'N', NULL, NULL, NULL, NULL, 0, 0, 0, 0, 0.00, NULL, NULL, NULL, NULL, 'Y', 'N', 'N', NULL, NULL, NULL, NULL, NULL, NULL, '[SPAM]', 0, NULL)"); + + db_query_parsed("$insert_fields VALUES ('Spam Filtering Only', 'Y', 'N', 'Y', 'Y', 'Y', 'N', 'Y', 'Y', 'Y', NULL, NULL, NULL, NULL, -999, 2.5, 5, 10, 20.00, NULL, NULL, NULL, NULL, 'N', 'Y', 'Y', NULL, NULL, NULL, NULL, NULL, NULL,'[SPAM]', 0, NULL)"); + + db_query_parsed("$insert_fields VALUES ('Low', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, -999, 4.5, 7, 10, 20.00, NULL, NULL, NULL, NULL, 'Y', 'Y', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, '[SPAM]', 0, NULL)"); + + db_query_parsed("$insert_fields VALUES ('High', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'N', 'Y', NULL, NULL, NULL, NULL, -999, 2.5, 3, 10, 20.00, NULL, NULL, NULL, NULL, 'Y', 'Y', 'Y', NULL, NULL, NULL, NULL, NULL, NULL, '[SPAM]', 0, NULL)"); + + + $table_quarantine = table_by_key('quarantine'); + db_query_parsed("CREATE TABLE IF NOT EXISTS $table_quarantine ( + `mail_id` varchar(12) NOT NULL, + `chunk_ind` int(10) unsigned NOT NULL, + `mail_text` blob, + PRIMARY KEY (`mail_id`,`chunk_ind`) + ) ENGINE=InnoDB DEFAULT CHARSET=latin1"); + + $table_sa_rules = table_by_key('sa_rules'); + db_query_parsed("CREATE TABLE IF NOT EXISTS $table_sa_rules ( + `rule` varchar(100) NOT NULL default '', + `rule_desc` varchar(200) NOT NULL default '', + PRIMARY KEY (`rule`) + ) ENGINE=MyISAM DEFAULT CHARSET=latin1"); + + + $table_users = table_by_key('users'); + db_query_parsed("CREATE TABLE IF NOT EXISTS $table_users ( + `id` int(10) unsigned NOT NULL auto_increment, + `priority` int(11) NOT NULL default '7', + `policy_id` int(10) unsigned NOT NULL default '1', + `email` varchar(255) NOT NULL, + `fullname` varchar(255) default NULL, + `local` char(1) default NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `email` (`email`) + ) ENGINE=MyISAM DEFAULT CHARSET=latin1 "); + + + $table_wblist = table_by_key('wblist'); + db_query_parsed("CREATE TABLE IF NOT EXISTS $table_wblist ( + `rid` int(10) unsigned NOT NULL, + `sid` int(10) unsigned NOT NULL, + `wb` varchar(10) NOT NULL, + PRIMARY KEY (`rid`,`sid`) + ) ENGINE=MyISAM DEFAULT CHARSET=latin1"); + + db_query_parsed("ALTER TABLE $table_msgrcpt ADD CONSTRAINT `msgrcpt_maddr_fk1` FOREIGN KEY (`rid`) REFERENCES $table_maddr (`id`), + ADD CONSTRAINT `msgrcpt_msgs_fk1` FOREIGN KEY (`mail_id`) REFERENCES $table_msgs (`mail_id`) ON DELETE CASCADE"); + + db_query_parsed("ALTER TABLE $table_msgs ADD CONSTRAINT `msgs_ibfk_fk1` FOREIGN KEY (`sid`) REFERENCES $table_maddr (`id`)"); + + db_query_parsed("ALTER TABLE $table_quarantine ADD CONSTRAINT `quarantine_msgs_fk1` FOREIGN KEY (`mail_id`) REFERENCES $table_msgs (`mail_id`) ON DELETE CASCADE"); + } + + +function upgrade_547_pgsql() { + // amavis tables +} + This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |