Salve a tutti ,
Non so perche questa applicazione debba farmi girare le @@ Cmq ecco il problema :
mi restituisce questo errore cosa che controllando e ricontrollando non dovrebbe fare :
Allora postando un po di codice per schiarire le idee :Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\b2bnext_1.0\includes\classes\ClassMySql .php:1) in C:\Inetpub\b2bnext_1.0\login.php on line 59
Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\b2bnext_1.0\includes\classes\ClassMySql .php:1) in C:\Inetpub\b2bnext_1.0\login.php on line 60
File login.php
File common.php<?php
// ####################### CARICO IL FILE DI BASE #############################
require('includes/common.php'); // Vedi piu in fondo
// ####################### CONTROLLO LO STATO DELL'UTENTE #####################
list($_STATUS_, $_USER_INFO_) = $Auth->auth_get_status();
if($_STATUS_ == AUTH_NOT_LOGGED){
$uname = strtolower(trim(b2b_eregi($_POST['user'])));
$passw = b2b_eregi($_POST['password']);
if($uname == "" or $passw == ""){
$_STATUS_ = AUTH_INVALID_PARAMS;
}else{
list($_STATUS_, $_USER_INFO_) = $Auth->auth_login($uname, $passw);
if(!is_null($_USER_INFO_)){
list($_STATUS_, $_UID_) = $Auth->auth_register_session($_USER_INFO_);
}
}
}
switch($_STATUS_){
case AUTH_LOGGED:
header("Refresh: 0;URL=index.php");
break;
case AUTH_INVALID_PARAMS:
header("Refresh: 0;URL=index.php");
break;
case AUTH_LOGEDD_IN:
switch($Auth->auth_get_option("TRANSICTION METHOD")){
case AUTH_USE_LINK:
header("Refresh: 0;URL=index.php?uid=".$_UID_);
break;
case AUTH_USE_COOKIE:
// ############## RIGHA 59
setcookie('uid', $_UID_, time()+_SESSION_TIME_*365);
// ############## RIGHA 60
header("Refresh: 0;URL=index.php");
break;
case AUTH_USE_SESSION:
$_SESSION['uid'] = $_UID_;
header("Refresh: 0;URL=index.php");
break;
}
break;
case AUTH_FAILED:
header("Refresh: 0;URL=index.php");
break;
}
?>
File ClassMySql.php<?php
if (eregi("common.php",$_SERVER['PHP_SELF'])) {
die("Non potete accedere direttamente a questo file");
}
else{
// ############# //
// INIZIO FILE //
// ############# //
// ##################### FILE CONFIGURAZIONE DI BASE ###################
require('includes/default.configuration.php');
// ##################### FILE DELLA LINGUA #############################
require('language/lang_it.php');
// ##################### CARICO LE CLASSI #############################
require('includes/classes/ClassMySql.php');
require('includes/classes/ClassAccount.php');
// ##################### CARICO LE LIBRERIE #############################
require('includes/library/function.lib.php');
// ##################### ISTANZIO GLI OGGETTI ##########################
$MySql = new ClassMySql(_DATABASE_,_USERDB_,_PWD_,_DBNAME_);
$Auth = new ClassAccount();
// ########### //
// FINE FILE //
// ########### //
}
?>
File ClassAccount.php<?php
if (eregi("ClassMySql.php",$_SERVER['PHP_SELF'])) {
die("Non potete accedere direttamente a questo file");
}
else{
// ############# //
// INIZIO FILE //
// ############# //
class ClassMySql {
// ############### //
// INIZIO CLASSE //
// ############### //
var $id_connect;
var $query_result;
var $row = array();
function ClassMySql($server, $user, $password, $database)
{
$this->user = $user;
$this->password = $password;
$this->server = $server;
$this->dbname = $database;
$this->id_connect = mysql_connect($this->server, $this->user, $this->password);
if( $this->id_connect )
{
if( $database != "" )
{
$this->dbname = $database;
$dbselect = mysql_select_db($this->dbname);
if( !$dbselect )
{
mysql_close($this->id_connect);
$this->id_connect = $dbselect;
}
}
return $this->id_connect;
}
else
{
return false;
}
}
function SqlClose()
{
if( $this->id_connect )
{
return mysql_close($this->id_connect);
}
else
{
return false;
}
}
function SqlQuery($query = "")
{
unset($this->query_result);
if( $query != "" )
{
$this->query_result = mysql_query($query, $this->id_connect);
}
else
{
return false;
}
return $this->query_result;
}
function SqlFetchArray($query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
if( $query_id )
{
$this->row[$query_id] = mysql_fetch_array($query_id, MYSQL_ASSOC);
return $this->row[$query_id];
}
else
{
return false;
}
}
function SqlFetchAssoc($query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
if( $query_id )
{
$this->row[$query_id] = mysql_fetch_assoc($query_id);
return $this->row[$query_id];
}
else
{
return false;
}
}
function SqlNumRows($query_id = 0)
{
if( !$query_id )
{
$query_id = $this->query_result;
}
return ( $query_id ) ? mysql_num_rows($query_id) : false;
}
function SqlInsertId()
{
return mysql_insert_id();
}
// ############# //
// FINE CLASSE //
// ############# //
}
// ########### //
// FINE FILE //
// ########### //
}
?>
<?php
if (eregi("ClassAccount.php",$_SERVER['PHP_SELF'])) {
die("Non potete accedere direttamente a questo file");
}
else{
// ############# //
// INIZIO FILE //
// ############# //
class ClassAccount{
// ############### //
// INIZIO CLASSE //
// ############### //
// Determina come passare il valore delle sessioni
var $_AUTH = array();
function ClassAccount(){
// Vedi default.configuration.php
// Setto il tipo di passaggio
$this->_AUTH["TRANSICTION METHOD"] = _TRANSACTION_METHOD_;
}
function auth_get_option($opt_name){
// Recupero il tipo di passaggio
return is_null($this->_AUTH[$opt_name]) ? NULL : $this->_AUTH[$opt_name];
}
function auth_get_uid(){
// Setto l'id a nullo per assicurarmi che venga recuperato quello corretto
$uid = NULL;
// Controllo come passare l'id
switch($this->auth_get_option("TRANSICTION METHOD")){
// Se uso i cookie
case AUTH_USE_COOKIE:
global $_COOKIE;
$uid = $_COOKIE['uid'];
break;
// Se uso le sessioni
case AUTH_USE_SESSION:
global $_SESSION;
$uid = $_SESSION['uid'];
break;
// Se uso la querystring tramite link
case AUTH_USE_LINK:
global $_GET;
$uid = $_GET['uid'];
break;
}
// ritorno il valore trovato
return $uid ? $uid : NULL;
}
function auth_clean_expired(){
global $MySql;
// Recupero l'id
$uid = $this->auth_get_uid();
// Cerco se nel DB esiste una sessione per l'id recuperato
$result = $MySql->SqlQuery("SELECT creation_date FROM b2b_sessioni WHERE uid='".$uid."'");
if($result){
// Se trovato recupero le info
$data = $MySql->SqlFetchArray($result);
if($data['creation_date']){
// Controllo che non sia scaduta
if($data['creation_date'] + _SESSION_GC_TIME_ <= time()){
switch($this->auth_get_option("TRANSICTION METHOD")){
// Caso con passaggio cookie
case AUTH_USE_COOKIE:
setcookie('uid');
break;
// Caso con passaggio sessioni
case AUTH_USE_SESSION:
$_SESSION['uid'] = NULL;
break;
// Caso con passaggio link
case AUTH_USE_LINK:
global $_GET;
$_GET['uid'] = NULL;
break;
}
}
}
}
$MySql->SqlQuery("
DELETE FROM b2b_carrello_temp
WHERE creation_date + "._SESSION_GC_TIME_." <= ".time()
);
$MySql->SqlQuery("
DELETE FROM b2b_sessioni
WHERE creation_date + "._SESSION_GC_TIME_." <= ".time()
);
}
function auth_get_status(){
global $MySql;
// Recupero l'id
$uid = $this->auth_get_uid();
// Se l'id esiste aggiorno le sessione evitando che scadano
if($uid != NULL){
$result = $MySql->SqlQuery("UPDATE b2b_sessioni
SET creation_date='" . time() . "' WHERE uid = '".$uid."'");
$result = $MySql->SqlQuery("UPDATE b2b_carrello_temp
SET creation_date='" . time() . "' WHERE id_sessione = '".$uid."'");
}
// Avvio la procedura per cancellare le sessioni scadute
$this->auth_clean_expired();
if(is_null($uid)){
// Se nullo allora ritorno AUTH_NOT_LOGGED
return array(100, NULL);
}else{
// Altrimenti cerco nel db l'id
$result = $MySql->SqlQuery("SELECT *
FROM b2b_sessioni S,b2b_account U
WHERE S.user_id = U.id_account and S.uid = '".$uid."'");
$num = $MySql->SqlNumRows($result);
if($num != 1){
// Se non trovato allora passo AUTH_NOT_LOGGED
return array(100, NULL);
}else{
// Se ttrovato passo AUTH_LOGGED e le info dell'account
$user_data = $MySql->SqlFetchAssoc($result);
return array(99, array_merge($user_data, array('uid' => $uid)));
}
}
}
function auth_login($uname, $passw){
global $MySql;
// Controllo nel DB se esiste un REC con i val passati
$result = $MySql->SqlQuery("SELECT * FROM b2b_account WHERE user='".$uname."' and pwd=MD5('".$passw."')");
// Controllo che esista un risultato
$num = $MySql->SqlNumRows($result);
if($num != 1){
// Se non esiste passo AUTH_INVALID_PARAMS
return array(104, NULL);
}else{
// Se esiste passo AUTH_LOGEDD_IN
$data = $MySql->SqlFetchArray($result);
return array(105, $data);
}
}
function auth_generate_uid(){
// Genero un'id casuale
list($usec, $sec) = explode(' ', microtime());
mt_srand((float) $sec + ((float) $usec * 100000));
// Restituisco l'id
return md5(uniqid(mt_rand(), true));
}
function auth_register_session($udata){
global $MySql;
// Genero l'id
$uid = $this->auth_generate_uid();
// Carico la sessione nel DB
$id_query = $MySql->SqlQuery("INSERT INTO b2b_sessioni (uid, user_id, creation_date) VALUES ('".$uid."', '".$udata['id_account']."', ". time().")");
// Controllo che sia stato effettuato un'inserimento
$UidInsert = $MySql->SqlInsertId();
if(isset($UidInsert) || $UidInsert != 0 || $UidInsert != NULL){
return array(105, $uid);
}else{
return array(106, NULL);
}
}
function auth_logout(){
global $MySql;
// Recupero l'id
$uid = $this->auth_get_uid();
if(is_null($uid)){
// Se gia nullo allora niente
return false;
}else{
// Cancello la sessione dal DB
$result = $MySql->SqlQuery("DELETE FROM b2b_sessioni WHERE uid = '".$uid."'");
// Cancello il carrello per quella sessione
$result = $MySql->SqlQuery("DELETE FROM b2b_carrello_temp WHERE id_sessione ='" . $uid . "'");
return true;
}
}
// ############# //
// FINE CLASSE //
// ############# //
}
// ########### //
// FINE FILE //
// ########### //
}