X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Faddressbook.php;h=0cd1f24a075c9364da2831e6d099f239c2a3a079;hb=21e18f59c03b946f6dfd5b885be3a108776718f9;hp=f81ae4eff092c11772a5eca868f1410a8c92bebd;hpb=ac987a56a67a53a01b7db77a02fdd9c9241b4549;p=squirrelmail.git diff --git a/src/addressbook.php b/src/addressbook.php index f81ae4ef..0cd1f24a 100644 --- a/src/addressbook.php +++ b/src/addressbook.php @@ -3,7 +3,7 @@ /** * addressbook.php * - * Copyright (c) 1999-2002 The SquirrelMail Project Team + * Copyright (c) 1999-2003 The SquirrelMail Project Team * Licensed under the GNU GPL. For full terms see the file COPYING. * * Manage personal address book. @@ -11,19 +11,52 @@ * $Id$ */ -require_once('../src/validate.php'); -require_once('../functions/array.php'); -require_once('../functions/display_messages.php'); -require_once('../functions/addressbook.php'); -require_once('../functions/strings.php'); -require_once('../functions/html.php'); +/* Path for SquirrelMail required files. */ +define('SM_PATH','../'); + +/* SquirrelMail required files. */ +require_once(SM_PATH . 'include/validate.php'); +require_once(SM_PATH . 'functions/display_messages.php'); +require_once(SM_PATH . 'functions/addressbook.php'); +require_once(SM_PATH . 'functions/strings.php'); +require_once(SM_PATH . 'functions/html.php'); + +/* lets get the global vars we may need */ +$key = $_COOKIE['key']; + +$username = $_SESSION['username']; +$onetimepad = $_SESSION['onetimepad']; +$base_uri = $_SESSION['base_uri']; +$delimiter = $_SESSION['delimiter']; + +/* From the address form */ +if ( isset($_POST['addaddr']) ) { + $addaddr = &$_POST['addaddr']; +} +if ( isset($_POST['editaddr']) ) { + $editaddr = &$_POST['editaddr']; +} +if ( isset($_POST['deladdr']) ) { + $deladdr = &$_POST['deladdr']; +} +$sel = &$_POST['sel']; + +if (isset($_POST['oldnick'])) { + $oldnick = $_POST['oldnick']; +} +if (isset($_POST['backend'])) { + $backend = $_POST['backend']; +} +if (isset($_POST['doedit'])) { + $doedit = $_POST['doedit']; +} /* Make an input field */ function adressbook_inp_field($label, $field, $name, $size, $values, $add) { global $color; $td_str = '' . $add . ''; return html_tag( 'tr' , @@ -36,9 +69,10 @@ function adressbook_inp_field($label, $field, $name, $size, $values, $add) { /* Output form to add and modify address data */ function address_form($name, $submittext, $values = array()) { global $color; + echo html_tag( 'table', adressbook_inp_field(_("Nickname"), 'nickname', $name, 15, $values, - '' . _("Must be unique") . '') . + ' ' . _("Must be unique") . '') . adressbook_inp_field(_("E-mail address"), 'email', $name, 45, $values, '') . adressbook_inp_field(_("First name"), 'firstname', $name, 45, $values, '') . adressbook_inp_field(_("Last name"), 'lastname', $name, 45, $values, '') . @@ -49,10 +83,9 @@ function address_form($name, $submittext, $values = array()) { $submittext . '">', 'center', $color[4], 'colspan="2"') ) - , 'center', '', 'border="0" cellpadding="1" cols="2" width="90%"') ."\n"; + , 'center', '', 'border="0" cellpadding="1" width="90%"') ."\n"; } - /* Open addressbook, with error messages on but without LDAP (the * * second "true"). Don't need LDAP here anyway */ $abook = addressbook_init(true, true); @@ -65,22 +98,24 @@ if($abook->localbackend == 0) { displayPageHeader($color, 'None'); - $defdata = array(); $formerror = ''; $abortform = false; $showaddrlist = true; $defselected = array(); +$form_url = 'addressbook.php'; /* Handle user's actions */ -if($REQUEST_METHOD == 'POST') { +if($_SERVER['REQUEST_METHOD'] == 'POST') { /************************************************** * Add new address * **************************************************/ if (!empty($addaddr['nickname'])) { - + foreach( $addaddr as $k => $adr ) { + $addaddr[$k] = strip_tags( $adr ); + } $r = $abook->add($addaddr, $abook->localbackend); /* Handle error messages */ @@ -93,7 +128,6 @@ if($REQUEST_METHOD == 'POST') { $showaddrlist = false; $defdata = $addaddr; } - } else { /************************************************ @@ -163,7 +197,7 @@ if($REQUEST_METHOD == 'POST') { $olddata = $abook->lookup($enick, $ebackend); /* Display the "new address" form */ - echo '
' . + echo '' . "\n" . html_tag( 'table', html_tag( 'tr', @@ -171,7 +205,7 @@ if($REQUEST_METHOD == 'POST') { "\n". '' . _("Update address") . '' ."\n", 'center', $color[0] ) ), - 'center', '', 'width="100%" cols="1"' ) . + 'center', '', 'width="100%" ' ); address_form("editaddr", _("Update address"), $olddata); echo '\n" . @@ -197,10 +231,10 @@ if($REQUEST_METHOD == 'POST') { '">' . _("ERROR") . ': ' . $abook->error . '' ."\n", 'center' ) ), - 'center', '', 'width="100%" cols="1"' ); + 'center', '', 'width="100%"' ); /* Display the "new address" form again */ - echo '' . "\n" . html_tag( 'table', html_tag( 'tr', @@ -208,7 +242,7 @@ if($REQUEST_METHOD == 'POST') { "\n". '
' . _("Update address") . '' ."\n", 'center', $color[0] ) ), - 'center', '', 'width="100%" cols="1"' ) . + 'center', '', 'width="100%"' ) . address_form("editaddr", _("Update address"), $newdata); echo '\n" . @@ -251,7 +285,7 @@ if (!empty($formerror)) { '">' . _("ERROR") . ': ' . $formerror . '' ."\n", 'center' ) ), - 'center', '', 'width="100%" cols="1"' ); + 'center', '', 'width="100%"' ); } @@ -272,7 +306,7 @@ if ($showaddrlist) { /* List addresses */ if (count($alist) > 0) { - echo '' . "\n"; + echo '' . "\n"; while(list($undef,$row) = each($alist)) { /* New table header for each backend */ @@ -297,8 +331,8 @@ if ($showaddrlist) { html_tag( 'tr', html_tag( 'td', "\n" . '' . $row['source'] . '' . "\n", 'center', $color[0] ) ) , - 'center', '', 'width="95%" cols="1"' ) ."\n" - . html_tag( 'table', '', 'center', '', 'cols="5" border="0" cellpadding="1" cellspacing="0" width="90%"' ) . + 'center', '', 'width="95%"' ) ."\n" + . html_tag( 'table', '', 'center', '', 'border="0" cellpadding="1" cellspacing="0" width="90%"' ) . html_tag( 'tr', "\n" . html_tag( 'th', ' ', 'left', '', 'width="1%"' ) . html_tag( 'th', _("Nickname"), 'left', '', 'width="1%"' ) . @@ -332,14 +366,15 @@ if ($showaddrlist) { html_tag( 'td', ' ' . $row['nickname'] . ' ', 'left', '', 'valign="top" width="1%" nowrap' ) . html_tag( 'td', ' ' . $row['name'] . ' ', 'left', '', 'valign="top" width="1%" nowrap' ) . html_tag( 'td', '', 'left', '', 'valign="top" width="1%" nowrap' ) . ' '; + $email = $abook->full_address($row); if ($compose_new_win == '1') { - echo ''; + echo ''; } else { - echo ''; + echo ''; } - echo $row['email'] . ' '."\n". - html_tag( 'td', ' ' . $row['label'] . ' ', 'left', '', 'valign="top" width="1%"' ) . + echo htmlspecialchars($row['email']) . ' '."\n". + html_tag( 'td', ' ' . htmlspecialchars($row['label']) . ' ', 'left', '', 'valign="top" width="1%"' ) . "\n"; $line++; } @@ -362,14 +397,14 @@ if ($showaddrlist) { /* Display the "new address" form */ echo '' . "\n" . - '' . "\n" . - html_tag( 'table', + '' . "\n" . + html_tag( 'table', html_tag( 'tr', html_tag( 'td', "\n". '' . sprintf(_("Add to %s"), $abook->localbackendname) . '' . "\n", 'center', $color[0] ) ) - , 'center', '', 'width="100%" cols="1"' ) ."\n"; + , 'center', '', 'width="100%"' ) ."\n"; address_form('addaddr', _("Add address"), $defdata); echo '
';