FWS-V2

 view release on metacpan or  search on metacpan

lib/FWS/V2/Display.pm  view on Meta::CPAN

    if ( !$self->{stopProcessing} ) {

        #
        # set default content dispoistion
        #
        $paramHash{contentDisposition}    ||= 'attachment';

        #
        # set the content type if we didn't get it in
        #
        $paramHash{contentType}           ||= 'text/html; charset=UTF-8';

        #
        # TODO don't think returnAdnDoNothing is needed anymore
        # bust out of here if there is nothing to do
        #
        if ( $self->formValue( 'returnAndDoNothing' ) ) { return }

        #
        # do reverse friendly logic to turn friendly URLs to non friendlies
        #
        if ( $self->siteValue( 'noFriendlies' ) && $self->formValue( 'p' ) !~ /^fws_/ ) {
            my @friendlyArray = @{$self->runSQL( SQL => "SELECT friendly_url FROM data WHERE site_guid='" . $self->{siteGUID} . "'  and (element_type='page')" )};
            while (@friendlyArray) {
                my $FURL = shift @friendlyArray;
                my $nonFURL = $self->{scriptName} . $self->{queryHead} . 'p=' . $FURL;
                $paramHash{content} =~ s/"\/$FURL"/"$nonFURL"/g;
            }
        }

        $self->saveSession();


        #
        # Return HTTP
        # Trim the domain name so it only ahs this.com without the host name.  this will fix stuff to make these all the same cookie
        # www.gnetworks.com secure.gnetworks.com www2.gnetworks.com cricket.gnetworks.com......
        #
        my $cookieDomain;
        my $cookie;
        if ( $self->{cookieDomainName} ) {
            $cookieDomain = ' domain=' . $self->{cookieDomainName} . ';';
        }
        
        #
        # if domainName doesn't have more than two dots in it, it is invalid by browsers
        # so lets kill it if thats the case so it will use a null/empty type value
        #
        if ( ($cookieDomain =~ tr/\.//) < 2 ) { $cookieDomain = '' }

        #
        # build the cookies for display
        #
        $cookie .= 'Set-Cookie: ' . $self->{sessionCookieName} . '=' . $self->formValue( 'session' ) . ';' . $cookieDomain . ' Path=/;' . ' Expires=' . $self->formatDate( format => 'cookie', monthMod => 1 ) . "\n";
        $cookie .= 'Set-Cookie: fbsr_' . $self->siteValue( 'facebookAppId' ) . '=deleted; Path=/;' . " Expires=Thu, 01-Jan-1970 00:00:01 GMT\n";

        #
        # simple page rendering
        #
        if ( $paramHash{head} ) {
            $paramHash{content} = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\">\n<head>\n" . $paramHash{head} . "</hea...
        }

        #
        # always return a 200
        #
        my $theHeader   = "Status: 200 OK\n";

        #
        # if the contentType doesn't have HTML in it, lets not pass the cookies
        #
        if ( $paramHash{contentType} =~ /html/i )   { $theHeader .= $cookie }
                                                      $theHeader .= "Accept-Ranges: bytes\n";
        if ( $paramHash{contentLength} )            { $theHeader .= 'Content-Length: ' . $paramHash{contentLength} . "\n" }
        if ( $paramHash{accessControlAllowOrigin} ) { $theHeader .= 'Access-Control-Allow-Origin: ' . $paramHash{accessControlAllowOrigin} . "\n" }
        if ( $paramHash{fileName} )                 { $theHeader .= 'Content-disposition: ' . $paramHash{contentDisposition} . ';' . ' filename="' . $paramHash{fileName} . "\"\n" }
                                                      $theHeader .= 'Content-Type: ' . $paramHash{contentType} . "\n\n";

        #
        # in case this was sent via a eval from an eplement, lets set the formvalue
        #
        $self->formValue( 'FWS_showElementOnly', 1 );

        if ( $self->formValue( 'redirect' ) ) {
            print "Status: 302 Found\n";
            print 'Location: ' . $self->urlDecode( $self->formValue( 'redirect' ) ) . "\n\n";
        }
        else { 
            print $theHeader  . $paramHash{content};
        }

        #
        # process our queue for every page we render
        # 
        $self->processQueue();

        #
        # shut off processing so we never do this more than once
        #
        $self->{stopProcessing} = 1;
    }
    return;
}


sub _FWSContent {
    my ( $self ) = @_;


    my $pageHTML;

    if ( !$self->{stopProcessing} ) {
    
    

        my $pageId = $self->safeSQL( $self->formValue( 'p' ) );

        #
        # this flag will suppress any access wrapping around the element
        #
        my $showElementOnly = 0;



( run in 1.277 second using v1.01-cache-2.11-cpan-85f18b9d64f )