estrazione dati per login

_LAIL_

Utente Attivo
19 Set 2013
57
0
6
come da titolo dovrei utilizzare gli stessi dati di login del sito per una chat.
le tabelle sono due in una sono contenuti i dati id user e pass ed e questa jcre_users mentre in un altra ci sono le altre informazioni come sesso età ecc ed e questa jcre_k2_users.

Questo e il login della chat:
PHP:
<?php
include('lib.php');

$answer = AutoLogin();
header('Content-type: text/xml');
echo $answer;

function AutoLogin()
{
	global $users;

	# NOTE: you can`t use $_SESSION here,
	# because requests are sent by FMS and not by browser on user's side.
    $uid = GetParam('uid');
    if (!$uid)
    {
       return "<invalidParams/>";
    }
	// replace with your custom logic

	$num = count($users);
	$user = null;

	for($i = 0; $i < $num; $i++)
	{
		$u = $users[$i];
		if(md5($u['id'].$u['userName'].$u['password']) == $uid)
		{
			$user = $u;
			break;
		}
	}

	if($user) return ParseUserData($user);
	else return '<login result="FAIL" error="error_authentication_failed"/>';
}
?>


Questo e il file lib


PHP:
<?php

define('MALE', 0);
define('FEMALE', 1);

define('ROOT', 'http://www.miosito.net/videochat/');

// Pre-created user accounts

jcre_users


$users = array(
	array('id' => 'admin',
		'userName' => 'admin',
		'password' => 'test',
		'gender' => MALE,
		'location' => 'London, UK',
		'age' => 35,
		'details' => 'Hello, I am Admin'),
	array('id' => '1',
		'userName' => 'David',
		'password' => 'test',
		'gender' => MALE,
		'location' => 'London, UK',
		'age' => 22,
		'details' => 'Hello, I am David'),
	array('id' => '2',
		'userName' => 'Amanda',
		'password' => 'test',
		'gender' => FEMALE,
		'location' => 'Los Angeles, California',
		'age' => 19,
		'details' => 'Hello, I am Amanda'),
	array('id' => '3',
		'userName' => 'Steven',
		'password' => 'test',
		'gender' => MALE,
		'location' => 'Sun Valley, Nevada',
		'age' => 31,
		'details' => 'Hello, I am Steven'),
	array('id' => '4',
		'userName' => 'Helen',
		'password' => 'test',
		'gender' => FEMALE,
		'location' => 'New York, US',
		'age' => 25,
		'details' => 'Hello, I am Helen'),
	array('id' => '5',
		'userName' => 'mod',
		'password' => 'mod',
		'gender' => FEMALE,
		'location' => 'London, UK',
		'age' => 30,
		'details' => 'Hello, I am Moderator'),
);

function ParseUserData($user, $getProfile = false)
{
	global $users;

	$res = "<login result=\"OK\">";
	$res .= '<userData>'.GetUser($user).'</userData>';
	/*$res .= '<friends>';
	for($i = 1; $i < 40; $i++)
	{
		$u = $users[4];
		$u['id'] = $i;
		$res .= '<friend>'.GetUser($u).'</friend>';
	}
	$res .= '</friends>';
	$res .= '<blocks>';
	for($i = 0; $i < 40; $i++)
	{
		$u = $users[4];
		$u['id'] = $i;
		$res .= '<block>'.GetUser($u).'</block>';
	}
	$res .= '</blocks>';*/
    if (!$getProfile)
    {
	$res .= '<friends>'
    .'<friend id = "'.$users[2]['id'].'" name = "'.$users[2]['userName'].'" thumbnail = "'.ROOT.'photos/'.$users[2]['id'].'_small.png'.'"/>'
    .'<friend id = "'.$users[3]['id'].'" name = "'.$users[3]['userName'].'" thumbnail = "'.ROOT.'photos/'.$users[3]['id'].'_small.png'.'"/>'
    .'</friends>';
    $res .= '<blocks>'
    .'<block id = "'.$users[4]['id'].'" name = "'.$users[4]['userName'].'" thumbnail = "'.ROOT.'photos/'.$users[4]['id'].'_small.png'.'"/>'
    .'</blocks>';
    $res .= '<additionalData>'.GetAdditionalData($user).'</additionalData>';
    }
	$res .= "</login>";

	return $res;
}

