Location: PHPKode > scripts > PXAServer > pxaserver/libreria/collector.inc.php
<?php
############################################################################
# This code is developed by Guerrieri Luca                                                                #
# copyright (C) 2006/2007 hide@address.com
# This code is released under the terms of the GPL v.2 License.
#
# The author is not responsible for data loss, or any kind of trouble that
# results from the use of this software.
# USE IT AT YOUR OWN RISK!
#
# 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., 675 Mass Ave, Cambridge, MA 02139, USA.
############################################################################

/*
 * Created on 1-set-2006
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */

  require ('libfunz.inc.php');
  require ('config.inc.php');

  $error= new MSGmanager;	//Istanzia la classe dei messaggi di errore

  $aj = new Ajax;
  $aj -> set_id ($_REQUEST['id']);
  $aj -> set_request($_REQUEST['resource']);
  $aj -> set_xml_file($ajax_xml_file);
  if ($_REQUEST['type']== "static"){
  //elaboriamo un file e lo restituiamo
  	$aj -> set_type("static");
  	$file2open = $template_directory.$template_name."/ajax_template/".$aj -> send_response();	//usa il link al file indicato in ajax_xml_file
  	if (!($fp = fopen ($file2open, "r"))) {
	 	print ($this->error->print_error('file2open_collector_error'));
  	}else {
		$readed_info = fread ($fp,filesize($file2open));
		echo $readed_info;
		fclose ($fp);
  	}
  }else if ($_REQUEST['type']== "dynamic"){
  //elaboriamo una query e la restituiamo
  	$aj -> set_type("dynamic");
	$link = db_connect();
	$Qm = new QueryManager;
	$Qm ->set_query($aj -> send_response());
	$Qr = new QueryResult($Qm ->get_static_query(),"assoc",$link);	//rilascia un array con il risultato della query eseguita
	$query_array = $Qr-> result;
	db_close($link);
	$tm = new TemplateManager;
	echo $tm->make_dynamic_template($template_name,$_REQUEST['resource'].'.tpl',$_REQUEST['resource'].'.xml',$query_array);
  }else if ($_REQUEST['type']== "dynamic_with_params"){
  //elaboriamo una query e forniamo i parametri e la restituiamo
  	$aj -> set_type("dynamic");
	$link = db_connect();
	$Qm = new QueryManager;
	$Qm ->set_query($aj -> send_response());
	$p_data= substr($_REQUEST['params'],(strpos($_REQUEST['params'],'*')+1));
	$p_placeholder= substr($_REQUEST['params'],0,strpos($_REQUEST['params'],'*'));
	$Qm ->set_placeholders(array($p_placeholder));		//imposto i nomi dei placeholders nella query come array
 	$Qm ->set_data(array($p_data));					//imposto i nomi delle variabili nella query come array
	$Qr = new QueryResult($Qm ->get_dynamic_query(),"assoc",$link);	//rilascia un array con il risultato della query eseguita
	$query_array = $Qr-> result;
	db_close($link);
	$tm = new TemplateManager;
	echo $tm->make_dynamic_template($template_name,$_REQUEST['resource'].'.tpl',$_REQUEST['resource'].'.xml',$query_array);
  }else if ($_REQUEST['type']== "static_tpl"){
  	//se il template è un template statico inserito nella directory static
	$aj -> set_type("static_tpl");
	$file2open = $template_directory.$template_name."/static/".$aj -> send_response();	//usa il link al file indicato in ajax_xml_file
  	if (!($fp = fopen ($file2open, "r"))) {
	 	print ($this->error->print_error('file2open_collector_error'));
  	}else {
		$readed_info = fread ($fp,filesize($file2open));
		echo $readed_info;
		fclose ($fp);
  	}

  }else if ($_REQUEST['type']== "static_html"){
  	//se il file da caricare è una pagina html o php

  	// ============= AGGIUSTARE ===================

	$aj -> set_type("static_html");
	$file2open = $url.$aj -> send_response();	//usa il link al file indicato in ajax_xml_file
  	if ($file2open=="") {
	 	print ($this->error->print_error('file2open_collector_error'));
  	}else {
		echo "<iframe src='".$file2open."' frameborder=\"no\" width=\"100%\" height=\"300\"></iframe>";
		//echo "<script>if (window!=top){div[\"content\"]=$file2open;}</script>";
  	}
  }
?>
Return current item: PXAServer