[imp] Redirecting to logout on maintenance task?

Josh Trutwin josh at trutwins.homeip.net
Fri Apr 22 13:19:23 PDT 2005


Hi,

I am working on this squirrelmail maintenance task and I'm able to
display a message to the user on first login about importing their
addresses, unfortunately whenever they choose perform maintenance or
skip it they get redirected to the login page (with login_reason set
to logout).

Here's the main part of the code (sorry for the line wrap):

    function doMaintenance()
    {        
        // this never gets logged!
        Horde::logMessage($_SERVER['REMOTE_ADDR'] . ' doMaintenance
here: ', __FILE__, __LINE__, PEAR_LOG_NOTICE);

        $result = Util::getFormData('sm_import_confirm');

        Horde::logMessage($_SERVER['REMOTE_ADDR'] . ' doMaintenance
form result: ' . $result, __FILE__, __LINE__, PEAR_LOG_NOTICE);

        exit;
    }

    /**
     * Asks to confirm SquirrelMail import on the maintenance page.
     *
     * @access public
     *
     * @return string  Message about import.
     */
    function describeMaintenance()
    {
        global $conf;

        if ((empty($conf['sm_import']['sm_host'])) ||
(empty($conf['sm_import']['sm_username'])) ||
(empty($conf['sm_import']['sm_password'])) ||
(empty($conf['sm_import']['sm_database']))) {
            Horde::fatal(PEAR::raiseError(sprintf(_("SquirrelMail
database settings not specified in conf.php"))), __FILE__, __LINE__);
        }
        
        /* Connect to database. */
        $this->_connect();
        
        /* Build the SQL query. */
        $query = 'SELECT COUNT(*) AS count FROM ' .
$conf['sm_import']['sm_address_table'] . ' WHERE owner = ?';
        $values = array(Auth::getAuth());

        /* Log the query at a DEBUG log level. */
       
Horde::logMessage(sprintf('Maintenance_Task_sm_import::describeMainte
nance(): %s', $query),
                          __FILE__, __LINE__, PEAR_LOG_NOTICE);

        /* Execute the query. */
        $result = $this->_db->query($query, $values);
        if (is_a($result, 'PEAR_Error')) {
            Horde::logMessage($result, __FILE__, __LINE__,
PEAR_LOG_ERR);
            return $result;
        }

        $count = 0;
        if (($row = $result->fetchRow(DB_FETCHMODE_ASSOC)) &&
!is_a($row, 'PEAR_Error')) {
           $count = $row['count'];
        }
        
        if ($count == 2) {
           return ("You do not have any address book entries in the
old SquirrelMail system, you can skip this import task.");
        }
        else {
           return ("Import SquirrelMail Addressbook ($count
entries).");
        }
    }

I'm finding that doMaintenance is not even called as my log messages
do not show up in the log.

This oddball does show up in the log though.

Apr 22 15:04:03 HORDE3 [notice] [imp] 64.83.223.150 failed [on line 31
of "/usr/local/sites/www.netbits.us/web/horde3/imp/login.php"]

I noticed that the form tag on the screen describing the maintenance
task has the following attributes:

<form method="post"
action="/horde3/imp/redirect.php?actionID=login&amp;autologin=1&amp;s
erver_key=imap&amp;maintenance_done=1" name="maint_confirm">

Should maintenance_done be set to 1 on this screen?

Here is a screen print of the maintenance task description form:

http://www.netbits.us/maint1.png

Here is a screen after pressing "Perform Maintenance" - not the funky
stuff after the username field:

http://www.netbits.us/maint2.png

Any thoughts?  Let me know if additional info is needed.

Josh


More information about the imp mailing list