コード例 #1
0
ファイル: plugin.php プロジェクト: elizabethcb/Daily-Globe
function newsletter_save($subscriber)
{
    global $wpdb;
    $email = newsletter_normalize_email($email);
    $name = newsletter_normalize_name($name);
    $wpdb->query($wpdb->prepare("update " . $wpdb->prefix . "newsletter set email=%s, name=%s where id=%d", $subscriber['email'], $subscriber['name'], $subscriber['id']));
}
コード例 #2
0
ファイル: import.php プロジェクト: elizabethcb/Daily-Globe
$options = get_option('newsletter');
if ($action == 'import') {
    @set_time_limit(100000);
    $csv = stripslashes($_POST['csv']);
    $lines = explode("\n", $csv);
    $errors = array();
    foreach ($lines as $line) {
        $line = trim($line);
        if ($line == '') {
            continue;
        }
        if ($line[0] == '#') {
            continue;
        }
        $data = explode(';', $line);
        $email = newsletter_normalize_email($data[0]);
        if (!newsletter_is_email($email)) {
            $errors[] = $line;
            continue;
        }
        $name = newsletter_normalize_name($data[1]);
        $token = md5(rand());
        $r = $wpdb->query("insert into " . $wpdb->prefix . "newsletter (status, email, name, token) values ('C', '" . $wpdb->escape($email) . "','" . $wpdb->escape($name) . "','" . $token . "')");
        // Zero or false mean no row inserted
        if (!$r) {
            $errors[] = $line;
        }
    }
}
$nc = new NewsletterControls();
?>