steffen: server/kolab-horde-fbview/kolab-horde-fbview/fbview/services cacheview.php, NONE, 1.1 css.php, NONE, 1.1 go.php, NONE, 1.1 javascript.php, NONE, 1.1 keyboard.php, NONE, 1.1 language.php, NONE, 1.1 maintenance.php, NONE, 1.1 prefs.php, NONE, 1.1 problem.php, NONE, 1.1 resetpassword.php, NONE, 1.1

cvs at intevation.de cvs at intevation.de
Mon Oct 31 12:43:34 CET 2005


Author: steffen

Update of /kolabrepository/server/kolab-horde-fbview/kolab-horde-fbview/fbview/services
In directory doto:/tmp/cvs-serv18388/kolab-horde-fbview/kolab-horde-fbview/fbview/services

Added Files:
	cacheview.php css.php go.php javascript.php keyboard.php 
	language.php maintenance.php prefs.php problem.php 
	resetpassword.php 
Log Message:
Fbview in separate package

--- NEW FILE: cacheview.php ---
<?php
/**
 * $Horde: horde/services/cacheview.php,v 1.8 2004/04/07 14:43:45 chuck Exp $
 *
 * Copyright 2002-2004 Chuck Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

@define('HORDE_BASE', dirname(__FILE__) . '/..');
require_once HORDE_BASE . '/lib/base.php';
require_once 'Horde/Cache.php';

$cid = Util::getFormData('cid');
if (empty($cid)) {
    _cacheError();
}

$cache = &Horde_Cache::singleton($conf['cache']['driver'], Horde::getDriverConfig('cache', $conf['cache']['driver']));
$cdata = unserialize($cache->getData($cid, "_cacheError('$cid')", $conf['cache']['default_lifetime']));

$browser->downloadHeaders('cacheObject', $cdata['ctype'], true, strlen($cdata['data']));
echo $cdata['data'];

/**
 * Output an error if no CID was specified or the data wasn't in the
 * cache.
 */
function _cacheError($cid = null)
{
    if (!is_null($cid)) {
        Horde::logMessage('CID ' . $cid . ' not found in the cache, unable to display.', __FILE__, __LINE__, PEAR_LOG_ERR);
    }
    exit;
}

--- NEW FILE: css.php ---
<?php
/**
 * $Horde: horde/services/css.php,v 1.45 2004/02/14 04:02:20 chuck Exp $
 *
 * Copyright 2000-2004 Charles J. Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

@define('HORDE_BASE', dirname(__FILE__) . '/..');
require_once HORDE_BASE . '/lib/core.php';

$registry = &Registry::singleton(HORDE_SESSION_NONE);

// Figure out if we've been inlined, or called directly.
$send_headers = strstr($_SERVER['PHP_SELF'], 'css.php');

// Set initial $mtime of this script.
$mtime = getlastmod();

if (@file_exists(HORDE_BASE . '/config/conf.php')) {
    require HORDE_BASE . '/config/conf.php';
} else {
    $conf['css']['cached'] = false;
}

$theme = Util::getFormData('theme');
if (Util::getFormData('inherit') !== 'no') {
    if (@file_exists(HORDE_BASE . '/config/html.php')) {
        $file = HORDE_BASE . '/config/html.php';
    } else {
        $file = HORDE_BASE . '/config/html.php.dist';
    }
    if ($conf['css']['cached']) {
        $hmtime = filemtime($file);
        if ($hmtime > $mtime) {
            $mtime = $hmtime;
        }
    }
    require $file;
    if (!empty($theme) && @file_exists(HORDE_BASE . '/config/themes/html-' . $theme . '.php')) {
        $file = HORDE_BASE . '/config/themes/html-' . $theme . '.php';
        if ($conf['css']['cached']) {
            $hmtime = filemtime($file);
            if ($hmtime > $mtime) {
                $mtime = $hmtime;
            }
        }
        require $file;
    }
}

$apps = Util::getFormData('app');
if (!empty($apps)) {
    if (!is_array($apps)) {
        $apps = array($apps);
    }
    foreach ($apps as $app) {
        $conf_file = $registry->applicationFilePath('%application%/config/conf.php', $app);
        if (@file_exists($conf_file)) {
            require $conf_file;
        }

        $file = '';
        if (@file_exists($registry->applicationFilePath('%application%/config/html.php', $app))) {
            $file = $registry->applicationFilePath('%application%/config/html.php', $app);
        } elseif (@file_exists($registry->applicationFilePath('%application%/config/html.php.dist', $app))) {
            $file = $registry->applicationFilePath('%application%/config/html.php.dist', $app);
        }
        if (!empty($file)) {
            if ($conf['css']['cached']) {
                $amtime = filemtime($file);
                if ($amtime > $mtime) {
                    $mtime = $amtime;
                }
            }
            require $file;
        }
        if (!empty($theme) && @file_exists($registry->applicationFilePath('%application%/config/themes/html-' . $theme . '.php', $app))) {
            $file = $registry->applicationFilePath('%application%/config/themes/html-' . $theme . '.php', $app);
            if ($conf['css']['cached']) {
                $amtime = filemtime($file);
                if ($amtime > $mtime) {
                    $mtime = $amtime;
                }
            }
            require $file;
        }
    }
}

if ($send_headers) {
    /* Compress the CSS. We need this explicit call since we don't call
     * base.php in this file. */
    Horde::compressOutput();

    if ($conf['css']['cached']) {
        $mod_gmt = gmdate('D, d M Y H:i:s', $mtime) . ' GMT';
        header('Last-Modified: ' . $mod_gmt);
        header('Cache-Control: public, max-age=86400');
    } else {
        header('Expires: -1');
        header('Pragma: no-cache');
        header('Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0');
    }
    header('Content-Type: text/css; charset=iso-8859-1');
}

