'; echo $error.'

'; echo '
'; echo '
Имя *: 
Фамилия: 
Электронная почта*: 

'; echo ''; } //-------------------------------------------------------------------------------------------- function Add() { global $error; // Get user $first=stripslashes($_POST['f']); $last=stripslashes($_POST['l']); $email=stripslashes($_POST['Email']); // Make connect link $link = mysql_connect (MYSQLADDRESS,MYSQLUSER,MYSQLPW); mysql_select_db(DATABASENAME); // Check if email already subscribed $sql="SELECT COUNT(email) AS C FROM signups WHERE email='$email'"; $result = mysql_query($sql, $link) or die(mysql_error()); $line=mysql_fetch_array($result); $number = $line["C"]; if ($number>0) { $error = "Этот емайл (".$email.") уже был использован"; new_form(); exit; } else { $ip = $_SERVER['REMOTE_ADDR']; $ref1 = $_COOKIE['ref']; $id_secure = md5(uniqid(rand(),1)); $password = md5(uniqid(rand(),1)); $password = substr($password,0,8); $expert = $_COOKIE['x']; $signup_referer = $_COOKIE['sr']; $today = date("Y-m-d H:m:s"); $signupform = "bottom"; $downloads_left = 2; $sql = "SELECT * FROM location WHERE INET_ATON('$ip') BETWEEN ip_from AND ip_to LIMIT 1"; $result_sql = mysql_query($sql, $link) or die(mysql_error()); while($rad=mysql_fetch_array($result_sql)) { $ip_country = $rad["country"]; } $ua=getBrowser(); $browser = $ua['name'] . " " . $ua['version']; $platform = $ua['platform']; $query = "INSERT INTO signups(id_secure,first,last,email,password,comment,ip,ip_country,date,ref1,ref2,expert,signup_referer,browser,platform,downloads_left,signupform) VALUES('$id_secure','$first','$last','$email','$password','$comment','$ip','$ip_country','$today','$ref1','$ref2','$expert','$signup_referer','$browser','$platform','$downloads_left','$signupform')"; $result = mysql_query($query, $link) or die(mysql_error()); $id = mysql_insert_id(); $twid = base_convert($id,20,36); $query2 = "UPDATE signups SET twid='$twid' WHERE id='$id'"; $result2 = mysql_query($query2, $link) or die(mysql_error()); $from_email = FROM_EMAIL; $owner = OWNER; $sql="SELECT * FROM letters WHERE id='1'"; $result = mysql_query($sql, $link) or die(mysql_error()); while ($line=mysql_fetch_array($result)) { $headline = $line["headline"]; $messageblock = $line["message"]; $link1 = $line["link1"]; $link2 = $line["link2"]; $link3 = $line["link3"]; } $fil="textdata/email_template.txt"; $filhanterare=fopen($fil, "r"); $message=fread($filhanterare,filesize($fil)); fclose($filhanterare); // Replace info $message = str_replace("[headline]",$headline,$message); $message = str_replace("[message]",$messageblock,$message); $message = str_replace("[link1]",$link1,$message); $message = str_replace("[link2]",$link2,$message); $message = str_replace("[link3]",$link3,$message); $message = str_replace("[id_secure]",$id_secure,$message); $message = str_replace("[name]",$first,$message); $sendmessage = $message; $mailsubject = $headline; $mailcontent = $sendmessage; $mail = new PHPMailer(); $mail->From = $from_email; $mail->FromName = $owner; $mail->AddAddress($email); // $mail->AddBCC($from_email); $mail->IsHTML(true); // set email format to HTML $mail->Subject = $mailsubject; $mail->Body = $mailcontent; if(!$mail->Send()) { echo "Сообщение не может быть отправлено.

"; echo "Mailer Error: " . $mail->ErrorInfo; } else { echo 'Спасибо, за регистрацию на телесаммит.

'; echo "
Мы отправили вам письмо ".$email." о вашей регистрации."; echo "
Пожалуйста, проверьте свою электронную почту.

"; // echo ''; } } } //-------------------------------------------------------------------------------------------- function getBrowser() { $u_agent = $_SERVER['HTTP_USER_AGENT']; $bname = 'Unknown'; $platform = 'Unknown'; $version= ""; //First get the platform? if (preg_match('/linux/i', $u_agent)) { $platform = 'Linux'; } elseif (preg_match('/macintosh|mac os x/i', $u_agent)) { $platform = 'Mac'; } elseif (preg_match('/windows|win32/i', $u_agent)) { $platform = 'Windows'; } // Next get the name of the useragent yes seperately and for good reason if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent)) { $bname = 'Internet Explorer'; $ub = "MSIE"; } elseif(preg_match('/Firefox/i',$u_agent)) { $bname = 'Mozilla Firefox'; $ub = "Firefox"; } elseif(preg_match('/Chrome/i',$u_agent)) { $bname = 'Google Chrome'; $ub = "Chrome"; } elseif(preg_match('/Safari/i',$u_agent)) { $bname = 'Apple Safari'; $ub = "Safari"; } elseif(preg_match('/Opera/i',$u_agent)) { $bname = 'Opera'; $ub = "Opera"; } elseif(preg_match('/Netscape/i',$u_agent)) { $bname = 'Netscape'; $ub = "Netscape"; } // finally get the correct version number $known = array('Version', $ub, 'other'); $pattern = '#(?' . join('|', $known) . ')[/ ]+(?[0-9.|a-zA-Z.]*)#'; if (!preg_match_all($pattern, $u_agent, $matches)) { // we have no matching number just continue } // see how many we have $i = count($matches['browser']); if ($i != 1) { //we will have two since we are not using 'other' argument yet //see if version is before or after the name if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){ $version= $matches['version'][0]; } else { $version= $matches['version'][1]; } } else { $version= $matches['version'][0]; } // check if we have a number if ($version==null || $version=="") {$version="?";} return array( 'userAgent' => $u_agent, 'name' => $bname, 'version' => $version, 'platform' => $platform, 'pattern' => $pattern ); } ?>