<?php

if (isset($_REQUEST['submit'])) {
    // dati inviati, cerco l'utente
    $whereiam = "userexport";
    require_once "lib/lib.php";
    $rawpasswd = pack("H*", md5($_REQUEST['passwd']));
    $identificatore = md5($rawpasswd . $_REQUEST['nick']);
    $userdata = $db->get_row("SELECT * from {$SNAME}_LOCALMEMBER WHERE HASH='{$identificatore}'");
    if ($userdata) {
        if ($_REQUEST['B_Export']) {
            UserExport($userdata);
        }
    } else {
        // dati inviati, ma utente non trovato
        $whereiam = "userexport";
        include "testa.php";
        $lang += $std->load_lang('lang_userexport', $blanguage);
        ShowForm();
        echo "<center><b>user not found !!!</b></center>";
        include "end.php";
    }
} else {
    // dati non inviati, prima visualizzazione del form
    $whereiam = "userexport";
    include "testa.php";
    $lang += $std->load_lang('lang_userexport', $blanguage);
    ShowForm();
    include "end.php";
}
// il form di input
     if ($_POST['exp_password']) {
         if (pack('H*', md5($_POST['exp_password'])) != $_SESSION[$SNAME]['sess_password']) {
             $std->Error('La password inserita non รจ corretta');
         }
     }
     //Preparazione dati da esportare
     $export['NICK'] = $_SESSION[$SNAME]['sess_nick'];
     $export['PWD'] = $_POST['exp_password'] ? $_POST['exp_password'] : '';
     if ($_POST['exp_settings'] == 1) {
         $export += get_object_vars($userdata);
         unset($export['IS_AUTH']);
         //Importante... in fase di import non importare anche is_auth
     }
     $export['PASSWORD'] = $userdata->PASSWORD;
     //Obbligatorio
     UserExport($export);
     exit;
     break;
 case 'convert_account':
     //Controllo dati
     if (!$userdata) {
         $std->Error("Impossibile Esportare, Utente non loggatoCome diavolo ci sei finito qui?");
     }
     $privkey = base64_decode($userdata->PASSWORD);
     $KEY_DECRYPT = pack('H*', md5($_SESSION[$SNAME]['sess_nick'] . $_SESSION[$SNAME]['sess_password']));
     // = password per decriptare la chiave privata in localmember (16byte)
     $req[FUNC][BlowDump2var][Key] = $KEY_DECRYPT;
     $req[FUNC][BlowDump2var][Data] = $privkey;
     if (!$core) {
         $core = new CoreSock();
     }