if (is_array($css)) {
    foreach ($css as $class => $params) {
        echo "$class {\n";
        if (is_array($params)) {
            foreach ($params as $key => $val) {
                if (is_array($val)) {
                    echo "$key {\n";
                    foreach ($val as $skey => $sval) {
                        echo "    $skey: $sval;\n";
                    }
                    echo "}\n";
                } else {
                    echo "    $key: $val;\n";
                }
            }
        }
        echo "}\n";
    }
}

--- NEW FILE: go.php ---
<?php
/**
 * A script to redirect to a given URL, used for example in IMP to hide any
 * referrer data being passed to the remote server and potentially exposing any
 * session IDs.
 *
 * Copyright 2003-2004 Marko Djukic <marko at oblo.com>
 *
 * See the enclosed file COPYING for license information (GPL). If you did not
 * receive this file, see http://www.fsf.org/copyleft/gpl.html.
 *
 * $Horde: horde/services/go.php,v 1.3 2004/01/01 15:16:59 jan Exp $
 *
 * @author Marko Djukic <marko at oblo.com>
 * @version $Revision: 1.1 $
 */

header('Refresh: 0; URL=' . $_GET['url']);

--- NEW FILE: javascript.php ---
<?php
/**
 * $Horde: horde/services/javascript.php,v 1.34 2004/03/03 08:38:18 jan Exp $
 *
 * Copyright 2000-2004 Charles J. Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

@define('HORDE_BASE', dirname(__FILE__) . '/..');
require_once HORDE_BASE . '/lib/core.php';

$registry = &Registry::singleton(HORDE_SESSION_READONLY);

// Figure out if we've been inlined, or called directly.
$send_headers = strstr($_SERVER['PHP_SELF'], 'javascript.php');

$app = Util::getFormData('app');
$file = Util::getFormData('file');
if (!empty($app) && !empty($file) && strpos($file, '..') === false) {
    $script_file = $registry->getParam('templates', $app) . '/javascript/' . $file;
    if (@file_exists($script_file)) {
        $registry->pushApp($app);
        $script = Util::bufferOutput('require', $script_file);

        if ($send_headers) {
            /* Compress the JS. We need this explicit call since we
             * don't include base.php in this file. */
            Horde::compressOutput();

            $mod_gmt = gmdate('D, d M Y H:i:s', filemtime($script_file)) . ' GMT';
            header('Last-Modified: ' . $mod_gmt);
            header('Cache-Control: public, max-age=86400');
            header('Content-Type: text/javascript');
        }

        echo $script;
    }
}

