summaryrefslogtreecommitdiff
path: root/site_static/lib/functions.php
diff options
context:
space:
mode:
Diffstat (limited to 'site_static/lib/functions.php')
-rw-r--r--site_static/lib/functions.php45
1 files changed, 45 insertions, 0 deletions
diff --git a/site_static/lib/functions.php b/site_static/lib/functions.php
new file mode 100644
index 0000000..061ec12
--- /dev/null
+++ b/site_static/lib/functions.php
@@ -0,0 +1,45 @@
+<?php
+include('db.php');
+function checkEmail($email) {
+$db = opendb();
+$sql = "select email from email where email='".$email."';";
+$res = mysql_fetch_array(mysql_query($sql));
+if($res){
+closedb($db);
+return 0;
+}
+ if(preg_match("/^([a-zA-Z0-9])+([a-zA-Z0-9\._-])*@([a-zA-Z0-9_-])+([a-zA-Z0-9\._-]+)+$/" , $email)){
+ list($username,$domain) = split('@', $email);
+ if(!checkdnsrr($domain,'MX')){
+ closedb($db);
+ return false;
+ }
+ closedb($db);
+ return true;
+ }
+ closedb($db);
+ return false;
+}
+
+function addEmail($email, $ip) {
+$db = opendb();
+$sql = "insert into email (email, ip, date) values
+ ('".$email."', '".$ip."', '".date('Y-m-d')."')";
+mysql_query($sql);
+closedb($db);
+}
+
+function checkIP($ip) {
+$db = opendb();
+$today = date('Y-m-d');
+$sql = "select count(id) from email where ip='".$ip."' and date='".$today."';";
+$res = mysql_fetch_array(mysql_query($sql));
+
+if($res and $res[0] >= 100){
+ closedb($db);
+ return 0;
+}
+closedb($db);
+return 1;
+}
+?>