Hmailserver_vacation plugin issues

Use this forum if you have installed hMailServer and want to ask a question related to a production release of hMailServer. Before posting, please read the troubleshooting guide. A large part of all reported issues are already described in detail here.
Post Reply
entropicsinkhole
Normal user
Normal user
Posts: 119
Joined: 2007-05-28 21:10

Hmailserver_vacation plugin issues

Post by entropicsinkhole » 2009-11-09 22:02

Hmailserver v 5.3 build 1617
Squirrelmail v v 1.4.20-RC2
hmailserver_vacation plugin v. 2.0
Xampp 1.7.2 (with php 5.3)

When I try to activate the hmailserver vacation plugin in squirrelmail (with or without the expiry date included) by clicking 'submit', it redirects me instead to an error page: "This page request could not be verified and appears to have expired" and then you have to re-login. The vacation message and expiry date still get sent to hmailserver (I double-checked on the server itself). Anyway, I turned on the error reporting in the plugin's config.php file:

ini_set('error_reporting', E_ALL);

So this is the message I get now:

Function eregi_replace() is deprecated in D:\xampp\htdocs\mail\plugins\hmailserver_vacation\options.php on line 133

It is probably php 5.3 that is the problem (since I newly updated xampp), but I'm wondering if anyone else found a way to fix this?

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Re: Hmailserver_vacation plugin issues

Post by martin » 2009-11-09 22:05

So you're saying that the changes is properly saved, but you get the error page?
What URL is shown in the frame where the error page is shown?

Please note that the plug-ins are no longer included in the hMailServer installation package. They aren't actively maintained any more.

entropicsinkhole
Normal user
Normal user
Posts: 119
Joined: 2007-05-28 21:10

Re: Hmailserver_vacation plugin issues

Post by entropicsinkhole » 2009-11-09 22:30

So you're saying that the changes is properly saved, but you get the error page?
Yep. And then I have to log back in by clicking the 'Go back to login page' link.
What URL is shown in the frame where the error page is shown?
http://mymailserver:port/mail/src/webmail.php
Please note that the plug-ins are no longer included in the hMailServer installation package. They aren't actively maintained any more.
That's too bad--it's one of my favorite SM plugins and worked great before my xampp/php update, but I know you're probably crazy-busy with everything else! I appreciate all the help you've been, now and in the past :)

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Re: Hmailserver_vacation plugin issues

Post by martin » 2009-11-10 18:44

In options.php, could you try to replace:

Code: Select all

header('Location: ' . $location);
with

Code: Select all

echo "hello";
and then try to submit changes again. Check if "Hello" is displayed on the screen.

User avatar
dzekas
Senior user
Senior user
Posts: 2486
Joined: 2005-10-13 21:28
Location: Lithuania

Re: Hmailserver_vacation plugin issues

Post by dzekas » 2009-11-10 19:00

entropicsinkhole wrote:Hmailserver v 5.3 build 1617
Squirrelmail v v 1.4.20-RC2
hmailserver_vacation plugin v. 2.0
Xampp 1.7.2 (with php 5.3)

When I try to activate the hmailserver vacation plugin in squirrelmail (with or without the expiry date included) by clicking 'submit', it redirects me instead to an error page: "This page request could not be verified and appears to have expired" and then you have to re-login. The vacation message and expiry date still get sent to hmailserver (I double-checked on the server itself). Anyway, I turned on the error reporting in the plugin's config.php file:

ini_set('error_reporting', E_ALL);

So this is the message I get now:

Function eregi_replace() is deprecated in D:\xampp\htdocs\mail\plugins\hmailserver_vacation\options.php on line 133

It is probably php 5.3 that is the problem (since I newly updated xampp), but I'm wondering if anyone else found a way to fix this?
ereg error is irrelevant. Reduce your error_reporting to 6143 and you should not see it.

You use SquirrelMail 1.4.20. This SquirrelMail version added security checks to all forms. When hMailServer vacation plugin redirects to options page, it does not set required form tokens. That's what triggers "This page request could not be verified and appears to have expired" error.

