1<?php
2
3if (empty($_SESSION['last_addemail'])) {
4    $_SESSION['last_addemail'] = 0;
5}
6if (!defined('PHPLISTINIT')) {
7    die();
8}
9verifyCsrfGetToken();
10
11if (!empty($_GET['email'])) {
12    $delay = time() - $_SESSION['last_addemail'];
13    if (!validateEmail($_GET['email'])) {
14        $status = s('That is not a valid email address');
15    } elseif ($delay > ADD_EMAIL_THROTTLE) {
16        $_SESSION['last_addemail'] = time();
17        Sql_Query(sprintf('insert into %s (email,uniqid,htmlemail,entered,uuid) values("%s","%s",1,now(),"%s")',
18            $GLOBALS['tables']['user'], sql_escape($_GET['email']), getUniqid(), (string) uuid::generate(4)), 1);
19        addUserHistory($_GET['email'], s('Added by %s', adminName()), s('Added with add-email on test'));
20        $status = s('Email address added');
21    } else {
22        // pluginsCall('processError','Error adding email address, throttled');
23        foreach ($GLOBALS['plugins'] as $plname => $plugin) {
24            $plugin->processError('Add email throttled '.$delay);
25        }
26        $status = s('Adding email address failed, try again later');
27    }
28}
29