--- NEW FILE: keyboard.php ---
<?php
/*
 * $Horde: horde/services/keyboard.php,v 1.12 2004/01/01 15:17:00 jan Exp $
 *
 * Copyright 2001-2004 Chuck Hagenbuch <chuck at horde.org>
 *
 * See the enclosed file COPYING for license information (LGPL).  If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

define('HORDE_BASE', dirname(__FILE__) . '/..');
require_once HORDE_BASE . '/lib/base.php';

$title = _("Special Character Input");
require HORDE_TEMPLATES . '/common-header.inc';

?>

<script language="Javascript" type="text/javascript">

var target;

function handleListChange(theList) {
    var numSelected = theList.selectedIndex;
    
    if (numSelected != 0) {
        document.characters.textbox.value += theList.options[numSelected].value;
        theList.selectedIndex = 0;
    }
}
</script>

<form name="characters">
<table border="0" cellspacing="0" cellpadding="2">
  <tr>
    <td align="left">
      <p class="smallheader"><?php echo _("Select the characters you need from the boxes below. You can then copy and paste them from the text area.") ?></p>
    </td>
  </tr>
  <tr>
    <td align="left">
      <table border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td align="center">
            <select name="a" onchange="handleListChange(this)">
              <option value="a" selected> a </option>
              <option value="À"> À </option>
              <option value="à"> à </option>
              <option value="Á"> Á </option>
              <option value="á"> á </option>
              <option value="Â"> Â </option>
              <option value="â"> â </option>
              <option value="Ã"> Ã </option>
              <option value="ã"> ã </option>
              <option value="Ä"> Ä </option>
              <option value="ä"> ä </option>
              <option value="Å"> Å </option>
              <option value="å"> å </option>
            </select>
          </td>
          <td align="center"> 
            <select name="e" onchange="handleListChange(this)">
              <option value="e" selected> e </option>
              <option value="È"> È </option>
              <option value="è"> è </option>
              <option value="É"> É </option>
              <option value="é"> é </option>
              <option value="Ê"> Ê </option>
              <option value="ê"> ê </option>
              <option value="Ë"> Ë </option>
              <option value="ë"> ë </option>
            </select>
          </td>
          <td align="center"> 
            <select name="i" onchange="handleListChange(this)">
              <option value="i" selected> i </option>
              <option value="Ì"> Ì </option>
              <option value="ì"> ì </option>
              <option value="Í"> Í </option>
              <option value="í"> í </option>
              <option value="Î"> Î </option>
              <option value="î"> î </option>
              <option value="Ï"> Ï </option>
              <option value="ï"> Ï </option>
            </select>
          </td>
          <td align="center"> 
            <select name="o" onchange="handleListChange(this)">
              <option value="o" selected> o </option>
              <option value="Ò"> Ò </option>
              <option value="ò"> ò </option>
              <option value="Ó"> Ó </option>
              <option value="ó"> ó </option>
              <option value="Ô"> Ô </option>
              <option value="ô"> ô </option>
              <option value="Õ"> Õ </option>
              <option value="õ"> õ </option>
              <option value="Ö"> Ö </option>
              <option value="ö"> ö </option>
            </select>
          </td>
          <td align="center"> 
            <select name="u" onchange="handleListChange(this)">
              <option value="u" selected> u </option>
              <option value="Ù"> Ù </option>
              <option value="ù"> ù </option>
              <option value="Ú"> Ú </option>
              <option value="ú"> ú </option>
              <option value="Û"> Û </option>
              <option value="û"> û </option>
              <option value="Ü"> Ü </option>
              <option value="ü"> ü </option>
            </select>
          </td>
          <td align="center"> 
            <select name="Other" onchange="handleListChange(this)">
              <option value="misc" selected> <?php echo _("Other"); ?></option>
              <option value="¢"> ¢ </option>
              <option value="£"> £ </option>
              <option value="¤"> ¤ </option>
              <option value="¥"> ¥ </option>
              <option value="Æ"> Æ </option>
              <option value="æ"> æ </option>
              <option value="ß"> ß </option>
              <option value="Ç"> Ç </option>
              <option value="ç"> ç </option>
              <option value="Ñ"> Ñ </option>
              <option value="ñ"> ñ </option>
              <option value="ý"> ý </option>
              <option value="ÿ"> ÿ </option>
              <option value="¿"> ¿ </option>
              <option value="¡"> ¡ </option>
            </select>
          </td>
        </tr>
      </table>
    </td>
  </tr>
  <tr>
    <td align="left" class="fixed">
      <textarea rows="4" cols="25" class="fixed" name="textbox"></textarea>
    </td>
  </tr>
  <tr>
    <td align="center">
      <input type="button" class="button" onclick="window.close();" name="close" value="<?php echo _("Close Window") ?>" />
    </td>
  </tr>
</table>
</form>
</body>
</html>

--- NEW FILE: language.php ---
<?php
/**
 * Script to set the new language.
 *
 * $Horde: horde/services/language.php,v 1.5 2004/01/01 15:17:00 jan Exp $
 *
 * Copyright 2003-2004 Marko Djukic <marko at oblo.com>
 *
 * See the enclosed file COPYING for license information (LGPL). If you did not
 * receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

@define('HORDE_BASE', dirname(__FILE__) . '/..');
require_once HORDE_BASE . '/lib/base.php';
 
/* Set the language. */
$_SESSION['horde_language'] = NLS::select();
$prefs->setValue('language', $_SESSION['horde_language']);

