Esempio n. 1
0
function sendContentType($contenttype, $pagetype = '', $charset = _CHARSET)
{
    global $manager, $CONF;
    if (!headers_sent()) {
        // if content type is application/xhtml+xml, only send it to browsers
        // that can handle it (IE6 cannot). Otherwise, send text/html
        // v2.5: For admin area pages, keep sending text/html (unless it's a debug version)
        //	   application/xhtml+xml still causes too much problems with the javascript implementations
        // v3.3: ($CONF['UsingAdminArea'] && !$CONF['debug']) gets removed,
        //	   application/xhtml+xml seems to be working, so we're going to use it if we can.
        //
        // Note: reverted the following function in JP version
        //
        /*
        	// v3.3 code
        	if (
        			($contenttype == 'application/xhtml+xml')
        		&&  (!stristr(serverVar('HTTP_ACCEPT'), 'application/xhtml+xml') )
        		) {
        		$contenttype = 'text/html';
        	}
        */
        // v3.2x code
        if ($contenttype == 'application/xhtml+xml' && ($CONF['UsingAdminArea'] && !$CONF['debug'] || !stristr(serverVar('HTTP_ACCEPT'), 'application/xhtml+xml'))) {
            $contenttype = 'text/html';
        }
        $manager->notify('PreSendContentType', array('contentType' => &$contenttype, 'charset' => &$charset, 'pageType' => $pagetype));
        // strip strange characters
        $contenttype = preg_replace('|[^a-z0-9-+./]|i', '', $contenttype);
        $charset = preg_replace('|[^a-z0-9-_]|i', '', $charset);
        if ($charset != '') {
            header('Content-Type: ' . $contenttype . '; charset=' . $charset);
        } else {
            header('Content-Type: ' . $contenttype);
        }
        // check if valid charset
        if (!encoding_check(false, false, $charset)) {
            foreach (array($_GET, $_POST) as $input) {
                array_walk($input, 'encoding_check');
            }
        }
    }
}
 function event_PostAuthentication($data)
 {
     global $CONF;
     if ($this->isMobile() && !$CONF['UsingAdminArea']) {
         if (requestVar('action') == 'addcomment' || strlen(getVar('query'))) {
             // check if valid SJIS
             if (!encoding_check(false, false, 'Shift_JIS')) {
                 foreach (array($_REQUEST, $_SERVER) as $input) {
                     array_walk($input, 'encoding_check');
                 }
             }
             // user/body/query won't be checked anymore.
             encoding_check(false, false, false, array('user', 'body', 'query'));
         }
     }
 }