<?
############################################################################
# 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.
############################################################################
/*
Libreria di funzioni
Guerrieri Luca hide@address.com
*/
$_C_MSGmanager = true;
$_C_HTMLmanager= true;
$_C_DBconnect= true;
$_C_TemplateManager= true;
$_C_Ajax= true;
$_C_QueryResult= true;
$_C_QueryManager= true;
$_C_Session = true;
$_C_Autentica = true;
$_C_LOGmanager = true;
require ("global.inc.php");
function header_html_simple($html_title='html_title',$html_body='html_body'){
/*
*Funzione che crea l'header di una pagina html semplice senza importare nulla
*/
$Html= new HTMLmanager;
$Html->set_html_header('simple_html_header');
$Html->set_html_title($html_title);
$Html->set_html_body($html_body);
print $Html->get_html_header();
}
function footer_html_standard(){
/*
* Funzione che restituisce il footer di una pagina html
*/
$Html= new HTMLmanager;
print $Html->get_html_footer('html_footer');
}
function header_html_full($html_title='html_title',$html_css='html_css',$print_css='print_css',$jscript,$ajax_javascript,$html_body='html_body'){
/*
* Funzione che restituisce un header html completo di import
* come javascript, stylesheet stampa e schermo
*/
$Html= new HTMLmanager;
$Html->set_html_header('complete_html_header');
$Html->set_html_title($html_title);
$Html->set_html_stylesheet($html_css);
$Html->set_print_stylesheet($print_css);
$Html->set_javascript($jscript);
$Html->set_ajax($ajax_javascript);
$Html->set_html_body($html_body);
print $Html->get_html_header();
}
function db_connect(){
/*
* Funzione che usiamo per connetterci al database
*/
//si connette al db
require ('config.inc.php');
$db = new DBconnect;
$db ->db_type=$dbtype;
$db ->db_param($dbserver,$dbusername,$dbpassword,$dbdatabase);
return $link=$db ->open();
}
function db_close($link){
/*
* Funzione che usiamo per chiudere la connessione al database
*/
//non usa la classe db perchè cambia la risorsa link alla quale punta
mysql_close($link);
return true;
}
function make_static_template_page ($template_name,$template_file,$data){
//Nome_template nome_file.tpl nome_file.xml
/*
* Funzione per l'interpretazione di template per la visualizzazione di
* contenuti statici (provenienti da soli file xml)
* $template_name: nome del template
* $template_file: file che contiene il modello file.tpl
* $data: file che contiene i placeholders ed i dati in un file.xml
*/
$error= new MSGmanager;
$Tm=new TemplateManager;
//Controlla che $template sia passato correttamente
if ((is_null($template_name))||(is_null($template_file))||(is_null($data))){
print ($this->error->print_error('libfunz_make_static_template_passed_error')); ###RICORDATI DI INSERIRE L'ERRORE
}else {
print $Tm->make_static_template($template_name,$template_file,$data);
}
}
function make_dynamic_template_page ($template_name,$template_file,$placeholders_file,$data){
/*
* Funzione per l'interpretazione di template per la visualizzazione di
* contenuti dinamici (provenienti da DataBase)
* $template_name: nome del template
* $template_file: file che contiene il modello file.tpl
* $placeholders_file: file che contiene i placeholders file.xml
* $data: array che contiene i dati da visualizzare es. Array(Array("username" => "luca","password" =>"password","level"=>"1","status" =>"1");
*/
$error = new MSGmanager;
$Tm=new TemplateManager;
//Controlla che $template sia passato correttamente
if ((is_null($template_name))||(is_null($template_file))||(is_null($placeholders_file))||(is_null($data))){
print ($this->error->print_error('libfunz_make_dynamic_template_passed_error'));
}else {
print $Tm->make_dynamic_template($template_name,$template_file,$placeholders_file,$data);
}
}
function make_ajax_dynamic_template_page ($template_name,$template_file,$placeholders_file,$data){
/*
* Funzione per l'interpretazione di template per la visualizzazione di
* contenuti dinamici (provenienti da DataBase)
* $template_name: nome del template
* $template_file: file che contiene il modello file.tpl
* $placeholders_file: file che contiene i placeholders file.xml
* $data: array che contiene i dati da visualizzare es. Array(Array("username" => "luca","password" =>"password","level"=>"1","status" =>"1"));
*/
$error = new MSGmanager;
$Tm=new TemplateManager;
//Controlla che $template sia passato correttamente
if ((is_null($template_name))||(is_null($template_file))||(is_null($placeholders_file))||(is_null($data))){
print ($this->error->print_error('libfunz_make_dynamic_template_passed_error'));
}else {
print $Tm->make_dynamic_template($template_name,$template_file,$placeholders_file,$data);
}
}
function perform_login ($username,$password, $login){
/*
* Funzione per effettuare il login
* $username: username dell'utente
* $password: password dell'utente
* $login: stringa criptata in MD5 del login che contiene
* username + password + captcha
*/
$aut = new Autentica;
$aut -> login($username,$password,$login);
return $aut -> login_result();
}
function register_user ($username, $password){
/*
* Funzione per registrare un nuovo utente
* $username
* $password
* inserisco l'utente lo imposto a livello "guest" e gli mando una email per conferma ed abilitazione
*/
}
function remember_password ($username){
/*
* Funzione per ricordare la password
* $username
* invia ad una email la domanda segreta e se la risposta è giusta
* resetto la password mettendone una nuova
*/
}
function set_user_space ($username){
/*
* Funzione per impostare lo user space dell'utente
* - file di log
* - altre cose
*/
}
function login_session_control(){
// da inserire prima di tutto!!!!
/*
* Funzione per controllare se è stato effettuato il login
*/
//if(session_id() == "") { session_start(); }
require ('config.inc.php');
$s = new Session;
$s -> init_session();
if (($s -> get_session_value("login")== null)|| ($s -> get_session_value("login")!="success")){
header("Location:".$login_page);
//print("<script>window.location='".$login_page."'</script>");
}else {
$s -> regenerate_session();
}
}
?>