You've already forked postfixadmin
mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2025-07-31 10:04:20 +03:00
Reformat everything with PHP-Cs-Fixer
This commit is contained in:
@ -13,5 +13,5 @@ before_script:
|
||||
- composer install
|
||||
|
||||
script:
|
||||
- composer check
|
||||
- composer check-format
|
||||
|
||||
|
@ -9,29 +9,24 @@ if(!class_exists('Zend_Version', false)) {
|
||||
chdir("..");
|
||||
|
||||
|
||||
if (!defined('SM_PATH'))
|
||||
{
|
||||
if (!defined('SM_PATH')) {
|
||||
define('SM_PATH', '../');
|
||||
}
|
||||
include_once(dirname(__FILE__) . '/config.php');
|
||||
include_once(dirname(__FILE__) . '/functions.inc.php');
|
||||
include_if_exists(dirname(__FILE__) . '/../include/validate.php');
|
||||
if (file_exists(dirname(__FILE__) . '/../include/validate.php'))
|
||||
{
|
||||
if (file_exists(dirname(__FILE__) . '/../include/validate.php')) {
|
||||
include_once(dirname(__FILE__) . '/include/validate.php');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
include_if_exists(SM_PATH . 'src/validate.php');
|
||||
}
|
||||
include_once(SM_PATH . 'functions/page_header.php');
|
||||
include_once(SM_PATH . 'functions/display_messages.php');
|
||||
include_once(SM_PATH . 'functions/imap.php');
|
||||
include_if_exists(SM_PATH . 'functions/array.php');
|
||||
if (file_exists(SM_PATH . 'src/load_prefs.php'))
|
||||
{
|
||||
if (file_exists(SM_PATH . 'src/load_prefs.php')) {
|
||||
include_once(SM_PATH . 'src/load_prefs.php');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
include_if_exists(SM_PATH . 'include/load_prefs.php');
|
||||
}
|
||||
// overwrite squirrelmail's content type to utf8...
|
||||
@ -41,4 +36,3 @@ header("Content-Type: text/html; charset=utf8");
|
||||
//global $VACCONFMESSAGE;
|
||||
bindtextdomain('postfixadmin', dirname(__FILE__) . '/postfixadmin/locale');
|
||||
textdomain('postfixadmin');
|
||||
|
||||
|
@ -44,12 +44,10 @@ function get_xmlrpc() {
|
||||
if (empty($_POST['password'])) {
|
||||
_display_password_form();
|
||||
exit(0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
try {
|
||||
$success = $login_object->login($_SESSION['username'], $_POST['password']);
|
||||
}
|
||||
catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
//var_dump($client->getHttpClient()->getLastResponse()->getBody());
|
||||
error_log("Failed to login to xmlrpc instance - " . $e->getMessage());
|
||||
die('Failed to login to xmlrpc instance');
|
||||
@ -59,14 +57,12 @@ function get_xmlrpc() {
|
||||
// reload the current page as a GET request.
|
||||
header("Location: {$_SERVER['REQUEST_URI']}");
|
||||
exit(0);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
_display_password_form();
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$success = $login_object->login($_SESSION['username'], $_SESSION['password']);
|
||||
}
|
||||
|
||||
@ -98,5 +94,3 @@ function check_email($email) {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,5 +23,3 @@
|
||||
****************************************************************************************/
|
||||
|
||||
header("Location: ../../index.php");
|
||||
|
||||
?>
|
@ -20,8 +20,7 @@ $pPassword_password_current_text = '';
|
||||
$pPassword_password_text = '';
|
||||
$error = 0;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
//$pPassword_password_text = _("pPassword_password_text");
|
||||
$fPassword_current = $_POST['fPassword_current'];
|
||||
$fPassword = $_POST['fPassword'];
|
||||
@ -67,8 +66,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
$stMessage = _("Please sign out and log back again with your new password!");
|
||||
bindtextdomain('squirrelmail', SM_PATH . 'locale');
|
||||
textdomain('squirrelmail');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
|
||||
textdomain('postfixadmin');
|
||||
$tMessage = _("Unable to change your password!");
|
||||
@ -125,4 +123,3 @@ echo "<table bgcolor=\"$color[0]\" align=\"center\" width=\"95%\" cellpadding=\"
|
||||
</tr></table></td></tr></table>";
|
||||
bindtextdomain('squirrelmail', SM_PATH . 'locale');
|
||||
textdomain('squirrelmail');
|
||||
?>
|
||||
|
@ -13,8 +13,7 @@ $xmlrpc = get_xmlrpc();
|
||||
$alias = $xmlrpc->getProxy('alias');
|
||||
do_header();
|
||||
// Normal page request (GET)
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET")
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$row = $alias->get();
|
||||
if ($row === false) {
|
||||
bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
|
||||
@ -26,8 +25,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET")
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$pEdit_alias_goto = _("To");
|
||||
|
||||
$fGoto = $_POST['fGoto'];
|
||||
@ -40,15 +38,12 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
$error = 0;
|
||||
// check that we have valid addresses in the list
|
||||
|
||||
foreach($array as $key => $email_address)
|
||||
{
|
||||
if (empty($email_address))
|
||||
{
|
||||
foreach ($array as $key => $email_address) {
|
||||
if (empty($email_address)) {
|
||||
unset($array[$key]);
|
||||
continue;
|
||||
}
|
||||
if (!check_email($email_address))
|
||||
{
|
||||
if (!check_email($email_address)) {
|
||||
$error = 1;
|
||||
$tGoto = $goto;
|
||||
bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
|
||||
@ -67,9 +62,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
$tMessage = _("Unable to modify the alias!");
|
||||
bindtextdomain('squirrelmail', SM_PATH . 'locale');
|
||||
textdomain('squirrelmail');
|
||||
}
|
||||
else {
|
||||
|
||||
} else {
|
||||
bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
|
||||
textdomain('postfixadmin');
|
||||
echo "<p align=center><b>". _("Alias successfully changed!"). "\n</b></p>";
|
||||
@ -130,7 +123,9 @@ bindtextdomain('squirrelmail', SM_PATH . 'locale');
|
||||
textdomain('squirrelmail');
|
||||
$aliases = $alias->get();
|
||||
foreach ($aliases as $address) {
|
||||
if ($address == "" || $address == NULL) { continue; }
|
||||
if ($address == "" || $address == null) {
|
||||
continue;
|
||||
}
|
||||
print "$address\n";
|
||||
}
|
||||
bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
|
||||
@ -162,4 +157,3 @@ echo "
|
||||
";
|
||||
bindtextdomain('squirrelmail', SM_PATH . 'locale');
|
||||
textdomain('squirrelmail');
|
||||
?>
|
||||
|
@ -18,11 +18,9 @@ $USERID_USERNAME = $username;
|
||||
$tmp = preg_split('/@/', $USERID_USERNAME);
|
||||
$USERID_DOMAIN = $tmp[1];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET")
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
$details = $vacation->getDetails();
|
||||
if ($vacation->checkVacation()) {
|
||||
|
||||
bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
|
||||
textdomain('postfixadmin');
|
||||
$tMessage = _("You already have an auto response configured!");
|
||||
@ -54,9 +52,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET")
|
||||
</tr></table><BR></td></tr></table></td></tr></table>";
|
||||
bindtextdomain('squirrelmail', SM_PATH . 'locale');
|
||||
textdomain('squirrelmail');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$tSubject = "Out of Office";
|
||||
$tSubject = $details['subject'];
|
||||
$VACCONF = $details['body'];
|
||||
@ -94,8 +90,7 @@ if ($_SERVER['REQUEST_METHOD'] == "GET")
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
$fBack = null;
|
||||
$fAway = null;
|
||||
foreach (array('fBack', 'fAway', 'fSubject', 'fBody') as $key) {
|
||||
@ -105,32 +100,26 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($fBack))
|
||||
{
|
||||
if (!empty($fBack)) {
|
||||
$success = $vacation->remove();
|
||||
|
||||
if(!$success)
|
||||
{
|
||||
if (!$success) {
|
||||
bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
|
||||
textdomain('postfixadmin');
|
||||
$tMessage = _("Unable to update your auto response settings!");
|
||||
echo "<p>This may signify an error; please contact support (1)</p>";
|
||||
bindtextdomain('squirrelmail', SM_PATH . 'locale');
|
||||
textdomain('squirrelmail');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
|
||||
textdomain('postfixadmin');
|
||||
echo "<p align=center><b>". _("Your auto response has been removed!") ."</b></p>";
|
||||
bindtextdomain('squirrelmail', SM_PATH . 'locale');
|
||||
textdomain('squirrelmail');
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty ($fAway))
|
||||
{
|
||||
if (!empty($fAway)) {
|
||||
// add record into vacation
|
||||
$success = $vacation->setAway($fSubject, $fBody);
|
||||
|
||||
@ -141,17 +130,12 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
$tMessage = _("Unable to update your auto response settings!");
|
||||
bindtextdomain('squirrelmail', SM_PATH . 'locale');
|
||||
textdomain('squirrelmail');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
bindtextdomain('postfixadmin', SM_PATH . 'plugins/postfixadmin/locale');
|
||||
textdomain('postfixadmin');
|
||||
echo "<p align=center><b>". _("Your auto response has been set!") ."</b></p>";
|
||||
bindtextdomain('squirrelmail', SM_PATH . 'locale');
|
||||
textdomain('squirrelmail');
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
@ -7,7 +7,6 @@ function squirrelmail_plugin_init_postfixadmin() {
|
||||
global $squirrelmail_plugin_hooks;
|
||||
|
||||
$squirrelmail_plugin_hooks['optpage_register_block']['postfixadmin'] = 'postfixadmin_optpage_register_block';
|
||||
|
||||
}
|
||||
|
||||
function postfixadmin_version() {
|
||||
@ -28,7 +27,7 @@ function postfixadmin_optpage_register_block () {
|
||||
'name' => _("Forwarding"),
|
||||
'url' => '../plugins/postfixadmin/postfixadmin_forward.php',
|
||||
'desc' => _("Here you can create and edit E-Mail forwards."),
|
||||
'js' => FALSE
|
||||
'js' => false
|
||||
);
|
||||
bindtextdomain('squirrelmail', SM_PATH . 'locale');
|
||||
textdomain('squirrelmail');
|
||||
@ -58,4 +57,3 @@ function postfixadmin_optpage_register_block () {
|
||||
textdomain('squirrelmail');
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
@ -45,17 +45,12 @@ if ( ! is_dir( $homedir ) ) {
|
||||
//
|
||||
// Recursive Delete Function
|
||||
//
|
||||
function deldir($dir)
|
||||
{
|
||||
function deldir($dir) {
|
||||
$current_dir = opendir($dir);
|
||||
while($entryname = readdir($current_dir))
|
||||
{
|
||||
if(is_dir("$dir/$entryname") and ($entryname != "." and $entryname!=".."))
|
||||
{
|
||||
while ($entryname = readdir($current_dir)) {
|
||||
if (is_dir("$dir/$entryname") and ($entryname != "." and $entryname!="..")) {
|
||||
deldir("${dir}/${entryname}");
|
||||
}
|
||||
elseif($entryname != "." and $entryname!="..")
|
||||
{
|
||||
} elseif ($entryname != "." and $entryname!="..") {
|
||||
unlink("${dir}/${entryname}");
|
||||
}
|
||||
}
|
||||
@ -74,33 +69,26 @@ $fr = opendir( $homedir );
|
||||
|
||||
// TODO: Would glob($homedir . '/**/*/new') be somewhat quicker/shorter/less effort?
|
||||
|
||||
while ( ($domain = readdir($fr)) !== false)
|
||||
{
|
||||
while (($domain = readdir($fr)) !== false) {
|
||||
//
|
||||
// Check if it's a dir
|
||||
//
|
||||
if ( $domain != "." and $domain != ".." and filetype($homedir .'/'. $domain) == "dir" )
|
||||
{
|
||||
if ($domain != "." and $domain != ".." and filetype($homedir .'/'. $domain) == "dir") {
|
||||
//
|
||||
// Open the (assumed) DOMAIN directory
|
||||
//
|
||||
$ff = opendir($homedir .'/'. $domain);
|
||||
while ( ($user = readdir($ff)) !== false)
|
||||
{
|
||||
while (($user = readdir($ff)) !== false) {
|
||||
//
|
||||
// Check for directories assuming it's a user account
|
||||
//
|
||||
if ( $user!="." and $user!=".." and filetype($homedir .'/'. $domain .'/'. $user) == "dir" )
|
||||
{
|
||||
if ($user!="." and $user!=".." and filetype($homedir .'/'. $domain .'/'. $user) == "dir") {
|
||||
//
|
||||
// if the dir 'new' exists inside then it's an account
|
||||
//
|
||||
if ( file_exists($homedir .'/'. $domain .'/'. $user .'/'. "new") )
|
||||
{
|
||||
if (file_exists($homedir .'/'. $domain .'/'. $user .'/'. "new")) {
|
||||
$dir[$domain][$user] = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
//
|
||||
// Alert that the dir doesn't have a 'new' dir, possibly not an account. Leave it.
|
||||
//
|
||||
@ -138,8 +126,7 @@ if ( ! $result ) {
|
||||
//
|
||||
// Fetch the list of results
|
||||
//
|
||||
while ( $row = mysqli_fetch_assoc( $result ) )
|
||||
{
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
//
|
||||
// Pull apart the maildir field, needed to figure out the directory structure to compare
|
||||
//
|
||||
@ -163,29 +150,24 @@ if ( count($dir[$strip[0]])==0 and mysqli_num_rows($result)>0 ) {
|
||||
//
|
||||
// If the array still exists (incase nothing there)
|
||||
//
|
||||
if ( is_array($dir) )
|
||||
{
|
||||
if (is_array($dir)) {
|
||||
//
|
||||
// Go through each dir
|
||||
//
|
||||
foreach ( $dir as $key => $value )
|
||||
{
|
||||
foreach ($dir as $key => $value) {
|
||||
//
|
||||
// Is this a user array?
|
||||
//
|
||||
if ( is_array( $value) )
|
||||
{
|
||||
if (is_array($value)) {
|
||||
//
|
||||
// Go through and nuke the folders
|
||||
//
|
||||
foreach ( $value as $user => $value2 )
|
||||
{
|
||||
foreach ($value as $user => $value2) {
|
||||
// Nuke.. need any more explanations?
|
||||
$path = $homedir . '/' . $key . '/' . $user;
|
||||
if ($MAKE_CHANGES) {
|
||||
deldir($path);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
echo " - Would recursively delete : $path \n";
|
||||
}
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ if(!is_file("$incpath/config.inc.php")) {
|
||||
require_once("$incpath/config.inc.php");
|
||||
|
||||
if (isset($CONF['configured'])) {
|
||||
if($CONF['configured'] == FALSE) {
|
||||
if ($CONF['configured'] == false) {
|
||||
die("Please edit config.inc.php - change \$CONF['configured'] to true after setting your database settings");
|
||||
}
|
||||
}
|
||||
@ -102,4 +102,3 @@ if (!defined('POSTFIXADMIN_CLI')) {
|
||||
}
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
?>
|
||||
|
@ -82,7 +82,7 @@ function authentication_has_role($role) {
|
||||
function authentication_require_role($role) {
|
||||
// redirect to appropriate page?
|
||||
if (authentication_has_role($role)) {
|
||||
return True;
|
||||
return true;
|
||||
}
|
||||
|
||||
header("Location: login.php");
|
||||
@ -313,7 +313,6 @@ function escape_string ($string) {
|
||||
$string = stripslashes($string);
|
||||
}
|
||||
if (!is_numeric($string)) {
|
||||
|
||||
$link = db_connect();
|
||||
|
||||
if ($CONF['database_type'] == "mysql") {
|
||||
@ -353,7 +352,9 @@ function escape_string ($string) {
|
||||
*/
|
||||
function safeget($param, $default="") {
|
||||
$retval=$default;
|
||||
if (isset($_GET[$param])) $retval=$_GET[$param];
|
||||
if (isset($_GET[$param])) {
|
||||
$retval=$_GET[$param];
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
@ -367,7 +368,9 @@ function safeget ($param, $default="") {
|
||||
*/
|
||||
function safepost($param, $default="") {
|
||||
$retval=$default;
|
||||
if (isset($_POST[$param])) $retval=$_POST[$param];
|
||||
if (isset($_POST[$param])) {
|
||||
$retval=$_POST[$param];
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
@ -380,7 +383,9 @@ function safepost ($param, $default="") {
|
||||
*/
|
||||
function safeserver($param, $default="") {
|
||||
$retval=$default;
|
||||
if (isset($_SERVER[$param])) $retval=$_SERVER[$param];
|
||||
if (isset($_SERVER[$param])) {
|
||||
$retval=$_SERVER[$param];
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
@ -393,7 +398,9 @@ function safeserver ($param, $default="") {
|
||||
*/
|
||||
function safecookie($param, $default="") {
|
||||
$retval=$default;
|
||||
if (isset($_COOKIE[$param])) $retval=$_COOKIE[$param];
|
||||
if (isset($_COOKIE[$param])) {
|
||||
$retval=$_COOKIE[$param];
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
@ -406,7 +413,9 @@ function safecookie ($param, $default="") {
|
||||
*/
|
||||
function safesession($param, $default="") {
|
||||
$retval=$default;
|
||||
if (isset($_SESSION[$param])) $retval=$_SESSION[$param];
|
||||
if (isset($_SESSION[$param])) {
|
||||
$retval=$_SESSION[$param];
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
@ -426,8 +435,12 @@ function safesession ($param, $default="") {
|
||||
* @return array for $struct
|
||||
*/
|
||||
function pacol($allow_editing, $display_in_form, $display_in_list, $type, $PALANG_label, $PALANG_desc, $default = "", $options = array(), $multiopt=0, $dont_write_to_db=0, $select="", $extrafrom="", $linkto="") {
|
||||
if ($PALANG_label != '') $PALANG_label = Config::lang($PALANG_label);
|
||||
if ($PALANG_desc != '') $PALANG_desc = Config::lang($PALANG_desc );
|
||||
if ($PALANG_label != '') {
|
||||
$PALANG_label = Config::lang($PALANG_label);
|
||||
}
|
||||
if ($PALANG_desc != '') {
|
||||
$PALANG_desc = Config::lang($PALANG_desc);
|
||||
}
|
||||
|
||||
if (is_array($multiopt)) { # remaining parameters provided in named array
|
||||
$not_in_db = 0; # keep default value
|
||||
@ -461,7 +474,6 @@ function pacol($allow_editing, $display_in_form, $display_in_list, $type, $PALAN
|
||||
// Call: get_domain_properties (string domain)
|
||||
//
|
||||
function get_domain_properties($domain) {
|
||||
|
||||
$handler = new DomainHandler();
|
||||
if (!$handler->init($domain)) {
|
||||
die("Error: " . join("\n", $handler->errormsg));
|
||||
@ -583,7 +595,9 @@ function create_page_browser($idxfield, $querypart) {
|
||||
// Call: divide_quota (string $quota)
|
||||
//
|
||||
function divide_quota($quota) {
|
||||
if ($quota == -1) return $quota;
|
||||
if ($quota == -1) {
|
||||
return $quota;
|
||||
}
|
||||
$value = round($quota / Config::read('quota_multiplier'), 2);
|
||||
return $value;
|
||||
}
|
||||
@ -634,7 +648,7 @@ function list_domains_for_admin ($username) {
|
||||
$query .= " LEFT JOIN $table_domain_admins ON $table_domain.domain=$table_domain_admins.domain ";
|
||||
$condition[] = "$table_domain_admins.username='$E_username' ";
|
||||
$condition[] = "$table_domain.active='" . db_get_boolean(true) . "'"; # TODO: does it really make sense to exclude inactive...
|
||||
$condition[] = "$table_domain.backupmx='" . db_get_boolean(False) . "'"; # TODO: ... and backupmx domains for non-superadmins?
|
||||
$condition[] = "$table_domain.backupmx='" . db_get_boolean(false) . "'"; # TODO: ... and backupmx domains for non-superadmins?
|
||||
}
|
||||
|
||||
$query .= " WHERE " . join(' AND ', $condition);
|
||||
@ -895,21 +909,15 @@ function pacrypt ($pw, $pw_db="") {
|
||||
$salt = $split_salt[2];
|
||||
}
|
||||
$password = md5crypt($pw, $salt);
|
||||
}
|
||||
|
||||
elseif ($CONF['encrypt'] == 'md5') {
|
||||
} elseif ($CONF['encrypt'] == 'md5') {
|
||||
$password = md5($pw);
|
||||
}
|
||||
|
||||
elseif ($CONF['encrypt'] == 'system') {
|
||||
} elseif ($CONF['encrypt'] == 'system') {
|
||||
if ($pw_db) {
|
||||
$password = crypt($pw, $pw_db);
|
||||
} else {
|
||||
$password = crypt($pw);
|
||||
}
|
||||
}
|
||||
|
||||
elseif ($CONF['encrypt'] == 'cleartext') {
|
||||
} elseif ($CONF['encrypt'] == 'cleartext') {
|
||||
$password = $pw;
|
||||
}
|
||||
|
||||
@ -925,9 +933,7 @@ function pacrypt ($pw, $pw_db="") {
|
||||
}
|
||||
$l = db_row($res["result"]);
|
||||
$password = $l[0];
|
||||
}
|
||||
|
||||
elseif ($CONF['encrypt'] == 'authlib') {
|
||||
} elseif ($CONF['encrypt'] == 'authlib') {
|
||||
$flavor = $CONF['authlib_default_flavor'];
|
||||
$salt = substr(create_salt(), 0, 2); # courier-authlib supports only two-character salts
|
||||
if (preg_match('/^{.*}/', $pw_db)) {
|
||||
@ -940,32 +946,40 @@ function pacrypt ($pw, $pw_db="") {
|
||||
if (stripos($flavor, 'md5raw') === 0) {
|
||||
$password = '{' . $flavor . '}' . md5($pw);
|
||||
} elseif (stripos($flavor, 'md5') === 0) {
|
||||
$password = '{' . $flavor . '}' . base64_encode(md5($pw, TRUE));
|
||||
$password = '{' . $flavor . '}' . base64_encode(md5($pw, true));
|
||||
} elseif (stripos($flavor, 'crypt') === 0) {
|
||||
$password = '{' . $flavor . '}' . crypt($pw, $salt);
|
||||
} elseif (stripos($flavor, 'SHA') === 0) {
|
||||
$password = '{' . $flavor . '}' . base64_encode(sha1($pw, TRUE));
|
||||
$password = '{' . $flavor . '}' . base64_encode(sha1($pw, true));
|
||||
} else {
|
||||
die("authlib_default_flavor '" . $flavor . "' unknown. Valid flavors are 'md5raw', 'md5', 'SHA' and 'crypt'");
|
||||
}
|
||||
}
|
||||
|
||||
elseif (preg_match("/^dovecot:/", $CONF['encrypt'])) {
|
||||
} elseif (preg_match("/^dovecot:/", $CONF['encrypt'])) {
|
||||
$split_method = preg_split('/:/', $CONF['encrypt']);
|
||||
$method = strtoupper($split_method[1]);
|
||||
# If $pw_db starts with {method}, change $method accordingly
|
||||
if (!empty($pw_db) && preg_match('/^\{([A-Z0-9.-]+)\}.+/', $pw_db, $method_matches)) { $method = $method_matches[1]; }
|
||||
if (! preg_match("/^[A-Z0-9.-]+$/", $method)) { die("invalid dovecot encryption method"); } # TODO: check against a fixed list?
|
||||
if (!empty($pw_db) && preg_match('/^\{([A-Z0-9.-]+)\}.+/', $pw_db, $method_matches)) {
|
||||
$method = $method_matches[1];
|
||||
}
|
||||
if (! preg_match("/^[A-Z0-9.-]+$/", $method)) {
|
||||
die("invalid dovecot encryption method");
|
||||
} # TODO: check against a fixed list?
|
||||
# if (strtolower($method) == 'md5-crypt') die("\$CONF['encrypt'] = 'dovecot:md5-crypt' will not work because dovecotpw generates a random salt each time. Please use \$CONF['encrypt'] = 'md5crypt' instead.");
|
||||
# $crypt_method = preg_match ("/.*-CRYPT$/", $method);
|
||||
|
||||
# digest-md5 and SCRAM-SHA-1 hashes include the username - until someone implements it, let's declare it as unsupported
|
||||
if (strtolower($method) == 'digest-md5') die("Sorry, \$CONF['encrypt'] = 'dovecot:digest-md5' is not supported by PostfixAdmin.");
|
||||
if (strtoupper($method) == 'SCRAM-SHA-1') die("Sorry, \$CONF['encrypt'] = 'dovecot:scram-sha-1' is not supported by PostfixAdmin.");
|
||||
if (strtolower($method) == 'digest-md5') {
|
||||
die("Sorry, \$CONF['encrypt'] = 'dovecot:digest-md5' is not supported by PostfixAdmin.");
|
||||
}
|
||||
if (strtoupper($method) == 'SCRAM-SHA-1') {
|
||||
die("Sorry, \$CONF['encrypt'] = 'dovecot:scram-sha-1' is not supported by PostfixAdmin.");
|
||||
}
|
||||
# TODO: add -u option for those hashes, or for everything that is salted (-u was available before dovecot 2.1 -> no problem with backward compability)
|
||||
|
||||
$dovecotpw = "doveadm pw";
|
||||
if (!empty($CONF['dovecotpw'])) $dovecotpw = $CONF['dovecotpw'];
|
||||
if (!empty($CONF['dovecotpw'])) {
|
||||
$dovecotpw = $CONF['dovecotpw'];
|
||||
}
|
||||
|
||||
# Use proc_open call to avoid safe_mode problems and to prevent showing plain password in process table
|
||||
$spec = array(
|
||||
@ -990,7 +1004,8 @@ function pacrypt ($pw, $pw_db="") {
|
||||
// use dovecot's stdin, it uses getpass() twice (except when using -t)
|
||||
// Write pass in pipe stdin
|
||||
if (empty($dovepasstest)) {
|
||||
fwrite($pipes[0], $pw . "\n", 1+strlen($pw)); usleep(1000);
|
||||
fwrite($pipes[0], $pw . "\n", 1+strlen($pw));
|
||||
usleep(1000);
|
||||
}
|
||||
fwrite($pipes[0], $pw . "\n", 1+strlen($pw));
|
||||
fclose($pipes[0]);
|
||||
@ -1024,9 +1039,7 @@ function pacrypt ($pw, $pw_db="") {
|
||||
|
||||
$password = rtrim($password);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
} else {
|
||||
die('unknown/invalid $CONF["encrypt"] setting: ' . $CONF['encrypt']);
|
||||
}
|
||||
|
||||
@ -1042,10 +1055,16 @@ function pacrypt ($pw, $pw_db="") {
|
||||
function md5crypt($pw, $salt="", $magic="") {
|
||||
$MAGIC = "$1$";
|
||||
|
||||
if ($magic == "") $magic = $MAGIC;
|
||||
if ($salt == "") $salt = create_salt ();
|
||||
if ($magic == "") {
|
||||
$magic = $MAGIC;
|
||||
}
|
||||
if ($salt == "") {
|
||||
$salt = create_salt();
|
||||
}
|
||||
$slist = explode("$", $salt);
|
||||
if ($slist[0] == "1") $salt = $slist[1];
|
||||
if ($slist[0] == "1") {
|
||||
$salt = $slist[1];
|
||||
}
|
||||
|
||||
$salt = substr($salt, 0, 8);
|
||||
$ctx = $pw . $magic . $salt;
|
||||
@ -1061,8 +1080,11 @@ function md5crypt ($pw, $salt="", $magic="") {
|
||||
$i = strlen($pw);
|
||||
|
||||
while ($i > 0) {
|
||||
if ($i & 1) $ctx .= chr (0);
|
||||
else $ctx .= $pw[0];
|
||||
if ($i & 1) {
|
||||
$ctx .= chr(0);
|
||||
} else {
|
||||
$ctx .= $pw[0];
|
||||
}
|
||||
$i = $i >> 1;
|
||||
}
|
||||
$final = hex2bin(md5($ctx));
|
||||
@ -1074,8 +1096,12 @@ function md5crypt ($pw, $salt="", $magic="") {
|
||||
} else {
|
||||
$ctx1 .= substr($final, 0, 16);
|
||||
}
|
||||
if ($i % 3) $ctx1 .= $salt;
|
||||
if ($i % 7) $ctx1 .= $pw;
|
||||
if ($i % 3) {
|
||||
$ctx1 .= $salt;
|
||||
}
|
||||
if ($i % 7) {
|
||||
$ctx1 .= $pw;
|
||||
}
|
||||
if ($i & 1) {
|
||||
$ctx1 .= substr($final, 0, 16);
|
||||
} else {
|
||||
@ -1109,7 +1135,8 @@ function hex2bin ($str) {
|
||||
}
|
||||
return $nstr;
|
||||
}
|
||||
/**/ }
|
||||
/**/
|
||||
}
|
||||
|
||||
/*
|
||||
* remove item $item from array $array
|
||||
@ -1212,11 +1239,12 @@ function smtp_mail ($to, $from, $data, $body = "") {
|
||||
*/
|
||||
function smtp_get_admin_email() {
|
||||
$admin_email = Config::read('admin_email');
|
||||
if(!empty($admin_email))
|
||||
if (!empty($admin_email)) {
|
||||
return $admin_email;
|
||||
else
|
||||
} else {
|
||||
return authentication_get_username();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
@ -1229,8 +1257,7 @@ function smtp_get_response ($fh) {
|
||||
do {
|
||||
$line = fgets($fh, 256);
|
||||
$res .= $line;
|
||||
}
|
||||
while (preg_match("/^\d\d\d\-/", $line));
|
||||
} while (preg_match("/^\d\d\d\-/", $line));
|
||||
return $res;
|
||||
}
|
||||
|
||||
@ -1263,7 +1290,9 @@ $DEBUG_TEXT = "\n
|
||||
function db_connect($ignore_errors = false) {
|
||||
global $CONF;
|
||||
global $DEBUG_TEXT;
|
||||
if ($ignore_errors != 0) $DEBUG_TEXT = '';
|
||||
if ($ignore_errors != 0) {
|
||||
$DEBUG_TEXT = '';
|
||||
}
|
||||
$error_text = '';
|
||||
|
||||
static $link;
|
||||
@ -1327,7 +1356,9 @@ function db_connect ($ignore_errors = false) {
|
||||
}
|
||||
$connect_string = "host=" . $CONF['database_host'] . " port=" . $CONF['database_port'] . " dbname=" . $CONF['database_name'] . " user=" . $CONF['database_user'] . " password=" . $CONF['database_password'];
|
||||
$link = @pg_pconnect($connect_string) or $error_text .= ("<p />DEBUG INFORMATION:<br />Connect: failed to connect to database. $DEBUG_TEXT");
|
||||
if ($link) pg_set_client_encoding($link, 'UNICODE');
|
||||
if ($link) {
|
||||
pg_set_client_encoding($link, 'UNICODE');
|
||||
}
|
||||
} else {
|
||||
$error_text .= "<p />DEBUG INFORMATION:<br />PostgreSQL functions not available! (php5-pgsql installed?)<br />database_type = 'pgsql' in config.inc.php, are you using a different database? $DEBUG_TEXT";
|
||||
}
|
||||
@ -1395,8 +1426,7 @@ function db_quota_text($count, $quota, $fieldname) {
|
||||
WHEN '0' THEN (coalesce($count,0) || ' / " . escape_string(html_entity_decode('∞')) . "')
|
||||
ELSE (coalesce($count,0) || ' / ' || $quota)
|
||||
END AS $fieldname";
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
return " CASE $quota
|
||||
WHEN '-1' THEN CONCAT(coalesce($count,0), ' / -')
|
||||
WHEN '0' THEN CONCAT(coalesce($count,0), ' / ', '" . escape_string(html_entity_decode('∞')) . "')
|
||||
@ -1466,14 +1496,22 @@ function db_query ($query, $ignore_errors = 0) {
|
||||
$number_rows = "";
|
||||
$link = db_connect();
|
||||
$error_text = "";
|
||||
if ($ignore_errors) $DEBUG_TEXT = "";
|
||||
if ($ignore_errors) {
|
||||
$DEBUG_TEXT = "";
|
||||
}
|
||||
|
||||
if ($CONF['database_type'] == "mysql") $result = @mysql_query ($query, $link)
|
||||
if ($CONF['database_type'] == "mysql") {
|
||||
$result = @mysql_query($query, $link)
|
||||
or $error_text = "Invalid query: " . mysql_error($link);
|
||||
if ($CONF['database_type'] == "mysqli") $result = @mysqli_query ($link, $query)
|
||||
}
|
||||
if ($CONF['database_type'] == "mysqli") {
|
||||
$result = @mysqli_query($link, $query)
|
||||
or $error_text = "Invalid query: " . mysqli_error($link);
|
||||
if (db_sqlite()) $result = @$link->query($query)
|
||||
}
|
||||
if (db_sqlite()) {
|
||||
$result = @$link->query($query)
|
||||
or $error_text = "Invalid query: " . $link->lastErrorMsg();
|
||||
}
|
||||
if (db_pgsql()) {
|
||||
$result = @pg_query($link, $query)
|
||||
or $error_text = "Invalid query: " . pg_last_error();
|
||||
@ -1489,7 +1527,9 @@ function db_query ($query, $ignore_errors = 0) {
|
||||
if ($result->numColumns()) {
|
||||
// Query returned something
|
||||
$num_rows = 0;
|
||||
while(@$result->fetchArray(SQLITE3_ASSOC)) $num_rows++;
|
||||
while (@$result->fetchArray(SQLITE3_ASSOC)) {
|
||||
$num_rows++;
|
||||
}
|
||||
$result->reset();
|
||||
$number_rows = $num_rows;
|
||||
} else {
|
||||
@ -1498,15 +1538,27 @@ function db_query ($query, $ignore_errors = 0) {
|
||||
}
|
||||
} elseif (preg_match("/^SELECT/i", trim($query))) {
|
||||
// if $query was a SELECT statement check the number of rows with [database_type]_num_rows ().
|
||||
if ($CONF['database_type'] == "mysql") $number_rows = mysql_num_rows ($result);
|
||||
if ($CONF['database_type'] == "mysqli") $number_rows = mysqli_num_rows ($result);
|
||||
if (db_pgsql() ) $number_rows = pg_num_rows ($result);
|
||||
if ($CONF['database_type'] == "mysql") {
|
||||
$number_rows = mysql_num_rows($result);
|
||||
}
|
||||
if ($CONF['database_type'] == "mysqli") {
|
||||
$number_rows = mysqli_num_rows($result);
|
||||
}
|
||||
if (db_pgsql()) {
|
||||
$number_rows = pg_num_rows($result);
|
||||
}
|
||||
} else {
|
||||
// if $query was something else, UPDATE, DELETE or INSERT check the number of rows with
|
||||
// [database_type]_affected_rows ().
|
||||
if ($CONF['database_type'] == "mysql") $number_rows = mysql_affected_rows ($link);
|
||||
if ($CONF['database_type'] == "mysqli") $number_rows = mysqli_affected_rows ($link);
|
||||
if (db_pgsql() ) $number_rows = pg_affected_rows ($result);
|
||||
if ($CONF['database_type'] == "mysql") {
|
||||
$number_rows = mysql_affected_rows($link);
|
||||
}
|
||||
if ($CONF['database_type'] == "mysqli") {
|
||||
$number_rows = mysqli_affected_rows($link);
|
||||
}
|
||||
if (db_pgsql()) {
|
||||
$number_rows = pg_affected_rows($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1527,10 +1579,18 @@ function db_query ($query, $ignore_errors = 0) {
|
||||
function db_row($result) {
|
||||
global $CONF;
|
||||
$row = "";
|
||||
if ($CONF['database_type'] == "mysql") $row = mysql_fetch_row ($result);
|
||||
if ($CONF['database_type'] == "mysqli") $row = mysqli_fetch_row ($result);
|
||||
if (db_sqlite() ) $row = $result->fetchArray(SQLITE3_NUM);
|
||||
if (db_pgsql() ) $row = pg_fetch_row ($result);
|
||||
if ($CONF['database_type'] == "mysql") {
|
||||
$row = mysql_fetch_row($result);
|
||||
}
|
||||
if ($CONF['database_type'] == "mysqli") {
|
||||
$row = mysqli_fetch_row($result);
|
||||
}
|
||||
if (db_sqlite()) {
|
||||
$row = $result->fetchArray(SQLITE3_NUM);
|
||||
}
|
||||
if (db_pgsql()) {
|
||||
$row = pg_fetch_row($result);
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
@ -1543,10 +1603,18 @@ function db_row ($result) {
|
||||
function db_array($result) {
|
||||
global $CONF;
|
||||
$row = "";
|
||||
if ($CONF['database_type'] == "mysql") $row = mysql_fetch_array ($result);
|
||||
if ($CONF['database_type'] == "mysqli") $row = mysqli_fetch_array ($result);
|
||||
if (db_sqlite() ) $row = $result->fetchArray();
|
||||
if (db_pgsql() ) $row = pg_fetch_array ($result);
|
||||
if ($CONF['database_type'] == "mysql") {
|
||||
$row = mysql_fetch_array($result);
|
||||
}
|
||||
if ($CONF['database_type'] == "mysqli") {
|
||||
$row = mysqli_fetch_array($result);
|
||||
}
|
||||
if (db_sqlite()) {
|
||||
$row = $result->fetchArray();
|
||||
}
|
||||
if (db_pgsql()) {
|
||||
$row = pg_fetch_array($result);
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
@ -1559,10 +1627,18 @@ function db_array ($result) {
|
||||
function db_assoc($result) {
|
||||
global $CONF;
|
||||
$row = "";
|
||||
if ($CONF['database_type'] == "mysql") $row = mysql_fetch_assoc ($result);
|
||||
if ($CONF['database_type'] == "mysqli") $row = mysqli_fetch_assoc ($result);
|
||||
if (db_sqlite() ) $row = $result->fetchArray(SQLITE3_ASSOC);
|
||||
if (db_pgsql() ) $row = pg_fetch_assoc ($result);
|
||||
if ($CONF['database_type'] == "mysql") {
|
||||
$row = mysql_fetch_assoc($result);
|
||||
}
|
||||
if ($CONF['database_type'] == "mysqli") {
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
}
|
||||
if (db_sqlite()) {
|
||||
$row = $result->fetchArray(SQLITE3_ASSOC);
|
||||
}
|
||||
if (db_pgsql()) {
|
||||
$row = pg_fetch_assoc($result);
|
||||
}
|
||||
return $row;
|
||||
}
|
||||
|
||||
@ -1761,7 +1837,9 @@ function db_where_clause($condition, $struct, $additional_raw_where = '', $searc
|
||||
$having_parts = array();
|
||||
|
||||
foreach ($condition as $field => $value) {
|
||||
if (isset($struct[$field]) && $struct[$field]['type'] == 'bool') $value = db_get_boolean($value);
|
||||
if (isset($struct[$field]) && $struct[$field]['type'] == 'bool') {
|
||||
$value = db_get_boolean($value);
|
||||
}
|
||||
$operator = '=';
|
||||
if (isset($searchmode[$field])) {
|
||||
if (in_array($searchmode[$field], $allowed_operators)) {
|
||||
@ -1794,8 +1872,12 @@ function db_where_clause($condition, $struct, $additional_raw_where = '', $searc
|
||||
}
|
||||
$query = ' WHERE 1=1 ';
|
||||
$query .= " $additional_raw_where ";
|
||||
if (count($where_parts) > 0) $query .= " AND ( " . join(" AND ", $where_parts) . " ) ";
|
||||
if (count($having_parts) > 0) $query .= " HAVING ( " . join(" AND ", $having_parts) . " ) ";
|
||||
if (count($where_parts) > 0) {
|
||||
$query .= " AND ( " . join(" AND ", $where_parts) . " ) ";
|
||||
}
|
||||
if (count($having_parts) > 0) {
|
||||
$query .= " HAVING ( " . join(" AND ", $having_parts) . " ) ";
|
||||
}
|
||||
|
||||
return $query;
|
||||
}
|
||||
@ -1834,7 +1916,7 @@ function table_by_key ($table_key) {
|
||||
* returns the current 'version' value from the config table
|
||||
* if $error_out is True (default), die() with a message that recommends to run setup.php.
|
||||
*/
|
||||
function check_db_version($error_out = True) {
|
||||
function check_db_version($error_out = true) {
|
||||
global $min_db_version;
|
||||
|
||||
$table = table_by_key('config');
|
||||
@ -1850,7 +1932,7 @@ function check_db_version($error_out = True) {
|
||||
db_query("INSERT INTO $table (name, value) VALUES ('version', '0')", 0, '');
|
||||
}
|
||||
|
||||
if ( ($dbversion < $min_db_version) && $error_out == True) {
|
||||
if (($dbversion < $min_db_version) && $error_out == true) {
|
||||
echo "ERROR: The PostfixAdmin database layout is outdated (you have r$dbversion, but r$min_db_version is expected).\nPlease run setup.php to upgrade the database.\n";
|
||||
exit(1);
|
||||
}
|
||||
@ -1885,10 +1967,10 @@ function alias_domain_postdeletion($alias_domain) {
|
||||
if (0!=$retval) {
|
||||
error_log("Running $command yielded return value=$retval, first line of output=$firstline");
|
||||
print '<p>WARNING: Problems running alias_domain postdeletion script!</p>';
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
//
|
||||
@ -1987,8 +2069,9 @@ function gen_show_status ($show_alias) {
|
||||
|
||||
function getRemoteAddr() {
|
||||
$REMOTE_ADDR = 'localhost';
|
||||
if (isset($_SERVER['REMOTE_ADDR']))
|
||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
||||
$REMOTE_ADDR = $_SERVER['REMOTE_ADDR'];
|
||||
}
|
||||
return $REMOTE_ADDR;
|
||||
}
|
||||
|
||||
|
@ -19,4 +19,3 @@
|
||||
//
|
||||
header("Location: ../login.php");
|
||||
exit;
|
||||
?>
|
||||
|
@ -1,4 +1,6 @@
|
||||
<?php if( !defined('POSTFIXADMIN') ) die( "This file cannot be used standalone." ); ?>
|
||||
<?php if (!defined('POSTFIXADMIN')) {
|
||||
die("This file cannot be used standalone.");
|
||||
} ?>
|
||||
<?php
|
||||
# List of supported languages
|
||||
$supported_languages = array(
|
||||
|
@ -2,7 +2,6 @@
|
||||
# $Id$
|
||||
|
||||
class AdminHandler extends PFAHandler {
|
||||
|
||||
protected $db_table = 'admin';
|
||||
protected $id_field = 'username';
|
||||
|
||||
@ -40,16 +39,40 @@ class AdminHandler extends PFAHandler {
|
||||
$this->struct=array(
|
||||
# field name allow display in... type $PALANG label $PALANG description default / options / ...
|
||||
# editing? form list
|
||||
'username' => pacol( $this->new, 1, 1, 'text', 'admin' , 'email_address' , '', '',
|
||||
array('linkto' => 'list.php?table=domain&username=%s') ),
|
||||
'username' => pacol(
|
||||
$this->new,
|
||||
1,
|
||||
1,
|
||||
'text',
|
||||
'admin',
|
||||
'email_address',
|
||||
'',
|
||||
'',
|
||||
array('linkto' => 'list.php?table=domain&username=%s')
|
||||
),
|
||||
'password' => pacol(1, 1, 0, 'pass', 'password', ''),
|
||||
'password2' => pacol( 1, 1, 0, 'pass', 'password_again' , '' , '', '',
|
||||
'password2' => pacol(
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
'pass',
|
||||
'password_again',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
/*not_in_db*/ 0,
|
||||
/*dont_write_to_db*/ 1,
|
||||
/*select*/ 'password as password2'
|
||||
),
|
||||
|
||||
'superadmin' => pacol( 1, 1, 0, 'bool', 'super_admin' , 'super_admin_desc' , 0
|
||||
'superadmin' => pacol(
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
'bool',
|
||||
'super_admin',
|
||||
'super_admin_desc',
|
||||
0
|
||||
# TODO: (finally) replace the ALL domain with a column in the admin table
|
||||
# TODO: current status: 'superadmin' column exists and is written when storing an admin with AdminHandler,
|
||||
# TODO: but the superadmin status is still (additionally) stored in the domain_admins table ("ALL" dummy domain)
|
||||
@ -58,14 +81,30 @@ class AdminHandler extends PFAHandler {
|
||||
# TODO: Create them with the trunk version to avoid this problem.
|
||||
),
|
||||
|
||||
'domains' => pacol( 1, 1, 0, 'list', 'domain' , '' , array(), list_domains(),
|
||||
'domains' => pacol(
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
'list',
|
||||
'domain',
|
||||
'',
|
||||
array(),
|
||||
list_domains(),
|
||||
/*not_in_db*/ 0,
|
||||
/*dont_write_to_db*/ 1,
|
||||
/*select*/ "coalesce(domains,'') as domains"
|
||||
/*extrafrom set in domain_count*/
|
||||
),
|
||||
|
||||
'domain_count' => pacol( 0, 0, 1, 'vnum', 'pAdminList_admin_count', '' , '', '',
|
||||
'domain_count' => pacol(
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
'vnum',
|
||||
'pAdminList_admin_count',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
/*not_in_db*/ 0,
|
||||
/*dont_write_to_db*/ 1,
|
||||
/*select*/ 'coalesce(__domain_count,0) as domain_count',
|
||||
@ -73,7 +112,8 @@ class AdminHandler extends PFAHandler {
|
||||
' SELECT count(*) AS __domain_count, ' . $domains_grouped . ' AS domains, username AS __domain_username ' .
|
||||
' FROM ' . table_by_key('domain_admins') .
|
||||
" WHERE domain != 'ALL' GROUP BY username " .
|
||||
' ) AS __domain on username = __domain_username'),
|
||||
' ) AS __domain on username = __domain_username'
|
||||
),
|
||||
|
||||
'active' => pacol(1, 1, 1, 'bool', 'active', '', 1),
|
||||
'phone' => pacol(1, $passwordReset, 0, 'text', 'pCreate_mailbox_phone', 'pCreate_mailbox_phone_desc', ''),
|
||||
@ -206,7 +246,6 @@ class AdminHandler extends PFAHandler {
|
||||
protected function _validate_password2($field, $val) {
|
||||
return $this->compare_password_fields('password', 'password2');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
@ -2,7 +2,6 @@
|
||||
# $Id$
|
||||
|
||||
class AdminpasswordHandler extends PFAHandler {
|
||||
|
||||
protected $db_table = 'admin';
|
||||
protected $id_field = 'username';
|
||||
|
||||
@ -25,10 +24,27 @@ class AdminpasswordHandler extends PFAHandler {
|
||||
# field name allow display in... type $PALANG label $PALANG description default / options / ...
|
||||
# editing? form list
|
||||
'username' => pacol(0, 1, 1, 'text', 'admin', ''),
|
||||
'oldpass' => pacol( 1, 1, 0, 'pass', 'pPassword_password_current' , '', '', '',
|
||||
/*not_in_db*/ 1 ),
|
||||
'oldpass' => pacol(
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
'pass',
|
||||
'pPassword_password_current',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
/*not_in_db*/ 1
|
||||
),
|
||||
'password' => pacol(1, 1, 0, 'pass', 'pPassword_password', ''),
|
||||
'password2' => pacol( 1, 1, 0, 'pass', 'pPassword_password2' , '' , '', '',
|
||||
'password2' => pacol(
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
'pass',
|
||||
'pPassword_password2',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
/*not_in_db*/ 0,
|
||||
/*dont_write_to_db*/ 1,
|
||||
/*select*/ 'password as password2'
|
||||
@ -38,7 +54,9 @@ class AdminpasswordHandler extends PFAHandler {
|
||||
|
||||
public function init($id) {
|
||||
# hardcode to logged in admin
|
||||
if ($this->admin_username == '') die("No admin logged in");
|
||||
if ($this->admin_username == '') {
|
||||
die("No admin logged in");
|
||||
}
|
||||
$this->id = $this->admin_username;
|
||||
$this->values['username'] = $this->id;
|
||||
$this->struct['username']['default'] = $this->id;
|
||||
@ -91,7 +109,9 @@ class AdminpasswordHandler extends PFAHandler {
|
||||
* skip default validation (check if password is good enough) for old password
|
||||
*/
|
||||
protected function _inp_pass($field, $val) {
|
||||
if ($field == 'oldpass') return true;
|
||||
if ($field == 'oldpass') {
|
||||
return true;
|
||||
}
|
||||
|
||||
return parent::_inp_pass($field, $val);
|
||||
}
|
||||
@ -103,7 +123,6 @@ class AdminpasswordHandler extends PFAHandler {
|
||||
protected function _validate_password2($field, $val) {
|
||||
return $this->compare_password_fields('password', 'password2');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
@ -7,7 +7,6 @@
|
||||
* @property $return return of methods
|
||||
*/
|
||||
class AliasHandler extends PFAHandler {
|
||||
|
||||
protected $db_table = 'alias';
|
||||
protected $id_field = 'address';
|
||||
protected $domain_field = 'domain';
|
||||
@ -27,37 +26,104 @@ class AliasHandler extends PFAHandler {
|
||||
$this->struct=array(
|
||||
# field name allow display in... type $PALANG label $PALANG description default / ...
|
||||
# editing? form list
|
||||
'status' => pacol( 0, 0, 0, 'html', '' , '' , '', '',
|
||||
array('not_in_db' => 1) ),
|
||||
'status' => pacol(
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
'html',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
array('not_in_db' => 1)
|
||||
),
|
||||
'address' => pacol($this->new, 1, 1, 'mail', 'alias', 'pCreate_alias_catchall_text'),
|
||||
'localpart' => pacol( $this->new, 0, 0, 'text', 'alias' , 'pCreate_alias_catchall_text' , '',
|
||||
'localpart' => pacol(
|
||||
$this->new,
|
||||
0,
|
||||
0,
|
||||
'text',
|
||||
'alias',
|
||||
'pCreate_alias_catchall_text',
|
||||
'',
|
||||
/*options*/ '',
|
||||
/*not_in_db*/ 1 ),
|
||||
'domain' => pacol( $this->new, 0, 1, 'enum', '' , '' , '',
|
||||
/*options*/ $this->allowed_domains ),
|
||||
/*not_in_db*/ 1
|
||||
),
|
||||
'domain' => pacol(
|
||||
$this->new,
|
||||
0,
|
||||
1,
|
||||
'enum',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
/*options*/ $this->allowed_domains
|
||||
),
|
||||
'goto' => pacol(1, 1, 1, 'txtl', 'to', 'pEdit_alias_help', array()),
|
||||
'is_mailbox' => pacol( 0, 0, 1, 'int', '' , '' , 0 ,
|
||||
'is_mailbox' => pacol(
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
'int',
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
# technically 'is_mailbox' is bool, but the automatic bool conversion breaks the query. Flagging it as int avoids this problem.
|
||||
# Maybe having a vbool type (without the automatic conversion) would be cleaner - we'll see if we need it.
|
||||
/*options*/ '',
|
||||
/*not_in_db*/ 0,
|
||||
/*dont_write_to_db*/ 1,
|
||||
/*select*/ 'coalesce(__is_mailbox,0) as is_mailbox' ),
|
||||
/*select*/ 'coalesce(__is_mailbox,0) as is_mailbox'
|
||||
),
|
||||
/*extrafrom set via set_is_mailbox_extrafrom() */
|
||||
'__mailbox_username' => pacol(0, 0, 1, 'vtxt', '', '', 0), # filled via is_mailbox
|
||||
'goto_mailbox' => pacol( $mbgoto, $mbgoto,$mbgoto,'bool', 'pEdit_alias_forward_and_store' , '' , 0,
|
||||
'goto_mailbox' => pacol(
|
||||
$mbgoto,
|
||||
$mbgoto,
|
||||
$mbgoto,
|
||||
'bool',
|
||||
'pEdit_alias_forward_and_store',
|
||||
'',
|
||||
0,
|
||||
/*options*/ '',
|
||||
/*not_in_db*/ 1 ), # read_from_db_postprocess() sets the value
|
||||
'on_vacation' => pacol( 1, 0, 1, 'bool', 'pUsersMenu_vacation' , '' , 0 ,
|
||||
/*not_in_db*/ 1
|
||||
), # read_from_db_postprocess() sets the value
|
||||
'on_vacation' => pacol(
|
||||
1,
|
||||
0,
|
||||
1,
|
||||
'bool',
|
||||
'pUsersMenu_vacation',
|
||||
'',
|
||||
0,
|
||||
/*options*/ '',
|
||||
/*not_in_db*/ 1 ), # read_from_db_postprocess() sets the value - TODO: read active flag from vacation table instead?
|
||||
/*not_in_db*/ 1
|
||||
), # read_from_db_postprocess() sets the value - TODO: read active flag from vacation table instead?
|
||||
'created' => pacol(0, 0, 0, 'ts', 'created', ''),
|
||||
'modified' => pacol(0, 0, 1, 'ts', 'last_modified', ''),
|
||||
'active' => pacol(1, 1, 1, 'bool', 'active', '', 1),
|
||||
'_can_edit' => pacol( 0, 0, 1, 'vnum', '' , '' , 0 , '',
|
||||
array('select' => '1 as _can_edit') ),
|
||||
'_can_delete' => pacol( 0, 0, 1, 'vnum', '' , '' , 0 , '',
|
||||
array('select' => '1 as _can_delete') ), # read_from_db_postprocess() updates the value
|
||||
'_can_edit' => pacol(
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
'vnum',
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
'',
|
||||
array('select' => '1 as _can_edit')
|
||||
),
|
||||
'_can_delete' => pacol(
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
'vnum',
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
'',
|
||||
array('select' => '1 as _can_delete')
|
||||
), # read_from_db_postprocess() updates the value
|
||||
# aliases listed in $CONF[default_aliases] are read-only for domain admins if $CONF[special_alias_control] is NO.
|
||||
);
|
||||
|
||||
@ -148,7 +214,9 @@ class AliasHandler extends PFAHandler {
|
||||
|
||||
$retval = parent::init($id);
|
||||
|
||||
if (!$retval) return false; # parent::init() failed, no need to continue
|
||||
if (!$retval) {
|
||||
return false;
|
||||
} # parent::init() failed, no need to continue
|
||||
|
||||
# hide 'goto_mailbox' for non-mailbox aliases
|
||||
# parent::init called view() before, so we can rely on having $this->result filled
|
||||
@ -215,13 +283,21 @@ class AliasHandler extends PFAHandler {
|
||||
* check number of existing aliases for this domain - is one more allowed?
|
||||
*/
|
||||
private function create_allowed($domain) {
|
||||
if ($this->called_by == 'MailboxHandler') return true; # always allow creating an alias for a mailbox
|
||||
if ($this->called_by == 'MailboxHandler') {
|
||||
return true;
|
||||
} # always allow creating an alias for a mailbox
|
||||
|
||||
$limit = get_domain_properties($domain);
|
||||
|
||||
if ($limit['aliases'] == 0) return true; # unlimited
|
||||
if ($limit['aliases'] < 0) return false; # disabled
|
||||
if ($limit['alias_count'] >= $limit['aliases']) return false;
|
||||
if ($limit['aliases'] == 0) {
|
||||
return true;
|
||||
} # unlimited
|
||||
if ($limit['aliases'] < 0) {
|
||||
return false;
|
||||
} # disabled
|
||||
if ($limit['alias_count'] >= $limit['aliases']) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -235,7 +311,9 @@ class AliasHandler extends PFAHandler {
|
||||
if (empty($values['localpart']) || empty($values['domain'])) { # localpart or domain not set
|
||||
return "";
|
||||
}
|
||||
if ($values['localpart'] == '*') $values['localpart'] = ''; # catchall
|
||||
if ($values['localpart'] == '*') {
|
||||
$values['localpart'] = '';
|
||||
} # catchall
|
||||
return $values['localpart'] . '@' . $values['domain'];
|
||||
} else {
|
||||
return $values[$this->id_field];
|
||||
@ -401,7 +479,9 @@ class AliasHandler extends PFAHandler {
|
||||
protected function _missing_localpart($field) {
|
||||
if (isset($this->RAWvalues['address'])) {
|
||||
$parts = explode('@', $this->RAWvalues['address']);
|
||||
if (count($parts) == 2) $this->RAWvalues['localpart'] = $parts[0];
|
||||
if (count($parts) == 2) {
|
||||
$this->RAWvalues['localpart'] = $parts[0];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -411,7 +491,9 @@ class AliasHandler extends PFAHandler {
|
||||
protected function _missing_domain($field) {
|
||||
if (isset($this->RAWvalues['address'])) {
|
||||
$parts = explode('@', $this->RAWvalues['address']);
|
||||
if (count($parts) == 2) $this->RAWvalues['domain'] = $parts[1];
|
||||
if (count($parts) == 2) {
|
||||
$this->RAWvalues['domain'] = $parts[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -453,7 +535,6 @@ class AliasHandler extends PFAHandler {
|
||||
$this->infomsg[] = Config::Lang_f('pDelete_delete_success', $this->id);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
@ -5,7 +5,6 @@
|
||||
* Handlers User level alias actions - e.g. add alias, get aliases, update etc.
|
||||
*/
|
||||
class AliasdomainHandler extends PFAHandler {
|
||||
|
||||
protected $db_table = 'alias_domain';
|
||||
protected $id_field = 'alias_domain';
|
||||
protected $domain_field = 'alias_domain';
|
||||
@ -15,11 +14,27 @@ class AliasdomainHandler extends PFAHandler {
|
||||
$this->struct=array(
|
||||
# field name allow display in... type $PALANG label $PALANG description default / options / ...
|
||||
# editing? form list
|
||||
'alias_domain' => pacol( $this->new, 1, 1, 'enum', 'pCreate_alias_domain_alias' , 'pCreate_alias_domain_alias_text' , '',
|
||||
'alias_domain' => pacol(
|
||||
$this->new,
|
||||
1,
|
||||
1,
|
||||
'enum',
|
||||
'pCreate_alias_domain_alias',
|
||||
'pCreate_alias_domain_alias_text',
|
||||
'',
|
||||
/*options, filled below*/ array(),
|
||||
/* multiopt */ array('linkto' => 'list-virtual.php?domain=%s') ),
|
||||
'target_domain' => pacol( 1, 1, 1, 'enum', 'pCreate_alias_domain_target' , 'pCreate_alias_domain_target_text', '',
|
||||
/*options*/ array() /* filled below */ ),
|
||||
/* multiopt */ array('linkto' => 'list-virtual.php?domain=%s')
|
||||
),
|
||||
'target_domain' => pacol(
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
'enum',
|
||||
'pCreate_alias_domain_target',
|
||||
'pCreate_alias_domain_target_text',
|
||||
'',
|
||||
/*options*/ array() /* filled below */
|
||||
),
|
||||
'created' => pacol(0, 0, 0, 'ts', 'created', ''),
|
||||
'modified' => pacol(0, 0, 1, 'ts', 'last_modified', ''),
|
||||
'active' => pacol(1, 1, 1, 'bool', 'active', '', 1),
|
||||
@ -40,7 +55,9 @@ class AliasdomainHandler extends PFAHandler {
|
||||
}
|
||||
|
||||
foreach ($this->struct['alias_domain']['options'] as $dom) {
|
||||
if (isset($used_targets[$dom])) unset ($this->struct['alias_domain']['options'][$dom]); # don't allow chained domain aliases (domain1 -> domain2 -> domain3)
|
||||
if (isset($used_targets[$dom])) {
|
||||
unset($this->struct['alias_domain']['options'][$dom]);
|
||||
} # don't allow chained domain aliases (domain1 -> domain2 -> domain3)
|
||||
}
|
||||
|
||||
if (count($this->struct['alias_domain']['options']) == 1) { # only one alias_domain available - filter it out from target_domain list
|
||||
@ -124,7 +141,6 @@ class AliasdomainHandler extends PFAHandler {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
@ -10,7 +10,6 @@ class CliDelete extends Shell {
|
||||
* Execution method always used for tasks
|
||||
*/
|
||||
public function execute() {
|
||||
|
||||
if (empty($this->args)) {
|
||||
$this->__interactive();
|
||||
}
|
||||
@ -33,7 +32,9 @@ class CliDelete extends Shell {
|
||||
$question = "Do you really want to delete '$address'?";
|
||||
$create = $this->in($question, array('y','n'));
|
||||
|
||||
if ($create == 'y') $this->__handle($address);
|
||||
if ($create == 'y') {
|
||||
$this->__handle($address);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -77,10 +78,10 @@ class CliDelete extends Shell {
|
||||
postfixadmin-cli $module delete <address>
|
||||
|
||||
Deletes $module <address> in non-interactive mode.
|
||||
");
|
||||
"
|
||||
);
|
||||
$this->_stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
class CliEdit extends Shell {
|
||||
|
||||
public $handler_to_use = "";
|
||||
public $new = 0;
|
||||
|
||||
@ -29,7 +28,6 @@ class CliEdit extends Shell {
|
||||
* The list of allowed params is based on $handler->struct
|
||||
*/
|
||||
private function __handle_params() {
|
||||
|
||||
$handler = new $this->handler_to_use($this->new);
|
||||
$form_fields = $handler->getStruct();
|
||||
$id_field = $handler->getId_field();
|
||||
@ -45,13 +43,16 @@ class CliEdit extends Shell {
|
||||
if ($form_fields[$key]['type'] == 'txtl') {
|
||||
$values[$key] = explode(',', $val);
|
||||
} elseif ($form_fields[$key]['type'] == 'bool') {
|
||||
if (strtolower($val) == 'y') $val = 1; # convert y to 1
|
||||
if (strtolower($val) == 'n') $val = 0; # convert n to 0
|
||||
if (strtolower($val) == 'y') {
|
||||
$val = 1;
|
||||
} # convert y to 1
|
||||
if (strtolower($val) == 'n') {
|
||||
$val = 0;
|
||||
} # convert n to 0
|
||||
$values[$key] = $val; # don't modify any other value - *Handler will complain if it's invalid ;-)
|
||||
} else {
|
||||
$values[$key] = $val;
|
||||
}
|
||||
|
||||
} elseif ($key == 'webroot') {
|
||||
# always set, ignore
|
||||
} else { # not editable, unknown field etc.
|
||||
@ -60,7 +61,9 @@ class CliEdit extends Shell {
|
||||
}
|
||||
}
|
||||
|
||||
if ($param_error) $this->_stop(1);
|
||||
if ($param_error) {
|
||||
$this->_stop(1);
|
||||
}
|
||||
|
||||
$this->__handle($this->args[0], $values);
|
||||
}
|
||||
@ -69,7 +72,6 @@ class CliEdit extends Shell {
|
||||
* Interactive mode
|
||||
*/
|
||||
private function __interactive() {
|
||||
|
||||
$handler = new $this->handler_to_use($this->new);
|
||||
|
||||
$form_fields = $handler->getStruct();
|
||||
@ -99,9 +101,7 @@ class CliEdit extends Shell {
|
||||
$form_fields = $handler->getStruct();
|
||||
|
||||
foreach ($form_fields as $key => $field) {
|
||||
|
||||
if ($field['editable'] && $field['display_in_form'] && $key != $id_field) {
|
||||
|
||||
while (0==0) { # endlees loop - except if input is valid
|
||||
$question = $field['label'] . ':';
|
||||
if ($field['desc'] != '') {
|
||||
@ -116,12 +116,11 @@ class CliEdit extends Shell {
|
||||
} else {
|
||||
$values[$key] = 0;
|
||||
}
|
||||
|
||||
} elseif ($field['type'] == 'enum') {
|
||||
$optiontxt = array();
|
||||
$optionlist = array();
|
||||
|
||||
foreach ($field['options'] AS $optionkey => $optionval) {
|
||||
foreach ($field['options'] as $optionkey => $optionval) {
|
||||
// $this->in hates number 0
|
||||
$optionkey = $optionkey + 1;
|
||||
$optiontxt[] = '['.$optionkey.'] - '.$optionval;
|
||||
@ -133,7 +132,6 @@ class CliEdit extends Shell {
|
||||
$values[$key] = $this->in($question, $optionlist);
|
||||
|
||||
$values[$key] = $field['options'][$values[$key]-1]; # convert int to option name
|
||||
|
||||
} elseif ($field['type'] == 'txtl') {
|
||||
$values[$key] = array();
|
||||
$nextval = $this->in($question);
|
||||
@ -143,7 +141,6 @@ class CliEdit extends Shell {
|
||||
}
|
||||
$nextval = $this->in("");
|
||||
}
|
||||
|
||||
} else {
|
||||
$values[$key] = $this->in($question);
|
||||
}
|
||||
@ -168,7 +165,6 @@ echo "*** value of $key is NULL - this should not happen! ***";
|
||||
break;
|
||||
}
|
||||
} # end while
|
||||
|
||||
} # end if $field[editable] etc.
|
||||
} # end foreach
|
||||
|
||||
@ -179,7 +175,6 @@ echo "*** value of $key is NULL - this should not happen! ***";
|
||||
* (try to) store values
|
||||
*/
|
||||
private function __handle($id, $values) {
|
||||
|
||||
$handler = new $this->handler_to_use($this->new);
|
||||
if (!$handler->init($id)) {
|
||||
$this->err($handler->errormsg);
|
||||
@ -230,7 +225,8 @@ echo "*** value of $key is NULL - this should not happen! ***";
|
||||
$cmdtext $module in non-interactive mode.
|
||||
|
||||
Available options are:
|
||||
");
|
||||
"
|
||||
);
|
||||
|
||||
$handler = new $this->handler_to_use($this->new);
|
||||
|
||||
@ -242,7 +238,9 @@ echo "*** value of $key is NULL - this should not happen! ***";
|
||||
$optkey = str_replace('_', '-', $key);
|
||||
$this->out(" --$optkey");
|
||||
$this->out(" " . $field['label']);
|
||||
if ($field['desc']) $this->out(" " . $field['desc']);
|
||||
if ($field['desc']) {
|
||||
$this->out(" " . $field['desc']);
|
||||
}
|
||||
$this->out("");
|
||||
}
|
||||
}
|
||||
@ -251,6 +249,5 @@ echo "*** value of $key is NULL - this should not happen! ***";
|
||||
|
||||
$this->_stop();
|
||||
}
|
||||
|
||||
}
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
@ -2,7 +2,6 @@
|
||||
# $Id$
|
||||
|
||||
class CliHelp extends Shell {
|
||||
|
||||
public $handler_to_use = "__not_set__";
|
||||
|
||||
/**
|
||||
@ -15,7 +14,6 @@ class CliHelp extends Shell {
|
||||
}
|
||||
|
||||
public function help() {
|
||||
|
||||
$handler = new $this->handler_to_use;
|
||||
# TODO: adjust help text according to $handler->taskNames
|
||||
|
||||
@ -26,7 +24,8 @@ class CliHelp extends Shell {
|
||||
"Usage:
|
||||
|
||||
postfixadmin-cli $module <task> [<address>] [--option value]
|
||||
");
|
||||
"
|
||||
);
|
||||
/*
|
||||
View $module in interactive mode.
|
||||
|
||||
@ -58,8 +57,6 @@ class CliHelp extends Shell {
|
||||
$this->out("{$cmd}\n\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
@ -7,7 +7,6 @@
|
||||
*/
|
||||
|
||||
class CliScheme extends Shell {
|
||||
|
||||
public $handler_to_use = "";
|
||||
public $new = 0;
|
||||
|
||||
@ -16,7 +15,6 @@ class CliScheme extends Shell {
|
||||
* Execution method always used for tasks
|
||||
*/
|
||||
public function execute() {
|
||||
|
||||
$module = preg_replace('/Handler$/', '', $this->handler_to_use);
|
||||
$module = strtolower($module);
|
||||
|
||||
@ -95,10 +93,10 @@ class CliScheme extends Shell {
|
||||
Print the $module database scheme in a way that can be
|
||||
pasted into upgrade.php.
|
||||
|
||||
");
|
||||
"
|
||||
);
|
||||
|
||||
$this->_stop();
|
||||
}
|
||||
|
||||
}
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
@ -10,7 +10,6 @@ class CliView extends Shell {
|
||||
* Execution method always used for tasks
|
||||
*/
|
||||
public function execute() {
|
||||
|
||||
if (empty($this->args)) {
|
||||
$this->__interactive();
|
||||
}
|
||||
@ -81,7 +80,6 @@ class CliView extends Shell {
|
||||
$this->out(sprintf("%20s: %s", $struct[$field]['label'], $value));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -105,10 +103,10 @@ class CliView extends Shell {
|
||||
postfixadmin-cli $module view <address>
|
||||
|
||||
View $module <address> in non-interactive mode.
|
||||
");
|
||||
"
|
||||
);
|
||||
$this->_stop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
@ -4,7 +4,6 @@
|
||||
# This class is too static - if you inherit a class from it, it will share the static $instance and all its contents
|
||||
# Therefore the class is marked as final to prevent someone accidently does this ;-)
|
||||
final class Config {
|
||||
|
||||
private static $instance = null;
|
||||
|
||||
# do not error_log() 'undefined config option' for deprecated options
|
||||
@ -62,7 +61,6 @@ final class Config {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -81,7 +79,7 @@ final class Config {
|
||||
|
||||
if ($var === 'all') {
|
||||
$return = array();
|
||||
foreach ($_this AS $key =>$var) {
|
||||
foreach ($_this as $key =>$var) {
|
||||
$return[$key] = $var;
|
||||
}
|
||||
return $return;
|
||||
@ -130,7 +128,9 @@ final class Config {
|
||||
|
||||
# check if sprintf changed something - if not, there are chances that $text didn't contain a %s
|
||||
if ($text == $newtext) {
|
||||
if (is_array($var)) $var = join('.', $var);
|
||||
if (is_array($var)) {
|
||||
$var = join('.', $var);
|
||||
}
|
||||
error_log("$var used via read_f, but nothing replaced (value $value)");
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@ final class Config {
|
||||
}
|
||||
|
||||
|
||||
function getAll() {
|
||||
public function getAll() {
|
||||
$output = $this->config;
|
||||
return $output;
|
||||
}
|
||||
@ -221,7 +221,6 @@ final class Config {
|
||||
}
|
||||
return $name;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
@ -5,7 +5,6 @@
|
||||
* Handlers User level alias actions - e.g. add alias, get aliases, update etc.
|
||||
*/
|
||||
class DomainHandler extends PFAHandler {
|
||||
|
||||
protected $db_table = 'domain';
|
||||
protected $id_field = 'domain';
|
||||
protected $domain_field = 'domain';
|
||||
@ -47,64 +46,178 @@ class DomainHandler extends PFAHandler {
|
||||
$this->struct=array(
|
||||
# field name allow display in... type $PALANG label $PALANG description default / options / ...
|
||||
# editing? form list
|
||||
'domain' => pacol( $this->new, 1, 1, 'text', 'domain' , '' , '', '',
|
||||
array('linkto' => 'list-virtual.php?domain=%s') ),
|
||||
'domain' => pacol(
|
||||
$this->new,
|
||||
1,
|
||||
1,
|
||||
'text',
|
||||
'domain',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
array('linkto' => 'list-virtual.php?domain=%s')
|
||||
),
|
||||
'description' => pacol($super, $super, $super, 'text', 'description', ''),
|
||||
|
||||
# Aliases
|
||||
'aliases' => pacol($super, $super, 0, 'num', 'aliases', 'pAdminEdit_domain_aliases_text', Config::read('aliases')),
|
||||
'alias_count' => pacol( 0, 0, 1, 'vnum', '' , '' , '', '',
|
||||
'alias_count' => pacol(
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
'vnum',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
/*not_in_db*/ 0,
|
||||
/*dont_write_to_db*/ 1,
|
||||
/*select*/ 'coalesce(__alias_count,0) - coalesce(__mailbox_count,0) as alias_count',
|
||||
/*extrafrom*/ 'left join ( select count(*) as __alias_count, domain as __alias_domain from ' . table_by_key('alias') .
|
||||
' group by domain) as __alias on domain = __alias_domain'),
|
||||
'aliases_quot' => pacol( 0, 0, 1, 'quot', 'aliases' , '' , 0, '',
|
||||
array('select' => db_quota_text( '__alias_count - coalesce(__mailbox_count,0)', 'aliases', 'aliases_quot')) ),
|
||||
'_aliases_quot_percent' => pacol( 0, 0, 1, 'vnum', '' ,'' , 0, '',
|
||||
array('select' => db_quota_percent('__alias_count - coalesce(__mailbox_count,0)', 'aliases', '_aliases_quot_percent')) ),
|
||||
' group by domain) as __alias on domain = __alias_domain'
|
||||
),
|
||||
'aliases_quot' => pacol(
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
'quot',
|
||||
'aliases',
|
||||
'',
|
||||
0,
|
||||
'',
|
||||
array('select' => db_quota_text('__alias_count - coalesce(__mailbox_count,0)', 'aliases', 'aliases_quot'))
|
||||
),
|
||||
'_aliases_quot_percent' => pacol(
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
'vnum',
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
'',
|
||||
array('select' => db_quota_percent('__alias_count - coalesce(__mailbox_count,0)', 'aliases', '_aliases_quot_percent'))
|
||||
),
|
||||
|
||||
# Mailboxes
|
||||
'mailboxes' => pacol($super, $super, 0, 'num', 'mailboxes', 'pAdminEdit_domain_aliases_text', Config::read('mailboxes')),
|
||||
'mailbox_count' => pacol( 0, 0, 1, 'vnum', '' , '' , '', '',
|
||||
'mailbox_count' => pacol(
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
'vnum',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
/*not_in_db*/ 0,
|
||||
/*dont_write_to_db*/ 1,
|
||||
/*select*/ 'coalesce(__mailbox_count,0) as mailbox_count',
|
||||
/*extrafrom*/ 'left join ( select count(*) as __mailbox_count, sum(quota) as __total_quota, domain as __mailbox_domain from ' . table_by_key('mailbox') .
|
||||
' group by domain) as __mailbox on domain = __mailbox_domain'),
|
||||
'mailboxes_quot' => pacol( 0, 0, 1, 'quot', 'mailboxes' , '' , 0, '',
|
||||
array('select' => db_quota_text( '__mailbox_count', 'mailboxes', 'mailboxes_quot')) ),
|
||||
'_mailboxes_quot_percent' => pacol( 0, 0, 1, 'vnum', '' , '' , 0, '',
|
||||
array('select' => db_quota_percent('__mailbox_count', 'mailboxes', '_mailboxes_quot_percent')) ),
|
||||
' group by domain) as __mailbox on domain = __mailbox_domain'
|
||||
),
|
||||
'mailboxes_quot' => pacol(
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
'quot',
|
||||
'mailboxes',
|
||||
'',
|
||||
0,
|
||||
'',
|
||||
array('select' => db_quota_text('__mailbox_count', 'mailboxes', 'mailboxes_quot'))
|
||||
),
|
||||
'_mailboxes_quot_percent' => pacol(
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
'vnum',
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
'',
|
||||
array('select' => db_quota_percent('__mailbox_count', 'mailboxes', '_mailboxes_quot_percent'))
|
||||
),
|
||||
|
||||
'maxquota' => pacol($editquota, $editquota, $quota, 'num', 'pOverview_get_quota', 'pAdminEdit_domain_maxquota_text', Config::read('maxquota')),
|
||||
|
||||
# Domain quota
|
||||
'quota' => pacol($edit_dom_q, $edit_dom_q, 0, 'num', 'pAdminEdit_domain_quota', 'pAdminEdit_domain_maxquota_text', Config::read('domain_quota_default')),
|
||||
'total_quota' => pacol( 0, 0, 1, 'vnum', '' , '' , '', '',
|
||||
array('select' => "$query_used_domainquota AS total_quota") /*extrafrom*//* already in mailbox_count */ ),
|
||||
'total_quot' => pacol( 0, 0, $dom_q, 'quot', 'pAdminEdit_domain_quota' , '' , 0, '',
|
||||
array('select' => db_quota_text( $query_used_domainquota, 'quota', 'total_quot')) ),
|
||||
'_total_quot_percent'=> pacol( 0, 0, $dom_q, 'vnum', '' , '' , 0, '',
|
||||
array('select' => db_quota_percent($query_used_domainquota, 'quota', '_total_quot_percent')) ),
|
||||
'total_quota' => pacol(
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
'vnum',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
array('select' => "$query_used_domainquota AS total_quota") /*extrafrom*//* already in mailbox_count */
|
||||
),
|
||||
'total_quot' => pacol(
|
||||
0,
|
||||
0,
|
||||
$dom_q,
|
||||
'quot',
|
||||
'pAdminEdit_domain_quota',
|
||||
'',
|
||||
0,
|
||||
'',
|
||||
array('select' => db_quota_text($query_used_domainquota, 'quota', 'total_quot'))
|
||||
),
|
||||
'_total_quot_percent'=> pacol(
|
||||
0,
|
||||
0,
|
||||
$dom_q,
|
||||
'vnum',
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
'',
|
||||
array('select' => db_quota_percent($query_used_domainquota, 'quota', '_total_quot_percent'))
|
||||
),
|
||||
|
||||
'transport' => pacol( $transp, $transp,$transp,'enum', 'transport' , 'pAdminEdit_domain_transport_text' , Config::read('transport_default') ,
|
||||
/*options*/ Config::read('transport_options') ),
|
||||
'transport' => pacol(
|
||||
$transp,
|
||||
$transp,
|
||||
$transp,
|
||||
'enum',
|
||||
'transport',
|
||||
'pAdminEdit_domain_transport_text',
|
||||
Config::read('transport_default'),
|
||||
/*options*/ Config::read('transport_options')
|
||||
),
|
||||
'backupmx' => pacol($super, $super, 1, 'bool', 'pAdminEdit_domain_backupmx', '', 0),
|
||||
'active' => pacol($super, $super, 1, 'bool', 'active', '', 1),
|
||||
'default_aliases' => pacol($this->new, $this->new, 0, 'bool', 'pAdminCreate_domain_defaultaliases', '', 1, '', /*not in db*/ 1),
|
||||
'created' => pacol(0, 0, 0, 'ts', 'created', ''),
|
||||
'modified' => pacol(0, 0, $super, 'ts', 'last_modified', ''),
|
||||
'_can_edit' => pacol( 0, 0, 1, 'int', '' , '' , 0 ,
|
||||
'_can_edit' => pacol(
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
'int',
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
/*options*/ '',
|
||||
/*not_in_db*/ 0,
|
||||
/*dont_write_to_db*/ 1,
|
||||
/*select*/ $this->is_superadmin . ' as _can_edit' ),
|
||||
'_can_delete' => pacol( 0, 0, 1, 'int', '' , '' , 0 ,
|
||||
/*select*/ $this->is_superadmin . ' as _can_edit'
|
||||
),
|
||||
'_can_delete' => pacol(
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
'int',
|
||||
'',
|
||||
'',
|
||||
0,
|
||||
/*options*/ '',
|
||||
/*not_in_db*/ 0,
|
||||
/*dont_write_to_db*/ 1,
|
||||
/*select*/ $this->is_superadmin . ' as _can_delete' ),
|
||||
/*select*/ $this->is_superadmin . ' as _can_delete'
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
@ -248,9 +361,15 @@ class DomainHandler extends PFAHandler {
|
||||
*
|
||||
* @param array values of current item
|
||||
*/
|
||||
public function _formatted_aliases ($item) { return $item['alias_count'] . ' / ' . $item['aliases'] ; }
|
||||
public function _formatted_mailboxes($item) { return $item['mailbox_count'] . ' / ' . $item['mailboxes']; }
|
||||
public function _formatted_quota ($item) { return $item['total_quota'] . ' / ' . $item['quota'] ; }
|
||||
public function _formatted_aliases($item) {
|
||||
return $item['alias_count'] . ' / ' . $item['aliases'] ;
|
||||
}
|
||||
public function _formatted_mailboxes($item) {
|
||||
return $item['mailbox_count'] . ' / ' . $item['mailboxes'];
|
||||
}
|
||||
public function _formatted_quota($item) {
|
||||
return $item['total_quota'] . ' / ' . $item['quota'] ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after a domain has been added
|
||||
@ -278,10 +397,10 @@ class DomainHandler extends PFAHandler {
|
||||
if (0!=$retval) {
|
||||
error_log("Running $command yielded return value=$retval, first line of output=$firstline");
|
||||
$this->errormsg[] = 'Problems running domain postcreation script!';
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -310,11 +429,10 @@ class DomainHandler extends PFAHandler {
|
||||
if (0!=$retval) {
|
||||
error_log("Running $command yielded return value=$retval, first line of output=$firstline");
|
||||
$this->errormsg[] = 'Problems running domain postdeletion script!';
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
@ -5,7 +5,6 @@
|
||||
* Handler for fetchmail jobs
|
||||
*/
|
||||
class FetchmailHandler extends PFAHandler {
|
||||
|
||||
protected $db_table = 'fetchmail';
|
||||
protected $id_field = 'id';
|
||||
protected $domain_field = 'domain';
|
||||
@ -175,7 +174,6 @@ class FetchmailHandler extends PFAHandler {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
@ -5,7 +5,6 @@
|
||||
* Simple class to represent a user.
|
||||
*/
|
||||
class MailboxHandler extends PFAHandler {
|
||||
|
||||
protected $db_table = 'mailbox';
|
||||
protected $id_field = 'username';
|
||||
protected $domain_field = 'domain';
|
||||
@ -19,13 +18,28 @@ class MailboxHandler extends PFAHandler {
|
||||
# editing? form list
|
||||
'username' => pacol($this->new, 1, 1, 'mail', 'pEdit_mailbox_username', '', ''),
|
||||
'local_part' => pacol($this->new, 0, 0, 'text', 'pEdit_mailbox_username', '', ''),
|
||||
'domain' => pacol( $this->new, 0, 1, 'enum', '' , '' , '',
|
||||
/*options*/ $this->allowed_domains ),
|
||||
'domain' => pacol(
|
||||
$this->new,
|
||||
0,
|
||||
1,
|
||||
'enum',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
/*options*/ $this->allowed_domains
|
||||
),
|
||||
# TODO: maildir: display in list is needed to include maildir in SQL result (for post_edit hook)
|
||||
# TODO: (not a perfect solution, but works for now - maybe we need a separate "include in SELECT query" field?)
|
||||
'maildir' => pacol($this->new, 0, 1, 'text', '', '', ''),
|
||||
'password' => pacol(1, 1, 0, 'pass', 'password', 'pCreate_mailbox_password_text', ''),
|
||||
'password2' => pacol( 1, 1, 0, 'pass', 'password_again' , '' , '',
|
||||
'password2' => pacol(
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
'pass',
|
||||
'password_again',
|
||||
'',
|
||||
'',
|
||||
/*options*/ '',
|
||||
/*not_in_db*/ 0,
|
||||
/*dont_write_to_db*/ 1,
|
||||
@ -36,9 +50,17 @@ class MailboxHandler extends PFAHandler {
|
||||
# read_from_db_postprocess() also sets 'quotabytes' for use in init()
|
||||
# TODO: read used quota from quota/quota2 table
|
||||
'active' => pacol(1, 1, 1, 'bool', 'active', '', 1),
|
||||
'welcome_mail' => pacol( $this->new, $this->new, 0, 'bool', 'pCreate_mailbox_mail' , '' , 1,
|
||||
'welcome_mail' => pacol(
|
||||
$this->new,
|
||||
$this->new,
|
||||
0,
|
||||
'bool',
|
||||
'pCreate_mailbox_mail',
|
||||
'',
|
||||
1,
|
||||
/*options*/ '',
|
||||
/*not_in_db*/ 1 ),
|
||||
/*not_in_db*/ 1
|
||||
),
|
||||
'phone' => pacol(1, $passwordReset, 0, 'text', 'pCreate_mailbox_phone', 'pCreate_mailbox_phone_desc', ''),
|
||||
'email_other' => pacol(1, $passwordReset, 0, 'mail', 'pCreate_mailbox_email', 'pCreate_mailbox_email_desc', ''),
|
||||
'token' => pacol(1, 0, 0, 'text', '', ''),
|
||||
@ -49,7 +71,9 @@ class MailboxHandler extends PFAHandler {
|
||||
);
|
||||
|
||||
# update allowed quota
|
||||
if (count($this->struct['domain']['options']) > 0) $this->prefill('domain', $this->struct['domain']['options'][0]);
|
||||
if (count($this->struct['domain']['options']) > 0) {
|
||||
$this->prefill('domain', $this->struct['domain']['options'][0]);
|
||||
}
|
||||
}
|
||||
|
||||
public function init($id) {
|
||||
@ -79,7 +103,9 @@ class MailboxHandler extends PFAHandler {
|
||||
* @param int - current quota
|
||||
*/
|
||||
protected function updateMaxquota($domain, $currentquota) {
|
||||
if ($domain == '') return false;
|
||||
if ($domain == '') {
|
||||
return false;
|
||||
}
|
||||
|
||||
$maxquota = $this->allowed_quota($domain, $currentquota);
|
||||
|
||||
@ -168,9 +194,15 @@ class MailboxHandler extends PFAHandler {
|
||||
private function create_allowed($domain) {
|
||||
$limit = get_domain_properties($domain);
|
||||
|
||||
if ($limit['mailboxes'] == 0) return true; # unlimited
|
||||
if ($limit['mailboxes'] < 0) return false; # disabled
|
||||
if ($limit['mailbox_count'] >= $limit['mailboxes']) return false;
|
||||
if ($limit['mailboxes'] == 0) {
|
||||
return true;
|
||||
} # unlimited
|
||||
if ($limit['mailboxes'] < 0) {
|
||||
return false;
|
||||
} # disabled
|
||||
if ($limit['mailbox_count'] >= $limit['mailboxes']) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -202,7 +234,6 @@ class MailboxHandler extends PFAHandler {
|
||||
|
||||
|
||||
protected function beforestore() {
|
||||
|
||||
if (isset($this->values['quota']) && $this->values['quota'] != -1) {
|
||||
$this->values['quota'] = $this->values['quota'] * Config::read('quota_multiplier'); # convert quota from MB to bytes
|
||||
}
|
||||
@ -241,9 +272,7 @@ class MailboxHandler extends PFAHandler {
|
||||
}
|
||||
|
||||
protected function storemore() {
|
||||
|
||||
if ($this->new) {
|
||||
|
||||
if (!$this->mailbox_post_script()) {
|
||||
# return false; # TODO: should this be fatal?
|
||||
}
|
||||
@ -257,7 +286,6 @@ class MailboxHandler extends PFAHandler {
|
||||
if (!$this->create_mailbox_subfolders()) {
|
||||
$this->infomsg[] = Config::lang_f('pCreate_mailbox_result_succes_nosubfolders', $this->id);
|
||||
}
|
||||
|
||||
} else { # edit mode
|
||||
# alias active status is updated in before_store()
|
||||
|
||||
@ -343,7 +371,9 @@ class MailboxHandler extends PFAHandler {
|
||||
* - display password on $new if enabled in config or autogenerated
|
||||
*/
|
||||
protected function _validate_password($field, $val) {
|
||||
if (!$this->_validate_password2($field, $val)) return false;
|
||||
if (!$this->_validate_password2($field, $val)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if ($this->new && Config::read('generate_password') == 'YES' && $val == '') {
|
||||
# auto-generate new password
|
||||
@ -415,7 +445,9 @@ class MailboxHandler extends PFAHandler {
|
||||
private function send_welcome_mail() {
|
||||
$fTo = $this->id;
|
||||
$fFrom = smtp_get_admin_email();
|
||||
if(empty($fFrom) || $fFrom == 'CLI') $fFrom = $this->id;
|
||||
if (empty($fFrom) || $fFrom == 'CLI') {
|
||||
$fFrom = $this->id;
|
||||
}
|
||||
$fSubject = Config::lang('pSendmail_subject_text');
|
||||
$fBody = Config::read('welcome_text');
|
||||
|
||||
@ -528,7 +560,6 @@ class MailboxHandler extends PFAHandler {
|
||||
* @return Boolean success/failure status
|
||||
*/
|
||||
protected function mailbox_post_script() {
|
||||
|
||||
if ($this->new) {
|
||||
$cmd = Config::read('mailbox_postcreation_script');
|
||||
$warnmsg = Config::Lang('mailbox_postcreate_failed');
|
||||
@ -537,20 +568,24 @@ class MailboxHandler extends PFAHandler {
|
||||
$warnmsg = Config::Lang('mailbox_postedit_failed');
|
||||
}
|
||||
|
||||
if ( empty($cmd) ) return TRUE; # nothing to do
|
||||
if (empty($cmd)) {
|
||||
return true;
|
||||
} # nothing to do
|
||||
|
||||
list(/*NULL*/, $domain) = explode('@', $this->id);
|
||||
$quota = $this->values['quota'];
|
||||
|
||||
if (empty($this->id) || empty($domain) || empty($this->values['maildir'])) {
|
||||
trigger_error('In '.__FUNCTION__.': empty username, domain and/or maildir parameter', E_USER_ERROR);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
$cmdarg1=escapeshellarg($this->id);
|
||||
$cmdarg2=escapeshellarg($domain);
|
||||
$cmdarg3=escapeshellarg($this->values['maildir']);
|
||||
if ($quota <= 0) $quota = 0; # TODO: check if this is correct behaviour
|
||||
if ($quota <= 0) {
|
||||
$quota = 0;
|
||||
} # TODO: check if this is correct behaviour
|
||||
$cmdarg4=escapeshellarg($quota);
|
||||
$command= "$cmd $cmdarg1 $cmdarg2 $cmdarg3 $cmdarg4";
|
||||
$retval=0;
|
||||
@ -560,10 +595,10 @@ class MailboxHandler extends PFAHandler {
|
||||
if (0!=$retval) {
|
||||
error_log("Running $command yielded return value=$retval, first line of output=$firstline");
|
||||
$this->errormsg[] = $warnmsg;
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -596,10 +631,10 @@ class MailboxHandler extends PFAHandler {
|
||||
if (0!=$retval) {
|
||||
error_log("Running $command yielded return value=$retval, first line of output=$firstline");
|
||||
$this->errormsg[] = 'Problems running mailbox postdeletion script!';
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -622,17 +657,19 @@ class MailboxHandler extends PFAHandler {
|
||||
*/
|
||||
protected function create_mailbox_subfolders() {
|
||||
$create_mailbox_subdirs = Config::read('create_mailbox_subdirs');
|
||||
if ( empty($create_mailbox_subdirs) ) return TRUE;
|
||||
if (empty($create_mailbox_subdirs)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (!is_array($create_mailbox_subdirs)) {
|
||||
trigger_error('create_mailbox_subdirs must be an array', E_USER_ERROR);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
$s_host = Config::read('create_mailbox_subdirs_host');
|
||||
if (empty($s_host)) {
|
||||
trigger_error('An IMAP/POP server host ($CONF["create_mailbox_subdirs_host"]) must be configured, if sub-folders are to be created', E_USER_ERROR);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
$s_options='';
|
||||
@ -641,7 +678,7 @@ class MailboxHandler extends PFAHandler {
|
||||
if (!empty($create_mailbox_subdirs_hostoptions)) {
|
||||
if (!is_array($create_mailbox_subdirs_hostoptions)) {
|
||||
trigger_error('The $CONF["create_mailbox_subdirs_hostoptions"] parameter must be an array', E_USER_ERROR);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
foreach ($create_mailbox_subdirs_hostoptions as $o) {
|
||||
$s_options.='/'.$o;
|
||||
@ -654,7 +691,7 @@ class MailboxHandler extends PFAHandler {
|
||||
$s_port = $create_mailbox_subdirs_hostport;
|
||||
if (intval($s_port)!=$s_port) {
|
||||
trigger_error('The $CONF["create_mailbox_subdirs_hostport"] parameter must be an integer', E_USER_ERROR);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
$s_port=':'.$s_port;
|
||||
}
|
||||
@ -664,9 +701,9 @@ class MailboxHandler extends PFAHandler {
|
||||
sleep(1); # give the mail triggering the mailbox creation a chance to do its job
|
||||
|
||||
$i=@imap_open($s, $this->id, $this->values['password']);
|
||||
if (FALSE==$i) {
|
||||
if (false==$i) {
|
||||
error_log('Could not log into IMAP/POP server: ' . $this->id . ': ' . imap_last_error());
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
|
||||
$s_prefix = Config::read('create_mailbox_subdirs_prefix');
|
||||
@ -676,13 +713,13 @@ class MailboxHandler extends PFAHandler {
|
||||
if (!$res) {
|
||||
error_log('Could not create IMAP folder $f: ' . $this->id . ': ' . imap_last_error());
|
||||
@imap_close($i);
|
||||
return FALSE;
|
||||
return false;
|
||||
}
|
||||
@imap_subscribe($i, $f);
|
||||
}
|
||||
|
||||
@imap_close($i);
|
||||
return TRUE;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@ -729,7 +766,6 @@ class MailboxHandler extends PFAHandler {
|
||||
|
||||
|
||||
#TODO: more self explaining language strings!
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
@ -117,7 +117,7 @@ abstract class PFAHandler {
|
||||
# (stored separately to make the functions reuseable)
|
||||
# filled by initMsg()
|
||||
protected $msg = array(
|
||||
'can_create' => True,
|
||||
'can_create' => true,
|
||||
'confirm_delete' => 'confirm',
|
||||
'list_header' => '', # headline used in list view
|
||||
);
|
||||
@ -143,7 +143,9 @@ abstract class PFAHandler {
|
||||
$this->order_by = $this->id_field;
|
||||
}
|
||||
|
||||
if ($new) $this->new = 1;
|
||||
if ($new) {
|
||||
$this->new = 1;
|
||||
}
|
||||
|
||||
if ($is_admin) {
|
||||
$this->admin_username = $username;
|
||||
@ -174,7 +176,15 @@ abstract class PFAHandler {
|
||||
$this->initStruct();
|
||||
|
||||
if (!isset($this->struct['_can_edit'])) {
|
||||
$this->struct['_can_edit'] = pacol( 0, 0, 1, 'vnum', '' , '' , '', '',
|
||||
$this->struct['_can_edit'] = pacol(
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
'vnum',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
/*not_in_db*/ 0,
|
||||
/*dont_write_to_db*/ 1,
|
||||
/*select*/ '1 as _can_edit'
|
||||
@ -182,7 +192,15 @@ abstract class PFAHandler {
|
||||
}
|
||||
|
||||
if (!isset($this->struct['_can_delete'])) {
|
||||
$this->struct['_can_delete'] = pacol( 0, 0, 1, 'vnum', '' , '' , '', '',
|
||||
$this->struct['_can_delete'] = pacol(
|
||||
0,
|
||||
0,
|
||||
1,
|
||||
'vnum',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
'',
|
||||
/*not_in_db*/ 0,
|
||||
/*dont_write_to_db*/ 1,
|
||||
/*select*/ '1 as _can_delete'
|
||||
@ -205,7 +223,9 @@ abstract class PFAHandler {
|
||||
* to intentionally disable the check if $this->domain_field is empty, override this function
|
||||
*/
|
||||
protected function no_domain_field() {
|
||||
if ($this->admin_username != "") die('Attemp to restrict domains without setting $this->domain_field!');
|
||||
if ($this->admin_username != "") {
|
||||
die('Attemp to restrict domains without setting $this->domain_field!');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -214,7 +234,9 @@ abstract class PFAHandler {
|
||||
* to intentionally disable the check if $this->user_field is empty, override this function
|
||||
*/
|
||||
protected function no_user_field() {
|
||||
if ($this->username != '') die('Attemp to restrict users without setting $this->user_field!');
|
||||
if ($this->username != '') {
|
||||
die('Attemp to restrict users without setting $this->user_field!');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -421,7 +443,9 @@ abstract class PFAHandler {
|
||||
# validate based on field type ($this->_inp_$type)
|
||||
$func="_inp_".$row['type'];
|
||||
if (method_exists($this, $func)) {
|
||||
if (!$this->{$func}($key, $values[$key])) $valid = false;
|
||||
if (!$this->{$func}($key, $values[$key])) {
|
||||
$valid = false;
|
||||
}
|
||||
} else {
|
||||
# TODO: warning if no validation function exists?
|
||||
}
|
||||
@ -429,10 +453,14 @@ abstract class PFAHandler {
|
||||
# validate based on field name (_validate_$fieldname)
|
||||
$func="_validate_".$key;
|
||||
if (method_exists($this, $func)) {
|
||||
if (!$this->{$func}($key, $values[$key])) $valid = false;
|
||||
if (!$this->{$func}($key, $values[$key])) {
|
||||
$valid = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (isset($this->errormsg[$key]) && $this->errormsg[$key] != '') $valid = false;
|
||||
if (isset($this->errormsg[$key]) && $this->errormsg[$key] != '') {
|
||||
$valid = false;
|
||||
}
|
||||
|
||||
if ($valid) {
|
||||
$this->values[$key] = $values[$key];
|
||||
@ -501,8 +529,12 @@ abstract class PFAHandler {
|
||||
unset($db_values[$key]); # virtual field, never write it
|
||||
break;
|
||||
}
|
||||
if ($this->struct[$key]['not_in_db'] == 1) unset ($db_values[$key]); # remove 'not in db' columns
|
||||
if ($this->struct[$key]['dont_write_to_db'] == 1) unset ($db_values[$key]); # remove 'dont_write_to_db' columns
|
||||
if ($this->struct[$key]['not_in_db'] == 1) {
|
||||
unset($db_values[$key]);
|
||||
} # remove 'not in db' columns
|
||||
if ($this->struct[$key]['dont_write_to_db'] == 1) {
|
||||
unset($db_values[$key]);
|
||||
} # remove 'dont_write_to_db' columns
|
||||
}
|
||||
|
||||
if ($this->new) {
|
||||
@ -570,7 +602,6 @@ abstract class PFAHandler {
|
||||
} elseif (db_sqlite()) {
|
||||
$formatted_date = "strftime(###KEY###, '" . escape_string(Config::Lang('dateformat_mysql')) . "')";
|
||||
# $base64_decode = "base64_decode(###KEY###)";
|
||||
|
||||
} else {
|
||||
$formatted_date = "DATE_FORMAT(###KEY###, '" . escape_string(Config::Lang('dateformat_mysql')) . "')";
|
||||
# $base64_decode = "FROM_BASE64(###KEY###)"; # requires MySQL >= 5.6
|
||||
@ -589,16 +620,19 @@ abstract class PFAHandler {
|
||||
$extrafrom = "";
|
||||
foreach ($this->struct as $key=>$row) {
|
||||
if (($row['display_in_list'] != 0 || $row['display_in_form'] != 0) && $row['not_in_db'] == 0) {
|
||||
if ($row['select'] != '') $key = $row['select'];
|
||||
if ($row['select'] != '') {
|
||||
$key = $row['select'];
|
||||
}
|
||||
|
||||
if ($row['extrafrom'] != '') $extrafrom = $extrafrom . " " . $row['extrafrom'] . "\n";
|
||||
if ($row['extrafrom'] != '') {
|
||||
$extrafrom = $extrafrom . " " . $row['extrafrom'] . "\n";
|
||||
}
|
||||
|
||||
if (isset($colformat[$row['type']])) {
|
||||
$select_cols[] = str_replace('###KEY###', $key, $colformat[$row['type']]);
|
||||
} else {
|
||||
$select_cols[] = $key;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -626,7 +660,9 @@ abstract class PFAHandler {
|
||||
}
|
||||
$where = db_where_clause($condition, $this->struct, $additional_where, $searchmode);
|
||||
} else {
|
||||
if ($condition == "") $condition = '1=1';
|
||||
if ($condition == "") {
|
||||
$condition = '1=1';
|
||||
}
|
||||
$where = " WHERE ( $condition ) $additional_where";
|
||||
}
|
||||
|
||||
@ -709,7 +745,9 @@ abstract class PFAHandler {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($errors) $this->errormsg[] = Config::lang($this->msg['error_does_not_exist']);
|
||||
if ($errors) {
|
||||
$this->errormsg[] = Config::lang($this->msg['error_does_not_exist']);
|
||||
}
|
||||
# $this->errormsg[] = $result['error'];
|
||||
return false;
|
||||
}
|
||||
@ -765,7 +803,7 @@ abstract class PFAHandler {
|
||||
$username = escape_string($username);
|
||||
|
||||
$table = table_by_key($this->db_table);
|
||||
$active = db_get_boolean(True);
|
||||
$active = db_get_boolean(true);
|
||||
$query = "SELECT password FROM $table WHERE " . $this->id_field . "='$username' AND active='$active'";
|
||||
|
||||
$result = db_query($query);
|
||||
@ -785,7 +823,7 @@ abstract class PFAHandler {
|
||||
* @param string $username
|
||||
* @return false|string
|
||||
*/
|
||||
function getPasswordRecoveryCode($username) {
|
||||
public function getPasswordRecoveryCode($username) {
|
||||
if ($this->init($username)) {
|
||||
$token = generate_password();
|
||||
$updatedRows = db_update($this->db_table, $this->id_field, $username, array(
|
||||
@ -810,7 +848,7 @@ abstract class PFAHandler {
|
||||
$username = escape_string($username);
|
||||
|
||||
$table = table_by_key($this->db_table);
|
||||
$active = db_get_boolean(True);
|
||||
$active = db_get_boolean(true);
|
||||
$query = "SELECT token FROM $table WHERE " . $this->id_field . "='$username' AND token <> '' AND active='$active' AND NOW() < token_validity";
|
||||
|
||||
$result = db_query($query);
|
||||
@ -891,8 +929,12 @@ abstract class PFAHandler {
|
||||
*/
|
||||
protected function _inp_num($field, $val) {
|
||||
$valid = is_numeric($val);
|
||||
if ($val < -1) $valid = false;
|
||||
if (!$valid) $this->errormsg[$field] = Config::Lang_f('must_be_numeric', $field);
|
||||
if ($val < -1) {
|
||||
$valid = false;
|
||||
}
|
||||
if (!$valid) {
|
||||
$this->errormsg[$field] = Config::Lang_f('must_be_numeric', $field);
|
||||
}
|
||||
return $valid;
|
||||
# return (int)($val);
|
||||
}
|
||||
@ -901,7 +943,9 @@ abstract class PFAHandler {
|
||||
* check if value is (numeric) boolean - in other words: 0 or 1
|
||||
*/
|
||||
protected function _inp_bool($field, $val) {
|
||||
if ($val == "0" || $val == "1") return true;
|
||||
if ($val == "0" || $val == "1") {
|
||||
return true;
|
||||
}
|
||||
$this->errormsg[$field] = Config::Lang_f('must_be_boolean', $field);
|
||||
return false;
|
||||
# return $val ? db_get_boolean(true): db_get_boolean(false);
|
||||
@ -911,7 +955,9 @@ abstract class PFAHandler {
|
||||
* check if value of an enum field is in the list of allowed values
|
||||
*/
|
||||
protected function _inp_enum($field, $val) {
|
||||
if(in_array($val, $this->struct[$field]['options'])) return true;
|
||||
if (in_array($val, $this->struct[$field]['options'])) {
|
||||
return true;
|
||||
}
|
||||
$this->errormsg[$field] = Config::Lang_f('invalid_value_given', $field);
|
||||
return false;
|
||||
}
|
||||
@ -920,7 +966,9 @@ abstract class PFAHandler {
|
||||
* check if value of an enum field is in the list of allowed values
|
||||
*/
|
||||
protected function _inp_enma($field, $val) {
|
||||
if(array_key_exists($val, $this->struct[$field]['options'])) return true;
|
||||
if (array_key_exists($val, $this->struct[$field]['options'])) {
|
||||
return true;
|
||||
}
|
||||
$this->errormsg[$field] = Config::Lang_f('invalid_value_given', $field);
|
||||
return false;
|
||||
}
|
||||
@ -931,11 +979,12 @@ abstract class PFAHandler {
|
||||
protected function _inp_pass($field, $val) {
|
||||
$validpass = validate_password($val); # returns array of error messages, or empty array on success
|
||||
|
||||
if(count($validpass) == 0) return true;
|
||||
if (count($validpass) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->errormsg[$field] = $validpass[0]; # TODO: honor all error messages, not only the first one?
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
@ -2,12 +2,11 @@
|
||||
# $Id$
|
||||
|
||||
class VacationHandler extends PFAHandler {
|
||||
|
||||
protected $db_table = 'vacation';
|
||||
protected $id_field = 'email';
|
||||
protected $domain_field = 'domain';
|
||||
|
||||
function init($id) {
|
||||
public function init($id) {
|
||||
die('VacationHandler is not yet ready to be used with *Handler methods'); # obvious TODO: remove when it's ready ;-)
|
||||
}
|
||||
|
||||
@ -30,7 +29,6 @@ class VacationHandler extends PFAHandler {
|
||||
if (! db_pgsql()) {
|
||||
$this->struct['cache'] = pacol(0, 0, 0, 'text', '', '', ''); # leftover from 2.2
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected function initMsg() {
|
||||
@ -72,14 +70,13 @@ class VacationHandler extends PFAHandler {
|
||||
public function delete() {
|
||||
$this->errormsg[] = '*** deletion not implemented yet ***';
|
||||
return false; # XXX function aborts here! XXX
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
protected $username = null;
|
||||
function __construct($username) {
|
||||
public function __construct($username) {
|
||||
$this->username = $username;
|
||||
$this->id = $username;
|
||||
}
|
||||
@ -89,8 +86,10 @@ class VacationHandler extends PFAHandler {
|
||||
* set the vacation table record to false.
|
||||
* @return boolean true on success.
|
||||
*/
|
||||
function remove() {
|
||||
if (!$this->updateAlias(0)) return false;
|
||||
public function remove() {
|
||||
if (!$this->updateAlias(0)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// tidy up vacation table.
|
||||
$vacation_data = array(
|
||||
@ -106,7 +105,7 @@ class VacationHandler extends PFAHandler {
|
||||
/**
|
||||
* @return boolean true indicates this server supports vacation messages, and users are able to change their own.
|
||||
*/
|
||||
function vacation_supported() {
|
||||
public function vacation_supported() {
|
||||
return Config::bool('vacation') && Config::bool('vacation_control');
|
||||
}
|
||||
|
||||
@ -114,7 +113,7 @@ class VacationHandler extends PFAHandler {
|
||||
* @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() {
|
||||
public function check_vacation() {
|
||||
$handler = new AliasHandler();
|
||||
|
||||
if (!$handler->init($this->id)) {
|
||||
@ -129,7 +128,9 @@ class VacationHandler extends PFAHandler {
|
||||
|
||||
$result = $handler->result();
|
||||
|
||||
if ($result['on_vacation']) return true;
|
||||
if ($result['on_vacation']) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -138,7 +139,7 @@ class VacationHandler extends PFAHandler {
|
||||
* @return struct|boolean stored information on vacation - array(subject - string, message - string, active - boolean, activeFrom - date, activeUntil - date)
|
||||
* will return false if no existing data
|
||||
*/
|
||||
function get_details() {
|
||||
public function get_details() {
|
||||
$table_vacation = table_by_key('vacation');
|
||||
$E_username = escape_string($this->username);
|
||||
|
||||
@ -167,7 +168,7 @@ class VacationHandler extends PFAHandler {
|
||||
* @param date $activeFrom
|
||||
* @param date $activeUntil
|
||||
*/
|
||||
function set_away($subject, $body, $interval_time, $activeFrom, $activeUntil) {
|
||||
public function set_away($subject, $body, $interval_time, $activeFrom, $activeUntil) {
|
||||
$this->remove(); // clean out any notifications that might already have been sent.
|
||||
|
||||
$E_username = escape_string($this->username);
|
||||
@ -235,6 +236,5 @@ class VacationHandler extends PFAHandler {
|
||||
# still here? then everything worked
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
@ -61,8 +61,7 @@ $res = `$cmd`;
|
||||
echo $res;
|
||||
*/
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET")
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
umask(077);
|
||||
$path = (ini_get('upload_tmp_dir') != '') ? ini_get('upload_tmp_dir') : '/tmp';
|
||||
date_default_timezone_set(@date_default_timezone_get()); # Suppress date.timezone warnings
|
||||
@ -71,14 +70,11 @@ if ($_SERVER['REQUEST_METHOD'] == "GET")
|
||||
|
||||
$header = "#\n# Postfix Admin $version\n# Date: " . date("D M j G:i:s T Y") . "\n#\n";
|
||||
|
||||
if (!$fh = fopen ($backup, 'w'))
|
||||
{
|
||||
if (!$fh = fopen($backup, 'w')) {
|
||||
flash_error("<div class=\"error_msg\">Cannot open file ($backup)</div>");
|
||||
$smarty->assign('smarty_template', 'message');
|
||||
$smarty->display('index.tpl');
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
fwrite($fh, $header);
|
||||
|
||||
$tables = array(
|
||||
@ -97,25 +93,19 @@ if ($_SERVER['REQUEST_METHOD'] == "GET")
|
||||
'vacation_notification'
|
||||
);
|
||||
|
||||
for ($i = 0 ; $i < sizeof ($tables) ; ++$i)
|
||||
{
|
||||
for ($i = 0 ; $i < sizeof($tables) ; ++$i) {
|
||||
$result = db_query("SHOW CREATE TABLE " . table_by_key($tables[$i]));
|
||||
if ($result['rows'] > 0)
|
||||
{
|
||||
while ($row = db_array ($result['result']))
|
||||
{
|
||||
if ($result['rows'] > 0) {
|
||||
while ($row = db_array($result['result'])) {
|
||||
fwrite($fh, "$row[1];\n\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0 ; $i < sizeof ($tables) ; ++$i)
|
||||
{
|
||||
for ($i = 0 ; $i < sizeof($tables) ; ++$i) {
|
||||
$result = db_query("SELECT * FROM " . table_by_key($tables[$i]));
|
||||
if ($result['rows'] > 0)
|
||||
{
|
||||
while ($row = db_assoc ($result['result']))
|
||||
{
|
||||
if ($result['rows'] > 0) {
|
||||
while ($row = db_assoc($result['result'])) {
|
||||
$fields = array_keys($row);
|
||||
$values = array_values($row);
|
||||
$values = array_map('escape_string', $values);
|
||||
@ -137,4 +127,3 @@ if ($_SERVER['REQUEST_METHOD'] == "GET")
|
||||
fpassthru($download_backup);
|
||||
}
|
||||
/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
|
||||
?>
|
||||
|
@ -43,17 +43,15 @@ $error = 0;
|
||||
$smtp_from_email = smtp_get_admin_email();
|
||||
$allowed_domains = list_domains_for_admin(authentication_get_username());
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
{
|
||||
if (safepost('token') != $_SESSION['PFA_token']) die('Invalid token!');
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
if (safepost('token') != $_SESSION['PFA_token']) {
|
||||
die('Invalid token!');
|
||||
}
|
||||
|
||||
if (empty($_POST['subject']) || empty($_POST['message']) || empty($_POST['name']))
|
||||
{
|
||||
if (empty($_POST['subject']) || empty($_POST['message']) || empty($_POST['name'])) {
|
||||
$error = 1;
|
||||
flash_error($PALANG['pBroadcast_error_empty']);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$wanted_domains = array_intersect($allowed_domains, $_POST['domains']);
|
||||
|
||||
$table_mailbox = table_by_key('mailbox');
|
||||
@ -92,12 +90,9 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
|
||||
$fHeaders .= $b_message;
|
||||
|
||||
if (!smtp_mail ($fTo, $smtp_from_email, $fHeaders))
|
||||
{
|
||||
if (!smtp_mail($fTo, $smtp_from_email, $fHeaders)) {
|
||||
flash_error(Config::lang_f('pSendmail_result_error', $fTo));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
flash_info(Config::lang_f('pSendmail_result_success', $fTo));
|
||||
}
|
||||
}
|
||||
@ -109,8 +104,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET" || $error == 1)
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET" || $error == 1) {
|
||||
$smarty->assign('allowed_domains', $allowed_domains);
|
||||
$smarty->assign('smtp_from_email', $smtp_from_email);
|
||||
$smarty->assign('error', $error);
|
||||
@ -121,4 +115,3 @@ if ($_SERVER['REQUEST_METHOD'] == "GET" || $error == 1)
|
||||
}
|
||||
|
||||
/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
|
||||
?>
|
||||
|
@ -1,3 +1,2 @@
|
||||
<?php
|
||||
require_once(dirname(__FILE__) . '/../common.php');
|
||||
|
||||
|
@ -19,7 +19,9 @@
|
||||
|
||||
require_once('common.php');
|
||||
|
||||
if (safeget('token') != $_SESSION['PFA_token']) die('Invalid token!');
|
||||
if (safeget('token') != $_SESSION['PFA_token']) {
|
||||
die('Invalid token!');
|
||||
}
|
||||
|
||||
$username = authentication_get_username(); # enforce login
|
||||
|
||||
@ -56,4 +58,3 @@ header ("Location: " . $formconf['listview']);
|
||||
exit;
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
?>
|
||||
|
@ -37,7 +37,9 @@ $error = 0;
|
||||
|
||||
$edit = safepost('edit', safeget('edit'));
|
||||
$new = 0;
|
||||
if ($edit == "") $new = 1;
|
||||
if ($edit == "") {
|
||||
$new = 1;
|
||||
}
|
||||
|
||||
$is_admin = authentication_has_role('admin');
|
||||
|
||||
@ -93,7 +95,9 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
if (safepost('token') != $_SESSION['PFA_token']) die('Invalid token!');
|
||||
if (safepost('token') != $_SESSION['PFA_token']) {
|
||||
die('Invalid token!');
|
||||
}
|
||||
$inp_values = safepost('value', array());
|
||||
|
||||
foreach ($form_fields as $key => $field) {
|
||||
@ -191,7 +195,6 @@ $fielderror = array();
|
||||
|
||||
foreach ($form_fields as $key => $field) {
|
||||
if ($form_fields[$key]['display_in_form']) {
|
||||
|
||||
if (isset($errormsg[$key])) {
|
||||
$fielderror[$key] = $errormsg[$key];
|
||||
unset($errormsg[$key]);
|
||||
@ -207,7 +210,9 @@ foreach($form_fields as $key => $field) {
|
||||
}
|
||||
}
|
||||
|
||||
if (count($errormsg)) flash_error($errormsg); # display the remaining error messages (not related to a field) with flash_error
|
||||
if (count($errormsg)) {
|
||||
flash_error($errormsg);
|
||||
} # display the remaining error messages (not related to a field) with flash_error
|
||||
|
||||
if ($new) {
|
||||
$smarty->assign('mode', 'create');
|
||||
@ -226,4 +231,3 @@ $smarty->assign ('smarty_template', 'editform');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
?>
|
||||
|
@ -19,7 +19,9 @@
|
||||
|
||||
require_once('common.php');
|
||||
|
||||
if (safeget('token') != $_SESSION['PFA_token']) die('Invalid token!');
|
||||
if (safeget('token') != $_SESSION['PFA_token']) {
|
||||
die('Invalid token!');
|
||||
}
|
||||
|
||||
$username = authentication_get_username(); # enforce login
|
||||
|
||||
@ -56,4 +58,3 @@ header ("Location: " . $formconf['listview']);
|
||||
exit;
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
?>
|
||||
|
@ -14,4 +14,3 @@
|
||||
//
|
||||
header("Location: ../login.php");
|
||||
exit;
|
||||
?>
|
||||
|
@ -20,14 +20,13 @@
|
||||
* Form POST \ GET Variables: -none-
|
||||
*/
|
||||
|
||||
$CONF = array('configured' => FALSE);
|
||||
$CONF = array('configured' => false);
|
||||
|
||||
if (file_exists(dirname(__FILE__) . '/../config.inc.php')) {
|
||||
require_once(dirname(__FILE__) . '/../config.inc.php');
|
||||
}
|
||||
|
||||
if ( $CONF['configured'] === TRUE )
|
||||
{
|
||||
if ($CONF['configured'] === true) {
|
||||
header("Location: login.php");
|
||||
exit;
|
||||
}
|
||||
|
@ -95,13 +95,15 @@ if (Config::bool('alias_domain')) {
|
||||
'msg' => $handler->getMsg(),
|
||||
'formconf' => $formconf,
|
||||
);
|
||||
$aliasdomain_data['msg']['show_simple_search'] = False; # hide search box
|
||||
$aliasdomain_data['msg']['show_simple_search'] = false; # hide search box
|
||||
|
||||
$aliasdomain_data['msg']['can_create'] = 1;
|
||||
|
||||
# hide create button if all domains (of this admin) are already used as alias domains
|
||||
$handler->getList("");
|
||||
if ( count($handler->result()) + 1 >= count($list_domains) ) $aliasdomain_data['msg']['can_create'] = 0; # all domains (of this admin) are already alias domains
|
||||
if (count($handler->result()) + 1 >= count($list_domains)) {
|
||||
$aliasdomain_data['msg']['can_create'] = 0;
|
||||
} # all domains (of this admin) are already alias domains
|
||||
|
||||
# get the really requested list
|
||||
if (count($search) == 0) {
|
||||
@ -150,7 +152,7 @@ $alias_data = array(
|
||||
);
|
||||
$alias_data['struct']['goto_mailbox']['display_in_list'] = 0; # not useful/defined for non-mailbox aliases
|
||||
$alias_data['struct']['on_vacation']['display_in_list'] = 0;
|
||||
$alias_data['msg']['show_simple_search'] = False; # hide search box
|
||||
$alias_data['msg']['show_simple_search'] = false; # hide search box
|
||||
|
||||
$handler->getList($search_alias, array(), $page_size, $fDisplay);
|
||||
$pagebrowser_alias = $handler->getPagebrowser($search_alias, array());
|
||||
@ -245,7 +247,7 @@ if ($result['rows'] > 0) {
|
||||
$row['active']=('t'==$row['active']) ? 1 : 0;
|
||||
|
||||
if (Config::bool('vacation_control_admin')) {
|
||||
if($row['v_active'] == NULL) {
|
||||
if ($row['v_active'] == null) {
|
||||
$row['v_active'] = 'f';
|
||||
}
|
||||
$row['v_active']=('t'==$row['v_active']) ? 1 : 0;
|
||||
@ -283,15 +285,13 @@ if (isset ($limit)) {
|
||||
|
||||
if ($limit['aliases'] == 0) {
|
||||
$alias_data['msg']['can_create'] = true;
|
||||
}
|
||||
elseif($limit['alias_count'] < $limit['aliases']) {
|
||||
} elseif ($limit['alias_count'] < $limit['aliases']) {
|
||||
$alias_data['msg']['can_create'] = true;
|
||||
}
|
||||
|
||||
if ($limit['mailboxes'] == 0) {
|
||||
$tCanAddMailbox = true;
|
||||
}
|
||||
elseif($limit['mailbox_count'] < $limit['mailboxes']) {
|
||||
} elseif ($limit['mailbox_count'] < $limit['mailboxes']) {
|
||||
$tCanAddMailbox = true;
|
||||
}
|
||||
|
||||
@ -314,8 +314,7 @@ if ((is_array ($tMailbox) and sizeof ($tMailbox) > 0)) {
|
||||
if (isset($tMailbox[$i]['quota'])) {
|
||||
$divide_quota ['quota'][$i] = divide_quota($tMailbox[$i]['quota']);
|
||||
}
|
||||
if(isset($tMailbox[$i]['quota']) && isset($tMailbox[$i]['current']))
|
||||
{
|
||||
if (isset($tMailbox[$i]['quota']) && isset($tMailbox[$i]['current'])) {
|
||||
$divide_quota ['percent'][$i] = min(100, round(($divide_quota ['current'][$i]/max(1, $divide_quota ['quota'][$i]))*100));
|
||||
$divide_quota ['quota_width'][$i] = ($divide_quota ['percent'][$i] / 100 * 120);
|
||||
} else {
|
||||
@ -326,15 +325,21 @@ if ((is_array ($tMailbox) and sizeof ($tMailbox) > 0)) {
|
||||
}
|
||||
|
||||
|
||||
class cNav_bar
|
||||
{
|
||||
protected $count, $title, $limit, $page_size, $pages, $search; //* arguments
|
||||
class cNav_bar {
|
||||
protected $count;
|
||||
protected $title;
|
||||
protected $limit;
|
||||
protected $page_size;
|
||||
protected $pages;
|
||||
protected $search; //* arguments
|
||||
|
||||
/* @var string - appended to page link href */
|
||||
public $append_to_url = '';
|
||||
|
||||
protected $have_run_init = false;
|
||||
protected $arr_prev, $arr_next, $arr_top; //* internal
|
||||
protected $arr_prev;
|
||||
protected $arr_next;
|
||||
protected $arr_top; //* internal
|
||||
protected $anchor;
|
||||
|
||||
public function __construct($aTitle, $aLimit, $aPage_size, $aPages, $aSearch) {
|
||||
@ -375,18 +380,19 @@ class cNav_bar
|
||||
|
||||
public function display_top() {
|
||||
$ret_val = '';
|
||||
if ($this->count < 1)
|
||||
if ($this->count < 1) {
|
||||
return $ret_val;
|
||||
if (!$this->have_run_init)
|
||||
}
|
||||
if (!$this->have_run_init) {
|
||||
$this->init();
|
||||
}
|
||||
|
||||
$ret_val .= '<a name="'.$this->anchor.'"></a>';
|
||||
$ret_val .= $this->display_pre();
|
||||
$ret_val .= '<b>'.$this->title.'</b> ';
|
||||
($this->limit >= $this->page_size) ? $highlight_at = $this->limit / $this->page_size : $highlight_at = 0;
|
||||
|
||||
for ($i = 0; $i < count ($this->pages); $i++)
|
||||
{
|
||||
for ($i = 0; $i < count($this->pages); $i++) {
|
||||
$lPage = $this->pages [$i];
|
||||
if ($i == $highlight_at) {
|
||||
$ret_val .= '<b>'.$lPage.'</b>'."\n";
|
||||
@ -406,10 +412,12 @@ class cNav_bar
|
||||
|
||||
public function display_bottom() {
|
||||
$ret_val = '';
|
||||
if ($this->count < 1)
|
||||
if ($this->count < 1) {
|
||||
return $ret_val;
|
||||
if (!$this->have_run_init)
|
||||
}
|
||||
if (!$this->have_run_init) {
|
||||
$this->init();
|
||||
}
|
||||
$ret_val .= $this->display_pre();
|
||||
$ret_val .= '</td><td valign="middle" align="right">';
|
||||
|
||||
@ -469,15 +477,16 @@ $smarty->assign ('boolconf_used_quotas', Config::bool('used_quotas'));
|
||||
$smarty->assign('divide_quota', $divide_quota);
|
||||
$smarty->assign('tCanAddMailbox', $tCanAddMailbox);
|
||||
$smarty->assign('display_mailbox_aliases', $display_mailbox_aliases);
|
||||
if (isset ($_GET ['tab']))
|
||||
if (isset($_GET ['tab'])) {
|
||||
$_SESSION ['tab'] = $_GET ['tab'];
|
||||
}
|
||||
//if (empty ($_GET ['tab']))
|
||||
// unset ($_SESSION ['tab']);
|
||||
if (!isset ($_SESSION ['tab']))
|
||||
if (!isset($_SESSION ['tab'])) {
|
||||
$_SESSION ['tab'] = 'all';
|
||||
}
|
||||
$smarty->assign('tab', $_SESSION ['tab']);
|
||||
$smarty->assign('smarty_template', 'list-virtual');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
?>
|
||||
|
@ -78,12 +78,15 @@ if (count($search)) {
|
||||
}
|
||||
$items = $handler->result();
|
||||
|
||||
if (count($handler->errormsg)) flash_error($handler->errormsg);
|
||||
if (count($handler->infomsg)) flash_error($handler->infomsg);
|
||||
if (count($handler->errormsg)) {
|
||||
flash_error($handler->errormsg);
|
||||
}
|
||||
if (count($handler->infomsg)) {
|
||||
flash_error($handler->infomsg);
|
||||
}
|
||||
|
||||
|
||||
if (safeget('output') == 'csv') {
|
||||
|
||||
$out = fopen('php://output', 'w');
|
||||
header('Content-Type: text/csv; charset=utf-8');
|
||||
header('Content-Disposition: attachment;filename='.$table.'.csv');
|
||||
@ -117,7 +120,6 @@ if (safeget('output') == 'csv') {
|
||||
}
|
||||
|
||||
fclose($out);
|
||||
|
||||
} else { # HTML output
|
||||
|
||||
$smarty->assign('admin_list', $list_admins);
|
||||
@ -133,8 +135,6 @@ if (safeget('output') == 'csv') {
|
||||
$smarty->assign('searchmode', $searchmode);
|
||||
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
?>
|
||||
|
@ -36,10 +36,10 @@ if($CONF['configured'] !== true) {
|
||||
|
||||
check_db_version(); # check if the database layout is up to date (and error out if not)
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
{
|
||||
|
||||
if (safepost('token') != $_SESSION['PFA_token']) die('Invalid token!');
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
if (safepost('token') != $_SESSION['PFA_token']) {
|
||||
die('Invalid token!');
|
||||
}
|
||||
|
||||
$lang = safepost('lang');
|
||||
$fUsername = trim(safepost('fUsername'));
|
||||
@ -52,7 +52,6 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
|
||||
$h = new AdminHandler;
|
||||
if ($h->login($fUsername, $fPassword)) {
|
||||
|
||||
init_session($fUsername, true);
|
||||
|
||||
# they've logged in, so see if they are a domain admin, as well.
|
||||
@ -73,7 +72,6 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
|
||||
header("Location: main.php");
|
||||
exit(0);
|
||||
|
||||
} else { # $h->login failed
|
||||
error_log("PostfixAdmin login failed (username: $fUsername, ip_address: {$_SERVER['REMOTE_ADDR']})");
|
||||
flash_error($PALANG['pLogin_failed']);
|
||||
@ -89,4 +87,3 @@ $smarty->assign ('forgotten_password_reset', Config::read('forgotten_admin_passw
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
?>
|
||||
|
@ -28,4 +28,4 @@ authentication_require_role('admin');
|
||||
$smarty->assign('smarty_template', 'main');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?>
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
@ -37,24 +37,23 @@ authentication_require_role('admin');
|
||||
$smtp_from_email = smtp_get_admin_email();
|
||||
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
{
|
||||
if (safepost('token') != $_SESSION['PFA_token']) die('Invalid token!');
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
if (safepost('token') != $_SESSION['PFA_token']) {
|
||||
die('Invalid token!');
|
||||
}
|
||||
|
||||
$fTo = safepost('fTo');
|
||||
$fFrom = $smtp_from_email;
|
||||
$fSubject = safepost('fSubject');
|
||||
|
||||
$tBody = $_POST['fBody'];
|
||||
if (get_magic_quotes_gpc ())
|
||||
{
|
||||
if (get_magic_quotes_gpc()) {
|
||||
$tBody = stripslashes($tBody); # TODO: check for get_magic_quotes_gpc inside safepost/safeget
|
||||
}
|
||||
|
||||
$error = 0;
|
||||
$email_check = check_email($fTo);
|
||||
if (empty ($fTo) or ($email_check != ''))
|
||||
{
|
||||
if (empty($fTo) or ($email_check != '')) {
|
||||
$error = 1;
|
||||
$tTo = escape_string($_POST['fTo']);
|
||||
$tSubject = escape_string($_POST['fSubject']);
|
||||
@ -62,8 +61,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
flash_error($email_check);
|
||||
}
|
||||
|
||||
if ($error != 1)
|
||||
{
|
||||
if ($error != 1) {
|
||||
if (!smtp_mail($fTo, $fFrom, $fSubject, $tBody)) {
|
||||
flash_error(Config::lang_f('pSendmail_result_error', $fTo));
|
||||
} else {
|
||||
@ -77,4 +75,3 @@ $smarty->display ('index.tpl');
|
||||
|
||||
|
||||
/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
|
||||
?>
|
||||
|
112
public/setup.php
112
public/setup.php
@ -65,8 +65,7 @@ $errormsg = array();
|
||||
//
|
||||
$phpversion = 'unknown-version';
|
||||
|
||||
if ($f_phpversion == 1)
|
||||
{
|
||||
if ($f_phpversion == 1) {
|
||||
if (phpversion() < 5) {
|
||||
print "<li><b>Error: Depends on: PHP v5+</b><br /></li>\n";
|
||||
$error += 1;
|
||||
@ -80,21 +79,16 @@ if ($f_phpversion == 1)
|
||||
print "<li>PHP version " . phpversion() . "</li>\n";
|
||||
}
|
||||
# TODO: check for PHP >= 5.2.3 - smarty uses htmlentities with 4 parameters. The forth parameter was added in PHP 5.2.3, older versions will give a warning
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
print "<li><b>Unable to check for PHP version. (missing function: phpversion())</b></li>\n";
|
||||
}
|
||||
|
||||
//
|
||||
// Check for Apache version
|
||||
//
|
||||
if ($f_apache_get_version == 1)
|
||||
{
|
||||
if ($f_apache_get_version == 1) {
|
||||
print "<li>" . apache_get_version() . "</li>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
# not running on Apache.
|
||||
# However postfixadmin _is_ running, so obviously we are on a supported webserver ;-))
|
||||
# No need to confuse the user with a warning.
|
||||
@ -107,19 +101,13 @@ print "<ul>\n";
|
||||
//
|
||||
// Check for Magic Quotes
|
||||
//
|
||||
if ($f_get_magic_quotes_gpc == 1)
|
||||
{
|
||||
if (get_magic_quotes_gpc () == 0)
|
||||
{
|
||||
if ($f_get_magic_quotes_gpc == 1) {
|
||||
if (get_magic_quotes_gpc() == 0) {
|
||||
print "<li>Magic Quotes: Disabled - OK</li>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
print "<li><b>Warning: Magic Quotes: ON (internal workaround used)</b></li>\n";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
print "<li><b>Unable to check for Magic Quotes. (missing function: get_magic_quotes_gpc())</b></li>\n";
|
||||
}
|
||||
|
||||
@ -127,23 +115,20 @@ else
|
||||
// Check for config.inc.php
|
||||
//
|
||||
$config_loaded = 0;
|
||||
if ($file_config == 1)
|
||||
{
|
||||
if ($file_config == 1) {
|
||||
print "<li>Depends on: presence config.inc.php - OK</li>\n";
|
||||
require_once(dirname(__FILE__) .'/../config.inc.php');
|
||||
$config_loaded = 1;
|
||||
|
||||
if (isset($CONF['configured'])) {
|
||||
if($CONF['configured'] === TRUE) {
|
||||
if ($CONF['configured'] === true) {
|
||||
print "<li>Checking \$CONF['configured'] - OK\n";
|
||||
} else {
|
||||
print "<li><b>Warning: \$CONF['configured'] is 'false'.<br>\n";
|
||||
print "You must edit your config.local.php and change this to true (this indicates you've created the database and user)</b>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
print "<li><b>Error: Depends on: presence config.inc.php - NOT FOUND</b><br /></li>\n";
|
||||
print "Create the file, and edit as appropriate (e.g. select database type etc)<br />";
|
||||
print "For example:<br />\n";
|
||||
@ -165,16 +150,14 @@ if ($file_local_config == 1) {
|
||||
//
|
||||
// Check if there is support for at least 1 database
|
||||
//
|
||||
if (($f_mysql_connect == 0) and ($f_mysqli_connect == 0) and ($f_pg_connect == 0) and ($f_sqlite_open == 0))
|
||||
{
|
||||
if (($f_mysql_connect == 0) and ($f_mysqli_connect == 0) and ($f_pg_connect == 0) and ($f_sqlite_open == 0)) {
|
||||
print "<li><b>Error: There is no database support in your PHP setup</b><br />\n";
|
||||
print "To install MySQL 3.23 or 4.0 support on FreeBSD:<br />\n";
|
||||
print "<pre>% cd /usr/ports/databases/php{$phpversion}-mysql/\n";
|
||||
print "% make clean install\n";
|
||||
print " - or with portupgrade -\n";
|
||||
print "% portinstall php{$phpversion}-mysql</pre>\n";
|
||||
if ($phpversion >= 5)
|
||||
{
|
||||
if ($phpversion >= 5) {
|
||||
print "To install MySQL 4.1 support on FreeBSD:<br />\n";
|
||||
print "<pre>% cd /usr/ports/databases/php5-mysqli/\n";
|
||||
print "% make clean install\n";
|
||||
@ -191,18 +174,15 @@ if (($f_mysql_connect == 0) and ($f_mysqli_connect == 0) and ($f_pg_connect == 0
|
||||
//
|
||||
// MySQL 3.23, 4.0 functions
|
||||
//
|
||||
if ($f_mysql_connect == 1)
|
||||
{
|
||||
if ($f_mysql_connect == 1) {
|
||||
print "<li>Depends on: MySQL 3.23, 4.0 - OK</li>\n";
|
||||
}
|
||||
|
||||
//
|
||||
// MySQL 4.1 functions
|
||||
//
|
||||
if ($phpversion >= 5)
|
||||
{
|
||||
if ($f_mysqli_connect == 1)
|
||||
{
|
||||
if ($phpversion >= 5) {
|
||||
if ($f_mysqli_connect == 1) {
|
||||
print "<li>Depends on: MySQL 4.1 - OK\n";
|
||||
if (!($config_loaded && $CONF['database_type'] == 'mysqli')) {
|
||||
print "<br>(change the database_type to 'mysqli' in config.local.php if you want to use MySQL)\n";
|
||||
@ -214,8 +194,7 @@ if ($phpversion >= 5)
|
||||
//
|
||||
// PostgreSQL functions
|
||||
//
|
||||
if ($f_pg_connect == 1)
|
||||
{
|
||||
if ($f_pg_connect == 1) {
|
||||
print "<li>Depends on: PostgreSQL - OK \n";
|
||||
if (!($config_loaded && $CONF['database_type'] == 'pgsql')) {
|
||||
print "<br>(change the database_type to 'pgsql' in config.local.php if you want to use PostgreSQL)\n";
|
||||
@ -223,8 +202,7 @@ if ($f_pg_connect == 1)
|
||||
print "</li>";
|
||||
}
|
||||
|
||||
if ($f_sqlite_open == 1)
|
||||
{
|
||||
if ($f_sqlite_open == 1) {
|
||||
print "<li>Depends on: SQLite - OK \n";
|
||||
if (!($config_loaded && db_sqlite())) {
|
||||
print "<br>(change the database_type to 'sqlite' in config.local.php if you want to use SQLite)\n";
|
||||
@ -236,7 +214,7 @@ if ($f_sqlite_open == 1)
|
||||
// Database connection
|
||||
//
|
||||
if ($config_loaded) {
|
||||
list ($link, $error_text) = db_connect(TRUE);
|
||||
list($link, $error_text) = db_connect(true);
|
||||
if ($error_text == "") {
|
||||
print "<li>Testing database connection (using {$CONF['database_type']}) - OK</li>";
|
||||
} else {
|
||||
@ -250,12 +228,9 @@ if ($config_loaded) {
|
||||
//
|
||||
// Session functions
|
||||
//
|
||||
if ($f_session_start == 1)
|
||||
{
|
||||
if ($f_session_start == 1) {
|
||||
print "<li>Depends on: session - OK</li>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
print "<li><b>Error: Depends on: session - NOT FOUND</b><br />\n";
|
||||
print "To install session support on FreeBSD:<br />\n";
|
||||
print "<pre>% cd /usr/ports/www/php$phpversion-session/\n";
|
||||
@ -268,12 +243,9 @@ else
|
||||
//
|
||||
// PCRE functions
|
||||
//
|
||||
if ($f_preg_match == 1)
|
||||
{
|
||||
if ($f_preg_match == 1) {
|
||||
print "<li>Depends on: pcre - OK</li>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
print "<li><b>Error: Depends on: pcre - NOT FOUND</b><br />\n";
|
||||
print "To install pcre support on FreeBSD:<br />\n";
|
||||
print "<pre>% cd /usr/ports/devel/php$phpversion-pcre/\n";
|
||||
@ -286,12 +258,9 @@ else
|
||||
//
|
||||
// Multibyte functions
|
||||
//
|
||||
if ( $f_mb_encode_mimeheader == 1 )
|
||||
{
|
||||
if ($f_mb_encode_mimeheader == 1) {
|
||||
print "<li>Depends on: multibyte string - OK</li>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
print "<li><b>Error: Depends on: multibyte string - NOT FOUND</b><br />\n";
|
||||
print "To install multibyte string support, install php$phpversion-mbstring</li>\n";
|
||||
$error += 1;
|
||||
@ -301,12 +270,9 @@ else
|
||||
//
|
||||
// Imap functions
|
||||
//
|
||||
if ( $f_imap_open == 1)
|
||||
{
|
||||
if ($f_imap_open == 1) {
|
||||
print "<li>Depends on: IMAP functions - OK</li>\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
print "<li><b>Warning: Depends on: IMAP functions - NOT FOUND</b><br />\n";
|
||||
print "To install IMAP support, install php$phpversion-imap<br />\n";
|
||||
print "Without IMAP support, you won't be able to create subfolders when creating mailboxes.</li>\n";
|
||||
@ -320,12 +286,9 @@ else
|
||||
|
||||
print "</ul>";
|
||||
|
||||
if ($error != 0)
|
||||
{
|
||||
if ($error != 0) {
|
||||
print "<p><b>Please fix the errors listed above.</b></p>";
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
print "<p>Everything seems fine... attempting to create/update database structure</p>\n";
|
||||
require_once(dirname(__FILE__) .'/upgrade.php');
|
||||
|
||||
@ -334,7 +297,9 @@ else
|
||||
$lostpw_error = 0;
|
||||
|
||||
$setuppw = "";
|
||||
if (isset($CONF['setup_password'])) $setuppw = $CONF['setup_password'];
|
||||
if (isset($CONF['setup_password'])) {
|
||||
$setuppw = $CONF['setup_password'];
|
||||
}
|
||||
|
||||
if (safepost("form") == "setuppw") {
|
||||
# "setup password" form submitted
|
||||
@ -379,13 +344,11 @@ else
|
||||
$setupMessage .= "<p>You are done with your basic setup. ";
|
||||
$setupMessage .= "<p><b>You can now <a href='login.php'>login to PostfixAdmin</a> using the account you just created.</b>";
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (($setuppw == "" || $setuppw == "changeme" || safeget("lostpw") == 1 || $lostpw_error != 0) /* && $_SERVER['REQUEST_METHOD'] != "POST" */) {
|
||||
# show "create setup password" form
|
||||
?>
|
||||
# show "create setup password" form?>
|
||||
|
||||
<div class="standout"><?php print $setupMessage; ?></div>
|
||||
<div id="edit_form">
|
||||
@ -413,7 +376,6 @@ else
|
||||
</div>
|
||||
|
||||
<?php
|
||||
|
||||
} elseif (
|
||||
(isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == "GET") ||
|
||||
$error != 0 ||
|
||||
@ -455,8 +417,7 @@ else
|
||||
</div>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
} ?>
|
||||
<b>Since version 2.3 there is no requirement to delete setup.php!</b><br />
|
||||
<b>Check the config.inc.php file for any other settings that you might need to change!<br />
|
||||
<?php
|
||||
@ -496,7 +457,9 @@ function check_setup_password($password, $lostpw_mode = 0) {
|
||||
$error = 1; # be pessimistic
|
||||
|
||||
$setuppw = "";
|
||||
if (isset($CONF['setup_password'])) $setuppw = $CONF['setup_password'];
|
||||
if (isset($CONF['setup_password'])) {
|
||||
$setuppw = $CONF['setup_password'];
|
||||
}
|
||||
|
||||
list($confsalt, $confpass, $trash) = explode(':', $setuppw . '::');
|
||||
$pass = encrypt_setup_password($password, $confsalt);
|
||||
@ -525,7 +488,6 @@ function check_setup_password($password, $lostpw_mode = 0) {
|
||||
}
|
||||
|
||||
function create_admin($values) {
|
||||
|
||||
DEFINE('POSTFIXADMIN_SETUP', 1); # avoids instant redirect to login.php after creating the admin
|
||||
|
||||
$handler = new AdminHandler(1, 'setup.php');
|
||||
|
@ -102,7 +102,9 @@ function _db_add_field($table, $field, $fieldtype, $after) {
|
||||
}
|
||||
|
||||
function printdebug($text) {
|
||||
if (safeget('debug') != "") print "<p style='color:#999'>$text</p>";
|
||||
if (safeget('debug') != "") {
|
||||
print "<p style='color:#999'>$text</p>";
|
||||
}
|
||||
}
|
||||
|
||||
$table = table_by_key('config');
|
||||
@ -142,7 +144,7 @@ if($CONF['database_type'] == 'pgsql') {
|
||||
db_query_parsed($mysql, 0, " COMMENT = 'PostfixAdmin settings'");
|
||||
}
|
||||
|
||||
$version = check_db_version(False);
|
||||
$version = check_db_version(false);
|
||||
_do_upgrade($version);
|
||||
|
||||
function _do_upgrade($current_version) {
|
||||
@ -233,13 +235,12 @@ function db_query_parsed($sql, $ignore_errors = 0, $attach_mysql = "") {
|
||||
global $CONF;
|
||||
|
||||
if ($CONF['database_type'] == 'mysql' || $CONF['database_type'] == 'mysqli') {
|
||||
|
||||
$replace = array(
|
||||
'{AUTOINCREMENT}' => 'int(11) not null auto_increment',
|
||||
'{PRIMARY}' => 'primary key',
|
||||
'{UNSIGNED}' => 'unsigned' ,
|
||||
'{FULLTEXT}' => 'FULLTEXT',
|
||||
'{BOOLEAN}' => "tinyint(1) NOT NULL DEFAULT '" . db_get_boolean(False) . "'",
|
||||
'{BOOLEAN}' => "tinyint(1) NOT NULL DEFAULT '" . db_get_boolean(false) . "'",
|
||||
'{UTF-8}' => '/*!40100 CHARACTER SET utf8 */',
|
||||
'{LATIN1}' => '/*!40100 CHARACTER SET latin1 */',
|
||||
'{IF_NOT_EXISTS}' => 'IF NOT EXISTS',
|
||||
@ -254,15 +255,14 @@ function db_query_parsed($sql, $ignore_errors = 0, $attach_mysql = "") {
|
||||
'{DATECURRENT}' => 'timestamp NOT NULL default CURRENT_TIMESTAMP', # only allowed once per table in MySQL
|
||||
);
|
||||
$sql = "$sql $attach_mysql";
|
||||
|
||||
} elseif (db_sqlite()) {
|
||||
$replace = array(
|
||||
'{AUTOINCREMENT}' => 'integer PRIMARY KEY AUTOINCREMENT NOT NULL',
|
||||
'{PRIMARY}' => 'PRIMARY KEY',
|
||||
'{UNSIGNED}' => 'unsigned',
|
||||
'{FULLTEXT}' => 'text',
|
||||
'{BOOLEAN}' => "tinyint(1) NOT NULL DEFAULT '" . db_get_boolean(False) . "'",
|
||||
'{BOOLEAN_TRUE}' => "tinyint(1) NOT NULL DEFAULT '" . db_get_boolean(True) . "'",
|
||||
'{BOOLEAN}' => "tinyint(1) NOT NULL DEFAULT '" . db_get_boolean(false) . "'",
|
||||
'{BOOLEAN_TRUE}' => "tinyint(1) NOT NULL DEFAULT '" . db_get_boolean(true) . "'",
|
||||
'{UTF-8}' => '',
|
||||
'{LATIN1}' => '',
|
||||
'{IF_NOT_EXISTS}' => 'IF NOT EXISTS',
|
||||
@ -282,7 +282,7 @@ function db_query_parsed($sql, $ignore_errors = 0, $attach_mysql = "") {
|
||||
'{PRIMARY}' => 'primary key',
|
||||
'{UNSIGNED}' => '',
|
||||
'{FULLTEXT}' => '',
|
||||
'{BOOLEAN}' => "BOOLEAN NOT NULL DEFAULT '" . db_get_boolean(False) . "'",
|
||||
'{BOOLEAN}' => "BOOLEAN NOT NULL DEFAULT '" . db_get_boolean(false) . "'",
|
||||
'{UTF-8}' => '', # UTF-8 is simply ignored.
|
||||
'{LATIN1}' => '', # same for latin1
|
||||
'{IF_NOT_EXISTS}' => '', # does not work with PgSQL
|
||||
@ -300,14 +300,13 @@ function db_query_parsed($sql, $ignore_errors = 0, $attach_mysql = "") {
|
||||
'{DATEFUTURE}' => "timestamp with time zone default '2038-01-18'", # stay in sync with MySQL
|
||||
'{DATECURRENT}' => 'timestamp with time zone default now()',
|
||||
);
|
||||
|
||||
} else {
|
||||
echo "Sorry, unsupported database type " . $conf['database_type'];
|
||||
exit;
|
||||
}
|
||||
|
||||
$replace['{BOOL_TRUE}'] = db_get_boolean(True);
|
||||
$replace['{BOOL_FALSE}'] = db_get_boolean(False);
|
||||
$replace['{BOOL_TRUE}'] = db_get_boolean(true);
|
||||
$replace['{BOOL_FALSE}'] = db_get_boolean(false);
|
||||
|
||||
$query = trim(str_replace(array_keys($replace), $replace, $sql));
|
||||
|
||||
@ -349,7 +348,6 @@ function _add_index($table, $indexname, $fieldlist) {
|
||||
echo "Sorry, unsupported database type " . $conf['database_type'];
|
||||
exit;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function upgrade_1_mysql() {
|
||||
@ -472,15 +470,14 @@ function upgrade_2_mysql() {
|
||||
# from TABLE_BACKUP_MX.TXT
|
||||
$table_domain = table_by_key('domain');
|
||||
if (!_mysql_field_exists($table_domain, 'transport')) {
|
||||
$result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN transport VARCHAR(255) AFTER maxquota;", TRUE);
|
||||
$result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN transport VARCHAR(255) AFTER maxquota;", true);
|
||||
}
|
||||
if (!_mysql_field_exists($table_domain, 'backupmx')) {
|
||||
$result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN backupmx {BOOLEAN} AFTER transport;", TRUE);
|
||||
$result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN backupmx {BOOLEAN} AFTER transport;", true);
|
||||
}
|
||||
}
|
||||
|
||||
function upgrade_2_pgsql() {
|
||||
|
||||
if (!_pgsql_object_exists(table_by_key('domain'))) {
|
||||
db_query_parsed("
|
||||
CREATE TABLE " . table_by_key('domain') . " (
|
||||
@ -601,8 +598,8 @@ function upgrade_2_pgsql() {
|
||||
|
||||
// this handles anyone who is upgrading... (and should have no impact on new installees)
|
||||
$table_domain = table_by_key('domain');
|
||||
$result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN transport VARCHAR(255)", TRUE);
|
||||
$result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN backupmx BOOLEAN DEFAULT false", TRUE);
|
||||
$result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN transport VARCHAR(255)", true);
|
||||
$result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN backupmx BOOLEAN DEFAULT false", true);
|
||||
}
|
||||
|
||||
function upgrade_3_mysql() {
|
||||
@ -681,7 +678,7 @@ function upgrade_3_mysql() {
|
||||
function upgrade_4_mysql() { # MySQL only
|
||||
# changes between 2.1 and moving to sourceforge
|
||||
$table_domain = table_by_key('domain');
|
||||
$result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN quota int(10) NOT NULL default '0' AFTER maxquota", TRUE);
|
||||
$result = db_query_parsed("ALTER TABLE $table_domain ADD COLUMN quota int(10) NOT NULL default '0' AFTER maxquota", true);
|
||||
# Possible errors that can be ignored:
|
||||
# - Invalid query: Table 'postfix.domain' doesn't exist
|
||||
}
|
||||
@ -729,7 +726,8 @@ function upgrade_4_pgsql() {
|
||||
$result = db_query_parsed("ALTER TABLE $table_mailbox ALTER COLUMN username DROP DEFAULT");
|
||||
$result = db_query_parsed("ALTER TABLE $table_mailbox ALTER COLUMN domain DROP DEFAULT");
|
||||
|
||||
$result = db_query_parsed("
|
||||
$result = db_query_parsed(
|
||||
"
|
||||
BEGIN;
|
||||
ALTER TABLE $table_mailbox RENAME COLUMN domain TO domain_old;
|
||||
ALTER TABLE $table_mailbox ADD COLUMN domain varchar(255) REFERENCES $table_domain (domain);
|
||||
@ -785,7 +783,6 @@ function upgrade_4_pgsql() {
|
||||
* - removed creation of default superadmin
|
||||
*/
|
||||
function upgrade_5_mysql() {
|
||||
|
||||
$result = db_query_parsed("
|
||||
CREATE TABLE {IF_NOT_EXISTS} " . table_by_key('admin') . " (
|
||||
`username` varchar(255) NOT NULL default '',
|
||||
@ -884,10 +881,10 @@ function upgrade_5_mysql() {
|
||||
* drop useless indicies (already available as primary key)
|
||||
*/
|
||||
function upgrade_79_mysql() { # MySQL only
|
||||
$result = db_query_parsed(_drop_index('admin', 'username'), True);
|
||||
$result = db_query_parsed(_drop_index('alias', 'address'), True);
|
||||
$result = db_query_parsed(_drop_index('domain', 'domain'), True);
|
||||
$result = db_query_parsed(_drop_index('mailbox', 'username'), True);
|
||||
$result = db_query_parsed(_drop_index('admin', 'username'), true);
|
||||
$result = db_query_parsed(_drop_index('alias', 'address'), true);
|
||||
$result = db_query_parsed(_drop_index('domain', 'domain'), true);
|
||||
$result = db_query_parsed(_drop_index('mailbox', 'username'), true);
|
||||
}
|
||||
|
||||
function upgrade_81_mysql() { # MySQL only
|
||||
@ -906,30 +903,28 @@ function upgrade_81_mysql() { # MySQL only
|
||||
"));
|
||||
|
||||
foreach ($all_sql as $sql) {
|
||||
$result = db_query_parsed($sql, TRUE);
|
||||
$result = db_query_parsed($sql, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Make logging translatable - i.e. create alias => create_alias
|
||||
*/
|
||||
function upgrade_90_mysql_pgsql() {
|
||||
$result = db_query_parsed("UPDATE " . table_by_key ('log') . " SET action = REPLACE(action,' ','_')", TRUE);
|
||||
$result = db_query_parsed("UPDATE " . table_by_key('log') . " SET action = REPLACE(action,' ','_')", true);
|
||||
# change edit_alias_state to edit_alias_active
|
||||
$result = db_query_parsed("UPDATE " . table_by_key ('log') . " SET action = 'edit_alias_state' WHERE action = 'edit_alias_active'", TRUE);
|
||||
$result = db_query_parsed("UPDATE " . table_by_key('log') . " SET action = 'edit_alias_state' WHERE action = 'edit_alias_active'", true);
|
||||
}
|
||||
|
||||
/**
|
||||
* MySQL only allow quota > 2 GB
|
||||
*/
|
||||
function upgrade_169_mysql() {
|
||||
|
||||
$table_domain = table_by_key('domain');
|
||||
$table_mailbox = table_by_key('mailbox');
|
||||
$result = db_query_parsed("ALTER TABLE $table_domain MODIFY COLUMN `quota` bigint(20) NOT NULL default '0'", TRUE);
|
||||
$result = db_query_parsed("ALTER TABLE $table_domain MODIFY COLUMN `maxquota` bigint(20) NOT NULL default '0'", TRUE);
|
||||
$result = db_query_parsed("ALTER TABLE $table_mailbox MODIFY COLUMN `quota` bigint(20) NOT NULL default '0'", TRUE);
|
||||
$result = db_query_parsed("ALTER TABLE $table_domain MODIFY COLUMN `quota` bigint(20) NOT NULL default '0'", true);
|
||||
$result = db_query_parsed("ALTER TABLE $table_domain MODIFY COLUMN `maxquota` bigint(20) NOT NULL default '0'", true);
|
||||
$result = db_query_parsed("ALTER TABLE $table_mailbox MODIFY COLUMN `quota` bigint(20) NOT NULL default '0'", true);
|
||||
}
|
||||
|
||||
|
||||
@ -968,7 +963,6 @@ function upgrade_318_mysql() {
|
||||
foreach ($all_sql as $sql) {
|
||||
$result = db_query_parsed($sql);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -976,7 +970,6 @@ function upgrade_318_mysql() {
|
||||
* Create fetchmail table
|
||||
*/
|
||||
function upgrade_344_mysql() {
|
||||
|
||||
$table_fetchmail = table_by_key('fetchmail');
|
||||
|
||||
db_query_parsed("
|
||||
@ -1650,7 +1643,6 @@ function upgrade_1824_sqlite() {
|
||||
{PRIMARY} (`on_vacation`,`notified`),
|
||||
CONSTRAINT `vacation_notification_pkey` FOREIGN KEY (`on_vacation`) REFERENCES `vacation` (`email`) ON DELETE CASCADE);
|
||||
");
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -1682,9 +1674,8 @@ function upgrade_1836_mysql() {
|
||||
"));
|
||||
|
||||
foreach ($all_sql as $sql) {
|
||||
$result = db_query_parsed($sql, TRUE);
|
||||
$result = db_query_parsed($sql, true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function upgrade_1837() {
|
||||
@ -1722,7 +1713,6 @@ function upgrade_1837_sqlite() {
|
||||
db_query_parsed("ALTER TABLE `$table` ADD COLUMN `email_other` varchar(255) NOT NULL DEFAULT ''");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* https://github.com/postfixadmin/postfixadmin/issues/89 */
|
||||
|
@ -37,13 +37,14 @@ $ah->init($USERID_USERNAME);
|
||||
$smarty->assign('USERID_USERNAME', $USERID_USERNAME);
|
||||
|
||||
|
||||
if ( ! $ah->view() ) die("Can't get alias details. Invalid alias?"); # this can only happen if a admin deleted the user since the user logged in
|
||||
if (! $ah->view()) {
|
||||
die("Can't get alias details. Invalid alias?");
|
||||
} # this can only happen if a admin deleted the user since the user logged in
|
||||
$result = $ah->result();
|
||||
$tGotoArray = $result['goto'];
|
||||
$tStoreAndForward = $result['goto_mailbox'];
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET")
|
||||
{
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
if ($tStoreAndForward) {
|
||||
$smarty->assign('forward_and_store', ' checked="checked"');
|
||||
$smarty->assign('forward_only', '');
|
||||
@ -56,9 +57,10 @@ if ($_SERVER['REQUEST_METHOD'] == "GET")
|
||||
$smarty->display('index.tpl');
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
{
|
||||
if (safepost('token') != $_SESSION['PFA_token']) die('Invalid token!');
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
if (safepost('token') != $_SESSION['PFA_token']) {
|
||||
die('Invalid token!');
|
||||
}
|
||||
|
||||
// user clicked on cancel button
|
||||
if (isset($_POST['fCancel'])) {
|
||||
@ -101,8 +103,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
if ($email_check != '') {
|
||||
$error += 1;
|
||||
flash_error("$address: $email_check");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$good_goto[] = $address;
|
||||
}
|
||||
}
|
||||
@ -110,7 +111,6 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
}
|
||||
|
||||
if ($error == 0) {
|
||||
|
||||
$values = array(
|
||||
'goto' => $good_goto,
|
||||
'goto_mailbox' => $fForward_and_store,
|
||||
@ -128,9 +128,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
exit;
|
||||
}
|
||||
flash_error($PALANG['pEdit_alias_result_error']);
|
||||
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$tGotoArray = $goto;
|
||||
}
|
||||
$smarty->assign('tGotoArray', $tGotoArray);
|
||||
@ -145,4 +143,3 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
}
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
?>
|
@ -32,10 +32,10 @@ require_once("../common.php");
|
||||
|
||||
check_db_version(); # check if the database layout is up to date (and error out if not)
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
{
|
||||
|
||||
if (safepost('token') != $_SESSION['PFA_token']) die('Invalid token!');
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
if (safepost('token') != $_SESSION['PFA_token']) {
|
||||
die('Invalid token!');
|
||||
}
|
||||
|
||||
$lang = safepost('lang');
|
||||
$fUsername = trim(safepost('fUsername'));
|
||||
@ -48,7 +48,6 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
|
||||
$h = new MailboxHandler();
|
||||
if ($h->login($fUsername, $fPassword)) {
|
||||
|
||||
init_session($fUsername, false);
|
||||
|
||||
header("Location: main.php");
|
||||
@ -68,4 +67,3 @@ $smarty->assign ('forgotten_password_reset', Config::read('forgotten_user_passwo
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
|
||||
?>
|
||||
|
@ -30,13 +30,10 @@ $USERID_USERNAME = authentication_get_username();
|
||||
$vh = new VacationHandler($USERID_USERNAME);
|
||||
if ($vh->check_vacation()) {
|
||||
$tummVacationtext = $PALANG['pUsersMain_vacationSet'];
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
$tummVacationtext = $PALANG['pUsersMain_vacation'];
|
||||
}
|
||||
$smarty->assign('tummVacationtext', $tummVacationtext);
|
||||
$smarty->assign('smarty_template', 'users_main');
|
||||
$smarty->display('index.tpl');
|
||||
/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
|
||||
?>
|
||||
|
@ -35,9 +35,10 @@ $username = authentication_get_username();
|
||||
$pPassword_password_text = "";
|
||||
$pPassword_password_current_text = "";
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
{
|
||||
if (safepost('token') != $_SESSION['PFA_token']) die('Invalid token!');
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
if (safepost('token') != $_SESSION['PFA_token']) {
|
||||
die('Invalid token!');
|
||||
}
|
||||
|
||||
if (isset($_POST['fCancel'])) {
|
||||
header("Location: main.php");
|
||||
@ -62,22 +63,18 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
$error += 1;
|
||||
$pPassword_password_current_text = $PALANG['pPassword_password_current_text_error'];
|
||||
}
|
||||
if (empty ($fPassword) or ($fPassword != $fPassword2))
|
||||
{
|
||||
if (empty($fPassword) or ($fPassword != $fPassword2)) {
|
||||
$error += 1;
|
||||
$pPassword_password_text = $PALANG['pPassword_password_text_error'];
|
||||
}
|
||||
|
||||
if ($error == 0)
|
||||
{
|
||||
if ($error == 0) {
|
||||
$mh->init($username); # TODO: error handling
|
||||
if ($mh->change_pw($fPassword, $fPassword_current)) {
|
||||
flash_info(Config::Lang_f('pPassword_result_success', $username));
|
||||
header("Location: main.php");
|
||||
exit(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
flash_error(Config::Lang_f('pPassword_result_error', $username));
|
||||
}
|
||||
}
|
||||
@ -91,4 +88,3 @@ $smarty->assign ('smarty_template', 'password');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
?>
|
||||
|
@ -22,4 +22,3 @@ require_once('../common.php');
|
||||
require_once('../vacation.php');
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
?>
|
||||
|
@ -51,8 +51,7 @@ if(authentication_has_role('admin')) {
|
||||
if ($fDomain == '' || !check_owner(authentication_get_username(), $fDomain)) {
|
||||
die("Invalid username!"); # TODO: better error message
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$Admin_role = 0 ;
|
||||
$Return_url = "main.php";
|
||||
authentication_require_role('user');
|
||||
@ -98,14 +97,18 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
}
|
||||
|
||||
//set a default, reset fields for coming back selection
|
||||
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'); }
|
||||
|
||||
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');
|
||||
}
|
||||
}
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
{
|
||||
if (safepost('token') != $_SESSION['PFA_token']) die('Invalid token!');
|
||||
if ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
if (safepost('token') != $_SESSION['PFA_token']) {
|
||||
die('Invalid token!');
|
||||
}
|
||||
|
||||
if (isset($_POST['fCancel'])) {
|
||||
header("Location: $Return_url");
|
||||
@ -128,8 +131,12 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
$tUseremail = $fUsername;
|
||||
|
||||
//set a default, reset fields for coming back selection
|
||||
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'); }
|
||||
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');
|
||||
}
|
||||
|
||||
if (isset($choice_of_reply[$tInterval_Time])) {
|
||||
$fInterval_Time = $tInterval_Time;
|
||||
@ -142,8 +149,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
|
||||
//Set the vacation data for $fUsername
|
||||
|
||||
if (!empty ($fChange))
|
||||
{
|
||||
if (!empty($fChange)) {
|
||||
|
||||
## check if ActiveUnitl is not back in time,
|
||||
## because vacation.pl will report SMTP recipient $smtp_recipient which resolves to $email does not have an active vacation (rv: $rv, email: $email)"
|
||||
@ -164,8 +170,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST")
|
||||
}
|
||||
|
||||
//if change, remove old one, then perhaps set new one
|
||||
if (!empty ($fBack))
|
||||
{
|
||||
if (!empty($fBack)) {
|
||||
if (!$vh->remove()) {
|
||||
$error = 1;
|
||||
}
|
||||
@ -184,21 +189,28 @@ if($error == 0) {
|
||||
header("Location: $Return_url");
|
||||
exit;
|
||||
}
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
flash_error(sprintf($PALANG['pVacation_result_error'], htmlentities($fUsername)));
|
||||
}
|
||||
|
||||
$today = date("Y-m-d");
|
||||
if (empty ($tActiveFrom)) $tActiveFrom = $today;
|
||||
if (empty ($tActiveUntil)) $tActiveUntil = $today;
|
||||
if (empty($tActiveFrom)) {
|
||||
$tActiveFrom = $today;
|
||||
}
|
||||
if (empty($tActiveUntil)) {
|
||||
$tActiveUntil = $today;
|
||||
}
|
||||
|
||||
if (! $details['active']) {
|
||||
# if vacation is disabled, there's no point in displaying the date of the last vacation ;-)
|
||||
# (which also means users would have to scroll in the calendar a lot)
|
||||
# so let's be user-friendly and set today's date (but only if the last vacation is in the past)
|
||||
if ($tActiveFrom < $today) $tActiveFrom = $today;
|
||||
if ($tActiveUntil < $today) $tActiveUntil = $today;
|
||||
if ($tActiveFrom < $today) {
|
||||
$tActiveFrom = $today;
|
||||
}
|
||||
if ($tActiveUntil < $today) {
|
||||
$tActiveUntil = $today;
|
||||
}
|
||||
}
|
||||
|
||||
$smarty->assign('tUseremail', $tUseremail);
|
||||
@ -212,4 +224,3 @@ $smarty->assign ('smarty_template', 'vacation');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
|
||||
?>
|
||||
|
@ -31,25 +31,26 @@ authentication_require_role('admin');
|
||||
$SESSID_USERNAME = authentication_get_username();
|
||||
if (authentication_has_role('global-admin')) {
|
||||
$list_domains = list_domains();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$list_domains = list_domains_for_admin($SESSID_USERNAME);
|
||||
}
|
||||
|
||||
$fDomain = '';
|
||||
$error = 0;
|
||||
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET")
|
||||
{
|
||||
if ((is_array ($list_domains) and sizeof ($list_domains) > 0)) $fDomain = $list_domains[0];
|
||||
if ($_SERVER['REQUEST_METHOD'] == "GET") {
|
||||
if ((is_array($list_domains) and sizeof($list_domains) > 0)) {
|
||||
$fDomain = $list_domains[0];
|
||||
}
|
||||
} elseif ($_SERVER['REQUEST_METHOD'] == "POST") {
|
||||
if (isset ($_POST['fDomain'])) $fDomain = escape_string ($_POST['fDomain']);
|
||||
if (isset($_POST['fDomain'])) {
|
||||
$fDomain = escape_string($_POST['fDomain']);
|
||||
}
|
||||
} else {
|
||||
die('Unknown request method');
|
||||
}
|
||||
|
||||
if (! (check_owner ($SESSID_USERNAME, $fDomain) || authentication_has_role('global-admin')))
|
||||
{
|
||||
if (! (check_owner($SESSID_USERNAME, $fDomain) || authentication_has_role('global-admin'))) {
|
||||
$error = 1;
|
||||
flash_error($PALANG['pViewlog_result_error']);
|
||||
}
|
||||
@ -57,8 +58,7 @@ if (! (check_owner ($SESSID_USERNAME, $fDomain) || authentication_has_role('glob
|
||||
// we need to initialize $tLog as an array!
|
||||
$tLog = array();
|
||||
|
||||
if ($error != 1)
|
||||
{
|
||||
if ($error != 1) {
|
||||
$table_log = table_by_key('log');
|
||||
$page_size = isset($CONF['page_size']) ? intval($CONF['page_size']) : 35;
|
||||
|
||||
@ -67,10 +67,8 @@ if ($error != 1)
|
||||
$query = "SELECT extract(epoch from timestamp) as timestamp,username,domain,action,data FROM $table_log WHERE domain='$fDomain' ORDER BY timestamp DESC LIMIT $page_size";
|
||||
}
|
||||
$result=db_query($query);
|
||||
if ($result['rows'] > 0)
|
||||
{
|
||||
while ($row = db_array ($result['result']))
|
||||
{
|
||||
if ($result['rows'] > 0) {
|
||||
while ($row = db_array($result['result'])) {
|
||||
if (db_pgsql()) {
|
||||
$row['timestamp']=gmstrftime('%c %Z', $row['timestamp']);
|
||||
}
|
||||
@ -79,8 +77,9 @@ if ($error != 1)
|
||||
}
|
||||
}
|
||||
|
||||
for ($i = 0; $i < count ($tLog); $i++)
|
||||
for ($i = 0; $i < count($tLog); $i++) {
|
||||
$tLog[$i]['action'] = $PALANG ['pViewlog_action_'.$tLog [$i]['action']];
|
||||
}
|
||||
|
||||
$smarty->assign('domain_list', $list_domains);
|
||||
$smarty->assign('domain_selected', $fDomain);
|
||||
@ -90,4 +89,3 @@ $smarty->assign ('smarty_template', 'viewlog');
|
||||
$smarty->display('index.tpl');
|
||||
|
||||
/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */
|
||||
?>
|
||||
|
@ -45,7 +45,6 @@ $server = new Zend_XmlRpc_Server();
|
||||
* @return boolean true on success, else false.
|
||||
*/
|
||||
function login($username, $password) {
|
||||
|
||||
$h = new MailboxHandler();
|
||||
if ($h->login($username, $password)) {
|
||||
session_regenerate_id();
|
||||
@ -59,8 +58,7 @@ function login($username, $password) {
|
||||
|
||||
if (!isset($_SESSION['authenticated'])) {
|
||||
$server->addFunction('login', 'login');
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
$server->setClass('UserProxy', 'user');
|
||||
$server->setClass('VacationProxy', 'vacation');
|
||||
$server->setClass('AliasProxy', 'alias');
|
||||
@ -77,7 +75,9 @@ class UserProxy {
|
||||
*/
|
||||
public function changePassword($old_password, $new_password) {
|
||||
$uh = new MailboxHandler();
|
||||
if (!$uh->init($_SESSION['sessid']['username'])) return false;
|
||||
if (!$uh->init($_SESSION['sessid']['username'])) {
|
||||
return false;
|
||||
}
|
||||
return $uh->change_pw($new_password, $old_password);
|
||||
}
|
||||
|
||||
@ -139,8 +139,6 @@ class VacationProxy {
|
||||
$vh = new VacationHandler($_SESSION['sessid']['username']);
|
||||
return $vh->set_away($subject, $body, $interval_time, $activeFrom, $activeUntil);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
class AliasProxy {
|
||||
/**
|
||||
|
@ -466,7 +466,6 @@ class PostfixAdmin {
|
||||
$this->stdout("");
|
||||
|
||||
exit();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -7,29 +7,25 @@ class PasswordTask extends Shell {
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function execute() {
|
||||
public function execute() {
|
||||
$random = false;
|
||||
if (empty($this->args)) {
|
||||
$this->__interactive();
|
||||
}
|
||||
|
||||
if (!empty($this->args[0])) {
|
||||
|
||||
$address = $this->args[0];
|
||||
|
||||
if (isset($this->params['g']) && $this->params['g'] == true) {
|
||||
$random = true;
|
||||
$password = NULL;
|
||||
$password = null;
|
||||
} elseif (isset($this->args[1]) && strlen($this->args[1]) > 8) { # TODO use validate_password()
|
||||
$password = $this->args[1];
|
||||
} else {
|
||||
|
||||
$this->Dispatch->stderr('Missing <newpw> or -g. Falling back to interactive mode.');
|
||||
$this->__interactive();
|
||||
}
|
||||
$this->__handle($address, $password, $random);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@ -37,7 +33,6 @@ class PasswordTask extends Shell {
|
||||
* Interactive
|
||||
*/
|
||||
private function __interactive() {
|
||||
|
||||
while (true) {
|
||||
$question = "Which address' password do you want to change?";
|
||||
$address = $this->in($question);
|
||||
@ -65,14 +60,13 @@ class PasswordTask extends Shell {
|
||||
$random == 'y' ? $random = true : $random = false;
|
||||
|
||||
|
||||
$password = NULL;
|
||||
$password = null;
|
||||
if ($random == false) {
|
||||
$question = "Pleas enter the new password?";
|
||||
$password = $this->in($question);
|
||||
}
|
||||
|
||||
$this->__handle($address, $password, $random);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -80,19 +74,18 @@ class PasswordTask extends Shell {
|
||||
* @param string $password optional
|
||||
* @param boolean $random optional - true to generate random pw.
|
||||
*/
|
||||
private function __handle($address, $password = NULL, $random = false) {
|
||||
|
||||
private function __handle($address, $password = null, $random = false) {
|
||||
if ($random == true) {
|
||||
$password = generate_password();
|
||||
}
|
||||
if ($password != NULL) {
|
||||
if ($password != null) {
|
||||
$handler = new MailboxHandler();
|
||||
|
||||
if (!$handler->init($address)) {
|
||||
$this->error("Change Password", join("\n", $handler->errormsg));
|
||||
}
|
||||
|
||||
if ( ! $handler->change_pw($password, NULL, false) ){
|
||||
if (! $handler->change_pw($password, null, false)) {
|
||||
$this->error("Change Password", join("\n", $handler->errormsg));
|
||||
}
|
||||
}
|
||||
|
@ -36,62 +36,62 @@ class Shell {
|
||||
* @var object
|
||||
* @access public
|
||||
*/
|
||||
var $Dispatch = null;
|
||||
public $Dispatch = null;
|
||||
/**
|
||||
* If true, the script will ask for permission to perform actions.
|
||||
*
|
||||
* @var boolean
|
||||
* @access public
|
||||
*/
|
||||
var $interactive = true;
|
||||
public $interactive = true;
|
||||
/**
|
||||
* Contains command switches parsed from the command line.
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $params = array();
|
||||
public $params = array();
|
||||
/**
|
||||
* Contains arguments parsed from the command line.
|
||||
*
|
||||
* @var array
|
||||
* @access public
|
||||
*/
|
||||
var $args = array();
|
||||
public $args = array();
|
||||
/**
|
||||
* The file name of the shell that was invoked.
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $shell = null;
|
||||
public $shell = null;
|
||||
/**
|
||||
* The class name of the shell that was invoked.
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $className = null;
|
||||
public $className = null;
|
||||
/**
|
||||
* The command called if public methods are available.
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $command = null;
|
||||
public $command = null;
|
||||
/**
|
||||
* The name of the shell in camelized.
|
||||
*
|
||||
* @var string
|
||||
* @access public
|
||||
*/
|
||||
var $name = null;
|
||||
public $name = null;
|
||||
|
||||
/**
|
||||
* Constructs this Shell instance.
|
||||
*
|
||||
*/
|
||||
function __construct(&$dispatch) {
|
||||
public function __construct(&$dispatch) {
|
||||
$vars = array('params', 'args', 'shell', 'shellCommand'=> 'command');
|
||||
foreach ($vars as $key => $var) {
|
||||
if (is_string($key)) {
|
||||
@ -117,7 +117,7 @@ class Shell {
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function initialize() {
|
||||
public function initialize() {
|
||||
}
|
||||
/**
|
||||
* Starts up the the Shell
|
||||
@ -126,7 +126,7 @@ class Shell {
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function startup() {
|
||||
public function startup() {
|
||||
#CHECK!
|
||||
if (empty($this->params['q'])) {
|
||||
$this->_welcome();
|
||||
@ -138,7 +138,7 @@ class Shell {
|
||||
*
|
||||
* @access protected
|
||||
*/
|
||||
function _welcome() {
|
||||
public function _welcome() {
|
||||
$this->out("\nWelcome to Postfixadmin-CLI v" . $this->Dispatch->version);
|
||||
$this->hr();
|
||||
}
|
||||
@ -152,11 +152,13 @@ class Shell {
|
||||
* @return Either the default value, or the user-provided input.
|
||||
* @access public
|
||||
*/
|
||||
function in($prompt, $options = null, $default = null) {
|
||||
public function in($prompt, $options = null, $default = null) {
|
||||
if (!$this->interactive) {
|
||||
return $default;
|
||||
}
|
||||
if ($prompt != '') $this->out("");
|
||||
if ($prompt != '') {
|
||||
$this->out("");
|
||||
}
|
||||
$in = $this->Dispatch->getInput($prompt, $options, $default);
|
||||
|
||||
if ($options && is_string($options)) {
|
||||
@ -184,7 +186,7 @@ class Shell {
|
||||
* @param boolean $newline If true, the outputs gets an added newline.
|
||||
* @access public
|
||||
*/
|
||||
function out($string, $newline = true) {
|
||||
public function out($string, $newline = true) {
|
||||
if (is_array($string)) {
|
||||
$str = '';
|
||||
foreach ($string as $message) {
|
||||
@ -200,7 +202,7 @@ class Shell {
|
||||
* @param string $string Error text to output.
|
||||
* @access public
|
||||
*/
|
||||
function err($string) {
|
||||
public function err($string) {
|
||||
if (is_array($string)) {
|
||||
$str = '';
|
||||
foreach ($string as $message) {
|
||||
@ -216,7 +218,7 @@ class Shell {
|
||||
* @param boolean $newline If true, the outputs gets an added newline.
|
||||
* @access public
|
||||
*/
|
||||
function hr($newline = false) {
|
||||
public function hr($newline = false) {
|
||||
if ($newline) {
|
||||
$this->out("\n");
|
||||
}
|
||||
@ -232,7 +234,7 @@ class Shell {
|
||||
* @param string $msg Error message
|
||||
* @access public
|
||||
*/
|
||||
function error($title, $msg) {
|
||||
public function error($title, $msg) {
|
||||
$out = "$title\n";
|
||||
$out .= "$msg\n";
|
||||
$out .= "\n";
|
||||
@ -244,7 +246,7 @@ class Shell {
|
||||
*
|
||||
* @access public
|
||||
*/
|
||||
function help() {
|
||||
public function help() {
|
||||
if ($this->command != null) {
|
||||
$this->err("Unknown {$this->name} command '$this->command'.\nFor usage, try 'postfixadmin-cli {$this->shell} help'.\n\n");
|
||||
} else {
|
||||
@ -258,10 +260,7 @@ class Shell {
|
||||
* @return void
|
||||
* @access public
|
||||
*/
|
||||
function _stop($status = 0) {
|
||||
public function _stop($status = 0) {
|
||||
exit($status);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
class Crypt {
|
||||
|
||||
@ -15,7 +15,7 @@ class Crypt {
|
||||
protected $size;
|
||||
|
||||
|
||||
function __construct($plaintext) {
|
||||
public function __construct($plaintext) {
|
||||
$this->plain = $plaintext;
|
||||
}
|
||||
|
||||
@ -29,6 +29,4 @@ class Crypt {
|
||||
public function get() {
|
||||
return $this->password;
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
require_once('crypt.php');
|
||||
require_once('dovecot_crypt.php');
|
||||
@ -29,4 +29,3 @@ if ($test2->verify('CRAM-MD5', $test2->get())) {
|
||||
echo "Varified: false\n";
|
||||
}
|
||||
echo "\n";
|
||||
?>
|
@ -1,4 +1,4 @@
|
||||
<?php
|
||||
<?php
|
||||
|
||||
define('SHA1_RESULTLEN', (160/8));
|
||||
define('SHA256_RESULTLEN', (256 / 8));
|
||||
@ -10,7 +10,6 @@
|
||||
|
||||
|
||||
class DovecotCrypt extends Crypt {
|
||||
|
||||
private $salt_chars = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||
|
||||
|
||||
@ -23,15 +22,15 @@ class DovecotCrypt extends Crypt {
|
||||
'CRYPT' => array('NONE', 0, 'crypt_verify', 'crypt_generate'),
|
||||
'MD5' => array('NONE', 0, 'md5_verify', 'md5_generate'),
|
||||
//'MD5-CRYPT' => array('NONE', 0, 'md5_crypt_verify', 'md5_crypt_generate'),
|
||||
'SHA' => array('BASE64', SHA1_RESULTLEN, NULL, 'sha1_generate'),
|
||||
'SHA1' => array('BASE64', SHA1_RESULTLEN, NULL, 'sha1_generate'),
|
||||
'SHA' => array('BASE64', SHA1_RESULTLEN, null, 'sha1_generate'),
|
||||
'SHA1' => array('BASE64', SHA1_RESULTLEN, null, 'sha1_generate'),
|
||||
//'SHA256' => array('BASE64', SHA256_RESULTLEN, NULL, 'sha256_generate'),
|
||||
//'SMD5' => array('BASE64', 0, 'smd5_verify', 'smd5_generate'),
|
||||
//'SSHA' => array('BASE64', 0, 'ssha_verify', 'ssha_generate'),
|
||||
//'SSHA256' => array('BASE64', 0, 'ssha356_verify', 'ssha256_generate'),
|
||||
'PLAIN' => array('NONE', 0, NULL, 'plain_generate'),
|
||||
'CLEARTEXT' => array('NONE', 0, NULL, 'plain_generate'),
|
||||
'CRAM-MD5' => array('HEX', CRAM_MD5_CONTEXTLEN, NULL, 'cram_md5_generate'),
|
||||
'PLAIN' => array('NONE', 0, null, 'plain_generate'),
|
||||
'CLEARTEXT' => array('NONE', 0, null, 'plain_generate'),
|
||||
'CRAM-MD5' => array('HEX', CRAM_MD5_CONTEXTLEN, null, 'cram_md5_generate'),
|
||||
//'HMAC-MD5' => array('HEX', CRAM_MD5_CONTEXTLEN, NULL, 'cram_md5_generate'),
|
||||
//'DIGEST-MD5' => array('HEX', MD5_RESULTLEN, NULL, 'digest_md5_generate'),
|
||||
//'PLAIN-MD4' => array('HEX', MD4_RESULTLEN, NULL, 'plain_md4_generate'),
|
||||
@ -66,14 +65,13 @@ class DovecotCrypt extends Crypt {
|
||||
}
|
||||
|
||||
$scheme = $this->password_schemes[$algorithm];
|
||||
if($scheme[2] == NULL) {
|
||||
if ($scheme[2] == null) {
|
||||
$this->errormsg[] = "This password scheme doesn't support verification";
|
||||
return false;
|
||||
}
|
||||
|
||||
$func = '__'.$scheme[2];
|
||||
return $this->$func($this->plain, $password);
|
||||
|
||||
}
|
||||
|
||||
private function __crypt_verify($plaintext, $password) {
|
||||
@ -81,7 +79,6 @@ class DovecotCrypt extends Crypt {
|
||||
return strcmp($crypted, $password) == 0;
|
||||
}
|
||||
private function __crypt_generate($plaintext) {
|
||||
|
||||
$password = crypt($plaintext);
|
||||
return $password;
|
||||
}
|
||||
@ -89,10 +86,8 @@ class DovecotCrypt extends Crypt {
|
||||
return $password;
|
||||
}
|
||||
private function __sha1_generate() {
|
||||
|
||||
}
|
||||
private function __plain_generate() {
|
||||
|
||||
}
|
||||
private function __cram_md5_generate($plaintext) {
|
||||
|
||||
@ -108,8 +103,7 @@ $salt = $plaintext;
|
||||
}
|
||||
|
||||
|
||||
function custom_hmac($algo, $data, $key, $raw_output = false)
|
||||
{
|
||||
public function custom_hmac($algo, $data, $key, $raw_output = false) {
|
||||
$algo = strtolower($algo);
|
||||
$pack = 'H'.strlen($algo('test'));
|
||||
$size = 64;
|
||||
|
@ -18,8 +18,7 @@ class PFASmarty {
|
||||
$templates_c = dirname(__FILE__) . '/templates_c';
|
||||
if (is_dir($templates_c) && is_writeable($templates_c)) {
|
||||
$this->template->setCompileDir($templates_c);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
# unfortunately there's no sane way to just disable compiling of templates
|
||||
clearstatcache(); // just incase someone just fixed it; on their next refresh it should work.
|
||||
error_log("ERROR: directory $templates_c doesn't exist or isn't writeable for the webserver");
|
||||
@ -72,10 +71,14 @@ class PFASmarty {
|
||||
}
|
||||
$smarty = new PFASmarty();
|
||||
|
||||
if (!isset($rel_path)) $rel_path = ''; # users/* sets this to '../'
|
||||
if (!isset($rel_path)) {
|
||||
$rel_path = '';
|
||||
} # users/* sets this to '../'
|
||||
|
||||
$CONF['theme_css'] = $rel_path . htmlentities($CONF['theme_css']);
|
||||
if (!empty($CONF['theme_custom_css'])) $CONF['theme_custom_css'] = $rel_path . htmlentities($CONF['theme_custom_css']);
|
||||
if (!empty($CONF['theme_custom_css'])) {
|
||||
$CONF['theme_custom_css'] = $rel_path . htmlentities($CONF['theme_custom_css']);
|
||||
}
|
||||
$CONF['theme_logo'] = $rel_path . htmlentities($CONF['theme_logo']);
|
||||
|
||||
$smarty->assign('CONF', $CONF);
|
||||
@ -89,10 +92,13 @@ $smarty->assign ('boolconf_alias_domain', Config::bool('alias_domain'));
|
||||
$smarty->assign('authentication_has_role', array('global_admin' => authentication_has_role('global-admin'), 'admin' => authentication_has_role('admin'), 'user' => authentication_has_role('user')));
|
||||
|
||||
function eval_size($aSize) {
|
||||
if ($aSize == 0) {$ret_val = Config::Lang('pOverview_unlimited'); }
|
||||
elseif ($aSize < 0) {$ret_val = Config::Lang('pOverview_disabled'); }
|
||||
else {$ret_val = $aSize; }
|
||||
if ($aSize == 0) {
|
||||
$ret_val = Config::Lang('pOverview_unlimited');
|
||||
} elseif ($aSize < 0) {
|
||||
$ret_val = Config::Lang('pOverview_disabled');
|
||||
} else {
|
||||
$ret_val = $aSize;
|
||||
}
|
||||
return $ret_val;
|
||||
}
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
?>
|
||||
|
@ -8,7 +8,6 @@
|
||||
require_once('RemoteTest.php');
|
||||
|
||||
class RemoteAliasTest extends RemoteTest {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
global $CONF;
|
||||
@ -29,8 +28,7 @@ class RemoteAliasTest extends RemoteTest {
|
||||
try {
|
||||
/* although we created an alias record, for users, this isn't returned... */
|
||||
$this->assertEqual($this->alias->get(), array());
|
||||
}
|
||||
catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
var_dump($this->xmlrpc_client->getHttpClient()->getLastResponse()->getBody());
|
||||
}
|
||||
}
|
||||
|
@ -9,7 +9,6 @@ require_once('Zend/Http/Client.php');
|
||||
require_once('Zend/Registry.php');
|
||||
|
||||
abstract class RemoteTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
protected $server_url = 'http://orange/david/postfixadmin/xmlrpc.php';
|
||||
protected $username = 'roger@example.com';
|
||||
protected $password = 'patchthedog';
|
||||
|
@ -8,7 +8,6 @@
|
||||
require_once('RemoteTest.php');
|
||||
|
||||
class RemoteUserTest extends RemoteTest {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
global $CONF;
|
||||
@ -30,8 +29,7 @@ class RemoteUserTest extends RemoteTest {
|
||||
$this->assertTrue($this->user->login($this->username, $this->password));
|
||||
$this->assertTrue($this->user->changePassword($this->password, 'foobar'));
|
||||
$this->assertTrue($this->user->login($this->username, 'foobar'));
|
||||
}
|
||||
catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
var_dump($this->xmlrpc_client->getHttpClient()->getLastResponse()->getBody());
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@
|
||||
require_once('RemoteTest.php');
|
||||
|
||||
class RemoteVacationTest extends RemoteTest {
|
||||
|
||||
public function __construct() {
|
||||
parent::__construct();
|
||||
global $CONF;
|
||||
@ -36,8 +35,7 @@ class RemoteVacationTest extends RemoteTest {
|
||||
public function testIsVacationSupported() {
|
||||
try {
|
||||
$this->assertTrue($this->vacation->isVacationSupported());
|
||||
}
|
||||
catch(Exception $e){
|
||||
} catch (Exception $e) {
|
||||
var_dump($e);
|
||||
var_dump($this->xmlrpc_client->getHttpClient()->getLastResponse()->getBody());
|
||||
die("fail..");
|
||||
@ -59,8 +57,7 @@ class RemoteVacationTest extends RemoteTest {
|
||||
$this->assertFalse($this->vacation->checkVacation());
|
||||
$this->assertTrue($this->vacation->setAway('zzzz', 'aaaa'));
|
||||
$this->assertTrue($this->vacation->checkVacation());
|
||||
}
|
||||
catch(Exception $e) {
|
||||
} catch (Exception $e) {
|
||||
var_dump($this->xmlrpc_client->getHttpClient()->getLastResponse()->getBody());
|
||||
}
|
||||
$details = $this->vacation->getDetails();
|
||||
@ -77,7 +74,6 @@ class RemoteVacationTest extends RemoteTest {
|
||||
$this->assertEqual($details['subject'], 'subject');
|
||||
$this->assertEqual($details['body'], 'body');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */
|
||||
|
Reference in New Issue
Block a user