|
|
@ -3,7 +3,7 @@
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Copy a new users identities and contacts from a nearby Squirrelmail installation
|
|
|
|
* Copy a new users identities and contacts from a nearby Squirrelmail installation
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @version 1.5
|
|
|
|
* @version 1.6
|
|
|
|
* @author Thomas Bruederli, Johannes Hessellund, pommi, Thomas Lueder
|
|
|
|
* @author Thomas Bruederli, Johannes Hessellund, pommi, Thomas Lueder
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
class squirrelmail_usercopy extends rcube_plugin
|
|
|
|
class squirrelmail_usercopy extends rcube_plugin
|
|
|
@ -173,31 +173,21 @@ class squirrelmail_usercopy extends rcube_plugin
|
|
|
|
$this->prefs = array();
|
|
|
|
$this->prefs = array();
|
|
|
|
foreach (file($prefsfile) as $line) {
|
|
|
|
foreach (file($prefsfile) as $line) {
|
|
|
|
list($key, $value) = explode('=', $line);
|
|
|
|
list($key, $value) = explode('=', $line);
|
|
|
|
if (empty($file_charset)) {
|
|
|
|
$this->prefs[$key] = $this->convert_charset(rtrim($value), $file_charset);
|
|
|
|
$this->prefs[$key] = utf8_encode(rtrim($value));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$this->prefs[$key] = rcube_charset::convert(rtrim($value), $file_charset, "UTF-8");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// also read signature file if exists
|
|
|
|
// also read signature file if exists
|
|
|
|
if (is_readable($sigfile)) {
|
|
|
|
if (is_readable($sigfile)) {
|
|
|
|
if (empty($file_charset)) {
|
|
|
|
$sig = file_get_contents($sigfile);
|
|
|
|
$this->prefs['___signature___'] = utf8_encode(file_get_contents($sigfile));
|
|
|
|
$this->prefs['___signature___'] = $this->convert_charset($sig, $file_charset);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$this->prefs['___signature___'] = rcube_charset::convert(file_get_contents($sigfile), $file_charset, "UTF-8");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (isset($this->prefs['identities']) && $this->prefs['identities'] > 1) {
|
|
|
|
if (isset($this->prefs['identities']) && $this->prefs['identities'] > 1) {
|
|
|
|
for ($i=1; $i < $this->prefs['identities']; $i++) {
|
|
|
|
for ($i=1; $i < $this->prefs['identities']; $i++) {
|
|
|
|
// read signature file if exists
|
|
|
|
// read signature file if exists
|
|
|
|
if (is_readable($sigbase.$i)) {
|
|
|
|
if (is_readable($sigbase.$i)) {
|
|
|
|
if (empty($file_charset)) {
|
|
|
|
$sig = file_get_contents($sigbase.$i);
|
|
|
|
$this->prefs['___sig'.$i.'___'] = utf8_encode(file_get_contents($sigbase.$i));
|
|
|
|
$this->prefs['___sig'.$i.'___'] = $this->convert_charset($sig, $file_charset);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
$this->prefs['___sig'.$i.'___'] = rcube_charset::convert(file_get_contents($sigbase.$i), $file_charset, "UTF-8");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -205,11 +195,8 @@ class squirrelmail_usercopy extends rcube_plugin
|
|
|
|
// parse addres book file
|
|
|
|
// parse addres book file
|
|
|
|
if (filesize($abookfile)) {
|
|
|
|
if (filesize($abookfile)) {
|
|
|
|
foreach(file($abookfile) as $line) {
|
|
|
|
foreach(file($abookfile) as $line) {
|
|
|
|
if (empty($file_charset)) {
|
|
|
|
$line = $this->convert_charset(rtrim($line), $file_charset);
|
|
|
|
list($rec['name'], $rec['firstname'], $rec['surname'], $rec['email']) = explode('|', utf8_encode(rtrim($line)));
|
|
|
|
list($rec['name'], $rec['firstname'], $rec['surname'], $rec['email']) = explode('|', $line);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
list($rec['name'], $rec['firstname'], $rec['surname'], $rec['email']) = explode('|', rcube_charset::convert(rtrim($line), $file_charset, "UTF-8"));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($rec['name'] && $rec['email']) {
|
|
|
|
if ($rec['name'] && $rec['email']) {
|
|
|
|
$this->abook[] = $rec;
|
|
|
|
$this->abook[] = $rec;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -261,4 +248,13 @@ class squirrelmail_usercopy extends rcube_plugin
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} // end if 'sql'-driver
|
|
|
|
} // end if 'sql'-driver
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private function convert_charset($str, $charset = null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (!$charset) {
|
|
|
|
|
|
|
|
return utf8_encode($sig);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return rcube_charset::convert($str, $charset, RCMAIL_CHARSET);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|