Blame view

ajax/subscribe_email.php 1.07 KB
42868d70   andryeyev   Создал GIT
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
  <?php
      header("Content-type: text/html; charset=windows-1251");
      require("../libs/setup.php");
  	include_once($_SERVER['DOCUMENT_ROOT']."/account/func/func.php");
  	include_once($_SERVER['DOCUMENT_ROOT']."/account/func/func.eMailing.php");	
  
      $setup = new setup();
  	
  	$email = trim($_GET['email']);
  	$name = trim($_GET['name']);
  	
  	if( !preg_match("/^([^@]+)+@([^@]+)\.([^@]+)$/i",$email) || strlen($email)>80 ) {print'email_error';exit;}
  	if( !preg_match("/.{1,200}/i",$name) ) {print'email_name';exit;}
  	
  	
  	if($setup->db->getOne('select id from zlo_users where email=?',array($email)))
  		print 1;
  	else{ 
  		$pass=generate_password(6);
  		$fields_values = array(
  								'username' => $name,
  								'pass' => $pass,
  								'send' => 1,
  								'email' => $email,
  								'hash' => md5($email . "_extremstyle.ua"),
  								);	
  		$setup->db->autoExecute('zlo_users',$fields_values,DB_AUTOQUERY_INSERT);
  		$user_id = mysql_insert_id();
  		eMailing('remind', $user_id);
  		$_SESSION['user'] = array('id'=>$user_id,'login'=>$name,'pass'=>$pass,'name'=>$name,'email'=>$emailss);
  		print 0;
  
  	}	
  ?>