Клубове Дир.бг
powered by diri.bg
търси в Клубове diri.bg Разширено търсене

Вход
Име
Парола

Клубове
Dir.bg
Взаимопомощ
Горещи теми
Компютри и Интернет
Контакти
Култура и изкуство
Мнения
Наука
Политика, Свят
Спорт
Техника
Градове
Религия и мистика
Фен клубове
Хоби, Развлечения
Общества
Я, архивите са живи
Клубове Дирене Регистрация Кой е тук Въпроси Списък Купувам / Продавам 23:10 19.04.24 
Клубове/ Компютри и Интернет / PHP Всички теми Следваща тема Пълен преглед*
Информация за клуба
Тема Re: До KiberZlo [re: Cont]
Автор sashometallico (непознат)
Публикувано26.05.12 02:38  



Преди време писах е това. Виж дали ти върши работа.

Цялата философия да го подкараш е да заместиш mail@example.com с твоя мейл, после да го запишеш като файл с разширение .php и накрая да го качиш.

В отговор на:


<?php
class metallico {
//set form recipent here:
public $to = 'mail@example.com';


public $name, $tel, $ml, $message, $output, $error, $errormsg, $jsemail;


//check mail function
function checkEmail($email){
return ( eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email) );
}



//hide email function:
function hide_email($email) {
$character_set = '+-.0123456789@ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz';
$key = str_shuffle($character_set);
$cipher_text = '';
$id = 'e'.rand(1,999999999);
for ($i=0;$i<strlen($email);$i+=1)
$cipher_text.= $key[strpos($character_set,$email[$i])];
$script = 'var a="'.$key.'";var b=a.split("").sort().join("");var c="'.$cipher_text.'";var d="";';
$script.= 'for(var e=0;e<c.length;e++)d+=b.charAt(a.indexOf(c.charAt(e)));';
$script.= 'document.getElementById("'.$id.'").innerHTML="<a href=\\"mailto:"+d+"\\">"+d+"</a>"';
$script = "eval(\"".str_replace(array("\\",'"'),array("\\\\",'\"'), $script)."\")";
$script = '<script type="text/javascript">/*<![CDATA[*/'.$script.'/*]]>*/</script>';
return '<span id="'.$id.'">[javascript protected email address]</span>'.$script;
}




function validpost($post) {
//check agains each of the posted values


if ( isset($post['name']) ? ( $post['name'] != '' ) && ( strlen($post['name']) > 2 ) : false ) { $this->name = addslashes($post['name']); } else { $this->error[] = 1; };
if ( isset($post['tel']) ? ( $post['tel'] != '' ) && ( strlen($post['tel']) > 2 ) : false ) { $this->tel = addslashes($post['tel']); } else { $this->error[] = 2; };
if ( isset($post['ml']) ? ( $post['ml'] != '' ) && ( strlen($post['ml']) > 2 ) && ($this->checkEmail($post['ml'])) : false ) { $this->ml = addslashes($post['ml']); } else { $this->error[] = 3; };

(isset($post['message']) && $post['message'] != '' ) ? $this->message = addslashes($post['message']) : $this->error[] = 4;

//debug:
//echo 'This function has set $post[\'message\'] as ' . $post['message'] . ' then it has $this->error[] as: <br /> ';
//print_r($this->error);
//echo '<br /> then it has $this->message as ' . $this->message;
//exit();
return ( !isset($this->error) );
}

function displayform() {
$this->output = '
<div id="contactformouter">
<form action="'. $_SERVER["SCRIPT_NAME"] .'" method="POST">
<table>
<tr>
<td><label for="name">Your Name: <span class="required">*</span></label></td>
<td><input type="text" name="name" id="name" class="forminput" /></td>
</tr>

<tr>
<td><label for="tel">Your Tel:</label></td>
<td><input type="text" name="tel" id="tel" class="forminput" /></td>
</tr>

<tr>
<td><label for="ml">Your Email: <span class="required">*</span></label></td>
<td><input type="text" name="ml" id="ml" class="forminput" /></td>
</tr>

<tr>
<td><label for="message">Message: <span class="required">*</span></label></td>
<td>
<textarea rows="10" cols="30" name="message" id="message"></textarea>
</td>
</tr>



<tr>
<td colspan="2" align="right">
<!--<input type="reset" onclick="return confirm(\'Are you sure you wish to reset?\')" />-->
<input type="submit" name="submit" value="Send" class="formbutton" />
</td>
</tr>
</table>
</form>
</div>
';
echo $this->output;
}

