-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathemail.php
executable file
·47 lines (35 loc) · 975 Bytes
/
email.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
error_reporting(E_ALL | E_STRICT);
ini_set('display_errors',1);
include('config.php');
try
{
$email = trim($_POST['email']);
if(!preg_match('/[A-Za-z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}/',$email))
{
throw new Exception('Invalid Email');
}
$store = $_POST['store'];
if(empty($store))
{
$store = '';
}
$sqlite_db = new PDO('sqlite:'.DB_PATH,DB_USER,DB_PASS);
$insert = "REPLACE INTO emails (id, customer_email, store_name, ip, time)
VALUES (:id, :customer_email, :store_name, :ip, :time)";
$upsert =$sqlite_db->prepare($insert);
$upsert->execute(
array(
':id' => null,
':customer_email' => $email,
':store_name' => $store,
':ip' => $_SERVER['REMOTE_ADDR'],
':time' => date('Y-m-d H:i:s',time())
)
);
echo "done";
}
catch(Exception $e)
{
echo 'Error: '.$e->getMessage();
}