Changeset 2335

Show
Ignore:
Timestamp:
11/16/05 23:06:18 (3 years ago)
Author:
pablo
Message:
  • Fixes bug: #217
  • Date was not printed.
  • Redirect will use HTTP_REFERER....
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/jaws/html/gadgets/Chatbox/ChatboxHTML.php

    r2295 r2335  
    103103            require_once JAWS_PATH . 'include/JawsCaptcha.php'; 
    104104            $jawsCaptchas =& new JawsCaptcha(); 
    105             $md5 = $jawsCaptchas->Random(); 
    106             $tpl->SetBlock('display/captcha'); 
    107             $tpl->SetVariable('captchacode', _t('GLOBAL_CAPTCHA_CODE')); 
    108             $tpl->SetVariable('captcha', _t('GLOBAL_CAPTCHA')); 
    109             $tpl->SetVariable('captchakey', $md5); 
    110             $tpl->SetVariable('captchaurl', 'index.php?gadget=Chatbox&action=Captcha&key='.$md5); 
    111             $tpl->ParseBlock('display/captcha'); 
     105            if ($jawsCaptchas->CanBeUsed()) { 
     106                $md5 = $jawsCaptchas->Random(); 
     107                $tpl->SetBlock('display/captcha'); 
     108                $tpl->SetVariable('captchacode', _t('GLOBAL_CAPTCHA_CODE')); 
     109                $tpl->SetVariable('captcha', _t('GLOBAL_CAPTCHA')); 
     110                $tpl->SetVariable('captchakey', $md5); 
     111                $tpl->SetVariable('captchaurl', 'index.php?gadget=Chatbox&action=Captcha&key='.$md5); 
     112                $tpl->ParseBlock('display/captcha'); 
     113            } 
    112114        } 
    113115 
     
    146148        require_once JAWS_PATH . 'include/JawsTypes/JawsHeader.php'; 
    147149 
    148         $urlRedirect = (empty($_SERVER['QUERY_STRING'])) ? 'index.php?' . $_SERVER['QUERY_STRING'] : 'index.php'; 
     150        $urlRedirect = 'index.php'; 
     151        if (isset($_SERVER['HTTP_REFERER'])) { 
     152            if (!empty($_SERVER['HTTP_REFERER'])) { 
     153                $urlRedirect = $_SERVER['HTTP_REFERER']; 
     154            }  
     155        } 
    149156        if ($GLOBALS['app']->Registry->Get('/gadgets/AntiSpam/allow_captchas') == 'yes' && 
    150157            $GLOBALS['app']->Registry->Get('/gadgets/Chatbox/use_antispam') == 'true') { 
    151             if (isset($_POST['captcha']) && isset($_POST['captchaKey'])) { 
    152                 require_once JAWS_PATH . 'include/JawsCaptcha.php'; 
    153                 $jawsCaptchas =& new JawsCaptcha(); 
    154                 if (!$jawsCaptchas->IsValid($_POST['captchaKey'], $_POST['captcha'])) { 
     158 
     159            require_once JAWS_PATH . 'include/JawsCaptcha.php'; 
     160            $jawsCaptchas =& new JawsCaptcha(); 
     161             
     162            if ($jawsCaptchas->CanBeUsed()) { 
     163                if (isset($_POST['captcha']) && isset($_POST['captchaKey'])) { 
     164                    if (!$jawsCaptchas->IsValid($_POST['captchaKey'], $_POST['captcha'])) { 
     165                        JawsHeader::Location($urlRedirect); 
     166                    } 
     167                } else {                 
    155168                    JawsHeader::Location($urlRedirect); 
    156169                } 
    157             } else { 
    158                 JawsHeader::Location($urlRedirect); 
    159170            } 
    160171        } 
     
    169180        } 
    170181        JawsHeader::Location($urlRedirect); 
     182    } 
     183 
     184    /** 
     185     * Format a date using Jaws 
     186     * 
     187     * @param string $value The data to format. 
     188     * @return string The formatted date. 
     189     */ 
     190    function FormatDate($value) 
     191    { 
     192        return $GLOBALS['app']->Date->Format($value); 
    171193    } 
    172194 
     
    204226            $datagrid->AddColumn(Piwi::CreateWidget('Column', _t('GLOBAL_NAME'), 'name')); 
    205227            $datagrid->AddColumn(Piwi::CreateWidget('Column', _t('GLOBAL_IP'), 'ip_address')); 
    206             $datagrid->AddColumn(Piwi::CreateWidget('Column', _t('GLOBAL_DATE'), 'updatetime')); 
     228            $datagrid->AddColumn(Piwi::CreateWidget('Column', _t('GLOBAL_DATE'), 'updatetime', 
     229                                                    true, 'Custom', true, '', array($this, 'FormatDate'))); 
    207230            $datagrid->AddColumn(Piwi::CreateWidget('Column', _t('CHATBOX_MESSAGE'), 'message')); 
    208231