X-Git-Url: https://vcs.fsf.org/?p=squirrelmail.git;a=blobdiff_plain;f=src%2Faddrbook_search.php;h=53f81c9bf3eb71c69976b1cd953896ad157403a3;hp=fca02aff45349c7f7a9da7f6426acfc4aa2ad7ad;hb=0b97a708e71c931153cd1ceee1495c9f4e1e209b;hpb=db48e3f5d3a7dfaeb19e9e87b9d6a8f6effe11dc diff --git a/src/addrbook_search.php b/src/addrbook_search.php index fca02aff..53f81c9b 100644 --- a/src/addrbook_search.php +++ b/src/addrbook_search.php @@ -15,8 +15,30 @@ * $Id$ */ -require_once('../src/validate.php'); -require_once('../functions/strings.php'); +/* Path for SquirrelMail required files. */ +define('SM_PATH','../'); + +/* SquirrelMail required files. */ +require_once(SM_PATH . 'include/validate.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']; + +sqextractGlobalVar('show'); +if ( isset($_POST['query']) ) { + $query = $_POST['query']; +} +if ( isset($_POST['listall']) ) { + $listall = $_POST['listall']; +} +if ( isset($_POST['backend'] ) ) { + $backend = $_POST['backend']; +} /* Function to include JavaScript code */ function insert_javascript() { @@ -93,40 +115,45 @@ function display_result($res, $includesource = true) { insert_javascript(); $line = 0; - echo '' . - '\n"; + echo "\n"; while (list($undef, $row) = each($res)) { - echo '\n"; + echo "\n"; $line++; } - echo '
 ' . - ' ' . _("Name") . - ' ' . _("E-mail") . - ' ' . _("Info"); + echo html_tag( 'table', '', 'center', '', 'border="0" width="98%"' ) . + html_tag( 'tr', '', '', $color[9] ) . + html_tag( 'th', ' ', 'left' ) . + html_tag( 'th', ' ' . _("Name"), 'left' ) . + html_tag( 'th', ' ' . _("E-mail"), 'left' ) . + html_tag( 'th', ' ' . _("Info"), 'left' ); if ($includesource) { - echo ' ' . _("Source"); + echo html_tag( 'th', ' ' . _("Source"), 'left', 'width="10%"' ); } - echo "
' . + $tr_bgcolor = ''; + $email = htmlspecialchars(addcslashes(AddressBook::full_address($row), "'"), ENT_QUOTES); + if ($line % 2) { $tr_bgcolor = $color[0]; } + echo html_tag( 'tr', '', '', $tr_bgcolor, 'nowrap' ) . + html_tag( 'td', 'To | " . + "'" . $email . "');\">To | " . 'Cc | " . + "'" . $email . "');\">Cc | " . 'Bcc" . - ' ' . - $row['name'] . ' ' . - ' " . $row['email'] . ' ' . - ' ' . $row['label'] . ' '; + "'" . $email . "');\">Bcc", + 'center', '', 'valign="top" width="5%" nowrap' ) . + html_tag( 'td', ' ' . htmlspecialchars($row['name']), 'left', '', 'valign="top" nowrap' ) . + html_tag( 'td', ' ' . + '" . htmlspecialchars($row['email']) . '' + , 'left', '', 'valign="top"' ) . + html_tag( 'td', htmlspecialchars($row['label']), 'left', '', 'valign="top" nowrap' ); if ($includesource) { - echo ' ' . $row['source']; + echo html_tag( 'td', ' ' . $row['source'], 'left', '', 'valign="top" nowrap' ); } - echo "
'; + echo ''; } /* ================= End of functions ================= */ @@ -140,9 +167,10 @@ displayHtmlHeader(); /* Initialize vars */ if (!isset($query)) { $query = ''; } if (!isset($show)) { $show = ''; } +if (!isset($backend)) { $backend = ''; } /* Choose correct colors for top and bottom frame */ -if ($show == 'form') { +if ($show == 'form' && !isset($listall)) { echo '
' . - _("No persons matching your search was found") . - "

\n\n", + echo html_tag( 'p', '
' . + _("No persons matching your search was found"), + 'center' ) . + "\n\n", exit; } @@ -165,14 +194,15 @@ if (empty($query) && empty($show) && empty($listall)) { $abook = addressbook_init(); /* Create search form */ -if ($show == 'form') { - echo '
' . "\n" . - '' . - '
' . "\n" . - ' ' . _("Search for") . "\n" . - ' \n"; + html_tag( 'table', '', '', '', 'border="0" width="100%" height="100%"' ) . + html_tag( 'tr' ) . + html_tag( 'td', ' ' . _("Search for") . "\n", 'left', '', 'nowrap valign="middle" width="10%"' ) . + html_tag( 'td', '', 'left', '', '' ) . + '\n"; /* List all backends to allow the user to choose where to search */ if ($abook->numbackends > 1) { @@ -187,13 +217,18 @@ if ($show == 'form') { echo '' . "\n"; } - echo '' . - ' | ' . "\n" . - '' . "\n" . - '' . "\n" . - '
' . "\n"; + echo '' . + html_tag( 'tr', + html_tag( 'td', '', 'left' ) . + html_tag( 'td', + '' . + ' | ' . "\n" . + ' | ' . "\n" , + 'left' ) + ) . + '' . "\n"; } else { /* Show personal addressbook */ @@ -209,10 +244,10 @@ if ($show == 'form') { usort($res,'alistcmp'); display_result($res, false); } else { - echo '

' . - sprintf(_("Unable to list addresses from %s"), - $abook->backends[$backend]->sname) . - '

' . "\n"; + echo html_tag( 'p', '' . + sprintf(_("Unable to list addresses from %s"), + $abook->backends[$backend]->sname) . '' , + 'center' ) . "\n"; } } else { $res = $abook->list_addr(); @@ -235,16 +270,19 @@ if ($show == 'form') { } if (!is_array($res)) { - echo '


' . - _("Your search failed with the following error(s)") . - ':
' . $abook->error . "

\n\n"; + echo html_tag( 'p', '
' . + _("Your search failed with the following error(s)") . + ':
' . $abook->error . "
\n" , + 'center' ) . + "\n\n"; exit; } if (sizeof($res) == 0) { - echo '


' . - _("No persons matching your search was found") . - ".

\n\n"; + echo html_tag( 'p', '
' . + _("No persons matching your search was found") . "\n" , + 'center' ) . + "\n\n"; exit; }