postfixadmin-svn Mailing List for PostfixAdmin (Page 96)
Brought to you by:
christian_boltz,
gingerdog
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(13) |
Oct
(63) |
Nov
(79) |
Dec
(34) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(15) |
Feb
(8) |
Mar
(8) |
Apr
(44) |
May
(18) |
Jun
(20) |
Jul
(35) |
Aug
(21) |
Sep
(8) |
Oct
(9) |
Nov
(21) |
Dec
(14) |
2009 |
Jan
(53) |
Feb
(13) |
Mar
(36) |
Apr
(40) |
May
(22) |
Jun
(10) |
Jul
(18) |
Aug
(18) |
Sep
(7) |
Oct
(26) |
Nov
(32) |
Dec
(13) |
2010 |
Jan
(6) |
Feb
(7) |
Mar
(12) |
Apr
(2) |
May
(12) |
Jun
(8) |
Jul
(9) |
Aug
(12) |
Sep
(12) |
Oct
(7) |
Nov
(9) |
Dec
(42) |
2011 |
Jan
(10) |
Feb
(35) |
Mar
(43) |
Apr
(39) |
May
(8) |
Jun
(8) |
Jul
(83) |
Aug
(20) |
Sep
(20) |
Oct
(63) |
Nov
(33) |
Dec
(20) |
2012 |
Jan
(28) |
Feb
(3) |
Mar
(1) |
Apr
(37) |
May
(16) |
Jun
(7) |
Jul
(3) |
Aug
|
Sep
|
Oct
(3) |
Nov
(1) |
Dec
(4) |
2013 |
Jan
(6) |
Feb
(16) |
Mar
(9) |
Apr
(11) |
May
(9) |
Jun
(30) |
Jul
(17) |
Aug
(6) |
Sep
(2) |
Oct
(30) |
Nov
(41) |
Dec
(26) |
2014 |
Jan
(16) |
Feb
(20) |
Mar
(5) |
Apr
(4) |
May
(14) |
Jun
(4) |
Jul
(1) |
Aug
|
Sep
(8) |
Oct
(18) |
Nov
(26) |
Dec
|
2015 |
Jan
(4) |
Feb
(9) |
Mar
(12) |
Apr
(26) |
May
(3) |
Jun
(3) |
Jul
(2) |
Aug
|
Sep
(15) |
Oct
(13) |
Nov
|
Dec
(1) |
2016 |
Jan
(1) |
Feb
(5) |
Mar
(4) |
Apr
(3) |
May
(19) |
Jun
|
Jul
|
Aug
(3) |
Sep
(16) |
Oct
(4) |
Nov
(5) |
Dec
(5) |
2017 |
Jan
(1) |
Feb
(8) |
Mar
|
Apr
(7) |
May
(3) |
Jun
(16) |
Jul
(13) |
Aug
(16) |
Sep
(6) |
Oct
(4) |
Nov
(10) |
Dec
(7) |
2018 |
Jan
(16) |
Feb
(17) |
Mar
(11) |
Apr
(13) |
May
(20) |
Jun
(3) |
Jul
(10) |
Aug
|
Sep
(3) |
Oct
(1) |
Nov
(6) |
Dec
(18) |
2019 |
Jan
(18) |
Feb
(31) |
Mar
(4) |
Apr
(4) |
May
(1) |
Jun
(8) |
Jul
(7) |
Aug
(10) |
Sep
(23) |
Oct
(6) |
Nov
(3) |
Dec
(5) |
2020 |
Jan
(10) |
Feb
(18) |
Mar
(34) |
Apr
(19) |
May
(6) |
Jun
(9) |
Jul
|
Aug
(10) |
Sep
(16) |
Oct
(6) |
Nov
(3) |
Dec
(11) |
2021 |
Jan
(118) |
Feb
(22) |
Mar
(13) |
Apr
(12) |
May
(48) |
Jun
(21) |
Jul
(17) |
Aug
(12) |
Sep
(19) |
Oct
(25) |
Nov
(16) |
Dec
(7) |
2022 |
Jan
(6) |
Feb
(7) |
Mar
(14) |
Apr
(4) |
May
|
Jun
(16) |
Jul
(18) |
Aug
(5) |
Sep
(12) |
Oct
(8) |
Nov
(10) |
Dec
(13) |
2023 |
Jan
|
Feb
(3) |
Mar
(2) |
Apr
(1) |
May
(2) |
Jun
(6) |
Jul
(3) |
Aug
(3) |
Sep
(3) |
Oct
(2) |
Nov
(7) |
Dec
(13) |
2024 |
Jan
(8) |
Feb
(6) |
Mar
(5) |
Apr
(10) |
May
(8) |
Jun
(6) |
Jul
(2) |
Aug
(1) |
Sep
(2) |
Oct
(4) |
Nov
(15) |
Dec
(10) |
2025 |
Jan
(3) |
Feb
(12) |
Mar
(3) |
Apr
(7) |
May
(18) |
Jun
(10) |
Jul
(10) |
Aug
(6) |
Sep
(16) |
Oct
(4) |
Nov
|
Dec
|
From: <Gin...@us...> - 2009-04-18 19:38:24
|
Revision: 630 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=630&view=rev Author: GingerDog Date: 2009-04-18 19:38:20 +0000 (Sat, 18 Apr 2009) Log Message: ----------- reindent; fix postgres date formatting issue with +01 times Modified Paths: -------------- trunk/list-virtual.php Modified: trunk/list-virtual.php =================================================================== --- trunk/list-virtual.php 2009-04-15 23:32:45 UTC (rev 629) +++ trunk/list-virtual.php 2009-04-18 19:38:20 UTC (rev 630) @@ -36,11 +36,11 @@ $SESSID_USERNAME = authentication_get_username(); if (authentication_has_role('global-admin')) { - $list_domains = list_domains (); - $is_superadmin = 1; + $list_domains = list_domains (); + $is_superadmin = 1; } else { - $list_domains = list_domains_for_admin(authentication_get_username()); - $is_superadmin = 0; + $list_domains = list_domains_for_admin(authentication_get_username()); + $is_superadmin = 0; } $tAlias = array(); @@ -50,153 +50,156 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { - if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']); - if (isset ($_GET['limit'])) $fDisplay = intval ($_GET['limit']); + if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']); + if (isset ($_GET['limit'])) $fDisplay = intval ($_GET['limit']); } else { - if (isset ($_POST['fDomain'])) $fDomain = escape_string ($_POST['fDomain']); - if (isset ($_POST['limit'])) $fDisplay = intval ($_POST['limit']); + if (isset ($_POST['fDomain'])) $fDomain = escape_string ($_POST['fDomain']); + if (isset ($_POST['limit'])) $fDisplay = intval ($_POST['limit']); } if (count($list_domains) == 0) { -# die("no domains"); - header("Location: list-domain.php"); # no domains (for this admin at least) - redirect to domain list + # die("no domains"); + header("Location: list-domain.php"); # no domains (for this admin at least) - redirect to domain list } if ((is_array ($list_domains) and sizeof ($list_domains) > 0)) if (empty ($fDomain)) $fDomain = $list_domains[0]; if (!check_owner(authentication_get_username(), $fDomain)) { -# die($PALANG['invalid_parameter']); - header("Location: list-domain.php"); # domain not owned by this admin - exit(0); + # die($PALANG['invalid_parameter']); + header("Location: list-domain.php"); # domain not owned by this admin + exit(0); } if (boolconf('alias_domain')) { - # Alias-Domains - # first try to get a list of other domains pointing - # to this currently chosen one (aka. alias domains) - $query = "SELECT $table_alias_domain.alias_domain,$table_alias_domain.target_domain,$table_alias_domain.modified,$table_alias_domain.active FROM $table_alias_domain WHERE target_domain='$fDomain' ORDER BY $table_alias_domain.alias_domain LIMIT $fDisplay, $page_size"; - if ('pgsql'==$CONF['database_type']) - { - $query = "SELECT alias_domain,target_domain,extract(epoch from modified) as modified,active FROM $table_alias_domain WHERE target_domain='$fDomain' ORDER BY alias_domain LIMIT $page_size OFFSET $fDisplay"; - } - $result = db_query ($query); - $tAliasDomains = array(); - if ($result['rows'] > 0) - { - while ($row = db_array ($result['result'])) - { - if ('pgsql'==$CONF['database_type']) - { - $row['modified']=gmstrftime('%c %Z',$row['modified']); - $row['active']=('t'==$row['active']) ? 1 : 0; - } - $tAliasDomains[] = $row; - } - } - # now let's see if the current domain itself is an alias for another domain - $query = "SELECT $table_alias_domain.alias_domain,$table_alias_domain.target_domain,$table_alias_domain.modified,$table_alias_domain.active FROM $table_alias_domain WHERE alias_domain='$fDomain'"; - if ('pgsql'==$CONF['database_type']) - { - $query = "SELECT alias_domain,target_domain,extract(epoch from modified) as modified,active FROM $table_alias_domain WHERE alias_domain='$fDomain'"; - } - $result = db_query ($query); - $tTargetDomain = ""; - if ($result['rows'] > 0) - { - if($row = db_array ($result['result'])) - { - if ('pgsql'==$CONF['database_type']) - { - $row['modified']=gmstrftime('%c %Z',$row['modified']); - $row['active']=('t'==$row['active']) ? 1 : 0; - } - $tTargetDomain = $row; - } - } + # Alias-Domains + # first try to get a list of other domains pointing + # to this currently chosen one (aka. alias domains) + $query = "SELECT $table_alias_domain.alias_domain,$table_alias_domain.target_domain,$table_alias_domain.modified,$table_alias_domain.active FROM $table_alias_domain WHERE target_domain='$fDomain' ORDER BY $table_alias_domain.alias_domain LIMIT $fDisplay, $page_size"; + if ('pgsql'==$CONF['database_type']) + { + $query = "SELECT alias_domain,target_domain,extract(epoch from modified) as modified,active FROM $table_alias_domain WHERE target_domain='$fDomain' ORDER BY alias_domain LIMIT $page_size OFFSET $fDisplay"; + } + $result = db_query ($query); + $tAliasDomains = array(); + if ($result['rows'] > 0) + { + while ($row = db_array ($result['result'])) + { + if ('pgsql'==$CONF['database_type']) + { + $row['modified']=gmstrftime('%c %Z',$row['modified']); + $row['active']=('t'==$row['active']) ? 1 : 0; + } + $tAliasDomains[] = $row; + } + } + # now let's see if the current domain itself is an alias for another domain + $query = "SELECT $table_alias_domain.alias_domain,$table_alias_domain.target_domain,$table_alias_domain.modified,$table_alias_domain.active FROM $table_alias_domain WHERE alias_domain='$fDomain'"; + if ('pgsql'==$CONF['database_type']) + { + $query = "SELECT alias_domain,target_domain,extract(epoch from modified) as modified,active FROM $table_alias_domain WHERE alias_domain='$fDomain'"; + } + $result = db_query ($query); + $tTargetDomain = ""; + if ($result['rows'] > 0) + { + if($row = db_array ($result['result'])) + { + if ('pgsql'==$CONF['database_type']) + { + $row['modified']=gmstrftime('%c %Z',$row['modified']); + $row['active']=('t'==$row['active']) ? 1 : 0; + } + $tTargetDomain = $row; + } + } } $query = "SELECT $table_alias.address, - $table_alias.goto, - $table_alias.modified, - $table_alias.active - FROM $table_alias LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username - WHERE ($table_alias.domain='$fDomain' AND $table_mailbox.maildir IS NULL) - OR - ($table_alias.domain='$fDomain' - AND $table_alias.goto LIKE '%,%' - AND $table_mailbox.maildir IS NOT NULL) - ORDER BY $table_alias.address LIMIT $fDisplay, $page_size"; + $table_alias.goto, + $table_alias.modified, + $table_alias.active + FROM $table_alias LEFT JOIN $table_mailbox ON $table_alias.address=$table_mailbox.username + WHERE ($table_alias.domain='$fDomain' AND $table_mailbox.maildir IS NULL) + OR + ($table_alias.domain='$fDomain' + AND $table_alias.goto LIKE '%,%' + AND $table_mailbox.maildir IS NOT NULL) + ORDER BY $table_alias.address LIMIT $fDisplay, $page_size"; if ('pgsql'==$CONF['database_type']) { - $query = "SELECT address, - goto, - modified, - active - FROM $table_alias WHERE domain='$fDomain' - AND NOT EXISTS(SELECT 1 FROM $table_mailbox - WHERE username=$table_alias.address - AND $table_alias.goto NOT LIKE '%,%') - ORDER BY address LIMIT $page_size OFFSET $fDisplay"; + $query = "SELECT address, + goto, + modified, + active + FROM $table_alias WHERE domain='$fDomain' + AND NOT EXISTS(SELECT 1 FROM $table_mailbox + WHERE username=$table_alias.address + AND $table_alias.goto NOT LIKE '%,%') + ORDER BY address LIMIT $page_size OFFSET $fDisplay"; } $result = db_query ($query); if ($result['rows'] > 0) { - while ($row = db_array ($result['result'])) - { - if ('pgsql'==$CONF['database_type']) - { - $row['modified']=gmstrftime('%c %Z',$row['modified']); - $row['active']=('t'==$row['active']) ? 1 : 0; - } + while ($row = db_array ($result['result'])) + { + if ('pgsql'==$CONF['database_type']) + { + //. at least in my database, $row['modified'] already looks like : 2009-04-11 21:38:10.75586+01, + // while gmstrftime expects an integer value. strtotime seems happy though. + //$row['modified']=gmstrftime('%c %Z',$row['modified']); + $row['modified'] = date('Y-m-d H:i', strtotime($row['modified'])); + $row['active']=('t'==$row['active']) ? 1 : 0; + } - /* Has a real mailbox as well? Remove the address from $row['goto'] in order to edit just the real aliases */ - if (strstr ($row['goto'], ',') != FALSE) - { - $row['goto'] = preg_replace ('/\s*,*\s*' . $row['address'] . '\s*,*\s*/', '', $row['goto']); - } + /* Has a real mailbox as well? Remove the address from $row['goto'] in order to edit just the real aliases */ + if (strstr ($row['goto'], ',') != FALSE) + { + $row['goto'] = preg_replace ('/\s*,*\s*' . $row['address'] . '\s*,*\s*/', '', $row['goto']); + } - $tAlias[] = $row; - } + $tAlias[] = $row; + } } if ($CONF['vacation_control_admin'] == 'YES') { - if (boolconf('used_quotas')) - $query = "SELECT $table_mailbox.*, $table_vacation.active AS v_active, $table_quota.current FROM $table_mailbox LEFT JOIN $table_vacation ON $table_mailbox.username=$table_vacation.email LEFT JOIN $table_quota ON $table_mailbox.username=$table_quota.username WHERE $table_mailbox.domain='$fDomain' AND $table_quota.path='quota/storage' ORDER BY $table_mailbox.username LIMIT $page_size OFFSET $fDisplay"; - else - $query = "SELECT $table_mailbox.*, $table_vacation.active AS v_active FROM $table_mailbox LEFT JOIN $table_vacation ON $table_mailbox.username=$table_vacation.email WHERE $table_mailbox.domain='$fDomain' ORDER BY $table_mailbox.username LIMIT $page_size OFFSET $fDisplay"; + if (boolconf('used_quotas')) + $query = "SELECT $table_mailbox.*, $table_vacation.active AS v_active, $table_quota.current FROM $table_mailbox LEFT JOIN $table_vacation ON $table_mailbox.username=$table_vacation.email LEFT JOIN $table_quota ON $table_mailbox.username=$table_quota.username WHERE $table_mailbox.domain='$fDomain' AND $table_quota.path='quota/storage' ORDER BY $table_mailbox.username LIMIT $page_size OFFSET $fDisplay"; + else + $query = "SELECT $table_mailbox.*, $table_vacation.active AS v_active FROM $table_mailbox LEFT JOIN $table_vacation ON $table_mailbox.username=$table_vacation.email WHERE $table_mailbox.domain='$fDomain' ORDER BY $table_mailbox.username LIMIT $page_size OFFSET $fDisplay"; } else { - $query = "SELECT * FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $fDisplay, $page_size"; - if ('pgsql'==$CONF['database_type']) - { - $query = "SELECT *,extract(epoch from created) as uts_created,extract(epoch from modified) as uts_modified FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $page_size OFFSET $fDisplay"; - } + $query = "SELECT * FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $fDisplay, $page_size"; + if ('pgsql'==$CONF['database_type']) + { + $query = "SELECT *,extract(epoch from created) as uts_created,extract(epoch from modified) as uts_modified FROM $table_mailbox WHERE domain='$fDomain' ORDER BY username LIMIT $page_size OFFSET $fDisplay"; + } } $result = db_query ($query); if ($result['rows'] > 0) { - while ($row = db_array ($result['result'])) - { - if ('pgsql'==$CONF['database_type']) - { - //var_dump($row); - $row['created']=gmstrftime('%c %Z',strtotime($row['created'])); - $row['modified']=gmstrftime('%c %Z',strtotime($row['modified'])); - $row['active']=('t'==$row['active']) ? 1 : 0; - if($row['v_active'] == NULL) { - $row['v_active'] = 'f'; - } - $row['v_active']=('t'==$row['v_active']) ? 1 : 0; - } - $tMailbox[] = $row; - } + while ($row = db_array ($result['result'])) + { + if ('pgsql'==$CONF['database_type']) + { + // XXX + $row['modified'] = date('Y-m-d H:i', strtotime($row['modified'])); + $row['created'] = date('Y-m-d H:i', strtotime($row['created'])); + $row['active']=('t'==$row['active']) ? 1 : 0; + if($row['v_active'] == NULL) { + $row['v_active'] = 'f'; + } + $row['v_active']=('t'==$row['v_active']) ? 1 : 0; + } + $tMailbox[] = $row; + } } $tCanAddAlias = false; @@ -204,32 +207,32 @@ $limit = get_domain_properties($fDomain); if (isset ($limit)) { - if ($fDisplay >= $page_size) { - $tDisplay_back_show = 1; - $tDisplay_back = $fDisplay - $page_size; - } - if (($limit['alias_count'] > $page_size) or ($limit['mailbox_count'] > $page_size)) { - $tDisplay_up_show = 1; - } - if ((($fDisplay + $page_size) < $limit['alias_count']) or - (($fDisplay + $page_size) < $limit['mailbox_count'])) - { - $tDisplay_next_show = 1; - $tDisplay_next = $fDisplay + $page_size; - } + if ($fDisplay >= $page_size) { + $tDisplay_back_show = 1; + $tDisplay_back = $fDisplay - $page_size; + } + if (($limit['alias_count'] > $page_size) or ($limit['mailbox_count'] > $page_size)) { + $tDisplay_up_show = 1; + } + if ((($fDisplay + $page_size) < $limit['alias_count']) or + (($fDisplay + $page_size) < $limit['mailbox_count'])) + { + $tDisplay_next_show = 1; + $tDisplay_next = $fDisplay + $page_size; + } - if($limit['aliases'] == 0) { - $tCanAddAlias = true; - } - elseif($limit['alias_count'] < $limit['aliases']) { - $tCanAddAlias = true; - } - if($limit['mailboxes'] == 0) { - $tCanAddMailbox = true; - } - elseif($limit['mailbox_count'] < $limit['mailboxes']) { - $tCanAddMailbox = true; - } + if($limit['aliases'] == 0) { + $tCanAddAlias = true; + } + elseif($limit['alias_count'] < $limit['aliases']) { + $tCanAddAlias = true; + } + if($limit['mailboxes'] == 0) { + $tCanAddMailbox = true; + } + elseif($limit['mailbox_count'] < $limit['mailboxes']) { + $tCanAddMailbox = true; + } } // this is why we need a proper template layer. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-04-15 23:32:49
|
Revision: 629 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=629&view=rev Author: christian_boltz Date: 2009-04-15 23:32:45 +0000 (Wed, 15 Apr 2009) Log Message: ----------- setup.php: - setup_password is now checked against a hashed value instead of plain text - setup.php will display the hash value of the entered password if it doesn't match - copy&paste ready to include in config.inc.php. No need to compute the password hash yourself ;-) - see generate_setup_password_salt(), encrypt_setup_password() and check_setup_password() for details how the password hashing works. Modified Paths: -------------- trunk/setup.php Modified: trunk/setup.php =================================================================== --- trunk/setup.php 2009-04-15 21:54:18 UTC (rev 628) +++ trunk/setup.php 2009-04-15 23:32:45 UTC (rev 629) @@ -306,17 +306,22 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { - // ensure password is correct. - if(!isset($_POST['setup_password'])) { + # ensure setup password is correct + if (safepost('setup_password') == "" ) { $error += 1; - $tMessage = "Setup password must be specified"; - } - if($_POST['setup_password'] != $CONF['setup_password']) { + $tMessage = "Setup password must be specified<br />If you didn't set up a setup password yet, enter the password you want to use."; + } elseif (strlen(safepost('setup_password')) < $CONF['min_password_length']) { $error += 1; - $tMessage = "Setup password not specified correctly"; + $tMessage = "The setup password you entered is too short. Please choose a better one."; + } else { + $pw_check_result = check_setup_password(safepost('setup_password')); + if ($pw_check_result != 'pass_OK') { + $error += 1; + $tMessage = $pw_check_result; + } } - if($error == 0) { + if($error == 0 && $pw_check_result == 'pass_OK') { if (isset ($_POST['fUsername'])) $fUsername = escape_string ($_POST['fUsername']); if (isset ($_POST['fPassword'])) $fPassword = escape_string ($_POST['fPassword']); if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']); @@ -391,5 +396,34 @@ </body> </html> <?php -/* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ + +function generate_setup_password_salt() { + $salt = time() . '*' . $_SERVER['REMOTE_ADDR'] . '*' . mt_rand(0,60000); + $salt = md5($salt); + return $salt; +} + +function encrypt_setup_password($password, $salt) { + return $salt . ':' . sha1($salt . ':' . $password); +} + +function check_setup_password($password) { + global $CONF; + $setuppw = ""; + if (isset($CONF['setup_password'])) $setuppw = $CONF['setup_password']; + + list($confsalt, $confpass, $trash) = explode(':', $setuppw . '::'); + $pass = encrypt_setup_password($password, $confsalt); + if ($pass == $setuppw) { # correct passsword + $result = "pass_OK"; + } else { + $pass = encrypt_setup_password($password, generate_setup_password_salt()); + $result = '<p><b>Setup password not specified correctly</b></p>'; + $result .= '<p>If you want to use the password you entered as setup password, edit config.inc.php and set</p>'; + $result .= "<pre>\$CONF['setup_password'] = '$pass';</pre>"; + } + return $result; +} + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-04-15 21:54:34
|
Revision: 628 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=628&view=rev Author: christian_boltz Date: 2009-04-15 21:54:18 +0000 (Wed, 15 Apr 2009) Log Message: ----------- model/*, tests/*: - added a vim: comment for tab expansion etc. Modified Paths: -------------- trunk/model/AliasHandler.php trunk/model/UserHandler.php trunk/model/VacationHandler.php trunk/tests/RemoteAliasTest.php trunk/tests/RemoteTest.php trunk/tests/RemoteUserTest.php trunk/tests/RemoteVacationTest.php trunk/tests/common.php trunk/tests/run.php Modified: trunk/model/AliasHandler.php =================================================================== --- trunk/model/AliasHandler.php 2009-04-12 09:39:36 UTC (rev 627) +++ trunk/model/AliasHandler.php 2009-04-15 21:54:18 UTC (rev 628) @@ -185,3 +185,5 @@ return false; } } + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ Modified: trunk/model/UserHandler.php =================================================================== --- trunk/model/UserHandler.php 2009-04-12 09:39:36 UTC (rev 627) +++ trunk/model/UserHandler.php 2009-04-15 21:54:18 UTC (rev 628) @@ -66,3 +66,5 @@ return false; } } + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ Modified: trunk/model/VacationHandler.php =================================================================== --- trunk/model/VacationHandler.php 2009-04-12 09:39:36 UTC (rev 627) +++ trunk/model/VacationHandler.php 2009-04-15 21:54:18 UTC (rev 628) @@ -124,3 +124,5 @@ return $vacation_goto; } } + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ Modified: trunk/tests/RemoteAliasTest.php =================================================================== --- trunk/tests/RemoteAliasTest.php 2009-04-12 09:39:36 UTC (rev 627) +++ trunk/tests/RemoteAliasTest.php 2009-04-15 21:54:18 UTC (rev 628) @@ -59,3 +59,5 @@ $this->assertEqual($this->alias->get(), array()); } } + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ Modified: trunk/tests/RemoteTest.php =================================================================== --- trunk/tests/RemoteTest.php 2009-04-12 09:39:36 UTC (rev 627) +++ trunk/tests/RemoteTest.php 2009-04-15 21:54:18 UTC (rev 628) @@ -80,3 +80,5 @@ } } } + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ Modified: trunk/tests/RemoteUserTest.php =================================================================== --- trunk/tests/RemoteUserTest.php 2009-04-12 09:39:36 UTC (rev 627) +++ trunk/tests/RemoteUserTest.php 2009-04-15 21:54:18 UTC (rev 628) @@ -36,3 +36,5 @@ } } } + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ Modified: trunk/tests/RemoteVacationTest.php =================================================================== --- trunk/tests/RemoteVacationTest.php 2009-04-12 09:39:36 UTC (rev 627) +++ trunk/tests/RemoteVacationTest.php 2009-04-15 21:54:18 UTC (rev 628) @@ -79,3 +79,5 @@ } } + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ Modified: trunk/tests/common.php =================================================================== --- trunk/tests/common.php 2009-04-12 09:39:36 UTC (rev 627) +++ trunk/tests/common.php 2009-04-15 21:54:18 UTC (rev 628) @@ -2,3 +2,5 @@ ini_set('include_path', ini_get('include_path') . ':' . dirname(__FILE__) . '/../'); require_once(dirname(__FILE__) . '/../common.php'); + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ Modified: trunk/tests/run.php =================================================================== --- trunk/tests/run.php 2009-04-12 09:39:36 UTC (rev 627) +++ trunk/tests/run.php 2009-04-15 21:54:18 UTC (rev 628) @@ -15,3 +15,5 @@ $test->addTestFile('./RemoteAliasTest.php'); exit($test->run(new TextReporter()) ? 0 : 1); + +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Seb...@us...> - 2009-04-12 09:39:40
|
Revision: 627 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=627&view=rev Author: Sebastian2009 Date: 2009-04-12 09:39:36 +0000 (Sun, 12 Apr 2009) Log Message: ----------- get in sync with mainline. Modified Paths: -------------- branches/postfixadmin-smarty/ADDITIONS/fetchmail.pl branches/postfixadmin-smarty/DOCUMENTS/POSTFIX_CONF.txt branches/postfixadmin-smarty/common.php branches/postfixadmin-smarty/config.inc.php branches/postfixadmin-smarty/create-mailbox.php branches/postfixadmin-smarty/edit-alias.php branches/postfixadmin-smarty/login.php branches/postfixadmin-smarty/model/AliasHandler.php branches/postfixadmin-smarty/model/UserHandler.php branches/postfixadmin-smarty/setup.php branches/postfixadmin-smarty/xmlrpc.php Modified: branches/postfixadmin-smarty/ADDITIONS/fetchmail.pl =================================================================== --- branches/postfixadmin-smarty/ADDITIONS/fetchmail.pl 2009-04-11 23:24:20 UTC (rev 626) +++ branches/postfixadmin-smarty/ADDITIONS/fetchmail.pl 2009-04-12 09:39:36 UTC (rev 627) @@ -8,6 +8,35 @@ # require liblockfile-simple-perl use LockFile::Simple qw(lock trylock unlock); +###################################################################### +########## Change the following variables to fit your needs ########## + +# database settings + +# database backend - uncomment one of these +our $db_type = 'Pg'; +#my $db_type = 'mysql'; + +# host name +our $db_host="127.0.0.1"; +# database name +our $db_name="postfix"; +# database username +our $db_username="mail"; +# database password +our $db_password="CHANGE_ME!"; + +# instead of changing this script, you can put your settings to /etc/mail/postfixadmin/fetchmail.conf +# just use perl syntax there to fill the variables listed above (without the "our" keyword). Example: +# $db_username = 'mail'; +if (-f "/etc/mail/postfixadmin/fetchmail.conf") { + require "/etc/mail/postfixadmin/fetchmail.conf"; +} + + +#################### Don't change anything below! #################### +###################################################################### + openlog("fetchmail-all", "pid", "mail"); sub log_and_die { @@ -30,11 +59,6 @@ } } -# mysql settings -$database="mailadmin"; -$hostname="127.0.0.1"; -$user="mail"; - $run_dir="/var/run/fetchmail"; # use specified config file @@ -42,26 +66,37 @@ do $configfile; } -$dsn = "DBI:mysql:database=$database;host=$hostname"; +if($db_type eq "Pg" || $db_type eq "mysql") { + $dsn = "DBI:$db_type:database=$db_name;host=$db_host"; +} else { + log_and_die "unsupported db_type $db_type"; +} + $lock_file=$run_dir . "/fetchmail-all.lock"; $lockmgr = LockFile::Simple->make(-autoclean => 1, -max => 1); $lockmgr->lock($lock_file) || log_and_die "can't lock ${lock_file}"; -#mysql connect -$dbh = DBI->connect($dsn, $user, $password) || log_and_die "cannot connect the database"; +# database connect +$dbh = DBI->connect($dsn, $db_username, $db_password) || log_and_die "cannot connect the database"; -$sql=<<SQL; -SELECT id,mailbox,src_server,src_auth,src_user,src_password,src_folder,fetchall,keep,protocol,mda,extra_options,usessl -FROM fetchmail -WHERE unix_timestamp(now())-unix_timestamp(date) > poll_time*60 -SQL +if($db_type eq "Pg") { + $sql_cond = "date_part('epoch',now())-date_part('epoch',date)"; +} elsif($db_type eq "mysql") { + $sql_cond = "unix_timestamp(now())-unix_timestamp(date)"; +} +$sql = " + SELECT id,mailbox,src_server,src_auth,src_user,src_password,src_folder,fetchall,keep,protocol,mda,extra_options,usessl + FROM fetchmail + WHERE $sql_cond > poll_time*60 + "; + my (%config); map{ my ($id,$mailbox,$src_server,$src_auth,$src_user,$src_password,$src_folder,$fetchall,$keep,$protocol,$mda,$extra_options,$usessl)=@$_; - syslog("info","fetch ${src_user}@${src_server} for ${mailbox}"); + syslog("info","fetch ${src_user}@${src_server} for ${mailbox}"); $cmd="user '${src_user}' there with password '".decode_base64($src_password)."'"; $cmd.=" folder '${src_folder}'" if ($src_folder); Modified: branches/postfixadmin-smarty/DOCUMENTS/POSTFIX_CONF.txt =================================================================== --- branches/postfixadmin-smarty/DOCUMENTS/POSTFIX_CONF.txt 2009-04-11 23:24:20 UTC (rev 626) +++ branches/postfixadmin-smarty/DOCUMENTS/POSTFIX_CONF.txt 2009-04-12 09:39:36 UTC (rev 627) @@ -57,7 +57,7 @@ password = password hosts = localhost dbname = postfix -query = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('%u', '@', alias_domain.target_domain) AND alias.active = 1 +query = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('%u', '@', alias_domain.target_domain) AND alias.active = 1 AND alias_domain.active='1' (Note: PostgreSQL does not have a concat() function, instead use e.g. .... alias.address = '%u' || '@' || alias_domain.target_domain AND ....) @@ -67,7 +67,7 @@ password = password hosts = localhost dbname = postfix -query = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('@', alias_domain.target_domain) AND alias.active = 1 +query = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('@', alias_domain.target_domain) AND alias.active = 1 AND alias_domain.active='1' (See above note re Concat + PostgreSQL) @@ -87,18 +87,17 @@ password = password hosts = localhost dbname = postfix -query = SELECT CONCAT(domain,'/',maildir) FROM mailbox WHERE username='%s' AND active = '1' +query = SELECT maildir FROM mailbox WHERE username='%s' AND active = '1' #expansion_limit = 100 -(See above note re Concat + PostgreSQL) - mysql_virtual_alias_domain_mailbox_maps.cf: user = postfix password = password hosts = localhost dbname = postfix -query = SELECT CONCAT(domain,'/',maildir) FROM mailbox,alias_domain WHERE alias_domain.alias_domain = '%d' and mailbox.username = CONCAT('%u', '@', alias_domain.target_domain) AND mailbox.active = 1 +query = SELECT maildir FROM mailbox,alias_domain WHERE alias_domain.alias_domain = '%d' and mailbox.username = CONCAT('%u', '@', alias_domain.target_domain) AND mailbox.active = 1 AND alias_domain.active='1' + (See above note re Concat + PostgreSQL) # For quota support Modified: branches/postfixadmin-smarty/common.php =================================================================== --- branches/postfixadmin-smarty/common.php 2009-04-11 23:24:20 UTC (rev 626) +++ branches/postfixadmin-smarty/common.php 2009-04-12 09:39:36 UTC (rev 627) @@ -22,39 +22,33 @@ } define('POSTFIXADMIN', 1); # checked in included files -function incorrect_setup() { - global $incpath; - # we ask the user to delete setup.php, which makes a blind redirect a bad idea - if(!is_file("$incpath/setup.php")) { - die ("config.inc.php does not exist or is not configured correctly. Please re-install setup.php and create/fix your config."); - } else { - # common.php is indirectly included in setup.php (via upgrade.php) - avoid endless redirect loop - if (!preg_match('/setup\.php$/', $_SERVER['SCRIPT_NAME'])) { - header("Location: setup.php"); - exit(0); - } - } -} - $incpath = dirname(__FILE__); (ini_get('magic_quotes_gpc') ? ini_set('magic_quotes_runtime', '0') : '1'); (ini_get('magic_quotes_gpc') ? ini_set('magic_quotes_sybase', '0') : '1'); -if(ini_get('register_globals')) { +if(ini_get('register_globals') == 'on') { die("Please turn off register_globals; edit your php.ini"); } require_once("$incpath/variables.inc.php"); if(!is_file("$incpath/config.inc.php")) { - // incorrectly setup... - incorrect_setup(); + die("config.inc.php is missing!"); } require_once("$incpath/config.inc.php"); + if(isset($CONF['configured'])) { if($CONF['configured'] == FALSE) { - incorrect_setup(); + die("Please edit config.inc.php - change \$CONF['configured'] to true after setting your database settings"); } + if(!isset($CONF['setup_password'])) { + die("You must have a \$CONF['setup_password'] defined - this allows authenticated access to setup.php"); + } + if($CONF['setup_password'] == 'changeme') { + die("You must specify a password in config.inc.php (\$CONF['setup_password']) in order to access setup.php"); + } } + + require_once("$incpath/languages/language.php"); require_once("$incpath/functions.inc.php"); require_once("$incpath/languages/" . check_language () . ".lang"); Modified: branches/postfixadmin-smarty/config.inc.php =================================================================== --- branches/postfixadmin-smarty/config.inc.php 2009-04-11 23:24:20 UTC (rev 626) +++ branches/postfixadmin-smarty/config.inc.php 2009-04-12 09:39:36 UTC (rev 627) @@ -27,10 +27,12 @@ * The following line needs commenting out or removing before the * application will run! * Doing this implies you have changed this file as required. + * i.e. configuring database etc; specifying setup.php password etc. */ $CONF['configured'] = false; - +// In order to setup Postfixadmin, you MUST change the password below. +$CONF['setup_password'] = 'changeme'; // Postfix Admin Path // Set the location of your Postfix Admin installation here. // YOU MUST ENTER THE COMPLETE URL e.g. http://domain.tld/postfixadmin Modified: branches/postfixadmin-smarty/create-mailbox.php =================================================================== --- branches/postfixadmin-smarty/create-mailbox.php 2009-04-11 23:24:20 UTC (rev 626) +++ branches/postfixadmin-smarty/create-mailbox.php 2009-04-12 09:39:36 UTC (rev 627) @@ -203,69 +203,13 @@ $tMessage = $PALANG['pAlias_result_error'] . "<br />($fUsername -> $fUsername)</br />"; } -/* -# TODO: The following code segment is from admin/create-mailbox.php. To be compared/merged with the code from /create-mailbox.php. - Lines starting with /* were inserted to keep this section in commented mode. - - - if ($result['rows'] != 1) - { - $tDomain = $fDomain; - $tMessage .= $PALANG['pCreate_mailbox_result_error'] . "<br />($fUsername)<br />"; - } - else - { - - $error=TRUE; // Being pessimistic - if (mailbox_postcreation($fUsername,$fDomain,$maildir)) - { - if ('pgsql'==$CONF['database_type']) - { - $result=db_query("COMMIT"); - -/* should really not be possible: */ -/* - if (!$result) die('COMMIT-query failed.'); - } - $error=FALSE; - } else { - $tMessage .= $PALANG['pCreate_mailbox_result_error'] . "<br />($fUsername)<br />"; - if ('pgsql'==$CONF['database_type']) - { - $result=db_query("ROLLBACK"); - -/* should really not be possible: */ -/* - if (!$result) die('ROLLBACK-query failed.'); - } else { - /* - When we cannot count on transactions, we need to move forward, despite - the problems. - */ -/* - $error=FALSE; - } - } - - - if (!$error) - { - db_log ($CONF['admin_email'], $fDomain, 'create_mailbox', $fUsername); - - */ - -/* -TODO: this is the start of /create-mailbox code segment that was originally used in /create-mailbox.php instead - of the above from admin/create-mailbox.php. - To be compared / merged. - */ - // apparently uppercase usernames really confuse some IMAP clients. $fUsername = strtolower($fUsername); $local_part = ''; if(preg_match('/^(.*)@/', $fUsername, $matches)) { $local_part = $matches[1]; } + $result = db_query ("INSERT INTO $table_mailbox (username,password,name,maildir,local_part,quota,domain,created,modified,active) VALUES ('$fUsername','$password','$fName','$maildir','$local_part','$quota','$fDomain',NOW(),NOW(),'$sqlActive')"); if ($result['rows'] != 1 || !mailbox_postcreation($fUsername,$fDomain,$maildir, $quota)) { @@ -277,9 +221,6 @@ { db_query('COMMIT'); db_log ($SESSID_USERNAME, $fDomain, 'create_mailbox', "$fUsername"); -/* -TODO: this is the end of /create-mailbox.php code segment - */ $tDomain = $fDomain; $tQuota = $CONF['maxquota']; Modified: branches/postfixadmin-smarty/edit-alias.php =================================================================== --- branches/postfixadmin-smarty/edit-alias.php 2009-04-11 23:24:20 UTC (rev 626) +++ branches/postfixadmin-smarty/edit-alias.php 2009-04-12 09:39:36 UTC (rev 627) @@ -34,6 +34,10 @@ authentication_require_role('admin'); $SESSID_USERNAME = authentication_get_username(); +if($CONF['alias_control_admin'] == 'NO' && !authentication_has_role('global-admin')) { + die("Check config.inc.php - domain administrators do not have the ability to edit user's aliases (alias_control_admin)"); +} + if ($_SERVER['REQUEST_METHOD'] == "GET") { if (isset ($_GET['address'])) $fAddress = escape_string ($_GET['address']); @@ -46,6 +50,9 @@ { $row = db_array ($result['result']); $tGoto = $row['goto']; + + //. if we are not a global admin, and special_alias_control is NO, hide the alias that's the mailbox name. + if($CONF['special_alias_control'] == 'NO' && !authentication_has_role('global-admin')) { /* Has a mailbox as well? Remove the address from $tGoto in order to edit just the real aliases */ $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fAddress' AND domain='$fDomain'"); @@ -53,7 +60,8 @@ { $tGoto = preg_replace ('/\s*,*\s*' . $fAddress . '\s*,*\s*/', '', $tGoto); } - } + } + } } else { @@ -90,7 +98,7 @@ $goto = preg_replace ('/,*$|^,*/', '', $goto); $goto = preg_replace ('/,,*/', ',', $goto); - if (empty ($goto)) + if (empty ($goto) && !authentication_has_role('global-admin')) { $error = 1; $tGoto = $_POST['fGoto']; @@ -121,11 +129,20 @@ /* The alias has a real mailbox as well, prepend $goto with it */ if ($result['rows'] == 1) { - $goto = "$fAddress,$goto"; + // ensure mailbox alias exists... if they're a domain admin, and they're not allowed to... + if($CONF['alias_control_admin'] == 'NO' && !authentication_has_role('global-admin')) { + $array[] = $fAddress; + } + } + // duplicates suck, mmkay.. + $array = array_unique($array); + $goto = implode(',', $array); + if ($error != 1) { + $goto = escape_string($goto); $result = db_query ("UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$fAddress' AND domain='$fDomain'"); if ($result['rows'] != 1) { Modified: branches/postfixadmin-smarty/login.php =================================================================== --- branches/postfixadmin-smarty/login.php 2009-04-11 23:24:20 UTC (rev 626) +++ branches/postfixadmin-smarty/login.php 2009-04-12 09:39:36 UTC (rev 627) @@ -31,14 +31,13 @@ require_once('common.php'); # force user to delete setup.php (allows creation of superadmins!) -if (file_exists (realpath ("./setup.php"))) { - if (is_string($CONF['configured']) && $CONF['configured'] == 'I_know_the_risk_of_not_deleting_setup.php') - { +if (isset($CONF['configured']) && $CONF['configured'] == 'I_know_the_risk_of_not_deleting_setup.php') { } else { - print "Please delete " . dirname(__FILE__) . "/setup.php before using Postfix Admin!"; - exit; + if($CONF['configured'] !== true) { + print "Installation not yet configured; please edit config.inc.php"; + exit; } } $smarty->assign ('language_selector', language_selector()); Modified: branches/postfixadmin-smarty/model/AliasHandler.php =================================================================== --- branches/postfixadmin-smarty/model/AliasHandler.php 2009-04-11 23:24:20 UTC (rev 626) +++ branches/postfixadmin-smarty/model/AliasHandler.php 2009-04-12 09:39:36 UTC (rev 627) @@ -97,6 +97,8 @@ $addresses = array_unique($addresses); $original = $this->get(true); + $tmp = preg_split('/@/', $this->username); + $domain = $tmp[1]; foreach($original as $address) { if($vacation_persist) { @@ -143,8 +145,6 @@ } if($this->hasAliasRecord() == false) { $true = db_get_boolean(True); - $tmp = preg_split('/@/', $username); - $domain = $tmp[1]; $sql = "INSERT INTO $table_alias (address, goto, domain, created, modified, active) VALUES ('$username', '$goto', '$domain', NOW(), NOW(), $true)"; } else { Modified: branches/postfixadmin-smarty/model/UserHandler.php =================================================================== --- branches/postfixadmin-smarty/model/UserHandler.php 2009-04-11 23:24:20 UTC (rev 626) +++ branches/postfixadmin-smarty/model/UserHandler.php 2009-04-12 09:39:36 UTC (rev 627) @@ -35,7 +35,7 @@ $result = db_query ("UPDATE $table_mailbox SET password='$new_db_password',modified=NOW() WHERE username='$username'"); - db_log ($username, $USERID_DOMAIN, 'edit_password', "$USERID_USERNAME"); + db_log ($username, $USERID_DOMAIN, 'edit_password', "$username"); return true; } Modified: branches/postfixadmin-smarty/setup.php =================================================================== --- branches/postfixadmin-smarty/setup.php 2009-04-11 23:24:20 UTC (rev 626) +++ branches/postfixadmin-smarty/setup.php 2009-04-12 09:39:36 UTC (rev 627) @@ -23,11 +23,8 @@ * Form POST \ GET Variables: -none- */ -define('POSTFIXADMIN', 1); # checked in included files +require_once("common.php"); -require_once("languages/en.lang"); -require_once("functions.inc.php"); - $CONF['show_header_text'] = 'NO'; $CONF['theme_logo'] = 'images/logo-default.png'; $CONF['theme_css'] = 'css/default.css'; @@ -309,6 +306,17 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { + // ensure password is correct. + if(!isset($_POST['setup_password'])) { + $error += 1; + $tMessage = "Setup password must be specified"; + } + if($_POST['setup_password'] != $CONF['setup_password']) { + $error += 1; + $tMessage = "Setup password not specified correctly"; + } + + if($error == 0) { if (isset ($_POST['fUsername'])) $fUsername = escape_string ($_POST['fUsername']); if (isset ($_POST['fPassword'])) $fPassword = escape_string ($_POST['fPassword']); if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']); @@ -325,10 +333,14 @@ if (isset ($_POST['fUsername'])) $tUsername = escape_string ($_POST['fUsername']); } else { print "<p><b>$tMessage</b></p>"; - echo "<p><b>Delete (or rename) setup.php, and then click <a href='login.php'>here to login</a>.</b></p>"; } } + else { + print "<p><b>$tMessage</b></p>"; + } + } + if ($_SERVER['REQUEST_METHOD'] == "GET" || $error != 0) { ?> @@ -340,6 +352,11 @@ <td colspan="3"><h3>Create superadmin account</h3></td> </tr> <tr> + <td>Setup password (see config.inc.php)</td> + <td><input class="flat" type="password" name="setup_password" value="" /></td> + <td></td> + </tr> + <tr> <td><?php print $PALANG['pAdminCreate_admin_username'] . ":"; ?></td> <td><input class="flat" type="text" name="fUsername" value="<?php print $tUsername; ?>" /></td> <td><?php print $pAdminCreate_admin_username_text; ?></td> @@ -367,8 +384,8 @@ <?php } - print "<b>Make sure you delete this setup.php file!</b><br />\n"; - print "Also check the config.inc.php file for any settings that you might need to change!<br />\n"; + print "<b>Since version 2.3 there is no requirement to delete setup.php!</b><br />\n"; + print "<b>Check the config.inc.php file for any other settings that you might need to change!<br />\n"; } ?> </div> Modified: branches/postfixadmin-smarty/xmlrpc.php =================================================================== --- branches/postfixadmin-smarty/xmlrpc.php 2009-04-11 23:24:20 UTC (rev 626) +++ branches/postfixadmin-smarty/xmlrpc.php 2009-04-12 09:39:36 UTC (rev 627) @@ -34,7 +34,6 @@ require_once('Zend/XmlRpc/Server.php'); $server = new Zend_XmlRpc_Server(); -session_start(); /** * @param string $username This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-04-11 23:24:22
|
Revision: 626 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=626&view=rev Author: christian_boltz Date: 2009-04-11 23:24:20 +0000 (Sat, 11 Apr 2009) Log Message: ----------- model/AliasHandler.php: - really ;-) fix undefined variable $username Modified Paths: -------------- trunk/model/AliasHandler.php Modified: trunk/model/AliasHandler.php =================================================================== --- trunk/model/AliasHandler.php 2009-04-11 20:45:38 UTC (rev 625) +++ trunk/model/AliasHandler.php 2009-04-11 23:24:20 UTC (rev 626) @@ -97,7 +97,7 @@ $addresses = array_unique($addresses); $original = $this->get(true); - $tmp = preg_split('/@/', $username); + $tmp = preg_split('/@/', $this->username); $domain = $tmp[1]; foreach($original as $address) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-04-11 20:45:40
|
Revision: 625 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=625&view=rev Author: christian_boltz Date: 2009-04-11 20:45:38 +0000 (Sat, 11 Apr 2009) Log Message: ----------- xmlrpc.php: - remove session_start() - the session is already started in common.php model/UserHandler.php: - db_log() used undefined variable $USERID_USERNAME - use $username instead Modified Paths: -------------- trunk/model/UserHandler.php trunk/xmlrpc.php Modified: trunk/model/UserHandler.php =================================================================== --- trunk/model/UserHandler.php 2009-04-11 20:44:46 UTC (rev 624) +++ trunk/model/UserHandler.php 2009-04-11 20:45:38 UTC (rev 625) @@ -35,7 +35,7 @@ $result = db_query ("UPDATE $table_mailbox SET password='$new_db_password',modified=NOW() WHERE username='$username'"); - db_log ($username, $USERID_DOMAIN, 'edit_password', "$USERID_USERNAME"); + db_log ($username, $USERID_DOMAIN, 'edit_password', "$username"); return true; } Modified: trunk/xmlrpc.php =================================================================== --- trunk/xmlrpc.php 2009-04-11 20:44:46 UTC (rev 624) +++ trunk/xmlrpc.php 2009-04-11 20:45:38 UTC (rev 625) @@ -34,7 +34,6 @@ require_once('Zend/XmlRpc/Server.php'); $server = new Zend_XmlRpc_Server(); -session_start(); /** * @param string $username This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-04-11 20:44:49
|
Revision: 624 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=624&view=rev Author: GingerDog Date: 2009-04-11 20:44:46 +0000 (Sat, 11 Apr 2009) Log Message: ----------- AliasHandler: fix undefined varaible (domain - line 157) Modified Paths: -------------- trunk/model/AliasHandler.php Modified: trunk/model/AliasHandler.php =================================================================== --- trunk/model/AliasHandler.php 2009-04-10 15:27:44 UTC (rev 623) +++ trunk/model/AliasHandler.php 2009-04-11 20:44:46 UTC (rev 624) @@ -97,6 +97,8 @@ $addresses = array_unique($addresses); $original = $this->get(true); + $tmp = preg_split('/@/', $username); + $domain = $tmp[1]; foreach($original as $address) { if($vacation_persist) { @@ -143,8 +145,6 @@ } if($this->hasAliasRecord() == false) { $true = db_get_boolean(True); - $tmp = preg_split('/@/', $username); - $domain = $tmp[1]; $sql = "INSERT INTO $table_alias (address, goto, domain, created, modified, active) VALUES ('$username', '$goto', '$domain', NOW(), NOW(), $true)"; } else { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-04-10 15:27:50
|
Revision: 623 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=623&view=rev Author: christian_boltz Date: 2009-04-10 15:27:44 +0000 (Fri, 10 Apr 2009) Log Message: ----------- setup.php: - remove "define('POSTFIXADMIN', 1)" and inclusion of en.lang - this is already done by common.php (used since r616). This fixes a "already defined" warning. Modified Paths: -------------- trunk/setup.php Modified: trunk/setup.php =================================================================== --- trunk/setup.php 2009-04-10 14:20:46 UTC (rev 622) +++ trunk/setup.php 2009-04-10 15:27:44 UTC (rev 623) @@ -23,9 +23,6 @@ * Form POST \ GET Variables: -none- */ -define('POSTFIXADMIN', 1); # checked in included files - -require_once("languages/en.lang"); require_once('common.php'); $CONF['show_header_text'] = 'NO'; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-04-10 14:20:47
|
Revision: 622 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=622&view=rev Author: christian_boltz Date: 2009-04-10 14:20:46 +0000 (Fri, 10 Apr 2009) Log Message: ----------- templates/search.php: - fix displaying of vacation status in search results - was broken for a) super admins (wrong nesting of if statements) b) mailboxes with vacation switched off (empty and therefore invisible link) templates/admin_search.php: - deleted unused file Modified Paths: -------------- trunk/templates/search.php Removed Paths: ------------- trunk/templates/admin_search.php Deleted: trunk/templates/admin_search.php =================================================================== --- trunk/templates/admin_search.php 2009-04-10 14:02:06 UTC (rev 621) +++ trunk/templates/admin_search.php 2009-04-10 14:20:46 UTC (rev 622) @@ -1,111 +0,0 @@ -<?php if( !defined('POSTFIXADMIN') ) die( "This file cannot be used standalone." ); ?> -<?php -require(dirname(__FILE__) . '/search.tpl'); - -/* old code, should be deleted after testing the merge with templates/search.php -?> - -<div id="overview"> -<form name="search" method="post" action="search.php"> -<table width=750><tr> -<td> - <h4><?php print $PALANG['pSearch_welcome'] . $fSearch; ?></h4> -</td> -<td> - <?php print $PALANG['pSearch']; ?>:<input type="textbox" name="search"> -</td> -<td align=right><select class="flat" name="fDomain" > -<?php -print "<option value=\"$list_domains[0]\" selected>$list_domains[0]</option>\n"; -for ($i = 1; $i < sizeof ($list_domains); $i++) -{ - print "<option value=\"$list_domains[$i]\">$list_domains[$i]</option>\n"; -} -?> -</select> -<input class="button" type="submit" name="fGo" value="Return to <?php print $PALANG['pAdminMenu_list_virtual']; ?>" /></td> -</tr></table> -</form> -</div> - -<?php -if (sizeof ($tAlias) > 0) -{ - print "<table id=\"alias_table\">\n"; - print " <tr>\n"; - print " <td colspan=\"5\"><h3>".$PALANG['pOverview_alias_title']."</h3></td>"; - print " </tr>"; - print " <tr class=\"header\">\n"; - print " <td>" . $PALANG['pOverview_alias_address'] . "</td>\n"; - print " <td>" . $PALANG['pOverview_alias_goto'] . "</td>\n"; - print " <td>" . $PALANG['pOverview_alias_modified'] . "</td>\n"; - print " <td>" . $PALANG['pOverview_alias_active'] . "</td>\n"; - print " <td colspan=\"2\"> </td>\n"; - print " </tr>\n"; - - for ($i = 0; $i < sizeof ($tAlias); $i++) - { - if ((is_array ($tAlias) and sizeof ($tAlias) > 0)) - { - print " <tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n"; - print " <td>" . $tAlias[$i]['address'] . "</td>\n"; - print " <td>" . ereg_replace (",", "<br>", $tAlias[$i]['goto']) . "</td>\n"; - print " <td>" . $tAlias[$i]['modified'] . "</td>\n"; - $active = ($tAlias[$i]['active'] == 1) ? $PALANG['YES'] : $PALANG['NO']; - print " <td><a href=\"edit-active.php?alias=" . urlencode ($tAlias[$i]['address']) . "&domain=" . $tAlias[$i]['domain']. "&return=search.php?search=" . urlencode ($fSearch) . "\">" . $active . "</a></td>\n"; - print " <td><a href=\"edit-alias.php?address=" . urlencode ($tAlias[$i]['address']) . "&domain=" . $tAlias[$i]['domain'] . "\">" . $PALANG['edit'] . "</a></td>\n"; - print " <td><a href=\"delete.php?table=alias&delete=" . urlencode ($tAlias[$i]['address']) . "&domain=" . $tAlias[$i]['domain'] . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_aliases'] . ": ". $tAlias[$i]['address'] . "')\">" . $PALANG['del'] . "</a></td>\n"; - print " </tr>\n"; - } - } - - print "</table>\n"; -} - -if (sizeof ($tMailbox) > 0) -{ - print "<table id=\"mailbox_table\">\n"; - print " <tr>\n"; - print " <td colspan=\"7\"><h3>".$PALANG['pOverview_mailbox_title']."</h3></td>"; - print " </tr>"; - print " <tr class=\"header\">\n"; - print " <td>" . $PALANG['pOverview_mailbox_username'] . "</td>\n"; - print " <td>" . $PALANG['pOverview_mailbox_name'] . "</td>\n"; - if ($CONF['quota'] == 'YES') print " <td>" . $PALANG['pOverview_mailbox_quota'] . "</td>\n"; - print " <td>" . $PALANG['pOverview_mailbox_modified'] . "</td>\n"; - print " <td>" . $PALANG['pOverview_mailbox_active'] . "</td>\n"; - if ($CONF['alias_control'] == 'YES') - { - print " <td colspan=\"3\"> </td>\n"; - } - else - { - print " <td colspan=\"2\"> </td>\n"; - } - print " </tr>\n"; - - for ($i = 0; $i < sizeof ($tMailbox); $i++) - { - if ((is_array ($tMailbox) and sizeof ($tMailbox) > 0)) - { - print " <tr class=\"hilightoff\" onMouseOver=\"className='hilighton';\" onMouseOut=\"className='hilightoff';\">\n"; - print " <td>" . $tMailbox[$i]['username'] . "</td>\n"; - print " <td>" . $tMailbox[$i]['name'] . "</td>\n"; - if ($CONF['quota'] == 'YES') print " <td>" . divide_quota ($tMailbox[$i]['quota']) . "</td>\n"; - print " <td>" . $tMailbox[$i]['modified'] . "</td>\n"; - $active = ($tMailbox[$i]['active'] == 1) ? $PALANG['YES'] : $PALANG['NO']; - print " <td><a href=\"edit-active.php?username=" . urlencode ($tMailbox[$i]['username']) . "&domain=" . $tMailbox[$i]['domain'] . "&return=search.php?search=" . urlencode ($fSearch) . "\">" . $active . "</a></td>\n"; - if ($CONF['alias_control'] == 'YES') - { - print " <td><a href=\"edit-alias.php?address=" . urlencode ($tMailbox[$i]['username']) . "&domain=" . $tMailbox[$i]['domain'] . "\">" . $PALANG['pOverview_alias_edit'] . "</a></td>\n"; - } - print " <td><a href=\"edit-mailbox.php?username=" . urlencode ($tMailbox[$i]['username']) . "&domain=" . $tMailbox[$i]['domain'] . "\">" . $PALANG['edit'] . "</a></td>\n"; - print " <td><a href=\"delete.php?table=mailbox&delete=" . urlencode ($tMailbox[$i]['username']) . "&domain=" . $tMailbox[$i]['domain'] . "\"onclick=\"return confirm ('" . $PALANG['confirm'] . $PALANG['pOverview_get_mailboxes'] . ": ". $tMailbox[$i]['username'] . "')\">" . $PALANG['del'] . "</a></td>\n"; - print " </tr>\n"; - } - } - print "</table>\n"; -} - -/* */ -?> Modified: trunk/templates/search.php =================================================================== --- trunk/templates/search.php 2009-04-10 14:02:06 UTC (rev 621) +++ trunk/templates/search.php 2009-04-10 14:20:46 UTC (rev 622) @@ -161,12 +161,11 @@ if ($CONF['alias_control'] == 'YES') $has_alias_control = 1; } else { if ($CONF['alias_control_admin'] == 'YES') $has_alias_control = 1; - if ($CONF['vacation_control_admin'] == 'YES') - { - $v_active = ($tMailbox[$i]['v_active'] == 1) ? $PALANG['pOverview_vacation_edit'] : ''; - print " <td><a href=\"edit-vacation.php?username=" . urlencode ($tMailbox[$i]['username']) . "&domain=" . $tMailbox[$i]['domain'] . "\">" . $v_active . "</a></td>\n"; - } } + if ($CONF['vacation_control_admin'] == 'YES') { + $v_active = ($tMailbox[$i]['v_active'] == 1) ? $PALANG['pOverview_vacation_edit'] : $PALANG['pOverview_vacation_option']; + print " <td><a href=\"edit-vacation.php?username=" . urlencode ($tMailbox[$i]['username']) . "&domain=" . $tMailbox[$i]['domain'] . "\">" . $v_active . "</a></td>\n"; + } if ($has_alias_control == 1) { print " <td><a href=\"edit-alias.php?address=" . urlencode ($tMailbox[$i]['username']) . "&domain=" . $tMailbox[$i]['domain'] . "\">" . $PALANG['pOverview_alias_edit'] . "</a></td>\n"; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-04-10 14:02:08
|
Revision: 621 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=621&view=rev Author: christian_boltz Date: 2009-04-10 14:02:06 +0000 (Fri, 10 Apr 2009) Log Message: ----------- templates/users_password.php: - fix undefined variable $USERID_USERNAME by using $username instead Modified Paths: -------------- trunk/templates/users_password.php Modified: trunk/templates/users_password.php =================================================================== --- trunk/templates/users_password.php 2009-04-09 20:46:44 UTC (rev 620) +++ trunk/templates/users_password.php 2009-04-10 14:02:06 UTC (rev 621) @@ -7,7 +7,7 @@ </tr> <tr> <td><?php print $PALANG['pPassword_admin'] . ":"; ?></td> - <td><?php print $USERID_USERNAME; ?></td> + <td><?php print $username; ?></td> <td><?php print $pPassword_admin_text; ?></td> </tr> <tr> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-04-09 20:46:54
|
Revision: 620 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=620&view=rev Author: christian_boltz Date: 2009-04-09 20:46:44 +0000 (Thu, 09 Apr 2009) Log Message: ----------- POSTFIX_CONF.txt. - honor alias_domain.active (see mail from Daniel Reichelt in postfixadmin-devel) - fix query for maildir in virtual_mailbox_maps - the maildir field already contains the domain (exact layout depends on the $CONF settings), so there's no need to prepend it again Modified Paths: -------------- trunk/DOCUMENTS/POSTFIX_CONF.txt Modified: trunk/DOCUMENTS/POSTFIX_CONF.txt =================================================================== --- trunk/DOCUMENTS/POSTFIX_CONF.txt 2009-04-09 20:05:45 UTC (rev 619) +++ trunk/DOCUMENTS/POSTFIX_CONF.txt 2009-04-09 20:46:44 UTC (rev 620) @@ -57,7 +57,7 @@ password = password hosts = localhost dbname = postfix -query = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('%u', '@', alias_domain.target_domain) AND alias.active = 1 +query = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('%u', '@', alias_domain.target_domain) AND alias.active = 1 AND alias_domain.active='1' (Note: PostgreSQL does not have a concat() function, instead use e.g. .... alias.address = '%u' || '@' || alias_domain.target_domain AND ....) @@ -67,7 +67,7 @@ password = password hosts = localhost dbname = postfix -query = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('@', alias_domain.target_domain) AND alias.active = 1 +query = SELECT goto FROM alias,alias_domain WHERE alias_domain.alias_domain = '%d' and alias.address = CONCAT('@', alias_domain.target_domain) AND alias.active = 1 AND alias_domain.active='1' (See above note re Concat + PostgreSQL) @@ -87,18 +87,17 @@ password = password hosts = localhost dbname = postfix -query = SELECT CONCAT(domain,'/',maildir) FROM mailbox WHERE username='%s' AND active = '1' +query = SELECT maildir FROM mailbox WHERE username='%s' AND active = '1' #expansion_limit = 100 -(See above note re Concat + PostgreSQL) - mysql_virtual_alias_domain_mailbox_maps.cf: user = postfix password = password hosts = localhost dbname = postfix -query = SELECT CONCAT(domain,'/',maildir) FROM mailbox,alias_domain WHERE alias_domain.alias_domain = '%d' and mailbox.username = CONCAT('%u', '@', alias_domain.target_domain) AND mailbox.active = 1 +query = SELECT maildir FROM mailbox,alias_domain WHERE alias_domain.alias_domain = '%d' and mailbox.username = CONCAT('%u', '@', alias_domain.target_domain) AND mailbox.active = 1 AND alias_domain.active='1' + (See above note re Concat + PostgreSQL) # For quota support This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <chr...@us...> - 2009-04-09 20:06:01
|
Revision: 619 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=619&view=rev Author: christian_boltz Date: 2009-04-09 20:05:45 +0000 (Thu, 09 Apr 2009) Log Message: ----------- fetchmail.pl: - added support for PgSQL - based on patch from johker, https://sourceforge.net/tracker/?func=detail&atid=937966&aid=2747526&group_id=191583 - rename config variables to use names known from vacation.pl - add support for external config file /etc/mail/postfixadmin/fetchmail.conf Modified Paths: -------------- trunk/ADDITIONS/fetchmail.pl Modified: trunk/ADDITIONS/fetchmail.pl =================================================================== --- trunk/ADDITIONS/fetchmail.pl 2009-04-08 20:17:24 UTC (rev 618) +++ trunk/ADDITIONS/fetchmail.pl 2009-04-09 20:05:45 UTC (rev 619) @@ -8,6 +8,35 @@ # require liblockfile-simple-perl use LockFile::Simple qw(lock trylock unlock); +###################################################################### +########## Change the following variables to fit your needs ########## + +# database settings + +# database backend - uncomment one of these +our $db_type = 'Pg'; +#my $db_type = 'mysql'; + +# host name +our $db_host="127.0.0.1"; +# database name +our $db_name="postfix"; +# database username +our $db_username="mail"; +# database password +our $db_password="CHANGE_ME!"; + +# instead of changing this script, you can put your settings to /etc/mail/postfixadmin/fetchmail.conf +# just use perl syntax there to fill the variables listed above (without the "our" keyword). Example: +# $db_username = 'mail'; +if (-f "/etc/mail/postfixadmin/fetchmail.conf") { + require "/etc/mail/postfixadmin/fetchmail.conf"; +} + + +#################### Don't change anything below! #################### +###################################################################### + openlog("fetchmail-all", "pid", "mail"); sub log_and_die { @@ -30,11 +59,6 @@ } } -# mysql settings -$database="mailadmin"; -$hostname="127.0.0.1"; -$user="mail"; - $run_dir="/var/run/fetchmail"; # use specified config file @@ -42,26 +66,37 @@ do $configfile; } -$dsn = "DBI:mysql:database=$database;host=$hostname"; +if($db_type eq "Pg" || $db_type eq "mysql") { + $dsn = "DBI:$db_type:database=$db_name;host=$db_host"; +} else { + log_and_die "unsupported db_type $db_type"; +} + $lock_file=$run_dir . "/fetchmail-all.lock"; $lockmgr = LockFile::Simple->make(-autoclean => 1, -max => 1); $lockmgr->lock($lock_file) || log_and_die "can't lock ${lock_file}"; -#mysql connect -$dbh = DBI->connect($dsn, $user, $password) || log_and_die "cannot connect the database"; +# database connect +$dbh = DBI->connect($dsn, $db_username, $db_password) || log_and_die "cannot connect the database"; -$sql=<<SQL; -SELECT id,mailbox,src_server,src_auth,src_user,src_password,src_folder,fetchall,keep,protocol,mda,extra_options,usessl -FROM fetchmail -WHERE unix_timestamp(now())-unix_timestamp(date) > poll_time*60 -SQL +if($db_type eq "Pg") { + $sql_cond = "date_part('epoch',now())-date_part('epoch',date)"; +} elsif($db_type eq "mysql") { + $sql_cond = "unix_timestamp(now())-unix_timestamp(date)"; +} +$sql = " + SELECT id,mailbox,src_server,src_auth,src_user,src_password,src_folder,fetchall,keep,protocol,mda,extra_options,usessl + FROM fetchmail + WHERE $sql_cond > poll_time*60 + "; + my (%config); map{ my ($id,$mailbox,$src_server,$src_auth,$src_user,$src_password,$src_folder,$fetchall,$keep,$protocol,$mda,$extra_options,$usessl)=@$_; - syslog("info","fetch ${src_user}@${src_server} for ${mailbox}"); + syslog("info","fetch ${src_user}@${src_server} for ${mailbox}"); $cmd="user '${src_user}' there with password '".decode_base64($src_password)."'"; $cmd.=" folder '${src_folder}'" if ($src_folder); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-04-08 20:23:19
|
Revision: 618 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=618&view=rev Author: GingerDog Date: 2009-04-08 20:17:24 +0000 (Wed, 08 Apr 2009) Log Message: ----------- common.php: remove requirement to delete setup.php; require $CONF["setup_password"] is changed etc Modified Paths: -------------- trunk/common.php Modified: trunk/common.php =================================================================== --- trunk/common.php 2009-04-08 20:16:35 UTC (rev 617) +++ trunk/common.php 2009-04-08 20:17:24 UTC (rev 618) @@ -22,20 +22,6 @@ } define('POSTFIXADMIN', 1); # checked in included files -function incorrect_setup() { - global $incpath; - # we ask the user to delete setup.php, which makes a blind redirect a bad idea - if(!is_file("$incpath/setup.php")) { - die ("config.inc.php does not exist or is not configured correctly. Please re-install setup.php and create/fix your config."); - } else { - # common.php is indirectly included in setup.php (via upgrade.php) - avoid endless redirect loop - if (!preg_match('/setup\.php$/', $_SERVER['SCRIPT_NAME'])) { - header("Location: setup.php"); - exit(0); - } - } -} - $incpath = dirname(__FILE__); (ini_get('magic_quotes_gpc') ? ini_set('magic_quotes_runtime', '0') : '1'); (ini_get('magic_quotes_gpc') ? ini_set('magic_quotes_sybase', '0') : '1'); @@ -46,15 +32,23 @@ require_once("$incpath/variables.inc.php"); if(!is_file("$incpath/config.inc.php")) { - // incorrectly setup... - incorrect_setup(); + die("config.inc.php is missing!"); } require_once("$incpath/config.inc.php"); + if(isset($CONF['configured'])) { if($CONF['configured'] == FALSE) { - incorrect_setup(); + die("Please edit config.inc.php - change \$CONF['configured'] to true after setting your database settings"); } + if(!isset($CONF['setup_password'])) { + die("You must have a \$CONF['setup_password'] defined - this allows authenticated access to setup.php"); + } + if($CONF['setup_password'] == 'changeme') { + die("You must specify a password in config.inc.php (\$CONF['setup_password']) in order to access setup.php"); + } } + + require_once("$incpath/languages/language.php"); require_once("$incpath/functions.inc.php"); require_once("$incpath/languages/" . check_language () . ".lang"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-04-08 20:22:40
|
Revision: 616 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=616&view=rev Author: GingerDog Date: 2009-04-08 20:16:05 +0000 (Wed, 08 Apr 2009) Log Message: ----------- setup.php: reindent; require setup_password before it will add an admin user Modified Paths: -------------- trunk/setup.php Modified: trunk/setup.php =================================================================== --- trunk/setup.php 2009-04-08 20:15:03 UTC (rev 615) +++ trunk/setup.php 2009-04-08 20:16:05 UTC (rev 616) @@ -26,7 +26,7 @@ define('POSTFIXADMIN', 1); # checked in included files require_once("languages/en.lang"); -require_once("functions.inc.php"); +require_once('common.php'); $CONF['show_header_text'] = 'NO'; $CONF['theme_logo'] = 'images/logo-default.png'; @@ -74,7 +74,7 @@ } else { - print "<li><b>Unable to check for PHP version. (missing function: phpversion())</b></li>\n"; + print "<li><b>Unable to check for PHP version. (missing function: phpversion())</b></li>\n"; } // @@ -82,13 +82,13 @@ // if ($f_apache_get_version == 1) { - print "<li>" . apache_get_version() . "</li>\n"; + print "<li>" . apache_get_version() . "</li>\n"; } 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. + # 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. } print "</ul>"; @@ -100,18 +100,18 @@ // if ($f_get_magic_quotes_gpc == 1) { - if (get_magic_quotes_gpc () == 0) - { - print "<li>Magic Quotes: Disabled - OK</li>\n"; - } - else - { - print "<li><b>Warning: Magic Quotes: ON (internal workaround used)</b></li>\n"; - } + if (get_magic_quotes_gpc () == 0) + { + print "<li>Magic Quotes: Disabled - OK</li>\n"; + } + else + { + print "<li><b>Warning: Magic Quotes: ON (internal workaround used)</b></li>\n"; + } } else { - print "<li><b>Unable to check for Magic Quotes. (missing function: get_magic_quotes_gpc())</b></li>\n"; + print "<li><b>Unable to check for Magic Quotes. (missing function: get_magic_quotes_gpc())</b></li>\n"; } // @@ -120,27 +120,27 @@ $config_loaded = 0; if ($file_config == 1) { - print "<li>Depends on: presence config.inc.php - OK</li>\n"; - require_once('config.inc.php'); - $config_loaded = 1; + print "<li>Depends on: presence config.inc.php - OK</li>\n"; + require_once('config.inc.php'); + $config_loaded = 1; - require('config.inc.php'); - if(isset($CONF['configured'])) { - 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.inc.php and change this to true (this indicates you've created the database and user)</b>\n"; - } - } + require('config.inc.php'); + if(isset($CONF['configured'])) { + 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.inc.php and change this to true (this indicates you've created the database and user)</b>\n"; + } + } } 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"; - print "<code><pre>cp config.inc.php.sample config.inc.php</pre></code>\n"; - $error =+ 1; + 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"; + print "<code><pre>cp config.inc.php.sample config.inc.php</pre></code>\n"; + $error =+ 1; } // @@ -148,33 +148,33 @@ // if (($f_mysql_connect == 0) and ($f_mysqli_connect == 0) and ($f_pg_connect == 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) - { - 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"; - print " - or with portupgrade -\n"; - print "% portinstall php5-mysqli</pre>\n"; - } - print "To install PostgreSQL support on FreeBSD:<br />\n"; - print "<pre>% cd /usr/ports/databases/php$phpversion-pgsql/\n"; - print "% make clean install\n"; - print " - or with portupgrade -\n"; - print "% portinstall php$phpversion-pgsql</pre></li>\n"; - $error =+ 1; + 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) + { + 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"; + print " - or with portupgrade -\n"; + print "% portinstall php5-mysqli</pre>\n"; + } + print "To install PostgreSQL support on FreeBSD:<br />\n"; + print "<pre>% cd /usr/ports/databases/php$phpversion-pgsql/\n"; + print "% make clean install\n"; + print " - or with portupgrade -\n"; + print "% portinstall php$phpversion-pgsql</pre></li>\n"; + $error =+ 1; } // // MySQL 3.23, 4.0 functions // if ($f_mysql_connect == 1) { - print "<li>Depends on: MySQL 3.23, 4.0 - OK</li>\n"; + print "<li>Depends on: MySQL 3.23, 4.0 - OK</li>\n"; } // @@ -182,14 +182,14 @@ // 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 "(change the database_type to 'mysqli' in config.inc.php!!)\n"; - } - print "</li>"; - } + if ($f_mysqli_connect == 1) + { + print "<li>Depends on: MySQL 4.1 - OK\n"; + if ( !($config_loaded && $CONF['database_type'] == 'mysqli') ) { + print "(change the database_type to 'mysqli' in config.inc.php!!)\n"; + } + print "</li>"; + } } // @@ -197,26 +197,26 @@ // if ($f_pg_connect == 1) { - print "<li>Depends on: PostgreSQL - OK \n"; - if ( !($config_loaded && $CONF['database_type'] == 'pgsql') ) { - print "(change the database_type to 'pgsql' in config.inc.php!!)\n"; - } - print "</li>"; + print "<li>Depends on: PostgreSQL - OK \n"; + if ( !($config_loaded && $CONF['database_type'] == 'pgsql') ) { + print "(change the database_type to 'pgsql' in config.inc.php!!)\n"; + } + print "</li>"; } // // Database connection // if ($config_loaded) { - list ($link, $error_text) = db_connect(TRUE); - if ($error_text == "") { - print "<li>Testing database connection - OK - {$CONF['database_type']}://{$CONF['database_user']}:xxxxx@{$CONF['database_host']}/{$CONF['database_name']}</li>"; - } else { - print "<li><b>Error: Can't connect to database</b><br />\n"; - print "Please edit the \$CONF['database_*'] parameters in config.inc.php.\n"; - print "$error_text</li>\n"; - $error ++; - } + list ($link, $error_text) = db_connect(TRUE); + if ($error_text == "") { + print "<li>Testing database connection - OK - {$CONF['database_type']}://{$CONF['database_user']}:xxxxx@{$CONF['database_host']}/{$CONF['database_name']}</li>"; + } else { + print "<li><b>Error: Can't connect to database</b><br />\n"; + print "Please edit the \$CONF['database_*'] parameters in config.inc.php.\n"; + print "$error_text</li>\n"; + $error ++; + } } // @@ -224,17 +224,17 @@ // if ($f_session_start == 1) { - print "<li>Depends on: session - OK</li>\n"; + print "<li>Depends on: session - OK</li>\n"; } 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"; - print "% make clean install\n"; - print " - or with portupgrade -\n"; - print "% portinstall php$phpversion-session</pre></li>\n"; - $error =+ 1; + 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"; + print "% make clean install\n"; + print " - or with portupgrade -\n"; + print "% portinstall php$phpversion-session</pre></li>\n"; + $error =+ 1; } // @@ -242,17 +242,17 @@ // if ($f_preg_match == 1) { - print "<li>Depends on: pcre - OK</li>\n"; + print "<li>Depends on: pcre - OK</li>\n"; } 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"; - print "% make clean install\n"; - print " - or with portupgrade -\n"; - print "% portinstall php$phpversion-pcre</pre></li>\n"; - $error =+ 1; + 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"; + print "% make clean install\n"; + print " - or with portupgrade -\n"; + print "% portinstall php$phpversion-pcre</pre></li>\n"; + $error =+ 1; } // @@ -260,13 +260,13 @@ // if ( $f_mb_encode_mimeheader == 1 ) { - print "<li>Depends on: multibyte string - OK</li>\n"; + print "<li>Depends on: multibyte string - OK</li>\n"; } 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; + 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; } @@ -275,14 +275,14 @@ // if ( $f_imap_open == 1) { - print "<li>Depends on: IMAP functions - OK</li>\n"; + print "<li>Depends on: IMAP functions - OK</li>\n"; } 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"; -# $error =+ 1; + 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"; + # $error =+ 1; } @@ -294,52 +294,71 @@ if ($error != 0) { - print "<p><b>Please fix the errors listed above.</b></p>"; + print "<p><b>Please fix the errors listed above.</b></p>"; } else { print "<p>Everything seems fine... attempting to create/update database structure</p>\n"; require_once('upgrade.php'); - $pAdminCreate_admin_username_text = $PALANG['pAdminCreate_admin_username_text']; - $pAdminCreate_admin_password_text = ""; - $tUsername = ''; - $tMessage = ''; + $pAdminCreate_admin_username_text = $PALANG['pAdminCreate_admin_username_text']; + $pAdminCreate_admin_password_text = ""; + $tUsername = ''; + $tMessage = ''; - if ($_SERVER['REQUEST_METHOD'] == "POST") - { - if (isset ($_POST['fUsername'])) $fUsername = escape_string ($_POST['fUsername']); - if (isset ($_POST['fPassword'])) $fPassword = escape_string ($_POST['fPassword']); - if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']); + if ($_SERVER['REQUEST_METHOD'] == "POST") + { + // ensure password is correct. + if(!isset($_POST['setup_password'])) { + $error += 1; + $tMessage = "Setup password must be specified"; + } + if($_POST['setup_password'] != $CONF['setup_password']) { + $error += 1; + $tMessage = "Setup password not specified correctly"; + } - // XXX need to ensure domains table includes an 'ALL' entry. - $table_domain = table_by_key('domain'); - $r = db_query("SELECT * FROM $table_domain WHERE domain = 'ALL'"); - if($r['rows'] == 0) { - db_insert($table_domain, array('domain' => 'ALL')); // all other fields should default through the schema. - } + if($error == 0) { + if (isset ($_POST['fUsername'])) $fUsername = escape_string ($_POST['fUsername']); + if (isset ($_POST['fPassword'])) $fPassword = escape_string ($_POST['fPassword']); + if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']); - list ($error, $tMessage, $pAdminCreate_admin_username_text, $pAdminCreate_admin_password_text) = create_admin($fUsername, $fPassword, $fPassword2, array('ALL'), TRUE); - if ($error != 0) { - if (isset ($_POST['fUsername'])) $tUsername = escape_string ($_POST['fUsername']); - } else { - print "<p><b>$tMessage</b></p>"; - echo "<p><b>Delete (or rename) setup.php, and then click <a href='login.php'>here to login</a>.</b></p>"; - } - } + // XXX need to ensure domains table includes an 'ALL' entry. + $table_domain = table_by_key('domain'); + $r = db_query("SELECT * FROM $table_domain WHERE domain = 'ALL'"); + if($r['rows'] == 0) { + db_insert($table_domain, array('domain' => 'ALL')); // all other fields should default through the schema. + } - if ($_SERVER['REQUEST_METHOD'] == "GET" || $error != 0) - { - ?> + list ($error, $tMessage, $pAdminCreate_admin_username_text, $pAdminCreate_admin_password_text) = create_admin($fUsername, $fPassword, $fPassword2, array('ALL'), TRUE); + if ($error != 0) { + if (isset ($_POST['fUsername'])) $tUsername = escape_string ($_POST['fUsername']); + } else { + print "<p><b>$tMessage</b></p>"; + } + } + else { + print "<p><b>$tMessage</b></p>"; + } + } + + if ($_SERVER['REQUEST_METHOD'] == "GET" || $error != 0) + { +?> + <div id="edit_form"> <form name="create_admin" method="post"> <table> - <tr> <td colspan="3"><h3>Create superadmin account</h3></td> </tr> <tr> + <td>Setup password (see config.inc.php)</td> + <td><input class="flat" type="password" name="setup_password" value="" /></td> + <td></td> + </tr> + <tr> <td><?php print $PALANG['pAdminCreate_admin_username'] . ":"; ?></td> <td><input class="flat" type="text" name="fUsername" value="<?php print $tUsername; ?>" /></td> <td><?php print $pAdminCreate_admin_username_text; ?></td> @@ -364,11 +383,11 @@ </form> </div> - <?php - } +<?php + } - print "<b>Make sure you delete this setup.php file!</b><br />\n"; - print "Also check the config.inc.php file for any settings that you might need to change!<br />\n"; + print "<b>Since version 2.3 there is no requirement to delete setup.php!</b><br />\n"; + print "<b>Check the config.inc.php file for any other settings that you might need to change!<br />\n"; } ?> </div> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-04-08 20:22:40
|
Revision: 615 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=615&view=rev Author: GingerDog Date: 2009-04-08 20:15:03 +0000 (Wed, 08 Apr 2009) Log Message: ----------- config.inc.php: add setup_password Modified Paths: -------------- trunk/config.inc.php Modified: trunk/config.inc.php =================================================================== --- trunk/config.inc.php 2009-04-06 20:01:18 UTC (rev 614) +++ trunk/config.inc.php 2009-04-08 20:15:03 UTC (rev 615) @@ -27,9 +27,12 @@ * The following line needs commenting out or removing before the * application will run! * Doing this implies you have changed this file as required. + * i.e. configuring database etc; specifying setup.php password etc. */ $CONF['configured'] = false; +// In order to setup Postfixadmin, you MUST change the password below. +$CONF['setup_password'] = 'changeme'; // Postfix Admin Path // Set the location of your Postfix Admin installation here. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-04-08 20:22:39
|
Revision: 617 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=617&view=rev Author: GingerDog Date: 2009-04-08 20:16:35 +0000 (Wed, 08 Apr 2009) Log Message: ----------- login.php: do not require the deletion of setup.php Modified Paths: -------------- trunk/login.php Modified: trunk/login.php =================================================================== --- trunk/login.php 2009-04-08 20:16:05 UTC (rev 616) +++ trunk/login.php 2009-04-08 20:16:35 UTC (rev 617) @@ -30,14 +30,12 @@ require_once('common.php'); -# force user to delete setup.php (allows creation of superadmins!) -if (file_exists (realpath ("./setup.php"))) { - if (is_string($CONF['configured']) && $CONF['configured'] == 'I_know_the_risk_of_not_deleting_setup.php') - { - } - else - { - print "Please delete " . dirname(__FILE__) . "/setup.php before using Postfix Admin!"; +if (isset($CONF['configured']) && $CONF['configured'] == 'I_know_the_risk_of_not_deleting_setup.php') { +} +else +{ + if($CONF['configured'] !== true) { + print "Installation not yet configured; please edit config.inc.php"; exit; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-04-06 20:01:22
|
Revision: 614 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=614&view=rev Author: GingerDog Date: 2009-04-06 20:01:18 +0000 (Mon, 06 Apr 2009) Log Message: ----------- postfixadmin-2.3rc3: 2.3rc3 - based on svn revision 612 (i think) Revision Links: -------------- http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=612&view=rev Added Paths: ----------- branches/postfixadmin-2.3rc3/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-04-06 19:59:18
|
Revision: 613 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=613&view=rev Author: GingerDog Date: 2009-04-06 19:59:11 +0000 (Mon, 06 Apr 2009) Log Message: ----------- debian/changelog, function.inc.php, CHANGELOG.TXT : 2.3 rc3 is almost here Modified Paths: -------------- trunk/CHANGELOG.TXT trunk/debian/changelog trunk/functions.inc.php Modified: trunk/CHANGELOG.TXT =================================================================== --- trunk/CHANGELOG.TXT 2009-04-06 19:54:11 UTC (rev 612) +++ trunk/CHANGELOG.TXT 2009-04-06 19:59:11 UTC (rev 613) @@ -11,6 +11,13 @@ # $Id$ +Version 2.3rc3 - 2009/04/06 - SVN r611 +-------------------------------------- + + - Minor improvements to the Debian packaging, expect more soon + - Assorted bug fixes + - Partial support for per-user fetchmail.pl support + Version 2.3rc2 - 2009/02/03 - SVN r593 -------------------------------------- Modified: trunk/debian/changelog =================================================================== --- trunk/debian/changelog 2009-04-06 19:54:11 UTC (rev 612) +++ trunk/debian/changelog 2009-04-06 19:59:11 UTC (rev 613) @@ -1,3 +1,10 @@ +postfixadmin (2.3rc3) unstable; urgency=low + + * Attempt at fixing Debian build issues (thanks to me...@so...) + * SVN revision 611 + + -- David Goodwin <dav...@pa...> Mon, 6 Apr 2009 20:56:00 +0000 + postfixadmin (2.3rc2) unstable; urgency=low * Subversion revision 593 Modified: trunk/functions.inc.php =================================================================== --- trunk/functions.inc.php 2009-04-06 19:54:11 UTC (rev 612) +++ trunk/functions.inc.php 2009-04-06 19:59:11 UTC (rev 613) @@ -22,7 +22,7 @@ exit; } -$version = '2.3 rc2'; +$version = '2.3 rc3'; /** * check_session This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-04-06 19:54:28
|
Revision: 612 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=612&view=rev Author: GingerDog Date: 2009-04-06 19:54:11 +0000 (Mon, 06 Apr 2009) Log Message: ----------- create-mailbox.php: Remove commented out & dead code Modified Paths: -------------- trunk/create-mailbox.php Modified: trunk/create-mailbox.php =================================================================== --- trunk/create-mailbox.php 2009-04-02 20:49:32 UTC (rev 611) +++ trunk/create-mailbox.php 2009-04-06 19:54:11 UTC (rev 612) @@ -40,10 +40,10 @@ authentication_require_role('admin'); $SESSID_USERNAME = authentication_get_username(); if(authentication_has_role('global-admin')) { - $list_domains = list_domains (); + $list_domains = list_domains (); } else { - $list_domains = list_domains_for_admin($SESSID_USERNAME); + $list_domains = list_domains_for_admin($SESSID_USERNAME); } @@ -53,274 +53,216 @@ if ($_SERVER['REQUEST_METHOD'] == "GET") { - $fDomain = $list_domains[0]; - if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']); + $fDomain = $list_domains[0]; + if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']); - if(!in_array($fDomain, $list_domains)) { - die("Invalid domain name selected, or you tried to select a domain you are not an admin for"); - } - $tDomain = $fDomain; - $result = db_query ("SELECT * FROM $table_domain WHERE domain='$fDomain'"); - if ($result['rows'] == 1) - { - $row = db_array ($result['result']); - $tQuota = $row['maxquota']; - } + if(!in_array($fDomain, $list_domains)) { + die("Invalid domain name selected, or you tried to select a domain you are not an admin for"); + } + $tDomain = $fDomain; + $result = db_query ("SELECT * FROM $table_domain WHERE domain='$fDomain'"); + if ($result['rows'] == 1) + { + $row = db_array ($result['result']); + $tQuota = $row['maxquota']; + } } if ($_SERVER['REQUEST_METHOD'] == "POST") { - if (isset ($_POST['fUsername']) && isset ($_POST['fDomain'])) $fUsername = escape_string ($_POST['fUsername']) . "@" . escape_string ($_POST['fDomain']); - $fUsername = strtolower ($fUsername); - if (isset ($_POST['fPassword'])) $fPassword = escape_string ($_POST['fPassword']); - if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']); - isset ($_POST['fName']) ? $fName = escape_string ($_POST['fName']) : $fName = ""; - if (isset ($_POST['fDomain'])) $fDomain = escape_string ($_POST['fDomain']); - isset ($_POST['fQuota']) ? $fQuota = intval($_POST['fQuota']) : $fQuota = 0; - isset ($_POST['fActive']) ? $fActive = escape_string ($_POST['fActive']) : $fActive = "1"; - if (isset ($_POST['fMail'])) $fMail = escape_string ($_POST['fMail']); + if (isset ($_POST['fUsername']) && isset ($_POST['fDomain'])) $fUsername = escape_string ($_POST['fUsername']) . "@" . escape_string ($_POST['fDomain']); + $fUsername = strtolower ($fUsername); + if (isset ($_POST['fPassword'])) $fPassword = escape_string ($_POST['fPassword']); + if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']); + isset ($_POST['fName']) ? $fName = escape_string ($_POST['fName']) : $fName = ""; + if (isset ($_POST['fDomain'])) $fDomain = escape_string ($_POST['fDomain']); + isset ($_POST['fQuota']) ? $fQuota = intval($_POST['fQuota']) : $fQuota = 0; + isset ($_POST['fActive']) ? $fActive = escape_string ($_POST['fActive']) : $fActive = "1"; + if (isset ($_POST['fMail'])) $fMail = escape_string ($_POST['fMail']); - if ( (!check_owner ($SESSID_USERNAME, $fDomain)) && (!authentication_has_role('global-admin')) ) - { - $error = 1; - $tUsername = escape_string ($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error1']; - } + if ( (!check_owner ($SESSID_USERNAME, $fDomain)) && (!authentication_has_role('global-admin')) ) + { + $error = 1; + $tUsername = escape_string ($_POST['fUsername']); + $tName = $fName; + $tQuota = $fQuota; + $tDomain = $fDomain; + $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error1']; + } - if (!check_mailbox ($fDomain)) - { - $error = 1; - $tUsername = escape_string ($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error3']; - } + if (!check_mailbox ($fDomain)) + { + $error = 1; + $tUsername = escape_string ($_POST['fUsername']); + $tName = $fName; + $tQuota = $fQuota; + $tDomain = $fDomain; + $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error3']; + } - if (empty ($fUsername) or !check_email ($fUsername)) - { - $error = 1; - $tUsername = escape_string ($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error1']; - } + if (empty ($fUsername) or !check_email ($fUsername)) + { + $error = 1; + $tUsername = escape_string ($_POST['fUsername']); + $tName = $fName; + $tQuota = $fQuota; + $tDomain = $fDomain; + $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error1']; + } - $tPassGenerated = 0; - if (empty ($fPassword) or empty ($fPassword2) or ($fPassword != $fPassword2)) - { - if (empty ($fPassword) and empty ($fPassword2) and $CONF['generate_password'] == "YES") - { - $fPassword = generate_password (); - $tPassGenerated = 1; - } - else - { - $error = 1; - $tUsername = escape_string ($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_password_text = $PALANG['pCreate_mailbox_password_text_error']; - } - } + $tPassGenerated = 0; + if (empty ($fPassword) or empty ($fPassword2) or ($fPassword != $fPassword2)) + { + if (empty ($fPassword) and empty ($fPassword2) and $CONF['generate_password'] == "YES") + { + $fPassword = generate_password (); + $tPassGenerated = 1; + } + else + { + $error = 1; + $tUsername = escape_string ($_POST['fUsername']); + $tName = $fName; + $tQuota = $fQuota; + $tDomain = $fDomain; + $pCreate_mailbox_password_text = $PALANG['pCreate_mailbox_password_text_error']; + } + } - if ($CONF['quota'] == "YES") - { - if (!check_quota ($fQuota, $fDomain)) - { - $error = 1; - $tUsername = escape_string ($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_quota_text = $PALANG['pCreate_mailbox_quota_text_error']; - } - } + if ($CONF['quota'] == "YES") + { + if (!check_quota ($fQuota, $fDomain)) + { + $error = 1; + $tUsername = escape_string ($_POST['fUsername']); + $tName = $fName; + $tQuota = $fQuota; + $tDomain = $fDomain; + $pCreate_mailbox_quota_text = $PALANG['pCreate_mailbox_quota_text_error']; + } + } - $result = db_query ("SELECT * FROM $table_alias WHERE address='$fUsername'"); - if ($result['rows'] == 1) - { - $error = 1; - $tUsername = escape_string ($_POST['fUsername']); - $tName = $fName; - $tQuota = $fQuota; - $tDomain = $fDomain; - $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error2']; - } + $result = db_query ("SELECT * FROM $table_alias WHERE address='$fUsername'"); + if ($result['rows'] == 1) + { + $error = 1; + $tUsername = escape_string ($_POST['fUsername']); + $tName = $fName; + $tQuota = $fQuota; + $tDomain = $fDomain; + $pCreate_mailbox_username_text = $PALANG['pCreate_mailbox_username_text_error2']; + } - if ($error != 1) - { - $password = pacrypt ($fPassword); + if ($error != 1) + { + $password = pacrypt ($fPassword); - if ($CONF['domain_path'] == "YES") - { - if ($CONF['domain_in_mailbox'] == "YES") - { - $maildir = $fDomain . "/" . $fUsername . "/"; - } - else - { - $maildir = $fDomain . "/" . escape_string (strtolower($_POST['fUsername'])) . "/"; - } - } - else - { - $maildir = $fUsername . "/"; - } - - if (!empty ($fQuota)) - { - $quota = multiply_quota ($fQuota); - } - else - { - $quota = 0; - } - - if ($fActive == "on") - { - $sqlActive = db_get_boolean(True); - } - else - { - $sqlActive = db_get_boolean(False); - } - if ('pgsql'==$CONF['database_type']) - { - db_query('BEGIN'); - } - - $result = db_query ("INSERT INTO $table_alias (address,goto,domain,created,modified,active) VALUES ('$fUsername','$fUsername','$fDomain',NOW(),NOW(),'$sqlActive')"); - if ($result['rows'] != 1) - { - $tDomain = $fDomain; - $tMessage = $PALANG['pAlias_result_error'] . "<br />($fUsername -> $fUsername)</br />"; - } - -/* -# TODO: The following code segment is from admin/create-mailbox.php. To be compared/merged with the code from /create-mailbox.php. - Lines starting with /* were inserted to keep this section in commented mode. - - - if ($result['rows'] != 1) - { - $tDomain = $fDomain; - $tMessage .= $PALANG['pCreate_mailbox_result_error'] . "<br />($fUsername)<br />"; - } - else - { - - $error=TRUE; // Being pessimistic - if (mailbox_postcreation($fUsername,$fDomain,$maildir)) - { - if ('pgsql'==$CONF['database_type']) + if ($CONF['domain_path'] == "YES") + { + if ($CONF['domain_in_mailbox'] == "YES") { - $result=db_query("COMMIT"); - -/* should really not be possible: */ -/* - if (!$result) die('COMMIT-query failed.'); + $maildir = $fDomain . "/" . $fUsername . "/"; } - $error=FALSE; - } else { - $tMessage .= $PALANG['pCreate_mailbox_result_error'] . "<br />($fUsername)<br />"; - if ('pgsql'==$CONF['database_type']) + else { - $result=db_query("ROLLBACK"); - -/* should really not be possible: */ -/* - if (!$result) die('ROLLBACK-query failed.'); - } else { - /* - When we cannot count on transactions, we need to move forward, despite - the problems. - */ -/* - $error=FALSE; + $maildir = $fDomain . "/" . escape_string (strtolower($_POST['fUsername'])) . "/"; } - } + } + else + { + $maildir = $fUsername . "/"; + } + if (!empty ($fQuota)) + { + $quota = multiply_quota ($fQuota); + } + else + { + $quota = 0; + } - if (!$error) - { - db_log ($CONF['admin_email'], $fDomain, 'create_mailbox', $fUsername); + if ($fActive == "on") + { + $sqlActive = db_get_boolean(True); + } + else + { + $sqlActive = db_get_boolean(False); + } + if ('pgsql'==$CONF['database_type']) + { + db_query('BEGIN'); + } - */ + $result = db_query ("INSERT INTO $table_alias (address,goto,domain,created,modified,active) VALUES ('$fUsername','$fUsername','$fDomain',NOW(),NOW(),'$sqlActive')"); + if ($result['rows'] != 1) + { + $tDomain = $fDomain; + $tMessage = $PALANG['pAlias_result_error'] . "<br />($fUsername -> $fUsername)</br />"; + } -/* -TODO: this is the start of /create-mailbox code segment that was originally used in /create-mailbox.php instead - of the above from admin/create-mailbox.php. - To be compared / merged. - */ - // apparently uppercase usernames really confuse some IMAP clients. - $fUsername = strtolower($fUsername); - $local_part = ''; - if(preg_match('/^(.*)@/', $fUsername, $matches)) { - $local_part = $matches[1]; - } - $result = db_query ("INSERT INTO $table_mailbox (username,password,name,maildir,local_part,quota,domain,created,modified,active) VALUES ('$fUsername','$password','$fName','$maildir','$local_part','$quota','$fDomain',NOW(),NOW(),'$sqlActive')"); - if ($result['rows'] != 1 || !mailbox_postcreation($fUsername,$fDomain,$maildir, $quota)) - { - $tDomain = $fDomain; - $tMessage .= $PALANG['pCreate_mailbox_result_error'] . "<br />($fUsername)<br />"; - db_query('ROLLBACK'); - } - else - { - db_query('COMMIT'); - db_log ($SESSID_USERNAME, $fDomain, 'create_mailbox', "$fUsername"); -/* -TODO: this is the end of /create-mailbox.php code segment - */ - $tDomain = $fDomain; + // apparently uppercase usernames really confuse some IMAP clients. + $fUsername = strtolower($fUsername); + $local_part = ''; + if(preg_match('/^(.*)@/', $fUsername, $matches)) { + $local_part = $matches[1]; + } - $tQuota = $CONF['maxquota']; + $result = db_query ("INSERT INTO $table_mailbox (username,password,name,maildir,local_part,quota,domain,created,modified,active) VALUES ('$fUsername','$password','$fName','$maildir','$local_part','$quota','$fDomain',NOW(),NOW(),'$sqlActive')"); + if ($result['rows'] != 1 || !mailbox_postcreation($fUsername,$fDomain,$maildir, $quota)) + { + $tDomain = $fDomain; + $tMessage .= $PALANG['pCreate_mailbox_result_error'] . "<br />($fUsername)<br />"; + db_query('ROLLBACK'); + } + else + { + db_query('COMMIT'); + db_log ($SESSID_USERNAME, $fDomain, 'create_mailbox', "$fUsername"); + $tDomain = $fDomain; - if ($fMail == "on") - { - $fTo = $fUsername; - $fFrom = $SESSID_USERNAME; - $fHeaders = "To: " . $fTo . "\n"; - $fHeaders .= "From: " . $fFrom . "\n"; + $tQuota = $CONF['maxquota']; - $fHeaders .= "Subject: " . encode_header ($PALANG['pSendmail_subject_text']) . "\n"; - $fHeaders .= "MIME-Version: 1.0\n"; - $fHeaders .= "Content-Type: text/plain; charset=utf-8\n"; - $fHeaders .= "Content-Transfer-Encoding: 8bit\n"; - - $fHeaders .= $CONF['welcome_text']; + if ($fMail == "on") + { + $fTo = $fUsername; + $fFrom = $SESSID_USERNAME; + $fHeaders = "To: " . $fTo . "\n"; + $fHeaders .= "From: " . $fFrom . "\n"; - if (!smtp_mail ($fTo, $fFrom, $fHeaders)) - { - $tMessage .= "<br />" . $PALANG['pSendmail_result_error'] . "<br />"; - } - else - { - $tMessage .= "<br />" . $PALANG['pSendmail_result_success'] . "<br />"; - } - } + $fHeaders .= "Subject: " . encode_header ($PALANG['pSendmail_subject_text']) . "\n"; + $fHeaders .= "MIME-Version: 1.0\n"; + $fHeaders .= "Content-Type: text/plain; charset=utf-8\n"; + $fHeaders .= "Content-Transfer-Encoding: 8bit\n"; - $tShowpass = ""; - if ( $tPassGenerated == 1 || $CONF['show_password'] == "YES") $tShowpass = " / $fPassword"; + $fHeaders .= $CONF['welcome_text']; - if (create_mailbox_subfolders($fUsername,$fPassword)) - { - $tMessage .= $PALANG['pCreate_mailbox_result_success'] . "<br />($fUsername$tShowpass)"; - } else { - $tMessage .= $PALANG['pCreate_mailbox_result_succes_nosubfolders'] . "<br />($fUsername$tShowpass)"; - } + if (!smtp_mail ($fTo, $fFrom, $fHeaders)) + { + $tMessage .= "<br />" . $PALANG['pSendmail_result_error'] . "<br />"; + } + else + { + $tMessage .= "<br />" . $PALANG['pSendmail_result_success'] . "<br />"; + } + } - } - } + $tShowpass = ""; + if ( $tPassGenerated == 1 || $CONF['show_password'] == "YES") $tShowpass = " / $fPassword"; + + if (create_mailbox_subfolders($fUsername,$fPassword)) + { + $tMessage .= $PALANG['pCreate_mailbox_result_success'] . "<br />($fUsername$tShowpass)"; + } else { + $tMessage .= $PALANG['pCreate_mailbox_result_succes_nosubfolders'] . "<br />($fUsername$tShowpass)"; + } + + } + } } include ("templates/header.php"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-04-02 20:49:33
|
Revision: 611 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=611&view=rev Author: GingerDog Date: 2009-04-02 20:49:32 +0000 (Thu, 02 Apr 2009) Log Message: ----------- fix register globals check in common.php - see https://sourceforge.net/tracker/?func=detail&aid=2721614&group_id=191583&atid=937964 Modified Paths: -------------- trunk/common.php Modified: trunk/common.php =================================================================== --- trunk/common.php 2009-04-02 20:30:07 UTC (rev 610) +++ trunk/common.php 2009-04-02 20:49:32 UTC (rev 611) @@ -40,7 +40,7 @@ (ini_get('magic_quotes_gpc') ? ini_set('magic_quotes_runtime', '0') : '1'); (ini_get('magic_quotes_gpc') ? ini_set('magic_quotes_sybase', '0') : '1'); -if(ini_get('register_globals')) { +if(ini_get('register_globals') == 'on') { die("Please turn off register_globals; edit your php.ini"); } require_once("$incpath/variables.inc.php"); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Gin...@us...> - 2009-04-02 20:30:17
|
Revision: 610 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=610&view=rev Author: GingerDog Date: 2009-04-02 20:30:07 +0000 (Thu, 02 Apr 2009) Log Message: ----------- edit-alias.php: reindent and make the $CONF["alias_control_admin"] and $CONF["special_alias_control"] are respected (for domain admins) - global admins can do whatever they like... Modified Paths: -------------- trunk/edit-alias.php Modified: trunk/edit-alias.php =================================================================== --- trunk/edit-alias.php 2009-04-02 11:20:39 UTC (rev 609) +++ trunk/edit-alias.php 2009-04-02 20:30:07 UTC (rev 610) @@ -34,111 +34,126 @@ authentication_require_role('admin'); $SESSID_USERNAME = authentication_get_username(); +if($CONF['alias_control_admin'] == 'NO' && !authentication_has_role('global-admin')) { + die("Check config.inc.php - domain administrators do not have the ability to edit user's aliases (alias_control_admin)"); +} + if ($_SERVER['REQUEST_METHOD'] == "GET") { - if (isset ($_GET['address'])) $fAddress = escape_string ($_GET['address']); - if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']); + if (isset ($_GET['address'])) $fAddress = escape_string ($_GET['address']); + if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']); - if (check_owner ($SESSID_USERNAME, $fDomain) || authentication_has_role('global-admin')) - { - $result = db_query ("SELECT * FROM $table_alias WHERE address='$fAddress' AND domain='$fDomain'"); - if ($result['rows'] == 1) - { - $row = db_array ($result['result']); - $tGoto = $row['goto']; + if (check_owner ($SESSID_USERNAME, $fDomain) || authentication_has_role('global-admin')) + { + $result = db_query ("SELECT * FROM $table_alias WHERE address='$fAddress' AND domain='$fDomain'"); + if ($result['rows'] == 1) + { + $row = db_array ($result['result']); + $tGoto = $row['goto']; - /* Has a mailbox as well? Remove the address from $tGoto in order to edit just the real aliases */ - $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fAddress' AND domain='$fDomain'"); - if ($result['rows'] == 1) - { - $tGoto = preg_replace ('/\s*,*\s*' . $fAddress . '\s*,*\s*/', '', $tGoto); - } - } - } - else - { - $tMessage = $PALANG['pEdit_alias_address_error']; - } + //. if we are not a global admin, and special_alias_control is NO, hide the alias that's the mailbox name. + if($CONF['special_alias_control'] == 'NO' && !authentication_has_role('global-admin')) { + /* Has a mailbox as well? Remove the address from $tGoto in order to edit just the real aliases */ + $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fAddress' AND domain='$fDomain'"); + if ($result['rows'] == 1) + { + $tGoto = preg_replace ('/\s*,*\s*' . $fAddress . '\s*,*\s*/', '', $tGoto); + } + } + } + } + else + { + $tMessage = $PALANG['pEdit_alias_address_error']; + } } if ($_SERVER['REQUEST_METHOD'] == "POST") { - $pEdit_alias_goto = $PALANG['pEdit_alias_goto']; - - if (isset ($_GET['address'])) $fAddress = escape_string ($_GET['address']); - $fAddress = strtolower ($fAddress); - if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']); - if (isset ($_POST['fGoto'])) $fGoto = escape_string ($_POST['fGoto']); - $fGoto = strtolower ($fGoto); + $pEdit_alias_goto = $PALANG['pEdit_alias_goto']; - if (! (check_owner ($SESSID_USERNAME, $fDomain) || authentication_has_role('global-admin')) ) - { - $error = 1; - $tGoto = $_POST['fGoto']; - $tMessage = $PALANG['pEdit_alias_domain_error'] . "$fDomain</span>"; - } - elseif (!check_alias_owner ($SESSID_USERNAME, $fAddress)) - { - $error = 1; - $tGoto = $fGoto; - $tMessage = $PALANG['pEdit_alias_result_error']; - } + if (isset ($_GET['address'])) $fAddress = escape_string ($_GET['address']); + $fAddress = strtolower ($fAddress); + if (isset ($_GET['domain'])) $fDomain = escape_string ($_GET['domain']); + if (isset ($_POST['fGoto'])) $fGoto = escape_string ($_POST['fGoto']); + $fGoto = strtolower ($fGoto); - $goto = preg_replace ('/\\\r\\\n/', ',', $fGoto); - $goto = preg_replace ('/\r\n/', ',', $goto); - $goto = preg_replace ('/[\s]+/i', '', $goto); - $goto = preg_replace ('/,*$|^,*/', '', $goto); - $goto = preg_replace ('/,,*/', ',', $goto); + if (! (check_owner ($SESSID_USERNAME, $fDomain) || authentication_has_role('global-admin')) ) + { + $error = 1; + $tGoto = $_POST['fGoto']; + $tMessage = $PALANG['pEdit_alias_domain_error'] . "$fDomain</span>"; + } + elseif (!check_alias_owner ($SESSID_USERNAME, $fAddress)) + { + $error = 1; + $tGoto = $fGoto; + $tMessage = $PALANG['pEdit_alias_result_error']; + } - if (empty ($goto)) - { - $error = 1; - $tGoto = $_POST['fGoto']; - $tMessage = $PALANG['pEdit_alias_goto_text_error1']; - } + $goto = preg_replace ('/\\\r\\\n/', ',', $fGoto); + $goto = preg_replace ('/\r\n/', ',', $goto); + $goto = preg_replace ('/[\s]+/i', '', $goto); + $goto = preg_replace ('/,*$|^,*/', '', $goto); + $goto = preg_replace ('/,,*/', ',', $goto); - if ($error != 1) - { - $array = preg_split ('/,/', $goto); - } - else - { - $array = array(); - } + if (empty ($goto) && !authentication_has_role('global-admin')) + { + $error = 1; + $tGoto = $_POST['fGoto']; + $tMessage = $PALANG['pEdit_alias_goto_text_error1']; + } - for ($i = 0; $i < sizeof ($array); $i++) { - if (in_array ("$array[$i]", $CONF['default_aliases'])) continue; - if (empty ($array[$i])) continue; # TODO: should never happen - remove after 2.2 release - if (!check_email ($array[$i])) - { - $error = 1; - $tGoto = $goto; - $tMessage = $PALANG['pEdit_alias_goto_text_error2'] . "$array[$i]</span>"; - } - } - - $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fAddress' AND domain='$fDomain'"); - /* The alias has a real mailbox as well, prepend $goto with it */ - if ($result['rows'] == 1) - { - $goto = "$fAddress,$goto"; - } + if ($error != 1) + { + $array = preg_split ('/,/', $goto); + } + else + { + $array = array(); + } - if ($error != 1) - { - $result = db_query ("UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$fAddress' AND domain='$fDomain'"); - if ($result['rows'] != 1) - { - $tMessage = $PALANG['pEdit_alias_result_error']; - } - else - { - db_log ($SESSID_USERNAME, $fDomain, 'edit_alias', "$fAddress -> $goto"); + for ($i = 0; $i < sizeof ($array); $i++) { + if (in_array ("$array[$i]", $CONF['default_aliases'])) continue; + if (empty ($array[$i])) continue; # TODO: should never happen - remove after 2.2 release + if (!check_email ($array[$i])) + { + $error = 1; + $tGoto = $goto; + $tMessage = $PALANG['pEdit_alias_goto_text_error2'] . "$array[$i]</span>"; + } + } - header ("Location: list-virtual.php?domain=$fDomain"); - exit; - } - } + $result = db_query ("SELECT * FROM $table_mailbox WHERE username='$fAddress' AND domain='$fDomain'"); + /* The alias has a real mailbox as well, prepend $goto with it */ + if ($result['rows'] == 1) + { + // ensure mailbox alias exists... if they're a domain admin, and they're not allowed to... + if($CONF['alias_control_admin'] == 'NO' && !authentication_has_role('global-admin')) { + $array[] = $fAddress; + } + } + // duplicates suck, mmkay.. + $array = array_unique($array); + + $goto = implode(',', $array); + + if ($error != 1) + { + $goto = escape_string($goto); + $result = db_query ("UPDATE $table_alias SET goto='$goto',modified=NOW() WHERE address='$fAddress' AND domain='$fDomain'"); + if ($result['rows'] != 1) + { + $tMessage = $PALANG['pEdit_alias_result_error']; + } + else + { + db_log ($SESSID_USERNAME, $fDomain, 'edit_alias', "$fAddress -> $goto"); + + header ("Location: list-virtual.php?domain=$fDomain"); + exit; + } + } } $fAddress = htmlentities($fAddress, ENT_QUOTES); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Seb...@us...> - 2009-04-02 11:20:54
|
Revision: 609 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=609&view=rev Author: Sebastian2009 Date: 2009-04-02 11:20:39 +0000 (Thu, 02 Apr 2009) Log Message: ----------- Get bugfixes from trunk in sync Modified Paths: -------------- branches/postfixadmin-smarty/fetchmail.php branches/postfixadmin-smarty/users/vacation.php Modified: branches/postfixadmin-smarty/fetchmail.php =================================================================== --- branches/postfixadmin-smarty/fetchmail.php 2009-04-02 11:14:17 UTC (rev 608) +++ branches/postfixadmin-smarty/fetchmail.php 2009-04-02 11:20:39 UTC (rev 609) @@ -121,9 +121,10 @@ $row_id = $edit; } - +$user_mailboxes_sql= "'" . implode("','",escape_string(array_values($fm_defaults["mailbox"]))) . "'"; # mailboxes as SQL if ($row_id) { - $result = db_query ("SELECT ".implode(",",escape_string(array_keys($fm_struct)))." FROM $table_fetchmail WHERE id=" . $row_id); + $result = db_query ("SELECT ".implode(",",escape_string(array_keys($fm_struct)))." FROM $table_fetchmail WHERE id=$row_id AND mailbox IN ($user_mailboxes_sql)"); + # TODO: the "AND mailbox IN ..." part should obsolete the check_owner call. Remove it after checking again. if ($result['rows'] > 0) { $edit_row = db_array ($result['result']); $account = $edit_row['src_user'] . " @ " . $edit_row['src_server']; @@ -221,7 +222,8 @@ $tFmail = array(); if ($edit + $new == 0) { # display list - $res = db_query ("SELECT ".implode(",",escape_string(array_keys($fm_struct)))." FROM $table_fetchmail order by id desc"); + # TODO: ORDER BY would even be better if it would order by the _domain_ of the target mailbox first + $res = db_query ("SELECT ".implode(",",escape_string(array_keys($fm_struct)))." FROM $table_fetchmail WHERE mailbox IN ($user_mailboxes_sql) ORDER BY mailbox,src_server,src_user"); if ($res['rows'] > 0) { while ($row = db_array ($res['result'])) { $tFmail[] = $row; Modified: branches/postfixadmin-smarty/users/vacation.php =================================================================== --- branches/postfixadmin-smarty/users/vacation.php 2009-04-02 11:14:17 UTC (rev 608) +++ branches/postfixadmin-smarty/users/vacation.php 2009-04-02 11:20:39 UTC (rev 609) @@ -49,7 +49,8 @@ $tSubject = ''; $tBody = ''; - if($vh->get_details()) { + $details = $vh->get_details(); + if($details != false) { $tSubject = $details['subject']; $tBody = $details['body']; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Seb...@us...> - 2009-04-02 11:14:35
|
Revision: 608 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=608&view=rev Author: Sebastian2009 Date: 2009-04-02 11:14:17 +0000 (Thu, 02 Apr 2009) Log Message: ----------- Change Postfixadmin to use smarty - there is a new folder configs where some basic configurations and definitions are placed - please review file configs/menu.conf for details. Modified Paths: -------------- branches/postfixadmin-smarty/backup.php branches/postfixadmin-smarty/broadcast-message.php branches/postfixadmin-smarty/common.php branches/postfixadmin-smarty/create-admin.php branches/postfixadmin-smarty/create-alias-domain.php branches/postfixadmin-smarty/create-alias.php branches/postfixadmin-smarty/create-domain.php branches/postfixadmin-smarty/create-mailbox.php branches/postfixadmin-smarty/css/default.css branches/postfixadmin-smarty/delete.php branches/postfixadmin-smarty/edit-active-admin.php branches/postfixadmin-smarty/edit-active-domain.php branches/postfixadmin-smarty/edit-active.php branches/postfixadmin-smarty/edit-admin.php branches/postfixadmin-smarty/edit-alias.php branches/postfixadmin-smarty/edit-domain.php branches/postfixadmin-smarty/edit-mailbox.php branches/postfixadmin-smarty/edit-vacation.php branches/postfixadmin-smarty/fetchmail.php branches/postfixadmin-smarty/list-admin.php branches/postfixadmin-smarty/list-domain.php branches/postfixadmin-smarty/list-virtual.php branches/postfixadmin-smarty/login.php branches/postfixadmin-smarty/main.php branches/postfixadmin-smarty/motd-users.txt branches/postfixadmin-smarty/motd.txt branches/postfixadmin-smarty/password.php branches/postfixadmin-smarty/search.php branches/postfixadmin-smarty/sendmail.php branches/postfixadmin-smarty/users/edit-alias.php branches/postfixadmin-smarty/users/login.php branches/postfixadmin-smarty/users/main.php branches/postfixadmin-smarty/users/password.php branches/postfixadmin-smarty/users/vacation.php branches/postfixadmin-smarty/viewlog.php Added Paths: ----------- branches/postfixadmin-smarty/config.local.php branches/postfixadmin-smarty/configs/ branches/postfixadmin-smarty/configs/menu.conf branches/postfixadmin-smarty/smarty.inc.php branches/postfixadmin-smarty/templates/admin_create-admin.tpl branches/postfixadmin-smarty/templates/admin_create-domain.tpl branches/postfixadmin-smarty/templates/admin_edit-admin.tpl branches/postfixadmin-smarty/templates/admin_edit-domain.tpl branches/postfixadmin-smarty/templates/admin_list-admin.tpl branches/postfixadmin-smarty/templates/admin_list-domain.tpl branches/postfixadmin-smarty/templates/broadcast-message.tpl branches/postfixadmin-smarty/templates/create-alias-domain.tpl branches/postfixadmin-smarty/templates/create-alias.tpl branches/postfixadmin-smarty/templates/create-mailbox.tpl branches/postfixadmin-smarty/templates/edit-alias.tpl branches/postfixadmin-smarty/templates/edit-mailbox.tpl branches/postfixadmin-smarty/templates/edit-vacation.tpl branches/postfixadmin-smarty/templates/fetchmail.tpl branches/postfixadmin-smarty/templates/footer.tpl branches/postfixadmin-smarty/templates/header.tpl branches/postfixadmin-smarty/templates/index.tpl branches/postfixadmin-smarty/templates/list-virtual.tpl branches/postfixadmin-smarty/templates/list-virtual_alias.tpl branches/postfixadmin-smarty/templates/list-virtual_alias_domain.tpl branches/postfixadmin-smarty/templates/list-virtual_mailbox.tpl branches/postfixadmin-smarty/templates/login.tpl branches/postfixadmin-smarty/templates/main.tpl branches/postfixadmin-smarty/templates/menu.tpl branches/postfixadmin-smarty/templates/message.tpl branches/postfixadmin-smarty/templates/motd-users.txt branches/postfixadmin-smarty/templates/motd.txt branches/postfixadmin-smarty/templates/overview-get.tpl branches/postfixadmin-smarty/templates/password.tpl branches/postfixadmin-smarty/templates/search.tpl branches/postfixadmin-smarty/templates/sendmail.tpl branches/postfixadmin-smarty/templates/users_edit-alias.tpl branches/postfixadmin-smarty/templates/users_login.tpl branches/postfixadmin-smarty/templates/users_main.tpl branches/postfixadmin-smarty/templates/users_menu.tpl branches/postfixadmin-smarty/templates/users_password.tpl branches/postfixadmin-smarty/templates/users_vacation.tpl branches/postfixadmin-smarty/templates/viewlog.tpl Modified: branches/postfixadmin-smarty/backup.php =================================================================== --- branches/postfixadmin-smarty/backup.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/backup.php 2009-04-02 11:14:17 UTC (rev 608) @@ -30,7 +30,11 @@ // TODO: make backup supported for postgres if ('pgsql'==$CONF['database_type']) { - print '<p>Sorry: Backup is currently not supported for your DBMS.</p>'; + $smarty->assign ('tMessage', '<p>Sorry: Backup is currently not supported for your DBMS ('.$CONF['database_type'].').</p>'); + $smarty->assign ('smarty_template', 'message'); + $smarty->display ('index.tpl'); +// print '<p>Sorry: Backup is currently not supported for your DBMS.</p>'; +die; } /* SELECT attnum,attname,typname,atttypmod-4,attnotnull,atthasdef,adsrc @@ -63,10 +67,10 @@ if (!$fh = fopen ($backup, 'w')) { $tMessage = "<div class=\"error_msg\">Cannot open file ($backup)</div>"; - include ("templates/header.php"); - include ("templates/menu.php"); - include ("templates/message.php"); - include ("templates/footer.php"); + $smarty->assign ('tMessage', $tMessage); + $smarty->assign ('smarty_template', 'message'); + $smarty->display ('index.tpl'); +// include ("templates/message.php"); } else { Modified: branches/postfixadmin-smarty/broadcast-message.php =================================================================== --- branches/postfixadmin-smarty/broadcast-message.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/broadcast-message.php 2009-04-02 11:14:17 UTC (rev 608) @@ -79,19 +79,20 @@ } } } - include ("templates/header.php"); - include ("templates/menu.php"); - echo '<p>'.$PALANG['pBroadcast_success'].'</p>'; - include ("templates/footer.php"); + $smarty->assign ('tMessage', $PALANG['pBroadcast_success']); + $smarty->assign ('smarty_template', 'message'); + $smarty->display ('index.tpl'); +// echo '<p>'.$PALANG['pBroadcast_success'].'</p>'; } } if ($_SERVER['REQUEST_METHOD'] == "GET" || $error == 1) { - include ("templates/header.php"); - include ("templates/menu.php"); - include ("templates/broadcast-message.php"); - include ("templates/footer.php"); + $smarty->assign ('error', $error); + $smarty->assign ('smarty_template', 'broadcast-message'); + $smarty->display ('index.tpl'); + +// include ("templates/broadcast-message.php"); } /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ Modified: branches/postfixadmin-smarty/common.php =================================================================== --- branches/postfixadmin-smarty/common.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/common.php 2009-04-02 11:14:17 UTC (rev 608) @@ -74,4 +74,8 @@ } spl_autoload_register('postfixadmin_autoload'); +//***** +require_once ("$incpath/smarty.inc.php"); +//***** /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ +?> \ No newline at end of file Added: branches/postfixadmin-smarty/config.local.php =================================================================== --- branches/postfixadmin-smarty/config.local.php (rev 0) +++ branches/postfixadmin-smarty/config.local.php 2009-04-02 11:14:17 UTC (rev 608) @@ -0,0 +1,25 @@ +<? +$CONF['postfix_admin_url'] = ''; + +//$CONF['show_header_text'] = 'YES'; +//$CONF['header_text'] = ':: Postfix Admin ::'; + +//$CONF['show_footer_text'] = 'YES'; +//$CONF['footer_text'] = 'Return to change-this-to-your.domain.tld'; +//$CONF['footer_link'] = 'http://change-this-to-your.domain.tld'; + +$CONF['fetchmail'] = 'YES'; + +$CONF['alias_goto_limit'] = '0'; + +$CONF['transport'] = 'YES'; + +//$CONF['page_size'] = '5'; + +//$CONF['vacation_control_admin'] = 'YES'; + +$CONF['quota'] = 'YES'; +//$CONF['used_quotas'] = 'YES'; +//$CONF['alias_domain'] = 'NO'; +$CONF['user_footer_link'] = "main.php"; +?> Added: branches/postfixadmin-smarty/configs/menu.conf =================================================================== --- branches/postfixadmin-smarty/configs/menu.conf (rev 0) +++ branches/postfixadmin-smarty/configs/menu.conf 2009-04-02 11:14:17 UTC (rev 608) @@ -0,0 +1,72 @@ +url_main = main.php +# list_admin +url_list_admin = list-admin.php +url_create_admin = create-admin.php +# list-domain +url_list_domain = list-domain.php +url_create_domain = create-domain.php +# list-virtual +url_list_virtual = list-virtual.php +url_create_mailbox = create-mailbox.php +url_create_alias = create-alias.php +url_create_alias_domain = create-alias-domain.php +# fetchmail +url_fetchmail = fetchmail.php +url_fetchmail_new_entry = fetchmail.php?new=1 +# sendmail +url_sendmail = sendmail.php +url_broadcast_message = broadcast-message.php +# password +url_password = password.php +# backup +url_backup = backup.php +# viewlog +url_viewlog = viewlog.php +# logout +url_logout = logout.php + +# user-menu +url_user_edit_alias = edit-alias.php +url_user_vacation = vacation.php +url_user_password = password.php +url_user_logout = logout.php + + +url_edit_active = edit-active.php + +tr_header = <tr class="header"> +tr_hilightoff = <tr class="hilightoff" onmouseover="className='hilighton';" onmouseout="className='hilightoff';"> + +url_delete = delete.php +url_search = search.php +form_search = <form name="search" method="post" action="search.php"><input name="search" size="10" /></form> + +[main] +_txt_list_domain = pMenu_overview + +[admin_list-admin] +url_edit_active_admin = edit-active-admin.php +url_edit_admin = edit-admin.php + +[admin_list-domain] +url_edit_active_domain = edit-active-domain.php +url_edit_domain = edit-domain.php + +[DISCARDED] +_txt_main = pMenu_main +_txt_list_admin = pAdminMenu_list_admin +_txt_create_admin = pAdminMenu_create_admin +_txt_list_domain = pAdminMenu_list_domain +_txt_create_domain = pAdminMenu_create_domain +_txt_list_virtual = pAdminMenu_list_virtual +_txt_create_mailbox = pMenu_create_mailbox +_txt_create_alias = pMenu_create_alias +_txt_create_alias_domain = pMenu_create_alias_domain +_txt_fetchmail = pMenu_fetchmail +_txt_fetchmail_new_entry = pFetchmail_new_entry +_txt_logout = pMenu_logout +_txt_viewlog = pMenu_viewlog +_txt_password = pMenu_password +_txt_backup = pAdminMenu_backup +_txt_sendmail = pMenu_sendmail +_txt_broadcast_message = pAdminMenu_broadcast_message Modified: branches/postfixadmin-smarty/create-admin.php =================================================================== --- branches/postfixadmin-smarty/create-admin.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/create-admin.php 2009-04-02 11:14:17 UTC (rev 608) @@ -34,7 +34,6 @@ require_once('common.php'); authentication_require_role('global-admin'); - $list_domains = list_domains (); $tDomains = array(); @@ -51,7 +50,6 @@ if (isset ($_POST['fPassword2'])) $fPassword2 = escape_string ($_POST['fPassword2']); $fDomains = array(); if (!empty ($_POST['fDomains'])) $fDomains = $_POST['fDomains']; - list ($error, $tMessage, $pAdminCreate_admin_username_text, $pAdminCreate_admin_password_text) = create_admin($fUsername, $fPassword, $fPassword2, $fDomains); if ($error != 0) { @@ -60,10 +58,14 @@ } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/admin_create-admin.php"); -include ("templates/footer.php"); +$smarty->assign ('tUsername', $tUsername); +$smarty->assign ('pAdminCreate_admin_username_text', $pAdminCreate_admin_username_text); +$smarty->assign ('pAdminCreate_admin_password_text', $pAdminCreate_admin_password_text); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('select_options', select_options ($list_domains, $tDomains)); +$smarty->assign ('smarty_template', 'admin_create-admin'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> Modified: branches/postfixadmin-smarty/create-alias-domain.php =================================================================== --- branches/postfixadmin-smarty/create-alias-domain.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/create-alias-domain.php 2009-04-02 11:14:17 UTC (rev 608) @@ -84,11 +84,14 @@ $fTargetDomain = escape_string ($_REQUEST['target_domain']); $fTargetDomain = strtolower ($fTargetDomain); } +//*** ????? if (isset ($_REQUEST['active'])) { $fActive = (bool)$_REQUEST['active']; } else { + $fActive = false; +} +if (!isset ($_REQUEST['submit'])) $fActive = true; -} if ($_SERVER['REQUEST_METHOD'] == "POST") { @@ -130,10 +133,13 @@ $tMessage .= "<br />($fAliasDomain -> $fTargetDomain)<br />\n"; } - -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/create-alias-domain.php"); -include ("templates/footer.php"); +$smarty->assign ('alias_domains', (count($alias_domains) > 0)); +$smarty->assign ('select_options_alias', select_options ($alias_domains, array ($fAliasDomain))); +$smarty->assign ('select_options_target', select_options ($target_domains, array ($fTargetDomain))); +if ($fActive) $smarty->assign ('fActive', ' checked="checked"'); +if ($error == 1) $tMessage = '<span class="error_msg">'.$tMessage.'</span>'; +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'create-alias-domain'); +$smarty->display ('index.tpl'); /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> Modified: branches/postfixadmin-smarty/create-alias.php =================================================================== --- branches/postfixadmin-smarty/create-alias.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/create-alias.php 2009-04-02 11:14:17 UTC (rev 608) @@ -169,9 +169,14 @@ } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/create-alias.php"); -include ("templates/footer.php"); +$smarty->assign ('tAddress', $tAddress); +$smarty->assign ('select_options', select_options ($list_domains, array ($tDomain))); +$smarty->assign ('pCreate_alias_address_text', $pCreate_alias_address_text); +$smarty->assign ('tGoto', $tGoto); +$smarty->assign ('pCreate_alias_goto_text', $pCreate_alias_goto_text); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'create-alias'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: branches/postfixadmin-smarty/create-domain.php =================================================================== --- branches/postfixadmin-smarty/create-domain.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/create-domain.php 2009-04-02 11:14:17 UTC (rev 608) @@ -142,10 +142,18 @@ } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/admin_create-domain.php"); -include ("templates/footer.php"); +$smarty->assign ('tDomain', $tDomain); +$smarty->assign ('pAdminCreate_domain_domain_text', $pAdminCreate_domain_domain_text); +$smarty->assign ('tDescription', $tDescription); +$smarty->assign ('tAliases', $tAliases); +$smarty->assign ('tMailboxes', $tMailboxes); +$smarty->assign ('tMaxquota', $tMaxquota); +$smarty->assign ('select_options', select_options ($CONF ['transport_options'], array ($tTransport))); +$smarty->assign ('tDefaultaliases', ($tDefaultaliases == 'on') ? ' checked="checked"' : ''); +$smarty->assign ('tBackupmx', ($tBackupmx == 'on') ? ' checked="checked"' : ''); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'admin_create-domain'); +$smarty->display ('index.tpl'); /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: branches/postfixadmin-smarty/create-mailbox.php =================================================================== --- branches/postfixadmin-smarty/create-mailbox.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/create-mailbox.php 2009-04-02 11:14:17 UTC (rev 608) @@ -48,7 +48,6 @@ $pCreate_mailbox_password_text = $PALANG['pCreate_mailbox_password_text']; -$pCreate_mailbox_name_text = $PALANG['pCreate_mailbox_name_text']; $pCreate_mailbox_quota_text = $PALANG['pCreate_mailbox_quota_text']; if ($_SERVER['REQUEST_METHOD'] == "GET") @@ -323,10 +322,17 @@ } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/create-mailbox.php"); -include ("templates/footer.php"); +$smarty->assign ('tUsername', $tUsername); +$smarty->assign ('select_options', select_options ($list_domains, array ($tDomain))); +$smarty->assign ('pCreate_mailbox_username_text', $pCreate_mailbox_username_text); +$smarty->assign ('pCreate_mailbox_password_text', $pCreate_mailbox_password_text); +$smarty->assign ('tName', $tName); +$smarty->assign ('tQuota', $tQuota); +$smarty->assign ('pCreate_mailbox_quota_text', $pCreate_mailbox_quota_text); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'create-mailbox'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> Modified: branches/postfixadmin-smarty/css/default.css =================================================================== --- branches/postfixadmin-smarty/css/default.css 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/css/default.css 2009-04-02 11:14:17 UTC (rev 608) @@ -240,12 +240,6 @@ line-height: 30px; } -#nav_bar { - text-align: right; - width: 750px; - margin: 0 auto; -} - #alias_domain_table, #alias_table, #mailbox_table, #overview_table, #log_table, #admin_table { width: 750px; margin: 0px auto; @@ -313,3 +307,9 @@ div.setup li { padding-bottom:1em; } + +div.nav_bar { + text-align: left; + width: 750px; + margin: 0 auto; +} Modified: branches/postfixadmin-smarty/delete.php =================================================================== --- branches/postfixadmin-smarty/delete.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/delete.php 2009-04-02 11:14:17 UTC (rev 608) @@ -225,11 +225,10 @@ flash_error($PALANG['invalid_parameter']); } +$smarty->assign ('smarty_template', 'message'); +$smarty->assign ('tMessage', $tMessage); +$smarty->display ('index.tpl'); -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/message.php"); -include ("templates/footer.php"); /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: branches/postfixadmin-smarty/edit-active-admin.php =================================================================== --- branches/postfixadmin-smarty/edit-active-admin.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/edit-active-admin.php 2009-04-02 11:14:17 UTC (rev 608) @@ -50,11 +50,10 @@ exit; } } +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'message'); +$smarty->display ('index.tpl'); -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/message.php"); -include ("templates/footer.php"); /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ Modified: branches/postfixadmin-smarty/edit-active-domain.php =================================================================== --- branches/postfixadmin-smarty/edit-active-domain.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/edit-active-domain.php 2009-04-02 11:14:17 UTC (rev 608) @@ -50,10 +50,10 @@ } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/message.php"); -include ("templates/footer.php"); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'message'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> Modified: branches/postfixadmin-smarty/edit-active.php =================================================================== --- branches/postfixadmin-smarty/edit-active.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/edit-active.php 2009-04-02 11:14:17 UTC (rev 608) @@ -106,9 +106,9 @@ } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/message.php"); -include ("templates/footer.php"); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'message'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> Modified: branches/postfixadmin-smarty/edit-admin.php =================================================================== --- branches/postfixadmin-smarty/edit-admin.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/edit-admin.php 2009-04-02 11:14:17 UTC (rev 608) @@ -21,8 +21,8 @@ * * tAllDomains * tDomains - * tActive - * tSadmin + * tActive_checked + * tSadmin_checked * * Form POST \ GET Variables: * @@ -131,29 +131,33 @@ $tAllDomains = list_domains(); $tDomains = list_domains_for_admin ($username); -$tActive = ''; +$tActive_checked = ''; $tPassword = $admin_details['password']; if($admin_details['active'] == 't' || $admin_details['active'] == 1) { - $tActive = $admin_details['active']; + $tActive_checked = ' checked="checked"'; } -$tSadmin = '0'; +$tSadmin_checked = ''; $result = db_query ("SELECT * FROM $table_domain_admins WHERE username='$username'"); // could/should be multiple matches to query; if ($result['rows'] >= 1) { $result = $result['result']; while($row = db_array($result)) { if ($row['domain'] == 'ALL') { - $tSadmin = '1'; + $tSadmin_checked = ' checked="checked"'; $tDomains = array(); /* empty the list, they're an admin */ } } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/admin_edit-admin.php"); -include ("templates/footer.php"); +$smarty->assign ('username', $username); +$smarty->assign ('pAdminEdit_admin_password_text', $pAdminEdit_admin_password_text); +$smarty->assign ('tActive_checked', $tActive_checked); +$smarty->assign ('tSadmin_checked', $tSadmin_checked); +$smarty->assign ('select_options', select_options ($tAllDomains, $tDomains)); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'admin_edit-admin'); +$smarty->display ('index.tpl'); /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: branches/postfixadmin-smarty/edit-alias.php =================================================================== --- branches/postfixadmin-smarty/edit-alias.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/edit-alias.php 2009-04-02 11:14:17 UTC (rev 608) @@ -143,10 +143,14 @@ $fAddress = htmlentities($fAddress, ENT_QUOTES); $fDomain = htmlentities($fDomain, ENT_QUOTES); -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/edit-alias.php"); -include ("templates/footer.php"); +$array = preg_split ('/,/', $tGoto); + +$smarty->assign ('fAddress', $fAddress); +$smarty->assign ('array', $array); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'edit-alias'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> Modified: branches/postfixadmin-smarty/edit-domain.php =================================================================== --- branches/postfixadmin-smarty/edit-domain.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/edit-domain.php 2009-04-02 11:14:17 UTC (rev 608) @@ -113,10 +113,18 @@ } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/admin_edit-domain.php"); -include ("templates/footer.php"); +$smarty->assign ('domain', $domain); +$smarty->assign ('tDescription', htmlspecialchars($tDescription, ENT_QUOTES)); +$smarty->assign ('tAliases', $tAliases); +$smarty->assign ('tMailboxes', $tMailboxes); +$smarty->assign ('tMaxquota', $tMaxquota); +$smarty->assign ('select_options', select_options ($CONF ['transport_options'], array ($tTransport))); +if ($tBackupmx) $smarty->assign ('tBackupmx', ' checked="checked"'); +if ($tActive) $smarty->assign ('tActive', ' checked="checked"'); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'admin_edit-domain'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: branches/postfixadmin-smarty/edit-mailbox.php =================================================================== --- branches/postfixadmin-smarty/edit-mailbox.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/edit-mailbox.php 2009-04-02 11:14:17 UTC (rev 608) @@ -175,9 +175,18 @@ } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/edit-mailbox.php"); -include ("templates/footer.php"); +$smarty->assign ('fUsername', $fUsername); +//$smarty->assign ('pEdit_mailbox_username_text', $pEdit_mailbox_username_text); +$smarty->assign ('pEdit_mailbox_password_text', $pEdit_mailbox_password_text); +$smarty->assign ('tName', htmlspecialchars ($tName,ENT_QUOTES)); +$smarty->assign ('pEdit_mailbox_name_text', $pEdit_mailbox_name_text); +$smarty->assign ('tMaxquota', $tMaxquota); +$smarty->assign ('tQuota', $tQuota); +$smarty->assign ('pEdit_mailbox_quota_text', $pEdit_mailbox_quota_text); +if ($tActive) $smarty->assign ('tActive', ' checked="checked"'); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'edit-mailbox'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> Modified: branches/postfixadmin-smarty/edit-vacation.php =================================================================== --- branches/postfixadmin-smarty/edit-vacation.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/edit-vacation.php 2009-04-02 11:14:17 UTC (rev 608) @@ -199,9 +199,13 @@ $tMessage = $PALANG['pVacation_result_error']; } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/edit-vacation.php"); -include ("templates/footer.php"); +$smarty->assign ('tUseremail', $tUseremail); +$smarty->assign ('tSubject', htmlentities(stripslashes($tSubject), ENT_QUOTES, 'UTF-8')); +$smarty->assign ('tBody', htmlentities(stripslashes($tBody), ENT_QUOTES , 'UTF-8')); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('fCanceltarget', $fCanceltarget); +$smarty->assign ('smarty_template', 'edit-vacation'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> Modified: branches/postfixadmin-smarty/fetchmail.php =================================================================== --- branches/postfixadmin-smarty/fetchmail.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/fetchmail.php 2009-04-02 11:14:17 UTC (rev 608) @@ -121,10 +121,9 @@ $row_id = $edit; } -$user_mailboxes_sql= "'" . implode("','",escape_string(array_values($fm_defaults["mailbox"]))) . "'"; # mailboxes as SQL + if ($row_id) { - $result = db_query ("SELECT ".implode(",",escape_string(array_keys($fm_struct)))." FROM $table_fetchmail WHERE id=$row_id AND mailbox IN ($user_mailboxes_sql)"); - # TODO: the "AND mailbox IN ..." part should obsolete the check_owner call. Remove it after checking again. + $result = db_query ("SELECT ".implode(",",escape_string(array_keys($fm_struct)))." FROM $table_fetchmail WHERE id=" . $row_id); if ($result['rows'] > 0) { $edit_row = db_array ($result['result']); $account = $edit_row['src_user'] . " @ " . $edit_row['src_server']; @@ -222,8 +221,7 @@ $tFmail = array(); if ($edit + $new == 0) { # display list - # TODO: ORDER BY would even be better if it would order by the _domain_ of the target mailbox first - $res = db_query ("SELECT ".implode(",",escape_string(array_keys($fm_struct)))." FROM $table_fetchmail WHERE mailbox IN ($user_mailboxes_sql) ORDER BY mailbox,src_server,src_user"); + $res = db_query ("SELECT ".implode(",",escape_string(array_keys($fm_struct)))." FROM $table_fetchmail order by id desc"); if ($res['rows'] > 0) { while ($row = db_array ($res['result'])) { $tFmail[] = $row; @@ -242,11 +240,143 @@ function _inp_password($val){ return base64_encode($val); } +//***** +$headers=array(); +foreach(array_keys($fm_struct) as $row){ + list($editible,$view,$type)=$fm_struct[$row]; + $title = $PALANG['pFetchmail_field_' . $row]; + $comment = $PALANG['pFetchmail_desc_' . $row]; + if ($view){ + $headers[]=$title; +// $headers[]=array($editible, $view, $type, $title, $comment); + } +} +function fetchmail_edit_row($data=array()) +{ + global $fm_struct,$fm_defaults,$PALANG; + $id = $data["id"]; + $_id = $data["id"] * 100 + 1; + $ret = "<table>"; + $ret .= '<tr><td colspan="3"><h3>'.$PALANG['pMenu_fetchmail'] . '</h3></td></tr>'; + # TODO: $formvars possibly contains db-specific boolean values + # TODO: no problems with MySQL, to be tested with PgSQL + # TODO: undefined values may also occour + foreach($fm_struct as $key=>$struct){ + list($editible,$view,$type)=$struct; + $title = $PALANG['pFetchmail_field_' . $key]; + $comment = $PALANG['pFetchmail_desc_' . $key]; + if ($editible){ + $ret.="<tr><td align='left' valign='top'><label for='${_id}' style='width:20em;'>${title}: </label></td>"; + $ret.="<td align=left style='padding-left:.25em;padding-right:.25em;background-color:white;'>"; + $func="_edit_".$type; + if (! function_exists($func)) + $func="_edit_text"; + $val=isset($data[$key]) + ?$data[$key] + :(! is_array($fm_defaults[$key]) + ?$fm_defaults[$key] + :'' + ); + $fm_defaults_key = ""; if (isset($fm_defaults[$key])) $fm_defaults_key = $fm_defaults[$key]; + $ret.=$func($_id++,$key,$fm_defaults_key,$val); + $ret.="</td><td align=left valign=top><i> ${comment}</i></td></tr>\n"; + } + elseif($view){ + $func="_view_".$type; + $val=isset($data[$key]) + ?(function_exists($func) + ?$func($data[$key]) + :nl2br($data[$key]) + ) + :"--x--"; + $ret.="<tr><td align=left valign=top>${title}: </label></td>"; + $ret.="<td align=left valign=top style='padding-left:.25em;padding-right:.25em;background-color:white;'>".$val; + $ret.="</td><td align=left valign=top><i> ${comment}</i></td></tr>\n"; + } + } + $ret.="<tr><td align=center colspan=3> + <input type=submit name=save value='" . $PALANG['save'] . "'> + <input type=submit name=cancel value='" . $PALANG['cancel'] . "'> + "; + if ($id){ + $ret.="<input type=hidden name=edit value='${id}'>"; + } + $ret.="</td></tr>\n"; + $ret.="</table>\n"; + $ret.="<p />\n"; + $ret.="</form>\n"; + $ret.="</div>\n"; + return $ret; +} +function _edit_text($id,$key,$def_vals,$val=""){ + $val=htmlspecialchars($val); + return "<input type=text name=${key} id=${id} value='${val}'>"; +} -include ("./templates/header.php"); -include ("./templates/menu.php"); -include ("./templates/fetchmail.php"); -include ("./templates/footer.php"); +function _edit_password($id,$key,$def_vals,$val=""){ + $val=preg_replace("{.}","*",$val); + return "<input type=password name=${key} id=${id} value='${val}'>"; +} +function _edit_num($id,$key,$def_vals,$val=""){ + $val=(int)($val); + return "<input type=text name=${key} id=${id} value='${val}'>"; +} + +function _edit_bool($id,$key,$def_vals,$val=""){ + $ret="<input type=checkbox name=${key} id=${id}"; + if ($val) + $ret.=" checked"; + $ret.=">"; + return $ret; +} + +function _edit_longtext($id,$key,$def_vals,$val=""){ + $val=htmlspecialchars($val); + return "<textarea name=${key} id=${id} rows=2 style='width:20em;'>${val}</textarea>"; +} + +function _edit_enum($id,$key,$def_vals,$val=""){ + $ret="<select name=${key} id=${id}>"; + foreach($def_vals as $opt_val){ + $ret.="<option"; + if ($opt_val==$val) + $ret.=" selected"; + $ret.=">${opt_val}</option>\n"; + } + $ret.="</select>\n"; + return $ret; +} + +function _listview_id($val){ + return "<a href='?edit=${val}'> ${val} </a>"; +} + +function _listview_bool($val){ + return $val?"+":""; +} + +function _listview_longtext($val){ + return strlen($val)?"Text - ".strlen($val)." chars":"--x--"; +} + +function _listview_text($val){ + return sizeof($val)?$val:"--x--"; +} + +function _listview_password($val){ + return preg_replace("{.}","*",$val); +} + +$smarty->assign ('edit', $edit); +$smarty->assign ('new', $new); +$smarty->assign ('fetchmail_edit_row', fetchmail_edit_row($formvars)); +$smarty->assign ('headers', $headers); +$smarty->assign ('user_domains', $user_domains); +$smarty->assign ('tFmail', $tFmail); + +$smarty->assign ('smarty_template', 'fetchmail'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> Modified: branches/postfixadmin-smarty/list-admin.php =================================================================== --- branches/postfixadmin-smarty/list-admin.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/list-admin.php 2009-04-02 11:14:17 UTC (rev 608) @@ -25,17 +25,24 @@ authentication_require_role('global-admin'); +$_active = array ($PALANG ['NO'], $PALANG ['YES']); + $list_admins = list_admins(); -if ((is_array ($list_admins) and sizeof ($list_admins) > 0)) { - for ($i = 0; $i < sizeof ($list_admins); $i++) { - $admin_properties[$i] = get_admin_properties ($list_admins[$i]); - } +if ((is_array ($list_admins) and sizeof ($list_admins) > 0)) +{ + for ($i = 0; $i < sizeof ($list_admins); $i++) + { + $admin_properties[$i] = get_admin_properties ($list_admins[$i]); + $admin_properties[$i] ['name'] = $list_admins[$i]; + if ($admin_properties [$i] ['domain_count'] == 'ALL') + $admin_properties [$i] ['domain_count'] = $PALANG ['pAdminEdit_admin_super_admin']; + $admin_properties [$i] ['active'] = $_active [$admin_properties [$i] ['active']]; + } } +$smarty->assign ('admin_properties', $admin_properties); +$smarty->assign ('tMessage', $tMessage); +$smarty->assign ('smarty_template', 'admin_list-admin'); +$smarty->display ('index.tpl'); -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/admin_list-admin.php"); -include ("templates/footer.php"); - /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: branches/postfixadmin-smarty/list-domain.php =================================================================== --- branches/postfixadmin-smarty/list-domain.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/list-domain.php 2009-04-02 11:14:17 UTC (rev 608) @@ -50,24 +50,36 @@ $list_domains = list_domains_for_admin(authentication_get_username()); } - if (!empty ($list_domains)) - { - for ($i = 0; $i < sizeof ($list_domains); $i++) - { - $domain_properties[$i] = get_domain_properties ($list_domains[$i]); - } - } +if (!empty ($list_domains)) +{ + for ($i = 0; $i < sizeof ($list_domains); $i++) + { + $domain_properties [$i] = get_domain_properties ($list_domains[$i]); + + $domain_properties [$i]['name'] = $list_domains [$i]; + $domain_properties [$i]['backupmx'] = ($domain_properties [$i]['backupmx'] == 1) ? $PALANG ['YES'] : $PALANG ['NO']; + $domain_properties [$i]['active'] = ($domain_properties [$i]['active'] == 1) ? $PALANG ['YES'] : $PALANG ['NO']; + + $domain_properties [$i]['maxquota'] = eval_size ($domain_properties [$i]['maxquota']); + $domain_properties [$i]['aliases'] = eval_size ($domain_properties [$i]['aliases']); + $domain_properties [$i]['mailboxes'] = eval_size ($domain_properties [$i]['mailboxes']); + } +} #} -include ("templates/header.php"); -include ("templates/menu.php"); - -if ($is_superadmin) { - include ("templates/admin_list-domain.php"); -} else { - include ("templates/overview-get.php"); +$smarty->assign ('domain_properties', $domain_properties); +if ($is_superadmin) +{ + $smarty->assign ('select_options', select_options ($list_admins, array ($fUsername))); + $smarty->assign ('smarty_template', 'admin_list-domain'); } -include ("templates/footer.php"); +else +{ + $smarty->assign ('select_options', select_options ($list_domains, array ($_GET['domain']))); + $smarty->assign ('smarty_template', 'overview-get'); +} +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> Modified: branches/postfixadmin-smarty/list-virtual.php =================================================================== --- branches/postfixadmin-smarty/list-virtual.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/list-virtual.php 2009-04-02 11:14:17 UTC (rev 608) @@ -230,14 +230,164 @@ elseif($limit['mailbox_count'] < $limit['mailboxes']) { $tCanAddMailbox = true; } + + $limit ['aliases'] = eval_size ($limit ['aliases']); + $limit ['mailboxes'] = eval_size ($limit ['mailboxes']); + $limit ['maxquota'] = eval_size ($limit ['maxquota']); } +$gen_show_status = array (); +$check_alias_owner = array (); + +if ((is_array ($tAlias) and sizeof ($tAlias) > 0)) + for ($i = 0; $i < sizeof ($tAlias); $i++) + { + $gen_show_status [$i] = gen_show_status($tAlias[$i]['address']); + $check_alias_owner [$i] = check_alias_owner($SESSID_USERNAME, $tAlias[$i]['address']); + } + +$gen_show_status_mailbox = array (); +$divide_quota = array (); +if ((is_array ($tMailbox) and sizeof ($tMailbox) > 0)) + for ($i = 0; $i < sizeof ($tMailbox); $i++) + { + $gen_show_status_mailbox [$i] = gen_show_status($tMailbox[$i]['username']); + $divide_quota ['current'][$i] = divide_quota ($tMailbox[$i]['current']); + $divide_quota ['quota'][$i] = divide_quota ($tMailbox[$i]['quota']); + } + +class cNav_bar +{ + var $count, $title, $limit, $page_size, $pages; //* arguments + var $url; //* manually + var $fInit, $arr_prev, $arr_next, $arr_top; //* internal + var $anchor; + function cNav_bar ($aCount, $aTitle, $aLimit, $aPage_size, $aPages) + { + $this->count = $aCount; + $this->title = $aTitle; + $this->limit = $aLimit; + $this->page_size = $aPage_size; + $this->pages = $aPages; + $this->url = ''; + $this->fInit = false; + } + function init () + { + $this->anchor = 'a'.substr ($this->title, 3); + $this->url .= '#'.$this->anchor; + ($this->limit >= $this->page_size) ? $this->arr_prev = ' <a href="?limit='.($this->limit - $this->page_size).$this->url.'"><img border="0" src="images/arrow-l.png" title="'.$GLOBALS ['PALANG']['pOverview_left_arrow'].'" alt="'.$GLOBALS ['PALANG']['pOverview_left_arrow'].'"/></a> ' : $this->arr_prev = ''; + ($this->limit > 0) ? $this->arr_top = ' <a href="?limit=0'.$this->url.'"><img border="0" src="images/arrow-u.png" title="'.$GLOBALS ['PALANG']['pOverview_up_arrow'].'" alt="'.$GLOABLS ['PALANG']['pOverview_up_arrow'].'"/></a> ' : $this->arr_top = ''; + (($this->limit + $this->page_size) < ($this->count * $this->page_size)) ? $this->arr_next = ' <a href="?limit='.($this->limit + $this->page_size).$this->url.'"><img border="0" src="images/arrow-r.png" title="'.$GLOBALS ['PALANG']['pOverview_right_arrow'].'" alt="'.$GLOBALS ['PALANG']['pOverview_right_arrow'].'"/></a> ' : $this->arr_next = ''; + $this->fInit = true; + } + function display_pre () + { + $ret_val = '<div class="nav_bar"'; +//$ret_val .= ' style="background-color:#ffa;"'; + $ret_val .= '>'; + $ret_val .= '<table width="730"><colgroup span="1"><col width="550"></col></colgroup> '; + $ret_val .= '<tr><td align="left">'; + return $ret_val; + } + function display_post () + { + $ret_val = '</td></tr></table></div>'; + return $ret_val; + } + function display_top () + { + $ret_val = ''; + if ($this->count < 1) + return $ret_val; + if (!$this->fInit) + $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++) + { + $lPage = $this->pages [$i]; + if ($i == $highlight_at) + $lPage = '<b>'.$lPage.'</b>'; + $ret_val .= '<a href="?limit='.($i * $this->page_size).$this->url.'">'.$lPage.'</a>'."\n"; + } + $ret_val .= '</td><td valign="middle" align="right">'; + + $ret_val .= $this->arr_prev; + $ret_val .= $this->arr_top; + $ret_val .= $this->arr_next; + + $ret_val .= $this->display_post (); + return $ret_val; + } + function display_bottom () + { + $ret_val = ''; + if ($this->count < 1) + return $ret_val; + if (!$this->fInit) + $this->init (); + $ret_val .= $this->display_pre (); + $ret_val .= '</td><td valign="middle" align="right">'; + + $ret_val .= $this->arr_prev; + $ret_val .= $this->arr_top; + $ret_val .= $this->arr_next; + + $ret_val .= $this->display_post (); + return $ret_val; + } +} + +$nav_bar_alias = new cNav_bar ($limit['alias_pgindex_count'], $PALANG['pOverview_alias_title'], $fDisplay, $CONF['page_size'], $limit['alias_pgindex']); +$nav_bar_alias->url = '&domain='.$fDomain; + +$nav_bar_mailbox = new cNav_bar ($limit['mbox_pgindex_count'], $PALANG['pOverview_mailbox_title'], $fDisplay, $CONF['page_size'], $limit['mbox_pgindex']); +$nav_bar_mailbox->url = '&domain='.$fDomain; +//print $nav_bar_alias->display_top (); + + // this is why we need a proper template layer. $fDomain = htmlentities($fDomain, ENT_QUOTES); -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/list-virtual.php"); -include ("templates/footer.php"); +$smarty->assign ('select_options', select_options ($list_domains, array ($fDomain))); +$smarty->assign ('nav_bar_alias', array ('top' => $nav_bar_alias->display_top (), 'bottom' => $nav_bar_alias->display_bottom ())); +$smarty->assign ('nav_bar_mailbox', array ('top' => $nav_bar_mailbox->display_top (), 'bottom' => $nav_bar_mailbox->display_bottom ())); + +$smarty->assign ('fDomain', $fDomain); + +$smarty->assign ('list_domains', $list_domains); +$smarty->assign ('limit', $limit); +$smarty->assign ('tDisplay_back_show', $tDisplay_back_show); +$smarty->assign ('tDisplay_back', $tDisplay_back); +$smarty->assign ('tDisplay_up_show', $tDisplay_up_show); +$smarty->assign ('tDisplay_next_show', $tDisplay_next_show); +$smarty->assign ('tDisplay_next', $tDisplay_next); + +if(sizeof ($tAliasDomains) > 0) + $smarty->assign ('tAliasDomains', $tAliasDomains); + +if(is_array($tTargetDomain)) +{ + $smarty->assign ('tTargetDomain', $tTargetDomain); + $smarty->assign ('PALANG_pOverview_alias_domain_target', sprintf($PALANG['pOverview_alias_domain_target'], $fDomain)); +} +$smarty->assign ('tAlias', $tAlias); +$smarty->assign ('gen_show_status', $gen_show_status); +$smarty->assign ('check_alias_owner', $check_alias_owner); +$smarty->assign ('tCanAddAlias', $tCanAddAlias); +$smarty->assign ('tMailbox', $tMailbox); +$smarty->assign ('gen_show_status_mailbox', $gen_show_status_mailbox); +$smarty->assign ('boolconf_used_quotas', boolconf('used_quotas')); +$smarty->assign ('divide_quota', $divide_quota); +$smarty->assign ('tCanAddMailbox', $tCanAddMailbox); +$smarty->assign ('smarty_template', 'list-virtual'); +$smarty->display ('index.tpl'); + + /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> Modified: branches/postfixadmin-smarty/login.php =================================================================== --- branches/postfixadmin-smarty/login.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/login.php 2009-04-02 11:14:17 UTC (rev 608) @@ -41,12 +41,12 @@ exit; } } + $smarty->assign ('language_selector', language_selector()); if ($_SERVER['REQUEST_METHOD'] == "GET") { - include ("./templates/header.php"); - include ("./templates/login.php"); - include ("./templates/footer.php"); + $smarty->assign ('smarty_template', 'login'); + $smarty->display ('index.tpl'); } if ($_SERVER['REQUEST_METHOD'] == "POST") @@ -101,9 +101,11 @@ exit(0); } - include ("./templates/header.php"); - include ("./templates/login.php"); - include ("./templates/footer.php"); + $smarty->assign ('tUsername', $tUsername); + $smarty->assign ('tMessage', $tMessage); + + $smarty->assign ('smarty_template', 'login'); + $smarty->display ('index.tpl'); } /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ Modified: branches/postfixadmin-smarty/main.php =================================================================== --- branches/postfixadmin-smarty/main.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/main.php 2009-04-02 11:14:17 UTC (rev 608) @@ -26,11 +26,7 @@ $SESSID_USERNAME = authentication_get_username(); authentication_require_role('admin'); +$smarty->assign ('smarty_template', 'main'); +$smarty->display ('index.tpl'); -include ("./templates/header.php"); -include ("./templates/menu.php"); -include ("./templates/main.php"); -include ("./templates/footer.php"); - -/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ -?> +/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: branches/postfixadmin-smarty/motd-users.txt =================================================================== --- branches/postfixadmin-smarty/motd-users.txt 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/motd-users.txt 2009-04-02 11:14:17 UTC (rev 608) @@ -1,7 +1,7 @@ <div class="standout"> === Announcement ===<br /> This is a new version of Postfix Admin.<br /> -If you have any questions please direct them to the <a href="mailto:<?php print $CONF['admin_email']; ?>">Site Admin</a><br /> +If you have any questions please direct them to the <a href="mailto:{$CONF.admin_email}">Site Admin</a><br /> === Announcement ===<br /> </div> <br /> Modified: branches/postfixadmin-smarty/motd.txt =================================================================== --- branches/postfixadmin-smarty/motd.txt 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/motd.txt 2009-04-02 11:14:17 UTC (rev 608) @@ -1,7 +1,7 @@ <div class="standout"> === Announcement ===<br /> This is a new version of Postfix Admin.<br /> -If you have any questions please direct them to the <a href="mailto:<?php print $CONF['admin_email']; ?>">Site Admin</a><br /> +If you have any questions please direct them to the <a href="mailto:{$CONF.admin_email}">Site Admin</a><br /> === Announcement ===<br /> </div> <br /> Modified: branches/postfixadmin-smarty/password.php =================================================================== --- branches/postfixadmin-smarty/password.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/password.php 2009-04-02 11:14:17 UTC (rev 608) @@ -33,12 +33,12 @@ $SESSID_USERNAME = authentication_get_username(); +$smarty->assign ('SESSID_USERNAME', $SESSID_USERNAME); +$smarty->assign ('smarty_template', 'password'); + if ($_SERVER['REQUEST_METHOD'] == "GET") { - include ("./templates/header.php"); - include ("./templates/menu.php"); - include ("./templates/password.php"); - include ("./templates/footer.php"); + $smarty->display ('index.tpl'); } if ($_SERVER['REQUEST_METHOD'] == "POST") @@ -88,10 +88,10 @@ } } - include ("./templates/header.php"); - include ("./templates/menu.php"); - include ("./templates/password.php"); - include ("./templates/footer.php"); + $smarty->assign ('pPassword_password_current_text', $pPassword_password_current_text); + $smarty->assign ('pPassword_password_text', $pPassword_password_text); + $smarty->assign ('tMessage', $tMessage); + $smarty->display ('index.tpl'); } /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ Modified: branches/postfixadmin-smarty/search.php =================================================================== --- branches/postfixadmin-smarty/search.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/search.php 2009-04-02 11:14:17 UTC (rev 608) @@ -124,10 +124,65 @@ } } -include ("templates/header.php"); -include ("templates/menu.php"); -include ("templates/search.php"); -include ("templates/footer.php"); +$check_alias_owner = array (); +if ((is_array ($tAlias) and sizeof ($tAlias) > 0)) + for ($i = 0; $i < sizeof ($tAlias); $i++) + $check_alias_owner [$i] = check_alias_owner ($SESSID_USERNAME, $tAlias[$i]['address']); + +$divide_quota = array (); +if ((is_array ($tMailbox) and sizeof ($tMailbox) > 0)) + for ($i = 0; $i < sizeof ($tMailbox); $i++) + { + $divide_quota ['quota'][$i] = divide_quota ($tMailbox[$i]['quota']); + } + +for ($i = 0; $i < sizeof ($tAlias); $i++) +{ + if ((is_array ($tAlias) and sizeof ($tAlias) > 0)) + { + $tAlias[$i]['display_address'] = $tAlias[$i]['address']; + if (stristr($tAlias[$i]['display_address'],$fSearch)) + { + $new_address = str_ireplace($fSearch, "<span style='background-color: lightgreen'>".$fSearch."</span>", $tAlias[$i]['display_address']); + $tAlias[$i]['display_address'] = $new_address; + } + if (stristr($tAlias[$i]['goto'], $fSearch)) + { + $tAlias[$i]['goto'] = str_ireplace($fSearch, "<span style='background-color: lightgreen'>".$fSearch."</span>", $tAlias[$i]['goto']); + } + ($tAlias [$i]['active'] == 1) ? $tAlias [$i]['active'] = $PALANG ['YES'] : $tAlias [$i]['active'] = $PALANG ['NO']; + } +} +for ($i = 0; $i < sizeof ($tMailbox); $i++) +{ + if ((is_array ($tMailbox) and sizeof ($tMailbox) > 0)) + { + $tMailbox[$i]['display_username'] = $tMailbox[$i]['username']; + if (stristr($tMailbox[$i]['display_username'],$fSearch)) + { + $new_name = str_ireplace ($fSearch, "<span style='background-color: lightgreen'>".$fSearch."</span>", $tMailbox[$i]['display_username']); + $tMailbox [$i]['display_username'] = $new_name; + } + if (stristr($tMailbox[$i]['name'],$fSearch)) + { + $tMailbox[$i]['name'] = str_ireplace($fSearch, "<span style='background-color: lightgreen'>".$fSearch."</span>", $tMailbox[$i]['name']); + } + ($tMailbox [$i]['active'] == 1) ? $tMailbox [$i]['active'] = $PALANG ['YES'] : $tMailbox [$i]['active'] = $PALANG ['NO']; + ($tMailbox [$i]['v_active'] == 1) ? $tMailbox [$i]['v_active'] = $PALANG ['pOverview_vacation_edit'] : $tMailbox [$i]['v_active'] = ''; + } +} + +$smarty->assign ('fSearch', $fSearch); +$smarty->assign ('select_options', select_options ($list_domains, array ($list_domains[0]))); +$smarty->assign ('tAlias', $tAlias); + +$smarty->assign ('check_alias_owner', $check_alias_owner); +$smarty->assign ('tMailbox', $tMailbox); +$smarty->assign ('divide_quota', $divide_quota); + +$smarty->assign ('smarty_template', 'search'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */ ?> Modified: branches/postfixadmin-smarty/sendmail.php =================================================================== --- branches/postfixadmin-smarty/sendmail.php 2009-03-30 12:46:35 UTC (rev 607) +++ branches/postfixadmin-smarty/sendmail.php 2009-04-02 11:14:17 UTC (rev 608) @@ -79,11 +79,12 @@ } } } +$smarty->assign ('SESSID_USERNAME', $SESSID_USERNAME); +$smarty->assign ('tMessage', $tMessage); -include ("./templates/header.php"); -include ("./templates/menu.php"); -include ("./templates/sendmail.php"); -include ("./templates/footer.php"); +$smarty->assign ('smarty_template', 'sendmail'); +$smarty->display ('index.tpl'); + /* vim: set expandtab softtabstop=3 tabstop=3 shiftwidth=3: */ ?> Added: branches/postfixadmin-smarty/smarty.inc.php =================================================================== --- branches/postfixadmin-smarty/smarty.inc.php (rev 0) +++ branches/postfixadmin-smarty/smarty.inc.php 2009-04-02 11:14:17 UTC (rev 608) @@ -0,0 +1,56 @@ +<? +require_once ("$incpath/smarty/libs/Smarty.class.php"); + +$smarty = new Smarty; + +//$smarty->debugging = true; + +$smarty->template_dir = $incpath.'/'.$smarty->template_dir; +$smarty->compile_dir = $incpath.'/'.$smarty->compile_dir; +$smarty->config_dir = $incpath.'/'.$smarty->config_dir; + +$CONF['theme_css'] = $CONF['postfix_admin_url'].'/'.htmlentities($CONF['theme_css']); +$CONF['theme_logo'] = $CONF['postfix_admin_url'].'/'.htmlentities($CONF['theme_logo']); + +$smarty->assign ('CONF', $CONF); +$smarty->assign ('PALANG', $PALANG); + +//*** footer.tpl +$smarty->assign ('version', $version); + +//*** menu.tpl +$smarty->assign ('boolconf_alias_domain', boolconf('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'))); + +if (authentication_has_role('global-admin')) +{ + $motd_file = "motd-admin.txt"; +} +else +{ + $motd_file = "motd.txt"; +} +if (file_exists ($CONF ['postfix_admin_path'].'/templates/'.$motd_file)) + $smarty->assign ('motd_file', $motd_file); +?> +<? +function select_options ($aValues, $aSelected) +{ + $ret_val = ''; + foreach ($aValues as $val) + { + $ret_val .= '<option value="'.$val.'"'; + if (in_array ($val, $aSelected)) + $ret_val .= ' selected="selected"'; + $ret_val .= '>'.$val.'</option>'; + } + return $ret_val; +} +function eval_size ($aSize) +{ + if ($aSize == 0) {$ret_val = $GLOBALS ['PALANG']['pOverview_unlimited']; } + elseif ($aSize < 0) {$ret_val = $GLOBALS ['PALANG']['pOverview_disabled']; } + else {$ret_val = $aSize; } + return $ret_val; +} +?> \ No newline at end of file Added: branches/postfixadmin-smarty/templates/admin_create-admin.tpl =================================================================== --- branches/postfixadmin-smarty/templates/admin_create-admin.tpl (rev 0) +++ branches/postfixadmin-smarty/templates/admin_create-admin.tpl 2009-04-02 11:14:17 UTC (rev 608) @@ -0,0 +1,37 @@ +<div id="edit_form"> +<form name="create_admin" method="post" action=""> +<table> + <tr> + <td colspan="3"><h3>{$PALANG.pAdminCreate_admin_welcome}</h3></td> + </tr> + <tr> + <td>{$PALANG.pAdminCreate_admin_username}:</td> + <td><input class="flat" type="text" name="fUsername" value="{$tUsername}" /></td> + <td>{$pAdminCreate_admin_username_text}</td> + </tr> + <tr> + <td>{$PALANG.pAdminCreate_admin_password}:</td> + <td><input class="flat" type="password" name="fPassword" /></td> + <td>{$pAdminCreate_admin_password_text}</td> + </tr> + <tr> + <td>{$PALANG.pAdminCreate_admin_password2}:</td> + <td><input class="flat" type="password" name="fPassword2" /></td> + <td> </td> + </tr> + <tr> + <td>{$PALANG.pAdminCreate_admin_address}:</td> + <td> + <select name="fDomains[]" size="10" multiple="multiple">{$select_options}</select> + </td> + <td> </td> + </tr> + <tr> + <td colspan="3" class="hlp_center"><input class="button" type="submit" name="submit" value="{$PALANG.pAdminCreate_admin_button}" /></td> + </tr> + <tr> + <td colspan="3" class="standout">{$tMessage}</td> + </tr> +</table> +</form> +</div> Added: branches/postfixadmin-smarty/templates/admin_create-domain.tpl =================================================================== --- branches/postfixadmin-smarty/templates/admin_create-domain.tpl (rev 0) +++ branches/postfixadmin-smarty/templates/admin_create-domain.tpl 2009-04-02 11:14:17 UTC (rev 608) @@ -0,0 +1,59 @@ +<div id="edit_form"> +<form name="create_domain" method="post" action=""> +<table> + <tr> + <td colspan="3"><h3>{$PALANG.pAdminCreate_domain_welcome}</h3></td> + </tr> + <tr> + <td>{$PALANG.pAdminCreate_domain_domain}:</td> + <td><input class="flat" type="text" name="fDomain" value="{$tDomain}" /></td> + <td>{$pAdminCreate_domain_domain_text}</td> + </tr> + <tr> + <td>{$PALANG.pAdminCreate_domain_description}:</td> + <td><input class="flat" type="text" name="fDescription" value="{$tDescription}" /></td> + <td> </td> + </tr> + <tr> + <td>{$PALANG.pAdminCreate_domain_aliases}:</td> + <td><input class="flat" type="text" name="fAliases" value="{$tAliases}" /></td> + <td>{$PALANG.pAdminCreate_domain_aliases_text}</td> + </tr> + <tr> + <td>{$PALANG.pAdminCreate_domain_mailboxes}:</td> + <td><input class="flat" type="text" name="fMailboxes" value="{$tMailboxes}" /></td> + <td>{$PALANG.pAdminCreate_domain_mailboxes_text}</td> + </tr> +{if $CONF.quota===YES} + <tr> + <td>{$PALANG.pAdminCreate_domain_maxquota}:</td> + <td><input class="flat" type="text" name="fMaxquota" value="{$tMaxquota}" /></td> + <td>{$PALANG.pAdminCreate_domain_maxquota_text}</td> + </tr> +{/if} +{if $CONF.transport===YES} + <tr> + <td>{$PALANG.pAdminCreate_domain_transport}:</td> + <td><select class="flat" name="fTransport">{$select_options}</select></td> + <td>{$PALANG.pAdminCreate_domain_transport_text}</td> + </tr> +{/if} + <tr> + <td>{$PALANG.pAdminCreate_domain_defaultaliases}:</td> + <td><input class="flat" type="checkbox" value='on' name="fDefaultaliases"{$tDefaultaliases}/></td> + <td>{$PALANG.pAdminCreate_domain_defaultaliases_text}</td> + </tr> + <tr> + <td>{$PALANG.pAdminCreate_domain_backupmx}:</td> + <td><input class="flat" type="checkbox" value='on' name="fBackupmx"{$tBackupmx}/></td> + <td> </td> + </tr> + <tr> + <td colspan="3" class="hlp_center"><input class="button" type="submit" name="submit" value="{$PALANG.pAdminCreate_domain_button}" /></td> + </tr> + <tr> + <td colspan="3" class="standout">{$tMessage}</td> + </tr> +</table> +</form> +</div> Added: branches/postfixadmin-smarty/templates/admin_edit-admin.tpl =================================================================== --- branches/postfixadmin-smarty/templates/admin_edit-admin.tpl (rev 0) +++ branches/postfixadmin-smarty/templates/admin_edit-admin.tpl 2009-04-02 11:14:17 UTC (rev 608) @@ -0,0 +1,46 @@ +<div id="edit_form"> +<form name="alias" method="post" action=""> +<table> + <tr> + <td colspan="3"><h3>{$PALANG.pAdminEdit_admin_welcome}</h3></td></tr> + <tr> + <td>{$PALANG.pAdminEdit_admin_username}:</td> + <td>{$username}</td> + <td> </td> + </tr> + <tr> + <td>{$PALANG.pAdminEdit_admin_password}:</td> + <td><input class="flat" type="password" name="fPassword" value=""/></td> + <td>{$pAdminEdit_admin_password_text}</td> + </tr> + <tr> + <td>{$PALANG.pAdminEdit_admin_password2}:</td> + <td><input class="flat" type="password" name="fPassword2" value="" /></td> + <td> </td> + </tr> + <tr> + <td>{$PALANG.pAdminEdit_admin_active}:</td> + <td><input class="flat" type="checkbox" name="fActive"{$tActive_checked}/></td> + <td> </td> + </tr> + <tr> + <td>{$PALANG.pAdminEdit_admin_super_admin}:</td> + <td><input class="flat" type="checkbox" name="fSadmin"{$tSadmin_checked}/></td> + <td> </td> + </tr> + <tr> + <td colspan="3" align="center"> + <select name="fDomains[]" size="10" multiple="multiple"> + {$select_options} + </select> + </td> + </tr> + <tr> + <td colspan="3" class="hlp_center"><input class="button" type="submit" name="submit" value="{$PALANG.pAdminEdit_admin_button}" /></td> + </tr> + <tr> + <td colspan="3" class="standout">{$tMessage}</td> + </tr> +</table> +</form> +</div> Added: branches/postfixadmin-smarty/templates/admin_edit-domain.tpl =================================================================== --- branches/postfixadmin-smarty/templates/admin_edit-domain.tpl (rev 0) +++ branches/postfixadmin-smarty/templates/admin_edit-domain.tpl 2009-04-02 11:14:17 UTC (rev 608) @@ -0,0 +1,59 @@ +<div id="ed... [truncated message content] |
From: <Gin...@us...> - 2009-03-30 12:46:39
|
Revision: 607 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=607&view=rev Author: GingerDog Date: 2009-03-30 12:46:35 +0000 (Mon, 30 Mar 2009) Log Message: ----------- fix bug where user entered vacation details were not being returned when you go to set yourself away again Modified Paths: -------------- trunk/users/vacation.php Modified: trunk/users/vacation.php =================================================================== --- trunk/users/vacation.php 2009-03-28 11:36:08 UTC (rev 606) +++ trunk/users/vacation.php 2009-03-30 12:46:35 UTC (rev 607) @@ -49,7 +49,8 @@ $tSubject = ''; $tBody = ''; - if($vh->get_details()) { + $details = $vh->get_details(); + if($details != false) { $tSubject = $details['subject']; $tBody = $details['body']; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <Seb...@us...> - 2009-03-28 11:36:12
|
Revision: 606 http://postfixadmin.svn.sourceforge.net/postfixadmin/?rev=606&view=rev Author: Sebastian2009 Date: 2009-03-28 11:36:08 +0000 (Sat, 28 Mar 2009) Log Message: ----------- Add smarty libraries and directories: - smarty Version 2.6.22 - template compile time directory (template_c) Added Paths: ----------- branches/postfixadmin-smarty/smarty/ branches/postfixadmin-smarty/smarty/libs/ branches/postfixadmin-smarty/smarty/libs/Config_File.class.php branches/postfixadmin-smarty/smarty/libs/Smarty.class.php branches/postfixadmin-smarty/smarty/libs/Smarty_Compiler.class.php branches/postfixadmin-smarty/smarty/libs/debug.tpl branches/postfixadmin-smarty/smarty/libs/internals/ branches/postfixadmin-smarty/smarty/libs/internals/core.assemble_plugin_filepath.php branches/postfixadmin-smarty/smarty/libs/internals/core.assign_smarty_interface.php branches/postfixadmin-smarty/smarty/libs/internals/core.create_dir_structure.php branches/postfixadmin-smarty/smarty/libs/internals/core.display_debug_console.php branches/postfixadmin-smarty/smarty/libs/internals/core.get_include_path.php branches/postfixadmin-smarty/smarty/libs/internals/core.get_microtime.php branches/postfixadmin-smarty/smarty/libs/internals/core.get_php_resource.php branches/postfixadmin-smarty/smarty/libs/internals/core.is_secure.php branches/postfixadmin-smarty/smarty/libs/internals/core.is_trusted.php branches/postfixadmin-smarty/smarty/libs/internals/core.load_plugins.php branches/postfixadmin-smarty/smarty/libs/internals/core.load_resource_plugin.php branches/postfixadmin-smarty/smarty/libs/internals/core.process_cached_inserts.php branches/postfixadmin-smarty/smarty/libs/internals/core.process_compiled_include.php branches/postfixadmin-smarty/smarty/libs/internals/core.read_cache_file.php branches/postfixadmin-smarty/smarty/libs/internals/core.rm_auto.php branches/postfixadmin-smarty/smarty/libs/internals/core.rmdir.php branches/postfixadmin-smarty/smarty/libs/internals/core.run_insert_handler.php branches/postfixadmin-smarty/smarty/libs/internals/core.smarty_include_php.php branches/postfixadmin-smarty/smarty/libs/internals/core.write_cache_file.php branches/postfixadmin-smarty/smarty/libs/internals/core.write_compiled_include.php branches/postfixadmin-smarty/smarty/libs/internals/core.write_compiled_resource.php branches/postfixadmin-smarty/smarty/libs/internals/core.write_file.php branches/postfixadmin-smarty/smarty/libs/plugins/ branches/postfixadmin-smarty/smarty/libs/plugins/block.textformat.php branches/postfixadmin-smarty/smarty/libs/plugins/compiler.assign.php branches/postfixadmin-smarty/smarty/libs/plugins/function.assign_debug_info.php branches/postfixadmin-smarty/smarty/libs/plugins/function.config_load.php branches/postfixadmin-smarty/smarty/libs/plugins/function.counter.php branches/postfixadmin-smarty/smarty/libs/plugins/function.cycle.php branches/postfixadmin-smarty/smarty/libs/plugins/function.debug.php branches/postfixadmin-smarty/smarty/libs/plugins/function.eval.php branches/postfixadmin-smarty/smarty/libs/plugins/function.fetch.php branches/postfixadmin-smarty/smarty/libs/plugins/function.html_checkboxes.php branches/postfixadmin-smarty/smarty/libs/plugins/function.html_image.php branches/postfixadmin-smarty/smarty/libs/plugins/function.html_options.php branches/postfixadmin-smarty/smarty/libs/plugins/function.html_radios.php branches/postfixadmin-smarty/smarty/libs/plugins/function.html_select_date.php branches/postfixadmin-smarty/smarty/libs/plugins/function.html_select_time.php branches/postfixadmin-smarty/smarty/libs/plugins/function.html_table.php branches/postfixadmin-smarty/smarty/libs/plugins/function.mailto.php branches/postfixadmin-smarty/smarty/libs/plugins/function.math.php branches/postfixadmin-smarty/smarty/libs/plugins/function.popup.php branches/postfixadmin-smarty/smarty/libs/plugins/function.popup_init.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.capitalize.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.cat.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.count_characters.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.count_paragraphs.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.count_sentences.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.count_words.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.date_format.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.debug_print_var.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.default.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.escape.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.indent.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.lower.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.needle.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.nl2br.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.regex_replace.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.replace.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.spacify.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.string_format.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.strip.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.strip_tags.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.truncate.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.upper.php branches/postfixadmin-smarty/smarty/libs/plugins/modifier.wordwrap.php branches/postfixadmin-smarty/smarty/libs/plugins/outputfilter.trimwhitespace.php branches/postfixadmin-smarty/smarty/libs/plugins/shared.escape_special_chars.php branches/postfixadmin-smarty/smarty/libs/plugins/shared.make_timestamp.php branches/postfixadmin-smarty/templates_c/ Added: branches/postfixadmin-smarty/smarty/libs/Config_File.class.php =================================================================== --- branches/postfixadmin-smarty/smarty/libs/Config_File.class.php (rev 0) +++ branches/postfixadmin-smarty/smarty/libs/Config_File.class.php 2009-03-28 11:36:08 UTC (rev 606) @@ -0,0 +1,393 @@ +<?php + +/** + * Config_File class. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For questions, help, comments, discussion, etc., please join the + * Smarty mailing list. Send a blank e-mail to + * sma...@go... + * + * @link http://www.smarty.net/ + * @version 2.6.19-dev + * @copyright Copyright: 2001-2005 New Digital Group, Inc. + * @author Andrei Zmievski <an...@ph...> + * @access public + * @package Smarty + */ + +/* $Id: Config_File.class.php 2786 2008-09-18 21:04:38Z Uwe.Tews $ */ + +/** + * Config file reading class + * @package Smarty + */ +class Config_File { + /**#@+ + * Options + * @var boolean + */ + /** + * Controls whether variables with the same name overwrite each other. + */ + var $overwrite = true; + + /** + * Controls whether config values of on/true/yes and off/false/no get + * converted to boolean values automatically. + */ + var $booleanize = true; + + /** + * Controls whether hidden config sections/vars are read from the file. + */ + var $read_hidden = true; + + /** + * Controls whether or not to fix mac or dos formatted newlines. + * If set to true, \r or \r\n will be changed to \n. + */ + var $fix_newlines = true; + /**#@-*/ + + /** @access private */ + var $_config_path = ""; + var $_config_data = array(); + /**#@-*/ + + /** + * Constructs a new config file class. + * + * @param string $config_path (optional) path to the config files + */ + function Config_File($config_path = NULL) + { + if (isset($config_path)) + $this->set_path($config_path); + } + + + /** + * Set the path where configuration files can be found. + * + * @param string $config_path path to the config files + */ + function set_path($config_path) + { + if (!empty($config_path)) { + if (!is_string($config_path) || !file_exists($config_path) || !is_dir($config_path)) { + $this->_trigger_error_msg("Bad config file path '$config_path'"); + return; + } + if(substr($config_path, -1) != DIRECTORY_SEPARATOR) { + $config_path .= DIRECTORY_SEPARATOR; + } + + $this->_config_path = $config_path; + } + } + + + /** + * Retrieves config info based on the file, section, and variable name. + * + * @param string $file_name config file to get info for + * @param string $section_name (optional) section to get info for + * @param string $var_name (optional) variable to get info for + * @return string|array a value or array of values + */ + function get($file_name, $section_name = NULL, $var_name = NULL) + { + if (empty($file_name)) { + $this->_trigger_error_msg('Empty config file name'); + return; + } else { + $file_name = $this->_config_path . $file_name; + if (!isset($this->_config_data[$file_name])) + $this->load_file($file_name, false); + } + + if (!empty($var_name)) { + if (empty($section_name)) { + return $this->_config_data[$file_name]["vars"][$var_name]; + } else { + if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name])) + return $this->_config_data[$file_name]["sections"][$section_name]["vars"][$var_name]; + else + return array(); + } + } else { + if (empty($section_name)) { + return (array)$this->_config_data[$file_name]["vars"]; + } else { + if(isset($this->_config_data[$file_name]["sections"][$section_name]["vars"])) + return (array)$this->_config_data[$file_name]["sections"][$section_name]["vars"]; + else + return array(); + } + } + } + + + /** + * Retrieves config info based on the key. + * + * @param $file_name string config key (filename/section/var) + * @return string|array same as get() + * @uses get() retrieves information from config file and returns it + */ + function &get_key($config_key) + { + list($file_name, $section_name, $var_name) = explode('/', $config_key, 3); + $result = &$this->get($file_name, $section_name, $var_name); + return $result; + } + + /** + * Get all loaded config file names. + * + * @return array an array of loaded config file names + */ + function get_file_names() + { + return array_keys($this->_config_data); + } + + + /** + * Get all section names from a loaded file. + * + * @param string $file_name config file to get section names from + * @return array an array of section names from the specified file + */ + function get_section_names($file_name) + { + $file_name = $this->_config_path . $file_name; + if (!isset($this->_config_data[$file_name])) { + $this->_trigger_error_msg("Unknown config file '$file_name'"); + return; + } + + return array_keys($this->_config_data[$file_name]["sections"]); + } + + + /** + * Get all global or section variable names. + * + * @param string $file_name config file to get info for + * @param string $section_name (optional) section to get info for + * @return array an array of variables names from the specified file/section + */ + function get_var_names($file_name, $section = NULL) + { + if (empty($file_name)) { + $this->_trigger_error_msg('Empty config file name'); + return; + } else if (!isset($this->_config_data[$file_name])) { + $this->_trigger_error_msg("Unknown config file '$file_name'"); + return; + } + + if (empty($section)) + return array_keys($this->_config_data[$file_name]["vars"]); + else + return array_keys($this->_config_data[$file_name]["sections"][$section]["vars"]); + } + + + /** + * Clear loaded config data for a certain file or all files. + * + * @param string $file_name file to clear config data for + */ + function clear($file_name = NULL) + { + if ($file_name === NULL) + $this->_config_data = array(); + else if (isset($this->_config_data[$file_name])) + $this->_config_data[$file_name] = array(); + } + + + /** + * Load a configuration file manually. + * + * @param string $file_name file name to load + * @param boolean $prepend_path whether current config path should be + * prepended to the filename + */ + function load_file($file_name, $prepend_path = true) + { + if ($prepend_path && $this->_config_path != "") + $config_file = $this->_config_path . $file_name; + else + $config_file = $file_name; + + ini_set('track_errors', true); + $fp = @fopen($config_file, "r"); + if (!is_resource($fp)) { + $this->_trigger_error_msg("Could not open config file '$config_file'"); + return false; + } + + $contents = ($size = filesize($config_file)) ? fread($fp, $size) : ''; + fclose($fp); + + $this->_config_data[$config_file] = $this->parse_contents($contents); + return true; + } + + /** + * Store the contents of a file manually. + * + * @param string $config_file file name of the related contents + * @param string $contents the file-contents to parse + */ + function set_file_contents($config_file, $contents) + { + $this->_config_data[$config_file] = $this->parse_contents($contents); + return true; + } + + /** + * parse the source of a configuration file manually. + * + * @param string $contents the file-contents to parse + */ + function parse_contents($contents) + { + if($this->fix_newlines) { + // fix mac/dos formatted newlines + $contents = preg_replace('!\r\n?!', "\n", $contents); + } + + $config_data = array(); + $config_data['sections'] = array(); + $config_data['vars'] = array(); + + /* reference to fill with data */ + $vars =& $config_data['vars']; + + /* parse file line by line */ + preg_match_all('!^.*\r?\n?!m', $contents, $match); + $lines = $match[0]; + for ($i=0, $count=count($lines); $i<$count; $i++) { + $line = $lines[$i]; + if (empty($line)) continue; + + if ( substr($line, 0, 1) == '[' && preg_match('!^\[(.*?)\]!', $line, $match) ) { + /* section found */ + if (substr($match[1], 0, 1) == '.') { + /* hidden section */ + if ($this->read_hidden) { + $section_name = substr($match[1], 1); + } else { + /* break reference to $vars to ignore hidden section */ + unset($vars); + $vars = array(); + continue; + } + } else { + $section_name = $match[1]; + } + if (!isset($config_data['sections'][$section_name])) + $config_data['sections'][$section_name] = array('vars' => array()); + $vars =& $config_data['sections'][$section_name]['vars']; + continue; + } + + if (preg_match('/^\s*(\.?\w+)\s*=\s*(.*)/s', $line, $match)) { + /* variable found */ + $var_name = rtrim($match[1]); + if (strpos($match[2], '"""') === 0) { + /* handle multiline-value */ + $lines[$i] = substr($match[2], 3); + $var_value = ''; + while ($i<$count) { + if (($pos = strpos($lines[$i], '"""')) === false) { + $var_value .= $lines[$i++]; + } else { + /* end of multiline-value */ + $var_value .= substr($lines[$i], 0, $pos); + break; + } + } + $booleanize = false; + + } else { + /* handle simple value */ + $var_value = preg_replace('/^([\'"])(.*)\1$/', '\2', rtrim($match[2])); + $booleanize = $this->booleanize; + + } + $this->_set_config_var($vars, $var_name, $var_value, $booleanize); + } + /* else unparsable line / means it is a comment / means ignore it */ + } + return $config_data; + } + + /**#@+ @access private */ + /** + * @param array &$container + * @param string $var_name + * @param mixed $var_value + * @param boolean $booleanize determines whether $var_value is converted to + * to true/false + */ + function _set_config_var(&$container, $var_name, $var_value, $booleanize) + { + if (substr($var_name, 0, 1) == '.') { + if (!$this->read_hidden) + return; + else + $var_name = substr($var_name, 1); + } + + if (!preg_match("/^[a-zA-Z_]\w*$/", $var_name)) { + $this->_trigger_error_msg("Bad variable name '$var_name'"); + return; + } + + if ($booleanize) { + if (preg_match("/^(on|true|yes)$/i", $var_value)) + $var_value = true; + else if (preg_match("/^(off|false|no)$/i", $var_value)) + $var_value = false; + } + + if (!isset($container[$var_name]) || $this->overwrite) + $container[$var_name] = $var_value; + else { + settype($container[$var_name], 'array'); + $container[$var_name][] = $var_value; + } + } + + /** + * @uses trigger_error() creates a PHP warning/error + * @param string $error_msg + * @param integer $error_type one of + */ + function _trigger_error_msg($error_msg, $error_type = E_USER_WARNING) + { + trigger_error("Config_File error: $error_msg", $error_type); + } + /**#@-*/ +} + +?> Added: branches/postfixadmin-smarty/smarty/libs/Smarty.class.php =================================================================== --- branches/postfixadmin-smarty/smarty/libs/Smarty.class.php (rev 0) +++ branches/postfixadmin-smarty/smarty/libs/Smarty.class.php 2009-03-28 11:36:08 UTC (rev 606) @@ -0,0 +1,1960 @@ +<?php + +/** + * Project: Smarty: the PHP compiling template engine + * File: Smarty.class.php + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * For questions, help, comments, discussion, etc., please join the + * Smarty mailing list. Send a blank e-mail to + * sma...@go... + * + * @link http://www.smarty.net/ + * @copyright 2001-2005 New Digital Group, Inc. + * @author Monte Ohrt <monte at ohrt dot com> + * @author Andrei Zmievski <an...@ph...> + * @package Smarty + * @version 2.6.21 + */ + +/* $Id: Smarty.class.php 2785 2008-09-18 21:04:12Z Uwe.Tews $ */ + +/** + * DIR_SEP isn't used anymore, but third party apps might + */ +if(!defined('DIR_SEP')) { + define('DIR_SEP', DIRECTORY_SEPARATOR); +} + +/** + * set SMARTY_DIR to absolute path to Smarty library files. + * if not defined, include_path will be used. Sets SMARTY_DIR only if user + * application has not already defined it. + */ + +if (!defined('SMARTY_DIR')) { + define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR); +} + +if (!defined('SMARTY_CORE_DIR')) { + define('SMARTY_CORE_DIR', SMARTY_DIR . 'internals' . DIRECTORY_SEPARATOR); +} + +define('SMARTY_PHP_PASSTHRU', 0); +define('SMARTY_PHP_QUOTE', 1); +define('SMARTY_PHP_REMOVE', 2); +define('SMARTY_PHP_ALLOW', 3); + +/** + * @package Smarty + */ +class Smarty +{ + /**#@+ + * Smarty Configuration Section + */ + + /** + * The name of the directory where templates are located. + * + * @var string + */ + var $template_dir = 'templates'; + + /** + * The directory where compiled templates are located. + * + * @var string + */ + var $compile_dir = 'templates_c'; + + /** + * The directory where config files are located. + * + * @var string + */ + var $config_dir = 'configs'; + + /** + * An array of directories searched for plugins. + * + * @var array + */ + var $plugins_dir = array('plugins'); + + /** + * If debugging is enabled, a debug console window will display + * when the page loads (make sure your browser allows unrequested + * popup windows) + * + * @var boolean + */ + var $debugging = false; + + /** + * When set, smarty does uses this value as error_reporting-level. + * + * @var boolean + */ + var $error_reporting = null; + + /** + * This is the path to the debug console template. If not set, + * the default one will be used. + * + * @var string + */ + var $debug_tpl = ''; + + /** + * This determines if debugging is enable-able from the browser. + * <ul> + * <li>NONE => no debugging control allowed</li> + * <li>URL => enable debugging when SMARTY_DEBUG is found in the URL.</li> + * </ul> + * @link http://www.foo.dom/index.php?SMARTY_DEBUG + * @var string + */ + var $debugging_ctrl = 'NONE'; + + /** + * This tells Smarty whether to check for recompiling or not. Recompiling + * does not need to happen unless a template or config file is changed. + * Typically you enable this during development, and disable for + * production. + * + * @var boolean + */ + var $compile_check = true; + + /** + * This forces templates to compile every time. Useful for development + * or debugging. + * + * @var boolean + */ + var $force_compile = false; + + /** + * This enables template caching. + * <ul> + * <li>0 = no caching</li> + * <li>1 = use class cache_lifetime value</li> + * <li>2 = use cache_lifetime in cache file</li> + * </ul> + * @var integer + */ + var $caching = 0; + + /** + * The name of the directory for cache files. + * + * @var string + */ + var $cache_dir = 'cache'; + + /** + * This is the number of seconds cached content will persist. + * <ul> + * <li>0 = always regenerate cache</li> + * <li>-1 = never expires</li> + * </ul> + * + * @var integer + */ + var $cache_lifetime = 3600; + + /** + * Only used when $caching is enabled. If true, then If-Modified-Since headers + * are respected with cached content, and appropriate HTTP headers are sent. + * This way repeated hits to a cached page do not send the entire page to the + * client every time. + * + * @var boolean + */ + var $cache_modified_check = false; + + /** + * This determines how Smarty handles "<?php ... ?>" tags in templates. + * possible values: + * <ul> + * <li>SMARTY_PHP_PASSTHRU -> print tags as plain text</li> + * <li>SMARTY_PHP_QUOTE -> escape tags as entities</li> + * <li>SMARTY_PHP_REMOVE -> remove php tags</li> + * <li>SMARTY_PHP_ALLOW -> execute php tags</li> + * </ul> + * + * @var integer + */ + var $php_handling = SMARTY_PHP_PASSTHRU; + + /** + * This enables template security. When enabled, many things are restricted + * in the templates that normally would go unchecked. This is useful when + * untrusted parties are editing templates and you want a reasonable level + * of security. (no direct execution of PHP in templates for example) + * + * @var boolean + */ + var $security = false; + + /** + * This is the list of template directories that are considered secure. This + * is used only if {@link $security} is enabled. One directory per array + * element. {@link $template_dir} is in this list implicitly. + * + * @var array + */ + var $secure_dir = array(); + + /** + * These are the security settings for Smarty. They are used only when + * {@link $security} is enabled. + * + * @var array + */ + var $security_settings = array( + 'PHP_HANDLING' => false, + 'IF_FUNCS' => array('array', 'list', + 'isset', 'empty', + 'count', 'sizeof', + 'in_array', 'is_array', + 'true', 'false', 'null'), + 'INCLUDE_ANY' => false, + 'PHP_TAGS' => false, + 'MODIFIER_FUNCS' => array('count'), + 'ALLOW_CONSTANTS' => false + ); + + /** + * This is an array of directories where trusted php scripts reside. + * {@link $security} is disabled during their inclusion/execution. + * + * @var array + */ + var $trusted_dir = array(); + + /** + * The left delimiter used for the template tags. + * + * @var string + */ + var $left_delimiter = '{'; + + /** + * The right delimiter used for the template tags. + * + * @var string + */ + var $right_delimiter = '}'; + + /** + * The order in which request variables are registered, similar to + * variables_order in php.ini E = Environment, G = GET, P = POST, + * C = Cookies, S = Server + * + * @var string + */ + var $request_vars_order = 'EGPCS'; + + /** + * Indicates wether $HTTP_*_VARS[] (request_use_auto_globals=false) + * are uses as request-vars or $_*[]-vars. note: if + * request_use_auto_globals is true, then $request_vars_order has + * no effect, but the php-ini-value "gpc_order" + * + * @var boolean + */ + var $request_use_auto_globals = true; + + /** + * Set this if you want different sets of compiled files for the same + * templates. This is useful for things like different languages. + * Instead of creating separate sets of templates per language, you + * set different compile_ids like 'en' and 'de'. + * + * @var string + */ + var $compile_id = null; + + /** + * This tells Smarty whether or not to use sub dirs in the cache/ and + * templates_c/ directories. sub directories better organized, but + * may not work well with PHP safe mode enabled. + * + * @var boolean + * + */ + var $use_sub_dirs = false; + + /** + * This is a list of the modifiers to apply to all template variables. + * Put each modifier in a separate array element in the order you want + * them applied. example: <code>array('escape:"htmlall"');</code> + * + * @var array + */ + var $default_modifiers = array(); + + /** + * This is the resource type to be used when not specified + * at the beginning of the resource path. examples: + * $smarty->display('file:index.tpl'); + * $smarty->display('db:index.tpl'); + * $smarty->display('index.tpl'); // will use default resource type + * {include file="file:index.tpl"} + * {include file="db:index.tpl"} + * {include file="index.tpl"} {* will use default resource type *} + * + * @var array + */ + var $default_resource_type = 'file'; + + /** + * The function used for cache file handling. If not set, built-in caching is used. + * + * @var null|string function name + */ + var $cache_handler_func = null; + + /** + * This indicates which filters are automatically loaded into Smarty. + * + * @var array array of filter names + */ + var $autoload_filters = array(); + + /**#@+ + * @var boolean + */ + /** + * This tells if config file vars of the same name overwrite each other or not. + * if disabled, same name variables are accumulated in an array. + */ + var $config_overwrite = true; + + /** + * This tells whether or not to automatically booleanize config file variables. + * If enabled, then the strings "on", "true", and "yes" are treated as boolean + * true, and "off", "false" and "no" are treated as boolean false. + */ + var $config_booleanize = true; + + /** + * This tells whether hidden sections [.foobar] are readable from the + * tempalates or not. Normally you would never allow this since that is + * the point behind hidden sections: the application can access them, but + * the templates cannot. + */ + var $config_read_hidden = false; + + /** + * This tells whether or not automatically fix newlines in config files. + * It basically converts \r (mac) or \r\n (dos) to \n + */ + var $config_fix_newlines = true; + /**#@-*/ + + /** + * If a template cannot be found, this PHP function will be executed. + * Useful for creating templates on-the-fly or other special action. + * + * @var string function name + */ + var $default_template_handler_func = ''; + + /** + * The file that contains the compiler class. This can a full + * pathname, or relative to the php_include path. + * + * @var string + */ + var $compiler_file = 'Smarty_Compiler.class.php'; + + /** + * The class used for compiling templates. + * + * @var string + */ + var $compiler_class = 'Smarty_Compiler'; + + /** + * The class used to load config vars. + * + * @var string + */ + var $config_class = 'Config_File'; + +/**#@+ + * END Smarty Configuration Section + * There should be no need to touch anything below this line. + * @access private + */ + /** + * where assigned template vars are kept + * + * @var array + */ + var $_tpl_vars = array(); + + /** + * stores run-time $smarty.* vars + * + * @var null|array + */ + var $_smarty_vars = null; + + /** + * keeps track of sections + * + * @var array + */ + var $_sections = array(); + + /** + * keeps track of foreach blocks + * + * @var array + */ + var $_foreach = array(); + + /** + * keeps track of tag hierarchy + * + * @var array + */ + var $_tag_stack = array(); + + /** + * configuration object + * + * @var Config_file + */ + var $_conf_obj = null; + + /** + * loaded configuration settings + * + * @var array + */ + var $_config = array(array('vars' => array(), 'files' => array())); + + /** + * md5 checksum of the string 'Smarty' + * + * @var string + */ + var $_smarty_md5 = 'f8d698aea36fcbead2b9d5359ffca76f'; + + /** + * Smarty version number + * + * @var string + */ + var $_version = '2.6.21'; + + /** + * current template inclusion depth + * + * @var integer + */ + var $_inclusion_depth = 0; + + /** + * for different compiled templates + * + * @var string + */ + var $_compile_id = null; + + /** + * text in URL to enable debug mode + * + * @var string + */ + var $_smarty_debug_id = 'SMARTY_DEBUG'; + + /** + * debugging information for debug console + * + * @var array + */ + var $_smarty_debug_info = array(); + + /** + * info that makes up a cache file + * + * @var array + */ + var $_cache_info = array(); + + /** + * default file permissions + * + * @var integer + */ + var $_file_perms = 0644; + + /** + * default dir permissions + * + * @var integer + */ + var $_dir_perms = 0771; + + /** + * registered objects + * + * @var array + */ + var $_reg_objects = array(); + + /** + * table keeping track of plugins + * + * @var array + */ + var $_plugins = array( + 'modifier' => array(), + 'function' => array(), + 'block' => array(), + 'compiler' => array(), + 'prefilter' => array(), + 'postfilter' => array(), + 'outputfilter' => array(), + 'resource' => array(), + 'insert' => array()); + + + /** + * cache serials + * + * @var array + */ + var $_cache_serials = array(); + + /** + * name of optional cache include file + * + * @var string + */ + var $_cache_include = null; + + /** + * indicate if the current code is used in a compiled + * include + * + * @var string + */ + var $_cache_including = false; + + /**#@-*/ + /** + * The class constructor. + */ + function Smarty() + { + $this->assign('SCRIPT_NAME', isset($_SERVER['SCRIPT_NAME']) ? $_SERVER['SCRIPT_NAME'] + : @$GLOBALS['HTTP_SERVER_VARS']['SCRIPT_NAME']); + } + + /** + * assigns values to template variables + * + * @param array|string $tpl_var the template variable name(s) + * @param mixed $value the value to assign + */ + function assign($tpl_var, $value = null) + { + if (is_array($tpl_var)){ + foreach ($tpl_var as $key => $val) { + if ($key != '') { + $this->_tpl_vars[$key] = $val; + } + } + } else { + if ($tpl_var != '') + $this->_tpl_vars[$tpl_var] = $value; + } + } + + /** + * assigns values to template variables by reference + * + * @param string $tpl_var the template variable name + * @param mixed $value the referenced value to assign + */ + function assign_by_ref($tpl_var, &$value) + { + if ($tpl_var != '') + $this->_tpl_vars[$tpl_var] = &$value; + } + + /** + * appends values to template variables + * + * @param array|string $tpl_var the template variable name(s) + * @param mixed $value the value to append + */ + function append($tpl_var, $value=null, $merge=false) + { + if (is_array($tpl_var)) { + // $tpl_var is an array, ignore $value + foreach ($tpl_var as $_key => $_val) { + if ($_key != '') { + if(!@is_array($this->_tpl_vars[$_key])) { + settype($this->_tpl_vars[$_key],'array'); + } + if($merge && is_array($_val)) { + foreach($_val as $_mkey => $_mval) { + $this->_tpl_vars[$_key][$_mkey] = $_mval; + } + } else { + $this->_tpl_vars[$_key][] = $_val; + } + } + } + } else { + if ($tpl_var != '' && isset($value)) { + if(!@is_array($this->_tpl_vars[$tpl_var])) { + settype($this->_tpl_vars[$tpl_var],'array'); + } + if($merge && is_array($value)) { + foreach($value as $_mkey => $_mval) { + $this->_tpl_vars[$tpl_var][$_mkey] = $_mval; + } + } else { + $this->_tpl_vars[$tpl_var][] = $value; + } + } + } + } + + /** + * appends values to template variables by reference + * + * @param string $tpl_var the template variable name + * @param mixed $value the referenced value to append + */ + function append_by_ref($tpl_var, &$value, $merge=false) + { + if ($tpl_var != '' && isset($value)) { + if(!@is_array($this->_tpl_vars[$tpl_var])) { + settype($this->_tpl_vars[$tpl_var],'array'); + } + if ($merge && is_array($value)) { + foreach($value as $_key => $_val) { + $this->_tpl_vars[$tpl_var][$_key] = &$value[$_key]; + } + } else { + $this->_tpl_vars[$tpl_var][] = &$value; + } + } + } + + + /** + * clear the given assigned template variable. + * + * @param string $tpl_var the template variable to clear + */ + function clear_assign($tpl_var) + { + if (is_array($tpl_var)) + foreach ($tpl_var as $curr_var) + unset($this->_tpl_vars[$curr_var]); + else + unset($this->_tpl_vars[$tpl_var]); + } + + + /** + * Registers custom function to be used in templates + * + * @param string $function the name of the template function + * @param string $function_impl the name of the PHP function to register + */ + function register_function($function, $function_impl, $cacheable=true, $cache_attrs=null) + { + $this->_plugins['function'][$function] = + array($function_impl, null, null, false, $cacheable, $cache_attrs); + + } + + /** + * Unregisters custom function + * + * @param string $function name of template function + */ + function unregister_function($function) + { + unset($this->_plugins['function'][$function]); + } + + /** + * Registers object to be used in templates + * + * @param string $object name of template object + * @param object &$object_impl the referenced PHP object to register + * @param null|array $allowed list of allowed methods (empty = all) + * @param boolean $smarty_args smarty argument format, else traditional + * @param null|array $block_functs list of methods that are block format + */ + function register_object($object, &$object_impl, $allowed = array(), $smarty_args = true, $block_methods = array()) + { + settype($allowed, 'array'); + settype($smarty_args, 'boolean'); + $this->_reg_objects[$object] = + array(&$object_impl, $allowed, $smarty_args, $block_methods); + } + + /** + * Unregisters object + * + * @param string $object name of template object + */ + function unregister_object($object) + { + unset($this->_reg_objects[$object]); + } + + + /** + * Registers block function to be used in templates + * + * @param string $block name of template block + * @param string $block_impl PHP function to register + */ + function register_block($block, $block_impl, $cacheable=true, $cache_attrs=null) + { + $this->_plugins['block'][$block] = + array($block_impl, null, null, false, $cacheable, $cache_attrs); + } + + /** + * Unregisters block function + * + * @param string $block name of template function + */ + function unregister_block($block) + { + unset($this->_plugins['block'][$block]); + } + + /** + * Registers compiler function + * + * @param string $function name of template function + * @param string $function_impl name of PHP function to register + */ + function register_compiler_function($function, $function_impl, $cacheable=true) + { + $this->_plugins['compiler'][$function] = + array($function_impl, null, null, false, $cacheable); + } + + /** + * Unregisters compiler function + * + * @param string $function name of template function + */ + function unregister_compiler_function($function) + { + unset($this->_plugins['compiler'][$function]); + } + + /** + * Registers modifier to be used in templates + * + * @param string $modifier name of template modifier + * @param string $modifier_impl name of PHP function to register + */ + function register_modifier($modifier, $modifier_impl) + { + $this->_plugins['modifier'][$modifier] = + array($modifier_impl, null, null, false); + } + + /** + * Unregisters modifier + * + * @param string $modifier name of template modifier + */ + function unregister_modifier($modifier) + { + unset($this->_plugins['modifier'][$modifier]); + } + + /** + * Registers a resource to fetch a template + * + * @param string $type name of resource + * @param array $functions array of functions to handle resource + */ + function register_resource($type, $functions) + { + if (count($functions)==4) { + $this->_plugins['resource'][$type] = + array($functions, false); + + } elseif (count($functions)==5) { + $this->_plugins['resource'][$type] = + array(array(array(&$functions[0], $functions[1]) + ,array(&$functions[0], $functions[2]) + ,array(&$functions[0], $functions[3]) + ,array(&$functions[0], $functions[4])) + ,false); + + } else { + $this->trigger_error("malformed function-list for '$type' in register_resource"); + + } + } + + /** + * Unregisters a resource + * + * @param string $type name of resource + */ + function unregister_resource($type) + { + unset($this->_plugins['resource'][$type]); + } + + /** + * Registers a prefilter function to apply + * to a template before compiling + * + * @param callback $function + */ + function register_prefilter($function) + { + $this->_plugins['prefilter'][$this->_get_filter_name($function)] + = array($function, null, null, false); + } + + /** + * Unregisters a prefilter function + * + * @param callback $function + */ + function unregister_prefilter($function) + { + unset($this->_plugins['prefilter'][$this->_get_filter_name($function)]); + } + + /** + * Registers a postfilter function to apply + * to a compiled template after compilation + * + * @param callback $function + */ + function register_postfilter($function) + { + $this->_plugins['postfilter'][$this->_get_filter_name($function)] + = array($function, null, null, false); + } + + /** + * Unregisters a postfilter function + * + * @param callback $function + */ + function unregister_postfilter($function) + { + unset($this->_plugins['postfilter'][$this->_get_filter_name($function)]); + } + + /** + * Registers an output filter function to apply + * to a template output + * + * @param callback $function + */ + function register_outputfilter($function) + { + $this->_plugins['outputfilter'][$this->_get_filter_name($function)] + = array($function, null, null, false); + } + + /** + * Unregisters an outputfilter function + * + * @param callback $function + */ + function unregister_outputfilter($function) + { + unset($this->_plugins['outputfilter'][$this->_get_filter_name($function)]); + } + + /** + * load a filter of specified type and name + * + * @param string $type filter type + * @param string $name filter name + */ + function load_filter($type, $name) + { + switch ($type) { + case 'output': + $_params = array('plugins' => array(array($type . 'filter', $name, null, null, false))); + require_once(SMARTY_CORE_DIR . 'core.load_plugins.php'); + smarty_core_load_plugins($_params, $this); + break; + + case 'pre': + case 'post': + if (!isset($this->_plugins[$type . 'filter'][$name])) + $this->_plugins[$type . 'filter'][$name] = false; + break; + } + } + + /** + * clear cached content for the given template and cache id + * + * @param string $tpl_file name of template file + * @param string $cache_id name of cache_id + * @param string $compile_id name of compile_id + * @param string $exp_time expiration time + * @return boolean + */ + function clear_cache($tpl_file = null, $cache_id = null, $compile_id = null, $exp_time = null) + { + + if (!isset($compile_id)) + $compile_id = $this->compile_id; + + if (!isset($tpl_file)) + $compile_id = null; + + $_auto_id = $this->_get_auto_id($cache_id, $compile_id); + + if (!empty($this->cache_handler_func)) { + return call_user_func_array($this->cache_handler_func, + array('clear', &$this, &$dummy, $tpl_file, $cache_id, $compile_id, $exp_time)); + } else { + $_params = array('auto_base' => $this->cache_dir, + 'auto_source' => $tpl_file, + 'auto_id' => $_auto_id, + 'exp_time' => $exp_time); + require_once(SMARTY_CORE_DIR . 'core.rm_auto.php'); + return smarty_core_rm_auto($_params, $this); + } + + } + + + /** + * clear the entire contents of cache (all templates) + * + * @param string $exp_time expire time + * @return boolean results of {@link smarty_core_rm_auto()} + */ + function clear_all_cache($exp_time = null) + { + return $this->clear_cache(null, null, null, $exp_time); + } + + + /** + * test to see if valid cache exists for this template + * + * @param string $tpl_file name of template file + * @param string $cache_id + * @param string $compile_id + * @return string|false results of {@link _read_cache_file()} + */ + function is_cached($tpl_file, $cache_id = null, $compile_id = null) + { + if (!$this->caching) + return false; + + if (!isset($compile_id)) + $compile_id = $this->compile_id; + + $_params = array( + 'tpl_file' => $tpl_file, + 'cache_id' => $cache_id, + 'compile_id' => $compile_id + ); + require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php'); + return smarty_core_read_cache_file($_params, $this); + } + + + /** + * clear all the assigned template variables. + * + */ + function clear_all_assign() + { + $this->_tpl_vars = array(); + } + + /** + * clears compiled version of specified template resource, + * or all compiled template files if one is not specified. + * This function is for advanced use only, not normally needed. + * + * @param string $tpl_file + * @param string $compile_id + * @param string $exp_time + * @return boolean results of {@link smarty_core_rm_auto()} + */ + function clear_compiled_tpl($tpl_file = null, $compile_id = null, $exp_time = null) + { + if (!isset($compile_id)) { + $compile_id = $this->compile_id; + } + $_params = array('auto_base' => $this->compile_dir, + 'auto_source' => $tpl_file, + 'auto_id' => $compile_id, + 'exp_time' => $exp_time, + 'extensions' => array('.inc', '.php')); + require_once(SMARTY_CORE_DIR . 'core.rm_auto.php'); + return smarty_core_rm_auto($_params, $this); + } + + /** + * Checks whether requested template exists. + * + * @param string $tpl_file + * @return boolean + */ + function template_exists($tpl_file) + { + $_params = array('resource_name' => $tpl_file, 'quiet'=>true, 'get_source'=>false); + return $this->_fetch_resource_info($_params); + } + + /** + * Returns an array containing template variables + * + * @param string $name + * @param string $type + * @return array + */ + function &get_template_vars($name=null) + { + if(!isset($name)) { + return $this->_tpl_vars; + } elseif(isset($this->_tpl_vars[$name])) { + return $this->_tpl_vars[$name]; + } else { + // var non-existant, return valid reference + $_tmp = null; + return $_tmp; + } + } + + /** + * Returns an array containing config variables + * + * @param string $name + * @param string $type + * @return array + */ + function &get_config_vars($name=null) + { + if(!isset($name) && is_array($this->_config[0])) { + return $this->_config[0]['vars']; + } else if(isset($this->_config[0]['vars'][$name])) { + return $this->_config[0]['vars'][$name]; + } else { + // var non-existant, return valid reference + $_tmp = null; + return $_tmp; + } + } + + /** + * trigger Smarty error + * + * @param string $error_msg + * @param integer $error_type + */ + function trigger_error($error_msg, $error_type = E_USER_WARNING) + { + trigger_error("Smarty error: $error_msg", $error_type); + } + + + /** + * executes & displays the template results + * + * @param string $resource_name + * @param string $cache_id + * @param string $compile_id + */ + function display($resource_name, $cache_id = null, $compile_id = null) + { + $this->fetch($resource_name, $cache_id, $compile_id, true); + } + + /** + * executes & returns or displays the template results + * + * @param string $resource_name + * @param string $cache_id + * @param string $compile_id + * @param boolean $display + */ + function fetch($resource_name, $cache_id = null, $compile_id = null, $display = false) + { + static $_cache_info = array(); + + $_smarty_old_error_level = $this->debugging ? error_reporting() : error_reporting(isset($this->error_reporting) + ? $this->error_reporting : error_reporting() & ~E_NOTICE); + + if (!$this->debugging && $this->debugging_ctrl == 'URL') { + $_query_string = $this->request_use_auto_globals ? $_SERVER['QUERY_STRING'] : $GLOBALS['HTTP_SERVER_VARS']['QUERY_STRING']; + if (@strstr($_query_string, $this->_smarty_debug_id)) { + if (@strstr($_query_string, $this->_smarty_debug_id . '=on')) { + // enable debugging for this browser session + @setcookie('SMARTY_DEBUG', true); + $this->debugging = true; + } elseif (@strstr($_query_string, $this->_smarty_debug_id . '=off')) { + // disable debugging for this browser session + @setcookie('SMARTY_DEBUG', false); + $this->debugging = false; + } else { + // enable debugging for this page + $this->debugging = true; + } + } else { + $this->debugging = (bool)($this->request_use_auto_globals ? @$_COOKIE['SMARTY_DEBUG'] : @$GLOBALS['HTTP_COOKIE_VARS']['SMARTY_DEBUG']); + } + } + + if ($this->debugging) { + // capture time for debugging info + $_params = array(); + require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); + $_debug_start_time = smarty_core_get_microtime($_params, $this); + $this->_smarty_debug_info[] = array('type' => 'template', + 'filename' => $resource_name, + 'depth' => 0); + $_included_tpls_idx = count($this->_smarty_debug_info) - 1; + } + + if (!isset($compile_id)) { + $compile_id = $this->compile_id; + } + + $this->_compile_id = $compile_id; + $this->_inclusion_depth = 0; + + if ($this->caching) { + // save old cache_info, initialize cache_info + array_push($_cache_info, $this->_cache_info); + $this->_cache_info = array(); + $_params = array( + 'tpl_file' => $resource_name, + 'cache_id' => $cache_id, + 'compile_id' => $compile_id, + 'results' => null + ); + require_once(SMARTY_CORE_DIR . 'core.read_cache_file.php'); + if (smarty_core_read_cache_file($_params, $this)) { + $_smarty_results = $_params['results']; + if (!empty($this->_cache_info['insert_tags'])) { + $_params = array('plugins' => $this->_cache_info['insert_tags']); + require_once(SMARTY_CORE_DIR . 'core.load_plugins.php'); + smarty_core_load_plugins($_params, $this); + $_params = array('results' => $_smarty_results); + require_once(SMARTY_CORE_DIR . 'core.process_cached_inserts.php'); + $_smarty_results = smarty_core_process_cached_inserts($_params, $this); + } + if (!empty($this->_cache_info['cache_serials'])) { + $_params = array('results' => $_smarty_results); + require_once(SMARTY_CORE_DIR . 'core.process_compiled_include.php'); + $_smarty_results = smarty_core_process_compiled_include($_params, $this); + } + + + if ($display) { + if ($this->debugging) + { + // capture time for debugging info + $_params = array(); + require_once(SMARTY_CORE_DIR . 'core.get_microtime.php'); + $this->_smarty_debug_info[$_included_tpls_idx]['exec_time'] = smarty_core_get_microtime($_params, $this) - $_debug_start_time; + require_once(SMARTY_CORE_DIR . 'core.display_debug_console.php'); + $_smarty_results .= smarty_core_display_debug_console($_params, $this); + } + if ($this->cache_modified_check) { + $_server_vars = ($this->request_use_auto_globals) ? $_SERVER : $GLOBALS['HTTP_SERVER_VARS']; + $_last_modified_date = @substr($_server_vars['HTTP_IF_MODIFIED_SINCE'], 0, strpos($_server_vars['HTTP_IF_MODIFIED_SINCE'], 'GMT') + 3); + $_gmt_mtime = gmdate('D, d M Y H:i:s', $this->_cache_info['timestamp']).' GMT'; + if (@count($this->_cache_info['insert_tags']) == 0 + && !$this->_cache_serials + && $_gmt_mtime == $_last_modified_date) { + if (php_sapi_name()=='cgi') + header('Status: 304 Not Modified'); + else + header('HTTP/1.1 304 Not Modified'); + + } else { + header('Last-Modified: '.$_gmt_mtime); + echo $_smarty_results; + } + } else { + echo $_smarty_results; + } + error_reporting($_smarty_old_error_level); + // restore initial cache_info + $this->_cache_info = array_pop($_cache_info); + return true; + } else { + error_reporting($_smarty_old_error_level); + // restore initial cache_info + $this->_cache_info = array_pop($_cache_info); + return $_smarty_results; + } + } else { + $this->_cache_info['template'][$resource_name] = true; + if ($this->cache_modified_check && $display) { + header('Last-Modified: '.gmdate('D, d M Y H:i:s', time()).' GMT'); + } + } + } + + // load filters that are marked as autoload + if (count($this->autoload_filters)) { + foreach ($this->autoload_filters as $_filter_type => $_filters) { + foreach ($_filters as $_filter) { + $this->load_filter($_filter_type, $_filter); + } + } + } + + $_smarty_compile_path = $this->_get_compile_path($resource_name); + + // if we just need to display the results, don't perform output + // buffering - for speed + $_cache_including = $this->_cache_including; + $this->_cache_including = false; + if ($display && !$this->caching && count($this->_plugins['outputfilter']) == 0) { + if ($this->_is_compiled($resource_name, $_smarty_compile_path) + || $this->_compile_resource($resource_name, $_smarty_compile_path)) + { + include($_smarty_compile_path); + } + } else { + ob_start(); + if ($this->_is_compiled($resource_name, $_smarty_compile_path) + || $this->_compile_resource($resource_name, $_smarty_compile_path)) + { + include($_smarty_compile_path); + } + $_smarty_results = ob_get_contents(); + ob_end_clean(); + + foreach ((array)$this->_plugins['outputfilter'] as $_output_filter) { + $_smarty_results = call_user_func_array($_output_filter[0], array($_smarty_results, &$this)); + } + } + +... [truncated message content] |