entropicsinkhole
Normal user
Normal user
Posts: 119
Joined: 2007-05-28 21:10

Re: Hmailserver_vacation plugin issues

Post by entropicsinkhole » 2009-11-10 19:32

martin wrote:In options.php, could you try to replace:

header('Location: ' . $location);
with
echo "hello";

and then try to submit changes again. Check if "Hello" is displayed on the screen.
That worked! Now I can just put an appropriate message in there, so people don't call me all the time :) Thanks so much Martin!!!
dzekas wrote: ereg error is irrelevant.
Yep, I figured that one out after I replaced (in options.php) eregi_replace('<br[[:space:]]*/?[[:space:]]*>', "\n", $messageText); with preg_replace('#<br\s*/?\s*>#', "\n", $messageText);

That got rid of the error too, but didn't solve the rest of the problem (which Martin just kindly helped me with)
dzekas wrote:This SquirrelMail version added security checks to all forms. When hMailServer vacation plugin redirects to options page, it does not set required form tokens. That's what triggers "This page request could not be verified and appears to have expired" error.
Good to know the cause. Thanks!

chaudhary.umesh
New user
New user
Posts: 20
Joined: 2007-06-07 08:03
Location: Mumbai

Re: Hmailserver_vacation plugin issues

Post by chaudhary.umesh » 2010-01-01 15:42

Hi,
I tried all the way you told but still i am getting the error
This page request could not be verified and appears to have expired.
Please let me know how can i resolve this issue.

User avatar
dzekas
Senior user
Senior user
Posts: 2486
Joined: 2005-10-13 21:28
Location: Lithuania

Re: Hmailserver_vacation plugin issues

Post by dzekas » 2010-01-01 16:53

chaudhary.umesh wrote:Hi,
I tried all the way you told but still i am getting the error
This page request could not be verified and appears to have expired.
Please let me know how can i resolve this issue.
downgrade to SquirrelMail 1.4.19 or update plugin to add security tokens.

chaudhary.umesh
New user
New user
Posts: 20
Joined: 2007-06-07 08:03
Location: Mumbai

Re: Hmailserver_vacation plugin issues

Post by chaudhary.umesh » 2010-01-02 05:59

Hi,
Could you please explain how can i update plugin to add security tokens.

User avatar
dzekas
Senior user
Senior user
Posts: 2486
Joined: 2005-10-13 21:28
Location: Lithuania

Re: Hmailserver_vacation plugin issues

Post by dzekas » 2010-01-02 11:06

chaudhary.umesh wrote:Hi,
Could you please explain how can i update plugin to add security tokens.
Sorry. I can't.

I can answer questions about SquirrelMail, but I have one condition. I don't work with SquirrelMail code, don't write patches and don't fix SquirrelMail plugins. Ever.

entropicsinkhole
Normal user
Normal user
Posts: 119
Joined: 2007-05-28 21:10

Re: Hmailserver_vacation plugin issues

Post by entropicsinkhole » 2010-01-08 16:58

chaudhary.umesh:

I'm not sure whether it helps at all, but here is my working plugins\hmailserver_vacation\options.php file, exactly word for word:



<?php
/*
* Change hMailServer Vacation message plugin 1.1
*
*/

/******************************************************************************************************************
* *
* Copyright (C) [2007] Author: Martin Knafve *
* modified for using with calendar.php by: Dr. Mario Roediger ( MRXS Infotainment GmbH (MRXS) ) *
* *
******************************************************************************************************************
* *
* This program is free software; you can redistribute it and/or modify it under the terms of the GNU General *
* Public License as published by the Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the *
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
* for more details. *
* *
* You should have received a copy of the GNU General Public License along with this program; if not, write to *
* the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA *
* *
*****************************************************************************************************************/

if (!defined('SM_PATH')) define('SM_PATH','../../');

include_once (SM_PATH . 'include/validate.php');
include_once (SM_PATH . 'functions/display_messages.php');

global $color;

include('./config.php');

sqgetGlobalVar('username',$username,SQ_SESSION);

if (strpos($username, '@') == FALSE)
{
// The user name is not a full email address.
// Append default domain to it.
global $default_domain;
$username .= "@" . $default_domain;
}