function GetUser($user)
{
	if(!isset($user['photo'])) $user['photo'] = ROOT.'photos/'.$user['id'].'_big.png';
	if(!isset($user['thumbnail']) ) $user['thumbnail'] = ROOT.'photos/'.$user['id'].'_small.png';
	if(!isset($user['level']) ) $user['level'] = 'regular';

	if($user['id'] == '3')
	{
		$user['photo'] = '';
		$user['thumbnail'] = '';
	}

	return <<<USER_DATA
<id>${user['id']}</id>
<name><![CDATA[${user['userName']}]]></name>
<gender>${user['gender']}</gender>
<location>${user['location']}</location>
<age>${user['age']}</age>
<photo>${user['photo']}</photo>
<thumbnail>${user['thumbnail']}</thumbnail>
<details>${user['details']}</details>
<level>${user['level']}</level>
<profileUrl><![CDATA[http://localhost/${user['userName']}]]></profileUrl>
USER_DATA;
}

function GetAdditionalData($user)
{
	$res = '';
	if($user['id'] == '1')
	{
		$res.= "<imgateway>";
		$res.= "<icq login='634427950' password='111111'/>";
		$res.= "<yahoo login='moshagosha' password='111111'/>";
		$res.= "<msn login='[email protected]' password='111111'/>";
		$res.= "</imgateway>";
	}
	return $res;
}

function GetParam($name, $default = '')
{
	if(isset($_POST[$name])) return $_POST[$name];
	if(isset($_GET[$name])) return $_GET[$name];
	return $default;
}

function trace($message, $isWriteLog = true)
{
    $content = print_r($message, true);
    if($isWriteLog)
    {
        $handle = @fopen('./log.txt', 'a');
        @fwrite($handle, date('Y-m-d H:i:s')."\r\n".$content."\r\n\r\n");
        @fclose($handle);
    }
    else echo '<pre>'.$content.'</pre><br>';
}

?>
 
Discussioni simili
Autore Titolo Forum Risposte Data
T Codice per estrazione dati da db PHP 4
L Estrazione dati per settimana. PHP 13
A [risolto] Istruzione per estrazione di dati casuali dal db PHP 25
E Progressbar estrazione dati da tabella mySQL Ajax 9
L Estrazione dati php Database 6
L Estrazione dati casuali non doppioni MySQL 1
D Chiave unica in estrazione dati da array php PHP 0
ronny1710 Estrazione Dati Tessera Sanitaria .NET Framework 1
creatorweb [PHP] estrazione ciclica dati con 2 dati alla volta PHP 2
Gigi87 [PHP] Estrazione dati da forum o da social network PHP 1
L estrazione dati da mysql in php e salvataggio in cartella del server PHP 51
E [PHP] estrazione dati in modo non continuativo PHP 1
C Estrazione Dati da Pagine Gialle PHP 0
A Estrazione dati da tabella sql MySQL 27
W Estrazione dati da DB PHP 20
L estrazione dati e immagini in contemporanea PHP 4
M estrazione dati casuali da database Database 0
C [PHP][MY SQL] - Estrazione dati database tramite form PHP 8
G estrazione dati da DB tramite PHP errore time out PHP 2
B Estrazione dati utente loggato MySQL 1
W Estrazione dati DB da lista MySQL 1
M Connessione Database ed estrazione dati Javascript 6
B Estrazione dati Classic ASP 3
U Estrazione dati da un db con un menu selezione in cascata PHP 6
Sargon estrazione dati PHP 17
A Estrazione dati da file.html PHP 8
G estrazione dati da xml ed inserimento in db PHP 0
P Menu a discesa con estrazione dati da datbase mysql PHP 21
M problema con estrazione dati da più tabelle MySQL 1
A problema: estrazione dati da query mysql e assegnazione ad una variabile PHP 2
L Estrazione dati PHP 32
M caratteri speciali ed estrazione dati Database 4
L Estrazione dati da 2 tabelle non relazionate Classic ASP 26
R Aiuto estrazione dati Database 0
G estrazione dati da più record in un solo nuovo campo Database 0
E Difficile estrazione dati da tabella PHP 3
K Estrazione di più risultati da tabelle correlate PHP 5
L Estrazione valori max su più campi MySQL 4
M [PHP] Estrazione random con nomi presi dal db PHP 22
gandalf1959 Estrazione e visualizzazione del simbolo dell'euro php/mysqli PHP 0
F Estrazione Email di persone selezionate e attive / facebook + invio di massa! Annunci servizi di Social Media Marketing 0
V Estrazione di una singola banda da file multi banda (RGB) con Python Programmazione 0
O [PHP] problema estrazione immagine da db PHP 12
V [PHP] Estrazione con SQL PHP 1
M [MS Access] Estrazione record multipli MS Access 1
S [PHP] estrazione dal DB complicata PHP 7
asevenx [Javascript] Estrazione dal database di un valore in base ad una scelta Javascript 7
S Php e mysql, estrazione da una tabella e inserimento in un'altra tabella PHP 14
P Probelma estrazione stringa PHP 5
L Estrazione Articoli Random da Tabella senza doppioni PHP 1

Discussioni simili