/**
 * - strips off CVS-Id-Lines from the templates
 * - replaces tags with real content
 *
 * @param   array           $aTplReplace    associative array including all substitutions
 * @param   array|string    $varContent     template(set)
 *
 * @return  mixed(array|string)
 */
function fTplReplace($aTplReplace, $varContent)
{
    // if $varContent is array use fTplReplace recursively
    if (is_array($varContent)) {
        foreach ($varContent as $kContent => $sContent) {
            $varContent[$kContent] = fTplReplace($aTplReplace, $sContent);
        }
        return $varContent;
    }
    // strips off CVS-Id lines enclosed by XHTML comment structure
    $varContent = preg_replace('|(<!-- \\$).*( //-->)\\n+|', '', $varContent);
    // substitute template tags by content, respecting tag prefixes
    foreach ($aTplReplace as $key => $value) {
        $aAction = explode('_', $key, 2);
        // prefixes used by templates and should be respected by substitution:
        // - 'INC' marks included (and still processed) templates
        // - 'PRE' marks preformatted tags which must NOT be processed
        if ($aAction[0] == 'INC' or $aAction[0] == 'PRE') {
            $varContent = str_replace(TPL_TAGOPEN . $key . TPL_TAGCLOSE, $value, $varContent);
        } else {
            $varContent = str_replace(TPL_TAGOPEN . $key . TPL_TAGCLOSE, htmlentities($value, ENT_NOQUOTES, 'ISO8859-15'), $varContent);
        }
    }
    // return template
    return $varContent;
}
/**
 * creates user interfaces
 *
 * @param   string  $sType      interface type
 * @param   array   $aData      user environment
 *
 * @return  void
 */
function fAdmDisplay($sType, $aData = array())
{
    $aValTpl = array('adduser' => 'scr.adm_adduser.tpl', 'not_complete' => 'scr.adm_adduser.tpl', 'input_error' => 'scr.adm_adduser.tpl', 'ok' => 'scr.adm_adduser_ok.tpl');
    $aTpl = array(0 => file_get_contents(TPL_DIR . 'head.tpl'), 30 => file_get_contents(TPL_DIR . $aValTpl[$sType]), 100 => file_get_contents(TPL_DIR . 'footer.tpl'));
    $aLang = parse_ini_file(LANG_DIR . 'admin.' . LANG . '.lang', TRUE);
    $aLang[$sType]['PRE_URL'] = $_SERVER['PHP_SELF'] . '?cmd=adm&sub=ausr';
    $aTpl[0] = fTplReplace($aLang['head'], $aTpl[0]);
    $aTpl[30] = fTplReplace($aLang[$sType], $aTpl[30]);
    $bOk = fTplPrint($aTpl);
    exit;
}
Esempio n. 3
0
/**
 * creates user interfaces
 *
 * @param   void
 *
 * @return  void
 */
function fSpDisplay()
{
    // load templates
    $aTpl = array(0 => file_get_contents(TPL_DIR . 'head.tpl'), 10 => file_get_contents(TPL_DIR . 'scr.menu_head.tpl'), 20 => file_get_contents(TPL_DIR . 'scr.menu_main.tpl'), 30 => file_get_contents(TPL_DIR . 'scr.startpage.tpl'), 100 => file_get_contents(TPL_DIR . 'footer.tpl'));
    // load language environment
    $aLang = parse_ini_file(LANG_DIR . 'startpage' . '.lang', TRUE);
    $aLang['menu'] = parse_ini_file(LANG_DIR . 'menu.' . LANG . '.lang', TRUE);
    // replace template placeholder tags
    $aTpl[0] = fTplReplace($aLang['head'], $aTpl[0]);
    $aTpl[10] = fTplReplace($aLang['menu']['head'], $aTpl[10]);
    $aTpl[20] = fTplReplace($aLang['menu']['main'], $aTpl[20]);
    // output to screen
    $bOk = fTplPrint($aTpl);
    exit;
}
Esempio n. 4
0
/**
 * sends an email to requesting user including new password
 *
 * @param   array   $aData      user environment
 *
 * @return  bool
 */
function fPwdMail($aData)
{
    $sTpl = file_get_contents(TPL_DIR . 'mail.pwdlost.' . $aData['lang'] . '.tpl');
    $aReplace = array('PRE_FIRSTNAME' => $aData['fname'], 'PRE_LASTNAME' => $aData['lname'], 'PRE_NICK' => $aData['nick'], 'PRE_PWD' => $aData['new_pwd'], 'PRE_IP' => $_SERVER['REMOTE_ADDR'], 'PRE_APPL' => BASE_URL, 'PRE_DATE' => date('y-m-d'), 'PRE_TIME' => date('H:i:s'));
    $sTpl = fTplReplace($aReplace, $sTpl);
    $sHeader = 'From: ' . MAIL_FROM . MAIL_HBR . 'Reply-To: ' . MAIL_RPATH . MAIL_HBR . 'X-Mailer: PHP/Calendar' . MAIL_HBR;
    $bOk = mail($aData['email'], 'Login', $sTpl, $sHeader);
    return $bOk;
}