<?php    
Header( "HTTP/1.1 301 Moved Permanently" );
Header( "Location: http://massimotivoli.wix.com/home" );
/* Header( "Refresh: 5; url=http://massimotivoli.wix.com/home" ); */
?>

<?php

$domain = $_SERVER[REMOTE_ADDR];
$from = $_SERVER[HTTP_REFERER]; 

$host = $_SERVER[REMOTE_HOST];

require 'include/MyTemplate.class.php';

$T = new MyTemplate();

$Maintpl= "templates/index.tpl";

/* set template which contains nested template, which will be shown at the top and bottom of the page */
$T->setFile('page', $Maintpl);



if (!isset($_GET['pageId']))
	{
		$page="home";
		$Filecontent="contents/home.html";
	}
else
   {
    if (ereg("\.\.",$_GET['pageId'])) exit();
    $page=$_GET['pageId'];
    $Filecontent="contents/$page.html";
    }

if ($page !="publications") {
	 if (!$Handle = fopen ($Filecontent, "r")) {
			 print "Errore nel reperimento dei dati**";
			 exit;
			}

			if (!$Content = fread ($Handle, filesize ($Filecontent)) ){
					 print "Errore nel reperimento dei dati 2";
					 exit;
			}

	fclose ($Handle);
} else {
	require("aigaion_simpleembedding/httpclient/http.php");
	//====== BEGIN EMBEDDING CODE ======  
	//the page to embed, as an aigaion anchor, without slash at end
	if ($_GET['sort'] == "byType") {
		$byType="/type";
	}
		
	$pageToEmbed = "authors/embed/77".$byType; 
	//the aigaion root, without index.php suffix, with slash at end
//	$aigaionRoot = "http://reposto.di.univaq.it/aigon2/";  
$aigaionRoot = "http://192.168.195.148/aigon2/";
	//login info: if dologin set to false, the embedding will not 
	//attempt to login, and therefore will only show public access 
	//information. If anonymous access is not enabled on the aigaion 
	//server, this will result in a loginscreen being shown
	$dologin = false; //note that in this example, the demo user 
					  //has access to one more publication than 
					  //the anonymous user  
	$loginName = "demo";
	$loginPass = "demo"; 
	

	
	set_time_limit(0);
	$http=new http_class;

	/* Connection timeout */
	$http->timeout=0;

	/* Data transfer timeout */
	$http->data_timeout=0;

	/* Output debugging information about the progress of the connection */
	$http->debug=0;

	/* Format dubug output to display with HTML pages */
	$http->html_debug=1;


	/*
	 *  Need to emulate a certain browser user agent?
	 *  Set the user agent this way:
	 */
	//$http->user_agent="Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";

	/*
	 *  If you want to the class to follow the URL of redirect responses
	 *  set this variable to 1.
	 */
	$http->follow_redirect=1;

	/*
	 *  How many consecutive redirected requests the class should follow.
	 */
	$http->redirection_limit=5;

	/*
	 *  If your DNS always resolves non-existing domains to a default IP
	 *  address to force the redirection to a given page, specify the
	 *  default IP address in this variable to make the class handle it
	 *  as when domain resolution fails.
	 */
	$http->exclude_address="";

	/*
	 *  If you want to establish SSL connections and you do not want the
	 *  class to use the CURL library, set this variable to 0 .
	 */
	$http->prefer_curl=0;		

	/*
	 *  If basic authentication is required, specify the user name and
	 *  password in these variables.
	 */
	  if ($dologin)
	  {
		$url= $aigaionRoot."index.php/login/dologin/".$pageToEmbed;
	  } 
	  else
	  {
	   $url= $aigaionRoot."index.php/".$pageToEmbed;
	  }

	
	/*
	 *  Generate a list of arguments for opening a connection and make an
	 *  HTTP request from a given URL.
	 */
	$error=$http->GetRequestArguments($url,$arguments);


	/* Set additional request headers */
	$arguments["Headers"]["Pragma"]="nocache";

	$error=$http->Open($arguments);

	if($error=="")
	{
		$error=$http->SendRequest($arguments);

		if($error=="")
		{
			for(Reset($http->request_headers),$header=0;$header<count($http->request_headers);Next($http->request_headers),$header++)
			{
				$header_name=Key($http->request_headers);
				if(GetType($http->request_headers[$header_name])=="array")
				{
					for($header_value=0;$header_value<count($http->request_headers[$header_name]);$header_value++)
						;//echo $header_name.": ".$http->request_headers[$header_name][$header_value],"\r\n";
				}
				else
					;//echo $header_name.": ".$http->request_headers[$header_name],"\r\n";
			}
			//echo "</PRE>\n";
			flush();

			//$headers=array();
			//$error=$http->ReadReplyHeaders($headers);
			if($error=="")
			{
				//echo "<H2><LI>Response status code:</LI</H2>\n<P>".$http->response_status;
				switch($http->response_status)
				{
					case "301":
					case "302":
					case "303":
					case "307":
						//echo " (redirect to <TT>".$headers["location"]."</TT>)<BR>\nSet the <TT>follow_redirect</TT> variable to handle redirect responses automatically.";
						break;
				}
				//echo "</P>\n";
				//echo "<H2><LI>Response headers:</LI</H2>\n<PRE>\n";
				/***************
				for(Reset($headers),$header=0;$header<count($headers);Next($headers),$header++)
				{
					$header_name=Key($headers);
					if(GetType($headers[$header_name])=="array")
					{
						for($header_value=0;$header_value<count($headers[$header_name]);$header_value++)
							;//echo $header_name.": ".$headers[$header_name][$header_value],"\r\n";
					}
					else
						;//echo $header_name.": ".$headers[$header_name],"\r\n";
				}
				*****************/
				//echo "</PRE>\n";
				//flush();

				//echo "<H2><LI>Response body:</LI</H2>\n<PRE>\n";
				for(;;)
				{
					$error=$http->ReadReplyBody($publications,1000000);
					
					if($error!=""
					|| strlen($body)==0)
						break;
						//$publications = $body;
					//echo $body;
				}
				//echo "</PRE>\n";
				flush();
			}
		}
		$http->Close();
	}
	if(strlen($error))
		echo "<CENTER><H2>Error: ",$error,"</H2><CENTER>\n";
	
	if ( $_GET['sort'] == "byType") {
		$link = "[<a href=index.php?pageId=publications>Sort by Year</a>]";
	} else {
		$link = "[<a href=index.php?pageId=publications&sort=byType>Sort by Type</a>]";
	}
	
	$link = $link."[<a href=\"http://scholar.google.com/citations?user=jvlJKLkAAAAJ&hl=en\"><b>My pubs on Google Scholar</b></a>]"; 
	
	$links = "<div class='topLinks'>
		[<a href=\"http://reposto.di.univaq.it/aigon2/index.php/export/author/77/bibtex\" target=\"aigaion_export\">Export BibTeX</a>]
		".$link."</div>";

	
	$copyright =	"<br/><br/><br/>
	<div class='copyright'>
		<h2><center>Copyright Notices for the Listed Publications</center></h2>
		<br/>
		<table>
			<tr >
				<td>ACM</td><td>Copyright by the Association for Computing Machinery, Inc. Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, to republish, to post on servers, or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from Publications Dept, ACM Inc., fax +1 (212) 869-0481, or permissions@acm.org.</td>
			</tr>
			<tr>
				<td>IEEE</td><td>This material is presented to ensure timely dissemination of scholarly and technical work. Copyright and all rights therein are retained by authors or by other copyright holders. All persons copying this information are expected to adhere to the terms and constraints invoked by each author's copyright. In most cases, these works may not be reposted without the explicit permission of the copyright holder.</td>

			</tr>
			<tr>
				<td>Springer</td><td>The following copyright notice applies to all papers published in the Lecture Notes in Computer Science by Springer-Verlag, as mentioned in the Copyright Form. The Author may publish his/her contribution on his/her personal Web page provided that he/she creates a link to the above mentioned volume of LNCS at the Springer-Verlag server or to the LNCS series homepage, and that together with this electronic version it is clearly pointed out, by prominently adding \"Copyright Springer-Verlag\", that the copyright for this contribution is held by Springer.</td>
			</tr>
		</table>
	</div>
	 <br/>
	<br/>";
	
	 $phdthesis = "<br><br><br><div class='phdthesis'><h2><center>PhD Thesis</center></h2>
		<br/><a href=./files/MT_PhD_Thesis.pdf>An architectural approach to the automatic composition and adaptation of software
        components</a>, M.Tivoli. PhD Thesis. Computer Science Department, University of
        L'Aquila. June, 6th 2005.</div>";
		
	$pubheader = "Publications of Massimo Tivoli<br><font size=1px>Total number of publications: ";
	$pubheader = $pubheader.substr_count($publications,"publication_summary");
	$pubheader = $pubheader."</font><br><font size=1px>Managed by <a href='http://reposto.di.univaq.it/aigon2/index.php'>Aigaion 2.0 (beta)</a></font>";
	$pubheader = $pubheader."<br>";
	$publications=str_replace("Publications of Massimo Tivoli",$pubheader,$publications);
	$publications=str_replace("sorted by journal and type","<font size=1px>sorted by journal and type</font>",$publications);

	$Content = $links.$publications.$phdthesis.$copyright;

}

 

$T->assignVars('content', $Content);
$T->assignVars('location',$page);
$T->fprint('page');



?>
