[pelican_comments] Add support comment_system
This commit is contained in:
71
content/vendor/form-comments/commentsubmit.php
vendored
Normal file
71
content/vendor/form-comments/commentsubmit.php
vendored
Normal file
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user