// if a message and other info was submitted, process it here
//
sqgetGlobalVar('vacationMessageSubmit', $vacationMessageSubmit, SQ_POST);

if (isset($vacationMessageSubmit) && $vacationMessageSubmit == 1)
{
// Save the changes...
sqgetGlobalVar('messageText', $messageText, SQ_POST);
sqgetGlobalVar('messageSubject', $messageSubject, SQ_POST);
sqgetGlobalVar('vacationStatus', $vacationStatus, SQ_POST);
sqgetGlobalVar('messageExpires', $messageExpires, SQ_POST);
sqgetGlobalVar('messageExpiresDate_timestamp', $messageExpiresDate, SQ_POST);

if ($vacationStatus == "") $vacationStatus = "0";
if ($messageExpires == "") $messageExpires = "0";

$obAccount = GetAccountObject($username);

$obAccount->VacationMessage = $messageText;
$obAccount->VacationSubject = $messageSubject;
$obAccount->VacationMessageIsOn = (isset($vacationStatus) && $vacationStatus == "1");

$obAccount->VacationMessageExpires = $messageExpires;
$obAccount->VacationMessageExpiresDate = date("Y-m-d", $messageExpiresDate);

$obAccount->Save();

$location = '../../src/options.php?optmode=submit&optpage=hmailserver_vacation';

//header('Location: ' . $location); // This was the original header, but with Squirrelmail v.1.4.20 it doesn't work anymore

echo '<br><br><br><br><br><br><center><font color="' . $color[2] . '"><b>'
. "You have successfully submitted your vacation message. Click 'Inbox' on the left-side pane to return to your mailbox"
. '</b></font></center></body></html>';
exit(0);
}

// pull previous settings from the account object
//
$obAccount = GetAccountObject($username);
$messageText = $obAccount->VacationMessage();
$messageSubject = $obAccount->VacationSubject();
$vacationStatus = $obAccount->VacationMessageIsOn();

$messageExpires = $obAccount->VacationMessageExpires;
$messageExpiresDate = $obAccount->VacationMessageExpiresDate;

bindtextdomain('squirrelmail', SM_PATH . 'locale');
textdomain('squirrelmail');

displayPageHeader($color, 'None', 'document.forms[0].elements["messageText"].focus();');

bindtextdomain('hmailserver_vacation', SM_PATH . 'plugins/hmailserver_vacation/locale');
textdomain('hmailserver_vacation');

