<?php
-
+
/**
* abook_database.php
*
* @subpackage addressbook
*/
-/** Needs the DB functions */
+/** Needs the DB functions */
if (!include_once('DB.php')) {
// same error also in db_prefs.php
require_once(SM_PATH . 'functions/display_messages.php');
class abook_database extends addressbook_backend {
var $btype = 'local';
var $bname = 'database';
-
+
var $dsn = '';
var $table = '';
var $owner = '';
var $dbh = false;
-
+
var $writeable = true;
-
+
/* ========================== Private ======================= */
-
+
/* Constructor */
function abook_database($param) {
$this->sname = _("Personal address book");
-
+
if (is_array($param)) {
- if (empty($param['dsn']) ||
- empty($param['table']) ||
+ if (empty($param['dsn']) ||
+ empty($param['table']) ||
empty($param['owner'])) {
return $this->set_error('Invalid parameters');
}
-
+
$this->dsn = $param['dsn'];
$this->table = $param['table'];
$this->owner = $param['owner'];
-
+
if (!empty($param['name'])) {
$this->sname = $param['name'];
}
return $this->set_error('Invalid argument to constructor');
}
}
-
-
+
+
/* Open the database. New connection if $new is true */
function open($new = false) {
$this->error = '';
-
+
/* Return true is file is open and $new is unset */
if ($this->dbh && !$new) {
return true;
}
-
+
/* Close old file, if any */
if ($this->dbh) {
$this->close();
}
-
+
$dbh = DB::connect($this->dsn, true);
-
+
if (DB::isError($dbh)) {
return $this->set_error(sprintf(_("Database error: %s"),
DB::errorMessage($dbh)));
}
-
+
$this->dbh = $dbh;
return true;
}
}
/* ========================== Public ======================== */
-
+
/* Search the file */
function &search($expr) {
$ret = array();
}
return $ret;
}
-
+
/* Lookup alias */
function &lookup($alias) {
if (empty($alias)) {
return array();
}
-
+
$alias = strtolower($alias);
if (!$this->open()) {
return false;
}
-
+
$query = sprintf("SELECT * FROM %s WHERE owner='%s' AND LOWER(nickname)='%s'",
$this->table, $this->owner, $this->dbh->quoteString($alias));
if (!$this->open()) {
return false;
}
-
+
if(isset($this->listing) && !$this->listing) {
return array();
}
$this->table, $this->owner);
$res = $this->dbh->query($query);
-
+
if (DB::isError($res)) {
return $this->set_error(sprintf(_("Database error: %s"),
DB::errorMessage($res)));
if (!$this->open()) {
return false;
}
-
+
/* See if user exist already */
$ret = $this->lookup($userdata['nickname']);
if (!empty($ret)) {
"'%s','%s','%s')",
$this->table, $this->owner,
$this->dbh->quoteString($userdata['nickname']),
- $this->dbh->quoteString($userdata['firstname']),
+ $this->dbh->quoteString($userdata['firstname']),
$this->dbh->quoteString($userdata['lastname']),
- $this->dbh->quoteString($userdata['email']),
+ $this->dbh->quoteString($userdata['email']),
$this->dbh->quoteString($userdata['label']) );
/* Do the insert */
if (!$this->open()) {
return false;
}
-
+
/* Create query */
$query = sprintf("DELETE FROM %s WHERE owner='%s' AND (",
$this->table, $this->owner);
if (!$this->open()) {
return false;
}
-
+
/* See if user exist */
$ret = $this->lookup($alias);
if (empty($ret)) {
$query = sprintf("UPDATE %s SET nickname='%s', firstname='%s', ".
"lastname='%s', email='%s', label='%s' ".
"WHERE owner='%s' AND nickname='%s'",
- $this->table,
+ $this->table,
$this->dbh->quoteString($userdata['nickname']),
- $this->dbh->quoteString($userdata['firstname']),
+ $this->dbh->quoteString($userdata['firstname']),
$this->dbh->quoteString($userdata['lastname']),
- $this->dbh->quoteString($userdata['email']),
+ $this->dbh->quoteString($userdata['email']),
$this->dbh->quoteString($userdata['label']),
$this->owner,
$this->dbh->quoteString($alias) );
}
} /* End of class abook_database */
-
// vim: et ts=4
-?>
+?>
\ No newline at end of file
function abook_global_file() {
global $address_book_global_filename;
$this->global_filename = $address_book_global_filename;
-
+
$this->sname = _("Global address book");
-
+
$this->open(true);
}
/* Open the addressbook file and store the file pointer.
- * Use $file as the file to open, or the class' own
- * filename property. If $param is empty and file is
+ * Use $file as the file to open, or the class' own
+ * filename property. If $param is empty and file is
* open, do nothing. */
function open($new = false) {
$this->error = '';
if($this->filehandle && !$new) {
return true;
}
-
+
/* Check that new file exists */
- if (! file_exists($this->global_filename) ||
+ if (! file_exists($this->global_filename) ||
! is_readable($this->global_filename)) {
return $this->set_error($this->global_filename . ': ' .
_("No such file or directory"));
}
-
+
/* Close old file, if any */
if ($this->filehandle) {
$this->close();
}
-
+
/* Open file, read only. */
$fh = @fopen($this->global_filename, 'r');
$this->writeable = false;
if(! $fh) {
- return $this->set_error($this->global_filename . ': ' .
+ return $this->set_error($this->global_filename . ': ' .
_("Open failed"));
}
-
+
$this->filehandle = &$fh;
return true;
}
}
/* ========================== Public ======================== */
-
+
/* Search the file */
function search($expr) {
if(is_array($expr)) {
return;
}
-
+
/* Make regexp from glob'ed expression
* May want to quote other special characters like (, ), -, [, ], etc. */
$expr = str_replace('?', '.', $expr);
$expr = str_replace('*', '.*', $expr);
-
+
$res = array();
if(!$this->open()) {
return false;
}
-
+
@rewind($this->filehandle);
-
+
while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
$line = join(' ', $row);
if (eregi($expr, $line)) {
'source' => &$this->sname);
}
}
-
+
return $res;
}
-
+
/* Lookup alias */
function lookup($alias) {
if (empty($alias)) {
return array();
}
-
+
$alias = strtolower($alias);
-
+
$this->open();
@rewind($this->filehandle);
-
+
while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
if (strtolower($row[0]) == $alias) {
return array('nickname' => $row[0],
'source' => &$this->sname);
}
}
-
+
return array();
}
$res = array();
$this->open();
@rewind($this->filehandle);
-
+
while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
$res[] = array('nickname' => $row[0],
'name' => $row[1] . ' ' . $row[2],
$this->set_error(_("Can not modify global address book"));
return false;
}
-
+
} /* End of class abook_local_file */
-?>
+?>
\ No newline at end of file
else {
$this->sname = $param['name'];
}
-
+
$this->open(true);
} else {
$this->set_error('Invalid argument to constructor');
/* Open the LDAP server. New connection if $new is true */
function open($new = false) {
$this->error = '';
-
+
/* Connection is already open */
if($this->linkid != false && !$new) {
return true;
}
-
+
$this->linkid = @ldap_connect($this->server, $this->port);
if(!$this->linkid) {
if(function_exists('ldap_error')) {
- return $this->set_error(ldap_error($this->linkid));
+ return $this->set_error(ldap_error($this->linkid));
} else {
return $this->set_error('ldap_connect failed');
}
}
-
+
if(!empty($this->protocol)) {
if(!@ldap_set_option($this->linkid, LDAP_OPT_PROTOCOL_VERSION, $this->protocol)) {
if(function_exists('ldap_error')) {
} else {
if(!@ldap_bind($this->linkid)) {
if(function_exists('ldap_error')) {
- return $this->set_error(ldap_error($this->linkid));
+ return $this->set_error(ldap_error($this->linkid));
} else {
return $this->set_error('anonymous ldap_bind failed');
}
}
$this->bound = true;
-
+
return true;
}
}
}
-
+
/* ========================== Public ======================== */
/* Search the LDAP server */
function search($expr) {
-
+
/* To be replaced by advanded search expression parsing */
if(is_array($expr)) return false;
-
+
/* Encode the expression */
$expr = $this->charset_encode($expr);
if(strstr($expr, '*') === false) {
$expr = "*$expr*";
}
$expression = "cn=$expr";
-
+
/* Make sure connection is there */
if(!$this->open()) {
return false;
}
-
+
$sret = @ldap_search($this->linkid, $this->basedn, $expression,
- array('dn', 'o', 'ou', 'sn', 'givenname',
+ array('dn', 'o', 'ou', 'sn', 'givenname',
'cn', 'mail', 'telephonenumber'),
0, $this->maxrows, $this->timeout);
-
+
/* Should get error from server using the ldap_error() function,
* but it only exist in the PHP LDAP documentation. */
if(!$sret) {
if(function_exists('ldap_error')) {
- return $this->set_error(ldap_error($this->linkid));
+ return $this->set_error(ldap_error($this->linkid));
} else {
- return $this->set_error('ldap_search failed');
+ return $this->set_error('ldap_search failed');
}
}
-
+
if(@ldap_count_entries($this->linkid, $sret) <= 0) {
return array();
}
-
+
/* Get results */
$ret = array();
$returned_rows = 0;
$res = @ldap_get_entries($this->linkid, $sret);
for($i = 0 ; $i < $res['count'] ; $i++) {
$row = $res[$i];
-
+
/* Extract data common for all e-mail addresses
* of an object. Use only the first name */
$nickname = $this->charset_decode($row['dn']);
$fullname = $this->charset_decode($row['cn'][0]);
-
+
if(empty($row['telephonenumber'][0])) {
$phone = '';
} else {
$phone = $this->charset_decode($row['telephonenumber'][0]);
}
-
+
if(!empty($row['ou'][0])) {
$label = $this->charset_decode($row['ou'][0]);
}
} else {
$label = '';
}
-
+
if(empty($row['givenname'][0])) {
$firstname = '';
} else {
$firstname = $this->charset_decode($row['givenname'][0]);
}
-
+
if(empty($row['sn'][0])) {
$surname = '';
} else {
$surname = $this->charset_decode($row['sn'][0]);
}
-
+
/* Add one row to result for each e-mail address */
if(isset($row['mail']['count'])) {
for($j = 0 ; $j < $row['mail']['count'] ; $j++) {
'phone' => $phone,
'backend' => $this->bnum,
'source' => &$this->sname));
-
+
// Limit number of hits
$returned_rows++;
- if(($returned_rows >= $this->maxrows) &&
+ if(($returned_rows >= $this->maxrows) &&
($this->maxrows > 0) ) {
ldap_free_result($sret);
return $ret;
} // for($j ...)
} // isset($row['mail']['count'])
-
+
}
-
+
ldap_free_result($sret);
return $ret;
} /* end search() */
*
* Careful with this -- it could get quite large for big sites. */
}
-?>
+?>
\ No newline at end of file
if(!empty($param['name'])) {
$this->sname = $param['name'];
}
-
+
$this->open(true);
} else {
$this->set_error('Invalid argument to constructor');
}
/* Open the addressbook file and store the file pointer.
- * Use $file as the file to open, or the class' own
- * filename property. If $param is empty and file is
+ * Use $file as the file to open, or the class' own
+ * filename property. If $param is empty and file is
* open, do nothing. */
function open($new = false) {
$this->error = '';
$file = $this->filename;
$create = $this->create;
-
+
/* Return true is file is open and $new is unset */
if($this->filehandle && !$new) {
return true;
}
-
+
/* Check that new file exitsts */
if((!(file_exists($file) && is_readable($file))) && !$create) {
return $this->set_error("$file: " . _("No such file or directory"));
}
-
+
/* Close old file, if any */
if($this->filehandle) { $this->close(); }
-
+
/* Open file. First try to open for reading and writing,
* but fall back to read only. */
umask($this->umask);
/* Lock the datafile - try 20 times in 5 seconds */
function lock() {
for($i = 0 ; $i < 20 ; $i++) {
- if(flock($this->filehandle, 2 + 4))
+ if(flock($this->filehandle, 2 + 4))
return true;
else
usleep(250000);
if(!$newfh) {
return $this->set_error($this->filename. '.tmp:' . _("Open failed"));
}
-
+
for($i = 0, $cnt=sizeof($rows) ; $i < $cnt ; $i++) {
if(is_array($rows[$i])) {
for($j = 0, $cnt_part=count($rows[$i]) ; $j < $cnt_part ; $j++) {
return $this->set_error($this->filename . '.tmp:' . _("Write failed"));
}
}
- }
+ }
fclose($newfh);
if (!@copy($this->filename . '.tmp' , $this->filename)) {
$this->open(true);
return true;
}
-
+
/* ========================== Public ======================== */
-
+
/* Search the file */
function search($expr) {
/* To be replaced by advanded search expression parsing */
if(is_array($expr)) { return; }
-
+
/* Make regexp from glob'ed expression
* May want to quote other special characters like (, ), -, [, ], etc. */
$expr = str_replace('?', '.', $expr);
$expr = str_replace('*', '.*', $expr);
-
+
$res = array();
if(!$this->open()) {
return false;
}
@rewind($this->filehandle);
-
+
while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
$line = join(' ', $row);
if(eregi($expr, $line)) {
'source' => &$this->sname));
}
}
-
+
return $res;
}
-
+
/* Lookup alias */
function lookup($alias) {
if(empty($alias)) {
}
$alias = strtolower($alias);
-
+
$this->open();
@rewind($this->filehandle);
-
+
while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
if(strtolower($row[0]) == $alias) {
return array('nickname' => $row[0],
'source' => &$this->sname);
}
}
-
+
return array();
}
$res = array();
$this->open();
@rewind($this->filehandle);
-
+
while ($row = @fgetcsv($this->filehandle, 2048, '|')) {
array_push($res, array('nickname' => $row[0],
'name' => $row[1] . ' ' . $row[2],
return $this->set_error(sprintf(_("User '%s' already exist"),
$ret['nickname']));
}
-
+
/* Here is the data to write */
$data = $this->quotevalue($userdata['nickname']) . '|' .
$this->quotevalue($userdata['firstname']) . '|' .
$data = ereg_replace("[\r\n]", ' ', $data);
/* Add linefeed at end */
$data = $data . "\n";
-
+
/* Reopen file, just to be sure */
$this->open(true);
if(!$this->writeable) {
return $this->set_error(_("Addressbook is read-only"));
}
-
+
/* Lock the file */
if(!$this->lock()) {
return $this->set_error(_("Could not lock datafile"));
}
-
+
/* Write */
$r = sq_fwrite($this->filehandle, $data);
-
+
/* Unlock file */
$this->unlock();
-
+
/* Test write result */
if($r === FALSE) {
/* Fail */
$this->set_error(_("Write to addressbook failed"));
return FALSE;
}
-
+
return TRUE;
}
if(!$this->writeable) {
return $this->set_error(_("Addressbook is read-only"));
}
-
+
/* Lock the file to make sure we're the only process working
* on it. */
if(!$this->lock()) {
return $this->set_error(_("Could not lock datafile"));
}
-
+
/* Read file into memory, ignoring nicknames to delete */
@rewind($this->filehandle);
$i = 0;
$rows[$i++] = $row;
}
}
-
+
/* Write data back */
if(!$this->overwrite($rows)) {
$this->unlock();
return false;
}
-
+
$this->unlock();
return true;
}
if(!$this->writeable) {
return $this->set_error(_("Addressbook is read-only"));
}
-
+
/* See if user exists */
$ret = $this->lookup($alias);
if(empty($ret)) {
return $this->set_error(sprintf(_("User '%s' does not exist"),
$alias));
}
-
+
/* Lock the file to make sure we're the only process working
* on it. */
if(!$this->lock()) {
return $this->set_error(_("Could not lock datafile"));
}
-
- /* Read file into memory, modifying the data for the
+
+ /* Read file into memory, modifying the data for the
* user identified by $alias */
$this->open(true);
@rewind($this->filehandle);
$rows[$i++] = array(0 => $userdata['nickname'],
1 => $userdata['firstname'],
2 => $userdata['lastname'],
- 3 => $userdata['email'],
+ 3 => $userdata['email'],
4 => $userdata['label']);
}
}
-
+
/* Write data back */
if(!$this->overwrite($rows)) {
$this->unlock();
return false;
}
-
+
$this->unlock();
return true;
}
-
+
/* Function for quoting values before saving */
function quotevalue($value) {
/* Quote the field if it contains | or ". Double quotes need to
}
} /* End of class abook_local_file */
-?>
+?>
\ No newline at end of file
<?php
+
/**
* addressbook.php
*
$hookReturn = do_hook('abook_init', $abook, $r);
$abook = $hookReturn[1];
$r = $hookReturn[2];
-
+
if ($onlylocal) {
return $abook;
}
* Had to move this function outside of the Addressbook Class
* PHP 4.0.4 Seemed to be having problems with inline functions.
* Note: this can return now since we don't support 4.0.4 anymore.
- */
+ */
function addressbook_cmp($a,$b) {
if($a['backend'] > $b['backend']) {
} else if($a['backend'] < $b['backend']) {
return -1;
}
-
+
return (strtolower($a['name']) > strtolower($b['name'])) ? 1 : -1;
}
var $error = '';
var $localbackend = 0;
var $localbackendname = '';
-
+
// Constructor function.
function AddressBook() {
$localbackendname = _("Personal address book");
$newback->bnum = $this->numbackends;
$this->backends[$this->numbackends] = $newback;
-
+
/* Store ID of first local backend added */
if ($this->localbackend == 0 && $newback->btype == 'local') {
$this->localbackend = $this->numbackends;
/*
- * This function takes a $row array as returned by the addressbook
+ * This function takes a $row array as returned by the addressbook
* search and returns an e-mail address with the full name or
* nickname optionally prepended.
*/
/* Return a sorted search */
function s_search($expression, $bnum = -1) {
-
+
$ret = $this->search($expression, $bnum);
if ( is_array( $ret ) ) {
usort($ret, 'addressbook_cmp');
- }
+ }
return $ret;
}
* local backends.
*/
function lookup($alias, $bnum = -1) {
-
+
$ret = array();
-
+
if ($bnum > -1) {
$res = $this->backends[$bnum]->lookup($alias);
if (is_array($res)) {
return false;
}
}
-
+
$sel = $this->get_backend_list('local');
for ($i = 0 ; $i < sizeof($sel) ; $i++) {
$backend = &$sel[$i];
return false;
}
}
-
+
return $ret;
}
/* Return all addresses */
function list_addr($bnum = -1) {
$ret = array();
-
+
if ($bnum == -1) {
$sel = $this->get_backend_list('local');
} else {
$sel = array(0 => &$this->backends[$bnum]);
}
-
+
for ($i = 0 ; $i < sizeof($sel) ; $i++) {
$backend = &$sel[$i];
$backend->error = '';
return false;
}
}
-
+
return $ret;
}
* to, or false if it failed.
*/
function add($userdata, $bnum) {
-
+
/* Validate data */
if (!is_array($userdata)) {
$this->error = _("Invalid input data");
if (empty($userdata['nickname'])) {
$userdata['nickname'] = $userdata['email'];
}
-
+
if (eregi('[ \\:\\|\\#\\"\\!]', $userdata['nickname'])) {
$this->error = _("Nickname contains illegal characters");
return false;
}
-
+
/* Check that specified backend accept new entries */
if (!$this->backends[$bnum]->writeable) {
$this->error = _("Addressbook is read-only");
return false;
}
-
+
/* Add address to backend */
$res = $this->backends[$bnum]->add($userdata);
if ($res) {
$this->error = $this->backends[$bnum]->error;
return false;
}
-
+
return false; // Not reached
} /* end of add() */
* If $alias is an array, all users in the array are removed.
*/
function remove($alias, $bnum) {
-
+
/* Check input */
if (empty($alias)) {
return true;
}
-
+
/* Convert string to single element array */
if (!is_array($alias)) {
$alias = array(0 => $alias);
}
-
- /* Check that specified backend is writeable */
+
+ /* Check that specified backend is writable */
if (!$this->backends[$bnum]->writeable) {
$this->error = _("Addressbook is read-only");
return false;
}
-
+
/* Remove user from backend */
$res = $this->backends[$bnum]->remove($alias);
if ($res) {
$this->error = $this->backends[$bnum]->error;
return false;
}
-
+
return FALSE; /* Not reached */
} /* end of remove() */
* If $alias is an array, all users in the array are removed.
*/
function modify($alias, $userdata, $bnum) {
-
+
/* Check input */
if (empty($alias) || !is_string($alias)) {
return true;
}
-
+
/* Validate data */
if(!is_array($userdata)) {
$this->error = _("Invalid input data");
$this->error = _("E-mail address is missing");
return false;
}
-
+
if (eregi('[\\: \\|\\#"\\!]', $userdata['nickname'])) {
$this->error = _("Nickname contains illegal characters");
return false;
}
-
+
if (empty($userdata['nickname'])) {
$userdata['nickname'] = $userdata['email'];
}
-
- /* Check that specified backend is writeable */
+
+ /* Check that specified backend is writable */
if (!$this->backends[$bnum]->writeable) {
$this->error = _("Addressbook is read-only");;
return false;
}
-
+
/* Modify user in backend */
$res = $this->backends[$bnum]->modify($alias, $userdata);
if ($res) {
$this->error = $this->backends[$bnum]->error;
return false;
}
-
+
return FALSE; /* Not reached */
} /* end of modify() */
-
-
+
+
} /* End of class Addressbook */
/**
var $btype = 'dummy';
var $bname = 'dummy';
var $sname = 'Dummy backend';
-
+
/*
* Variables common for all backends, but that
* should not be changed by the backends.
var $bnum = -1;
var $error = '';
var $writeable = false;
-
+
function set_error($string) {
$this->error = '[' . $this->sname . '] ' . $string;
return false;
}
-
-
+
+
/* ========================== Public ======================== */
-
+
function search($expression) {
$this->set_error('search not implemented');
return false;
}
-
+
function lookup($alias) {
$this->set_error('lookup not implemented');
return false;
}
-
+
function list_addr() {
$this->set_error('list_addr not implemented');
return false;
}
-
+
function add($userdata) {
$this->set_error('add not implemented');
return false;
}
-
+
function remove($alias) {
$this->set_error('delete not implemented');
return false;
}
-
+
function modify($alias, $newuserdata) {
$this->set_error('modify not implemented');
return false;
* @param string $alt_tag alt tag value (string visible to text only browsers)
* @param integer $Down sort value when list is sorted ascending
* @param integer $Up sort value when list is sorted descending
- * @return string html code with sorting images and urls
+ * @return string html code with sorting images and urls
*/
function show_abook_sort_button($abook_sort_order, $alt_tag, $Down, $Up ) {
global $form_url;
}
/* Only load database backend if database is configured */
-if((isset($addrbook_dsn) && !empty($addrbook_dsn)) ||
+if((isset($addrbook_dsn) && !empty($addrbook_dsn)) ||
(isset($addrbook_global_dsn) && !empty($addrbook_global_dsn)) ) {
include_once(SM_PATH . 'functions/abook_database.php');
}
{
/* If there is a text attachment, we would like to create a 'view' button
that links to the text attachment viewer.
-
+
$Args[1] = the array of actions
-
+
Use our plugin name for adding an action
$Args[1]['attachment_common'] = array for href and text
-
+
$Args[1]['attachment_common']['text'] = What is displayed
$Args[1]['attachment_common']['href'] = Where it links to
-
+
This sets the 'href' of this plugin for a new link. */
sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
$Args[1]['attachment_common']['href'] = SM_PATH . 'src/view_text.php?'. $QUERY_STRING;
$Args[1]['attachment_common']['href'] =
- set_url_var($Args[1]['attachment_common']['href'],
+ set_url_var($Args[1]['attachment_common']['href'],
'ent_id',$Args[5]);
-
+
/* The link that we created needs a name. "view" will be displayed for
all text attachments handled by this plugin. */
$Args[1]['attachment_common']['text'] = _("view");
Where that link points to can be changed. Just in case the link above
for viewing text attachments is not the same as the default link for
this file, we'll change it.
-
+
This is a lot better in the image links, since the defaultLink will just
download the image, but the one that we set it to will format the page
to have an image tag in the center (looking a lot like this text viewer) */
all text attachments handled by this plugin. */
$Args[1]['attachment_common']['text'] = _("view");
- $Args[6] = $Args[1]['attachment_common']['href'];
+ $Args[6] = $Args[1]['attachment_common']['href'];
}
-function attachment_common_link_html(&$Args)
+function attachment_common_link_html(&$Args)
{
sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
/* why use the overridetype? can this be removed */
'&override_type0=text&override_type1=html';
$Args[1]['attachment_common']['href'] =
- set_url_var($Args[1]['attachment_common']['href'],
+ set_url_var($Args[1]['attachment_common']['href'],
'ent_id',$Args[5]);
$Args[1]['attachment_common']['text'] = _("view");
global $attachment_common_show_images, $attachment_common_show_images_list;
sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
-
+
$info['passed_id'] = $Args[3];
$info['mailbox'] = $Args[4];
$info['ent_id'] = $Args[5];
-
+
$attachment_common_show_images_list[] = $info;
-
+
$Args[1]['attachment_common']['href'] = SM_PATH . 'src/image.php?'. $QUERY_STRING;
$Args[1]['attachment_common']['href'] =
- set_url_var($Args[1]['attachment_common']['href'],
+ set_url_var($Args[1]['attachment_common']['href'],
'ent_id',$Args[5]);
-
+
$Args[1]['attachment_common']['text'] = _("view");
-
+
$Args[6] = $Args[1]['attachment_common']['href'];
}
function attachment_common_link_vcard(&$Args)
{
sqgetGlobalVar('QUERY_STRING', $QUERY_STRING, SQ_SERVER);
-
+
$Args[1]['attachment_common']['href'] = SM_PATH . 'src/vcard.php?'. $QUERY_STRING;
$Args[1]['attachment_common']['href'] =
- set_url_var($Args[1]['attachment_common']['href'],
+ set_url_var($Args[1]['attachment_common']['href'],
'ent_id',$Args[5]);
-
+
$Args[1]['attachment_common']['text'] = _("Business Card");
-
+
$Args[6] = $Args[1]['attachment_common']['href'];
}
function attachment_common_octet_stream(&$Args)
{
global $FileExtensionToMimeType;
-
+
do_hook('attachment_common-load_mime_types');
-
+
ereg('\\.([^\\.]+)$', $Args[7], $Regs);
-
+
$Ext = strtolower($Regs[1]);
-
+
if ($Ext == '' || ! isset($FileExtensionToMimeType[$Ext]))
- return;
-
- $Ret = do_hook('attachment ' . $FileExtensionToMimeType[$Ext],
- $Args[1], $Args[2], $Args[3], $Args[4], $Args[5], $Args[6],
+ return;
+
+ $Ret = do_hook('attachment ' . $FileExtensionToMimeType[$Ext],
+ $Args[1], $Args[2], $Args[3], $Args[4], $Args[5], $Args[6],
$Args[7], $Args[8], $Args[9]);
-
+
foreach ($Ret as $a => $b) {
$Args[$a] = $b;
}
}
-?>
+?>
\ No newline at end of file
if ( sqsession_is_registered('user_is_logged_in') ) {
return;
} else {
- global $PHP_SELF, $session_expired_post,
+ global $PHP_SELF, $session_expired_post,
$session_expired_location, $squirrelmail_language;
/* First we store some information in the new session to prevent
* information-loss.
*/
-
+
$session_expired_post = $_POST;
$session_expired_location = $PHP_SELF;
- if (!sqsession_is_registered('session_expired_post')) {
+ if (!sqsession_is_registered('session_expired_post')) {
sqsession_register($session_expired_post,'session_expired_post');
}
if (!sqsession_is_registered('session_expired_location')) {
*/
function digest_md5_response ($username,$password,$challenge,$service,$host) {
$result=digest_md5_parse_challenge($challenge);
-
+
// verify server supports qop=auth
// $qop = explode(",",$result['qop']);
//if (!in_array("auth",$qop)) {
$reply .= ',qop=' . $qop_value;
$reply = base64_encode($reply);
return $reply . "\r\n";
-
+
}
/**
return $hmac;
}
-/**
+/**
* Fillin user and password based on SMTP auth settings.
*
* @param string $user Reference to SMTP username
* @param string $pass Reference to SMTP password (unencrypted)
*/
function get_smtp_user(&$user, &$pass) {
- global $username, $smtp_auth_mech,
+ global $username, $smtp_auth_mech,
$smtp_sitewide_user, $smtp_sitewide_pass;
if ($smtp_auth_mech == 'none') {
}
}
-?>
+?>
\ No newline at end of file
do_hook('loading_constants');
-?>
+?>
\ No newline at end of file
}
// vim: et ts=4
-?>
+?>
\ No newline at end of file
* Copyright (c) 1999-2004 The SquirrelMail Project Team
* Licensed under the GNU GPL. For full terms see the file COPYING.
*
- * This includes code to update < 4.1.0 globals to the newer format
+ * This includes code to update < 4.1.0 globals to the newer format
* It also has some session register functions that work across various
- * php versions.
+ * php versions.
*
* @version $Id$
* @package squirrelmail
require_once(SM_PATH . 'config/config.php');
/** set the name of the session cookie */
-if(isset($session_name) && $session_name) {
- ini_set('session.name' , $session_name);
-} else {
- ini_set('session.name' , 'SQMSESSID');
+if(isset($session_name) && $session_name) {
+ ini_set('session.name' , $session_name);
+} else {
+ ini_set('session.name' , 'SQMSESSID');
}
/** If magic_quotes_runtime is on, SquirrelMail breaks in new and creative ways.
$_SERVER['PHP_SELF'] = strip_tags($_SERVER['PHP_SELF']);
-/**
- * returns true if current php version is at mimimum a.b.c
- *
+/**
+ * returns true if current php version is at mimimum a.b.c
+ *
* Called: check_php_version(4,1)
* @param int a major version number
* @param int b minor version number
* @param int c release number
* @return bool
*/
-function check_php_version ($a = '0', $b = '0', $c = '0')
+function check_php_version ($a = '0', $b = '0', $c = '0')
{
return version_compare ( PHP_VERSION, "$a.$b.$c", 'ge' );
}
/**
- * returns true if the current internal SM version is at minimum a.b.c
- * These are plain integer comparisons, as our internal version is
+ * returns true if the current internal SM version is at minimum a.b.c
+ * These are plain integer comparisons, as our internal version is
* constructed by us, as an array of 3 ints.
*
* Called: check_sm_version(1,3,3)
$SQM_INTERNAL_VERSION[1] == $b &&
$SQM_INTERNAL_VERSION[2] < $c ) ) {
return FALSE;
- }
- return TRUE;
+ }
+ return TRUE;
}
sqsession_is_active();
- $_SESSION["$name"] = $var;
-
+ $_SESSION["$name"] = $var;
+
session_register("$name");
}
sqsession_is_active();
unset($_SESSION[$name]);
-
+
session_unregister("$name");
}
function sqsession_is_registered ($name) {
$test_name = &$name;
$result = false;
-
+
if (isset($_SESSION[$test_name])) {
$result = true;
}
-
+
return $result;
}
/**
* Search for the var $name in $_SESSION, $_POST, $_GET,
- * $_COOKIE, or $_SERVER and set it in provided var.
+ * $_COOKIE, or $_SERVER and set it in provided var.
*
* If $search is not provided, or == SQ_INORDER, it will search
* $_SESSION, then $_POST, then $_GET. Otherwise,
- * use one of the defined constants to look for
+ * use one of the defined constants to look for
* a var in one place specifically.
*
- * Note: $search is an int value equal to one of the
+ * Note: $search is an int value equal to one of the
* constants defined above.
*
* example:
enclosing them in quotes will cause them to evaluate
as strings. */
switch ($search) {
- /* we want the default case to be first here,
- so that if a valid value isn't specified,
+ /* we want the default case to be first here,
+ so that if a valid value isn't specified,
all three arrays will be searched. */
default:
case SQ_INORDER: // check session, post, get
if ( isset($_GET[$name]) ) {
$value = $_GET[$name];
return TRUE;
- }
+ }
/* NO IF HERE. FOR SQ_INORDER CASE, EXIT after GET */
break;
case SQ_COOKIE:
if ( isset($_COOKIE[$name]) ) {
$value = $_COOKIE[$name];
- return TRUE;
+ return TRUE;
}
break;
case SQ_SERVER:
*/
function sqsession_is_active() {
-
+
$sessid = session_id();
if ( empty( $sessid ) ) {
session_start();
}
// vim: et ts=4
-?>
+?>
\ No newline at end of file
}
if ( $bgcolor <> '' ) {
- $bgc = " bgcolor=\"$bgcolor\"";
+ $bgc = " bgcolor=\"$bgcolor\"";
}
switch ( $align ) {
$ret .= ">$val</$tag>";
} else {
$ret .= '>';
- }
+ }
return( $ret );
}
'/.+(\\?'.$var.')=(.*)$/AU', /* at front and only var */
'/.+(\\&'.$var.')=(.*)$/AU' /* at the end */
);
- preg_replace('/&/','&',$url);
+ preg_replace('/&/','&',$url);
switch (true) {
case (preg_match($pat_a[0],$url,$regs)):
$k = $regs[1];
function echo_template_var($var, $format_ar = array() ) {
$frm_last = count($format_ar) -1;
- if (isset($format_ar[0])) echo $format_ar[0];
+ if (isset($format_ar[0])) echo $format_ar[0];
$i = 1;
switch (true) {
echo $format_ar[$frm_last];
}
}
-?>
+?>
\ No newline at end of file
* If Japanese translation is used - function returns string converted to euc-jp
* If iconv or recode functions are enabled and translation uses utf-8 - function returns utf-8 encoded string.
* If $charset is not supported - function returns unconverted string.
- *
+ *
* sanitizing of html tags is also done by this function.
*
* @param string $charset
$charset = "iso-8859-8";
/*
- * Recode converts html special characters automatically if you use
- * 'charset..html' decoding. There is no documented way to put -d option
+ * Recode converts html special characters automatically if you use
+ * 'charset..html' decoding. There is no documented way to put -d option
* into php recode function call.
*/
if ( $use_php_recode ) {
// If we don't use recode and iconv, we'll do it old way.
/* All HTML special characters are 7 bit and can be replaced first */
-
+
$string = htmlspecialchars ($string);
/* controls cpu and memory intensive decoding cycles */
* @param string $string
* @param string $charset
* @param boolean $htmlencode keep htmlspecialchars encoding
- * @param string
+ * @param string
*/
function charset_encode($string,$charset,$htmlencode=true) {
global $default_charset;
function fixcharset($charset) {
// minus removed from function names
$charset=str_replace('-','_',$charset);
-
+
// windows-125x and cp125x charsets
$charset=str_replace('windows_','cp',$charset);
* if $do_search is true, then scan the browser information
* for a possible language that we know
*
- * Function sets system locale environment (LC_ALL, LANG, LANGUAGE),
+ * Function sets system locale environment (LC_ALL, LANG, LANGUAGE),
* gettext translation bindings and html header information.
*
* Function returns error codes, if there is some fatal error.
- * 0 = no error,
- * 1 = mbstring support is not present,
+ * 0 = no error,
+ * 1 = mbstring support is not present,
* 2 = mbstring support is not present, user's translation reverted to en_US.
*
* @param string $sm_language translation used by user's interface
* @param bool $do_search use browser's preferred language detection functions. Defaults to false.
* @param bool $default set $sm_language to $squirrelmail_default_language if language detection fails or language is not set. Defaults to false.
- * @return int function execution error codes.
+ * @return int function execution error codes.
*/
function set_up_language($sm_language, $do_search = false, $default = false) {
if ($do_search && ! $sm_language && isset($accept_lang)) {
$sm_language = substr($accept_lang, 0, 2);
}
-
+
if ((!$sm_language||$default) && isset($squirrelmail_default_language)) {
$squirrelmail_language = $squirrelmail_default_language;
$sm_language = $squirrelmail_default_language;
}
$sm_notAlias = $sm_language;
-
+
// Catching removed translation
// System reverts to English translation if user prefs contain translation
// that is not available in $languages array
setlocale(LC_ALL, $longlocale);
// Set text direction/alignment variables
- if (isset($languages[$sm_notAlias]['DIR']) &&
+ if (isset($languages[$sm_notAlias]['DIR']) &&
$languages[$sm_notAlias]['DIR'] == 'rtl') {
/**
* Text direction
*
* Structure of array:
* $languages['language']['variable'] = 'value'
- *
+ *
* Possible 'variable' names:
* NAME - Translation name in English
* CHARSET - Encoding used by translation
* LOCALE - Full locale name (in xx_XX.charset format)
* DIR - Text direction. Used to define Right-to-Left languages. Possible values 'rtl' or 'ltr'. If undefined - defaults to 'ltr'
* XTRA_CODE - translation uses special functions. See doc/i18n.txt
- *
+ *
* Each 'language' definition requires NAME+CHARSET or ALIAS variables.
*
* @name $languages
$detect_encoding == 'EUC-JP' ||
$detect_encoding == 'SJIS' ||
$detect_encoding == 'UTF-8') {
-
+
$ret = mb_convert_kana(mb_convert_encoding($ret, 'EUC-JP', 'AUTO'), "KV");
}
break;
$detect_encoding == 'EUC-JP' ||
$detect_encoding == 'SJIS' ||
$detect_encoding == 'UTF-8') {
-
+
$ret = mb_convert_encoding(mb_convert_kana($ret, "KV"), 'JIS', 'AUTO');
}
break;
case 'strimwidth':
$width = func_get_arg(2);
- $ret = mb_strimwidth($ret, 0, $width, '...');
+ $ret = mb_strimwidth($ret, 0, $width, '...');
break;
case 'encodeheader':
$result = '';
if ($prevcsize == 1) {
$result .= $tmpstr;
} else {
- $result .= str_replace(' ', '',
+ $result .= str_replace(' ', '',
mb_encode_mimeheader($tmpstr,'iso-2022-jp','B',''));
}
$tmpstr = $tmp;
$no_end = "\x5c\x24\x28\x5b\x7b\xa1\xf2\x5c\xa1\xc6\xa1\xc8\xa1\xd2\xa1" .
"\xd4\xa1\xd6\xa1\xd8\xa1\xda\xa1\xcc\xa1\xf0\xa1\xca\xa1\xce\xa1\xd0\xa1\xef";
$wrap = func_get_arg(2);
-
- if (strlen($ret) >= $wrap &&
+
+ if (strlen($ret) >= $wrap &&
substr($ret, 0, 1) != '>' &&
strpos($ret, 'http://') === FALSE &&
strpos($ret, 'https://') === FALSE &&
strpos($ret, 'ftp://') === FALSE) {
-
+
$ret = mb_convert_kana($ret, "KV");
$line_new = '';
$ptr = 0;
-
+
while ($ptr < strlen($ret) - 1) {
$l = mb_strcut($ret, $ptr, $wrap);
$ptr += strlen($l);
$tmp = $l;
-
+
$l = mb_strcut($ret, $ptr, 2);
while (strlen($l) != 0 && mb_strpos($no_begin, $l) !== FALSE ) {
$tmp .= $l;
/**
* Japanese decoding function
*
- * converts string to euc-jp, if string uses JIS, EUC-JP, ShiftJIS or UTF-8
+ * converts string to euc-jp, if string uses JIS, EUC-JP, ShiftJIS or UTF-8
* charset. Needs mbstring support in php.
* @param string $ret text, that has to be converted
* @return string converted string
$detect_encoding == 'EUC-JP' ||
$detect_encoding == 'SJIS' ||
$detect_encoding == 'UTF-8') {
-
+
$ret = mb_convert_encoding(mb_convert_kana($ret, "KV"), 'JIS', 'AUTO');
}
}
if ($prevcsize == 1) {
$result .= $tmpstr;
} else {
- $result .= str_replace(' ', '',
+ $result .= str_replace(' ', '',
mb_encode_mimeheader($tmpstr,'iso-2022-jp','B',''));
}
$tmpstr = $tmp;
/**
* Japanese header decoding function
*
- * return human readable string from mime header. string is returned in euc-jp
+ * return human readable string from mime header. string is returned in euc-jp
* charset.
* @param string $ret header string
* @return string decoded header string
/**
* Japanese wordwrap function
- *
+ *
* wraps text at set number of symbols
* @param string $ret text
* @param integer $wrap number of symbols per line
"\xa8\xa1\xa9\xa1\xcf\xa1\xd1";
$no_end = "\x5c\x24\x28\x5b\x7b\xa1\xf2\x5c\xa1\xc6\xa1\xc8\xa1\xd2\xa1" .
"\xd4\xa1\xd6\xa1\xd8\xa1\xda\xa1\xcc\xa1\xf0\xa1\xca\xa1\xce\xa1\xd0\xa1\xef";
-
- if (strlen($ret) >= $wrap &&
+
+ if (strlen($ret) >= $wrap &&
substr($ret, 0, 1) != '>' &&
strpos($ret, 'http://') === FALSE &&
strpos($ret, 'https://') === FALSE &&
strpos($ret, 'ftp://') === FALSE) {
$ret = mb_convert_kana($ret, "KV");
-
+
$line_new = '';
$ptr = 0;
-
+
while ($ptr < strlen($ret) - 1) {
$l = mb_strcut($ret, $ptr, $wrap);
$ptr += strlen($l);
$tmp = $l;
-
+
$l = mb_strcut($ret, $ptr, 2);
while (strlen($l) != 0 && mb_strpos($no_begin, $l) !== FALSE ) {
$tmp .= $l;
* Korean downloaded filename processing functions
*
* @param string default return value
- * @return string
+ * @return string
*/
function korean_xtra_downloadfilename($ret) {
$ret = str_replace("\x0D\x0A", '', $ret); /* Hanmail's CR/LF Clear */
/**
* Replaces non-braking spaces inserted by some browsers with regular space
- *
- * This function can be used to replace non-braking space symbols
- * that are inserted in forms by some browsers instead of normal
+ *
+ * This function can be used to replace non-braking space symbols
+ * that are inserted in forms by some browsers instead of normal
* space symbol.
*
* @param string $string Text that needs to be cleaned
return $string;
endswitch;
-// return space instead of non-braking space.
+// return space instead of non-braking space.
return str_replace($nbsp,' ',$string);
}
/**
* Function informs if it is safe to convert given charset to the one that is used by user.
*
- * It is safe to use conversion only if user uses utf-8 encoding and when
+ * It is safe to use conversion only if user uses utf-8 encoding and when
* converted charset is similar to the one that is used by user.
*
* @param string $input_charset Charset of text that needs to be converted
// Charsets that are similar
switch ($default_charset):
case "windows-1251":
- if ( $input_charset == "iso-8859-5" ||
+ if ( $input_charset == "iso-8859-5" ||
$input_charset == "koi8-r" ||
$input_charset == "koi8-u" ) {
return true;
return false;
}
case "windows-1257":
- if ( $input_charset == "iso-8859-13" ||
+ if ( $input_charset == "iso-8859-13" ||
$input_charset == "iso-8859-4" ) {
return true;
} else {
return false;
}
case "iso-8859-4":
- if ( $input_charset == "iso-8859-13" ||
+ if ( $input_charset == "iso-8859-13" ||
$input_charset == "windows-1257" ) {
return true;
} else {
return false;
}
case "iso-8859-5":
- if ( $input_charset == "windows-1251" ||
- $input_charset == "koi8-r" ||
+ if ( $input_charset == "windows-1251" ||
+ $input_charset == "koi8-r" ||
$input_charset == "koi8-u" ) {
return true;
} else {
}
case "koi8-r":
if ( $input_charset == "windows-1251" ||
- $input_charset == "iso-8859-5" ||
+ $input_charset == "iso-8859-5" ||
$input_charset == "koi8-u" ) {
return true;
} else {
return $identities;
}
-?>
+?>
\ No newline at end of file
require_once(SM_PATH . 'functions/imap_general.php');
require_once(SM_PATH . 'functions/imap_search.php');
-?>
+?>
\ No newline at end of file
<?php
+
/**
* imap_mailbox.php
*
$color, $search_position = '', $search_all, $count_all) {
global $message_highlight_list, $squirrelmail_language, $languages,
- $index_order, $pos, $allow_charset_search,
+ $index_order, $pos, $allow_charset_search,
$imap_server_type;
$pos = $search_position;
$multi_search = explode(' ', $search_what);
$search_string = '';
- /* it seems macosx does not support the prefered search
+ /* it seems macosx does not support the prefered search
syntax so we fall back to the older style. This IMAP
server has a problem with multiple search terms. Instead
of returning the messages that match all the terms it
if ($allow_charset_search && isset($languages[$squirrelmail_language]['CHARSET']) &&
$languages[$squirrelmail_language]['CHARSET']) {
$ss = "SEARCH CHARSET "
- . strtoupper($languages[$squirrelmail_language]['CHARSET'])
+ . strtoupper($languages[$squirrelmail_language]['CHARSET'])
. " ALL $search_string";
} else {
$ss = "SEARCH ALL $search_string";
$readin = sqimap_run_command($imapConnection, $ss, false, $result, $message, TRUE);
/* try US-ASCII charset if search fails */
- if (isset($languages[$squirrelmail_language]['CHARSET'])
+ if (isset($languages[$squirrelmail_language]['CHARSET'])
&& strtolower($result) == 'no') {
$ss = "SEARCH CHARSET \"US-ASCII\" ALL $search_string";
- $readin = sqimap_run_command ($imapConnection, $ss, true,
+ $readin = sqimap_run_command ($imapConnection, $ss, true,
$result, $message);
}
-?>
+?>
\ No newline at end of file
*/
function sqimap_mb_convert_encoding($str, $to_encoding, $from_encoding, $default_charset)
{
- // Allows mbstring functions only with iso-8859-*, utf-8 and
+ // Allows mbstring functions only with iso-8859-*, utf-8 and
// iso-2022-jp (Japanese)
// koi8-r and gb2312 can be added only in php 4.3+
if ( stristr($default_charset, 'iso-8859-') ||
- stristr($default_charset, 'utf-8') ||
+ stristr($default_charset, 'utf-8') ||
stristr($default_charset, 'iso-2022-jp') ) {
if (function_exists('mb_convert_encoding')) {
return mb_convert_encoding($str, $to_encoding, $from_encoding);
function imap_utf7_encode_local($s) {
global $languages, $squirrelmail_language;
-
+
if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
function_exists($languages[$squirrelmail_language]['XTRA_CODE'].'_utf7_imap_encode')) {
return call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_utf7_imap_encode', $s);
return $utf7_s;
}
- // Later code works only for ISO-8859-1
-
+ // Later code works only for ISO-8859-1
+
$b64_s = ''; // buffer for substring to be base64-encoded
$utf7_s = ''; // imap-utf7-encoded string
for ($i = 0; $i < strlen($s); $i++) {
function imap_utf7_decode_local($s) {
global $languages, $squirrelmail_language;
-
+
if (isset($languages[$squirrelmail_language]['XTRA_CODE']) &&
function_exists($languages[$squirrelmail_language]['XTRA_CODE'] . '_utf7_imap_decode')) {
return call_user_func($languages[$squirrelmail_language]['XTRA_CODE'] . '_utf7_imap_decode', $s);
}
// Later code works only for ISO-8859-1
-
+
$b64_s = '';
$iso_8859_1_s = '';
for ($i = 0, $len = strlen($s); $i < $len; $i++) {
return $d;
}
-?>
+?>
\ No newline at end of file
/* pretty impressive huh? */
-?>
+?>
\ No newline at end of file
<?php
/**
-* mailbox_display.php
-*
-* Copyright (c) 1999-2004 The SquirrelMail Project Team
-* Licensed under the GNU GPL. For full terms see the file COPYING.
-*
-* This contains functions that display mailbox information, such as the
-* table row that has sender, date, subject, etc...
-*
-* @version $Id$
-* @package squirrelmail
-*/
+ * mailbox_display.php
+ *
+ * Copyright (c) 1999-2004 The SquirrelMail Project Team
+ * Licensed under the GNU GPL. For full terms see the file COPYING.
+ *
+ * This contains functions that display mailbox information, such as the
+ * table row that has sender, date, subject, etc...
+ *
+ * @version $Id$
+ * @package squirrelmail
+ */
/** The standard includes.. */
require_once(SM_PATH . 'functions/strings.php');
require_once(SM_PATH . 'functions/forms.php');
/**
-* default value for page_selector_max
-*/
+ * default value for page_selector_max
+ */
define('PG_SEL_MAX', 10);
/**
-* The number of pages to cache msg headers
-*/
+ * The number of pages to cache msg headers
+ */
define('SQM_MAX_PAGES_IN_CACHE',5);
/**
-* Sort constants used for sorting of messages
-*/
+ * Sort constants used for sorting of messages
+ */
define('SQSORT_NONE',0);
define('SQSORT_DATE_ASC',1);
define('SQSORT_DATE_DEC',2);
// define('MBX_PREF_FUTURE',unique integer key);
/**
-* @param mixed $start UNDOCUMENTED
-*/
+ * @param mixed $start UNDOCUMENTED
+ */
function elapsed($start) {
$end = microtime();
}
/**
-* Displays message header row in messages list
-*
-* @param array $aMsg contains all message related parameters
-* @return void
-*/
+ * Displays message header row in messages list
+ *
+ * @param array $aMsg contains all message related parameters
+ * @return void
+ */
function printMessageInfo($aMsg) {
// FIX ME, remove these globals as well by adding an array as argument for the user settings
/**
-* Does the $srt $_GET var to field mapping
-*
-* @param int $srt Field to sort on
-* @param bool $bServerSort Server sorting is true
-* @return string $sSortField Field to sort on
-*/
+ * Does the $srt $_GET var to field mapping
+ *
+ * @param int $srt Field to sort on
+ * @param bool $bServerSort Server sorting is true
+ * @return string $sSortField Field to sort on
+ */
function getSortField($sort,$bServerSort) {
switch($sort) {
case SQSORT_NONE:
}
/**
- * retrieve messages by sequence id's and fetch the UID to retrieve
- * the UID. for sorted lists this is not needed because a UID FETCH
- * automaticly add the UID value in fetch results
- **/
+ * retrieve messages by sequence id's and fetch the UID to retrieve
+ * the UID. for sorted lists this is not needed because a UID FETCH
+ * automaticly add the UID value in fetch results
+ **/
$aFetchItems[] = 'UID';
//create id range
}
/**
-* This function loops through a group of messages in the mailbox
-* and shows them to the user.
-*
-* @param mixed $imapConnection
-* @param array $aMailbox associative array with mailbox related vars
-*/
+ * This function loops through a group of messages in the mailbox
+ * and shows them to the user.
+ *
+ * @param mixed $imapConnection
+ * @param array $aMailbox associative array with mailbox related vars
+ */
function showMessagesForMailbox($imapConnection, &$aMailbox) {
global $color;
}
/**
-* Function to map an uid list with a msg header array by uid
-* The mapped headers are printed with printMessage
-* aMailbox parameters contains info about the page we are on, the
-* used search criteria, the number of messages to show
-*
-* @param resource $imapConnection socket handle to imap
-* @param array $aMailbox array with required elements MSG_HEADERS, UIDSET, OFFSET, LIMIT
-* @return void
-**/
+ * Function to map an uid list with a msg header array by uid
+ * The mapped headers are printed with printMessage
+ * aMailbox parameters contains info about the page we are on, the
+ * used search criteria, the number of messages to show
+ *
+ * @param resource $imapConnection socket handle to imap
+ * @param array $aMailbox array with required elements MSG_HEADERS, UIDSET, OFFSET, LIMIT
+ * @return void
+ **/
function displayMessageArray($imapConnection, $aMailbox) {
$iSetIndx = $aMailbox['SETINDEX'];
$aId = $aMailbox['UIDSET'][$iSetIndx];
}
/**
-* Displays the standard message list header.
-*
-* To finish the table, you need to do a "</table></table>";
-*
-* @param resource $imapConnection
-* @param array $aMailbox associative array with mailbox related information
-* @param string $msg_cnt_str
-* @param string $paginator Paginator string
-*/
+ * Displays the standard message list header.
+ *
+ * To finish the table, you need to do a "</table></table>";
+ *
+ * @param resource $imapConnection
+ * @param array $aMailbox associative array with mailbox related information
+ * @param string $msg_cnt_str
+ * @param string $paginator Paginator string
+ */
function mail_message_listing_beginning ($imapConnection,
$aMailbox,
$msg_cnt_str = '',
}
/**
-* Function to add the last row in a message list, it contains the paginator and info about
-* the number of messages.
-*
-* @param integer $num_msgs number of messages in a mailbox
-* @param string $paginator_str Paginator string [Prev | Next] [ 1 2 3 ... 91 92 94 ] [Show all]
-* @param string $msg_cnt_str Message count string Viewing Messages: 21 to 1861 (20 total)
-*/
+ * Function to add the last row in a message list, it contains the paginator and info about
+ * the number of messages.
+ *
+ * @param integer $num_msgs number of messages in a mailbox
+ * @param string $paginator_str Paginator string [Prev | Next] [ 1 2 3 ... 91 92 94 ] [Show all]
+ * @param string $msg_cnt_str Message count string Viewing Messages: 21 to 1861 (20 total)
+ */
function mail_message_listing_end($num_msgs, $paginator_str, $msg_cnt_str) {
global $color;
if ($num_msgs) {
}
/**
-* Prints the table header for the messages list view
-*
-* @param array $aMailbox
-*/
+ * Prints the table header for the messages list view
+ *
+ * @param array $aMailbox
+ */
function printHeader($aMailbox) {
global $index_order, $internal_date_sort, $color;
echo html_tag( 'tr' ,'' , 'center', $color[5] );
/* calculate the width of the subject column based on the
- * widths of the other columns */
+ * widths of the other columns */
$widths = array(1=>1,2=>25,3=>5,4=>0,5=>1,6=>5);
$subjectwidth = 100;
foreach($index_order as $item) {
/**
-* This function shows the sort button. Isn't this a good comment?
-*
-* @param array $aMailbox
-* @param integer $Down
-* @param integer $Up
-*/
+ * This function shows the sort button. Isn't this a good comment?
+ *
+ * @param array $aMailbox
+ * @param integer $Down
+ * @param integer $Up
+ */
function ShowSortButton($aMailbox, $Down, $Up ) {
global $PHP_SELF;
}
/**
-* FIXME: Undocumented function
-*
-* @param array $aMailbox
-*/
+ * FIXME: Undocumented function
+ *
+ * @param array $aMailbox
+ */
function get_selectall_link($aMailbox) {
global $checkall, $javascript_on;
global $PHP_SELF;
}
/**
-* This function computes the "Viewing Messages..." string.
-*
-* @param integer $start_msg first message number
-* @param integer $end_msg last message number
-* @param integer $num_msgs total number of message in folder
-* @return string
-*/
+ * This function computes the "Viewing Messages..." string.
+ *
+ * @param integer $start_msg first message number
+ * @param integer $end_msg last message number
+ * @param integer $num_msgs total number of message in folder
+ * @return string
+ */
function get_msgcnt_str($start_msg, $end_msg, $num_msgs) {
/* Compute the $msg_cnt_str. */
$result = '';
}
/**
-* Generate a paginator link.
-*
-* @param mixed $box Mailbox name
-* @param mixed $start_msg Message Offset
-* @param mixed $use
-* @param string $text text used for paginator link
-* @return string
-*/
+ * Generate a paginator link.
+ *
+ * @param mixed $box Mailbox name
+ * @param mixed $start_msg Message Offset
+ * @param mixed $use
+ * @param string $text text used for paginator link
+ * @return string
+ */
function get_paginator_link($box, $start_msg, $text) {
sqgetGlobalVar('PHP_SELF',$php_self,SQ_SERVER);
$result = "<a href=\"$php_self?startMessage=$start_msg&mailbox=$box\" "
}
/**
-* This function computes the paginator string.
-*
-* @param string $box mailbox name
-* @param integer $iOffset offset in total number of messages
-* @param integer $iTotal total number of messages
-* @param integer $iLimit maximum number of messages to show on a page
-* @param bool $bShowAll show all messages at once (non paginate mode)
-* @return string $result paginate string with links to pages
-*/
+ * This function computes the paginator string.
+ *
+ * @param string $box mailbox name
+ * @param integer $iOffset offset in total number of messages
+ * @param integer $iTotal total number of messages
+ * @param integer $iLimit maximum number of messages to show on a page
+ * @param bool $bShowAll show all messages at once (non paginate mode)
+ * @return string $result paginate string with links to pages
+ */
function get_paginator_str($box, $iOffset, $iTotal, $iLimit, $bShowAll) {
global $username, $data_dir;
sqgetGlobalVar('PHP_SELF',$php_self,SQ_SERVER);
/* Put all the pieces of the paginator string together. */
/**
- * Hairy code... But let's leave it like it is since I am not certain
- * a different approach would be any easier to read. ;)
- */
+ * Hairy code... But let's leave it like it is since I am not certain
+ * a different approach would be any easier to read. ;)
+ */
$result = '';
if ( $prv_str || $nxt_str ) {
}
/**
-* FIXME: Undocumented function
-*/
+ * FIXME: Undocumented function
+ */
function truncateWithEntities($subject, $trim_at)
{
$ent_strlen = strlen($subject);
global $languages, $squirrelmail_language;
/*
- * see if this is entities-encoded string
- * If so, Iterate through the whole string, find out
- * the real number of characters, and if more
- * than $trim_at, substr with an updated trim value.
- */
+ * see if this is entities-encoded string
+ * If so, Iterate through the whole string, find out
+ * the real number of characters, and if more
+ * than $trim_at, substr with an updated trim value.
+ */
$trim_val = $trim_at;
$ent_offset = 0;
$ent_loc = 0;
}
/**
-* FIXME: Undocumented function
-*/
+ * FIXME: Undocumented function
+ */
function processSubject($subject, $threadlevel = 0) {
/* Shouldn't ever happen -- caught too many times in the IMAP functions */
if ($subject == '') {
/**
-* Creates button
-*
-* @deprecated see form functions available in 1.5.1 and 1.4.3.
-* @param string $type
-* @param string $name
-* @param string $value
-* @param string $js
-* @param bool $enabled
-*/
+ * Creates button
+ *
+ * @deprecated see form functions available in 1.5.1 and 1.4.3.
+ * @param string $type
+ * @param string $name
+ * @param string $value
+ * @param string $js
+ * @param bool $enabled
+ */
function getButton($type, $name, $value, $js = '', $enabled = TRUE) {
$disabled = ( $enabled ? '' : 'disabled ' );
$js = ( $js ? $js.' ' : '' );
}
/**
-* Puts string into cell, aligns it and adds <small> tag
-*
-* @param string $string string
-* @param string $align alignment
-*/
+ * Puts string into cell, aligns it and adds <small> tag
+ *
+ * @param string $string string
+ * @param string $align alignment
+ */
function getSmallStringCell($string, $align) {
return html_tag('td',
'<small>' . $string . ': </small>',
}
/**
-* This should go in imap_mailbox.php
-* @param string $mailbox
-*/
+ * This should go in imap_mailbox.php
+ * @param string $mailbox
+ */
function handleAsSent($mailbox) {
global $handleAsSent_result;
function createHTMLWidget() {
global $javascript_on;
- // Use new value if available
+ // Use new value if available
if (!empty($this->new_value)) {
$tempValue = $this->value;
$this->value = $this->new_value;
/* Add the "post script" for this option. */
$result .= $this->post_script;
-
+
// put correct value back if need be
if (!empty($this->new_value)) {
$this->value = $tempValue;
}
$result = "<input type=\"text\" name=\"new_$this->name\" value=\"" .
- htmlspecialchars($this->value) .
+ htmlspecialchars($this->value) .
"\" size=\"$width\" $this->script />$this->trailing_text\n";
return ($result);
}
/* Add each possible value to the select list. */
foreach ($this->possible_values as $real_value => $disp_value) {
/* Start the next new option string. */
- $new_option = '<option value="' .
+ $new_option = '<option value="' .
htmlspecialchars($real_value) . '"';
/* If this value is the current value, select it. */
/* Add each possible value to the select list. */
foreach ($this->possible_values as $real_value => $disp_value) {
- if ( is_array($disp_value) ) {
+ if ( is_array($disp_value) ) {
/* For folder list, we passed in the array of boxes.. */
$new_option = sqimap_mailbox_option_list(0, $selected, 0, $disp_value);
} else {
/* Start the next new option string. */
$new_option = '<option value="' . htmlspecialchars($real_value) . '"';
-
+
/* If this value is the current value, select it. */
if ($real_value == $this->value) {
$new_option .= ' selected="selected"';
}
-
+
/* Add the display value to our option string. */
$new_option .= '>' . htmlspecialchars($disp_value) . "</option>\n";
}
/* And add the new option string to our select tag. */
$result .= $new_option;
- }
+ }
/* Close the select tag and return our happy result. */
$result .= "</select>\n";
return ($result);
}
function createWidget_Float() {
-
+
global $javascript_on;
// add onChange javascript handler to a regular string widget
- // which will strip out all non-numeric (period also OK) chars
+ // which will strip out all non-numeric (period also OK) chars
if ($javascript_on)
return preg_replace('/\/>/', ' onChange="origVal=this.value; newVal=\'\'; '
. 'for (i=0;i<origVal.length;i++) { if ((origVal.charAt(i)>=\'0\' '
function createWidget_Boolean() {
/* Do the whole current value thing. */
if ($this->value != SMPREF_NO) {
- $yes_chk = ' checked=""';
+ $yes_chk = ' checked="checked"';
$no_chk = '';
} else {
$yes_chk = '';
- $no_chk = ' checked=""';
+ $no_chk = ' checked="checked"';
}
/* Build the yes choice. */
echo '<link rel="stylesheet" type="text/css" href="' .
$base_uri . 'themes/css/'.$custom_css.'" />';
}
-
+
if ($squirrelmail_language == 'ja_JP') {
echo "<!-- \xfd\xfe -->\n";
echo '<meta http-equiv="Content-type" content="text/html; charset=euc-jp" />' . "\n";
}
-
+
if ($do_hook) {
do_hook('generic_header');
}
-
+
echo "\n<title>$title</title>$xtra\n";
/* work around IE6's scrollbar bug */
<style type="text/css">
<!--
/* avoid stupid IE6 bug with frames and scrollbars */
- body {
- voice-family: "\"}\"";
- voice-family: inherit;
+ body {
+ voice-family: "\"}\"";
+ voice-family: inherit;
width: expression(document.documentElement.clientWidth - 30);
}
-->
$compose_uri = $base_uri.'src/compose.php?newmessage=1';
$session = 0;
}
-
- if($javascript_on) {
+
+ if($javascript_on) {
switch ( $module ) {
case 'src/read_body.php':
"document.forms[i-1].elements[pos].focus();\n".
"}\n".
"}\n";
-
+
$js .= "// -->\n".
"</script>\n";
$onload = 'onload="checkForm();"';
displayHtmlHeader ('SquirrelMail', $js);
- break;
+ break;
default:
$js = '<script language="JavaScript" type="text/javascript">' .
"}\n".
"$xtra\n".
"}\n";
-
+
if ($compose_new_win == '1') {
if (!preg_match("/^[0-9]{3,4}$/", $compose_width)) {
$compose_width = '640';
}
$js .= "// -->\n". "</script>\n";
-
+
$onload = 'onload="checkForm();"';
displayHtmlHeader ('SquirrelMail', $js);
- break;
+ break;
}
} else {
"</script>\n";
$onload = 'onload="checkForm();"';
displayHtmlHeader (_("Compose"), $js);
- break;
+ break;
}
} else {
/* javascript off */
echo "<body text=\"$color[8]\" bgcolor=\"$color[4]\" link=\"$color[7]\" vlink=\"$color[7]\" alink=\"$color[7]\" $onload>\n\n";
}
-?>
+?>
\ No newline at end of file
if ( !sqsession_is_registered('prefs_are_cached') ||
!isset( $prefs_cache) ||
- !is_array( $prefs_cache)
+ !is_array( $prefs_cache)
) {
$prefs_are_cached = false;
$prefs_cache = array();
if (substr($dir, -1) == '/') {
$dir = substr($dir, 0, strlen($dir) - 1);
}
-
+
/* Compute the hash for this user and extract the hash directories. */
$hash_dirs = computeHashDirs($username);
}
}
}
-
+
/* Return the full hashed datafile path. */
return ($result);
}
if (substr($dir, -1) == '/') {
$dir = substr($dir, 0, strlen($dir) - 1);
}
-
+
/* If necessary, populate the hash dir variable. */
if ($hash_dirs == '') {
$hash_dirs = computeHashDirs($username);
if ($tree[$index]['doIHaveChildren']) {
sqimap_mailbox_create($imap_stream, $trash_folder . $delimiter . $subFolderName, "");
- $mbx_response = sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
+ $mbx_response = sqimap_mailbox_select($imap_stream, $tree[$index]['value']);
$messageCount = $mbx_response['EXISTS'];
if ($messageCount > 0) {
sqimap_messages_copy($imap_stream, 1, '*', $trash_folder . $delimiter . $subFolderName);
'news://');
global $url_parser_poss_ends;
-$url_parser_poss_ends = array(' ', "\n", "\r", '<', '>', ".\r", ".\n",
- '. ', ' ', ')', '(', '"', '<', '>', '.<',
+$url_parser_poss_ends = array(' ', "\n", "\r", '<', '>', ".\r", ".\n",
+ '. ', ' ', ')', '(', '"', '<', '>', '.<',
']', '[', '{', '}', "\240", ', ', '. ', ",\n", ",\r");
$start = $target_pos;
$blength = strlen($body);
}
-}
-?>
+}
+?>
\ No newline at end of file