<?php require_once('includes/requirelogin.inc.php'); require_once('includes/requirepost.inc.php'); $action=TPOST('action'); $login=TPOST('login'); $mb_id=current_mb_id(); if ($_SESSION['uniwits.member.pseudo.action']!=$action) { header("Location: return"); return; } $_SESSION['uniwits.member.pseudo.result']=null; $errorareas=array(); if ($action=='new') { $errorareas=iif_array4(array( array(!$login,'ERROR-LOGIN-INVALID',array(0)) )); if (count_true_entries($errorareas)==0) { $DBConn->connect(false); $DBConn->begin(true); $org_login=db_load_login($DBConn,$mb_id); $org_member=db_load_member($DBConn,$mb_id); $org_member_info=db_load_member_info($DBConn,$mb_id); $org_member_emails=db_load_member_emails($DBConn,$mb_id,false); $org_member_phones=db_load_member_phones($DBConn,$mb_id,false); try { $alias_login=$org_login; $alias_login['mb_login']=$login; $mb_id_alias=db_insert_login($DBConn,$alias_login); } catch (Exception $e) { $DBConn->rollback(); $errorareas['ERROR-LOGIN-EXISTS']=array(0); } if ($mb_id_alias) { db_set_member($DBConn,$mb_id_alias,$org_member); db_set_member_info($DBConn,$mb_id_alias,$org_member_info); db_set_member_emails($DBConn,$mb_id_alias,array_projection($org_member_emails,'mb_email')); db_set_member_phones($DBConn,$mb_id_alias,array_projection($org_member_phones,'mb_phone')); $vemails=array(); foreach ($org_member_emails as $e) { if ($e['me_status']=='VALIDATED') array_push($vemails,$e['mb_email']); if ($e['me_notify']) db_set_member_notifying_email($DBConn,$mb_id_alias,$e['mb_email']); } db_validate_member_email($DBConn,$mb_id_alias,$vemails); db_record_login_alias($DBConn,$mb_id,$mb_id_alias); $DBConn->commit(); $_SESSION['uniwits.member.pseudo.result']=array($mb_id_alias); } } if (count_true_entries($errorareas)>0) { $_SESSION['uniwits.inputcache.domain']='member.pseudo'; $_SESSION['uniwits.inputcache.errorareas']=$errorareas; $_SESSION['uniwits.inputcache.data']=array('login'=>$login); header("Location: member.pseudo?action=new&op=revise"); } else { $_SESSION['uniwits.member.pseudo.action']=null; purge_array_by_key_prefix($_SESSION,'uniwits.inputcache.'); header("Location: return"); } } ?>