مرجع پارسی MyBB

نسخه‌ی کامل: +++مشاهده ای پی افراد در فرم تماس با ما
شما درحال مشاهده‌ی نسخه‌ی متنی این صفحه می‌باشید. مشاهده‌ی نسخه‌ی کامل با قالب‌بندی مناسب.
صفحه‌ها: 1 2
سلام

من یه فرم تماس نصب کردم واسه کاربرانی بخاطر تشابه ای پی محروم شدن بتونن تماس بگیرن با من
کد 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(
"کد امنیتی داخل تصویر را به درستی وارد نکرده اید.");
 }
}
?>


الان میشه بگید چی باید اضافه کنم که ای پی طرف هم برای من ارسال بشه؟؟ الان فقط یه ایمیل و پیام طرف رو ارسال میکنه ممنون میشم راهنمایی کنید
Heart
IP کاربری که صفحه فرم را باز می کند:
کد php:
$_SERVER['REMOTE_ADDR'
ببخشید کد رو باید کجا اضافه کنم؟Blush
تورو خدا یکی کد درست رو بده ، الان هی تند تند پیام میدم من نمیدونم ای پی شون چیه که محروم شدهBlush
دقیقا مثل سایر بخش هایی که در فرم خود ایجاد کرده اید.!
مثلا متغیر IP را به آن نسبت دهید سپس با دستور Post ارسال کنید.

کد php:
$IP $_SERVER['REMOTE_ADDR']; 
معذرت این اسکریپ رو از جایی دانلود کردم و نصب

تغییرات ومتغییرش نمیدونم چیشه

ممنون میشم خودتون در کد اعمال کنیدBlush

کد:

کد 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(
"کد امنیتی داخل تصویر را به درستی وارد نکرده اید.");
 }
}
?>
این کدی که شما دادید مربوط به مرحله ی بعد از پر کردن فرم است!
همش دو فایل داره فایل 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">&nbsp;</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(&quot;resultd&quot;);" 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(urlparameters) {
      
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'urltrue);
      
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($possiblemt_rand(0strlen($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($image20200255);
        
$text_color imagecolorallocate($image2515978);
        
$noise_color imagecolorallocate($image2552555255);
        
/* generate random dots in background */
        
for( $i=0$i<($width*$height)/3$i++ ) {
            
imagefilledellipse($imagemt_rand(0,$width), mt_rand(0,$height), 11$noise_color);
        }
        
/* generate random lines in background */
        
for( $i=0$i<($width*$height)/150$i++ ) {
            
imageline($imagemt_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_size0$this->font$code) or die('Error in imagettfbbox function');
        
$x = ($width $textbox[4])/2;
        
$y = ($height $textbox[5])/2;
        
imagettftext($image$font_size0$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'] > $_GET['characters'] : '6';

$captcha = new CaptchaSecurityImages($width,$height,$characters);

?>
UndecidedUndecidedUndecidedUndecidedUndecidedUndecidedUndecidedUndecidedUndecidedUndecidedBlush
فایل 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">&nbsp;</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(&quot;resultd&quot;);" 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(
"کد امنیتی داخل تصویر را به درستی وارد نکرده اید.");
 }
}
?>
صفحه‌ها: 1 2