/* Redirect to the url or login page if none given. */
$url = Util::getFormData('url');
if (empty($url)) {
    $url = Horde::applicationUrl('index.php', true);
}
header('Location: ' . $url);

--- NEW FILE: maintenance.php ---
<?php
/**
 * $Horde: horde/services/maintenance.php,v 1.28 2004/04/07 14:43:45 chuck Exp $
 *
 * Copyright 2001-2004 Michael Slusarz <slusarz at bigworm.colorado.edu>
 * Copyright 2001-2004 Charles J. Hagenbuch <chuck at horde.org>
 * Copyright 2001-2004 Jon Parise <jon at horde.org>
 *
 * See the enclosed file COPYING for license information (LGPL).  If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

include_once '../lib/base.php';
include_once 'Horde/Maintenance.php';

/* Make sure there is a user logged in. */
if (!Auth::getAuth()) {
    $url = Horde::url($registry->getParam('webroot', 'horde') . '/login.php', true);
    $url = Util::addParameter($url, 'url', Horde::selfUrl());
    header('Location: ' . $url);
    exit;
}

/* If no 'module' parameter passed in, return error. */
if (!($module = basename(Util::getFormData('module', '')))) {
    Horde::fatal(PEAR::raiseError(_("Do not directly access maintenance.php")), __FILE__, __LINE__);
}

/* Load the module specific maintenance class now. */
if (!($maint = &Maintenance::factory($module))) {
    Horde::fatal(PEAR::raiseError(_("The Maintenance:: class did not load successfully")), __FILE__, __LINE__);
}

/* Have the maintenance module do all necessary processing. */
list($action, $tasks) = $maint->runMaintenancePage();

/* Print top elements of confirmation page. */
require HORDE_TEMPLATES . '/common-header.inc';
require HORDE_TEMPLATES . '/maintenance/maintenance_top.inc';

if ($action == MAINTENANCE_OUTPUT_CONFIRM) {
    /* Confirmation-style output */
    require HORDE_TEMPLATES . '/maintenance/confirm_top.inc';
    if ($browser->hasFeature('javascript')) {
        include HORDE_TEMPLATES . '/maintenance/javascript.inc';
    }
    /* $pref, $descrip, & $checked need to be set for the templates. */
    foreach ($tasks as $pref) {
        list($descrip, $checked) = $maint->infoMaintenance($pref);
        include HORDE_TEMPLATES . '/maintenance/confirm_middle.inc';
    }
    require HORDE_TEMPLATES . '/maintenance/confirm_bottom.inc';
} elseif ($action == MAINTENANCE_OUTPUT_AGREE) {
    /* Agreement-style output */
    require HORDE_TEMPLATES . '/maintenance/agreement_top.inc';
    /* $pref & $descrip need to be set for the templates. */
    foreach ($tasks as $pref) {
        list($descrip, $checked) = $maint->infoMaintenance($pref);
        include HORDE_TEMPLATES . '/maintenance/agreement_middle.inc';
    }
    require HORDE_TEMPLATES . '/maintenance/agreement_bottom.inc';
} elseif ($action == MAINTENANCE_OUTPUT_NOTICE) {
    /* Notice-style output */
    require HORDE_TEMPLATES . '/maintenance/notice_top.inc';
    /* $pref & $descrip need to be set for the templates. */
    foreach ($tasks as $pref) {
        list($descrip, $checked) = $maint->infoMaintenance($pref);
        include HORDE_TEMPLATES . '/maintenance/notice_middle.inc';
    }
    require HORDE_TEMPLATES . '/maintenance/notice_bottom.inc';
}

