Script Tips

Tuesday, 17 August 2004 18:11

Dealing with file or Site inclusion

Written by 
Rate this item
(0 votes)

File Inclusion

The first three methods only allow local files to be included

Include method:
You can include files in sub folders for example file="include\include_example.htm"
Or you can include files in the parent folder or other parent sub folders for example:
Other subfolder: file="..\include\include_example.htm"
Parent folder: file="..\include_example.htm"
IIS Server Tip for referencing parent directory

For windows you must use an "asp" or shtml extension.
If you use shtml then you must have the include file within a directory that has execute set - cgi-bin will work.

Example File=

<!-- #include file="include_example.htm"-->

Example Virtual=

<!-- #include Virtual="include/include_example.htm"-->

ASP server.execute method:
<%server.execute "include_example.htm"%>

PHP include method
include "include/include_example.htm";
include ("include/include_example.htm");

These methods allow inclusion of files located on another server!

PHP under linux can allow file inclusion of files from other websites if allow_url_fopen is enabled.
This setting does not work in Windows as it is always disabled.

<iframe scrolling="no" border="0" frameborder="0" width="200" height="150" src="include_example.htm" mce_src="include_example.htm">
Your Browser does not support IFrames</iframe>

Object method:
<object style="border: 0.5cm groove orange" data="include_example.htm" type="text/html" height="130" width="250">

Screen Scrape with ASP .NET:
This method requires you to save the file with an ASPX extension.
<%@ Import Namespace="System.Net" %>

<script language="VB" runat="server">
    Sub Page_Load(sender as Object, e as EventArgs)
         'Create a WebClient instance
       Dim objWebClient as New WebClient()
       Const strURL as String = ""    
       Dim objUTF8 as New UTF8Encoding()
       lblHTMLOutput.Text = objUTF8.GetString(objWebClient.DownloadData(strURL))
       Catch webEx As WebException 'to avoid dot net system error'
           if webEx.Status = WebExceptionStatus.ConnectFailure then
                'do nothing
             end if
         End Try
      End Sub
<table width="100%" bgcolor="white">
            <td align="center">
                  <h1>Screen Scrape Example of</h1>
      <asp:label id="lblHTMLOutput" runat="server" /> 

Vincent Gabriele

Read 7404 times Last modified on Sunday, 13 September 2015 17:59
More in this category: « Placing Text on a Picture

Leave a comment

Make sure you enter all the required information, indicated by an asterisk (*). HTML code is not allowed.