aboutsummaryrefslogtreecommitdiffstats
path: root/content/vendor/form-comments/commentsubmit.php
diff options
context:
space:
mode:
Diffstat (limited to 'content/vendor/form-comments/commentsubmit.php')
-rw-r--r--content/vendor/form-comments/commentsubmit.php71
1 files changed, 71 insertions, 0 deletions
diff --git a/content/vendor/form-comments/commentsubmit.php b/content/vendor/form-comments/commentsubmit.php
new file mode 100644
index 0000000..c78e39d
--- /dev/null
+++ b/content/vendor/form-comments/commentsubmit.php
@@ -0,0 +1,71 @@
+<?php
+
+$post_id = $_POST["post_id"];
+$return_url = $_POST["return_url"];
+
+// Slug
+function seourl($string) {
+ //Lower case everything
+ $string = strtolower($string);
+ //Make alphanumeric (removes all other characters)
+ $string = preg_replace("/[^a-z0-9_\s-]/", "", $string);
+ //Clean up multiple dashes or whitespaces
+ $string = preg_replace("/[\s-]+/", " ", $string);
+ //Convert whitespaces and underscore to dash
+ $string = preg_replace("/[\s_]/", "-", $string);
+ return $string;
+}
+
+// Check for empty fields
+if(empty($_POST['name']) ||
+ empty($_POST['comment']) ||
+ empty($_POST['email']) ||
+ !filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)
+)
+{
+ // header( "Location: {$return_url}");
+ header( "Location: ../{$return_url}");
+} else {
+
+ $DATE_FORMAT = "Y-m-d H:i";
+ $publish = date($DATE_FORMAT);
+
+ $name = strip_tags(utf8_decode(htmlspecialchars($_POST['name'])));
+ $link = strip_tags(htmlspecialchars($_POST['link']));
+ $comment = strip_tags(utf8_decode(htmlspecialchars($_POST['comment'])));
+ $email_address = strip_tags(htmlspecialchars($_POST['email']));
+
+ //slug
+ $nslug = seourl($name);
+ $fslug = date("Ymd-H:i:s");
+ $slug = "$nslug-$fslug";
+
+ // Create the email and send the message
+ // Add your email address
+ $to = 'heckyel@riseup.net';
+ $email_subject = <<<EOT
+[conocimientoslibres.tuxfamily.org] Mensaje de {$name}
+EOT;
+
+ $email_body = <<<EOT
+Haz recibido un nuevo comentario del formulario de tu sitio web.\n\n
+Aqui estan los detalles:\n\n
+post_id: {$post_id}\n\n
+Author: {$name}\n\n
+Date: {$publish}\n\n
+Email: {$email_address}\n\n
+Slug: {$slug}\n\n
+Web: {$link}\n\n
+{$comment}
+EOT;
+
+ $headers = "From: noreply@conocimientoslibres.tuxfamily.org\n"; // Using something like noreply@yourdomain.com.
+ $headers .= "Reply-To: $email_address";
+ mail($to,$email_subject,$email_body,$headers);
+
+ // Rediret to current post
+ // header( "Location: {$return_url}");
+ header("Refresh: 10; URL=../{$return_url}");
+ printf('Hurra! %s su comentario se envió correctamente,
+volviendo a la web en 10 segundos...', $name);
+}