/* Print bottom elements of maintenance page. */
require HORDE_TEMPLATES . '/maintenance/maintenance_bottom.inc';
require HORDE_TEMPLATES . '/common-footer.inc';

--- NEW FILE: prefs.php ---
<?php
/**
 * $Horde: horde/services/prefs.php,v 1.12 2004/05/08 21:54:48 jan Exp $
 *
 * Copyright 1999-2004 Charles J. Hagenbuch <chuck at horde.org>
 * Copyright 1999-2004 Jon Parise <jon at horde.org>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

@define('HORDE_BASE', dirname(__FILE__) . '/..');
require_once dirname(__FILE__) . '/../lib/core.php';
require_once 'Horde/Prefs/UI.php';

$registry = &Registry::singleton();

/* Figure out which application we're setting preferences for. */
$app = Util::getFormData('app', Prefs_UI::getDefaultApp());
$appbase = $registry->getParam('fileroot', $app);

/* See if we have a preferences group set. */
$group = Util::getFormData('group');

/* Load $app's base environment. */
require_once $appbase . '/lib/base.php';

if ($group == 'identities') {
    require_once 'Horde/Identity.php';
    $identity = &Identity::singleton($app == 'horde' ? null : array($app, $app));
    if ($app != 'horde') {
        require HORDE_BASE . '/config/prefs.php';
        $horde_members = $prefGroups['identities']['members'];
    }
}

/* Load $app's preferences, if any. */
if (file_exists($appbase . '/config/prefs.php')) {
    require $appbase . '/config/prefs.php';
}

/* Load custom preference handlers for $app, if present. */
if (file_exists($appbase . '/lib/prefs.php')) {
    require_once $appbase . '/lib/prefs.php';
}

if ($group == 'identities') {
    if (isset($horde_members)) {
        $prefGroups['identities']['members'] = array_merge($horde_members, $prefGroups['identities']['members']);
    }
    switch (Util::getFormData('actionID')) {
    case 'update_prefs':
        $default = Util::getFormData('default_identity');
        $id = Util::getFormData('identity');
        if ($id == -1) {
            $id = $identity->add();
        } elseif ($id == -2) {
            $prefGroups['identities']['members'] = array('default_identity');
        }
        $identity->setDefault($id);
        if (Prefs_UI::handleForm($group, $identity)) {
            $identity->setDefault($default);
            $result = $identity->verify();
            if (is_a($result, 'PEAR_Error')) {
                $notification->push($result, 'horde.error');
            } else {
                $identity->save();
            }
        } else {
            $identity->setDefault($default);
            $identity->save();
        }
        unset($prefGroups);
        require $appbase . '/config/prefs.php';
        break;
    case 'delete_identity':
        $deleted_identity = $identity->delete(Util::getFormData('id'));
        $notification->push(sprintf(_("The identity \"%s\" has been deleted."), $deleted_identity[0]['id']), 'horde.success');
        break;
    }
} elseif (Prefs_UI::handleForm($group, $prefs)) {
    require $appbase . '/config/prefs.php';
}

/* Show the UI. */
Prefs_UI::generateUI($group);

require $registry->getParam('templates', 'horde') . '/common-footer.inc';

