# Class: Asp::Server
[ "README", "lib/asp/server.rb", "lib/asp/application.rb", "lib/asp/request.rb", "lib/asp/response.rb", "lib/asp/session.rb", nil].each do
Asp.view_html
Asp::Session.view_html
Asp::Response.view_html
Asp::Application.view_html
Asp::Server.view_html
Asp::Request.view_html
Asp::Eval.view_html
end

Class Asp::Server < Object

(in files lib/asp/server.rb )

Copyright (C) 2003, 2004 Gregoire Lejeune <gregoire.lejeune@free.fr>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA

Methods

Public Class method: new( r, oAspError, aspHandler )

# File lib/asp/server.rb, line 183
    def initialize( r, oAspError, aspHandler )
      @oApacheRequest = r
      @oAspError = oAspError
      @oAspHandler = aspHandler

      @bEnd = 0
    end

Public Instance method: clearError( )

(Not Implemented)

# File lib/asp/server.rb, line 155
    def clearError( )
      ## -> void
    end

Public Instance method: createObject( xType )

(Not Implemented)

# File lib/asp/server.rb, line 160
    def createObject( xType )
      ## -> object
    end

Public Instance method: createObjectFromClsid( xClsid )

(Not Implemented)

# File lib/asp/server.rb, line 165
    def createObjectFromClsid( xClsid )
      ## -> object
    end

Public Instance method: execute( filename, *args )

Executes the current request using another page.

# File lib/asp/server.rb, line 51
    def execute( filename, *args )
      funcname = "i__"+rand( Time::new.to_i ).to_s+"__"+rand( Time::new.to_i ).to_s
      code = @oAspHandler.compile(filename)
      ##code = compile(filename)
      totalcode = "def " + funcname + "( args=nil )\n" + code + "\nend\n"

      @oAspHandler.load_code( totalcode, nil )
      eval( "@oAspHandler." + funcname + "( args )" )
    end

Public Instance method: exist?( xFilename )

Returns true if xFilename exist, false otherwise

# File lib/asp/server.rb, line 32
    def exist?( xFilename )
      return File.exist?( xFilename.untaint ).untaint
    end

Public Instance method: file()

Returns the absolute file path to current executing script.

# File lib/asp/server.rb, line 27
    def file
      return @oApacheRequest.filename.dup
    end

Public Instance method: fileExist( xFilename )

Alias for exist?

Public Instance method: getLastError( )

Returns the last script error

# File lib/asp/server.rb, line 131
    def getLastError( )
      return @oAspError
    end

Public Instance method: htmlDecode( xData )

Decodes a string that has been encoded to eliminate invalid HTML characters.

# File lib/asp/server.rb, line 170
    def htmlDecode( xData )
      ## -> string
      return Common::html_unescape( xData )
    end

Public Instance method: htmlEncode( data )

Alias for html_encode

Public Instance method: html_decode( xData )

Alias for htmlDecode

Public Instance method: html_encode( data )

Encodes a string to be displayed in a browser.

# File lib/asp/server.rb, line 38
    def html_encode( data )
      return Common::html_escape( data )
    end

Public Instance method: machineName()

Gets the server’s computer name. (To be implemented)

# File lib/asp/server.rb, line 145
    def machineName
      ## -> string
    end

Public Instance method: mail( hMailOps, hSMTPOps=nil )

Sends a mail

hMailOps is a hash with keys :

  • From : mail From
  • To : mail To
  • Subject : mail Subject
  • Body : mail Body

hSMTPOps is a hash with keys :

  • server : SMTP server address. If you have MailHost configured, this wil be the default else default is localhost
  • port : SMTP server port. If you have MailPort configured, this will be the default else default is 25
# File lib/asp/server.rb, line 89
    def mail( hMailOps, hSMTPOps=nil )
      if hSMTPOps.nil? == true
        hSMTPOps = Hash::new
        hSMTPOps["server"] = ENV["MailHost"].untaint || "localhost"
        hSMTPOps["port"]   = ENV["MailPort"].untaint || 25
      end

      body = "From: " + String( hMailOps["From"] ) + "\n" +
             "To: " + String( hMailOps["To"] ) + "\n" +
             "Subject: " + ( String( hMailOps["Subject"] ) || "[No Subject]" ) + "\n\n" +
             ( String( hMailOps["Body"] ) || "" )
      
      begin
        smtp = Net::SMTP::new( hSMTPOps["server"], hSMTPOps["port"] )
        smtp.start( )
        smtp.sendmail( body, hMailOps["From"], hMailOps["To"] )
        smtp.finish
      end
    end

Public Instance method: mapPath( path )

Returns the physical file path that corresponds to the specified virtual path on the Web server.

# File lib/asp/server.rb, line 62
    def mapPath( path )
      global = @oApacheRequest.filename.dup
      local = @oApacheRequest.uri
      www = global.gsub( local, "" )
      mmm = global.gsub( /[^\/]*$/, "" )

      result = ""
      if /^\// =~ path
        result = www + path
      else
        result = File::expand_path( mmm + path )
      end

      return result
    end

Public Instance method: scriptTimeout()

(Not Implemented)

# File lib/asp/server.rb, line 150
    def scriptTimeout
      ## -> int
    end

Public Instance method: transfer( filename, *args )

Transfers control to another script.

# File lib/asp/server.rb, line 44
    def transfer( filename, *args )
      @bEnd = 1
      self.execute( filename, args )
      goto :e
    end

Public Instance method: url( uri, hParams=nil )

Will return a URL with hParams serialized into a query string

# File lib/asp/server.rb, line 117
    def url( uri, hParams=nil )
      args = ""
      sep = "?"
      if hParams.nil? == false
        hParams.each_pair { |k,v|
          args += sep + self.url_encode( k ) + "=" + self.url_encode( v )
          sep = "&"
        }
      end

      return( uri + args )
    end

Public Instance method: urlDecode( xUrl )

Decodes a string encoded for HTTP transmission and sent to the server in a URL.

# File lib/asp/server.rb, line 177
    def urlDecode( xUrl )
      ## -> string
      return Common::url_decode( xUrl )
    end

Public Instance method: urlEncode( data )

Alias for url_encode

Public Instance method: urlPathEncode( data )

Alias for url_encode

Public Instance method: url_encode( data )

Encodes a string for reliable HTTP transmission from the Web server to a client via the URL.

# File lib/asp/server.rb, line 110
    def url_encode( data )
      return Common::url_encode( data )
    end

Public Instance method: xslt( xsl_data, xml_data )

This method takes string for XSL and XML data and returns the XSLT output as a string

# File lib/asp/server.rb, line 136
    def xslt( xsl_data, xml_data )
      xslt = XML::XSLT.new()
      xslt.xml = xml_data
      xslt.xsl = xsl_data
      return xslt.serve()
    end