Ejemplo n.º 1
0
    print $cached_output;
    exit;
}
$modin = isset($_REQUEST['modin']) && $_REQUEST['modin'] ? intval($_REQUEST['modin']) : false;
// Fetch the form instance specified by submitted modin value.
$udm = new UserDataInput($dbcon, $modin);
if (!$udm->isLive()) {
    ampredirect(AMP_CONTENT_URL_INDEX);
    exit;
}
// User ID.
$uid = isset($_REQUEST['uid']) ? intval($_REQUEST['uid']) : false;
$otp = isset($_REQUEST['otp']) ? $_REQUEST['otp'] : null;
// Check for duplicates, setting $uid if found.
if (!$uid) {
    $uid = $udm->findDuplicates();
}
// Check for authentication, sending authentication mail if necessary.
if ($uid) {
    // Set authentication token if uid present
    $auth = $udm->authenticate($uid, $otp);
}
// Fetch or save user data.
if ((!$uid || $auth) && $udm->submitted) {
    // Save only if submitted data is present, and the user is
    // authenticated, or if the submission is anonymous (i.e., !$uid)
    $udm->saveUser();
} elseif ($uid && $auth && !$udm->submitted) {
    // Fetch the user data for $uid if there is no submitted data
    // and the user is authenticated.
    $udm->getUser($uid);