--- NEW FILE: problem.php ---
<?php
/**
 * $Horde: horde/services/problem.php,v 2.107 2004/04/07 14:43:45 chuck Exp $
 *
 * Copyright 1999-2004 Charles J. Hagenbuch <chuck at horde.org>
 * Copyright 1999-2004 Jon Parise <jon at horde.org>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

/* Send the browser back to the correct page. */
function _returnToPage()
{
    $returnURL = Util::getFormData('return_url', Horde::url($GLOBALS['registry']->getParam('webroot', 'horde') . '/login.php', true));
    header('Location: ' . str_replace('&', '&', $returnURL));
}

@define('AUTH_HANDLER', true);
@define('HORDE_BASE', dirname(__FILE__) . '/..');
require_once HORDE_BASE . '/lib/base.php';
require_once HORDE_BASE . '/lib/version.php';
require_once 'Horde/Identity.php';

if (!($perms->exists('problem') ?
      $perms->hasPermission('problem', Auth::getAuth(), PERMS_READ) :
      Auth::getAuth())) {
    _returnToPage();
}

$identity = &Identity::singleton();
$email = $identity->getValue('from_addr');
if (empty($email)) {
    $email = Util::getFormData('email', '');
}
if (empty($email)) {
    $email = Auth::getAuth();
}
$message = Util::getFormData('message', '');
$name = Util::getFormData('name', $identity->getValue('fullname'));
$subject = Util::getFormData('subject', '');

$actionID = Util::getFormData('actionID');
switch ($actionID) {
case 'send_problem_report':
    require_once 'Horde/Text.php';

    if (!empty($subject) && !empty($message)) {
        require_once 'Horde/MIME.php';
        require_once 'Horde/MIME/Headers.php';
        require_once 'Horde/MIME/Message.php';

        $msg_headers = &new MIME_Headers();
        $msg_headers->addReceivedHeader();
        $msg_headers->addMessageIdHeader();
        $msg_headers->addAgentHeader();
        $msg_headers->addHeader('Date', date('r'));
        $msg_headers->addHeader('To', $conf['problems']['email']);
        $msg_headers->addHeader('Subject', _("[Problem Report]") . ' ' . $subject);

        if (!empty($email)) {
            if (!empty($name)) {
                list($mailbox, $host) = @explode('@', $email);
                if (empty($host)) {
                    $host = $conf['server']['name'];
                }
                $msg_headers->addHeader('From', MIME::rfc822WriteAddress($mailbox, $host, $name));
            } else {
                $msg_headers->addHeader('From', $email);
            }
            $msg_headers->addHeader('Sender', 'horde-problem@' . $conf['server']['name']);
        } else {
            $msg_headers->addHeader('From', 'horde-problem@' . $conf['server']['name']);
        }
        $recipients = $conf['problems']['email'];

        $message = str_replace("\r\n", "\n", $message);

        // This is not a gettext string on purpose.
        $remote = (!empty($_SERVER['REMOTE_HOST'])) ? $_SERVER['REMOTE_HOST'] : $_SERVER['REMOTE_ADDR'];
        $user_agent = $_SERVER['HTTP_USER_AGENT'];
        $message = "This problem report was received from $remote. " .
            "The user clicked the problem report link from the following location:\n" .
            Util::getFormData('return_url', 'No requesting page') .
            "\nand is using the following browser:\n$user_agent\n\n$message";

        $mime = &new MIME_Message();
        $body = &new MIME_Part('text/plain', Text::wrap($message, 80, "\n"));

        $mime->addPart($body);
        $msg_headers->addMIMEHeaders($mime);

        if (!is_a($mime->send($recipients, $msg_headers), 'PEAR_Error')) {
            /* We succeeded. Return to previous page and exit this script. */
            _returnToPage();
            exit;
        } else {
            $label = _("Describe the Problem");
        }
    } else {
        /* Something wasn't quite right. Strange. */
        $label = _("Describe the Problem");
    }
    break;

case 'cancel_problem_report':
    _returnToPage();
    exit;
    break;
}

if (empty($label)) {
    $label = _("Describe the Problem");
}

$title = _("Problem Description");
$menu = $menu->getMenu();
require HORDE_TEMPLATES . '/common-header.inc';
require HORDE_TEMPLATES . '/menu/menu.inc';
require HORDE_TEMPLATES . '/problem/problem.inc';
require HORDE_TEMPLATES . '/common-footer.inc';