function displayerror() {
$this->errormsg = '<div class="problems"><p class="error">Problems were found with the information you entered:</p>';

//set the error message:
(in_array(1, $this->error)) ? $this->errormsg .= '<p class="errordetail">Please enter your name (it must be at least 3 letters).</p>' : false;
(in_array(2, $this->error)) ? $this->errormsg .= '<p class="errordetail">Please enter your telephone number.</p>' : false;
(in_array(3, $this->error)) ? $this->errormsg .= '<p class="errordetail">You have entered an invalid email address. Please enter your email again.</p>' : false;
(in_array(4, $this->error)) ? $this->errormsg .= '<p class="errordetail">You have not entered a message.</p>' : false;

$this->errormsg .= '<p>Please fix the errors above in the form below, or just send us an email on ' . $this->jsemail . ' </p></div>';

$this->output = '
<div id="contactformouter">';
$this->output .= $this->errormsg;
$this->output .= '<form action="'. $_SERVER["SCRIPT_NAME"] .'" method="POST">
<table>
<tr>
<td><label for="name">Your Name: <span class="required">*</span></label></td>
<td><input type="text" name="name" id="name" class="forminput'; (in_array(1, $this->error)) ? $this->output .= ' red"' : $this->output .= '" value="' . $this->name . '"'; $this->output .= ' /></td>
</tr>

<tr>
<td><label for="tel">Your Tel:</label></td>
<td><input type="text" name="tel" id="tel" class="forminput'; (in_array(2, $this->error)) ? $this->output .= ' red"' : $this->output .= '" value="' . $this->tel . '"'; $this->output .= ' /></td>
</tr>

<tr>
<td><label for="ml">Your Email:</label> <span class="required">*</span></td>
<td><input type="text" name="ml" id="ml" class="forminput'; (in_array(3, $this->error)) ? $this->output .= ' red"' : $this->output .= '" value="' . $this->ml . '"'; $this->output .= ' /></td>
</tr>

<tr>
<td><label for="message">Message: <span class="required">*</span></label></td>
<td>
<textarea name="message" id="message" class="formselect'; (in_array(4, $this->error)) ? $this->output .= ' red"' : false; $this->output .= '" cols="30" rows="10"></textarea>
</td>
</tr>
<tr>
<td colspan="2" style="text-align: right;">
<!--<input type="reset" onclick="return confirm(\'Are you sure you wish to reset?\')" />-->
<input type="submit" name="submit" value="Send" class="formbutton" />
</td>
</tr>
</table>
</form>
</div>
';
echo $this->output;

}

function processmail() {
//create the variables for the email:
$subject = 'New enquiry from your website';

//headers:
$headers = "MIME-Version: 1.0\n";
$headers .= "Content-type: text/plain; charset=ISO-8859-1\n";
$headers .= "X-Priority: 3\n";
$headers .= "X-MSMail-Priority: Normal\n";
$headers .= "X-Mailer: php\n";
$headers .= "From: \"".$this->name."\" <".$this->ml.">\n";
$headers .= "Auto-Submitted: auto-generated\n";

//msg:
$msg = "A visitor of your website has just filled in the form. The details are shown below: \n\n";
$msg .= "Name: $this->name \n";
$msg .= "Telephone: $this->tel \n";
$msg .= "Email: $this->ml \n";
$msg .= "Message: $this->message \n";


$msg .= "Metallico Web Mail script, free to use (GNU/GPL).
";

//echo $msg;

//attempt to send the email:
(mail($this->to, $subject, $msg, $headers)) ? $this->output = 'Thank you for your message. We will respond shortly.' : $this->output = 'Your request could not be sent (reason: The PHP mail() function has failed to process the email). Please email us manually at ' . $this->jsemail;

//display result:
echo $this->output;

}


//the init function to be called when the class instance is created:
function __construct() {
$this->jsemail = $this->hide_email($this->to);

if ( isset($_POST["submit"]) ) {

($this->validpost($_POST)) ? $this->processmail() : $this->displayerror();
}
else {
//then display the form:
$this->displayform();
}
}

}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Metallico Form</title>
<!--<link rel="stylesheet" type="text/css" href="style.css" /> -->
</head>
<body>
<?php $classmet = new metallico(); ?>
</body>
</html>




Just trying to help..

Цялата тема
ТемаАвторПубликувано
* Формуляр за обратна връзка Cont   26.04.12 12:44
. * Re: Формуляр за обратна връзка croesus   26.04.12 12:59
. * Re: Формуляр за обратна връзка Cont   26.04.12 13:31
. * Re: Формуляр за обратна връзка croesus   26.04.12 18:06
. * Re: Формуляр за обратна връзка Cont   27.04.12 10:41
. * Re: Формуляр за обратна връзка WMC   28.04.12 19:56
. * Re: Формуляр за обратна връзка KiberZlo   30.04.12 04:18
. * До KiberZlo Cont   02.05.12 17:12
. * Re: До KiberZlo sashometallico   26.05.12 02:38
Клуб :  


Clubs.dir.bg е форум за дискусии. Dir.bg не носи отговорност за съдържанието и достоверността на публикуваните в дискусиите материали.

Никаква част от съдържанието на тази страница не може да бъде репродуцирана, записвана или предавана под каквато и да е форма или по какъвто и да е повод без писменото съгласие на Dir.bg
За Забележки, коментари и предложения ползвайте формата за Обратна връзка | Мобилна версия | Потребителско споразумение
© 2006-2024 Dir.bg Всички права запазени.