Exemplo n.º 1
0
int SSIEngine::processSet(HttpSession *pSession, SSIComponent *pComponent)
{
    SubstItem *pItem = (SubstItem *)pComponent->getFirstAttr();
    const AutoStr2 *pVarName;
    char achBuf1[8192];
    char *p;
    int len;
    int attr;
    while (pItem)
    {

        attr = pItem->getSubType();
        if (attr == SSI_SET_VAR)
        {
            pVarName = pItem->getStr();
            pItem = (SubstItem *) pItem->next();
            if (!pItem)
                break;
            if (pItem->getSubType() != SSI_SET_VALUE)
                continue;
            p = achBuf1;
            len = 8192;
            len = RequestVars::appendSubst(pItem, pSession, p, len, 0,
                                           pSession->getReq()->getSSIRuntime()->getRegexResult(),
                                           pSession->getReq()->getSSIRuntime()
                                           ->getConfig()->getTimeFmt()->c_str());
            RequestVars::setEnv(pSession, pVarName->c_str(), pVarName->len(), achBuf1,
                                p - achBuf1);
        }

        pItem = (SubstItem *) pItem->next();
    }
    return 0;
}
Exemplo n.º 2
0
int SSIEngine::processEcho(HttpSession *pSession, SSIComponent *pComponent)
{
    SubstItem *pItem = (SubstItem *)pComponent->getFirstAttr();
    char achBuf1[8192];
    char achBuf[40960];
    char *p;
    int len;
    int attr;
    int encode = SSI_ENC_ENTITY;
    while (pItem)
    {
        attr = pItem->getSubType();
        p = achBuf1;
        len = 8192;
        switch (attr)
        {
        case SSI_ECHO_VAR:
            if ((pItem->getType() == REF_DATE_LOCAL) ||
                (pItem->getType() == REF_LAST_MODIFIED) ||
                (pItem->getType() == REF_DATE_GMT))
                memccpy(p, pSession->getReq()->getSSIRuntime()
                        ->getConfig()->getTimeFmt()->c_str(), 0, 4096);
            RequestVars::appendSubst(pItem, pSession, p, len,
                                     0, pSession->getReq()->getSSIRuntime()->getRegexResult());
            if (encode == SSI_ENC_URL)
            {
                len = HttpUtil::escape(achBuf1, p - achBuf1,
                                       achBuf, 40960);
                p = achBuf;
            }
            else if (encode == SSI_ENC_ENTITY)
            {
                len = HttpUtil::escapeHtml(achBuf1, p, achBuf, 40960);
                p = achBuf;
            }
            else
            {
                len = p - achBuf1;
                p = achBuf1;
            }
            if (len > 0)
                pSession->appendDynBody(p, len);
            break;
        case SSI_ENC_NONE:
        case SSI_ENC_URL:
        case SSI_ENC_ENTITY:
            encode = attr;
            break;
        }

        pItem = (SubstItem *) pItem->next();
    }
    return 0;
}
Exemplo n.º 3
0
int SSIEngine::updateSSIConfig( HttpSession *pSession, SSIComponent * pComponent, 
                            SSIRuntime * pRuntime )
{
    SubstItem *pItem = (SubstItem *)pComponent->getFirstAttr();
    char achBuf[4096];
    char * p;
    int len;
    int attr;
    while( pItem )
    {
        attr = pItem->getSubType();
        p = achBuf;
        len = 4096;
        switch( attr )
        {
        case SSI_ECHOMSG:
        case SSI_ERRMSG:
        case SSI_TIMEFMT:
            RequestVars::appendSubst( pItem, pSession, p, len, 0, NULL );
            if ( attr == SSI_ERRMSG )
                pRuntime->getConfig()->setErrMsg( achBuf, p - achBuf );
            else if ( attr == SSI_ECHOMSG )
                pRuntime->getConfig()->setEchoMsg( achBuf, p - achBuf );
            else 
                pRuntime->getConfig()->setTimeFmt( achBuf, p - achBuf );
            break;
        case SSI_SIZEFMT:
            if ( pItem->getType() == REF_STRING )
            {
                const AutoStr2 * pStr = pItem->getStr();
                if (( pStr )&&( pStr->c_str() ))
                {
                    pRuntime->getConfig()->setSizeFmt( pStr->c_str(), pStr->len() );
                }
            }
            break;

        }
    
        pItem = (SubstItem *) pItem->next();
    }
    return 0;
}