using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Net; using System.IO; using System.Text; namespace GoogleControl { /// /// Component to use in the consumer ASPX to call the HTTP control. /// Declaration: /// <%@ Page language="c#" Codebehind="ControlClient.aspx.cs" /// AutoEventWireup="false" Inherits="GoogleControl.ControlClient" /// Src="ControlClient.aspx.cs" %> /// Usage: /// <% include(url_of_GoogleForm); %> ///

Copyright (c) 2002 Alexis Grandemange
/// Mail: alexis.grandemange@pagebox.net

///
This program is free software; you can redistribute it and/or
	/// modify it under the terms of the GNU Lesser General Public
	/// License as published by the Free Software Foundation; version
	/// 2.1 of the License.
	/// This library 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 Lesser General Public License for more details.
	/// A copy of the GNU Lesser General Public License lesser.txt should be
	/// included in the distribution.
///
public class ControlClient : System.Web.UI.Page { public ControlClient() { Page.Init += new System.EventHandler(Page_Init); } private void Page_Load(object sender, System.EventArgs e) { } private void Page_Init(object sender, EventArgs e) { InitializeComponent(); } #region Web Form Designer generated code /// /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// private void InitializeComponent() { this.Load += new System.EventHandler(this.Page_Load); } #endregion /// /// Write the GoogleForm stream on the consumer ASPX. /// include replaces GoogleForm.aspx by its full URL. /// include sets the consumer full URL in the from parameter. /// /// Url of GoogleForm.aspx public void include(string url) { string referer = Request.ServerVariables["HTTP_HOST"] + Request.ServerVariables["URL"]; string query = url + "?from=" + referer; WebRequest WReq = WebRequest.Create(query); WReq.Timeout = 1000000; WebResponse WResp = WReq.GetResponse(); StreamReader sr = new StreamReader(WResp.GetResponseStream(), Encoding.UTF8); int length = 1024; char [] buf = new char[1024]; int len = sr.Read(buf, 0, length); while(len > 0) { string txt = new string(buf, 0, len); Response.Write(txt.Replace("GoogleForm.aspx", url)); len = sr.Read(buf, 0, length); } } } }