ارسالها: 34
موضوعها: 5
تاریخ عضویت: ۲۰ ارديبهشت ۱۳۹۰
۱۳۹۰/۶/۲، ۲۰:۰۲:۳۸ عصر
(آخرین ویرایش: ۱۳۹۰/۶/۵، ۱۶:۴۷:۲۵ عصر، توسط Karimian.)
سلام
من یه فرم تماس نصب کردم واسه کاربرانی بخاطر تشابه ای پی محروم شدن بتونن تماس بگیرن با من
کد php: <?php session_start(); $yourmail="superstar20.ir@gmail.com"; //---------------------------------- if((isset($_POST["from"]))&&(isset($_POST["msg"]))){ //------------ validation(); //------------ $sender=$_POST["from"]; $pms=$_POST["msg"]; $to=htmlspecialchars($yourmail); $from=htmlspecialchars($sender); $subject=$_POST["sbj"]; $msg=htmlspecialchars($pms); mail($to,$subject,$msg,$from) or die("ایمیل ارسال نشد."); print "".$to."سپاس ، پیام شماارسال شد ، به زودی پیام شما بررسی و پاسخ به ایمیل صحیح که قرار داده ایید ارسال خواهد شد - تنها از پیام مدیریت از ایمیل روبرو ارسال خواهد شد"; }
function validation() { if($_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) { //if security is ok. if((isset($_POST["from"]))&&(isset($_POST["msg"]))){ $sender=$_POST["from"]; $pms=$_POST["msg"]; if(strlen($sender)==0) die("فیلد ایمیل شما خالی است."); if(! strstr($sender,"@")) die("آدرس ایمیلتان معتبر نیست."); if(strlen($pms)==0) die("شما پیامی برای ارسال ننوشتید ."); } } else { die("کد امنیتی داخل تصویر را به درستی وارد نکرده اید."); } } ?>
الان میشه بگید چی باید اضافه کنم که ای پی طرف هم برای من ارسال بشه؟؟ الان فقط یه ایمیل و پیام طرف رو ارسال میکنه ممنون میشم راهنمایی کنید
سپاس شده توسط | |
|
ارسالها: 2,082
موضوعها: 138
تاریخ عضویت: ۷ شهريور ۱۳۸۸
اعتبار:
439
IP کاربری که صفحه فرم را باز می کند:
سپاس شده توسط | Karimian (۱۳۹۰/۶/۲، ۲۲:۲۴:۲۰ عصر) |
|
ارسالها: 34
موضوعها: 5
تاریخ عضویت: ۲۰ ارديبهشت ۱۳۹۰
ببخشید کد رو باید کجا اضافه کنم؟
سپاس شده توسط | |
|
ارسالها: 34
موضوعها: 5
تاریخ عضویت: ۲۰ ارديبهشت ۱۳۹۰
تورو خدا یکی کد درست رو بده ، الان هی تند تند پیام میدم من نمیدونم ای پی شون چیه که محروم شده
سپاس شده توسط | |
|
ارسالها: 2,082
موضوعها: 138
تاریخ عضویت: ۷ شهريور ۱۳۸۸
اعتبار:
439
۱۳۹۰/۶/۳، ۱۶:۴۶:۱۷ عصر
(آخرین ویرایش: ۱۳۹۰/۶/۳، ۱۶:۴۸:۱۸ عصر، توسط Mohammad-Za.)
دقیقا مثل سایر بخش هایی که در فرم خود ایجاد کرده اید.!
مثلا متغیر IP را به آن نسبت دهید سپس با دستور Post ارسال کنید.
کد php: $IP = $_SERVER['REMOTE_ADDR'];
سپاس شده توسط | |
|
ارسالها: 34
موضوعها: 5
تاریخ عضویت: ۲۰ ارديبهشت ۱۳۹۰
معذرت این اسکریپ رو از جایی دانلود کردم و نصب
تغییرات ومتغییرش نمیدونم چیشه
ممنون میشم خودتون در کد اعمال کنید
کد:
کد php: <?php session_start(); $yourmail="superstar20.ir@gmail.com"; //---------------------------------- if((isset($_POST["from"]))&&(isset($_POST["msg"]))){ //------------ validation(); //------------ $sender=$_POST["from"]; $pms=$_POST["msg"]; $to=htmlspecialchars($yourmail); $from=htmlspecialchars($sender); $subject=$_POST["sbj"]; $msg=htmlspecialchars($pms); mail($to,$subject,$msg,$from) or die("ایمیل ارسال نشد."); print "".$to."سپاس ، پیام شماارسال شد ، به زودی پیام شما بررسی و پاسخ به ایمیل صحیح که قرار داده ایید ارسال خواهد شد - تنها از پیام مدیریت از ایمیل روبرو ارسال خواهد شد"; }
function validation() { if($_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) { //if security is ok. if((isset($_POST["from"]))&&(isset($_POST["msg"]))){ $sender=$_POST["from"]; $pms=$_POST["msg"]; if(strlen($sender)==0) die("فیلد ایمیل شما خالی است."); if(! strstr($sender,"@")) die("آدرس ایمیلتان معتبر نیست."); if(strlen($pms)==0) die("شما پیامی برای ارسال ننوشتید ."); } } else { die("کد امنیتی داخل تصویر را به درستی وارد نکرده اید."); } } ?>
سپاس شده توسط | |
|
ارسالها: 2,082
موضوعها: 138
تاریخ عضویت: ۷ شهريور ۱۳۸۸
اعتبار:
439
این کدی که شما دادید مربوط به مرحله ی بعد از پر کردن فرم است!
سپاس شده توسط | |
|
ارسالها: 34
موضوعها: 5
تاریخ عضویت: ۲۰ ارديبهشت ۱۳۹۰
همش دو فایل داره فایل index.php
کد php: <?php //مثال ارسال ایمیل نوشته شده توسط حسین علی نژاد. //Written by Hossein Alinejad //ِDownload from http://www.pcwsoft.com //mail:halinejad@gmail.com session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Ajax Mail Form</title> <style type="text/css"> <!-- .style4 { font-size: 9pt; font-family: "Courier New", Courier, monospace; } .style6 { font-size: 9pt; font-family: Tahoma, Arial; color: #40505E; border: 1pt solid #9DACBF; } .style7 { color: #004F9D; font-family: Tahoma, Arial; font-size: 9pt; } a:link { text-decoration: none; } a:visited { text-decoration: none; color: #004F9D; } a:hover { text-decoration: none; color: #FF3300; } a:active { text-decoration: none; } .ttop { font-family: Tahoma, Arial; font-size: 10pt; font-weight: bold; color: #3B4956; } #Layer1 { position:absolute; left:17px; top:18px; width:41px; height:48px; z-index:1; background-image: url(loading.gif); visibility: hidden; } .style10 {color: #004F9D; font-family: Tahoma, Arial; font-size: 8pt; } a { font-family: Tahoma, Arial; font-size: 8pt; color: #004F9D; } .style11 { color: #4E6272; font-family: Tahoma, Arial; font-size: 8pt; } --> </style> </head> <script language="JavaScript" type="text/javascript" src="post.js"></script> <body > <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" nowrap="nowrap"></td> </tr> <tr> <td align="center"><div class="ttop" id="resultd"></div></td> </tr> <tr> <td nowrap="nowrap"><form id="form1" name="form1" method="post" action=""> <div id="Layer1"></div> <table width="38%" border="0" align="center" cellpadding="0" cellspacing="6"> <tr> <td width="20%" valign="top" nowrap="nowrap" class="style7"><label>From :</label></td> <td colspan="2"><input name="from" type="text" autocomplete=off class="style6" id="from" size="32" /></td> </tr> <tr> <td valign="top" nowrap="nowrap" class="style7">Subject :</td> <td colspan="2"><input name="sbj" type="text" autocomplete=off class="style6" id="sbj" size="32" /></td> </tr> <tr> <td valign="top" nowrap="nowrap" class="style7"><label>Message</label> :</td> <td colspan="2"><textarea name="msg" cols="43" rows="10" class="style6" id="msg"></textarea></td> </tr> <tr> <td class="style7"> </td> <td width="13%"><img src="cc/CaptchaSecurityImages.php" class="style6" /></td> <td width="67%"><table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td nowrap="nowrap"><span class="style10">Enter Security Code Below:</span></td> </tr> <tr> <td><input name="security_code" autocomplete="off" type="text" class="style6" id="security_code" size="20" /></td> </tr> </table></td> </tr> <tr> <td><label></label></td> <td colspan="2"><input id="sb" name="btn" type="button" class="style6" onclick="javascript:get(this.parentNode);off('sb');loading("resultd");" value="Send" /> </td> </tr> </table> </form> </td> </tr> <tr> <td align="center"><span class="style11">P30vel Ajax contact form ,</span> <span class="style10"> Powered by</span> <span class="style11">Eh3an.p <span lang="fa">» </span> P30vel.ir ®</span> <span class="style10">Version 1.1</span></td> </tr> </table> </body> </html>
فایل process_mail.php
کد php: <?php session_start(); $yourmail="ایمیل خود را وارد کنید"; //---------------------------------- if((isset($_POST["from"]))&&(isset($_POST["msg"]))){ //------------ validation(); //------------ $sender=$_POST["from"]; $pms=$_POST["msg"]; $to=htmlspecialchars($yourmail); $from=htmlspecialchars($sender); $subject=$_POST["sbj"]; $msg=htmlspecialchars($pms); mail($to,$subject,$msg,$from) or die("ایمیل ارسال نشد."); print "با تشکر به ایمیل شما به ".$to." ارسال شد.در اولین فرصت رسیدگی خواهد شد"; }
function validation() { if($_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) { //if security is ok. if((isset($_POST["from"]))&&(isset($_POST["msg"]))){ $sender=$_POST["from"]; $pms=$_POST["msg"]; if(strlen($sender)==0) die("فیلد ایمیل شما خالی است."); if(! strstr($sender,"@")) die("آدرس ایمیلتان معتبر نیست."); if(strlen($pms)==0) die("شما پیامی برای ارسال ننوشتید ."); } } else { die("کد امنیتی داخل تصویر را به درستی وارد نکرده اید."); } } ?>
فایل جاوا به نام post
کد php: var http_request = false; function makePOSTRequest(url, parameters) { http_request = false; if (window.XMLHttpRequest) { // Mozilla, Safari,... http_request = new XMLHttpRequest(); if (http_request.overrideMimeType) { // set type accordingly to anticipated content type http_request.overrideMimeType('text/html'); } } else if (window.ActiveXObject) { // IE try { http_request = new ActiveXObject("Msxml2.XMLHTTP"); } catch (e) { try { http_request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {} } } if (!http_request) { alert('Cannot create XMLHTTP instance'); return false; } http_request.onreadystatechange = alertContents; http_request.open('POST', url, true); http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded"); http_request.setRequestHeader("Content-length", parameters.length); http_request.setRequestHeader("Connection", "close"); http_request.send(parameters); }
function alertContents() { if (http_request.readyState == 4) { if (http_request.status == 200) { //alert(http_request.responseText); off('sb'); loading("resultd");//loading result = http_request.responseText; document.getElementById('resultd').innerHTML = result; on('sb'); } else { alert('یک مشکل پیش آمده است.'); } } } function loading(ob) { document.getElementById(ob).innerHTML = '<img src="loading.gif" width="16" height="16" align="absmiddle" /> در حال ارسال...'; } function get(obj) { smail=document.getElementById('from').value; subj=document.getElementById('sbj').value; message=document.getElementById('msg').value; secode=document.getElementById('security_code').value; var poststr = "from=" + smail + "&sbj=" + subj + "&msg=" + message + "&security_code=" + secode; makePOSTRequest('process_mail.php', poststr); } //------------------- function off(itm) { obj1=document.getElementById(itm); obj1.disabled=true; } function on(itm) { obj2=document.getElementById(itm); obj2.disabled=false; }
و یک فایل در فولد cc
به نام CaptchaSecurityImages.php
کد php: <?php session_start();
class CaptchaSecurityImages {
var $font = 'monofont.ttf';
function generateCode($characters) { /* list all possible characters, similar looking characters and vowels have been removed */ $possible = '23456789bcdfghjkmnpqrstvwxyz'; $code = ''; $i = 0; while ($i < $characters) { $code .= substr($possible, mt_rand(0, strlen($possible)-1), 1); $i++; } return $code; }
function CaptchaSecurityImages($width='120',$height='40',$characters='6') { $code = $this->generateCode($characters); /* font size will be 75% of the image height */ $font_size = $height * 0.75; $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream'); /* set the colours */ $background_color = imagecolorallocate($image, 20, 200, 255); $text_color = imagecolorallocate($image, 251, 59, 78); $noise_color = imagecolorallocate($image, 255, 2555, 255); /* generate random dots in background */ for( $i=0; $i<($width*$height)/3; $i++ ) { imagefilledellipse($image, mt_rand(0,$width), mt_rand(0,$height), 1, 1, $noise_color); } /* generate random lines in background */ for( $i=0; $i<($width*$height)/150; $i++ ) { imageline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color); } /* create textbox and add text */ $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function'); $x = ($width - $textbox[4])/2; $y = ($height - $textbox[5])/2; imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Error in imagettftext function'); /* output captcha image to browser */ header('Content-Type: image/jpeg'); imagejpeg($image); imagedestroy($image); $_SESSION['security_code'] = $code; }
}
$width = isset($_GET['width']) ? $_GET['width'] : '120'; $height = isset($_GET['height']) ? $_GET['height'] : '40'; $characters = isset($_GET['characters']) && $_GET['characters'] > 1 ? $_GET['characters'] : '6';
$captcha = new CaptchaSecurityImages($width,$height,$characters);
?>
سپاس شده توسط | |
|
ارسالها: 34
موضوعها: 5
تاریخ عضویت: ۲۰ ارديبهشت ۱۳۹۰
سپاس شده توسط | |
|
ارسالها: 2,082
موضوعها: 138
تاریخ عضویت: ۷ شهريور ۱۳۸۸
اعتبار:
439
۱۳۹۰/۶/۵، ۲۰:۳۰:۲۴ عصر
(آخرین ویرایش: ۱۳۹۰/۶/۵، ۲۲:۵۸:۴۴ عصر، توسط Mohammad-Za.)
فایل index.php
کد php: <?php //مثال ارسال ایمیل نوشته شده توسط حسین علی نژاد. //Written by Hossein Alinejad //ِDownload from http://www.pcwsoft.com //mail:halinejad@gmail.com session_start(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Ajax Mail Form</title> <style type="text/css"> <!-- .style4 { font-size: 9pt; font-family: "Courier New", Courier, monospace; } .style6 { font-size: 9pt; font-family: Tahoma, Arial; color: #40505E; border: 1pt solid #9DACBF; } .style7 { color: #004F9D; font-family: Tahoma, Arial; font-size: 9pt; } a:link { text-decoration: none; } a:visited { text-decoration: none; color: #004F9D; } a:hover { text-decoration: none; color: #FF3300; } a:active { text-decoration: none; } .ttop { font-family: Tahoma, Arial; font-size: 10pt; font-weight: bold; color: #3B4956; } #Layer1 { position:absolute; left:17px; top:18px; width:41px; height:48px; z-index:1; background-image: url(loading.gif); visibility: hidden; } .style10 {color: #004F9D; font-family: Tahoma, Arial; font-size: 8pt; } a { font-family: Tahoma, Arial; font-size: 8pt; color: #004F9D; } .style11 { color: #4E6272; font-family: Tahoma, Arial; font-size: 8pt; } --> </style> </head> <script language="JavaScript" type="text/javascript" src="post.js"></script> <body > <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="center" nowrap="nowrap"></td> </tr> <tr> <td align="center"><div class="ttop" id="resultd"></div></td> </tr> <tr> <td nowrap="nowrap"><form id="form1" name="form1" method="post" action=""> <div id="Layer1"></div> <table width="38%" border="0" align="center" cellpadding="0" cellspacing="6"> <tr> <td width="20%" valign="top" nowrap="nowrap" class="style7"><label>From :</label></td> <td colspan="2"><input name="from" type="text" autocomplete=off class="style6" id="from" size="32" /></td> </tr> <tr> <td valign="top" nowrap="nowrap" class="style7">Subject :</td> <td colspan="2"><input name="sbj" type="text" autocomplete=off class="style6" id="sbj" size="32" /></td> </tr> <tr> <td valign="top" nowrap="nowrap" class="style7"><label>Message</label> :</td> <td colspan="2"><textarea name="msg" cols="43" rows="10" class="style6" id="msg"></textarea></td> </tr> <tr> <td class="style7"> </td> <td width="13%"><img src="cc/CaptchaSecurityImages.php" class="style6" /></td> <td width="67%"><table width="100%" border="0" cellspacing="2" cellpadding="0"> <tr> <td nowrap="nowrap"><span class="style10">Enter Security Code Below:</span></td> </tr> <tr> <td><input name="security_code" autocomplete="off" type="text" class="style6" id="security_code" size="20" /></td> </tr>
</table></td> </tr> <tr> <td><label></label></td> <td colspan="2"><input id="sb" name="btn" type="button" class="style6" onclick="javascript:get(this.parentNode);off('sb');loading("resultd");" value="Send" /> </td> </tr> </table> </form> </td> </tr> <tr> <td align="center"><span class="style11">P30vel Ajax contact form ,</span> <span class="style10"> Powered by</span> <span class="style11">Eh3an.p <span lang="fa">» </span> P30vel.ir ®</span> <span class="style10">Version 1.1</span></td> </tr> </table> </body> </html>
فایل process_mail.php:
کد php: <?php session_start(); $yourmail="ایمیل خود را وارد کنید"; //---------------------------------- if((isset($_POST["from"]))&&(isset($_POST["msg"]))){ //------------ validation(); //------------ $sender=$_POST["from"]; $ip = $_SERVER['REMOTE_ADDR']; $pms=$_POST["msg"]; $to=htmlspecialchars($yourmail); $from=htmlspecialchars($sender); $subject=$_POST["sbj"]; $msg=htmlspecialchars($pms); $message = "$ip \n $msg"; mail($to,$subject,$message,$from) or die("ایمیل ارسال نشد."); print "با تشکر به ایمیل شما به ".$to." ارسال شد.در اولین فرصت رسیدگی خواهد شد"; }
function validation() { if($_SESSION['security_code'] == $_POST['security_code'] && !empty($_SESSION['security_code'] ) ) { //if security is ok. if((isset($_POST["from"]))&&(isset($_POST["msg"]))){ $sender=$_POST["from"]; $pms=$_POST["msg"]; if(strlen($sender)==0) die("فیلد ایمیل شما خالی است."); if(! strstr($sender,"@")) die("آدرس ایمیلتان معتبر نیست."); if(strlen($pms)==0) die("شما پیامی برای ارسال ننوشتید ."); } } else { die("کد امنیتی داخل تصویر را به درستی وارد نکرده اید."); } } ?>
سپاس شده توسط | Karimian (۱۳۹۰/۶/۵، ۲۰:۳۷:۳۷ عصر) |
|
|