--- NEW FILE: resetpassword.php ---
<?php
/**
 * $Horde: horde/services/resetpassword.php,v 1.4 2004/05/25 08:50:29 mdjukic Exp $
 *
 * Copyright 2004 Marko Djukic <marko at oblo.com>
 *
 * See the enclosed file COPYING for license information (LGPL). If you
 * did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
 */

@define('AUTH_HANDLER', true);
@define('HORDE_BASE', dirname(__FILE__) . '/..');
require_once HORDE_BASE . '/lib/base.php';
require_once 'Horde/Form.php';
require_once 'Horde/Variables.php';

// Make sure auth backend allows passwords to be reset.
$auth = &Auth::singleton($conf['auth']['driver']);
if (!$auth->hasCapability('resetpassword')) {
    $notification->push(_("Can not reset password automatically, contact your administrator."), 'horde.error');
    header('Location: ' . Auth::getLoginScreen('', Util::getFormData('url')));
    exit;
}

$vars = &Variables::getDefaultVariables();

$title = _("Reset Your Password");
$form = &Horde_Form::singleton('HordeSignupForm', $vars, $title);
$form->setButtons(_("Continue"));

/* Set up the fields for the username and alternate email. */
$form->addHidden('', 'url', 'text', false);
$v = &$form->addVariable(_("Username"), 'username', 'text', true);
$v->setOption('trackchange', true);
$form->addVariable(_("Alternate email address"), 'email', 'email', true);
$can_validate = false;

/* If a username has been supplied try fetching the prefs stored info. */
if ($username = $vars->get('username')) {
    $prefs = &Prefs::singleton($conf['prefs']['driver'], 'horde', $username, '', null, false);
    $prefs->retrieve();
    $email = $prefs->getValue('alternate_email');
    /* Does the alternate email stored in prefs match the one submitted? */
    if ($vars->get('email') == $email) {
        $can_validate = true;
        $form->setButtons(_("Reset Password"));
        $question = $prefs->getValue('security_question');
        $form->addVariable($question, 'question', 'description', false);
        $form->addVariable(_("Answer"), 'answer', 'text', true);
    } else {
        $notification->push(_("Incorrect username or alternate address. Try again or contact your administrator if you need further help."), 'horde.error');
    }
}

/* Validate the form. */
if ($can_validate && $form->validate($vars)) {
    $form->getInfo($vars, $info);

    /* Fetch values from prefs for selected user. */
    $answer = $prefs->getValue('security_answer');

    /* Check the given values witht the prefs stored ones. */
    require_once 'Horde/String.php';
    if ($email == $info['email'] && String::lower($answer) == String::lower($info['answer'])) {
        /* Info matches, so reset the password. */
        $password = $auth->resetPassword($info['username']);

        require_once 'Mail.php';
        $mailer = &Mail::factory($conf['mailer']['type'], $conf['mailer']['params']);

        /* Set up the email headers and body. */
        $headers['From'] = $email;
        $headers['To'] = $email;
        $recipients[] = $headers['To'];
        $headers['Subject'] = _("Your password has been reset");
        $body = sprintf(_("Your new password for %s is: %s"), $registry->getParam('name', 'horde'), $password);
        $mailer->send($recipients, $headers, $body);

        $notification->push(_("Your password has been reset, check your email and log in with your new password."), 'horde.success');
        header('Location: ' . Auth::getLoginScreen('', $info['url']));
        exit;
    } else {
        /* Info submitted does not match what is in prefs, redirect user back
         * to login. */
        $notification->push(_("Could not reset the password for the requested user. Some or all of the details are not correct. Try again or contact your administrator if you need further help."), 'horde.error');
    }
}

require HORDE_TEMPLATES . '/common-header.inc';
$notification->notify(array('listeners' => 'status'));
require_once 'Horde/Form/Renderer.php';
$renderer = &new Horde_Form_Renderer();
$form->renderActive($renderer, $vars, 'resetpassword.php', 'post');
require HORDE_TEMPLATES . '/common-footer.inc';





More information about the commits mailing list