Added contact CGI.

This commit is contained in:
Johannes Findeisen 2025-10-09 03:45:42 +02:00
commit 377efd7a86
7 changed files with 92 additions and 8 deletions

View file

@ -5,7 +5,7 @@
<h2 style="display:none;">Navigation</h2>
<ul style="list-style:none;margin-left:0px;text-align:center;">
<li style="display:inline;"><a href="/" style="text-decoration:none;" title="Root" class="home">Root</a>&nbsp;-</li>
<!--<li style="display:inline;">&nbsp;<a href="/contact/" style="text-decoration:none;" title="Contact" class="mail">Contact</a>&nbsp;-</li>-->
<li style="display:inline;">&nbsp;<a href="/contact/" style="text-decoration:none;" title="Contact" class="mail">Contact</a>&nbsp;-</li>
<li style="display:inline;">&nbsp;<a href="/community/code-of-conduct/" style="text-decoration:none;" title="Code of Conduct" class="love">Code of Conduct</a>&nbsp;-</li>
<li style="display:inline;">&nbsp;<a href="/privacy/" style="text-decoration:none;" title="Privacy" class="privacy">Privacy</a>&nbsp;-</li>
<!--<li style="display:inline;">&nbsp;<a href="/search/" style="text-decoration:none;" title="Search" class="search">Search</a>&nbsp;-</li>-->

View file

@ -11,10 +11,8 @@
<link rel="canonical" href="{{ site.url }}{{ page.url | replace:'index.html','' }}">
<link rel="shortcut icon" type="image/png" href="/favicon.png">
<link rel="stylesheet" type="text/css" href="/css/cookieconsent.min.css">
<!--<link rel="stylesheet" type="text/css" href="/css/bootstrap-5.0.2.min.css">-->
<link rel="stylesheet" type="text/css" href="/css/main.css">
<!--<script src="/js/bootstrap-5.0.2.min.js" charset="{{ site.charset }}"></script>-->
<!--<script src="/js/jquery-3.6.4.min.js" charset="{{ site.charset }}"></script>-->
<script src="/js/jquery-3.6.4.min.js" charset="{{ site.charset }}"></script>
<script src="/js/js-cookie-3.0.5.min.js" charset="{{ site.charset }}"></script>
<script src="/js/matomo.min.js" charset="{{ site.charset }}"></script>
</head>

View file

@ -9,7 +9,8 @@
<li><a class="page-link" href="/" style="text-decoration:none;" title="/">/</a></li>
<!-- <li><a class="page-link" href="/about/" style="text-decoration:none;" title="/about/">/about/</a></li>-->
<li><a class="page-link" href="/blog/" style="text-decoration:none;" title="/blog/">/blog/</a></li>
<li><a class="page-link" href="/community/" style="text-decoration:none;" title="/community/">/community/</a></li><!--
<li><a class="page-link" href="/community/" style="text-decoration:none;" title="/community/">/community/</a></li>
<li><a class="page-link" href="/contact/" style="text-decoration:none;" title="/contact/">/contact/</a></li><!--
<li><a class="page-link" href="/development/" style="text-decoration:none;" title="/development/">/development/</a></li>
<li><a class="page-link" href="/documentation/" style="text-decoration:none;" title="/documentation/">/documentation/</a></li>
<li><a class="page-link" href="/examples/" style="text-decoration:none;" title="/examples/">/examples/</a></li>-->

View file

@ -0,0 +1,27 @@
---
permalink: /cgi/challenge/
---
<?php
session_start();
session_set_cookie_params(3600);
date_default_timezone_set("{{ site.timezone }}");
if(isset($_SESSION["one"])) {
unset($_SESSION["one"]);
}
if(isset($_SESSION["two"])) {
unset($_SESSION["two"]);
}
$_SESSION["one"] = rand(0, 9);
$_SESSION["two"] = rand(0, 9);
#$_SESSION["sum"] = $_SESSION["one"] + $_SESSION["two"];
$challenge = $_SESSION["one"] . " + " . $_SESSION["two"];
header('Content-Type: text/plain; charset=utf-8');
echo($challenge);
?>

47
cgi/mail/mail.php Normal file
View file

@ -0,0 +1,47 @@
---
permalink: /cgi/mail/
---
<?php
session_start();
session_set_cookie_params(3600);
date_default_timezone_set("{{ site.timezone }}");
$error = "";
$sum = $_SESSION["one"] + $_SESSION["two"];
if ($_POST["sum"] != $sum) { $error = "{{ site.challenge_error }}"; }
if ($_POST["sum"] == $sum) {
$mailTo = "{{ site.email }}";
$mailAddress = "noreply@{{ site.url_short }}";
if($_POST["email"]) {
$mailAddress = $_POST["email"];
}
$mailHeaders = "From: " . $_POST["name"] . " <" . $mailAddress . ">" . "\r\n" .
"Date: " . date(DATE_RFC822);
$mailSubject = "[{{ site.url_short }}]: No subject!";
if($_POST["subject"]) {
$mailSubject = "[{{ site.url_short }}]: " . $_POST["subject"];
}
$mailBody = $_POST["message"] . "\n\n" . "Website: " . $_POST["website"] . "\nUser Agent: " . $_SERVER['HTTP_USER_AGENT'];
if (!@mail($mailTo, $mailSubject, $mailBody, $mailHeaders)) { $error = "Failed to send mail!"; }
unset($_SESSION["one"]);
unset($_SESSION["two"]);
}
header('Content-Type: text/plain; charset=utf-8');
if ($error=="") {
echo("{{ site.mail_thank_you }}");
} else {
//echo($error . " (". $_POST["sum"] . "/" . $sum . ")");
echo($error);
}
?>

View file

@ -1,18 +1,25 @@
---
layout: page
layout: default
published: true
noToc: true
noDate: true
noPermalink: true
noComments: true
title: /contact/index.fun
subtitle: THIS FORM DOES NOT WORK, USE <a href="mailto:hanez@fun-lang.xyz">EMAIL</a> TO CONTACT ME!
_subtitle: THIS FORM DOES NOT WORK, USE <a href="mailto:hanez@fun-lang.xyz">EMAIL</a> TO CONTACT ME!
description: Contact
permalink: /contact/
tags:
- contact
---
<div class="post">
<header class="post-header">
<h1 class="post-title" id="terminal">{{ site.title }} {{ page.title }}</h1>
<p>{{ page.subtitle }}</p>
</header>
</div>
<script>
function doSubmit() {
$("#loader").removeClass("hidden");

View file

@ -36,11 +36,15 @@ Fun is and will ever be 100% free under the terms of the [Apache-2.0 License](ht
- Joy in coding
- Fun!
### Extras
- PC/SC smart card support builtin (optional)
## Characteristics
- Dynamic and optionally statically typed
- Type safety
- Written in C (C11) and Fun
- Written in C (C99) and Fun
- Internal libs are written with no_camel_case even when written in Fun, except class names
- Only a minimal function set is written in C, and most other core functions and libraries are implemented in Fun