forked from nodesman/wp-autoresponder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubscriber.lib.php
82 lines (64 loc) · 1.72 KB
/
subscriber.lib.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
function _wpr_subscriber_get($id)
{
global $wpdb;
$query = "SELECT * FROM ".$wpdb->prefix."wpr_subscribers where id=$id";
$result = $wpdb->get_results($query);
if (count($result)>0)
{
return $result[0];
}
else
{
return false;
}
}
function _wpr_subscription_status($active, $confirmed)
{
if ($active == 1 && $confirmed== 1)
return __("Subscribed",'wpr_autoresponder');
if ($active == 1 && $confirmed== 0)
return __("Subscribed and Unconfirmed",'wpr_autoresponder');
if ($active == 0 && $confirmed== 1)
return __("Unsubscribed",'wpr_autoresponder');
if ($active == 2 && $confirmed==1)
return __("Transfered",'wpr_autoresponder');
if ($active == 3)
return __("Disabled Due To Delivery Problems",'wpr_autoresponder');
}
/*
nid,
name,
email,
fid,
date,
hash,
*/
function _wpr_subsciber_add_confirmed($params)
{
global $wpdb;
$nid = $params['nid'];
$name = $params['name'];
$email = $params['email'];
$fid = ($params['fid'])?$params['fid']:0;
$date = ($params['date'])?$params['date']:time();
$hash = ($params['hash'])?$params['hash']:generateSubscriberHash();
$query = "INSERT INTO ".$wpdb->prefix."wpr_subscribers (nid, name, email, fid, date, hash,active, confirmed) values ('$nid','$name','$email','$fid','$date','$hash',1,1);";
$wpdb->query($query);
return $wpdb->insert_id;
}
function generateSubscriberHash()
{
for ($i=0;$i<6;$i++)
{
$a[] = rand(65,90);
$a[] = rand(97,123);
$a[] = rand(48,57);
$whichone = rand(0,2);
$currentCharacter = chr($a[$whichone]);
$hash .= $currentCharacter;
unset($a);
}
$hash .= time();
return $hash;
}