init
This commit is contained in:
33
php/functions.php
Normal file
33
php/functions.php
Normal file
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
// Strips nasty tags from code..
|
||||
function cleanEvilTags($data) {
|
||||
$data = preg_replace("/javascript/i", "javascript",$data);
|
||||
$data = preg_replace("/alert/i", "alert",$data);
|
||||
$data = preg_replace("/about:/i", "about:",$data);
|
||||
$data = preg_replace("/onmouseover/i", "onmouseover",$data);
|
||||
$data = preg_replace("/onclick/i", "onclick",$data);
|
||||
$data = preg_replace("/onload/i", "onload",$data);
|
||||
$data = preg_replace("/onsubmit/i", "onsubmit",$data);
|
||||
$data = preg_replace("/<body/i", "<body",$data);
|
||||
$data = preg_replace("/<html/i", "<html",$data);
|
||||
$data = preg_replace("/document\./i", "document.",$data);
|
||||
$data = preg_replace("/<script/i", "<script",$data);
|
||||
return strip_tags(trim($data));
|
||||
}
|
||||
|
||||
// Cleans output data..
|
||||
function cleanData($data) {
|
||||
$data = str_replace(' & ', ' & ', $data);
|
||||
return (get_magic_quotes_gpc() ? stripslashes($data) : $data);
|
||||
}
|
||||
|
||||
function multiDimensionalArrayMap($func,$arr) {
|
||||
$newArr = array();
|
||||
if (!empty($arr)) {
|
||||
foreach($arr AS $key => $value) {
|
||||
$newArr[$key] = (is_array($value) ? multiDimensionalArrayMap($func,$value) : $func($value));
|
||||
}
|
||||
}
|
||||
return $newArr;
|
||||
}
|
||||
48
php/mail.php
Normal file
48
php/mail.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
include 'functions.php';
|
||||
|
||||
if (!empty($_POST)){
|
||||
|
||||
$data['success'] = true;
|
||||
$_POST = multiDimensionalArrayMap('cleanEvilTags', $_POST);
|
||||
$_POST = multiDimensionalArrayMap('cleanData', $_POST);
|
||||
|
||||
//your email adress
|
||||
$emailTo ="yourmail@yoursite.com"; //"yourmail@yoursite.com";
|
||||
|
||||
//from email adress
|
||||
$emailFrom ="contact@yoursite.com"; //"contact@yoursite.com";
|
||||
|
||||
//email subject
|
||||
$emailSubject = "Mail from Porta";
|
||||
|
||||
$name = $_POST["name"];
|
||||
$email = $_POST["email"];
|
||||
$comment = $_POST["comment"];
|
||||
if($name == "")
|
||||
$data['success'] = false;
|
||||
|
||||
if (!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email))
|
||||
$data['success'] = false;
|
||||
|
||||
|
||||
if($comment == "")
|
||||
$data['success'] = false;
|
||||
|
||||
if($data['success'] == true){
|
||||
|
||||
$message = "NAME: $name<br>
|
||||
EMAIL: $email<br>
|
||||
COMMENT: $comment";
|
||||
|
||||
|
||||
$headers = "MIME-Version: 1.0" . "\r\n";
|
||||
$headers .= "Content-type:text/html; charset=utf-8" . "\r\n";
|
||||
$headers .= "From: <$emailFrom>" . "\r\n";
|
||||
mail($emailTo, $emailSubject, $message, $headers);
|
||||
|
||||
$data['success'] = true;
|
||||
echo json_encode($data);
|
||||
}
|
||||
}
|
||||
0
php/newslatter.txt
Normal file
0
php/newslatter.txt
Normal file
21
php/newsletter.php
Normal file
21
php/newsletter.php
Normal file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
if($_POST){
|
||||
|
||||
$fileName = 'newsletter.txt'; //set 777 permision for this file.
|
||||
$error = false;
|
||||
|
||||
$email = $_POST['email'];
|
||||
|
||||
if (!preg_match("/^[_\.0-9a-zA-Z-]+@([0-9a-zA-Z][0-9a-zA-Z-]+\.)+[a-zA-Z]{2,6}$/i", $email))
|
||||
$error = true;
|
||||
|
||||
|
||||
//If all ok, save emali adress in file
|
||||
if($error == false){
|
||||
$file = fopen($fileName, a);
|
||||
fwrite($file, "$email,");
|
||||
fclose($file);
|
||||
echo 'OK';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user