echo '<br>';
echo '<form method="POST"><input type="hidden" name="vacationMessageSubmit" value="1">'
. '<table width=95% align=center cellpadding=2 cellspacing=2 border=0>'
. '<tr><td bgcolor="' . $color[0] . '">'
. '<center><b>'
. _("Vacation / Autoresponder");
?>
</b></center>
</td>
</tr>
<tr>
<td align="center">
<table width="70%" cellspacing="2" cellpadding="0" border="0">
<tr>
<td valign="top" width="20%">
<br>
<input type="checkbox" name="vacationStatus" value="1" <?php if ($vacationStatus == 'on') echo ' CHECKED' ?>>
</td>
<td>
<br>
<b><?php echo _("Activate vacation autoresponder") ?></b>
</td>
</tr>
<tr>
<td colspan="2">
<br>
<b><?php echo _("Message subject") . '</b> ' . _("(leave blank to use standard \"RE:\" syntax)"); ?>:
<br>
<input type="text" name="messageSubject" size="87" value="<?php echo $messageSubject; ?>">
</td>
</tr>
<tr>
<td colspan="2">
<br>
<b><?php echo _("Message text"); ?></b>:
<br>
<textarea name="messageText" rows="5" cols="75" wrap="off"><?php echo preg_replace('#<br\s*/?\s*>#', "\n", $messageText); ?></textarea>
</td>
</tr>
<tr>
<td valign="top">
<br>
<input type="checkbox" name="messageExpires" value="1" <?php if ($messageExpires == '1') echo ' CHECKED' ?>>
</td>
<td>
<br>
<b><?php echo _("vacation autoresponder expires") ?></b>
</td>
</tr>
<tr>
<td valign="top" nowrap>
<br>
<?php
$type_of_datefield = ( !isset($type_of_datefield) || empty($type_of_datefield) || $type_of_datefield=='auto' )? 'selectbox' : $type_of_datefield;
$type_of_datefield = ( $type_of_datefield != 'selectbox' && $type_of_datefield != 'text' )? 'selectbox' : $type_of_datefield;
if ( $type_of_datefield == 'selectbox' )
{
$day_target='messageExpiresDate_day';
$month_target='messageExpiresDate_month';
$year_target='messageExpiresDate_year';
$date_target='';
$create_selectset = true;
$create_datefield = false;
} else {
$date_target='messageExpiresDate_date';
$day_target = $month_target = $year_target = '';
$create_selectset = false;
$create_datefield = true;
}
$timestamp_target = 'messageExpiresDate_timestamp';
$create_timestampfield = 'hidden';
$time_db = ( strpos($messageExpiresDate, '0000') === false && strpos($messageExpiresDate, '-00') === false )? strtotime($messageExpiresDate) : time();
$set_day = date("d", $time_db);
$set_month = date("m", $time_db);
$set_year = date("Y", $time_db);
require_once('functions.php');
echo show_CalendarPopup($instance='1', $calendar_width, $calendar_height, $day_target, $month_target, $year_target, $date_target, $timestamp_target, $create_selectset, $create_datefield, $create_timestampfield, $size_factor=1, $set_day, $set_month, $set_year );
?>
</td>
<td>
<br>
<b><?php echo _("vacation autoresponder expiresdate") ?></b>
</td>
</tr>
<tr>
<td align="center" colspan="2">
<br>
<input type="submit" value="<?php echo _("Submit"); ?>" style="width:99%">
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
</html>

<?php

exit(0);



// displays simple error output page
//
function showError($message)
{

global $color;
displayPageHeader($color, 'None');
echo '<br><br><center><font color="' . $color[2] . '"><b>'
. $message
. '</b></font></center></body></html>';

}

function GetAccountObject($username)
{
global $imapServerAddress;

bindtextdomain('hmailserver_vacation', SM_PATH . 'plugins/hmailserver_vacation/locale');
textdomain('hmailserver_vacation');

$hmailserver_addr = (!empty($imapServerAddress))? $imapServerAddress : 'localhost';

// Extract domain part from email address
$iAtPos = strpos($username, '@');

$DomainName = substr($username, $iAtPos + 1);

/**
* FIXME: handle COM permission issues.
* Fatal error: Uncaught exception 'com_exception' with message 'Failed
* to create COM object `hMailServer.Application': Access is denied. '
*/
$hCOMApp = new COM("hMailServer.Application", $hmailserver_addr);

global $admin_password;
if (strlen($admin_password) > 0)
$hCOMApp->Authenticate("Administrator", $admin_password);

$obDomain = $hCOMApp->Domains->ItemByName($DomainName);

if (!isset($obDomain))
{
echo _("Operation failed - Can not access the domain object.");
die;
}

$obAccount = $obDomain->Accounts->ItemByAddress($username);

if (!isset($obAccount))
{
echo _("Operation failed - Can not access the account object.");
die;
}

return $obAccount;

}
?>

sbouli
Normal user
Normal user
Posts: 69
Joined: 2007-11-27 12:37

Re: Hmailserver_vacation plugin issues

Post by sbouli » 2010-01-26 18:34

martin wrote:Please note that the plug-ins are no longer included in the hMailServer installation package. They aren't actively maintained any more.

Hi, can you please update the Functionnality page then ?
If you choose to use SquirrelMail under Windows, you can let your users change their own passwords and out-of-office messages using a hMailServer plug-in for SquirrelMail.

Thanks

Stéphane

User avatar
martin
Developer
Developer
Posts: 6834
Joined: 2003-11-21 01:09
Location: Sweden
Contact:

Re: Hmailserver_vacation plugin issues

Post by martin » 2010-01-26 23:44

Done

Post Reply