X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Faddressbook.php;h=f36496ba6a94976b3e276ed4592ef6879e1b8517;hb=709a1a6d2b6881c1e57e542579436a8f9a909ac3;hp=2c04b8e14b38c25554ea2745503ca844d948b4b9;hpb=ac2cd35d14b086d268d1f5ee3603415615a06aad;p=squirrelmail.git
diff --git a/src/addressbook.php b/src/addressbook.php
index 2c04b8e1..f36496ba 100644
--- a/src/addressbook.php
+++ b/src/addressbook.php
@@ -2,45 +2,27 @@
/**
** addressbook.php
**
+ ** Copyright (c) 1999-2000 The SquirrelMail development team
+ ** Licensed under the GNU GPL. For full terms see the file COPYING.
+ **
** Manage personal address book.
**
+ ** $Id$
**/
- session_start();
-
- if(!isset($logged_in)) {
- echo _("You must login first.");
- exit;
- }
- if(!isset($username) || !isset($key)) {
- echo _("You need a valid user and password to access this page!");
- exit;
- }
-
- if (!isset($config_php))
- include("../config/config.php");
- if (!isset($array_php))
- include("../functions/array.php");
- if (!isset($strings_php))
- include("../functions/strings.php");
- if (!isset($imap_php))
- include("../functions/imap.php");
- if (!isset($page_header_php))
- include("../functions/page_header.php");
- if (!isset($display_messages_php))
- include("../functions/display_messages.php");
- if (!isset($addressbook_php))
- include("../functions/addressbook.php");
-
+ include('../src/validate.php');
+ include('../functions/array.php');
+ include('../functions/display_messages.php');
+ include('../functions/addressbook.php');
// Sort array by the key "name"
function alistcmp($a,$b) {
- if($a["backend"] > $b["backend"])
+ if($a['backend'] > $b['backend'])
return 1;
- else if($a["backend"] < $b["backend"])
+ else if($a['backend'] < $b['backend'])
return -1;
- return (strtolower($a["name"]) > strtolower($b["name"])) ? 1 : -1;
+ return (strtolower($a['name']) > strtolower($b['name'])) ? 1 : -1;
}
// Output form to add and modify address data
@@ -52,28 +34,38 @@
printf("
".
"".
" %s | \n",
- $color[4], $name, htmlspecialchars($values["nickname"]),
+ $color[4], $name,
+ (isset($values['nickname']))?
+ htmlspecialchars($values['nickname']):"",
_("Must be unique"));
printf("%s: | ",
_("E-mail address"));
printf("".
" |
\n",
- $color[4], $name, htmlspecialchars($values["email"]));
+ $color[4], $name,
+ (isset($values["email"]))?
+ htmlspecialchars($values["email"]):"");
printf("%s: | ",
_("First name"));
printf("".
" |
\n",
- $color[4], $name, htmlspecialchars($values["firstname"]));
+ $color[4], $name,
+ (isset($values["firstname"]))?
+ htmlspecialchars($values["firstname"]):"");
printf("%s: | ",
_("Last name"));
printf("".
" |
\n",
- $color[4], $name, htmlspecialchars($values["lastname"]));
+ $color[4], $name,
+ (isset($values["lastname"]))?
+ htmlspecialchars($values["lastname"]):"");
printf("%s: | ",
_("Additional info"));
printf("".
" |
\n",
- $color[4], $name, htmlspecialchars($values["label"]));
+ $color[4], $name,
+ (isset($values["label"]))?
+ htmlspecialchars($values["label"]):"");
printf("\n".
" |
\n",
@@ -83,13 +75,6 @@
}
- // IMAP Login
- $imapConnection = sqimap_login ($username, $key,
- $imapServerAddress, $imapPort, 10);
- include("../src/load_prefs.php");
- sqimap_logout ($imapConnection);
-
-
// Open addressbook, with error messages on but without LDAP (the
// second "true"). Don't need LDAP here anyway
$abook = addressbook_init(true, true);
@@ -98,23 +83,23 @@
exit();
}
- displayPageHeader($color, "None");
+ displayPageHeader($color, 'None');
$defdata = array();
- $formerror = "";
+ $formerror = '';
$abortform = false;
$showaddrlist = true;
$defselected = array();
// Handle user's actions
- if($REQUEST_METHOD == "POST") {
+ if($REQUEST_METHOD == 'POST') {
// ***********************************************
// Add new address
// ***********************************************
- if(!empty($addaddr["nickname"])) {
+ if(!empty($addaddr['nickname'])) {
$r = $abook->add($addaddr, $abook->localbackend);
@@ -122,7 +107,7 @@
if(!$r) {
// Remove backend name from error string
$errstr = $abook->error;
- $errstr = ereg_replace("^\[.*\] *", "", $errstr);
+ $errstr = ereg_replace('^\[.*\] *', '', $errstr);
$formerror = $errstr;
$showaddrlist = false;
@@ -147,7 +132,7 @@
$delfailed = false;
for($i = 0 ; (($i < sizeof($sel)) && !$delfailed) ; $i++) {
- list($sbackend, $snick) = split(":", $sel[$i]);
+ list($sbackend, $snick) = explode(':', $sel[$i]);
// When we get to a new backend, process addresses in
// previous one.
@@ -189,18 +174,18 @@
else if(!empty($editaddr)) {
// Stage one: Copy data into form
- if(sizeof($sel) > 0) {
+ if (isset($sel) && sizeof($sel) > 0) {
if(sizeof($sel) > 1) {
$formerror = _("You can only edit one address at the time");
$showaddrlist = true;
$defselected = $sel;
} else {
$abortform = true;
- list($ebackend, $enick) = split(":", $sel[0]);
+ list($ebackend, $enick) = explode(':', $sel[0]);
$olddata = $abook->lookup($enick, $ebackend);
// Display the "new address" form
- printf("";
+ print '';
$abortform = true;
}
@@ -284,21 +269,34 @@
// Display the address management part
if($showaddrlist) {
- printf("